Skip to content

Commit 13f9777

Browse files
add fgs docs
1 parent d198154 commit 13f9777

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

docs/source/advance.rst

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,66 @@ Please refer to :py:meth:`tensorcircuit.templates.measurements.sparse_expectatio
219219

220220
For different representations to evaluate Hamiltonian expectation in tensorcircuit, please refer to :doc:`tutorials/tfim_vqe_diffreph`.
221221

222+
223+
Fermion Gaussian State Simulator
224+
--------------------------------
225+
226+
TensorCircuit-NG provides a powerful Fermion Gaussian State (FGS) simulator for efficient simulation of non-interacting fermionic systems (with or without U(1) symmtery). The simulator is particularly useful for studying quantum many-body physics and entanglement properties.
227+
228+
229+
.. code-block:: python
230+
231+
import tensorcircuit as tc
232+
import numpy as np
233+
234+
# Initialize a 4-site system with sites 0 and 2 occupied
235+
sim = tc.FGSSimulator(L=4, filled=[0, 2])
236+
237+
# Evolve with hopping terms
238+
sim.evol_hp(i=0, j=1, chi=1.0) # hopping between sites 0 and 1
239+
240+
# Calculate entanglement entropy for subsystem of sites 0, 1
241+
entropy = sim.entropy([2, 3])
242+
243+
244+
The simulator supports various operations including:
245+
246+
1. State initialization from quadratic Hamiltonians ground states
247+
2. Time evolution (real and imaginary)
248+
3. Entanglement measures (von Neumann, Renyi entropies and entanglement asymmetry)
249+
4. Correlation matrix calculations
250+
5. Measurements
251+
252+
253+
Here's an example studying entanglement asymmetry in tilted ferromagnet states:
254+
255+
.. code-block:: python
256+
257+
def xy_hamiltonian(theta, L):
258+
# XY model with tilted field
259+
gamma = 2 / (np.cos(theta) ** 2 + 1) - 1
260+
mu = 4 * np.sqrt(1 - gamma**2) * np.ones([L])
261+
262+
# Construct Hamiltonian terms
263+
h = (generate_hopping_h(2.0, L) +
264+
generate_pairing_h(gamma * 2, L) +
265+
generate_chemical_h(mu))
266+
return h
267+
268+
def get_saq_sa(theta, l, L, k, batch=1024):
269+
# Calculate entanglement asymmetry in the middle subsystem with size l
270+
traceout = [i for i in range(0, L//2 - l//2)] + \
271+
[i for i in range(L//2 + l//2, L)]
272+
273+
# Get Hamiltonian ground state which is within FGS
274+
hi = xy_hamiltonian(theta, L)
275+
sim = tc.FGSSimulator(L, hc=hi)
276+
277+
# Get both symmetry-resolved and standard entanglement
278+
return (np.real(sim.renyi_entanglement_asymmetry(k, traceout, batch=batch)),
279+
sim.renyi_entropy(k, traceout))
280+
281+
222282
Randoms, Jit, Backend Agnostic, and Their Interplay
223283
--------------------------------------------------------
224284

@@ -310,4 +370,4 @@ It is worth noting that since ``Circuit.unitary_kraus`` and ``Circuit.general_kr
310370

311371
One may wonder why random numbers are dealt in such a complicated way, please refer to the `Jax design note <https://github.com/google/jax/blob/main/docs/design_notes/prng.md>`_ for some hints.
312372

313-
If vmap is also involved apart from jit, I currently find no way to maintain the backend agnosticity as TensorFlow seems to have no support of vmap over random keys (ping me on GitHub if you think you have a way to do this). I strongly recommend the users using Jax backend in the vmap+random setup.
373+
If vmap is also involved apart from jit, I currently find no way to maintain the backend agnosticity as TensorFlow seems to have no support of vmap over random keys (ping me on GitHub if you think you have a way to do this). I strongly recommend the users using Jax backend in the vmap+random setup.

0 commit comments

Comments
 (0)