-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CoilSet with NFP and sym #864
Conversation
| benchmark_name | dt(%) | dt(s) | t_new(s) | t_old(s) |
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
test_build_transform_fft_lowres | +0.41 +/- 1.58 | +5.03e-05 +/- 1.95e-04 | 1.24e-02 +/- 1.2e-04 | 1.24e-02 +/- 1.5e-04 |
test_build_transform_fft_midres | +0.80 +/- 1.48 | +7.30e-04 +/- 1.35e-03 | 9.19e-02 +/- 7.1e-04 | 9.12e-02 +/- 1.1e-03 |
test_build_transform_fft_highres | +0.97 +/- 0.96 | +4.46e-03 +/- 4.43e-03 | 4.65e-01 +/- 4.1e-03 | 4.61e-01 +/- 1.6e-03 |
test_equilibrium_init_lowres | +0.64 +/- 2.57 | +5.06e-03 +/- 2.03e-02 | 7.94e-01 +/- 1.7e-02 | 7.89e-01 +/- 1.1e-02 |
test_equilibrium_init_medres | +0.21 +/- 1.79 | +3.01e-03 +/- 2.55e-02 | 1.43e+00 +/- 1.9e-02 | 1.42e+00 +/- 1.7e-02 |
test_equilibrium_init_highres | -0.44 +/- 1.21 | -1.86e-02 +/- 5.08e-02 | 4.18e+00 +/- 2.2e-02 | 4.20e+00 +/- 4.6e-02 |
test_objective_compile_dshape_current | -4.54 +/- 7.56 | -2.07e-01 +/- 3.45e-01 | 4.36e+00 +/- 2.5e-01 | 4.57e+00 +/- 2.4e-01 |
test_objective_compile_atf | -0.07 +/- 5.59 | -6.52e-03 +/- 5.20e-01 | 9.31e+00 +/- 4.1e-01 | 9.31e+00 +/- 3.3e-01 |
test_objective_compute_dshape_current | -0.25 +/- 3.28 | -5.37e-06 +/- 7.00e-05 | 2.13e-03 +/- 3.8e-05 | 2.13e-03 +/- 5.9e-05 |
test_objective_compute_atf | +0.87 +/- 1.26 | +6.47e-05 +/- 9.34e-05 | 7.48e-03 +/- 4.6e-05 | 7.42e-03 +/- 8.1e-05 |
test_objective_jac_dshape_current | +1.74 +/- 8.49 | +7.76e-04 +/- 3.79e-03 | 4.55e-02 +/- 3.3e-03 | 4.47e-02 +/- 1.9e-03 |
test_objective_jac_atf | -1.47 +/- 4.29 | -3.31e-02 +/- 9.67e-02 | 2.22e+00 +/- 7.8e-02 | 2.26e+00 +/- 5.7e-02 |
test_perturb_1 | -2.77 +/- 12.12 | -2.44e-01 +/- 1.07e+00 | 8.58e+00 +/- 8.1e-01 | 8.82e+00 +/- 7.0e-01 |
test_perturb_2 | -1.07 +/- 6.55 | -1.55e-01 +/- 9.51e-01 | 1.44e+01 +/- 4.5e-01 | 1.45e+01 +/- 8.4e-01 | |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #864 +/- ##
==========================================
+ Coverage 94.81% 94.84% +0.02%
==========================================
Files 80 80
Lines 19695 19711 +16
==========================================
+ Hits 18674 18695 +21
+ Misses 1021 1016 -5
|
def body(B, x): | ||
B += self[0].compute_magnetic_field( | ||
coords, params=x, basis=basis, grid=grid | ||
# stellarator symmetry is easiest in [X,Y,Z] coordinates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found it was easiest to convert back and forth between the two different coordinate systems to use whichever one is most convenient in the moment, rather than doing all the computations in whichever basis the user input. These conversions are small constant matrix multiplications so I figure there isn't much downside to this approach.
B_xyz = coil.compute_magnetic_field( | ||
grid_xyz, basis="xyz", source_grid=coil_grid | ||
) | ||
B_rpz = coil.compute_magnetic_field( | ||
grid_rpz, basis="rpz", source_grid=coil_grid | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized we didn't have any test to check that compute_magnetic_field(basis="rpz")
gives the same result as compute_magnetic_field(basis="xyz")
, so I added it here for each coil.
np.testing.assert_allclose(B_true, B_approx, rtol=1e-3, atol=1e-10) | ||
|
||
@pytest.mark.unit | ||
def test_symmetry_magnetic_field(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of what this new test is checking:
sym_coilset
contains only 3 unique coils in half of one field period. It computes it's magnetic field assuming field period symmetry and stellarator symmetry, using the new code that was added.
asym_coilset
contains 24 coils but should be equivalent to the other coil set (3 unique coils, x2 for stellarator symmetry, x4 field periods). It computes it's magnetic field the "old school" way from each coil.
This test checks that both coil sets give the same magnetic fields, in both coordinate systems.
Change back to coords but make sure it cant accept Grid for that argument |
- deleted eq arg in build() - used wrapper for Bplasma - updated grid to source_grid for compute_magnetic_field - add tolerances for testing axisymmetric Bnorm (maybe #864)
Resolves #858
TODO:
NFP > 1
)sym = True
)