From f6e357c684e7eeb363dd7bf4159c65423666f7ac Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Sat, 30 Nov 2019 12:22:57 +0100 Subject: Change gnuplot appearance --- gnuplot.plt | 6 +++--- 1 file changed, 3 insertions(+), 3 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 -- cgit v1.2.3-54-g00ecf From f3988902b014da58eb8c6a1914312721b0b59f86 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Sat, 30 Nov 2019 12:52:41 +0100 Subject: Fix bloch_map --- single_dequantify.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/single_dequantify.py b/single_dequantify.py index 43c256d..44f2190 100644 --- a/single_dequantify.py +++ b/single_dequantify.py @@ -9,10 +9,10 @@ alpha = 1 / npy.sqrt(2) beta = 1 / npy.sqrt(2) state = npy.array([alpha, beta]) -dt = 0.2 -iterations = 20 +dt = 0.067 +iterations = 41 -H = npy.array([[2,-2j],[2j,3]]) +H = npy.array([[2,-1j],[1j,3]]) def time_evolution(state, dt = dt): @@ -20,19 +20,20 @@ def time_evolution(state, dt = dt): 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) + theta = 2 * npy.arctan(abs(temp) / 2) + phi = cmt.phase(temp) + return npy.array([phi, theta]) def sphere2cart(phi, theta): return [ - mth.sin(theta) * mth.cos(phi), - mth.sin(theta) * mth.sin(phi), - mth.cos(theta) + mth.cos(theta) * mth.cos(phi), + mth.cos(theta) * mth.sin(phi), + mth.sin(theta) ] historie = npy.array([bloch_map(state)]) -f = open("data", "a") +f = open("data", "w") for i in range(iterations): state = time_evolution(state) @@ -40,7 +41,7 @@ for i in range(iterations): 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") + f.write(f"{coords[0]}; {coords[1]}; {coords[2]}; {(i + 1) / iterations}\n") f.close() subprocess.run(["gnuplot", "gnuplot.plt"]) -- cgit v1.2.3-54-g00ecf From 98c588bbb04f11b05324b6e415ec358305f06f7a Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Sat, 30 Nov 2019 13:15:01 +0100 Subject: Normalize alpha and beta --- single_dequantify.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/single_dequantify.py b/single_dequantify.py index 44f2190..fa5f017 100644 --- a/single_dequantify.py +++ b/single_dequantify.py @@ -5,14 +5,18 @@ 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 / npy.sqrt(2) +alpha = 1 +#beta = 1 / npy.sqrt(2) +beta = 1 -dt = 0.067 -iterations = 41 +norm = npy.linalg.norm([alpha, beta]) +state = npy.array([alpha / norm, beta / norm]) -H = npy.array([[2,-1j],[1j,3]]) +dt = 0.1 +iterations = 61 + +H = npy.array([[2,0],[0,3]]) def time_evolution(state, dt = dt): @@ -20,16 +24,16 @@ def time_evolution(state, dt = dt): def bloch_map(state): temp = npy.conj(state[0] / state[1]) - theta = 2 * npy.arctan(abs(temp) / 2) + theta = 2 * npy.arctan(abs(temp)) phi = cmt.phase(temp) - return npy.array([phi, theta]) + return (phi, theta) def sphere2cart(phi, theta): return [ - mth.cos(theta) * mth.cos(phi), - mth.cos(theta) * mth.sin(phi), - mth.sin(theta) + mth.sin(theta) * mth.cos(phi), + mth.sin(theta) * mth.sin(phi), + mth.cos(theta) ] historie = npy.array([bloch_map(state)]) @@ -39,8 +43,8 @@ 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]) + (phi, theta) = bloch_map(state) + coords = sphere2cart(phi, theta) f.write(f"{coords[0]}; {coords[1]}; {coords[2]}; {(i + 1) / iterations}\n") f.close() -- cgit v1.2.3-54-g00ecf