Heisenberg Spin Chain Dynamics
Simulate the time evolution of a 1D Heisenberg chain and watch correlations spread across the lattice.
Constructing the Hamiltonian
import qalgora
from qalgora import operators
import numpy as np
def heisenberg(n, Jx, Jy, Jz):
H = 0
for i in range(n - 1):
H += (Jx * operators.spin.x(i) * operators.spin.x(i + 1)
+ Jy * operators.spin.y(i) * operators.spin.y(i + 1)
+ Jz * operators.spin.z(i) * operators.spin.z(i + 1))
return H
H = heisenberg(6, 1.0, 1.0, 1.0)
Evolving from a domain wall
The initial state domain_wall_state is the product state with the left half of the
chain spin-up and the right half spin-down (|↑↑↑↓↓↓⟩) — supply your own state object here
(illustrative fragment).
dims = {i: 2 for i in range(6)}
# domain_wall_state: left half |1>, right half |0> (construct from your state API)
result = qalgora.evolve(
H, dimensions=dims,
schedule=qalgora.Schedule(steps=np.linspace(0, 5, 200), parameters=["t"]),
initial_state=domain_wall_state,
observables=[operators.spin.z(i) for i in range(6)],
)
# <Z_i>(t) shows magnetization spreading from the initial wall
GPU dynamics (planned)
GPU integration of the full many-body state is a planned / unreleased interface. On
the planned dynamics target it would reach longer spin chains than are tractable on CPU.
Heisenberg 自旋链动力学
模拟一维 Heisenberg 链的时间演化,观察关联如何在晶格中传播。
构建哈密顿量
import qalgora
from qalgora import operators
import numpy as np
def heisenberg(n, Jx, Jy, Jz):
H = 0
for i in range(n - 1):
H += (Jx * operators.spin.x(i) * operators.spin.x(i + 1)
+ Jy * operators.spin.y(i) * operators.spin.y(i + 1)
+ Jz * operators.spin.z(i) * operators.spin.z(i + 1))
return H
H = heisenberg(6, 1.0, 1.0, 1.0)
从畴壁态开始演化
初态 domain_wall_state 即链左半自旋向上、右半自旋向下的直积态(|↑↑↑↓↓↓⟩)——此处为示例片段,需自行构造对应的态对象。
dims = {i: 2 for i in range(6)}
# domain_wall_state 左半 |1> 右半 |0>(用你的态 API 构造)
result = qalgora.evolve(
H, dimensions=dims,
schedule=qalgora.Schedule(steps=np.linspace(0, 5, 200), parameters=["t"]),
initial_state=domain_wall_state,
observables=[operators.spin.z(i) for i in range(6)],
)
# <Z_i>(t) 展示磁化从初始畴壁向外扩散
GPU 动力学(规划中)
对完整多体态的 GPU 积分为规划中 / 尚未发布的接口。在规划中的动力学后端上,它能够模拟 CPU 难以处理的更长自旋链。