BasisSet

class siegpy.basisset.BasisSet(states=None, potential=None, coord_map=None, max_virial=0)[source]

Bases: object

This class is arguably the most important one in the whole module since it defines all the main methods allowing to study the Siegert states of a given Hamiltonian (and compare their relevance with the traditional continuum states).

Parameters:
  • states (list of Eigenstate instances or Eigenstate or None) – Eigenstates of a Hamiltonian. If None, it means that the BasisSet instance will be empty.
  • potential (Potential or None) – Potential leading to the eigenstates.
  • coord_map (CoordMap or None) – Coordinate mapping used to find the eigenstates.
  • max_virial (float or None) – Maximal virial used to discriminate between Siegert states and other eigenstates.
Raises:

ValueError – If the value of states is invalid.

potential
Returns:Potential used to find the eigenstates.
Return type:Potential
coord_map
Returns:Coordinate mapping used to find the eigenstates.
Return type:CoordMap
max_virial

If updated, max_virial updates the Siegert_type attribute of the Siegert states in the basis set.

Returns:Maximal virial for a state to be considered as a Siegert state.
Return type:float
states
Returns:States of a BasisSet instance.
Return type:list

Example

>>> BasisSet().states
[]
write(filename)[source]

Write the basis set in a binary file (using pickle).

Parameters:filename (str) – Name of the file to be written.

Example

>>> BasisSet().write("tmp.dat")
classmethod from_file(filename)[source]

Initialize a basis set from a binary file.

Parameters:filename (str) – Name of a file containing a basis set.
Raises:NameError – If a the file does not exist.
__add__(states)[source]

Add a list of states or the states of another BasisSet instance to a BasisSet instance.

Parameters:states (list of Eigenstate instances or BasisSet) – Eigenstates of a Hamiltonian or another basis set.
Returns:A new basis set.
Return type:BasisSet
Raises:TypeError – If states is not a basis set or a list of eigenstates.
__len__()[source]
Returns:Length of the list of states
Return type:int
__eq__(other)[source]
Returns:True if both basis sets contain the same states.
Return type:bool
is_empty
Returns:True if the basis set is empty.
Return type:bool
is_not_empty
Returns:True if the basis set is not empty.
Return type:bool
bounds
Returns:Basis set made of all the bound states of the current basis set.
Return type:BasisSet
antibounds
Returns:Basis set made of all the anti-bound states of the current basis set.
Return type:BasisSet
resonants
Returns:Basis set made of all the resonant states of the current basis set.
Return type:BasisSet
antiresonants
Returns:Basis set made of all the anti-resonant states of the current basis set.
Return type:BasisSet
siegerts
Returns:Basis set made of all the Siegert states of the current basis set.
Return type:BasisSet
continuum
Returns:Basis set made of all the continuum states of the current basis set.
Return type:BasisSet
unknown
Returns:Basis set made of all the states of unknown type of the current basis set.
Return type:BasisSet
plot_wavefunctions(nres=None, nstates=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 states, if any 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 wavefunctions to plot (optional).
  • nstates (int) – Number of wavefunctions to plot (optional).
  • xlim (tuple(float or int, float or int)) – Range of the x axis of the plot (optional).
  • xlim – 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).
energies
Returns:The energies of the states in the current basis set.
Return type:list
wavenumbers
Returns:The wavenumbers of the states in the curent basis set.
Return type:list
virials
Returns:Virial values of the states in the current basis set.
Return type:list
no_coord_map
Returns:True if the coordinate mapping is such that \(x \mapsto x\).
Return type:bool
plot_wavenumbers(xlim=None, ylim=None, title=None, file_save=None, show_unknown=True)[source]

Plot the wavenumbers of the Siegert states in the basis set.

Parameters:
  • xlim (tuple(float or int, float or int)) – Range of the x axis of the plot (optional).
  • xlim – 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).
  • show_unknown (bool) – If True, plot the data of the states with an unknown type.
plot_energies(xlim=None, ylim=None, title=None, file_save=None, show_unknown=True)[source]

Plot the energies of the Siegert states in the basis set.

Parameters:
  • 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).
  • show_unknown (bool) – If True, plot the data of the states with an unknown type.
scal_prod(test)[source]

Method computing the scalar product \(\left\langle \varphi | test \right\rangle\) for each state \(\varphi\) in the basis set.

Parameters:test (Function) – Test function.
Returns:Scalar product of all the states in the basis set with the test function.
Return type:numpy array
completeness_convergence(test, klim=None)[source]

Evaluate the convergence of the completeness relation for the current basis set using a given test function.

Parameters:
  • test (Function) – Test function.
  • klim (tuple(float or int, float or int)) – Wavenumber range where the completeness convergence must be computed (optional).
Returns:

A tuple made of the array of the states wavenumbers and the array of the convergence of the completeness relation using all the states (both have the same length).

Return type:

tuple(numpy array, numpy array)

Raises:

ValueError – If the wavenumber klim range covers negative values.

Berggren_completeness_convergence(test, klim=None)[source]

Method evaluating the convergence of the CR using the Berggren expansion.

Parameters:
  • test (Function) – Test function.
  • xlim (tuple(float or int, float or int)) – Wavenumber range where the completeness convergence must be computed (optional).
Returns:

A tuple made of the array of the states wavenumbers and the array of the convergence of the Berggren completeness relation (both have the same length).

Return type:

tuple(numpy array, numpy array)

plot_completeness_convergence(test, klim=None, title=None, file_save=None)[source]

Plot the convergence of the completeness relation using all or the fiest nstates in the basis set.

Parameters:
  • test (Function) – Test function.
  • klim (tuple(float or int, float or int)) – Wavenumber range where the completeness convergence must be computed and range of the x axis of the plot (optional).
  • title (str) – Plot title (optional).
  • file_save (str) – Filename of the plot to be saved (optional).
MLE_strength_function(test, kgrid)[source]

Warning

Only the peaks due to the resonant couples can be produced at the moment. Numerical anti-bound states are required for the true MLE of the strength function to be computed from a numerical basis set.

Evaluate the Mittag-Leffler expansion strength function of the basis set for a given test function, discretized on a grid of wavenumbers kgrid.

Parameters:
  • test (Function) – Test function.
  • kgrid (numpy array) – Wavenumbers for which the strength function is evaluated.
Returns:

MLE of the strength function evaluated on the kgrid.

Return type:

numpy array

plot_strength_function(test, kgrid, nres=None, title=None, file_save=None)[source]

Plot the Mittag-Leffler Expansion of the strength function for a given test function.

The MLE of the strength function evaluated using 1, …, nres resonant couples can also be plotted.

Parameters:
  • test (Function) – Test function.
  • kgrid (numpy array) – Wavenumbers for which the strength function is evaluated.
  • nres (int) – Number of resonant couples contributions to be plotted (default to None, meaning that none are plotted; if nres=0, then only the sum of the bound and anti-bound states contributions is plotted).
  • title (str) – Plot title (optional).
  • file_save (str) – Filename of the plot to be saved (optional).
Berggren_propagation(test, time_grid)[source]

Evaluate the Berggren Expansion of the time-propagation of a test wavepacket over a given time grid. Only bound and resonant states are used, with a weight 1.

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.
Returns:

Berggren expansion of the propagated wavepacket for the different times of time_grid.

Return type:

2D numpy array

_propagate(test, time_grid)[source]

Evaluate the contribution of all the states to the time propagation of the initial wavepacket test for all the times in time_grid.

Note

The same default weight is used for all the states.

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.
Returns:

Propagated wavepacket for the different times of time_grid.

Return type:

2D numpy array