wavepacket

A package for the propagation of quantum-mechanical wave functions.

Submodules

Exceptions

BadFunctionCall

Signals that a function was called incorrectly.

BadGridError

An invalid grid was supplied.

BadStateError

An invalid state was supplied.

ExecutionError

An unrecoverable problem was encountered in foreign code.

InvalidValueError

A function argument was incorrect, for example out of bounds.

Classes

Gaussian

Callable that defines a one-dimensional Gaussian function.

PlaneWave

Callable that defines a plane wave.

Functions

log(→ None)

Prints some data about the state for inspection.

Package Contents

exception wavepacket.BadFunctionCall

Bases: Exception

Signals that a function was called incorrectly.

A typical but rare use-case would be a function that was called with incorrect parameters.

exception wavepacket.BadGridError

Bases: Exception

An invalid grid was supplied.

Most often, you attempt an operation between objects that must be defined on the same grid. For example, the addition of two operators defined on different grids is not a useful operation. The grid may also miss required properties, for example an operation may expect a specific degree of freedom type along some index.

exception wavepacket.BadStateError

Bases: Exception

An invalid state was supplied.

Either the state is completely invalid (neither wave function nor density operator), or you supplied the wrong type of state to a function, for example passing a density operator where a wave function was required.

exception wavepacket.ExecutionError

Bases: Exception

An unrecoverable problem was encountered in foreign code.

The main example is the wavepacket.solver.odesolver getting an error back while integrating.

exception wavepacket.InvalidValueError

Bases: Exception

A function argument was incorrect, for example out of bounds.

class wavepacket.Gaussian(x: float = 0.0, p: float = 0.0, rms: float | None = None, fwhm: float | None = None)

Bases: wavepacket.typing.Generator

Callable that defines a one-dimensional Gaussian function.

This callable can be supplied wherever a callable is required. An example would be an initial wave function for wavepacket.builder.product_wave_function(), or a potential wrapped in a wavepacket.operator.Potential1D.

Parameters:
xfloat, default=0

The center of the Gaussian.

pfloat, default=0

The momentum of the Gaussian.

rms, fwhmfloat

You must specify the width of the Gaussian using exactly one of these values, either through the root-mean-square width, or the full-width-at-half-maximum.

Raises:
wp.InvalidValueError

If the width of the Gaussian is not positive.

wp.BadFunctionCall

If both rms and fwhm have either been set or not supplied.

Notes

Up to scaling, the functional form of the Gaussian is f(x) = e^{-(x-x_0)^2 / 2 \sigma^2 + \imath p (x-x_0)}. Here, sigma is the rms width, which is connected to the FWHM by \sigma = \mathrm{FWHM} / \sqrt{8 \ln 2}.

class wavepacket.PlaneWave(k: float)

Callable that defines a plane wave.

You will typically use this callable for initial states. There are often better options, especially if your FBR already defines a plane wave basis, but sometimes you may just want to represent a reasonable plane wave and not count indices to get the correct wave vector.

Parameters:
kfloat

The wave vector of the plane wave.

wavepacket.log(t: numbers.Real, state: wavepacket.grid.State, precision: int = 6) None

Prints some data about the state for inspection.

The idea is that you call this function during every solver step and get a log with the most important values about the propagation, for example the state trace (if it deviates from one, this may be caused by poor convergence).

Parameters:
tfloat

The time at which you log.

statewp.grid.State

The state to log.

precisionint, default=6

How many decimal places should be printed.