Nonlinear time evolution and the GPE

This notebook shows how to use QuSpin to study time evolution. Below we show three examples:

  • imaginary time evolution to find the lowest energy state of the GPE
  • real time evolution with a user-defined function for a non-linear ODE
  • unitary quantum evolution

The Gross-Pitaevskii equation (GPE) describes the physics of weakly-interacting bosonic systems, and is given by $$ i\partial_t\psi_j(t) = -J\left[ \psi_{j-1}(t) + \psi_{j+1}(t)\right] + \frac{1}{2}\kappa_i(j-j_0)^2\psi_j(t) + U|\psi_j(t)|^2\psi_j(t) $$ where $J$ is the hopping matrix element, $\kappa_i$ is the harmonic trap 'frequency' [we use the subindex $i$ to indicate an initial value which will play a role later on], and $U$ -- the interaction strength. The lattice sites are labelled by $j=0,\dots,L-1$, and $j_0$ is the centre of the 1d chain. We set the lattice constant to unity, and use open boundary conditions.

It will prove useful to define the GPE in vectorised form. Let $\vec \psi$ be the vector whose elements are the magnitude of the function $\psi_j$ on every site. The GPE then reduces to $$ i\partial_t\vec{\psi}(t) = H_\mathrm{sp}\vec{\psi}(t) + U \vec{\psi}^*(t)\circ \vec{\psi}(t)\circ \vec{\psi}(t)$$ where $H_\mathrm{sp}$ is a single-particle Hailtonian which contains the hopping term and the armonic potential, and the simbol $\circ$ defines element-wise multiplication: $(\vec\psi\circ\vec\phi)_j = \psi_j\phi_j$.

We start by constructing the single-particle Hamiltonian $H_\mathrm{sp}$. For the sake of saving code, it would be advantageous to view this Hamiltonian as the $t=0$ limit of a more-generic time-dependent Hamiltonian $H_\mathrm{sp}(t)$, which is defined by

$$ H_\mathrm{sp}(t) = -J\sum_{j=0}^{L-2} (a^\dagger_{j+1}a_j + \mathrm{h.c.}) + \frac{1}{2}\kappa_\mathrm{trap}(t)\sum_{j=0}^{L-1}(j-j_0)^2n_j $$$$\kappa_\mathrm{trap}(t)=(\kappa_f-\kappa_i)t/t_\mathrm{ramp}+ \kappa_i $$

In the limit $t=0$, we have $\kappa_\mathrm{trap}(0) = \kappa_i $.

First, we load the required libraries and define the model parameters


In [1]:
from quspin.operators import hamiltonian # Hamiltonians and operators
from quspin.basis import boson_basis_1d # Hilbert space boson basis
from quspin.tools.evolution import evolve
import numpy as np # generic math functions
from six import iteritems # loop over elements of dictionary
import matplotlib.pyplot as plt
#
##### define model parameters #####
L=300 # system size
# calculate centre of chain
if L%2==0:
    j0 = L//2-0.5 # centre of chain
else:
    j0 = L//2 # centre of chain
sites=np.arange(L)-j0 # centred chain sites around zero
# static parameters
J=1.0 # hopping
U=1.0 # Bose-Hubbard interaction strength
# dynamic parameters
kappa_trap_i=0.001 # initial chemical potential
kappa_trap_f=0.0001 # final chemical potential
t_ramp=40.0/J # set total ramp time
# ramp protocol
def ramp(t,kappa_trap_i,kappa_trap_f,t_ramp):
    return  (kappa_trap_f - kappa_trap_i)*t/t_ramp + kappa_trap_i
# ramp protocol parameters
ramp_args=[kappa_trap_i,kappa_trap_f,t_ramp]

where we defined the function ramp() as the protocol $\kappa_\mathrm{trap}(t)$. Pay special attention to its arguments: the first argument must necessarily be the time $t$, followerd by all optional arguments (the parameters). These same parameters are then stored in the variable ramp_args.

Defining the static part of the Hamiltonian is straightforward and proceeds as before. However, due to the time dependence of $H_\mathrm{sp}(t)$, we now use a non-empty dynamic list. The structure of dynamic lists is similar to that of static lists: first comes the operator string, then the corresponding site-coupling list. The new thing is that we also need to parse the time-dependent function ramp, and its arguments ramp_args.


In [2]:
##### construct single-particle Hamiltonian #####
# define site-coupling lists
hopping=[[-J,i,(i+1)%L] for i in range(L-1)]
trap=[[0.5*(i-j0)**2,i] for i in range(L)]
# define static and dynamic lists
static=[["+-",hopping],["-+",hopping]]
dynamic=[['n',trap,ramp,ramp_args]] # <-- definition of dyamic lists
# define basis
basis = boson_basis_1d(L,Nb=1,sps=2)
# build Hamiltonian
Hsp=hamiltonian(static,dynamic,basis=basis,dtype=np.float64)
E,V=Hsp.eigsh(time=0.0,k=1,which='SA')


