From 19d0a0d8550fd6deaa8f00e0f5c1c06342a94822 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Sat, 30 Nov 2019 17:43:14 +0100 Subject: Add simultaneou animations --- gnuplot.plt | 20 +++++++++++++++++--- single_dequantify.py | 29 +++++++++++++++++------------ 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/gnuplot.plt b/gnuplot.plt index ea5e043..f94ccdb 100644 --- a/gnuplot.plt +++ b/gnuplot.plt @@ -1,7 +1,21 @@ set view equal xyz set parametric set isosamples 34,34 -splot cos(u)*cos(v),cos(u)*sin(v),sin(u) w l lc rgb "#42a4f5" -replot 'data' w points palette pointsize 2 pointtype 7 -; +unset colorbox +unset key + +iterations = 100 +states = 6 + +do for [ii=1:iterations] { + splot cos(u)*cos(v),cos(u)*sin(v),sin(u) w l lc rgb "#42a4f5", \ + 'data' every ::1::ii * states w points palette pointsize 2 pointtype 7#, \ + #do for [ij=1:states] { + # ic = ij * iterations + ii + # replot 'data' every ::ij * iterations::ic w points palette pointsize 2 pointtype 7#, \ + # #'data' every ::ij * iterations::ic w p palette + #} + pause 0.1 +} + pause mouse close 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() -- cgit v1.2.3-70-g09d2