This is a Julia file that solves a partial differential equation (PDE) using three parts: (1) setting up the PDE, (2) defining the numerical method for solving the PDE, and (3) running the simulation. I will also explain how to use these three parts and provide an example JSON configuration file.
First, we need to define the PDE we want to solve. We can use the DifferentialEquations.jl package to do this. equation.jl
is an example of a setup function that defines a 1D heat equation.
This function takes a configuration file as input and returns an ODEProblem object that specifies the initial conditions, boundary conditions, and PDE to solve.
Next, we need to define the numerical method for solving the PDE. We can use the DifferentialEquations.jl again package for this. function.jl
is an example of a function that defines an explicit Runge-Kutta method for solving the heat equation.
This function takes the same configuration file as the setup function and returns a tuple of a time-stepping method, a spatial discretization method, and an integration method.
Finally, we can run the simulation by combining the PDE problem and the numerical method. We can use the DifferentialEquations.jl package for this as well. solver.jl
is the example of a function that runs the simulation.
This function takes the same configuration file as the setup functions and returns the solution to the PDE.
This file specifies the length of the domain
To use the configuration file, you can load it in your main script using the JSON.jl package:
using JSON
config_file = "config.json"
config = JSON.parsefile(config_file)