-
Notifications
You must be signed in to change notification settings - Fork 0
/
mult_track_ring.py
83 lines (69 loc) · 1.95 KB
/
mult_track_ring.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
import os
import sys
import time
# Must set these before NumPy import to disable its multithreading
os.environ["OPENBLAS_NUM_THREADS"] = "1" # export OPENBLAS_NUM_THREADS=1
os.environ["MKL_NUM_THREADS"] = "1" # export MKL_NUM_THREADS=1
import cupy as cp
import h5py
from matplotlib.backends.backend_pdf import PdfPages
import matplotlib.pyplot as plt
import numpy as np
import nvtx
import pylatt as latt
if __name__ == "__main__":
show_plots = False
run_2nd_DA = False
if sys.argv[1] == "gpu":
use_gpu = True
elif sys.argv[1] == "cpu":
use_gpu = False
else:
raise ValueError
if use_gpu:
latt.use_gpu()
else:
latt.use_cpu()
import nsls2sr_supercell as acell
with nvtx.annotate("First DA", color="red"):
t0 = time.perf_counter()
acell.ring.finddyapsym4(
xmin=-0.05,
xmax=0.04,
ymin=1e-6,
ymax=0.02,
nx=31,
ny=11,
dp=0,
nturn=256,
dfu=False,
naf=False,
)
print(f"DA took {time.perf_counter()-t0:.6f}")
if show_plots:
acell.ring.pltdyap()
if run_2nd_DA:
sh1 = acell.ring.getElements("sext", "sh1", unique=True)[0]
sh1.K2 = 12
with nvtx.annotate("Second DA", color="red"):
t0 = time.perf_counter()
acell.ring.finddyapsym4(
xmin=-0.05,
xmax=0.04,
ymin=1e-6,
ymax=0.02,
nx=31,
ny=11,
dp=0,
nturn=256,
dfu=False,
naf=False,
)
print(f"DA took {time.perf_counter()-t0:.6f}")
if show_plots:
acell.ring.pltdyap()
if show_plots:
pp = PdfPages(".".join(__file__.split(".")[:-1] + ["pdf"]))
for fignum in plt.get_fignums():
pp.savefig(figure=fignum)
pp.close()