summaryrefslogtreecommitdiff
path: root/single_dequantify.py
diff options
context:
space:
mode:
authorDennis Kobert <dennis@kobert.dev>2019-11-30 17:43:14 +0100
committerDennis Kobert <dennis@kobert.dev>2019-11-30 17:43:14 +0100
commit19d0a0d8550fd6deaa8f00e0f5c1c06342a94822 (patch)
treece9dbe6f8febadf36bfd16834da663cc9545e9e4 /single_dequantify.py
parent84b9f0eb682b60ecc8592bef22c549051d200ead (diff)
Add simultaneou animations
Diffstat (limited to 'single_dequantify.py')
-rw-r--r--single_dequantify.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/single_dequantify.py b/single_dequantify.py
index 96f76ed..a775ff1 100644
--- a/single_dequantify.py
+++ b/single_dequantify.py
@@ -7,8 +7,9 @@ import scipy.linalg as sla
alpha = 1
beta = 1
-dt = 0.1
-iterations = 61
+dt = 0.08
+iterations = 100
+state_num = 6
H = npy.array([[1,0],[0,2]])
@@ -16,9 +17,6 @@ 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 time_evolution(state, dt = dt):
return npy.dot(state, sla.expm(-1j * dt * H))
@@ -36,16 +34,23 @@ def sphere2cart(phi, theta):
-1 * mth.cos(theta)
]
-historie = npy.array([bloch_map(state)])
f = open("data", "w")
+states = []
+for i in range(state_num):
+ alpha = i / state_num
+ beta = (state_num - i) / state_num
+ norm = npy.linalg.norm([alpha, beta])
+ state = npy.array([alpha / norm, beta / norm])
+ states.append(state)
+
+
for i in range(iterations):
- state = time_evolution(state)
- h = npy.dot(state, state)
- 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")
+ 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")
f.close()