summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--single_dequantify.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/single_dequantify.py b/single_dequantify.py
index 43c256d..44f2190 100644
--- a/single_dequantify.py
+++ b/single_dequantify.py
@@ -9,10 +9,10 @@ alpha = 1 / npy.sqrt(2)
beta = 1 / npy.sqrt(2)
state = npy.array([alpha, beta])
-dt = 0.2
-iterations = 20
+dt = 0.067
+iterations = 41
-H = npy.array([[2,-2j],[2j,3]])
+H = npy.array([[2,-1j],[1j,3]])
def time_evolution(state, dt = dt):
@@ -20,19 +20,20 @@ def time_evolution(state, dt = dt):
def bloch_map(state):
temp = npy.conj(state[0] / state[1])
- phi = 2 * npy.arctan(1 / abs(temp))
- theta = npy.arctan(temp.imag / temp.real)
+ theta = 2 * npy.arctan(abs(temp) / 2)
+ phi = cmt.phase(temp)
+
return npy.array([phi, theta])
def sphere2cart(phi, theta):
return [
- mth.sin(theta) * mth.cos(phi),
- mth.sin(theta) * mth.sin(phi),
- mth.cos(theta)
+ mth.cos(theta) * mth.cos(phi),
+ mth.cos(theta) * mth.sin(phi),
+ mth.sin(theta)
]
historie = npy.array([bloch_map(state)])
-f = open("data", "a")
+f = open("data", "w")
for i in range(iterations):
state = time_evolution(state)
@@ -40,7 +41,7 @@ for i in range(iterations):
historie = npy.vstack([historie,bloch_map(state)])
coords = bloch_map(state)
coords = sphere2cart(coords[0], coords[1])
- f.write(f"{coords[0]}; {coords[1]}; {coords[2]}\n")
+ f.write(f"{coords[0]}; {coords[1]}; {coords[2]}; {(i + 1) / iterations}\n")
f.close()
subprocess.run(["gnuplot", "gnuplot.plt"])