Solver for the Nonlinear Schrodinger equation using the split-operator method as described in the algorithm archive, in an imperative programming style
The wavefunction, trapping function, and timestep (real or imaginary) are all configurable at the top level. Besides finding the lowest energy state of the system, the code also generates a gif animation of the wavefunction through time
Run python3 ./splitop.py to execute the script, which will save the data to the output/ folder
Configurable variables are at the top of the script:
-
XMINandXMAXcontrol the width of the simulation "box" -
REScontrols the resolution of the simulation -
STEP_SIZEcontrols the size of the timestep for the simulation. Lower timestep gives more accuracy, but takes longer -
- To toggle groundstate simulations, add/remove the
-1jconstant ($-\sqrt-1$ ) multiplied with theSTEP_SIZE'
- To toggle groundstate simulations, add/remove the
-
TIMESTEPScontrols the number of iterations to make. IfSTEP_SIZEis decreased for accuracy, it's probably a good idea to increaseTIMESTEPSaccordingly
Some operators can also be configured. Namely,
- The trapping potential operator
Vcan be any trapping function of X, often a polynomial of even degree and positive leading coefficient. -
- The trapping potential defaults to a simple parabola
- The wavefunction
WFCcan also be any function of X, often a spiking function to settle nicely with the trapping potential -
- The wavefunction defaults to a simple shifted gaussian function
Once the data has been generated, the included plot.plt gnuplot script can be run to generate the animation shown above
To run it, just call the script with gnuplot: gnuplot plot.plt.
The output will be placed in the output/ folder alongside the generated data files
- Multiple choices for solver backend:
-
- Fourth Order Runge-Kutta (RK4)
-
- Crank-Nicolson
-
- Iterative Fleck
-
- Operator Exponential Scheme
- Argument parser for simple arguments (not operators)
- Iterative timestep tuning
