groundstate_demo2
Joe Hope and Graham Dennis
Calculate the ground state of the non-linear Schrodinger equation in a harmonic magnetic trap. This is done by evolving it in imaginary time while re-normalising each timestep. We demonstrate calculating the energy, energy per particle, and chemical potential at each time step to monitor the convergence of the imaginary time algorithm.
const real Uint = 1.0e2; const real Nparticles = 1;

/* offset constants */ const real EnergyOffset = pow(pow(3.0*Nparticles/4*Uint,2.0)/2.0,1/3.0); // 1D

t
V1
real Vtrap = 0.5*y*y;

V1 = -i*(Vtrap - EnergyOffset);

phi
if (fabs(y) < 1.0) { phi = 1.0; // This will be automatically normalised later } else { phi = 0.0; }
KE
wavefunction
KE = 0.5*ky*ky*mod2(phi);
VE NLE
potential wavefunction
VE = -Im(V1) * mod2(phi); NLE = 0.5*Uint *mod2(phi) * mod2(phi);
E E_over_N mu
spatial_energy kinetic_energy normalisation
E = KE + VE + NLE; E_over_N = E/Ncalc; mu = (KE + VE + 2.0*NLE) / Ncalc;
Ncalc
wavefunction
// Calculate the current normalisation of the wave function. Ncalc = mod2(phi);
20 20
wavefunction normalisation
// Correct normalisation of the wavefunction phi *= sqrt(Nparticles/Ncalc);
T
T = -0.5*ky*ky;
wavefunction
potential
dphi_dt = T[phi] - (i*V1 + Uint*mod2(phi))*phi;
wavefunction
norm_dens
wavefunction normalisation
norm_dens = mod2(phi)/Ncalc;
ER E_over_NR NR muR
energy normalisation
ER = E; E_over_NR = E_over_N; NR = Ncalc; muR = mu;