diff options
Diffstat (limited to 'twoqbit_dequantify.py')
-rw-r--r-- | twoqbit_dequantify.py | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/twoqbit_dequantify.py b/twoqbit_dequantify.py index b6e0abb..efc3304 100644 --- a/twoqbit_dequantify.py +++ b/twoqbit_dequantify.py @@ -1,3 +1,5 @@ +import sys +import plot import subprocess import math as mth import cmath as cmt @@ -8,23 +10,36 @@ alpha = 2 beta = 0 gamma = 1 delta = 1+1j +state_num = 1 norm = npy.linalg.norm([alpha, beta, gamma, delta]) state = npy.array([alpha / norm, beta / norm, gamma / norm, delta / norm]) dt = 0.05 -iterations = 20 +iterations = 200 -H = npy.array([[1,0,0,1j],[0,2,0,0],[0,0,3,0],[-1j,0,0,4]]) M0 = [[1,0,0,0],[0,1,0,0],[0,0,-1,0],[0,0,0,-1]] M1 = [[0,0,1,0],[0,0,0,1],[1,0,0,0],[0,1,0,0]] M2 = [[0,0,-1j,0],[0,0,0,-1j],[1j,0,0,0],[0,1j,0,0]] M3 = [[0,0,0,1],[0,0,-1,0],[0,-1,0,0],[1,0,0,0]] +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 + H = npy.array([[1,0,0,1j],[0,2,0,0],[0,0,3,0],[-1j,0,0,4]]) + return ([alpha, beta, gamma, delta], H) + def time_evolution(state, dt = dt): - return npy.dot(state, sla.expm(-1j * dt * H)) + return (npy.dot(state[0], sla.expm(-1j * dt * state[1])), state[1]) def fibration(state): x0=npy.dot(npy.conj(state),npy.dot(M0,state)) @@ -37,14 +52,24 @@ def fibration(state): return ([x0.real,x1.real,x2.real,x3,x4]) -f = open("data", "w") - -for i in range(iterations + 1): - hopf_state = fibration(state) - f.write(f"{hopf_state[3]}; {hopf_state[4]}; {(i + 1) / (iterations + 1)}\n") - print(hopf_state) - state = time_evolution(state) +states = [] +for i in range(state_num): + (co, H) = init_state(i) + norm = npy.linalg.norm(co) + state = npy.array([co[0] / norm, co[1] / norm, co[2] / norm, co[3] / norm]) + states.append((state, H)) +f = open("data", "w") +for i in range(iterations): + for j in range(state_num): + hopf_state = fibration(states[j][0]) + colour = i / iterations + if state_num > 1: + colour = j / state_num + f.write(f"{hopf_state[0]}; {hopf_state[1]}; {hopf_state[2]}; {hopf_state[3]}; {hopf_state[4]}; {colour}\n") + states[j] = time_evolution(states[j]) f.close() -subprocess.run(["gnuplot", "gnuplot_2d.plt"]) +#plot.plot(iterations, iterations, state_num, "anim3d.plt") +plot.plot(iterations, iterations, state_num, "anim2d.plt") + |