Grids
Grids hold the discretized wavefunction and potential.
Grid(dim, potential, psi0, absorber=None, dtype=np.complex128)
A grid object holds discrete representations of the wavepacket and the potential at a given time t. It also knows about the initial wavepacket.
Create a grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dim
|
int
|
Spatial dimension. |
required |
potential
|
Potential object
|
The potential used in potential discretization. |
required |
psi0
|
WavePacket object
|
Initial wavepacket object. |
required |
absorber
|
Potential object
|
Absorbing boundary potential. |
None
|
dtype
|
(complex128, complex64)
|
Precision of the wavefunction and the potential. |
numpy.complex128
|
psi
property
writable
Current wavefunction \(\psi(t)\).
V
property
Current potential \(V(t)\), including the absorber.
psi_norm
property
Norm \(\Vert\psi\Vert\).
density
property
Probability density \(\vert\psi\vert^2\).
expectation_kinetic()
Kinetic energy \(\langle T\rangle = \langle k^2/2\rangle\), computed in momentum space.
expectation_potential()
Potential energy \(\langle V\rangle\); absorbers (the imaginary part of \(V\)) do not contribute.
energy()
Energy \(\langle H\rangle = \langle T\rangle + \langle V\rangle\).
update_potential(t)
Update potential for time \(t\).
renormalize_psi()
Renormalize \(\psi\) such that \(\Vert\psi\Vert = 1\).
suggest_time_step(safety=3.0)
Suggest a time step from the potential landscape elevation. The highest difference in total energy that is possible is \(\Delta E = \Delta V\), which corresponds to \(\delta\omega = \Delta V\) (atomic units!) or \(\delta t = 2\pi/\Delta V\).
Do not use this for tiny or vanishing potentials as e.g. in free-particle propagation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
safety
|
float
|
Divide computed dt by this number for safer propagation. |
3.0
|
Returns:
| Name | Type | Description |
|---|---|---|
dt |
float
|
Suggested time step. |
Grid1d(size, grid_samples, potential, psi0, absorber=None, dtype=np.complex128)
Bases: Grid
One dimensional periodic grid.
The grid points are \(x_j = x_\mathrm{min} + j\,\Delta x\) with \(\Delta x = (x_\mathrm{max} - x_\mathrm{min})/N\), i.e. the right boundary is not included, as appropriate for the periodicity implied by the FFT.
Create a 1d grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
tuple of float
|
Grid boundaries (x_min, x_max). |
required |
grid_samples
|
int
|
Number of grid points; powers of two are fastest. |
required |
potential
|
Potential object
|
The potential used in potential discretization. |
required |
psi0
|
WavePacket object
|
Initial wavepacket object. |
required |
absorber
|
Potential object
|
Absorbing boundary potential. |
None
|
dtype
|
(complex128, complex64)
|
Precision of the wavefunction and the potential; complex64 halves memory and is faster for large grids, at a relative accuracy of about 1e-6. |
numpy.complex128
|
make_psi_periodic()
Try to avoid Gibbs' phenomenon by manually making the wavefunction periodic.
expectation_x()
Position expectation value \(\langle x\rangle\).
expectation_p()
Momentum expectation value \(\langle p\rangle\), computed in momentum space.
width_x()
Position uncertainty \(\Delta x\).
Grid2d(size, grid_samples, potential, psi0, absorber=None, dtype=np.complex128)
Bases: Grid
Two dimensional periodic grid.
Arrays are indexed as psi[i, j] with \(x_i\) along the first and \(y_j\)
along the second axis (indexing="ij"). As in 1d, the upper
boundaries are not included. 2d potentials and wavepackets are evaluated
with r = (X, Y), a tuple of coordinate arrays.
Create a 2d grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
tuple
|
Grid boundaries ((x_min, x_max), (y_min, y_max)). |
required |
grid_samples
|
int or tuple of int
|
Number of grid points (N_x, N_y); powers of two are fastest. |
required |
potential
|
Potential object
|
The potential used in potential discretization. |
required |
psi0
|
WavePacket object
|
Initial wavepacket object. |
required |
absorber
|
Potential object
|
Absorbing boundary potential. |
None
|
dtype
|
(complex128, complex64)
|
Precision of the wavefunction and the potential; complex64 halves memory and is faster for large grids, at a relative accuracy of about 1e-6. |
numpy.complex128
|
extent
property
(x_min, x_max, y_min, y_max), e.g. for imshow.
expectation_r()
Position expectation value \((\langle x\rangle, \langle y\rangle)\).
width_r()
Position uncertainties \((\Delta x, \Delta y)\).
expectation_p()
Momentum expectation value \((\langle p_x\rangle, \langle p_y\rangle)\).