-
Notifications
You must be signed in to change notification settings - Fork 1
/
phase_diagram_spherical.py
executable file
·93 lines (75 loc) · 2.32 KB
/
phase_diagram_spherical.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
""" In this script we will read out the psi for each point from the .h5 fiels in /data folder
"""
# numpy
import numpy as np
from numpy import pi
# model and dmrg
from kitaev_ladder import KitaevLadderModel, save_after_run, load_data, run_atomic
# spherical coordinates
from spherical_coordinates import spherical_to_decarte
# path toolkits
from pathlib import Path
# region selection
# first we decide how many points we want
N = 20
Ntheta = N + 1
Nphi = N + 1
# use linspace to conveniently create the desired number of points
# the default linspace provides intervals with both closed boundaries
theta_list = np.linspace(0, pi/2, Ntheta)
phi_list = np.linspace(0, pi/2, Nphi)
chi = 100
L = 3
N_sweeps_check=1
max_sweeps=20
verbose=0
# folder name
prefix = f'data_L_{L}/'
Path(prefix).mkdir(parents=True, exist_ok=True)
run_save = save_after_run(run_atomic, folder_prefix=prefix)
def get_J(theta, phi):
Jx, Jy, Jz = spherical_to_decarte(r=1.0, theta=theta, phi=phi)
if Jx == -0.0:
Jx = 0.0
if Jy == -0.0:
Jy = 0.0
if Jz == -0.0:
Jz = 0.0
# if Jx = Jy then slightly differ them to avoid the symmetric state
if Jx == Jy:
Jx += 0.001
Jy -= 0.001
return (Jx, Jy, Jz)
# store those points reaching the max sweeps
unclear_points = []
# run the DMRG
for theta in theta_list:
psi = None
for phi in phi_list:
if psi is not None:
initial_psi = psi.copy()
else:
initial_psi = None
Jx, Jy, Jz = get_J(theta, phi)
J = (Jx, Jy, Jz)
print("\n\n\n Calculating the (Jx, Jy, Jz) = (%.3f, %.3f, %.3f) ground state" % (Jx, Jy, Jz))
result = run_save(
chi=chi,
Jx=Jx,
Jy=Jy,
Jz=Jz,
L=L,
initial_psi=initial_psi,
N_sweeps_check=N_sweeps_check,
max_sweeps=max_sweeps,
verbose=0,
)
if result != 0:
sweeps_stat = result['sweeps_stat']
last_sweep = len(sweeps_stat['sweep']) * N_sweeps_check
max_sweeps = result['parameters']['max_sweeps']
if max_sweeps == last_sweep:
unclear_points.append(J)
else:
initial_psi = result['psi']
print("Finished.\n", "Unclear points: ", unclear_points)