Quantum Heisenberg system
A chain of spins one half with the XXZ Hamiltonian.
- Class:
QuantumHeisenbergSystem - Import:
from skcomplex.systems.physics.statistical_mechanics import QuantumHeisenbergSystem - Field:
physics/statistical_mechanics - Topics:
quantum,spins,lattice,magnetism,open system - References:
- Heisenberg 1928
- Mihailović et al. 2023
Use this system
The block imports the class and simulates the system with its default parameters and its tuned run settings.
from skcomplex.systems.physics.statistical_mechanics import QuantumHeisenbergSystem
trajectory = QuantumHeisenbergSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
n_sites |
12 |
J |
1.0 |
delta |
1.0 |
h |
0.0 |
gamma |
0.0 |
boundary |
'periodic' |
initial |
'flip' |
solver |
'auto' |
backend |
'auto' |
Tags
The system with its default parameters has these capability tags, which solvers and analyses check.
| Tag | Values |
|---|---|
| Time | continuous |
| Space | lattice |
| Laws | rate |
| Randomness | deterministic |
| Domains | complex |
| Structure | fixed |
Class
The source of the class shows how it builds its components from its model parameters.
class QuantumHeisenbergSystem(BaseSystem):
"""A chain of spins one half with the XXZ Hamiltonian.
The chain has a field and optional dephasing.
The Hamiltonian is `J Σ (S^x_i S^x_j + S^y_i S^y_j + Δ S^z_i S^z_j) - h Σ S^z_i` over neighbouring pairs, with `ħ =
1`. A dephasing rate `gamma > 0` adds the dissipator `S^z_i` on every site, so the state is a density matrix that
loses its coherence. One flipped spin in a ferromagnetic background spreads as a magnon, whose probability at
distance `d` is `J_d(J t)²` in the XX chain, a light cone in the space-time image of `S^z`. The total magnetisation
is conserved. The system has the observables `sz` of every site, `magnetization`, and the energy.
Args:
n_sites:
The number of spins.
J:
The exchange coupling, antiferromagnetic when positive.
delta:
The anisotropy `Δ`.
h:
The field.
gamma:
The dephasing rate.
boundary:
`'periodic'` for a ring, or `'open'` for a chain with two ends.
initial:
`'flip'` for one flipped spin at site `n_sites // 2`, `'neel'` for alternating spins, `'domain_wall'` for
the left half up and the right half down, or `'ground'` for the ground state, which the tuned run settings
start from as `initial_state={'<label>.state': 'ground'}`.
label:
The label of the system, which names it when it is nested in another one.
solver:
The solver of the problem, or `'auto'` for the one the system chooses.
backend:
The backend that evaluates the compiled functions, or `'auto'` for the one the system chooses.
Raises:
ValidationError:
The boundary or the initial state is unknown.
Examples:
>>> from skcomplex.systems.physics.statistical_mechanics import QuantumHeisenbergSystem
>>> len(QuantumHeisenbergSystem(6).prepare().system_.elements[0].psi)
6
"""
field = 'physics/statistical_mechanics'
topics = ('quantum', 'spins', 'lattice', 'magnetism', 'open system')
references = ('Heisenberg 1928', 'Mihailović et al. 2023')
until = 8.0
dt = 0.05
observables = (
Observable('sz', local_magnetization, group='chain', reduce=_get_sites),
Observable('magnetization', total_magnetization),
)
def __init__(
self,
n_sites: int = 12,
*,
J: float = 1.0,
delta: float = 1.0,
h: float = 0.0,
gamma: float = 0.0,
boundary: str = 'periodic',
initial: str = 'flip',
label: str = 'system',
solver: BaseSolver | str = 'auto',
backend: BaseBackend | str = 'auto',
) -> None:
super().__init__(label, solver=solver, backend=backend)
self.n_sites = n_sites
self.J = J
self.delta = delta
self.h = h
self.gamma = gamma
self.boundary = boundary
self.initial = initial
@staticmethod
def _get_initial_labels(n_sites: int, initial: str) -> list[str]:
"""Return the basis label of every spin of a product initial state."""
if initial == 'neel':
return ['up' if site % 2 == 0 else 'down' for site in range(n_sites)]
if initial == 'flip':
return ['down' if site == n_sites // 2 else 'up' for site in range(n_sites)]
return ['up' if site < n_sites // 2 else 'down' for site in range(n_sites)]
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set `system_` to the chain of spins with the exchange, the field, and the dephasing.
Args:
context:
The observables to compile with the problem, or `None` for none.
Raises:
ValidationError:
The boundary or the initial state is unknown.
"""
super()._prepare(context)
if self.boundary not in BOUNDARIES or self.initial not in INITIAL_STATES:
error_msg = (
f'Unknown boundary {self.boundary!r} or initial state {self.initial!r}. Use a boundary of '
f'{", ".join(BOUNDARIES)} and an initial state of {", ".join(INITIAL_STATES)}.'
)
raise ValidationError(error_msg)
space = LatticeSpace(self.n_sites, boundary=BOUNDARIES[self.boundary])
labels = self._get_initial_labels(self.n_sites, self.initial)
chain = SpinElement('chain', psi=labels, space=space)
interactions: list[BaseInteraction] = [
XXZExchangeInteraction('exchange', among='chain', J=self.J, delta=self.delta),
ZeemanFieldInteraction('field', target='chain', h=self.h),
]
if self.gamma > 0:
interactions.append(DephasingInteraction('dephasing', target='chain', gamma=self.gamma))
self.system_ = System(self.label, elements=[chain], interactions=interactions)
if self.initial == 'ground':
self.initial_state_ = {f'{self.label}.state': 'ground'}
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
SpinElement, fromElement
Interactions:
XXZExchangeInteraction, fromInteractionZeemanFieldInteraction, fromInteraction
class SpinElement(Element):
"""Spins of the Hilbert space they take.
Every spin has the spin components `x`, `y`, `z` and the ladder operators.
The basis is ordered from `m = j` to `m = -j`, so `'up'` is index 0 and `'down'` is the last index. Laws read the
operators of the state `psi` of a spin, such as `local_operator(s.target.psi, 'z')`. With `space`, there is one spin
at every site of the space, as along a chain.
Args:
label:
The label of the spin or of the spins.
psi:
The state in the Hilbert space: `'up'`, `'down'`, a basis index, or a vector, or one state per spin.
hilbert:
The Hilbert space of a spin, with the spin components `x`, `y`, `z` and the ladder operators `plus` and
`minus` as its operators, by default that of a spin one half.
space:
The lattice of the spins, or `None` for one spin.
Examples:
>>> from skcomplex.systems.physics.statistical_mechanics._quantum_spins import SpinElement
>>> SpinElement('s').hilbert.dimension
2
"""
visual = VisualSpec('expectations')
def __init__(
self,
label: str,
psi: Annotated[object, CC] = 'up',
*,
hilbert: HilbertSpec = SPIN_HALF,
space: BaseSpace | None = None,
) -> None:
super().__init__(label, space=space)
self.psi = psi
self.hilbert = hilbert
class XXZExchangeInteraction(Interaction):
"""Exchange between neighbouring spins.
The exchange is `J (S^x_i S^x_j + S^y_i S^y_j + Δ S^z_i S^z_j)` on every pair of neighbours of the space of the
spins.
Args:
label:
The label of the interaction.
among:
The path of the spins.
J:
The exchange coupling, antiferromagnetic when positive.
delta:
The anisotropy `Δ`, 1 for the isotropic chain and 0 for the XX chain.
along:
The pairs the exchange couples, `True` for the neighbours of the space of the spins.
Examples:
>>> from skcomplex.systems.physics.statistical_mechanics import XXZExchangeInteraction
>>> XXZExchangeInteraction('exchange', among='chain', delta=0.5).delta
0.5
"""
law_classes: ClassVar[tuple[type[BaseLaw], ...]] = (GeneratorLaw,)
def __init__(
self,
label: str,
*,
among: Role,
J: float = 1.0,
delta: float = 1.0,
along: bool | str = True,
) -> None:
super().__init__(label, among=among, along=along)
self.J = J
self.delta = delta
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the exchange Hamiltonian of one pair of neighbours.
Args:
context:
The namespace of the pair, with `source` and `target`, the time `t`, and the parameters.
"""
super()._prepare(context)
first, second = context.source.psi, context.target.psi
exchange = (
local_operator(first, 'x') * local_operator(second, 'x')
+ local_operator(first, 'y') * local_operator(second, 'y')
+ context.delta * local_operator(first, 'z') * local_operator(second, 'z')
)
self.laws_ = [GeneratorLaw(context.J * exchange)]
class ZeemanFieldInteraction(Interaction):
"""Uniform field `-h Σ S^z_i` on the spins of a chain.
Args:
label:
The label of the interaction.
target:
The path of the spin chain.
h:
The field.
Examples:
>>> from skcomplex.systems.physics.statistical_mechanics import ZeemanFieldInteraction
>>> ZeemanFieldInteraction('field', target='chain', h=0.2).h
0.2
"""
law_classes: ClassVar[tuple[type[BaseLaw], ...]] = (GeneratorLaw,)
def __init__(self, label: str, *, target: Role, h: float = 0.0) -> None:
super().__init__(label)
self.target = target
self.h = h
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the Hamiltonian of the field.
Args:
context:
The namespace of the spins of the target, the time `t`, and the parameters.
"""
super()._prepare(context)
self.laws_ = [GeneratorLaw(-context.h * sum(local_operator(member.psi, 'z') for member in context.target))]