Adiabatic AF state preparation #698
-
|
Hello everyone, I am currently trying to simulate the adiabatic antiferromagnetic state preparation. Here is the code I made: import torch
from torch import tensor
from qadence import sample, TimeParameter, FeatureParameter, X, Y, Z, N, add, kron, Register, HamEvo, run, BackendName, PI, expectation
from qadence.analog.constants import C6_DICT
from pyqtorch.utils import SolverType
import numpy as np
from sympy import cos, sin, exp, tanh
ode_solver = SolverType.KRYLOV_SE # time-dependent Schrodinger equation solver method
n_steps_hevo = 10000 # integration time steps used by solver
# Parameters
c_6 = C6_DICT[60] # [rad*μm^6/μs]
U = 2*PI # [rad/μs]
omega_max = 2*U
delta_0 = -6*U
delta_f = 2*U
# Time parameters on pulses Omega and delta
t_rise = 0.252 # [μs]
t_fall = 0.5 # [μs]
t_total = 1.552 # [μs]
# Register
n = 3
dx = (c_6 / U) ** (1/6) # [μm]
reg = Register.rectangular_lattice(qubits_row = 3, qubits_col = 3, spacing=dx)
# Initial state: ground state
initial_state = torch.zeros(2**(n**2), dtype=torch.complex128).unsqueeze(0)
initial_state[0] = 1
# Hamiltonian parameters
t = TimeParameter("t")
omega_param = FeatureParameter("omega") # [rad/μs]
delta_param = FeatureParameter("delta") # [rad/μs]
a = 50000
def f(t):
return 0.5 * (tanh(a * t) + 1)
omega_t = omega_max/t_rise * t * (f(t) - f(t-t_rise)) + omega_max * (f(t-t_rise) - f(t-(t_total-t_fall))) + (omega_max/t_fall * (t_total-t)) * (f(t-(t_total-t_fall)) - f(t-t_total))
delta_t = delta_0 * (f(t+0.1) - f(t-t_rise)) + (((delta_f-delta_0)*t/(t_total-t_fall-t_rise)) + delta_0 - (delta_f-delta_0)*t_rise/(t_total-t_fall-t_rise)) * (f(t-t_rise) - f(t-(t_total-t_fall))) + delta_f * (f(t-(t_total-t_fall)) - f(t-(t_total+0.1)))
Rb = (c_6/omega_t)**(1/6)
cociente = Rb/dx
# Hamiltonian
h_x = (omega_param * omega_t / 2) * add(X(i) for i in range(n))
h_n = -1.0 * delta_param * delta_t * add(N(i) for i in range(n))
h_d = h_x + h_n # Driving Hamiltonian
h_nn = U * (N(0)@N(1) + N(0)@N(1) + N(1)@N(2)
+ N(2)@N(5) + N(5)@N(8) + N(8)@N(7)
+ N(7)@N(6) + N(6)@N(3) + N(3)@N(0)
+ N(4)@N(1) + N(4)@N(3) + N(4)@N(7)
+ N(4)@N(5))# Ising
h = h_d + h_nn
# Duration time evolution
duration = t_total * 1e3 # [ns] 1e3 ns = 1 μs
# Omega and delta values
param_values = {
"omega": tensor(1),
"delta": tensor(1)
}
# Evolution
evo = HamEvo(h, parameter=t, duration=duration/1000)
# Sample
xs = sample(reg, evo, state=initial_state, values=param_values, n_shots=10000)The thing is, I used the exact same pulses Omega and delta that are being used on this pulser tutorial (you can check the pulses by running the omega_t and delta_t lines) and the same Rydberg coefficient. I also used the exact same register: The issue is that I am not getting the AF state whatsoever. The result I obtained is:
Maybe the problem lies when defining the Hamiltonian, as I do not exactly understand the Parameter thing. Can someone check if the Hamiltonian is well-defined? Also, maybe I have to drop this idea as the code takes too long to compute, if anyone has a better idea of study with Qadence I am open to hear it. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Hello again everyone, Somehow I managed to fix the code shown above (I'm impressed by myself), if anyone wants to see it, here it is: import torch
from torch import tensor
from qadence import sample, product_state, TimeParameter, FeatureParameter, X, Y, Z, N, add, kron, Register, HamEvo, run, BackendName, PI, expectation
from qadence.analog.constants import C6_DICT
from pyqtorch.utils import SolverType
import numpy as np
from sympy import cos, sin, exp, tanh
ode_solver = SolverType.KRYLOV_SE # time-dependent Schrodinger equation solver method
n_steps_hevo = 10000 # integration time steps used by solver
# Parameters
c_6 = C6_DICT[60] # [rad*μm^6/μs]
U = 2*PI # [rad/μs]
# Time parameters on pulses Omega and delta
t_rise = 0.252 # [μs]
t_fall = 0.5 # [μs]
t_total = 1.552 # [μs]
# Register
n = 3
dx = (c_6 / U) ** (1/6) # [μm]
reg = Register.rectangular_lattice(qubits_row=n, qubits_col=n, spacing=dx)
# Initial state: ground state
initial_state = product_state("000000000")
# Hamiltonian parameters
t = TimeParameter("t")
omega_max_param = FeatureParameter("omega_max") # [rad/μs]
delta_0_param = FeatureParameter("delta_0") # [rad/μs]
delta_f_param = FeatureParameter("delta_f") # [rad/μs]
a = 50000
def f(t):
return 0.5 * (tanh(a * t) + 1)
omega_t = omega_max_param/t_rise * t * (f(t) - f(t-t_rise)) + omega_max_param * (f(t-t_rise) - f(t-(t_total-t_fall))) + (omega_max_param/t_fall * (t_total-t)) * (f(t-(t_total-t_fall)) - f(t-t_total))
delta_t = delta_0_param * (f(t+0.1) - f(t-t_rise)) + (((delta_f_param-delta_0_param)*t/(t_total-t_fall-t_rise)) + delta_0_param - (delta_f_param-delta_0_param)*t_rise/(t_total-t_fall-t_rise)) * (f(t-t_rise) - f(t-(t_total-t_fall))) + delta_f_param * (f(t-(t_total-t_fall)) - f(t-(t_total+0.1)))
# Hamiltonian
h_x = (omega_t / 2) * add(X(i) for i in range(3*n))
h_n = -1.0 * delta_t * add(N(i) for i in range(3*n))
h_d = h_x + h_n # Driving Hamiltonian
h_nn = U * (N(0)@N(1) + N(1)@N(2)
+ N(2)@N(5) + N(5)@N(8) + N(8)@N(7)
+ N(7)@N(6) + N(6)@N(3) + N(3)@N(0)
+ N(4)@N(1) + N(4)@N(3) + N(4)@N(7)
+ N(4)@N(5)) # Ising
h = h_d + h_nn
# Duration time evolution
duration = t_total * 1e3 # [ns] 1e3 ns = 1 μs
# Omega and delta values
param_values = {
"omega_max": tensor(2*U),
"delta_0": tensor(-6*U),
"delta_f": tensor(2*U)
}
# Evolution
evo = HamEvo(h, parameter=t, duration=duration/1000)
# Sample
xs = sample(reg, evo, state=initial_state, values=param_values, n_shots=10000)which gives the desired AF state:
@jpmoutinho you can check if this is good enough, I am happy with the result :) |
Beta Was this translation helpful? Give feedback.
-
|
Additionaly, if anyone is curious, this is the evolution of the whole system under the hamiltonian shown in the selected reply: the phase transition from the ground state to the antiferromagnetic state is clearly visible, although the qubit 4 is not that populated since it is the one in the middle of the square lattice, and therefore it is interacting with 4 nearest neighbours. EDIT: there was a slight error in the code. In the interacting Hamiltonian, the term |
Beta Was this translation helpful? Give feedback.


Hello again everyone,
Somehow I managed to fix the code shown above (I'm impressed by myself), if anyone wants to see it, here it is: