|
| 1 | +""" |
| 2 | +Analog circuit simulation for Rydberg array |
| 3 | +""" |
| 4 | + |
| 5 | +import numpy as np |
| 6 | +import tensorcircuit as tc |
| 7 | + |
| 8 | +K = tc.set_backend("jax") |
| 9 | +tc.set_dtype("complex128") |
| 10 | + |
| 11 | +# Define simulation parameters |
| 12 | +# a compatible set of units: mus, mum, MHz |
| 13 | +nqubits = 12 |
| 14 | +omega = 2.0 * np.pi |
| 15 | +delta = 0.0 |
| 16 | +c6 = 8e8 |
| 17 | +evolution_time = 2.0 |
| 18 | + |
| 19 | +# Define the 1D lattice |
| 20 | +chain = tc.templates.lattice.ChainLattice([nqubits], lattice_constant=10, pbc=False) |
| 21 | + |
| 22 | +# Instantiate the AnalogCircuit |
| 23 | +ac = tc.AnalogCircuit(nqubits) |
| 24 | + |
| 25 | +# 1. Create the sparsely excited state |
| 26 | +ac.x([i for i in range(nqubits) if i % 4 == 0]) |
| 27 | + |
| 28 | +rydberg_hmatrix = tc.templates.hamiltonians.rydberg_hamiltonian( |
| 29 | + chain, omega=omega, delta=delta, c6=c6 |
| 30 | +) |
| 31 | + |
| 32 | + |
| 33 | +# 2. Define the time-dependent Rydberg Hamiltonian |
| 34 | +def rydberg_hamiltonian_func(t): |
| 35 | + # In this example, the Hamiltonian is time-independent, but it could be a function of t |
| 36 | + return rydberg_hmatrix |
| 37 | + |
| 38 | + |
| 39 | +# 3. Add the analog evolution block |
| 40 | +ac.add_analog_block(rydberg_hamiltonian_func, time=evolution_time) |
| 41 | + |
| 42 | +# 4. apply some digital gates if needed, say for random measurements |
| 43 | + |
| 44 | +# for i in range(nqubits): |
| 45 | +# j = np.random.choice(3) |
| 46 | +# if j == 1: |
| 47 | +# ac.h(i) |
| 48 | +# elif j == 2: |
| 49 | +# ac.rx(i, theta=-np.pi/4) |
| 50 | + |
| 51 | +# 5. Sample from the final state in the computational basis |
| 52 | +sample = ac.sample(batch=1024, allow_state=True, format="count_dict_bin") |
| 53 | +print("\nSampled bitstrings:\n", sample) |
0 commit comments