gpe.Examples.tutorial#

Example code from the tutorial.

Classes#

StateHOConvergence1

State with tools to check convergence for a 1D HO GPE.

StateHOConvergence2

State with tools to check convergence for a 2D HO GPE.

Module Contents#

class StateHOConvergence1(**kw)[source]#

Bases: gpe.bec.HOMixin, gpe.bec.StateGPEBase

State with tools to check convergence for a 1D HO GPE.

This is a simple state with default parameters forming a trapped gas in a 1D harmonic oscillator. It has some functions for checking and plotting convergence.

The state is specified by the parameter dmu = mu / (hbar*w/2) - 1. If dmu = 0, we will have no interactions (but don’t do this: use a small, non-zero value), while larger values will approach the TF limit.

Nx = 64[source]#
Lx = 14.0[source]#
dmu = 0.74[source]#
w = 1.0[source]#
g = 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.

get_convergence(full_output=False)[source]#

Return (ir, uv) convergence factors.

These are the ratios of the density at the edge vs maximum density in position (IR) and momentum (UV) space.

Parameters:

full_output (bool) – If True, return (ir, uv, x, nx, k, nk).

plot_convergence(ax=None, legend=True, **kw)[source]#

Plot the convergence in axis axs[0].

Parameters:
  • ax (Axes) – Plot convergence in ax if provided.

  • legend (bool) – If True, include the legend.

  • **kw (dict) – All other arguments are passed to plot().

Returns:

ax

Return type:

Axes

get_gtilde()[source]#

Return the dimensionless interaction parameter.

plot(axs=None, plot_convergence=False, **kw)[source]#

Plot the state in axis ax.

Parameters:
  • axs ([Axes]) – List of axes. Plot in axs[0] if provided. plot the convergence in axs[1], if provided and plot_convergence is True.

  • plot_convergence (bool) – If True, include the convergence plot.

  • **kw (dict) – All other arguments are passed to plot().

Returns:

ax

Return type:

Axes

get_initialized_state(fix_N=False, minimize_kw={})[source]#

Return a minimized state.

class StateHOConvergence2(**kw)[source]#

Bases: StateHOConvergence1

State with tools to check convergence for a 2D HO GPE.

This is a simple state with default parameters forming a trapped gas in a 2D harmonic oscillator. It has some functions for checking and plotting convergence.

The state is specified by the parameter dmu = mu / (hbar*w/2) - 1. If dmu = 0, we will have no interactions (but don’t do this: use a small, non-zero value), while larger values will approach the TF limit.

Nx = 64[source]#
Lx = 14.0[source]#
dmu = 0.74[source]#
w = 1.0[source]#
g = 1.0[source]#
get_convergence(full_output=False)[source]#

Return (ir, uv) convergence factors.

These are the ratios of the density at the edge vs maximum density in position (IR) and momentum (UV) space.

Parameters:

full_output (bool) – If True, return (ir, uv, r, nr, k, nk).

plot_convergence(ax=None, legend=True, **kw)[source]#

Plot the convergence in axis axs[0].

Parameters:
  • ax (Axes) – Plot convergence in ax if provided.

  • legend (bool) – If True, include the legend.

  • **kw (dict) – All other arguments are passed to plot().

Returns:

ax

Return type:

Axes

plot(axs=None, plot_convergence=False, **kw)[source]#

Plot the state in axis ax.

Parameters:
  • axs ([Axes]) – List of axes. Plot in axs[0] if provided. plot the convergence in axs[1], if provided and plot_convergence is True.

  • plot_convergence (bool) – If True, include the convergence plot.

  • **kw (dict) – All other arguments are passed to plot().

Returns:

ax

Return type:

Axes