Ejemplo n.º 1
0
        def solve4l(l):
            def CombinedPotential(r):
                return LennardJonesPotential(e, s, r) + l*(l+1)/(mh*r**2)

            # initialize the (combined) potential
            self._V = array(map(lambda r: CombinedPotential(r), self._r))

            # initialize the k's, based on the potential
            self._k = mh*(E-self._V)

            for i in xrange(r0_pos, len(self._r)-1):
                self._u[i+1] = numerov(self._dr, self._k[i], self._u[i], self._k[i-1], self._u[i-1], self._k[i+1])
from numerov import numerov

# Specific function k used in the schrödinger equation
k = lambda z, eps: eps - z

# The values for eps
eps = np.array([5.0, 6.0])

# Number of steps N and step size dz
N = 10000
dz = 0.001

# Initial valuess
z0 = 0.0
psi0 = 0.0
psid0 = 1.0

# Plot the solutions of the numerov algorithm and save them
plt.axis([0, 10, -1, 1])
for e in eps:
    k_eps = lambda x: k(x, e)
    z, psi = numerov(z0, psi0, psid0, k_eps, dz, N)
    plt.plot(z, psi)
plt.xlabel(r'$\eta$')
plt.ylabel(r'$\psi(\eta)$')

if not os.path.exists('figures'):
    os.mkdir('figures')
plt.savefig('figures/fig2_1.pgf')
plt.show()
Ejemplo n.º 3
0
Archivo: ex2.py Proyecto: DropD/CQP
#!/usr/bin/python

from numerov import numerov
import numpy as np

def VBound(c):
    return lambda x : 0 <= x <= 1 and c * (x**2 - x) or 0

def k_gen(V):
    return lambda x : 2 * (E - V(x))

if __name__ == '__main__':
    dx = 0.001
    c  = 1e3
    integrator = numerov(dx)
    V = VBound(c)
    k = k_gen(V)

    # choose a point b
    b = 0.5
    E = V(b)*1e2

    psiL0 = np.exp(-1j * np.sqrt(np.complex(k(0))) * -dx)
    psiR0 = np.exp(-1j * np.sqrt(np.complex(k(1))) * (1+dx))
    psiL1 = psiR1 = 1

    pli = [psiL0, psiL1]
    pri = [psiR0, psiR1]

    psiL = integrator.integrate(0, b, k, pli)
    integrator.dx = -dx
Ejemplo n.º 4
0
def epsSlider_onChanged(eps):
    k_eps = lambda x: eps - x
    z, psi = numerov(z0, psi0, psid0, k_eps, dz, N)

    lines.set_data(z, psi)
def psi_limit(eps):
  """ Returns the last value of the solution psi """
  k_eps = lambda z: k(z, eps)
  psi = numerov(z0, psi0, psid0, k_eps, dz, N)[1]
  return psi[N - 1]