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:
- 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
See also
- 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
orsigma_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 than1.
. This also means that even if the center is not sampled at all, the norm of the result is1.
.\[\Psi (x) = \left( \frac{m \omega}{\pi \hbar} \right)^\frac{1}{4} e^{-\frac{m\omega x^2}{2\hbar}}\]- Parameters:
- Returns:
The ground state.
- Return type:
fa.Array
- Raises:
ValueError – If
omega
andsigma_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
See also
- 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
- 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