simplify harmonic circuit with just a constant. I don't think the circuit is correct at that point
@@ -42,11 +42,10 @@ class Harmonic(Potential):
"""
#@abstractmethod
- def __init__(self, num_qubits, m, omega, x0, delta, tau):
+ def __init__(self, num_qubits, const, x0, delta, tau):
super().__init__()
self._num_qubits = num_qubits
- self._m = m
- self._omega = omega
+ self._c = const
self._x0 = x0
self._delta = delta
self._tau = tau
@@ -76,12 +75,12 @@ class Harmonic(Potential):
circ = np.zeros((1<<self._num_qubits,1<<self._num_qubits), dtype='complex64')
if ordering == 'normal':
for i in range(1<<self._num_qubits):
- circ[i,i]=-1.j * 0.5 * self._m * self._omega**2 * (self._x0 + i*self._delta)**2 * self._tau
+ circ[i,i]=-1.j * 0.5 * self._c * (self._x0 + i*self._delta)**2 * self._tau
elif ordering == 'reversed':
for i in range(1<<self._num_qubits):
j = (1<<self._num_qubits)-1-i
- circ[j,j]=-1.j * 0.5 * self._m * self._omega**2 * (self._x0 + i*self._delta)**2 * self._tau
+ circ[j,j]=-1.j * 0.5 * self._c * (self._x0 + i*self._delta)**2 * self._tau
else:
raise ValueError('Ordering should be either "normal" or "reversed"')
@@ -93,12 +92,12 @@ class Harmonic(Potential):
elif mode=='circuit':
if ordering == 'normal':
- gamma = 0.5 * self._m * self._omega**2 *self._tau
+ gamma = 0.5 * self._c *self._tau
q = QuantumRegister(self._num_qubits, name='q')
circ = QuantumCircuit(q)
- global phase
+ #global phase
circ.u1(-1 * gamma * self._x0**2, q[0])
circ.x(q[0])
circ.u1(-1 * gamma * self._x0**2, q[0])
@@ -118,14 +117,12 @@ class Harmonic(Potential):
elif ordering == 'reversed':
- #self._x0 = self._x0 + self._delta*((1<<self._num_qubits)-1)
- #self._delta = -self._delta
- gamma = 0.5 * self._m * self._omega**2 *self._tau
+ gamma = 0.5 * self._c *self._tau
q = QuantumRegister(self._num_qubits, name='q')
circ = QuantumCircuit(q)
- global phase
+ #global phase
circ.u1(-1 * gamma * self._x0**2, q[0])
circ.x(q[0])
circ.u1(-1 * gamma * self._x0**2, q[0])
