summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--gnuplot_2q.plt7
-rw-r--r--plotting.py57
-rw-r--r--single_dequantify.py11
-rw-r--r--twoqbit_dequantify.py49
5 files changed, 63 insertions, 64 deletions
diff --git a/.gitignore b/.gitignore
index 0c7b4fc..86b607b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
-data
+data*
+plotting.py
__pycache__
diff --git a/gnuplot_2q.plt b/gnuplot_2q.plt
new file mode 100644
index 0000000..6614b49
--- /dev/null
+++ b/gnuplot_2q.plt
@@ -0,0 +1,7 @@
+set view equal xyz
+set parametric
+set isosamples 34,34
+splot cos(u)*cos(v),cos(u)*sin(v),sin(u) w l lc rgb "#42a4f5"
+replot 'data2q' w points palette pointsize 2 pointtype 7
+;
+pause mouse close
diff --git a/plotting.py b/plotting.py
deleted file mode 100644
index 57116c1..0000000
--- a/plotting.py
+++ /dev/null
@@ -1,57 +0,0 @@
-import math as mth
-import cmath as cmt
-import numpy as npy
-from mpl_toolkits.mplot3d import Axes3D
-import matplotlib.pyplot as plt
-from itertools import product, combinations
-from matplotlib.patches import FancyArrowPatch
-from mpl_toolkits.mplot3d import proj3d
-
-
-class Arrow3D(FancyArrowPatch):
-
- def __init__(self, xs, ys, zs, *args, **kwargs):
- FancyArrowPatch.__init__(self, (0, 0), (0, 0), *args, **kwargs)
- self._verts3d = xs, ys, zs
-
- def draw(self, renderer):
- xs3d, ys3d, zs3d = self._verts3d
- xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
- self.set_positions((xs[0], ys[0]), (xs[1], ys[1]))
- FancyArrowPatch.draw(self, renderer)
-
-
-def kugel(historie):
- fig = plt.figure()
- ax = fig.gca(projection='3d')
-
- # draw sphere
- u, v = npy.mgrid[0:2*npy.pi:20j, 0:npy.pi:10j]
- x = npy.cos(u)*npy.sin(v)
- y = npy.sin(u)*npy.sin(v)
- z = npy.cos(v)
- ax.plot_wireframe(x, y, z, color="r")
-
- # draw a time evolution
- for blochpunkt in historie:
- x = mth.cos(blochpunkt[1]) * mth.cos(blochpunkt[0])
- y = mth.cos(blochpunkt[1]) * mth.sin(blochpunkt[0])
- z = mth.sin(blochpunkt[1])
- a = Arrow3D([0, x], [0, y], [0, z], mutation_scale=20,
- lw=1, arrowstyle="-|>", color="k")
- ax.add_artist(a)
- plt.show()
-
-def phi(phi):
- ax = plt.axes()
- plt.grid()
-
- x = mth.cos(phi[0])
- y = mth.sin(phi[0])
-
- ax.arrow(0, 0, 0.5, 0.5, head_width=0.05, head_length=0.07)
- plt.title('Zeitentwicklung von phi')
-
- plt.xlim(-1.1,1.1)
- plt.ylim(-1.1,1.1)
- plt.show()
diff --git a/single_dequantify.py b/single_dequantify.py
index 8e801a1..db2ed0c 100644
--- a/single_dequantify.py
+++ b/single_dequantify.py
@@ -5,7 +5,7 @@ import cmath as cmt
import numpy as npy
import scipy.linalg as sla
-alpha = 3
+alpha = 0
beta = 1
norm = npy.linalg.norm([alpha, beta])
@@ -14,7 +14,7 @@ state = npy.array([alpha / norm, beta / norm])
dt = 0.1
iterations = 61
-H = npy.array([[2,0],[0,3]])
+H = npy.array([[2,1j],[-1j,3]])
def time_evolution(state, dt = dt):
return npy.dot(state, sla.expm(-1j * dt * H))
@@ -36,13 +36,12 @@ def sphere2cart(phi, theta):
historie = npy.array([bloch_map(state)])
f = open("data", "w")
-for i in range(iterations):
- state = time_evolution(state)
- h = npy.dot(state, state)
+for i in range(iterations + 1):
historie = npy.vstack([historie,bloch_map(state)])
(phi, theta) = bloch_map(state)
coords = sphere2cart(phi, theta)
- f.write(f"{coords[0]}; {coords[1]}; {coords[2]}; {(i + 1) / iterations}\n")
+ f.write(f"{coords[0]}; {coords[1]}; {coords[2]}; {(i + 1) / (iterations + 1)}\n")
+ state = time_evolution(state)
f.close()
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"])