-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add compute implementation for surface geometry terms #884
Changes from all commits
d09ac80
9118b46
7e128e7
d24ab93
279d71d
4d5b271
9b9ee9d
4dde043
675b65d
539196e
886fbb2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1653,3 +1653,20 @@ def test_iota_components(HELIOTRON_vac): | |
data = eq.compute(["iota", "iota current", "iota vacuum"], grid) | ||
np.testing.assert_allclose(data["iota"], data["iota vacuum"]) | ||
np.testing.assert_allclose(data["iota current"], 0) | ||
|
||
|
||
@pytest.mark.unit | ||
def test_surface_equilibrium_geometry(): | ||
"""Test that computing stuff from surface gives same result as equilibrium.""" | ||
names = ["DSHAPE", "HELIOTRON", "NCSX"] | ||
data = ["A", "V", "a", "R0", "R0/a", "a_major/a_minor"] | ||
for name in names: | ||
eq = get(name) | ||
for key in data: | ||
x = eq.compute(key)[key].max() # max needed for elongation broadcasting | ||
y = eq.surface.compute(key)[key].max() | ||
if key == "a_major/a_minor": | ||
rtol, atol = 1e-2, 0 # need looser tol here bc of different grids | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I increase the resolution of both the grids, can I reduce rtol and still pass the test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in theory yes. The main difference is that the eq.compute uses a quadrature grid to compute the perimeter, which doesn't include nodes at rho=1, so we extrapolate what the true perimeter is based on an approximation from rho~0.9x. As you increase the resolution, the outermost node in the quadrature grid will approach rho=1 but you'd need to go to really high resolution. |
||
else: | ||
rtol, atol = 1e-8, 0 | ||
np.testing.assert_allclose(x, y, rtol=rtol, atol=atol, err_msg=name + key) |
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.
Does this always work? What is the shape is like a triangle?
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.
it's always an approximation for any non-elliptical cross section, since the definitions of major and minor axes and elongation aren't uniquely defined in those cases. In practice it still gives reasonable results in all the cases we've tried it. For a triangular cross section you'd basically be getting the elongation of an equivalent elipse which would likely be close to 1, which is what we'd expect.