Hermiticity check passed!
Symmetry checks passed!
Particle conservation check passed!

Imaginary Time Evolution

Let us set $t=0$ and consider the GPE for the initial trap parameter $\kappa_i=\kappa_\mathrm{trap}(0)$. The ground state of the single-particle Hamiltonian $H_\mathrm{sp}(t=0)$ is squeezed due to the trap. However, repulsive interactions have an opposite effect trying to push the particles apart. Thus, the true state of the system is a compromise of hte two effects.

Our first goal is to find the GS of the GPE, which is formally defined as the state of minimal energy: $$\vec\psi_\mathrm{GS} = \inf_{\vec{\psi}} \bigg( \vec{\psi}^t H_\mathrm{sp}(t=0)\vec{\psi} + \frac{U}{2}\sum_{j=0}^{L-1}|\psi_j|^4\bigg)$$

One way to find the configuration $\vec\psi_\mathrm{GS}$, is to solve the GPE in imaginary time ($it\to \tau$), which induces exponential decay in all modes of the system, except for the lowest-energy state. In doing so, we keep the norm of the solution fixed: $$\partial_{\tau}\vec\varphi(\tau) = -\bigg[H_\mathrm{sp}(0)\vec\varphi(\tau) + U \vec\varphi^*(\tau)\circ \vec\varphi(\tau)\circ \vec\varphi(\tau)\bigg],\qquad ||\vec\varphi(\tau)||=\mathrm{const.}$$ $$\vec{\psi}_\mathrm{GS} = \lim_{\tau\to\infty}\vec\varphi(\tau)$$

Any initial value problem requires us to pick an initial state. In the case of imaginary evolution, this state can often be arbitrary, but needs to possess the same symmetries as the true GPE ground state. Here, we choose the ground state of the single-particle Hamiltonian for an initial state, and normalise it to one particle per site. We also define the imaginary time vector tau. This array has to contain sufficiently long times so that we make sure we obtain the long imaginary time limit $\tau\to\infty$. Since imaginary time evolution is not unitary, QuSpin will be normalising the vector every $\tau$-step. Thus, one also needs to make sure these steps are small enough to avoid convergence problems of the ODE solver.

Performing imaginary time evolution is done using the evolve() method of the measurements tool. This function accepts an initial state phi0, initial time tau[0], and a time vector tau and solves the user-defined ODE GPE_imag_time. The first two arguments of this user-defined ODE function must be the time variable and the state. The parameters of the ODE are passed using the keyword argument f_params=GPE_params. To ensure the normalisation of the state at each $\tau$-step we use the flag imag_time=True. Real-valued output can be specified by real=True. Last, we request evolve() to create a generator object using the keyword argument iterate=True. Many of the keyword arguments of evolve() are the same as in the H.evolve() method of the hamiltonian class: for instance, one can choose a specific SciPy solver and its arguments, or the solver's absolute and relative tolerance.

Last, looping over the generator phi_tau we have access to the solution, which we display in a form of a movie:


In [3]:
#########################################################
##### imaginary-time evolution to compute GS of GPE #####
################################################### ######
def GPE_imag_time(tau,phi,Hsp,U):
    """
    This function solves the real-valued GPE in imaginary time:
    $$ -\dot\phi(\tau) = Hsp(t=0)\phi(\tau) + U |\phi(\tau)|^2 \phi(\tau) $$
    """
    return -( Hsp.dot(phi,time=0) + U*np.abs(phi)**2*phi )
# define ODE parameters
GPE_params = (Hsp,U)
# define initial state to flow to GS from
phi0=V[:,0]*np.sqrt(L) # initial state normalised to 1 particle per site
# define imaginary time vector
tau=np.linspace(0.0,35.0,71)
# evolve state in imaginary time
psi_tau = evolve(phi0,tau[0],tau,GPE_imag_time,f_params=GPE_params,imag_time=True,real=True,iterate=True)
#
# display state evolution
for i,psi0 in enumerate(psi_tau):
    # compute energy
    E_GS=(Hsp.matrix_ele(psi0,psi0,time=0) + 0.5*U*np.sum(np.abs(psi0)**4) ).real
    print('$J\\tau=%0.2f,\\ E_\\mathrm{GS}(\\tau)=%0.4fJ$'%(tau[i],E_GS) )


