wavepacket.expression
Classes that wrap operators into expressions for use in partial differential equations.
Classes
Base class for expressions. |
|
Represents a commutator expression in a Liouville von-Neumann equation. |
|
Expression wrapper for a Schrödinger equation. |
Package Contents
- class wavepacket.expression.ExpressionBase
Bases:
abc.ABCBase class for expressions.
By deriving from this class and implementing the method
ExpressionBase.apply(), you can add custom expressions.Notes
All differential equations have the form
(or equivalently
), that is, the left-hand side
is just the time derivative. This matches the common convention for the
Liouville von-Neumann equation, but differs from the usual
form of the Schrödinger equation, where the imaginary factor
is on the left-hand side of the equation.- abstractmethod apply(state: wavepacket.grid.State, t: float | None = None) wavepacket.grid.State
Applies the expression to the input state and returns the result.
- Parameters:
- statewp.grid.State
The state on which the expression is applied.
- tfloat, optional
The time at which the expression is evaluated. Default is None, which will raise an exception if the contained expression is time-dependent.
- Raises:
- wp.BadStateError
If the state is invalid or has the wrong time. For example, a Schroedinger equaiton makes little sense for a density operator.
- class wavepacket.expression.CommutatorLiouvillian(op: wavepacket.operator.OperatorBase)
Bases:
wavepacket.expression.expressionbase.ExpressionBaseRepresents a commutator expression in a Liouville von-Neumann equation.
Given an operator H, this commutator expression is given by
.- Parameters:
- opwp.operator.OperatorBase
The operator to commute with the density operator.
Notes
The extra factor of -i is added to ensure that the commutator can be directly plugged into a Liouville von-Neumann equation. defined as
.
If you need the raw commutator, you have to multiply the result with
the imaginary number.- apply(rho: wavepacket.grid.State, t: float | None = None) wavepacket.grid.State
Evaluates the commutator for the given density operator and time.
- Parameters:
- rhowp.grid.State
The density operator to commute with
- tfloat, optional
The time at which the operator is evaluated. By default it is None, which will throw if the contained operator is time-dependent.
- Returns:
- wp.grid.State
The result of the commutator.
- Raises:
- wp.BadGridError
If the grids of the density operator and the wrapped operator do not match.
- wp.BadStateError
If the input state is not a valid density operator.
- class wavepacket.expression.SchroedingerEquation(hamiltonian: wavepacket.operator.OperatorBase)
Bases:
wavepacket.expression.expressionbase.ExpressionBaseExpression wrapper for a Schrödinger equation.
You should wrap a Hamiltonian in an object of this type so that the solvers can subsequently solve the resulting equation.
- Parameters:
- hamiltonianwp.operator.OperatorBase
The Hamiltonian that is wrapped by this class.
Notes
The Schrödinger equation is given by
,
so this class only multiplies the wave function with the
negative imaginary number, and wraps the input Hamiltonian
into an expression so that solvers can work with it.- apply(psi: wavepacket.grid.State, t: float | None = None) wavepacket.grid.State
Evaluates the right-hand side of the Schrödinger equation for the given input state and time.
- Parameters:
- psiwp.grid.State
The input state that is evaluated.
- tfloat, optional
The time at which the Schrödinger equation is evaluated. The default None throws if the wrapped operator is time-dependent.
- Returns:
- wp.grid.State
The result of the evaluation.
- Raises:
- wp.grid.BadGridError
If the state’s grid differs from that of the Hamiltonian.
- wp.grid.BadStateError
If the input state is not a wave function.