diff options
-rw-r--r-- | gnuplot.plt | 6 | ||||
-rw-r--r-- | single_dequantify.py | 32 |
2 files changed, 19 insertions, 19 deletions
diff --git a/gnuplot.plt b/gnuplot.plt index 635bd3e..ea5e043 100644 --- a/gnuplot.plt +++ b/gnuplot.plt @@ -1,7 +1,7 @@ set view equal xyz set parametric -set isosamples 10,10 -splot cos(u)*cos(v),cos(u)*sin(v),sin(u) -replot 'data' +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 ; pause mouse close diff --git a/single_dequantify.py b/single_dequantify.py index 0d38fc7..a4a3021 100644 --- a/single_dequantify.py +++ b/single_dequantify.py @@ -5,24 +5,26 @@ import cmath as cmt import numpy as npy import scipy.linalg as sla -alpha = 1 / npy.sqrt(2) -beta = 1 / npy.sqrt(2) -state = npy.array([alpha, beta]) +alpha = 1 +beta = 1 -dt = 0.2 -iterations = 200 +norm = npy.linalg.norm([alpha, beta]) +state = npy.array([alpha / norm, beta / norm]) -H = npy.array([[2,0],[0,3]]) +dt = 0.1 +iterations = 61 +H = npy.array([[2,0],[0,3]]) def time_evolution(state, dt = dt): return npy.dot(state, sla.expm(-1j * dt * H)) def bloch_map(state): temp = npy.conj(state[0] / state[1]) - phi = 2 * npy.arctan(1 / abs(temp)) - theta = npy.arctan(temp.imag / temp.real) - return npy.array([phi, theta]) + theta = 2 * npy.arctan(abs(temp)) + phi = cmt.phase(temp) + + return (phi, theta) def sphere2cart(phi, theta): return [ @@ -38,12 +40,10 @@ for i in range(iterations): state = time_evolution(state) h = npy.dot(state, state) historie = npy.vstack([historie,bloch_map(state)]) - coords = bloch_map(state) - coords = sphere2cart(coords[0], coords[1]) - f.write(f"{coords[0]}; {coords[1]}; {coords[2]}\n") + (phi, theta) = bloch_map(state) + coords = sphere2cart(phi, theta) + f.write(f"{coords[0]}; {coords[1]}; {coords[2]}; {(i + 1) / iterations}\n") f.close() -import plotting -#plotting.phi(historie[:,0]) -plotting.kugel(historie) -#subprocess.run(["gnuplot", "gnuplot.plt"]) + +subprocess.run(["gnuplot", "gnuplot.plt"]) |