$J\tau=0.00,\ E_\mathrm{GS}(\tau)=2095.4510J$
$J\tau=0.50,\ E_\mathrm{GS}(\tau)=864.1360J$
$J\tau=1.00,\ E_\mathrm{GS}(\tau)=551.3869J$
$J\tau=1.50,\ E_\mathrm{GS}(\tau)=395.5782J$
$J\tau=2.00,\ E_\mathrm{GS}(\tau)=298.5153J$
$J\tau=2.50,\ E_\mathrm{GS}(\tau)=231.0927J$
$J\tau=3.00,\ E_\mathrm{GS}(\tau)=181.1400J$
$J\tau=3.50,\ E_\mathrm{GS}(\tau)=142.5232J$
$J\tau=4.00,\ E_\mathrm{GS}(\tau)=111.7613J$
$J\tau=4.50,\ E_\mathrm{GS}(\tau)=86.7082J$
$J\tau=5.00,\ E_\mathrm{GS}(\tau)=65.9578J$
$J\tau=5.50,\ E_\mathrm{GS}(\tau)=48.5440J$
$J\tau=6.00,\ E_\mathrm{GS}(\tau)=33.7774J$
$J\tau=6.50,\ E_\mathrm{GS}(\tau)=21.1510J$
$J\tau=7.00,\ E_\mathrm{GS}(\tau)=10.2816J$
$J\tau=7.50,\ E_\mathrm{GS}(\tau)=0.8739J$
$J\tau=8.00,\ E_\mathrm{GS}(\tau)=-7.3046J$
$J\tau=8.50,\ E_\mathrm{GS}(\tau)=-14.4398J$
$J\tau=9.00,\ E_\mathrm{GS}(\tau)=-20.6824J$
$J\tau=9.50,\ E_\mathrm{GS}(\tau)=-26.1563J$
$J\tau=10.00,\ E_\mathrm{GS}(\tau)=-30.9646J$
$J\tau=10.50,\ E_\mathrm{GS}(\tau)=-35.1936J$
$J\tau=11.00,\ E_\mathrm{GS}(\tau)=-38.9168J$
$J\tau=11.50,\ E_\mathrm{GS}(\tau)=-42.1966J$
$J\tau=12.00,\ E_\mathrm{GS}(\tau)=-45.0870J$
$J\tau=12.50,\ E_\mathrm{GS}(\tau)=-47.6346J$
$J\tau=13.00,\ E_\mathrm{GS}(\tau)=-49.8799J$
$J\tau=13.50,\ E_\mathrm{GS}(\tau)=-51.8583J$
$J\tau=14.00,\ E_\mathrm{GS}(\tau)=-53.6010J$
$J\tau=14.50,\ E_\mathrm{GS}(\tau)=-55.1354J$
$J\tau=15.00,\ E_\mathrm{GS}(\tau)=-56.4856J$
$J\tau=15.50,\ E_\mathrm{GS}(\tau)=-57.6729J$
$J\tau=16.00,\ E_\mathrm{GS}(\tau)=-58.7163J$
$J\tau=16.50,\ E_\mathrm{GS}(\tau)=-59.6325J$
$J\tau=17.00,\ E_\mathrm{GS}(\tau)=-60.4365J$
$J\tau=17.50,\ E_\mathrm{GS}(\tau)=-61.1414J$
$J\tau=18.00,\ E_\mathrm{GS}(\tau)=-61.7590J$
$J\tau=18.50,\ E_\mathrm{GS}(\tau)=-62.2996J$
$J\tau=19.00,\ E_\mathrm{GS}(\tau)=-62.7724J$
$J\tau=19.50,\ E_\mathrm{GS}(\tau)=-63.1857J$
$J\tau=20.00,\ E_\mathrm{GS}(\tau)=-63.5467J$
$J\tau=20.50,\ E_\mathrm{GS}(\tau)=-63.8617J$
$J\tau=21.00,\ E_\mathrm{GS}(\tau)=-64.1365J$
$J\tau=21.50,\ E_\mathrm{GS}(\tau)=-64.3760J$
$J\tau=22.00,\ E_\mathrm{GS}(\tau)=-64.5846J$
$J\tau=22.50,\ E_\mathrm{GS}(\tau)=-64.7663J$
$J\tau=23.00,\ E_\mathrm{GS}(\tau)=-64.9244J$
$J\tau=23.50,\ E_\mathrm{GS}(\tau)=-65.0620J$
$J\tau=24.00,\ E_\mathrm{GS}(\tau)=-65.1816J$
$J\tau=24.50,\ E_\mathrm{GS}(\tau)=-65.2856J$
$J\tau=25.00,\ E_\mathrm{GS}(\tau)=-65.3761J$
$J\tau=25.50,\ E_\mathrm{GS}(\tau)=-65.4547J$
$J\tau=26.00,\ E_\mathrm{GS}(\tau)=-65.5230J$
$J\tau=26.50,\ E_\mathrm{GS}(\tau)=-65.5824J$
$J\tau=27.00,\ E_\mathrm{GS}(\tau)=-65.6340J$
$J\tau=27.50,\ E_\mathrm{GS}(\tau)=-65.6788J$
$J\tau=28.00,\ E_\mathrm{GS}(\tau)=-65.7178J$
$J\tau=28.50,\ E_\mathrm{GS}(\tau)=-65.7517J$
$J\tau=29.00,\ E_\mathrm{GS}(\tau)=-65.7812J$
$J\tau=29.50,\ E_\mathrm{GS}(\tau)=-65.8069J$
$J\tau=30.00,\ E_\mathrm{GS}(\tau)=-65.8292J$
$J\tau=30.50,\ E_\mathrm{GS}(\tau)=-65.8486J$
$J\tau=31.00,\ E_\mathrm{GS}(\tau)=-65.8655J$
$J\tau=31.50,\ E_\mathrm{GS}(\tau)=-65.8803J$
$J\tau=32.00,\ E_\mathrm{GS}(\tau)=-65.8931J$
$J\tau=32.50,\ E_\mathrm{GS}(\tau)=-65.9043J$
$J\tau=33.00,\ E_\mathrm{GS}(\tau)=-65.9141J$
$J\tau=33.50,\ E_\mathrm{GS}(\tau)=-65.9226J$
$J\tau=34.00,\ E_\mathrm{GS}(\tau)=-65.9300J$
$J\tau=34.50,\ E_\mathrm{GS}(\tau)=-65.9365J$
$J\tau=35.00,\ E_\mathrm{GS}(\tau)=-65.9421J$

