Helper functions#

expectation_value(psi: Array, op: Array)[source]#

Compute the expectation value of the given diagonal operator on the fa.Array in the space of the operator.

Parameters:
  • wf (fa.Array) – The wave function.

  • op (fa.Array) – The diagonal operator.

  • psi (Array)

Returns:

The expectation value of the given diagonal operator as a scalar array of the used Array API implementation. If xp.sum returns a Python float this would be a Python float.

Return type:

Any

get_e_kin(psi: Array, m: float, return_microK: bool = False)[source]#

Compute the kinetic energy of the given wave function with the given mass.

Parameters:
  • psi (fa.Array) – The wave function.

  • m (float) – The mass of the wave function.

  • return_microK (bool, optional) – Return the kinetic energy in microK instead of Joule.

Returns:

The kinetic energy as a scalar array of the used Array API implementation. If xp.sum returns a Python float this would be a Python float.

Return type:

Any

get_ground_state_ho(dim: Dimension, *, mass: float, xp: Any | None = None, dtype: Any | None = None, omega: float | None = None, sigma_p: float | None = None) Array[source]#

Returns a wave function with the ground state of the 1-dimensional quantum harmonic oscillator (QHO). Either omega or sigma_p has to be specified. The ground state is centered at the origin in position and frequency space. The result is numerically normalized so that cut-off tails do not result in a norm smaller than 1.. This also means that even if the center is not sampled at all, the norm of the result is 1..

\[\Psi (x) = \left( \frac{m \omega}{\pi \hbar} \right)^\frac{1}{4} e^{-\frac{m\omega x^2}{2\hbar}}\]
Parameters:
  • dim (Dimension) – Dimension in which to create the QHO.

  • mass (float) – The mass of the matter wave.

  • omega (float | None) – The angular frequency of the QHO, by default None

  • sigma_p (float | None) – The momentum uncertainty, by default None

  • xp (Any | None)

  • dtype (Any | None)

Returns:

The ground state.

Return type:

fa.Array

Raises:

ValueError – If omega and sigma_p are both specified.

See also

fftarray.coords_from_dim

norm(psi: Array)[source]#

Compute the norm of the given fa.Array in its current space.

Parameters:

psi (fa.Array) – The wave function.

Returns:

The norm of the fa.Array as a scalar array of the used Array API implementation. If xp.sum returns a Python float this would be a Python float.

Return type:

Any

normalize(psi: Array) Array[source]#

Normalize the wave function.

Parameters:

psi (fa.Array) – The initial wave function.

Returns:

The normalized wave function.

Return type:

fa.Array

See also

matterwave.norm

scalar_product(a: Array, b: Array)[source]#

Take the scalar product between two wave functions.

Parameters:
  • a (fa.Array) – Wavefunction <pos|a>

  • b (fa.Array) – Wavefunction <pos|b>

Returns:

The Scalar product as a scalar array of the used Array API implementation. If xp.sum returns a Python float this would be a Python float.

Return type:

Any