update
This commit is contained in:
@@ -18,8 +18,7 @@ def timestr():
|
||||
class nmesh_tester:
|
||||
def __init__(self, a=1e-8, m=0, N=1, l=1, type="out", ntheta=16, nphi=32,
|
||||
interp="yes", n=20, luni=0, rlist="", rmodes=[], imodes=[],
|
||||
rpsi4s=[], ipsi4s=[], mode_file="mode.csv", psi4_file="psi4.csv",
|
||||
l2_file="l2.csv",
|
||||
rpsi4s=[], ipsi4s=[],
|
||||
outlist="0.05 0.08 0.1 -0.4 0.42 0.33 1.4 0.2 0.35"):
|
||||
self.a = a
|
||||
self.m = m
|
||||
@@ -34,15 +33,16 @@ class nmesh_tester:
|
||||
self.rlist = rlist
|
||||
self.rarray = list(map(float, rlist.split()))
|
||||
self.outlist = outlist
|
||||
self.outarray = list(map(float, outlist.split()))
|
||||
self.outarray = np.array(list(map(float, outlist.split()))).reshape(-1,3)
|
||||
self.rmodes = rmodes
|
||||
self.imodes = imodes
|
||||
self.rpsi4s = rpsi4s
|
||||
self.ipsi4s = ipsi4s
|
||||
self.mode_file = mode_file
|
||||
self.psi4_file = psi4_file
|
||||
self.l2_file = l2_file
|
||||
if max(max(self.rarray),max(self.outarray)) < 2.0:
|
||||
self.mode_file = f"result_modes_a{a}-m{m}-N{N}-l{l}-{type}.csv"
|
||||
self.psi4_file = f"result_psi4_a{a}-m{m}-N{N}-l{l}-{type}.csv"
|
||||
self.l2_file = f"result_l2_a{a}-m{m}-N{N}-l{l}-{type}.csv"
|
||||
self.normarray = np.concatenate((self.rarray, np.linalg.norm(self.outarray, axis=1)))
|
||||
if np.max(self.normarray) < 2.0:
|
||||
self.mesh_type = "CubedSpheres"
|
||||
else:
|
||||
self.mesh_type = "Shell"
|
||||
@@ -82,8 +82,8 @@ ADM_Set1stDerivsInADMconstraints = yes
|
||||
# initial mesh
|
||||
|
||||
amr_mesh_type = Shell
|
||||
amr_Shell_rin = {np.floor(min(self.rarray+self.outarray))}
|
||||
amr_Shell_rout = {np.ceil(max(self.rarray+self.outarray))}
|
||||
amr_Shell_rin = {np.floor(np.min(self.normarray))}
|
||||
amr_Shell_rout = {np.ceil(np.max(self.normarray))}
|
||||
amr_Shell_r1 = 0
|
||||
amr_n0 = {self.n}
|
||||
amr_n1 = {self.n}
|
||||
@@ -136,10 +136,13 @@ Invariants_psi4_test_0dout_coordinates = {self.outlist}
|
||||
|
||||
logfile_creation = yes
|
||||
0douttime = 0.1
|
||||
0doutput = Invariants_rpsi4 Invariants_ipsi4
|
||||
0doutput = Invariants_rpsi4 Invariants_ipsi4 Invariants_Teukolsky_rpsi4_err Invariants_Teukolsky_ipsi4_err
|
||||
|
||||
1douttime = 0.1
|
||||
1doutput = Invariants_rpsi4 Invariants_ipsi4
|
||||
|
||||
2douttime = 0.1
|
||||
2doutput = Invariants_Teukolsky_rpsi4_err Invariants_Teukolsky_ipsi4_err
|
||||
'''
|
||||
with open(filename, "w") as f:
|
||||
f.write(preparfile)
|
||||
@@ -155,21 +158,23 @@ logfile_creation = yes
|
||||
if not os.path.exists(self.mode_file):
|
||||
with open(self.mode_file, "w") as f:
|
||||
csv_writer = csv.writer(f)
|
||||
csv_writer.writerow(["a", "m", "N", "L", "type", "nt", "np", "interp",
|
||||
csv_writer.writerow(["nt", "np", "interp",
|
||||
"mesh", "n", "luni", "r", "l", "m", "re_mode",
|
||||
"im_mode", "re_mode_err", "im_mode_err",
|
||||
"re_mode_rel_error", "im_mode_rel_err"])
|
||||
"im_mode", "re_mode_wl", "im_mode_wl",
|
||||
"re_mode_err", "im_mode_err",
|
||||
"re_mode_rel_error", "im_mode_rel_err"])
|
||||
if not os.path.exists(self.psi4_file):
|
||||
with open(self.psi4_file, "w") as f:
|
||||
csv_writer = csv.writer(f)
|
||||
csv_writer.writerow(["a", "m", "N", "L", "type", "mesh", "n", "luni",
|
||||
"x", "y", "z", "rpsi4", "ipsi4", "rpsi4_err",
|
||||
"ipsi4_err", "rpsi4_rel_err", "ipsi4_rel_err"])
|
||||
csv_writer.writerow(["mesh", "n", "luni",
|
||||
"x", "y", "z", "rpsi4", "ipsi4", "rpsi4_wl",
|
||||
"ipsi4_wl", "rpsi4_err", "ipsi4_err",
|
||||
"rpsi4_rel_err", "ipsi4_rel_err"])
|
||||
if not os.path.exists(self.l2_file):
|
||||
with open(self.l2_file, "w") as f:
|
||||
csv_writer = csv.writer(f)
|
||||
csv_writer.writerow(["a", "m", "N", "L", "type", "nt", "np", "interp",
|
||||
"mesh", "n", "luni", "r", "l2-norm",
|
||||
csv_writer.writerow(["nt", "np", "interp",
|
||||
"mesh", "n", "luni", "r", "l2-norm_wl",
|
||||
"l2-distance", "l2-rel_err"])
|
||||
|
||||
print(f"[{timestr()}]\tAnalysing modes...")
|
||||
@@ -182,8 +187,7 @@ logfile_creation = yes
|
||||
l2distance = 0
|
||||
for l in range(1,9):
|
||||
for m in range(-l, l+1):
|
||||
output_line = [self.a, self.m, self.N, self.l, self.type,\
|
||||
self.ntheta, self.nphi, self.interp, self.mesh_type,\
|
||||
output_line = [self.ntheta, self.nphi, self.interp, self.mesh_type,\
|
||||
self.n, self.luni, r, l, m]
|
||||
mode_file = f'{basename}/modes/psi4_r{r}_l{l}_m{m}.t'
|
||||
with open(mode_file, 'r') as f:
|
||||
@@ -196,14 +200,13 @@ logfile_creation = yes
|
||||
rmode_rel_error = 'nan' if rmode==0 else rmode_error/rmode
|
||||
imode_rel_error = 'nan' if imode==0 else imode_error/imode
|
||||
l2distance += rmode_error**2 + imode_error**2
|
||||
output_line.extend([rmode_error, imode_error,
|
||||
output_line.extend([rmode, imode, rmode_error, imode_error,
|
||||
rmode_rel_error, imode_rel_error])
|
||||
ind += 1
|
||||
csv_writer.writerow(output_line)
|
||||
with open(self.l2_file, "a") as l2_fp:
|
||||
l2_writer = csv.writer(l2_fp)
|
||||
l2_writer.writerow([self.a, self.m, self.N, self.l, self.type,
|
||||
self.ntheta, self.nphi, self.interp,
|
||||
l2_writer.writerow([self.ntheta, self.nphi, self.interp,
|
||||
self.mesh_type, self.n, self.luni, r, l2norm,
|
||||
l2distance, l2distance/l2norm])
|
||||
|
||||
@@ -212,8 +215,7 @@ logfile_creation = yes
|
||||
csv_writer = csv.writer(psi4_fp)
|
||||
n_points = len(self.outarray)//3
|
||||
for i in range(n_points):
|
||||
output_line = [self.a, self.m, self.N, self.l, self.type,\
|
||||
self.mesh_type, self.n, self.luni]
|
||||
output_line = [self.mesh_type, self.n, self.luni]
|
||||
psi4_files = [f"{basename}/Invariants_rpsi4_pt{i}.t",
|
||||
f"{basename}/Invariants_ipsi4_pt{i}.t"]
|
||||
with open(psi4_files[0]) as f:
|
||||
@@ -232,21 +234,17 @@ logfile_creation = yes
|
||||
ipsi4_error = Nipsi4 - ipsi4
|
||||
rpsi4_rel_error = 'nan' if rpsi4==0 else rpsi4_error/rpsi4
|
||||
ipsi4_rel_error = 'nan' if ipsi4==0 else ipsi4_error/ipsi4
|
||||
output_line.extend([rpsi4_error, ipsi4_error,
|
||||
output_line.extend([rpsi4, ipsi4, rpsi4_error, ipsi4_error,
|
||||
rpsi4_rel_error, ipsi4_rel_error])
|
||||
csv_writer.writerow(output_line)
|
||||
|
||||
rlist = [0.4, 1.3, 1.8]
|
||||
pointlist = [[0.05, 0.08, 0.1], [-0.4, 0.42, 0.33], [1.4, 0.2, 0.35]]#, [0.01, 0.02, 0.48]]
|
||||
rlist = [1.4, 1.8, 2.5]
|
||||
pointlist = [[-0.4, 1.42, 0.33], [1.4, 0.2, 0.35], [1.01, 0.02, 1.48]]
|
||||
|
||||
rlist_str = ' '.join(str(r) for r in rlist)
|
||||
outlist = ' '.join(str(coord) for point in pointlist for coord in point)
|
||||
|
||||
mode_file = "result_modes.csv"
|
||||
psi4_file = "result_psi4.csv"
|
||||
l2_file = "result_l2.csv"
|
||||
|
||||
for a in [1e-6, 1e-8, 1e-10, 1e-12]:
|
||||
for a in [1e-8, 1e-10, 1e-12]:
|
||||
for m in [0, 1, -1, 2, -2]:
|
||||
for N in [1, 2, 3, 4]:
|
||||
for l in [0.5, 1, 2]:
|
||||
@@ -294,11 +292,10 @@ for a in [1e-6, 1e-8, 1e-10, 1e-12]:
|
||||
raise SystemExit("wrong in wolframscript.")
|
||||
for ntheta in [16, 32, 64]:
|
||||
nphi = 2*ntheta
|
||||
for interp in ["yes"]:
|
||||
for interp in ["yes", "no"]:
|
||||
for n in [10, 20, 40]:
|
||||
for luni in [0, 1, 2]:
|
||||
tester = nmesh_tester(a, m, N, l, type, ntheta, nphi,
|
||||
interp, n, luni, rlist_str, rmodes,
|
||||
imodes, rpsi4s, ipsi4s, mode_file,
|
||||
psi4_file, l2_file, outlist)
|
||||
imodes, rpsi4s, ipsi4s, outlist)
|
||||
tester.run_test()
|
||||
|
||||
Reference in New Issue
Block a user