summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Kobert <dennis@kobert.dev>2019-11-30 18:30:56 +0100
committerDennis Kobert <dennis@kobert.dev>2019-11-30 18:30:56 +0100
commite1172e94602f4cf003392409d9543d17c31881dc (patch)
tree5975b9d1c7e21ad0d496412da625bdc24c95bb79
parent19d0a0d8550fd6deaa8f00e0f5c1c06342a94822 (diff)
parentfc949f6605f114d27cafc835b1bc7fa3027050b3 (diff)
Merge branch 'master' of keybase://team/entropyy.quantensysteme/dequantify
-rw-r--r--.gitignore3
-rw-r--r--gnuplot.plt21
-rw-r--r--gnuplot/animation.plt11
-rw-r--r--gnuplot/plotxy.plt11
-rw-r--r--plotting.py57
-rw-r--r--single_dequantify.py33
-rw-r--r--twoqbit_dequantify.py50
7 files changed, 99 insertions, 87 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.plt b/gnuplot.plt
deleted file mode 100644
index f94ccdb..0000000
--- a/gnuplot.plt
+++ /dev/null
@@ -1,21 +0,0 @@
-set view equal xyz
-set parametric
-set isosamples 34,34
-unset colorbox
-unset key
-
-iterations = 100
-states = 6
-
-do for [ii=1:iterations] {
- splot cos(u)*cos(v),cos(u)*sin(v),sin(u) w l lc rgb "#42a4f5", \
- 'data' every ::1::ii * states w points palette pointsize 2 pointtype 7#, \
- #do for [ij=1:states] {
- # ic = ij * iterations + ii
- # replot 'data' every ::ij * iterations::ic w points palette pointsize 2 pointtype 7#, \
- # #'data' every ::ij * iterations::ic w p palette
- #}
- pause 0.1
-}
-
-pause mouse close
diff --git a/gnuplot/animation.plt b/gnuplot/animation.plt
new file mode 100644
index 0000000..6228a53
--- /dev/null
+++ b/gnuplot/animation.plt
@@ -0,0 +1,11 @@
+set view equal xyz
+set parametric
+set isosamples 34,34
+
+do for [ii=start:end] {
+ splot cos(u)*cos(v),cos(u)*sin(v),sin(u) w l lc rgb "#42a4f5", \
+ 'data' every ::1::ii * states w points palette pointsize 2 pointtype 7#, \
+ pause 0.1
+}
+
+pause mouse close
diff --git a/gnuplot/plotxy.plt b/gnuplot/plotxy.plt
new file mode 100644
index 0000000..b3bf993
--- /dev/null
+++ b/gnuplot/plotxy.plt
@@ -0,0 +1,11 @@
+set size square
+#plot cos(x),sin(y) w l lc rgb "#42a4f5"
+set xrange [-1.1:1.1]
+set yrange [-1.1:1.1]
+set xlabel "Re(V)"
+set ylabel "Im(V)"
+set xzeroaxis
+set yzeroaxis
+plot 'data' 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 a775ff1..f43f9f1 100644
--- a/single_dequantify.py
+++ b/single_dequantify.py
@@ -5,11 +5,9 @@ import cmath as cmt
import numpy as npy
import scipy.linalg as sla
-alpha = 1
-beta = 1
dt = 0.08
iterations = 100
-state_num = 6
+state_num = 1
H = npy.array([[1,0],[0,2]])
@@ -17,6 +15,14 @@ if len(sys.argv) == 3:
alpha = complex(sys.argv[1])
beta = complex(sys.argv[2])
+def init_state(i):
+ alpha = 1
+ beta = 1
+ if state_num > 1:
+ alpha = i / state_num
+ beta = (state_num - i) / state_num
+ return (alpha, beta)
+
def time_evolution(state, dt = dt):
return npy.dot(state, sla.expm(-1j * dt * H))
@@ -38,8 +44,7 @@ f = open("data", "w")
states = []
for i in range(state_num):
- alpha = i / state_num
- beta = (state_num - i) / state_num
+ (alpha, beta) = init_state(i)
norm = npy.linalg.norm([alpha, beta])
state = npy.array([alpha / norm, beta / norm])
states.append(state)
@@ -47,11 +52,23 @@ for i in range(state_num):
for i in range(iterations):
for j in range(state_num):
- states[j] = time_evolution(states[j])
(phi, theta) = bloch_map(states[j])
coords = sphere2cart(phi, theta)
- f.write(f"{coords[0]}; {coords[1]}; {coords[2]}; {(j + 1) / state_num}\n")
+ colour = i / iterations
+ if state_num > 1:
+ colour = j / state_num
+ f.write(f"{coords[0]}; {coords[1]}; {coords[2]}; {colour}\n")
+ states[j] = time_evolution(states[j])
f.close()
-subprocess.run(["gnuplot", "gnuplot.plt"])
+import os
+
+path = 'gnuplot/'
+if os.name == 'nt':
+ path.replace('/','\\')
+subprocess.run(["gnuplot",
+ "-e", f"states={state_num};",
+ "-e", f"start={iterations};" ,
+ "-e", f"end={iterations};",
+ "-c", path + "animation.plt"])
diff --git a/twoqbit_dequantify.py b/twoqbit_dequantify.py
new file mode 100644
index 0000000..b6e0abb
--- /dev/null
+++ b/twoqbit_dequantify.py
@@ -0,0 +1,50 @@
+import subprocess
+import math as mth
+import cmath as cmt
+import numpy as npy
+import scipy.linalg as sla
+
+alpha = 2
+beta = 0
+gamma = 1
+delta = 1+1j
+
+norm = npy.linalg.norm([alpha, beta, gamma, delta])
+state = npy.array([alpha / norm, beta / norm, gamma / norm, delta / norm])
+
+dt = 0.05
+iterations = 20
+
+H = npy.array([[1,0,0,1j],[0,2,0,0],[0,0,3,0],[-1j,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("data", "w")
+
+for i in range(iterations + 1):
+ hopf_state = fibration(state)
+ f.write(f"{hopf_state[3]}; {hopf_state[4]}; {(i + 1) / (iterations + 1)}\n")
+ print(hopf_state)
+ state = time_evolution(state)
+
+f.close()
+
+subprocess.run(["gnuplot", "gnuplot_2d.plt"])