The goal of this program is to solve the time dependent Schrodinger equation. Notice this is different than the time independent version
which is an eigenvalue problem.
Let's work in 2 dimensions where our independent variables are
We will use the Crank Nicholson method. Writing everything in terms of operators, we can see the right hand side is really just the hamiltonian operator so now we have
The next step here is to discretize
or
where
As you can see, this problem requires complex variables. One can either code the problem using complex variables, or recast it as a purely real problem. The linear algebra subroutines I wrote are for real numbers only so I will instead make it a purely real problem. We can rewrite
as
This results in 2 coupled equations:
We can write these as block matrices or a "super matrix" if you will. It is a mathematical object that looks like a 2x2 matrix but each element itself is a matrix. So we have:
Therefore if the wave function is discretized as a (complex) vector of length , we replace it with a purely real vector of length
and perform the matrix multiplication:
Since the matrices on the right hand side of the equation contain only constants you can store the result of multiplying the second one by the inverse of the first one and use it to evolve for as many time steps as necessary.
The probability densities are then given by:
We will put the wavefunction in a box from $ -L to L$ and set
The size of the box : length
The number of sample points in : n_points
The number of time steps: n_steps
The size of the time step : delta_t
The width of the Gaussian wave function : width
The center of the Gaussian wave function : center
The oscillator parameter : k_oscillator (For the next part)
A file name for the results as a function of time: time_file
A file name for the results of the probability density: density_file
After reading the input parameters the program will sample the lattice points. This will allow us to set the initial wave function to the Gaussian expressed above. Then the code will construct the time evolution matrix:
Remember that the wave function will be an array of size 2n_points. The first half contains a sampling of the real part of $\vec{\psi^n}$ , while the second half contains a sampling of the imaginary part. For the initial Gaussian (which is purely real) the second half will be all zeros. In the same vein, the time evolution matrix will be a 2n_points by 2*n_points matrix.
Then we can evolve you wave function and store the different snapshots in the time_wave_function array. Then we can calculate the following expectation values for every time step.
Normalization:
Expectation value of position:
Width:
Finally into two different files you will find the results. One file should contain those expectation values (one per column) as a function of time. The second file should contain a few snapshots of the probability density at different times.
The time evolution of the width can actually be computed analytically as:
where is the initial width from the namelist file.
We can confirm that the width grows, initially, according to the analytic prescription. After some time it will deviate because of the wall. We can see this in jupyter.
Now let's throw the wavefunction into a harmonic oscillator where
It would be quite beneficial to you if you had a Linux system because it would enable you to use the makefile included.
If this is the case then what you do is open a terminal, use the cd command to change to this directory.
Then type make.
You'll see some gfortran commands being executed. All of this has created an exectuable file called schrodinger.
In order to run this executable you type ./schrodinger This will make the program compile with default values which produce results of the part of the project with V(x) and k equal to 0. However if you want to run with the harmonic oscillator then do ./schrodinger parameters.namelist which sets k = 1.0.
You can edit the namelist input yourself to see how the output changes, slight deviations in initial conditions can wildly change the graph of the probability densities!
Next you can type jupyter notebook into the terminal to see the graphs of the probability densities and expectation values.






