qm_sim.temporal_solver.crank_nicolson.CrankNicolson
- class qm_sim.temporal_solver.crank_nicolson.CrankNicolson(H: Callable[[float], ndarray], output_shape: tuple[int] = None)[source]
Bases:
TemporalSolver
- __init__(H: Callable[[float], ndarray], output_shape: tuple[int] = None)[source]
Initialize a temporal solver
- Parameters:
H (Callable[[float], np.ndarray]) – Function of time, representing the temporal derivative at that time
output_shape (tuple[int], optional) – Expected shape of the solution, defaults to None
Methods
__init__
(H[, output_shape])Initialize a temporal solver
iterate
(v_0, t0, t_final, dt[, dt_storage, ...])Iterate the time propagation scheme.
tqdm
(t_start, t_end, enable)Attributes
Is the method explicit or implicit?
Name of the solver
Integration order
Is the method stable? If only conditionally stable, this will be true and
dt
will be forced into its stable range- explicit: bool = False
Is the method explicit or implicit?
- iterate(v_0: ndarray, t0: float, t_final: float, dt: float, dt_storage: float = None, verbose: bool = True) tuple[ndarray, ndarray] [source]
Iterate the time propagation scheme. Store the current state every
dt_storage
- Args:
- t_final (float):
End time for calculations
- dt_storage (float, optional):
Data storage period. If None, store each calculation
dt
Defaults to None.
- Returns:
- np.ndarray:
Time values, shape (
n
,) forn
storage times- np.ndarray:
State at times stored in the other output. shape (
n
,H
.shape)
- name: str = 'crank-nicolson'
Name of the solver
- order: int = 2
Integration order
- stable: bool = True
Is the method stable? If only conditionally stable, this will be true and
dt
will be forced into its stable range