Real Time Evolution with User-Specified ODE

Next, we use our GPE ground state, to time-evolve it in real time according to the trap widening protocol $\kappa_\mathrm{trap}(t)$ hard-coded into the single-particle Hamiltonian $H_\mathrm{sp}(t)$. We proceed analogously -- first we define the real-time GPE and the time vector. In defining the GPE function, we split the ODE into a time-independent static part and a time-dependent dynamic part. The single-particle Hamiltonian for the former is accessed using the hamiltonian attribute Hsp.static which returns a sparse matrix. We can then manually add the non-linear cubic mean-field interaction term. In order to access the time-dependent part of the Hamiltonian, and evaluate it, we loop over the dynamic list Hsp.dynamic, reading off the corresponding sparse matrix Hd together with the time-dependent function f which multiplies it, and its arguments f_args. Last, we multiply the final output vector by the Schr\"odinger $-i$, which ensures the unitarity of for real-time evolution.

To perform real-time evolution we once again use the evolve() function. This time, however, since the solution of the GPE is anticipated to be complex-valued, and because we do not do imaginary time, we do not need to pass the flags real and imag_time. Instead, we decided to show the flags for the relative and absolute tolerance of the solver.


In [4]:
#########################################################
############## real-time evolution of GPE ###############
#########################################################
def GPE(time,psi):
    """
    This function solves the complex-valued time-dependent GPE:
    $$ i\dot\psi(t) = Hsp(t)\psi(t) + U |\psi(t)|^2 \psi(t) $$
    """
    # solve static part of GPE
    psi_dot = Hsp.static.dot(psi) + U*np.abs(psi)**2*psi
    # solve dynamic part of GPE
    for f,Hd in iteritems(Hsp.dynamic):
        psi_dot += f(time)*Hd.dot(psi)
    return -1j*psi_dot
# define real time vector
t=np.linspace(0.0,t_ramp,101)
# time-evolve state according to GPE
psi_t = evolve(psi0,t[0],t,GPE,iterate=True,atol=1E-12,rtol=1E-12)
#
# display state evolution
for i,psi in enumerate(psi_t):
    # compute energy
    E=(Hsp.matrix_ele(psi,psi,time=t[i]) + 0.5*U*np.sum(np.abs(psi)**4) ).real
    print('$Jt=%0.2f,\\ E(t)-E_\\mathrm{GS}=%0.4fJ$'%(t[i],E-E_GS) )


