##Solving Parabolic PDEs with finite differences methods
The project aims to solve parabolic PDEs, namely the diffusion and Schrodinger equations in 1d and 2d.
This file is instructions to the basic usage of the code. Most classes and functions used, have a thorough doc-sheet as a comment where the parameters and returns are thoroughly described. If someone is interested in such details, he hasn't but to open the files and read the comments on the definitions of functions and classes.
-
The bulk of the code is in diffusion.py and schrodinger.py. There, simulations are defined as python classes and solvers are called as methods of these classes.
-
There are four simulation classes: Diffusion_1d, Diffusion_2d, Schrodinger_1d and Schrodinger_2d. All, except 2D diffusion, use the Crank-Nicolson method to solve the equations using the method .Crank_Nicolson. For 2D diffusion, Euler's method is used instead with .Euler .
-
The utilities.py script, contains useful function such as potentials, initial distributions and wave-packets.
-
All scripts that start with "run" (e.g. run_schrodinger_2D.py) are non-essential. They are examples of runfiles that use the code for some cases. With minor modifications to these, one can explore the full capabilities of the code.
As mentioned before the example runfiles provided can be a good starting point for any application. However, I will outline the process in case someone wants to make his own.
-
It is strongly advised to open the parent (to the files) directory "as a project" with either Spyder (suggested) or PyCharm.
-
Import the class of the desired solver along with anything you need from the utilities script.
-
Instantiate the simulation, e.g. sim = Schrodinger_1d( L = 50., x0=0, T = 10, Nx = 2501, Nt = 10001 )
-
Use the solver method, e.g. u = sim.Crank_Nicolson(lambda x: gaussian_wave_packet_1d(x, lamda=8, center = 10, k0 = 10) , Left_BC = 0., Right_BC = 0., BC_type = 'dirichlet', normalize_input = True, V=0)
-
Plot and/or save results e.g. with matplotlib.
The above example will simulate the propagation of a Gaussian wave-packet.
Note that in many cases, especially in 2D, the program can take significant time to run.