gpe.Examples.traveling_waves#

Demonstration of Travelling Wave solutions of the GPE.

For the plain GPE these have analytic solutions as discussed in the Docs/Travelling Wave.ipynb notebook.

Attributes#

u

Classes#

StateTravellingWave

Class for solving for traveling waves.

MinimizeStateTravellingWave

Minimizer for states with the pytimeode.interfaces.IStateForABMEvolver

Module Contents#

u[source]#
class StateTravellingWave(Nx=128, Lx=10.0, psi_0=1.0, ind=None, n_avg=1.0, v_p=0.0, twist=0.0, m=1.0, hbar=1.0, g=1.0)[source]#

Bases: gpe.bec.StateTwist_x

Class for solving for traveling waves.

Here we hold one point of the wavefunction fixed. To do this, we need to hijack some of the functions from the original State class. For example, the total particle number and braket functions exclude this point so that particle number projection can be properly implemented.

To do this, we set the metric to exclude this point, and overload some functions to ensure that a constant value is maintained.

ind = None[source]#
psi_0 = 1.0[source]#
n_avg = 1.0[source]#
init()[source]#

Initialize the state.

This method defines the basis positions, momenta, etc. for use later on. We define these here rather than in the constructor __init__() so that the user can change them later and the reinitialize the state. We also call this function from the pre_evolve_hook() so that it is called before any evolution takes place. For this reason, we should not modify the state here.

property metric[source]#
exact_psi()[source]#

Return the analytic soliton

compute_dy_dt(dy, subtract_mu=False)[source]#

Return dy_dt storing the results in dy.

Parameters:

subtract_mu (bool) –

If True, then subtract the chemical potential such that dy_dt is orthogonal to the original state y. This will minimize the evolution of the overall phase during real-time evolution (which can reduce numerical errors) and will ensure that evolution under imaginary or complex time will preserve particle number.

This should not be set if computing physical energy of the state, however, which is why it is a parameter.

scale(f)[source]#

Perform self *= f as efficiently as possible.

axpy(x, a=1)[source]#

Perform self += a*x as efficiently as possible.

get_energy()[source]#

Return the energy of the state. Useful for minimization.

plot(log=False, label=None)[source]#

Plot 1D, 2D, or 3D data and return axs.

Parameters:
  • log (bool) – If True, plot the log of the densities.

  • label (str) – For 1D data, use this label.

  • phase (bool) – If True, draw the phase plot in 2D.

  • fig (Figure) – Figure in which to draw plots. Only used if ax or axs are None.

  • axs ([Axes]) – List of axes used in plot. This is what is returned and should be passed in during an animation loop

  • convergence (bool) – If True, display UV and IR convergence factors.

  • plot_convergence (bool) – If True, plot converge in inset.

class MinimizeStateTravellingWave(state, fix_N=True, **kw)[source]#

Bases: gpe.minimize.MinimizeState

Minimizer for states with the pytimeode.interfaces.IStateForABMEvolver interface.

psi_0[source]#
ind[source]#
pack(psi)[source]#

This is not symmetric with unpack as it does not scale the solution by any factors. (This is because we unpack both states and Hpsi which have different scalings.).

unpack(x, state=None)[source]#

Unpack x into state including factors of x_scale

Note: Do not scale or otherwise mutate x.