summaryrefslogtreecommitdiff
path: root/twoqbit_dequantify.py
diff options
context:
space:
mode:
authorRuben Erlenstedt <rxy626@gmail.com>2019-11-30 16:55:12 +0100
committerRuben Erlenstedt <rxy626@gmail.com>2019-11-30 16:55:12 +0100
commit3c5f2981c616e7375a3155d4bfaffec6e361ff89 (patch)
tree5ca59aa1e54d602058ef23ee8037fb91ae807f1f /twoqbit_dequantify.py
parentb3c6bad7b98c156429c88e1ecad4ffb53db2871b (diff)
Adapt time evolution for 2qbit
Diffstat (limited to 'twoqbit_dequantify.py')
-rw-r--r--twoqbit_dequantify.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/twoqbit_dequantify.py b/twoqbit_dequantify.py
new file mode 100644
index 0000000..9165a12
--- /dev/null
+++ b/twoqbit_dequantify.py
@@ -0,0 +1,49 @@
+import subprocess
+import math as mth
+import cmath as cmt
+import numpy as npy
+import scipy.linalg as sla
+
+alpha = 1
+beta = 1
+gamma = 1
+delta = 1
+
+norm = npy.linalg.norm([alpha, beta, gamma, delta])
+state = npy.array([alpha / norm, beta / norm, gamma / norm, delta / norm])
+
+dt = 0.1
+iterations = 5
+
+H = npy.array([[1,0,0,0],[0,2,0,0],[0,0,3,0],[0,0,0,4]])
+
+M0 = [[1,0,0,0],[0,1,0,0],[0,0,-1,0],[0,0,0,-1]]
+M1 = [[0,0,1,0],[0,0,0,1],[1,0,0,0],[0,1,0,0]]
+M2 = [[0,0,-1j,0],[0,0,0,-1j],[1j,0,0,0],[0,1j,0,0]]
+M3 = [[0,0,0,1],[0,0,-1,0],[0,-1,0,0],[1,0,0,0]]
+
+
+def time_evolution(state, dt = dt):
+ return npy.dot(state, sla.expm(-1j * dt * H))
+
+def fibration(state):
+ x0=npy.dot(npy.conj(state),npy.dot(M0,state))
+ x1=npy.dot(npy.conj(state),npy.dot(M1,state))
+ x2=npy.dot(npy.conj(state),npy.dot(M2,state))
+ V=npy.dot(state,npy.dot(M3,state))
+ x3=V.real
+ x4=V.imag
+
+ return ([x0.real,x1.real,x2.real,x3,x4])
+
+
+f = open("data2q", "w")
+
+for i in range(iterations + 1):
+ hopf_state = fibration(state)
+ f.write(f"{hopf_state[0]}; {hopf_state[1]}; {hopf_state[2]}; {(i + 1) / (iterations + 1)}\n")
+ state = time_evolution(state)
+
+f.close()
+
+subprocess.run(["gnuplot", "gnuplot_2q.plt"])