Skip to main content

Module spin

Module spin 

Source

Structs§

BlochSphereRenderer
Render Bloch sphere as wireframe with state vector.
SpinChain
Heisenberg spin chain with nearest-neighbor coupling.
SpinState
Spin-1/2 state: |psi> = up|+> + down|->.

Functions§

bloch_angles
Get Bloch sphere angles (theta, phi) from a spin state. |psi> = cos(theta/2)|+> + e^{i*phi}*sin(theta/2)|->
from_bloch
Create spin state from Bloch sphere angles.
larmor_precession
Larmor precession: time evolution in a magnetic field. H = -gamma * B.sigma, evolve by exp(-iHt/hbar). For simplicity, gamma*hbar/2 = 1, so omega = |B|.
pauli_x
Pauli X gate: |+> <-> |->
pauli_y
Pauli Y gate: |+> -> i|-> , |-> -> -i|+>
pauli_z
Pauli Z gate: |+> -> |+>, |-> -> -|->
rotate_spin
Rotate spin state about an axis by an angle. Uses the SU(2) rotation: exp(-i * angle/2 * n.sigma)
spin_expectation
Expectation value of spin along an axis: <S.n> = (hbar/2)*<psi|sigma.n|psi>. Returns the value in units of hbar/2 (i.e., between -1 and 1).
stern_gerlach
Stern-Gerlach measurement along an axis. Returns (collapsed state, outcome +1 or -1).