Skip to content

Commit f960c19

Browse files
jonathanschillingjurasic-pf
authored andcommitted
Compare a coarse Nestor run against a fine only-coils run
1 parent e0279c3 commit f960c19

2 files changed

Lines changed: 29 additions & 20 deletions

File tree

examples/compare_nestor_only_coils.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,20 @@
1212
folder = Path("examples/data")
1313

1414
vmecpp_nestor = h5py.File(folder / "w7x_free_bdy_vac_nestor.out.h5", "r")
15-
nfp = vmecpp_nestor["/wout/nfp"][()]
16-
ns = vmecpp_nestor["/wout/ns"][()]
17-
mnmax = vmecpp_nestor["/wout/mnmax"][()]
18-
xm = vmecpp_nestor["/wout/xm"][()]
19-
xn = vmecpp_nestor["/wout/xn"][()]
15+
ref_nfp = vmecpp_nestor["/wout/nfp"][()]
16+
ref_ns = vmecpp_nestor["/wout/ns"][()]
17+
ref_mnmax = vmecpp_nestor["/wout/mnmax"][()]
18+
ref_xm = vmecpp_nestor["/wout/xm"][()]
19+
ref_xn = vmecpp_nestor["/wout/xn"][()]
2020
ref_rmnc = vmecpp_nestor["/wout/rmnc"][()]
2121
ref_zmns = vmecpp_nestor["/wout/zmns"][()]
2222

2323
vmecpp_only_coils = h5py.File(folder / "w7x_free_bdy_vac_only_coils.out.h5", "r")
24-
# assume the rest is consistent
24+
tst_nfp = vmecpp_only_coils["/wout/nfp"][()]
25+
tst_ns = vmecpp_only_coils["/wout/ns"][()]
26+
tst_mnmax = vmecpp_only_coils["/wout/mnmax"][()]
27+
tst_xm = vmecpp_only_coils["/wout/xm"][()]
28+
tst_xn = vmecpp_only_coils["/wout/xn"][()]
2529
tst_rmnc = vmecpp_only_coils["/wout/rmnc"][()]
2630
tst_zmns = vmecpp_only_coils["/wout/zmns"][()]
2731

@@ -30,21 +34,26 @@
3034
theta = np.linspace(0.0, 2.0 * np.pi, ntheta)
3135
for phi_degrees in [0, 18, 36]:
3236
phi = np.deg2rad(phi_degrees)
33-
kernel = np.outer(xm, theta) - np.outer(xn, phi)
34-
cos_kernel = np.cos(kernel)
35-
sin_kernel = np.sin(kernel)
37+
38+
ref_kernel = np.outer(ref_xm, theta) - np.outer(ref_xn, phi)
39+
ref_cos_kernel = np.cos(ref_kernel)
40+
ref_sin_kernel = np.sin(ref_kernel)
41+
42+
tst_kernel = np.outer(tst_xm, theta) - np.outer(tst_xn, phi)
43+
tst_cos_kernel = np.cos(tst_kernel)
44+
tst_sin_kernel = np.sin(tst_kernel)
3645

3746
plt.figure()
38-
for j in [0, 2**2, 4**2, 6**2, 50]:
39-
ref_r = np.dot(ref_rmnc[j, :], cos_kernel)
40-
ref_z = np.dot(ref_zmns[j, :], sin_kernel)
47+
for j in [0, 2**2, 4**2, 6**2, -1]:
48+
ref_r = np.dot(ref_rmnc[j, :], ref_cos_kernel)
49+
ref_z = np.dot(ref_zmns[j, :], ref_sin_kernel)
4150
if j == 0:
4251
plt.plot(ref_r, ref_z, "ro", label="Nestor")
4352
else:
4453
plt.plot(ref_r, ref_z, "r-", lw=2)
4554

46-
tst_r = np.dot(tst_rmnc[j, :], cos_kernel)
47-
tst_z = np.dot(tst_zmns[j, :], sin_kernel)
55+
tst_r = np.dot(tst_rmnc[j, :], tst_cos_kernel)
56+
tst_z = np.dot(tst_zmns[j, :], tst_sin_kernel)
4857
if j == 0:
4958
plt.plot(tst_r, tst_z, "bx", label="only coils")
5059
else:

examples/data/w7x_free_bdy_vac_only_coils.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"lasym" : false,
33
"nfp" : 5,
4-
"mpol" : 7,
5-
"ntor" : 6,
4+
"mpol" : 20,
5+
"ntor" : 12,
66
"ntheta" : 0,
77
"nzeta" : 36,
8-
"ns_array" : [ 51 ],
9-
"ftol_array" : [ 1.0E-12 ],
8+
"ns_array" : [ 99 ],
9+
"ftol_array" : [ 1.0E-15 ],
1010
"niter_array" : [ 50000 ],
1111
"delt" : 1.0,
1212
"tcon0" : 1.0,
@@ -23,8 +23,8 @@
2323
"ac" : [ 0.0, 1.0 ],
2424
"curtor" : 0.0,
2525
"bloat" : 1.0,
26-
"raxis_c" : [ 5.6343, 0.35209, 0.0, 0.0, 0.0, 0.0, 0.0 ],
27-
"zaxis_s" : [ 0.0, -0.29578, 0.0, 0.0, 0.0, 0.0, 0.0 ],
26+
"raxis_c" : [ 5.6343, 0.35209, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
27+
"zaxis_s" : [ 0.0, -0.29578, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
2828
"rbc" : [ {
2929
"n" : 0,
3030
"m" : 0,

0 commit comments

Comments
 (0)