$Jt=0.00,\ E(t)-E_\mathrm{GS}=-0.0000J$
$Jt=0.40,\ E(t)-E_\mathrm{GS}=-1.2925J$
$Jt=0.80,\ E(t)-E_\mathrm{GS}=-2.5853J$
$Jt=1.20,\ E(t)-E_\mathrm{GS}=-3.8787J$
$Jt=1.60,\ E(t)-E_\mathrm{GS}=-5.1731J$
$Jt=2.00,\ E(t)-E_\mathrm{GS}=-6.4687J$
$Jt=2.40,\ E(t)-E_\mathrm{GS}=-7.7658J$
$Jt=2.80,\ E(t)-E_\mathrm{GS}=-9.0649J$
$Jt=3.20,\ E(t)-E_\mathrm{GS}=-10.3663J$
$Jt=3.60,\ E(t)-E_\mathrm{GS}=-11.6702J$
$Jt=4.00,\ E(t)-E_\mathrm{GS}=-12.9771J$
$Jt=4.40,\ E(t)-E_\mathrm{GS}=-14.2872J$
$Jt=4.80,\ E(t)-E_\mathrm{GS}=-15.6011J$
$Jt=5.20,\ E(t)-E_\mathrm{GS}=-16.9190J$
$Jt=5.60,\ E(t)-E_\mathrm{GS}=-18.2412J$
$Jt=6.00,\ E(t)-E_\mathrm{GS}=-19.5683J$
$Jt=6.40,\ E(t)-E_\mathrm{GS}=-20.9005J$
$Jt=6.80,\ E(t)-E_\mathrm{GS}=-22.2383J$
$Jt=7.20,\ E(t)-E_\mathrm{GS}=-23.5820J$
$Jt=7.60,\ E(t)-E_\mathrm{GS}=-24.9320J$
$Jt=8.00,\ E(t)-E_\mathrm{GS}=-26.2887J$
$Jt=8.40,\ E(t)-E_\mathrm{GS}=-27.6525J$
$Jt=8.80,\ E(t)-E_\mathrm{GS}=-29.0238J$
$Jt=9.20,\ E(t)-E_\mathrm{GS}=-30.4030J$
$Jt=9.60,\ E(t)-E_\mathrm{GS}=-31.7905J$
$Jt=10.00,\ E(t)-E_\mathrm{GS}=-33.1868J$
$Jt=10.40,\ E(t)-E_\mathrm{GS}=-34.5921J$
$Jt=10.80,\ E(t)-E_\mathrm{GS}=-36.0070J$
$Jt=11.20,\ E(t)-E_\mathrm{GS}=-37.4318J$
$Jt=11.60,\ E(t)-E_\mathrm{GS}=-38.8670J$
$Jt=12.00,\ E(t)-E_\mathrm{GS}=-40.3129J$
$Jt=12.40,\ E(t)-E_\mathrm{GS}=-41.7701J$
$Jt=12.80,\ E(t)-E_\mathrm{GS}=-43.2388J$
$Jt=13.20,\ E(t)-E_\mathrm{GS}=-44.7195J$
$Jt=13.60,\ E(t)-E_\mathrm{GS}=-46.2127J$
$Jt=14.00,\ E(t)-E_\mathrm{GS}=-47.7187J$
$Jt=14.40,\ E(t)-E_\mathrm{GS}=-49.2380J$
$Jt=14.80,\ E(t)-E_\mathrm{GS}=-50.7710J$
$Jt=15.20,\ E(t)-E_\mathrm{GS}=-52.3181J$
$Jt=15.60,\ E(t)-E_\mathrm{GS}=-53.8798J$
$Jt=16.00,\ E(t)-E_\mathrm{GS}=-55.4565J$
$Jt=16.40,\ E(t)-E_\mathrm{GS}=-57.0485J$
$Jt=16.80,\ E(t)-E_\mathrm{GS}=-58.6563J$
$Jt=17.20,\ E(t)-E_\mathrm{GS}=-60.2804J$
$Jt=17.60,\ E(t)-E_\mathrm{GS}=-61.9211J$
$Jt=18.00,\ E(t)-E_\mathrm{GS}=-63.5790J$
$Jt=18.40,\ E(t)-E_\mathrm{GS}=-65.2543J$
$Jt=18.80,\ E(t)-E_\mathrm{GS}=-66.9476J$
$Jt=19.20,\ E(t)-E_\mathrm{GS}=-68.6592J$
$Jt=19.60,\ E(t)-E_\mathrm{GS}=-70.3897J$
$Jt=20.00,\ E(t)-E_\mathrm{GS}=-72.1394J$
$Jt=20.40,\ E(t)-E_\mathrm{GS}=-73.9087J$
$Jt=20.80,\ E(t)-E_\mathrm{GS}=-75.6981J$
$Jt=21.20,\ E(t)-E_\mathrm{GS}=-77.5080J$
$Jt=21.60,\ E(t)-E_\mathrm{GS}=-79.3389J$
$Jt=22.00,\ E(t)-E_\mathrm{GS}=-81.1912J$
$Jt=22.40,\ E(t)-E_\mathrm{GS}=-83.0652J$
$Jt=22.80,\ E(t)-E_\mathrm{GS}=-84.9615J$
$Jt=23.20,\ E(t)-E_\mathrm{GS}=-86.8804J$
$Jt=23.60,\ E(t)-E_\mathrm{GS}=-88.8225J$
$Jt=24.00,\ E(t)-E_\mathrm{GS}=-90.7881J$
$Jt=24.40,\ E(t)-E_\mathrm{GS}=-92.7777J$
$Jt=24.80,\ E(t)-E_\mathrm{GS}=-94.7917J$
$Jt=25.20,\ E(t)-E_\mathrm{GS}=-96.8306J$
$Jt=25.60,\ E(t)-E_\mathrm{GS}=-98.8948J$
$Jt=26.00,\ E(t)-E_\mathrm{GS}=-100.9848J$
$Jt=26.40,\ E(t)-E_\mathrm{GS}=-103.1010J$
$Jt=26.80,\ E(t)-E_\mathrm{GS}=-105.2438J$
$Jt=27.20,\ E(t)-E_\mathrm{GS}=-107.4137J$
$Jt=27.60,\ E(t)-E_\mathrm{GS}=-109.6112J$
$Jt=28.00,\ E(t)-E_\mathrm{GS}=-111.8367J$
$Jt=28.40,\ E(t)-E_\mathrm{GS}=-114.0906J$
$Jt=28.80,\ E(t)-E_\mathrm{GS}=-116.3736J$
$Jt=29.20,\ E(t)-E_\mathrm{GS}=-118.6859J$
$Jt=29.60,\ E(t)-E_\mathrm{GS}=-121.0281J$
$Jt=30.00,\ E(t)-E_\mathrm{GS}=-123.4007J$
$Jt=30.40,\ E(t)-E_\mathrm{GS}=-125.8042J$
$Jt=30.80,\ E(t)-E_\mathrm{GS}=-128.2389J$
$Jt=31.20,\ E(t)-E_\mathrm{GS}=-130.7055J$
$Jt=31.60,\ E(t)-E_\mathrm{GS}=-133.2044J$
$Jt=32.00,\ E(t)-E_\mathrm{GS}=-135.7361J$
$Jt=32.40,\ E(t)-E_\mathrm{GS}=-138.3011J$
$Jt=32.80,\ E(t)-E_\mathrm{GS}=-140.9000J$
$Jt=33.20,\ E(t)-E_\mathrm{GS}=-143.5332J$
$Jt=33.60,\ E(t)-E_\mathrm{GS}=-146.2012J$
$Jt=34.00,\ E(t)-E_\mathrm{GS}=-148.9047J$
$Jt=34.40,\ E(t)-E_\mathrm{GS}=-151.6441J$
$Jt=34.80,\ E(t)-E_\mathrm{GS}=-154.4199J$
$Jt=35.20,\ E(t)-E_\mathrm{GS}=-157.2328J$
$Jt=35.60,\ E(t)-E_\mathrm{GS}=-160.0833J$
$Jt=36.00,\ E(t)-E_\mathrm{GS}=-162.9719J$
$Jt=36.40,\ E(t)-E_\mathrm{GS}=-165.8992J$
$Jt=36.80,\ E(t)-E_\mathrm{GS}=-168.8659J$
$Jt=37.20,\ E(t)-E_\mathrm{GS}=-171.8725J$
$Jt=37.60,\ E(t)-E_\mathrm{GS}=-174.9195J$
$Jt=38.00,\ E(t)-E_\mathrm{GS}=-178.0077J$
$Jt=38.40,\ E(t)-E_\mathrm{GS}=-181.1377J$
$Jt=38.80,\ E(t)-E_\mathrm{GS}=-184.3099J$
$Jt=39.20,\ E(t)-E_\mathrm{GS}=-187.5253J$
$Jt=39.60,\ E(t)-E_\mathrm{GS}=-190.7842J$
$Jt=40.00,\ E(t)-E_\mathrm{GS}=-194.0875J$

