spinecho_sim package#

A set of tools for spin echo simulations.

class spinecho_sim.ParticleState(*, spin: GenericSpin, displacement: ParticleDisplacement = <factory>, parallel_velocity: float, gyromagnetic_ratio: float = -204000000.0)#

Bases: object

Represents the state of a particle in the simulation.

as_coherent() list[CoherentParticleState]#

Convert to a CoherentParticleState.

displacement: ParticleDisplacement#
gyromagnetic_ratio: float = -204000000.0#
parallel_velocity: float#
spin: GenericSpin#
class spinecho_sim.Solenoid(*, length: float, field: Callable[[float], np.ndarray[Any, np.dtype[np.floating]]])#

Bases: object

Dataclass representing a solenoid with its parameters.

field: Callable[[float], np.ndarray[Any, np.dtype[np.floating]]]#
classmethod from_experimental_parameters(*, length: float, magnetic_constant: float, current: float) Solenoid#

Build a solenoid from an experimental magnetic constant and current.

length: float#
simulate_trajectories(initial_states: list[ParticleState], n_steps: int = 100) SolenoidSimulationResult#

Run a solenoid simulation for multiple initial states.

simulate_trajectory(initial_state: ParticleState, n_steps: int = 100) SolenoidTrajectory#

Run the spin echo simulation using configured parameters.

classmethod with_nonuniform_z(length: float, strength: Callable[[float], float]) Solenoid#

Build a solenoid with a non-uniform field along the z-axis.

classmethod with_uniform_z(length: float, strength: float) Solenoid#

Build a solenoid with a uniform field along the z-axis.

class spinecho_sim.SolenoidSimulationResult(*, trajectories: TrajectoryList, positions: ndarray[Any, dtype[floating]])#

Bases: object

Represents the result of a solenoid simulation.

property displacements: ParticleDisplacementList#

Extract the displacements from the simulation states.

positions: ndarray[Any, dtype[floating]]#
property spins: Spin[tuple[int, int, int]]#

Extract the spin components from the simulation states.

trajectories: TrajectoryList#
class spinecho_sim.SolenoidTrajectory(*, trajectory: Trajectory, positions: ndarray[Any, dtype[floating]])#

Bases: object

Represents the trajectory of a particle as it moves through the simulation.

property displacement: ParticleDisplacement#

The displacement of the particle at the end of the trajectory.

positions: ndarray[Any, dtype[floating]]#
property spins: Spin[tuple[int, int]]#

The spin components from the simulation states.

trajectory: Trajectory#

Subpackages#

Submodules#

spinecho_sim.util module#

spinecho_sim.util.get_figure(ax: Axes | None = None) tuple[Figure | SubFigure, Axes]#

Get a figure and axes for plotting.

spinecho_sim.util.get_measure_label(measure: Literal['real', 'imag', 'abs', 'arg']) str#

Get the specified measure of an array.

spinecho_sim.util.measure_data(arr: ndarray, measure: Literal['real', 'imag', 'abs', 'arg']) ndarray#

Get the specified measure of an array.

spinecho_sim.util.timed(f: Callable[P, R]) Callable[P, R]#

Log the time taken for f to run.

Parameters#

fCallable[P, R]

The function to time

Returns#

Callable[P, R]

The decorated function