qscat.units and qscat.exceptions

qscat.units

Atomic units are used throughout qscat: energies in Hartree, lengths in Bohr. These conversions exist so unit handling is never scattered through method code — there is exactly one place that knows the Hartree/eV factor.

HARTREE_TO_EV

Convert a string or number to a floating point number, if possible.

EV_TO_HARTREE

Convert a string or number to a floating point number, if possible.

hartree_to_ev

Convert energy in Hartree to electron-volts.

ev_to_hartree

Convert energy in electron-volts to Hartree.

qscat.units.HARTREE_TO_EV: float = 27.211386245988

Convert a string or number to a floating point number, if possible.

qscat.units.EV_TO_HARTREE: float = 0.03674932217565499

Convert a string or number to a floating point number, if possible.

qscat.units.hartree_to_ev(x)[source]

Convert energy in Hartree to electron-volts.

Parameters:

x (float | ndarray)

Return type:

float | ndarray

qscat.units.ev_to_hartree(x)[source]

Convert energy in electron-volts to Hartree.

Parameters:

x (float | ndarray)

Return type:

float | ndarray

qscat.exceptions

Every recoverable error qscat raises is a subclass of QscatError. Each also subclasses the built-in it replaces, so catching the built-in remains valid. Generic argument validation may still raise a plain ValueError/TypeError.

QscatError

Base class for all errors raised by qscat.

GridError

Invalid FEM-DVR-ECS grid / discretisation specification.

ModelError

Invalid model specification, parameters, or registry lookup.

BackendError

A linear-algebra backend is unavailable or failed at runtime.

ConvergenceError

A numerical procedure failed to reach its convergence target.

exception qscat.exceptions.QscatError[source]

Base class for all errors raised by qscat.

exception qscat.exceptions.GridError[source]

Invalid FEM-DVR-ECS grid / discretisation specification.

Raised when a grid, element, or quadrature specification is malformed or out of range (e.g. a non-increasing segment endpoint, a quadrature order below 2, an r_max inside the fixed inner segments).

Examples

Each qscat error subclasses the built-in it replaces, so existing except/pytest.raises code keeps working:

>>> from qscat.exceptions import GridError, QscatError
>>> issubclass(GridError, ValueError)
True
>>> issubclass(GridError, QscatError)
True
exception qscat.exceptions.ModelError[source]

Invalid model specification, parameters, or registry lookup.

exception qscat.exceptions.BackendError[source]

A linear-algebra backend is unavailable or failed at runtime.

Raised when a requested sparse backend (e.g. MUMPS) is not installed, or a backend operation fails in a way that is about the backend rather than the input (e.g. an optional dependency missing on the chosen code path).

exception qscat.exceptions.ConvergenceError[source]

A numerical procedure failed to reach its convergence target.