Spins
Spin realizations shared by the physics packages.
The package holds Ising spins and the Monte Carlo sampling of Ising spins.
IsingSamplingInteraction(label, *, target, state='spin')
Bases: SpinSamplingInteraction
Boltzmann weight of Ising spins s = ±1, whose local energy is -J s sum_j s_j - h s.
The coupling J, the field h, and the temperature are values of the spins, and the MetropolisSolver of the
system flips them, MetropolisSolver(moves={'spins.spin': 'flip'}).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the components of its system. |
required |
target
|
Role
|
The path of the group of spins. |
required |
state
|
str
|
The name of the state that holds the spin. |
'spin'
|
Examples:
>>> from types import SimpleNamespace
>>> from sage.all__sagemath_symbolics import var
>>> from skcomplex.systems.physics.common.spins import IsingSamplingInteraction
>>> ising = IsingSamplingInteraction('ising', target='spins')
>>> other = SimpleNamespace(spin=var('t'))
>>> ising.energy(SimpleNamespace(target=SimpleNamespace(spin=var('s'), J=1, h=var('h'), other=other)))
-h*s - s*neighbors(t, reduce='sum')
Source code in src/skcomplex/systems/physics/common/spins/_ising_sampling.py
44 45 | |
IsingSpinElement(label, *, spin=1.0, J=1.0, h=0.0, temperature=2.0, space=None)
Bases: Element
Ising spins, up at 1 or down at -1.
Every spin has its coupling J, its field h, and its temperature.
An IsingSamplingInteraction flips the spins by Monte Carlo sweeps at the temperature of the spins.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the spin or the lattice of spins. |
required |
spin
|
object
|
The initial spin, 1 or -1, or one spin per site. |
1.0
|
J
|
float
|
The coupling between neighbouring spins. |
1.0
|
h
|
float
|
The external field. |
0.0
|
temperature
|
Annotated[float, open(0, oo)]
|
The temperature in units of the coupling. |
2.0
|
space
|
BaseSpace | None
|
The lattice or network of the spins, or |
None
|
Examples:
>>> from skcomplex.systems.physics.common.spins import IsingSpinElement
>>> IsingSpinElement('spin').temperature
2.0
Source code in src/skcomplex/systems/physics/common/spins/_ising_spin.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
SpinSamplingInteraction(label, *, target, state, energy)
Bases: Interaction
Boltzmann weight of the spins of a lattice or network group, at the temperature of the spins.
The objective of every spin is its local energy over the value temperature of the spins, E / T, so the
temperature lives with the couplings and fields of the spins, and a schedule of <group>.temperature changes it
during a run. The MetropolisSolver of the system moves the spins, such as
MetropolisSolver(moves={'spins.spin': 'flip'}). The local energy reads the spin as namespace.target and a
neighbour as namespace.target.other.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the components of its system. |
required |
target
|
Role
|
The path of the group of spins. |
required |
state
|
str
|
The name of the state the moves change. |
required |
energy
|
Callable[[SimpleNamespace], object]
|
The function |
required |
Examples:
>>> from skcomplex.core.components.laws.utils import neighbors
>>> from skcomplex.systems.physics.common.spins import SpinSamplingInteraction
>>> energy = lambda n: -n.target.spin * neighbors(n.target.other.spin)
>>> SpinSamplingInteraction('ising', target='spins', state='spin', energy=energy).state
'spin'
Source code in src/skcomplex/systems/physics/common/spins/_spin_sampling.py
47 48 49 50 51 52 53 54 55 56 57 58 | |
ThermalSamplingInteraction(label, *, target, state, energy, temperature=1.0)
Bases: Interaction
Boltzmann weight exp(-E / T) of a state of the members of a group, at a temperature.
The objective of every member is its local energy over the temperature, E / T, such as
-s sum_j s_j / T for an Ising spin, and the MetropolisSolver of the system moves the state, such as
MetropolisSolver(moves={'spins.s': 'flip'}). The temperature is a value of the system, so a sweep or a schedule
changes it like any value. It samples the spins of a magnet, the angles of a lattice gauge field, or the opinions
of a population with a social energy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the components of its system. |
required |
target
|
Role
|
The path of the group on the sites of a lattice or the nodes of a network. |
required |
state
|
str
|
The name of the state the moves change. |
required |
energy
|
Callable[[SimpleNamespace], object]
|
The function |
required |
temperature
|
Annotated[float, open(0, oo)]
|
The temperature. |
1.0
|
Examples:
>>> from skcomplex.core.components.laws.utils import neighbors
>>> from skcomplex.systems.physics.common.spins import ThermalSamplingInteraction
>>> energy = lambda n: -n.target.s * neighbors(n.target.other.s)
>>> ThermalSamplingInteraction('ising', target='spins', state='s', energy=energy, temperature=2.0).temperature
2.0
Source code in src/skcomplex/systems/physics/common/spins/_thermal_sampling.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |