ising
¶
Classical and transverse-field Ising model factory.
IsingModel
dataclass
¶
Bundled operators for a classical or transverse-field Ising Hamiltonian.
Qubits are labeled 0 .. num_qubits - 1. Couplings act on the edge set
edges; single-site fields are on every qubit. Every ZZ edge and every
single-site field is a LocalHamiltonian. A long-range edge, including
the periodic wrap, names its two endpoints. Embedding that term puts
identity on the sites in between.
Attributes:
-
full_hamiltonians(list[Hamiltonian]) –Hamiltonian terms in the full Hilbert space.
-
local_hamiltonians(list[LocalHamiltonian]) –One ZZ term per edge and one single-site field per qubit.
-
c_ops_full(list[Operator]) –Lindblad operators in the full space (empty; closed system).
-
c_ops_local(list[LocalOperator]) –Local Lindblad operators (empty; closed system).
-
psi0(State) –Default initial state (all-|0⟩ classical, all-|+⟩ transverse).
-
e_ops(list[Operator]) –Per-site
Zobservables. -
measurements(list[Measurement]) –Per-site
Zexpectations from shot counts, matchinge_ops. -
pauli_sum(PauliSum) –Full Hamiltonian as a sparse Pauli sum.
-
edges(list[tuple[int, int]]) –Resolved undirected interaction pairs
(i, j)withi < j. -
num_qubits(int) –Number of qubits.
-
J(float) –Coupling strength.
-
h(float) –Field strength.
-
field(FieldKind) –"classical"(Z field) or"transverse"(X field). -
topology(TopologyKind) –"chain"or"custom"whenedgeswas supplied. -
boundary(BoundaryKind) –Boundary condition used for chain presets (
"open"for custom).
Source code in shadowsim/models/ising.py
ising
¶
ising(
*,
n_qubits: int,
J: float = 1.0,
h: float = 0.0,
field: FieldKind = "transverse",
topology: TopologyKind = _DEFAULT_TOPOLOGY,
boundary: BoundaryKind = _DEFAULT_BOUNDARY,
edges: Sequence[tuple[int, int]] | None = None,
) -> IsingModel
Build a classical or transverse-field Ising model.
Classical field
\(H = J \sum_{(i,j) \in E} Z_i Z_j + h \sum_i Z_i\)
Transverse field
\(H = J \sum_{(i,j) \in E} Z_i Z_j + h \sum_i X_i\)
Connectivity E comes from a 1D chain preset (topology="chain" with
boundary="open" or "periodic") or from an explicit edges list.
Parameters:
-
n_qubits(int) –Number of qubits (at least 2).
-
J(float, default:1.0) –ZZ coupling strength.
-
h(float, default:0.0) –On-site field strength.
-
field(FieldKind, default:'transverse') –"classical"for a Z field,"transverse"for an X field. -
topology(TopologyKind, default:_DEFAULT_TOPOLOGY) –Preset graph when
edgesis omitted (only"chain"). -
boundary(BoundaryKind, default:_DEFAULT_BOUNDARY) –Chain boundary condition when
edgesis omitted. -
edges(Sequence[tuple[int, int]] | None, default:None) –Optional undirected interaction pairs. When set, overrides topology/boundary (which must remain at their defaults).
Returns:
-
IsingModel–An
IsingModelwith full/local Hamiltonians and default closed-system -
IsingModel–simulation helpers.
Raises:
-
ValueError–On invalid size, field, topology, boundary, edges, or when both
Jandhare zero (no Hamiltonian terms).
Source code in shadowsim/models/ising.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |