gpe.Examples.traveling_waves
============================

.. py:module:: gpe.Examples.traveling_waves

.. autoapi-nested-parse::

   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
----------

.. autoapisummary::

   gpe.Examples.traveling_waves.u


Classes
-------

.. autoapisummary::

   gpe.Examples.traveling_waves.StateTravellingWave
   gpe.Examples.traveling_waves.MinimizeStateTravellingWave


Module Contents
---------------

.. py:data:: u

.. py: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)

   Bases: :py:obj:`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.


   .. py:attribute:: ind
      :value: None



   .. py:attribute:: psi_0
      :value: 1.0



   .. py:attribute:: n_avg
      :value: 1.0



   .. py:method:: init()

      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.



   .. py:property:: metric


   .. py:method:: exact_psi()

      Return the analytic soliton



   .. py:method:: compute_dy_dt(dy, subtract_mu=False)

      Return `dy_dt` storing the results in `dy`.

      :param subtract_mu: 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.
      :type subtract_mu: bool



   .. py:method:: scale(f)

      Perform `self *= f` as efficiently as possible.



   .. py:method:: axpy(x, a=1)

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



   .. py:method:: get_energy()

      Return the energy of the state.  Useful for minimization.



   .. py:method:: plot(log=False, label=None)

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

      :param log: If `True`, plot the log of the densities.
      :type log: bool
      :param label: For 1D data, use this label.
      :type label: str
      :param phase: If `True`, draw the phase plot in 2D.
      :type phase: bool
      :param fig: Figure in which to draw plots.  Only used if `ax` or `axs` are `None`.
      :type fig: Figure
      :param axs: List of axes used in plot.  This is what is returned and should be passed in
                  during an animation loop
      :type axs: [Axes]
      :param convergence: If `True`, display UV and IR convergence factors.
      :type convergence: bool
      :param plot_convergence: If `True`, plot converge in inset.
      :type plot_convergence: bool



.. py:class:: MinimizeStateTravellingWave(state, fix_N=True, **kw)

   Bases: :py:obj:`gpe.minimize.MinimizeState`


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


   .. py:attribute:: psi_0


   .. py:attribute:: ind


   .. py:method:: pack(psi)

      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.).



   .. py:method:: unpack(x, state=None)

      Unpack `x` into `state` including factors of `x_scale`

      Note: Do not scale or otherwise mutate `x`.



