summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--single_dequantify.py30
1 files changed, 17 insertions, 13 deletions
diff --git a/single_dequantify.py b/single_dequantify.py
index 44f2190..fa5f017 100644
--- a/single_dequantify.py
+++ b/single_dequantify.py
@@ -5,14 +5,18 @@ import cmath as cmt
import numpy as npy
import scipy.linalg as sla
-alpha = 1 / npy.sqrt(2)
-beta = 1 / npy.sqrt(2)
-state = npy.array([alpha, beta])
+#alpha = 1 / npy.sqrt(2)
+alpha = 1
+#beta = 1 / npy.sqrt(2)
+beta = 1
-dt = 0.067
-iterations = 41
+norm = npy.linalg.norm([alpha, beta])
+state = npy.array([alpha / norm, beta / norm])
-H = npy.array([[2,-1j],[1j,3]])
+dt = 0.1
+iterations = 61
+
+H = npy.array([[2,0],[0,3]])
def time_evolution(state, dt = dt):
@@ -20,16 +24,16 @@ def time_evolution(state, dt = dt):
def bloch_map(state):
temp = npy.conj(state[0] / state[1])
- theta = 2 * npy.arctan(abs(temp) / 2)
+ theta = 2 * npy.arctan(abs(temp))
phi = cmt.phase(temp)
- return npy.array([phi, theta])
+ return (phi, theta)
def sphere2cart(phi, theta):
return [
- mth.cos(theta) * mth.cos(phi),
- mth.cos(theta) * mth.sin(phi),
- mth.sin(theta)
+ mth.sin(theta) * mth.cos(phi),
+ mth.sin(theta) * mth.sin(phi),
+ mth.cos(theta)
]
historie = npy.array([bloch_map(state)])
@@ -39,8 +43,8 @@ for i in range(iterations):
state = time_evolution(state)
h = npy.dot(state, state)
historie = npy.vstack([historie,bloch_map(state)])
- coords = bloch_map(state)
- coords = sphere2cart(coords[0], coords[1])
+ (phi, theta) = bloch_map(state)
+ coords = sphere2cart(phi, theta)
f.write(f"{coords[0]}; {coords[1]}; {coords[2]}; {(i + 1) / iterations}\n")
f.close()