SWPBasisSet¶
The SWPBasisSet
class, representing a basis set made of
eigenstates of a 1D Square-Well Potential (SWP), is defined below.
-
class
siegpy.swpbasisset.
SWPBasisSet
(states=None)[source]¶ Bases:
siegpy.analyticbasisset.AnalyticBasisSet
Class representing a basis set in the case of 1D Square Well Potential. It mostly implements the abstract methods of its parent class.
Parameters: states (list of SWPEigenstate instances) – Eigenstates of a 1D SW potential. Raises: ValueError
– If all states are notSWPEigenstate
instances.Example
A basis set is initialized by a list of states:
>>> pot = SWPotential(4.442882938158366, 10) >>> bnd1 = SWPSiegert(4.42578048382546j, 'e', pot) >>> bnd2 = SWPSiegert(4.284084610255061j, 'o', pot) >>> bs = SWPBasisSet(states=[bnd1, bnd2]) >>> assert bs[0] == bnd1 >>> assert bs[1] == bnd2
The basis set can be empty:
>>> bs = SWPBasisSet() >>> assert bs.is_empty
-
classmethod
find_Siegert_states
(pot, re_kmax, re_hk, im_kmax, im_hk=None, analytic=True, grid=None, bounds_only=False)[source]¶ The Siegert states wavenumbers are found using the Muller scheme of the mpmath findroot method. This allows one to find a complex root of a function, starting from a wavenumber as input guess.
To find the Siegert states in a given portion of the wavenumber complex plane, a grid of input guess wavenumbers is therefore required. The parameters specifying this grid are listed below:
Parameters: - pot (SWPotential) – 1D Square-Well Potential for which we look for the continuum states.
- re_kmax (float) – Maximal value for the real part of the resonant states.
- re_hk (float) – Real part of the grid step for initial roots.
- im_kmax (float) – (Absolute) maximal value for the imaginary part of the resonant and anti-resonant states.
- im_hk (float) – Imaginary part of the grid step for the initial roots (optional, except in the cases where the imaginary part of the resonant states becomes bigger (in absolute value) than the imaginary part of the first bound state).
- analytic (bool) – If
True
, scalar products with the Siegert states will be computed analytically (default toTrue
). - grid (numpy array or list or set) – Discretization grid of the wavefunctions of the Siegert states (optional).
- bounds_only (bool) – If
True
, only the bounds states have to be found (default toFalse
).
Returns: Sorted basis set with all the Siegerts found in the user-defined range.
Return type: Examples
Read a basis set from a file as a reference:
>>> from siegpy.swpbasisset import SWPBasisSet >>> bs_1 = SWPBasisSet.from_file("doc/notebooks/siegerts.dat", nres=3) >>> len(bs_1.resonants) 3
To find the Siegert states of a given potential, proceed as follows:
>>> pot = bs_1.potential >>> bs = SWPBasisSet.find_Siegert_states(pot, 4.5, 1.5, 1.0, im_hk=1.0) >>> bs == bs_1 True
The previous test shows that all the Siegert states of the reference are recovered, and this includes the resonant states whose wavenumber can have a real part up to 4.5 and an imaginary part as low as -1.0.
Warning
It is not ensured that all Siegert states in the defined range are found: you may want to check the grid_step values.
For instance, if the grid step along the real wavenumber axis is too large, the reference results are not recovered:
>>> bs = SWPBasisSet.find_Siegert_states(pot, 4.5, 4.5, 1.0, im_hk=1.0) >>> bs == bs_1 False
-
classmethod
find_continuum_states
(pot, kmax, hk, kmin=None, even_only=False, analytic=True, grid=None)[source]¶ Initialize a BasisSet instance made of SWPContinuum instances. The basis set has \(2*n_k\) elements if
even_only=False
, \(n_k\) elements otherwise (where \(n_k\) is the number of continuum states defined by the grid stephk
and the minimal and maximal values of the wavenumber gridkmin
andkmax
).Parameters: - pot (SWPotential) – 1D Square-Well Potential for which we look for the continuum states.
- kmax (float) – Wavenumber of the last continuum state.
- hk (float) – Grid step of the wavenumber grid.
- kmin (float) – Wavenumber of the first continuum state (optional)
- even_only (bool) – If
True
, only even continuum states are created (default toFalse
) - analytic (bool) – If
True
, the scalar products will be computed analytically (default toTrue
). - grid (numpy array or list or set) – Discretization grid of the wavefunctions of the continuum states (optional).
Returns: Basis set of all continuum states defined by the grid of wavenumbers.
Return type: Raises: WavenumberError
– Ifhk
,kmin
or`kmax
is not strictly positive.Examples
Let us start by defining a potential:
>>> from siegpy.swpbasisset import SWPBasisSet >>> bs_ref = SWPBasisSet.from_file("doc/notebooks/siegerts.dat") >>> pot = bs_ref.potential
The continuum states are found, given a potential and a grid of initial wavenumbers (note that the minimal and maximal wavenumber cannot be 0)
>>> hk = 1; kmax = 3 >>> bs = SWPBasisSet.find_continuum_states(pot, kmax, hk) >>> bs.wavenumbers [1.0, 1.0, 2.0, 2.0, 3.0, 3.0]
It is possible to find only the even continuum states:
>>> p = pot >>> bs = SWPBasisSet.find_continuum_states(p, kmax, hk, even_only=True) >>> bs.wavenumbers [1.0, 2.0, 3.0] >>> assert len(bs.even) == 3 and bs.odd.is_empty
The minimal wavenumber can set:
>>> bs = SWPBasisSet.find_continuum_states(pot, kmax, hk, kmin=3) >>> bs.wavenumbers [3.0, 3.0]
-
parity
¶ Returns: None
if both parities are present,'e'
or'o'
if all the states are even or odd, respectively.Return type: None or str
-
even
¶ Returns: All the even states of the basis set. Return type: SWPBasisSet
-
odd
¶ Returns: All the odd states of the basis set. Return type: SWPBasisSet
-
plot_wavefunctions
(nres=None, xlim=None, ylim=None, title=None, file_save=None)[source]¶ Plot the bound, resonant and anti-resonant wavefunctions of the basis set along with the potential. The continuum and anti-bound states, if any are present in the basis set, are not plotted.
The wavefunctions are translated along the y-axis by their energy (for bound states) or absolute value of their energy (for resonant and anti-resonant states).
Parameters: - nres (int) – Number of resonant and antiresonant wavefunctions to plot.
- xlim (tuple(float or int, float or int)) – Range of the x axis of the plot (optional)
- ylim (tuple(float or int, float or int)) – Range of the y axis of the plot (optional)
- title (str) – Plot title (optional).
- file_save (str) – Filename of the plot to be saved (optional)
-
continuum_contributions_to_CR
(test, hk=None, kmax=None)[source]¶ Evaluate the continuum contributions to the completeness relation.
This is an overriding of the inherited
siegpy.analyticbasisset.AnalyticBasisSet.continuum_contributions_to_CR()
method in order to account for the parity of the continuum states of the Square-Well potential.Parameters: - test (Function) – Test function.
- hk (float) – Grid step for the wavenumbers of the “on-the-fly” continuum basis sets (optional).
- kmax (float) – Maximal wavenumber of the on-the-fly continuum basis set (optional).
Returns: Contribution of each continuum state of the basis set to the exact completeness relation.
Return type: numpy array
Raises: BasisSetError
– If the basis set has less odd continuum states than even continuum states when the test function is not even.
-
static
_evaluate_integrand
(q, k, test, eta, potential)[source]¶ Evaluate the integrand used to compute the strength function “on-the-fly.”
Parameters: - q (float) – Wavenumber of the continuum state considered.
- k (float) – Wavenumber for which the strength function is evaluated.
- test (Function) – Test function.
- eta (float) – Infinitesimal for integration (if
None
, default to 10 times the value of the grid-step of the continuum basis set). - potential (Potential) – Potential of the currently studied analytical case.
Returns: Value of the integrand.
Return type: complex
-
_propagate
(test, time_grid, weights=None)[source]¶ Evaluate the time-propagation of a test wavepacket as the matrix product of two matrices: one to account for the time dependance of the propagation of the wavepacket (mat_time), the other for its space dependance (mat_space).
This is an overriding of the inherited
siegpy.basisset.BasisSet._propagate()
method to take into account the parity of the eigenstates in the 1D SWP case.Parameters: - test (Function) – Test function.
- time_grid (numpy array or list of positive numbers) – Times for which the propagation is evaluated. It must contain positive numbers only.
- weights (dict) – Dictionary of the weights to use for the time-propagation. Keys correspond to a type of Siegert states (‘ab’ for anti-bounds, ‘b’ for bounds, ‘r’ for resonants and ‘ar’ for anti-resonants) and the corresponding value is the weight to use for all the states of the given type (optional).
Returns: Propagated wavepacket for the different times of
time_grid
.Return type: 2D numpy array
Raises: BasisSetError
– If the basis set has less odd continuum states than even continuum states when the test function is not even.
-
_add_one_continuum_state
()[source]¶ Add two continuum state to the basis set, depending on the already existing continuum states.
This is an overriding of the inherited
siegpy.analyticbasisset.AnalyticBasisSet._add_one_continuum_state()
method to account for the parity of the continuum states in the 1D SWP case.Returns: The same basis set with one more continuum state. Return type: SWPBasisSet
-
classmethod