summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnuplot.plt7
-rw-r--r--gnuplot/animation.plt11
-rw-r--r--gnuplot/plotxy.plt (renamed from gnuplot_2d.plt)0
-rw-r--r--single_dequantify.py51
4 files changed, 48 insertions, 21 deletions
diff --git a/gnuplot.plt b/gnuplot.plt
deleted file mode 100644
index ea5e043..0000000
--- a/gnuplot.plt
+++ /dev/null
@@ -1,7 +0,0 @@
-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 'data' w points palette pointsize 2 pointtype 7
-;
-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_2d.plt b/gnuplot/plotxy.plt
index b3bf993..b3bf993 100644
--- a/gnuplot_2d.plt
+++ b/gnuplot/plotxy.plt
diff --git a/single_dequantify.py b/single_dequantify.py
index 3cf7d3a..f43f9f1 100644
--- a/single_dequantify.py
+++ b/single_dequantify.py
@@ -5,10 +5,9 @@ import cmath as cmt
import numpy as npy
import scipy.linalg as sla
-alpha = 1
-beta = 1
-dt = 0.1
-iterations = 61
+dt = 0.08
+iterations = 100
+state_num = 1
H = npy.array([[1,0],[0,2]])
@@ -16,8 +15,13 @@ if len(sys.argv) == 3:
alpha = complex(sys.argv[1])
beta = complex(sys.argv[2])
-norm = npy.linalg.norm([alpha, beta])
-state = npy.array([alpha / norm, beta / norm])
+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))
@@ -36,16 +40,35 @@ def sphere2cart(phi, theta):
-1 * mth.cos(theta)
]
-historie = npy.array([bloch_map(state)])
f = open("data", "w")
-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 + 1)}\n")
- state = time_evolution(state)
+states = []
+for i in range(state_num):
+ (alpha, beta) = init_state(i)
+ norm = npy.linalg.norm([alpha, beta])
+ state = npy.array([alpha / norm, beta / norm])
+ states.append(state)
+
+
+for i in range(iterations):
+ for j in range(state_num):
+ (phi, theta) = bloch_map(states[j])
+ coords = sphere2cart(phi, theta)
+ 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"])