summaryrefslogtreecommitdiff
path: root/twoqbit_dequantify.py
blob: b6e0abb979d3177234ffb1e81c02143e2667e168 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import subprocess
import math as mth
import cmath as cmt
import numpy as npy
import scipy.linalg as sla

alpha = 2
beta  = 0
gamma = 1
delta = 1+1j

norm  = npy.linalg.norm([alpha, beta, gamma, delta])
state = npy.array([alpha / norm, beta / norm, gamma / norm, delta / norm])

dt = 0.05
iterations = 20

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]]


def time_evolution(state, dt = dt):
    return npy.dot(state, sla.expm(-1j * dt * H))

def fibration(state):
    x0=npy.dot(npy.conj(state),npy.dot(M0,state))
    x1=npy.dot(npy.conj(state),npy.dot(M1,state))
    x2=npy.dot(npy.conj(state),npy.dot(M2,state))
    V=npy.dot(state,npy.dot(M3,state))
    x3=V.real
    x4=V.imag

    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)

f.close()

subprocess.run(["gnuplot", "gnuplot_2d.plt"])