API Reference
Models
OpenSpinDynamics.SpinModels.SpinModel — Type
SpinModel(N; Jxy=1.0, Jz=1.0, hx=zeros(N), hz=zeros(N), Jmn=zeros(N, N))Construct a quantum spin model.
Arguments
N: Number of spins.
Keywords
Jxy: XY coupling strength.Jz: Ising coupling strength.hx: Local x-fields.hz: Local z-fields.Jmn: Coupling matrix.
Returns
A SpinModel containing the Hamiltonian and model parameters.
OpenSpinDynamics.SpinModels.update_model! — Function
update_model!(model::SpinModel, Jxy::Float64, Jz::Float64; kwargs...)Updates the Hamiltonian of an existing SpinModel object with new parameters.
Arguments:
model: TheSpinModelinstance to update.Jxy: XY coupling constant.Jz: Z coupling constant.
Keyword arguments:
hx: New magnetic field in the x-direction.hz: New magnetic field in the z-direction.Jmn: New coupling matrix.
Returns: Nothing. Modifies the SpinModel in place.
Initial states
OpenSpinDynamics.QuantumState.neel_state — Function
neel_state(N; direction=:z)Construct a normalized Néel product state for N spins.
The first spin points along the positive direction, followed by alternating spins. direction may be :z or :x.
OpenSpinDynamics.QuantumState.polarized_state — Function
polarized_state(N; direction=:z)Construct a normalized fully polarized product state for N spins.
direction may be :z or :x.
Time evolution
OpenSpinDynamics.evolve — Function
evolve(model, ψ0, time_points, observables; kwargs...)Evolve a pure state under a SpinModel.
Supported methods:
:krylov:arnoldi:trajectories
evolve(model, ρ0, time_points, observables; lindblad_ops, method=:expm)Evolve a density matrix under Lindblad dynamics.
Supported methods:
:expm:ode
Spin operators
OpenSpinDynamics.Operators.SpinOperators — Type
SpinOperatorsCollection of single-site spin operators for an N-spin Hilbert space.
The fields contain sparse operators acting on the full Hilbert space:
x[i]: Pauli $σ_x$ operator acting on sitei.z[i]: Pauli $σ_z$ operator acting on sitei.plus[i]: raising operator $σ_+$ acting on sitei.minus[i]: lowering operator $σ_-$ acting on sitei.
OpenSpinDynamics.Operators.spin_operators — Function
spin_operators(N::Int)Construct single-site spin operators for an N-spin system.
Returns a SpinOperators object containing the $σ_x$, $σ_z$, $σ_+$, and $σ_-$ operators for every site, represented as sparse matrices on the full $2^N$-dimensional Hilbert space.
Arguments
N: Number of spins. Must be positive.
Example
ops = spin_operators(4)
ops.z[1]
ops.plus[2]Couplings
OpenSpinDynamics.Coupling.LongRangeCouplingClean — Type
LongRangeCouplingCleanClean long-range power-law coupling between N spins.
The interaction between sites i and j is
\[J_{ij} = \frac{1}{|i-j|^\alpha},\]
with zero diagonal.
OpenSpinDynamics.Coupling.LongRangeCouplingDisorder — Type
LongRangeCouplingDisorderRandom long-range power-law coupling between N spins distributed over a lattice of size L.
Couplings decay with distance as
\[J_{ij} = \frac{1}{|r_i-r_j|^\alpha}.\]
The generated coupling matrix is symmetric with zero diagonal.
Fields
matrix: Coupling matrix.α: Power-law exponent.L: Lattice size.N: Number of spins.reordered: Whether sampled sites are reordered.
OpenSpinDynamics.Coupling.NearestNeighborCoupling — Type
NearestNeighborCouplingNearest-neighbor coupling with alternating bond strengths.
For neighboring sites, the coupling is
\[J_{n,n+1} = 1 + (-1)^n \delta,\]
while all non-nearest-neighbor couplings vanish.