diff options
author | Dennis Kobert <dennis@kobert.dev> | 2019-11-30 18:30:56 +0100 |
---|---|---|
committer | Dennis Kobert <dennis@kobert.dev> | 2019-11-30 18:30:56 +0100 |
commit | e1172e94602f4cf003392409d9543d17c31881dc (patch) | |
tree | 5975b9d1c7e21ad0d496412da625bdc24c95bb79 /single_dequantify.py | |
parent | 19d0a0d8550fd6deaa8f00e0f5c1c06342a94822 (diff) | |
parent | fc949f6605f114d27cafc835b1bc7fa3027050b3 (diff) |
Merge branch 'master' of keybase://team/entropyy.quantensysteme/dequantify
Diffstat (limited to 'single_dequantify.py')
-rw-r--r-- | single_dequantify.py | 33 |
1 files changed, 25 insertions, 8 deletions
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"]) |