Testing

Testing#

import mmf_setup;mmf_setup.nbinit()

This cell adds /home/docs/checkouts/readthedocs.org/user_builds/gpe/checkouts/latest/src to your path, and contains some definitions for equations and some CSS for styling the notebook. If things look a bit strange, please try the following:

  • Choose "Trust Notebook" from the "File" menu.
  • Re-execute this cell.
  • Reload the notebook.

%pylab inline --no-import-all
from gpe.tests.test_minimize import state
from gpe import exact_solutions
from gpe.minimize import MinimizeState
s = exact_solutions.HarmonicOscillator()
np.random.seed(11)
s[...] = np.random.random(s.shape) + np.random.random(s.shape)*1j - 0.5 - 0.5j
s.normalize()
m = MinimizeState(s)
s.get_energy()
s.set_data(s.psi_exact)
s.get_energy()
abs(s.get_Hy(subtract_mu=True).ravel()).max()
%pylab is deprecated, use %matplotlib inline and import the required libraries.
Populating the interactive namespace from numpy and matplotlib
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[2], line 2
      1 get_ipython().run_line_magic('pylab', 'inline --no-import-all')
----> 2 from gpe.tests.test_minimize import state
      3 from gpe import exact_solutions
      4 from gpe.minimize import MinimizeState
      5 s = exact_solutions.HarmonicOscillator()

ModuleNotFoundError: No module named 'gpe.tests'
import gpe.axial

import gpe.utils
class Experiment(gpe.utils.ExperimentBase):
    axial = True
    exact_state = exact_solutions.HarmonicOscillator())
    def get_state(self):
        if self.axial:
            s = self.exact_state
            state = gpe.axial.StateAxial(
                Nxr=(Nx, Nx//2),
                Lxr=(s.Lx, s.Lx//2),
            )
            
            return state
  Cell In[3], line 6
    exact_state = exact_solutions.HarmonicOscillator())
                                                      ^
SyntaxError: unmatched ')'
if True:
    s = exact_solutions.HarmonicOscillator(g=1.0)
    ds = s.empty()
    s.compute_dy_dt(ds, subtract_mu=True)
    print(abs(ds.ravel()).max())
    assert np.allclose(ds.ravel(), 0)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[4], line 2
      1 if True:
----> 2     s = exact_solutions.HarmonicOscillator(g=1.0)
      3     ds = s.empty()
      4     s.compute_dy_dt(ds, subtract_mu=True)
      5     print(abs(ds.ravel()).max())

NameError: name 'exact_solutions' is not defined
\[ \psi(x) = e^{-x^2/2}, \qquad N = \sqrt{\pi} \]
s = exact_solutions.HarmonicOscillator(g=1.0)
assert np.allclose(s.ravel(), s.psi_exact)
ds = s.empty()
pdb.run('s.compute_dy_dt(ds, subtract_mu=True)')
x = s.x
plt.plot(x, abs(ds.ravel()))
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[5], line 1
----> 1 s = exact_solutions.HarmonicOscillator(g=1.0)
      2 assert np.allclose(s.ravel(), s.psi_exact)
      3 ds = s.empty()
      4 pdb.run('s.compute_dy_dt(ds, subtract_mu=True)')

NameError: name 'exact_solutions' is not defined
V = s.get_Vext()
Ks = s.copy()
Ks.apply_laplacian(1.0)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[6], line 1
----> 1 V = s.get_Vext()
      2 Ks = s.copy()
      3 Ks.apply_laplacian(1.0)

NameError: name 's' is not defined
pdb.run('s.get_Vext()')
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[7], line 1
----> 1 pdb.run('s.get_Vext()')

NameError: name 'pdb' is not defined
#plt.plot(x, (-Ks/2 - s*V).ravel().real)
#plt.plot(x, s.g*s.psi_exact**2*s.psi_exact, ':')
#plt.plot(x, Ks.ravel().real)
#plt.plot(x, (-1+x**2)*s.ravel())
#plt.plot(x, ds.ravel())