spinecho_sim.solenoid package#

Module for simulating and plotting solenoid magnetic fields and particle trajectories.

class spinecho_sim.solenoid.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.solenoid.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.solenoid.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#
spinecho_sim.solenoid.plot_expectation_angles(result: SolenoidSimulationResult) tuple[Figure, Axes]#
spinecho_sim.solenoid.plot_expectation_trajectories(trajectories: TrajectoryList) tuple[Figure, Axes3D]#
spinecho_sim.solenoid.plot_expectation_trajectory(trajectory: Trajectory) tuple[Figure, Axes3D, Line2D]#
spinecho_sim.solenoid.plot_expectation_values(result: SolenoidSimulationResult) tuple[Figure, Axes]#
spinecho_sim.solenoid.plot_spin_states(result: SolenoidSimulationResult) tuple[Figure, Axes]#