Skip to content

Conversation

@QuiXamii
Copy link

@QuiXamii QuiXamii commented Nov 5, 2025

This module implements VQE optimization for finding ground states of the generalized 2D toric code Hamiltonian with open boundary conditions and provides comparison among different ansätze: FLDC, GLDC, and FDC. The new example demonstrates how to build the model, configure ansätze, run optimization, and compare energies and convergence behavior.

image image

This module implements VQE optimization for finding ground states of the
generalized 2D toric code Hamiltonian with open boundary conditions and provides comparison
among different ansätze: FLDC, GLDC, and FDC.
Build the generalized 2D toric code Hamiltonian with open boundary conditions.

The Hamiltonian is: H = -(1-h)∑A_v - (1-h)∑B_p - h∑(hx*X_i + hz*Z_i)
where A_v are vertex operators (X products) and B_p are plaquette operators (Z products).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more elaboration on how plaquette operators is defined at the boundary

circuit.RZ(q1, theta=params[7])
circuit.RY(q2, theta=params[8])
circuit.RZ(q1, theta=params[9])
circuit.RZ(q2, theta=params[10])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how this is su4 gate as su4 gate has 15 parameters? though it is ok for demonstration here, the latest version of tc has native c.su4(i, i+1, theta=vec_15).

c: tc.Circuit, h: float, hx: float, hz: float, Lx: int, Ly: int
) -> float:
"""Calculate toric code energy for a given circuit state."""
H = build_toric_hamiltonian(Lx=Lx, Ly=Ly, h=h, hx=hx, hz=hz)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then H is built every iteration? a bad design

@refraction-ray
Copy link
Member

In general looks good, but some changes are required as comments

@codecov
Copy link

codecov bot commented Nov 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants