wavepacket.operator =================== .. py:module:: wavepacket.operator .. autoapi-nested-parse:: This module contains classes that define operators on a given grid. .. !! processed by numpydoc !! Classes ------- .. autoapisummary:: wavepacket.operator.OperatorBase wavepacket.operator.CartesianKineticEnergy wavepacket.operator.PlaneWaveFbrOperator wavepacket.operator.Potential1D Functions --------- .. autoapisummary:: wavepacket.operator.expectation_value Package Contents ---------------- .. py:class:: OperatorBase(grid: wavepacket.grid.Grid) Bases: :py:obj:`abc.ABC` Base class of an operator. An operator can be applied to a wave function or from the left or right to a density operator. It is defined on a grid, and can only operate on states on that grid. :Parameters: **grid** : wp.grid.Grid The grid on which the operator is defined. Particular operators may require additional parameters. :Attributes: **grid** .. .. !! processed by numpydoc !! .. py:property:: grid Returns the grid on which the operator is defined. .. !! processed by numpydoc !! .. py:method:: apply(state: wavepacket.grid.State, t: Optional[float] = None) -> wavepacket.grid.State Applies the operator onto a wave function or a density operator from the left. This is a convenience function if you just want to apply the operator without detailed knowledge of the state. :Parameters: **state** : wp.grid.State The state that the operator is applied on. **t** : float, optional The time at which the operator is applied. The default value `None` raises an exception for time-dependent operators. :Returns: wp.grid.State The result of applying the operator on the state. :Raises: wp.BadGridError If the state's grid does not match the grid of the operator. wp.BadStateError If the state is neither a wave function nor a density operator. .. !! processed by numpydoc !! .. py:method:: apply_to_wave_function(psi: wavepacket.typing.ComplexData, t: float) -> wavepacket.typing.ComplexData :abstractmethod: Applies the operator on a wave function. This function is mainly for Wavepacket-internal use. It ignores most error handling (usually done by the wrapping :py:class:`wavepacket.expression.ExpressionBase`), and operates directly on coefficients to avoid the creation of temporary states. :Parameters: **psi** : wpt.ComplexData The coefficients describing the wave function on which the operator acts. **t** : float The time at which the operator should be evaluated. :Returns: wpt.ComplexData The coefficients of the resulting wave function. .. !! processed by numpydoc !! .. py:method:: apply_from_left(rho: wavepacket.typing.ComplexData, t: float) -> wavepacket.typing.ComplexData :abstractmethod: Applies the operator on a density operator from the left. This function is mainly for Wavepacket-internal use. It ignores most error handling (usually done by the wrapping :py:class:`wavepacket.expression.ExpressionBase`), and operates directly on coefficients to avoid the creation of temporary states. :Parameters: **rho** : wpt.ComplexData The coefficients describing the density operator on which the operator acts. **t** : float The time at which the operator should be evaluated. :Returns: wpt.ComplexData The coefficients of the resulting density operator. .. !! processed by numpydoc !! .. py:method:: apply_from_right(rho: wavepacket.typing.ComplexData, t: float) -> wavepacket.typing.ComplexData :abstractmethod: Applies the operator on a density operator from the right. This function is mainly for Wavepacket-internal use. It ignores most error handling (usually done by the wrapping :py:class:`wavepacket.expression.ExpressionBase`), and operates directly on coefficients to avoid the creation of temporary states. :Parameters: **rho** : wpt.ComplexData The coefficients describing the density operator on which the operator acts. **t** : float The time at which the operator should be evaluated. :Returns: wpt.ComplexData The coefficients of the resulting density operator. .. !! processed by numpydoc !! .. py:function:: expectation_value(op: wavepacket.operator.operatorbase.OperatorBase, state: wavepacket.grid.State, t: Optional[float] = None) -> complex Calculates the expectation value of an operator for a given state. :Parameters: **op** : wp.operator.OperatorBase The operator whose expectation value is calculated. **state** : wp.grid.State The wave function or density operator that is used for the calculation. **t** : float, optional The time at which the operator should be evaluated. Only required for time-dependent operators, where the default value `None` raises an exception. .. !! processed by numpydoc !! .. py:class:: CartesianKineticEnergy(grid: wavepacket.grid.Grid, dof_index: int, mass: float) Bases: :py:obj:`PlaneWaveFbrOperator` Convenience class that implements the common Cartesian kinetic energy operator. The form of the operator is :math:`-\frac{1}{2m} \ \frac{\partial^2}{\partial x^2}`. It requires the degree of freedom to be a :py:class:`wavepacket.grid.PlaneWaveDof`. :Parameters: **grid** : wp.grid.Grid The grid on which the operator is defined. **dof_index** : inst Degree of freedom along which the operator acts **mass** : float The mass of the particle. :Raises: wp.InvalidValueError If the mass is not positive, or if the degree of freedom does not describe a plane wave expansion. .. !! processed by numpydoc !! .. py:class:: PlaneWaveFbrOperator(grid: wavepacket.grid.Grid, dof_index: int, generator: wavepacket.typing.Generator) Bases: :py:obj:`wavepacket.operator.operatorbase.OperatorBase` Base class for operators that are diagonal in a plane wave basis. The :py:class:`wavepacket.grid.PlaneWaveDof` describes an expansion of the wave function in plane waves. In the corresponding FBR, derivatives are diagonal and essentially transform into a multiplication with the wave vector / FBR grid. A key difference to a generic FBR operator is that this operator does not apply the shift after the FFT, which increases performance. :Parameters: **grid** : wp.grid.Grid The grid on which the operator is defined. **dof_index** : int The degree of freedom along which the operator is defined. **generator** : wpt.Generator A callable that gives the operator value for each FBR point. :Raises: wp.InvalidValueError If the supplied degree of freedom is not a plane wave expansion. .. !! processed by numpydoc !! .. py:method:: apply_to_wave_function(psi: wavepacket.typing.ComplexData, t: float) -> wavepacket.typing.ComplexData Applies the operator on a wave function. This function is mainly for Wavepacket-internal use. It ignores most error handling (usually done by the wrapping :py:class:`wavepacket.expression.ExpressionBase`), and operates directly on coefficients to avoid the creation of temporary states. :Parameters: **psi** : wpt.ComplexData The coefficients describing the wave function on which the operator acts. **t** : float The time at which the operator should be evaluated. :Returns: wpt.ComplexData The coefficients of the resulting wave function. .. !! processed by numpydoc !! .. py:method:: apply_from_left(rho: wavepacket.typing.ComplexData, t: float) -> wavepacket.typing.ComplexData Applies the operator on a density operator from the left. This function is mainly for Wavepacket-internal use. It ignores most error handling (usually done by the wrapping :py:class:`wavepacket.expression.ExpressionBase`), and operates directly on coefficients to avoid the creation of temporary states. :Parameters: **rho** : wpt.ComplexData The coefficients describing the density operator on which the operator acts. **t** : float The time at which the operator should be evaluated. :Returns: wpt.ComplexData The coefficients of the resulting density operator. .. !! processed by numpydoc !! .. py:method:: apply_from_right(rho: wavepacket.typing.ComplexData, t: float) -> wavepacket.typing.ComplexData Applies the operator on a density operator from the right. This function is mainly for Wavepacket-internal use. It ignores most error handling (usually done by the wrapping :py:class:`wavepacket.expression.ExpressionBase`), and operates directly on coefficients to avoid the creation of temporary states. :Parameters: **rho** : wpt.ComplexData The coefficients describing the density operator on which the operator acts. **t** : float The time at which the operator should be evaluated. :Returns: wpt.ComplexData The coefficients of the resulting density operator. .. !! processed by numpydoc !! .. py:class:: Potential1D(grid: wavepacket.grid.Grid, dof_index: int, generator: wavepacket.typing.RealGenerator) Bases: :py:obj:`wavepacket.operator.operatorbase.OperatorBase` Operator that represents a real-valued one-dimensional potential. Within the DVR approximation [Reb00f2ab5b8e-1]_, potential energy operators are diagonal in the DVR. That is, they are completely described by a value for each grid point. :Parameters: **grid** : wp.grid.Grid The grid on which the operator is defined **dof_index** : int the index of the degree of freedom along which the potential is defined. **generator** : wpt.RealGenerator A callable that generates a potential energy value for each grid point of the respective DOF. .. rubric:: References .. [Reb00f2ab5b8e-1] https://sourceforge.net/p/wavepacket/wiki/Numerics.DVR> .. only:: latex [Reb00f2ab5b8e-1]_ .. !! processed by numpydoc !! .. py:method:: apply_to_wave_function(psi: wavepacket.typing.ComplexData, t: float) -> wavepacket.typing.ComplexData Applies the operator on a wave function. This function is mainly for Wavepacket-internal use. It ignores most error handling (usually done by the wrapping :py:class:`wavepacket.expression.ExpressionBase`), and operates directly on coefficients to avoid the creation of temporary states. :Parameters: **psi** : wpt.ComplexData The coefficients describing the wave function on which the operator acts. **t** : float The time at which the operator should be evaluated. :Returns: wpt.ComplexData The coefficients of the resulting wave function. .. !! processed by numpydoc !! .. py:method:: apply_from_left(rho: wavepacket.typing.ComplexData, t: float) -> wavepacket.typing.ComplexData Applies the operator on a density operator from the left. This function is mainly for Wavepacket-internal use. It ignores most error handling (usually done by the wrapping :py:class:`wavepacket.expression.ExpressionBase`), and operates directly on coefficients to avoid the creation of temporary states. :Parameters: **rho** : wpt.ComplexData The coefficients describing the density operator on which the operator acts. **t** : float The time at which the operator should be evaluated. :Returns: wpt.ComplexData The coefficients of the resulting density operator. .. !! processed by numpydoc !! .. py:method:: apply_from_right(rho: wavepacket.typing.ComplexData, t: float) -> wavepacket.typing.ComplexData Applies the operator on a density operator from the right. This function is mainly for Wavepacket-internal use. It ignores most error handling (usually done by the wrapping :py:class:`wavepacket.expression.ExpressionBase`), and operates directly on coefficients to avoid the creation of temporary states. :Parameters: **rho** : wpt.ComplexData The coefficients describing the density operator on which the operator acts. **t** : float The time at which the operator should be evaluated. :Returns: wpt.ComplexData The coefficients of the resulting density operator. .. !! processed by numpydoc !!