Real Time Evolution under a Hamiltonian

The last example we show demonstrates how to use the hamiltonian class method evolve(), which is almost the same as the measurement function evolve(). The idea behind it is that any Hamiltonian, defins a unique unitary evolution through the Schroedinger equation.

Suppose we put aside the GPE altogether, setting $U=0$. We ask the question how does the GPE GS (obtained via imaginary time evolution) evolve under the free Hamiltonian $H_\mathrm{sp}(t)$ which widens thr trap.

Below, we show how to evolve the GPE ground state under the single-particle Hamiltonian, which des not know about the interactions. This can be though of as quenching the interaction strength $U$ to zero and observing the time evolution of the state in a slowly changing harmonic trap. More precisely, we want to solve the linear initial value problem

$$ i\partial_t\vec{\psi}(t) = H_\mathrm{sp}(t)\vec{\psi}(t),\ \ \ \vec \psi(0) = \vec\psi_\mathrm{GS} $$

This time, there is no need for a user-defined function for the ODE -- Schroedinger's equation (in real and imaginary time) is provided in QuSpin by default.


In [5]:
#######################################################################################
##### quantum real time evolution from GS of GPE with single-particle Hamiltonian #####
#######################################################################################
# define real time vector
t=np.linspace(0.0,2*t_ramp,101)
# time-evolve state according to linear Hamiltonian Hsp (no need to define a GPE)
psi_sp_t = Hsp.evolve(psi0,t[0],t,iterate=True,atol=1E-12,rtol=1E-12)
#
# display state evolution
for i,psi in enumerate(psi_sp_t):
    # compute energy
    E=Hsp.matrix_ele(psi,psi,time=t[i]).real
    print('$Jt=%0.2f,\\ E(t)-E_\\mathrm{GS}=%0.4fJ$'%(t[i],E-E_GS) )


