phys_552.seq
============

.. py:module:: phys_552.seq

.. autoapi-nested-parse::

   Tools for solving the radial Schrodinger equation to high precision,



Classes
-------

.. autoapisummary::

   phys_552.seq.CoulombSEQ


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

.. py:class:: CoulombSEQ(**kw)

   Helper to solve the radial Schrodinger equation with a Coulomb tail.

   Assumes that the potential behaves like `V(r) = -alpha/r` at long distances, and
   that `V(r)` is not more singular than the centrifugal term `1/r^2` at short
   distance.

   .. attribute:: dimension

      Dimension of space.  I.e `dimension = 2` for cylindrical coordinates (without z).

      :type: int

   .. attribute:: hbar, m

      Physical constants

      :type: float

   .. attribute:: alpha

      Coefficient for the tail of the potential (Units of energy * distance).

      :type: float


   .. py:attribute:: dimension
      :value: 3



   .. py:attribute:: hbar
      :value: 1.0



   .. py:attribute:: m
      :value: 1.0



   .. py:attribute:: alpha
      :value: 1.0



   .. py:method:: V(r)

      Potential.  (Overload to change.)

      The default is the pure Coulomb potential.  Custom potentials must include this
      tail.



   .. py:method:: compute_E(E, tol=1e-08, l=0, lam=0.999, **kw)

      Return the energy eigenvalue E by shooting.

      :param E: Initial guess.
      :type E: float
      :param l: Angular momentum quantum number.
      :type l: int
      :param tol: Desired relative tolerance.
      :type tol: float
      :param lam: Parameter for bracketing the energy.  Initial search is in the range
                  `(lam*E, E/lam)`
      :type lam: float
      :param kw: Additional arguments passed down to `solve_ivp`.
      :type kw: dict



   .. py:method:: get_a(E)

      Return a, the length scale associated with the exponential decay.



   .. py:method:: get_r_v(E)

      Return `r_v`, an approximate location of the turning point.



   .. py:method:: compute_du_dr(r, udu, E, l=0)

      Return `(du, ddu)` for solve_ivp.

      Integrates the radial equation at the specified energy and angular momentum.

      :param r: Radius.  `r.shape == (n,)`
      :type r: array-like
      :param udu: Current solution and derivative, `u, du = udu`.  `udu.shape == (2, n)`.
      :type udu: array-like
      :param E: Energy for state.
      :type E: float
      :param l: Angular momentum quantum number.
      :type l: int



   .. py:method:: get_r_u_du_backwards(E, u0=None, R=None, R_max=None, tol=1e-08, max_step=None, l=0)

      Return `(rs, us, dus)` for the radial equation.

      Solves the radial equation by integrating from `R_max` backwards to `R` in order
      to kill any exponentially growing solutions.

      :param E: Energy, and angular momentum.
      :type E: float, int
      :param l: Energy, and angular momentum.
      :type l: float, int
      :param u0: Initial size of the radial wavefunction `u0 = u(R_max)`.  If not provided,
                 then we estimate by first performing a quick low-tolerance integration to
                 `r_v`.
      :type u0: float | None
      :param R: Integrate from `R_max` down to `R`.  If not provided, we estimate based on the
                length scales of the problem.
      :type R: float | None
      :param R_max: Integrate from `R_max` down to `R`.  If not provided, we estimate based on the
                    length scales of the problem.
      :type R_max: float | None
      :param tol: Tolerance for final integration.  Assumes everything is roughly order unity,
                  so this should be interpreted as a relative tolerance.
      :type tol: float
      :param max_step: Passed to `solve_ivp`.  Estimated if not provided.
      :type max_step: float | None

      :returns: * **rs** (*array-like*) -- Radial points (abscissa) for solution.
                * **us** (*array-like*) -- Radial wavefunction at these points `u(r)`
                * **dus** (*array-like*) -- Derivative of the radial wavefunction at these points.



   .. py:method:: objective(E, r0_a=None, R_max_a=None, N=10, deg=6, tol=1e-08, **kw)

      Short-distance objective function for finding E.

      :param tol: Tolerance for final integration.  Assumes everything is roughly order unity,
                  so this should be interpreted as a relative tolerance.
      :type tol: float
      :param r0_a: Dimensionless quantity `r0/a` specifying how far down to integrate.
                   If not provided, then estimate from tolerance and length scales.
      :type r0_a: float | None
      :param R_max_a: Dimensionless quantity `R_max/a` specifying R_max.
      :type R_max_a: float | None
      :param N: How many points and the degree to use when extrapolating from `r0` to 0.  We
                use `np.polyfit`.
      :type N: int
      :param deg: How many points and the degree to use when extrapolating from `r0` to 0.  We
                  use `np.polyfit`.
      :type deg: int



