From aa98e4dba7d771bd1e9519442f830542cff2860c Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Sun, 1 Dec 2019 01:58:10 +0100 Subject: Improve preformarce by calculating the hamilton once --- gnuplot/anim2d.plt | 3 ++- gnuplot/anim3d.plt | 4 +++- single_dequantify.py | 4 ++-- twoqbit_dequantify.py | 37 +++++++++++++++++++------------------ 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/gnuplot/anim2d.plt b/gnuplot/anim2d.plt index 38b8d5a..f131c1f 100644 --- a/gnuplot/anim2d.plt +++ b/gnuplot/anim2d.plt @@ -8,7 +8,8 @@ set yzeroaxis set object circle at 0,0 size 1 do for [ii=start:end] { - plot 'data' every ::1::ii * states using 4:5:6 w points palette pointsize 2 pointtype 7 + plot 'data' every ::ii::ii * states using 4:5:6 w points palette pointsize 2 pointtype 7, \ + 'data' every ::1::ii * states using 4:5:6 w l palette lw 3 pause 0.1 } diff --git a/gnuplot/anim3d.plt b/gnuplot/anim3d.plt index 99cfe10..05d9f51 100644 --- a/gnuplot/anim3d.plt +++ b/gnuplot/anim3d.plt @@ -2,9 +2,11 @@ set view equal xyz set parametric set isosamples 34,34 +ii = start do for [ii=start:end] { splot cos(u)*cos(v),cos(u)*sin(v),sin(u) w l lc rgb "#42a4f5", \ - 'data' every ::1::ii * states using 1:2:3:6 w points palette pointsize 2 pointtype 7#, \ + 'data' every ::ii - states::ii * states using 1:2:3:6 w points palette pointsize 1.2 pointtype 7, \ + 'data' every ::1::ii * states using 1:2:3:6 w l palette pause 0.1 } diff --git a/single_dequantify.py b/single_dequantify.py index 99ebdc4..e90142a 100644 --- a/single_dequantify.py +++ b/single_dequantify.py @@ -7,7 +7,7 @@ import scipy.linalg as sla dt = 0.08 iterations = 100 -state_num = 3 +state_num = 5 H = npy.array([[1,0],[0,2]]) @@ -59,5 +59,5 @@ for i in range(iterations): states[j] = time_evolution(states[j]) f.close() -plot.plot(1, iterations, state_num, "anim2d.plt") +plot.plot(1, iterations, state_num, "anim3d.plt") diff --git a/twoqbit_dequantify.py b/twoqbit_dequantify.py index efc3304..af2e506 100644 --- a/twoqbit_dequantify.py +++ b/twoqbit_dequantify.py @@ -6,17 +6,10 @@ import cmath as cmt import numpy as npy import scipy.linalg as sla -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 = 200 +dt = 0.02 +accu = 100 +iterations = 5000 M0 = [[1,0,0,0],[0,1,0,0],[0,0,-1,0],[0,0,0,-1]] @@ -29,17 +22,24 @@ if len(sys.argv) == 3: beta = complex(sys.argv[2]) def init_state(i): - alpha = 1 - beta = 1 + alpha = 2 + beta = 0 + gamma = 1 + delta = 1+1j if state_num > 1: alpha = i / state_num - beta = (state_num - i) / state_num + beta = -(state_num - i) / state_num + gamma = alpha + beta + delta = delta * i 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) + H = sla.expm(-1j * (dt / accu) * H) + norm = npy.linalg.norm([alpha, beta, gamma, delta]) + state = npy.array([alpha / norm, beta / norm, gamma / norm, delta / norm]) + return (state, H) def time_evolution(state, dt = dt): - return (npy.dot(state[0], sla.expm(-1j * dt * state[1])), state[1]) + return (npy.dot(state[0], state[1]), state[1]) def fibration(state): x0=npy.dot(npy.conj(state),npy.dot(M0,state)) @@ -67,9 +67,10 @@ for i in range(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]) + for l in range(accu): + states[j] = time_evolution(states[j], dt / accu) f.close() -#plot.plot(iterations, iterations, state_num, "anim3d.plt") -plot.plot(iterations, iterations, state_num, "anim2d.plt") +plot.plot(iterations, iterations, state_num, "anim3d.plt") +#plot.plot(iterations, iterations, state_num, "anim2d.plt") -- cgit v1.2.3