$Jt=0.00,\ E(t)-E_\mathrm{GS}=-390.2907J$
$Jt=0.80,\ E(t)-E_\mathrm{GS}=-392.8745J$
$Jt=1.60,\ E(t)-E_\mathrm{GS}=-395.4518J$
$Jt=2.40,\ E(t)-E_\mathrm{GS}=-398.0162J$
$Jt=3.20,\ E(t)-E_\mathrm{GS}=-400.5615J$
$Jt=4.00,\ E(t)-E_\mathrm{GS}=-403.0818J$
$Jt=4.80,\ E(t)-E_\mathrm{GS}=-405.5714J$
$Jt=5.60,\ E(t)-E_\mathrm{GS}=-408.0248J$
$Jt=6.40,\ E(t)-E_\mathrm{GS}=-410.4371J$
$Jt=7.20,\ E(t)-E_\mathrm{GS}=-412.8033J$
$Jt=8.00,\ E(t)-E_\mathrm{GS}=-415.1192J$
$Jt=8.80,\ E(t)-E_\mathrm{GS}=-417.3806J$
$Jt=9.60,\ E(t)-E_\mathrm{GS}=-419.5838J$
$Jt=10.40,\ E(t)-E_\mathrm{GS}=-421.7255J$
$Jt=11.20,\ E(t)-E_\mathrm{GS}=-423.8026J$
$Jt=12.00,\ E(t)-E_\mathrm{GS}=-425.8125J$
$Jt=12.80,\ E(t)-E_\mathrm{GS}=-427.7530J$
$Jt=13.60,\ E(t)-E_\mathrm{GS}=-429.6222J$
$Jt=14.40,\ E(t)-E_\mathrm{GS}=-431.4184J$
$Jt=15.20,\ E(t)-E_\mathrm{GS}=-433.1405J$
$Jt=16.00,\ E(t)-E_\mathrm{GS}=-434.7875J$
$Jt=16.80,\ E(t)-E_\mathrm{GS}=-436.3588J$
$Jt=17.60,\ E(t)-E_\mathrm{GS}=-437.8541J$
$Jt=18.40,\ E(t)-E_\mathrm{GS}=-439.2735J$
$Jt=19.20,\ E(t)-E_\mathrm{GS}=-440.6170J$
$Jt=20.00,\ E(t)-E_\mathrm{GS}=-441.8854J$
$Jt=20.80,\ E(t)-E_\mathrm{GS}=-443.0792J$
$Jt=21.60,\ E(t)-E_\mathrm{GS}=-444.1996J$
$Jt=22.40,\ E(t)-E_\mathrm{GS}=-445.2477J$
$Jt=23.20,\ E(t)-E_\mathrm{GS}=-446.2249J$
$Jt=24.00,\ E(t)-E_\mathrm{GS}=-447.1328J$
$Jt=24.80,\ E(t)-E_\mathrm{GS}=-447.9732J$
$Jt=25.60,\ E(t)-E_\mathrm{GS}=-448.7480J$
$Jt=26.40,\ E(t)-E_\mathrm{GS}=-449.4592J$
$Jt=27.20,\ E(t)-E_\mathrm{GS}=-450.1091J$
$Jt=28.00,\ E(t)-E_\mathrm{GS}=-450.6999J$
$Jt=28.80,\ E(t)-E_\mathrm{GS}=-451.2343J$
$Jt=29.60,\ E(t)-E_\mathrm{GS}=-451.7145J$
$Jt=30.40,\ E(t)-E_\mathrm{GS}=-452.1435J$
$Jt=31.20,\ E(t)-E_\mathrm{GS}=-452.5237J$
$Jt=32.00,\ E(t)-E_\mathrm{GS}=-452.8580J$
$Jt=32.80,\ E(t)-E_\mathrm{GS}=-453.1494J$
$Jt=33.60,\ E(t)-E_\mathrm{GS}=-453.4006J$
$Jt=34.40,\ E(t)-E_\mathrm{GS}=-453.6146J$
$Jt=35.20,\ E(t)-E_\mathrm{GS}=-453.7945J$
$Jt=36.00,\ E(t)-E_\mathrm{GS}=-453.9432J$
$Jt=36.80,\ E(t)-E_\mathrm{GS}=-454.0639J$
$Jt=37.60,\ E(t)-E_\mathrm{GS}=-454.1595J$
$Jt=38.40,\ E(t)-E_\mathrm{GS}=-454.2333J$
$Jt=39.20,\ E(t)-E_\mathrm{GS}=-454.2883J$
$Jt=40.00,\ E(t)-E_\mathrm{GS}=-454.3277J$
$Jt=40.80,\ E(t)-E_\mathrm{GS}=-454.3546J$
$Jt=41.60,\ E(t)-E_\mathrm{GS}=-454.3721J$
$Jt=42.40,\ E(t)-E_\mathrm{GS}=-454.3835J$
$Jt=43.20,\ E(t)-E_\mathrm{GS}=-454.3917J$
$Jt=44.00,\ E(t)-E_\mathrm{GS}=-454.4001J$
$Jt=44.80,\ E(t)-E_\mathrm{GS}=-454.4117J$
$Jt=45.60,\ E(t)-E_\mathrm{GS}=-454.4297J$
$Jt=46.40,\ E(t)-E_\mathrm{GS}=-454.4573J$
$Jt=47.20,\ E(t)-E_\mathrm{GS}=-454.4975J$
$Jt=48.00,\ E(t)-E_\mathrm{GS}=-454.5536J$
$Jt=48.80,\ E(t)-E_\mathrm{GS}=-454.6287J$
$Jt=49.60,\ E(t)-E_\mathrm{GS}=-454.7259J$
$Jt=50.40,\ E(t)-E_\mathrm{GS}=-454.8486J$
$Jt=51.20,\ E(t)-E_\mathrm{GS}=-454.9998J$
$Jt=52.00,\ E(t)-E_\mathrm{GS}=-455.1828J$
$Jt=52.80,\ E(t)-E_\mathrm{GS}=-455.4008J$
$Jt=53.60,\ E(t)-E_\mathrm{GS}=-455.6571J$
$Jt=54.40,\ E(t)-E_\mathrm{GS}=-455.9550J$
$Jt=55.20,\ E(t)-E_\mathrm{GS}=-456.2978J$
$Jt=56.00,\ E(t)-E_\mathrm{GS}=-456.6890J$
$Jt=56.80,\ E(t)-E_\mathrm{GS}=-457.1320J$
$Jt=57.60,\ E(t)-E_\mathrm{GS}=-457.6303J$
$Jt=58.40,\ E(t)-E_\mathrm{GS}=-458.1876J$
$Jt=59.20,\ E(t)-E_\mathrm{GS}=-458.8074J$
$Jt=60.00,\ E(t)-E_\mathrm{GS}=-459.4936J$
$Jt=60.80,\ E(t)-E_\mathrm{GS}=-460.2500J$
$Jt=61.60,\ E(t)-E_\mathrm{GS}=-461.0805J$
$Jt=62.40,\ E(t)-E_\mathrm{GS}=-461.9894J$
$Jt=63.20,\ E(t)-E_\mathrm{GS}=-462.9809J$
$Jt=64.00,\ E(t)-E_\mathrm{GS}=-464.0592J$
$Jt=64.80,\ E(t)-E_\mathrm{GS}=-465.2290J$
$Jt=65.60,\ E(t)-E_\mathrm{GS}=-466.4950J$
$Jt=66.40,\ E(t)-E_\mathrm{GS}=-467.8620J$
$Jt=67.20,\ E(t)-E_\mathrm{GS}=-469.3351J$
$Jt=68.00,\ E(t)-E_\mathrm{GS}=-470.9197J$
$Jt=68.80,\ E(t)-E_\mathrm{GS}=-472.6213J$
$Jt=69.60,\ E(t)-E_\mathrm{GS}=-474.4455J$
$Jt=70.40,\ E(t)-E_\mathrm{GS}=-476.3984J$
$Jt=71.20,\ E(t)-E_\mathrm{GS}=-478.4863J$
$Jt=72.00,\ E(t)-E_\mathrm{GS}=-480.7156J$
$Jt=72.80,\ E(t)-E_\mathrm{GS}=-483.0931J$
$Jt=73.60,\ E(t)-E_\mathrm{GS}=-485.6260J$
$Jt=74.40,\ E(t)-E_\mathrm{GS}=-488.3216J$
$Jt=75.20,\ E(t)-E_\mathrm{GS}=-491.1876J$
$Jt=76.00,\ E(t)-E_\mathrm{GS}=-494.2320J$
$Jt=76.80,\ E(t)-E_\mathrm{GS}=-497.4629J$
$Jt=77.60,\ E(t)-E_\mathrm{GS}=-500.8891J$
$Jt=78.40,\ E(t)-E_\mathrm{GS}=-504.5194J$
$Jt=79.20,\ E(t)-E_\mathrm{GS}=-508.3629J$
$Jt=80.00,\ E(t)-E_\mathrm{GS}=-512.4291J$

In [ ]: