Skip to content
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

Basis vectors #598

Merged
merged 26 commits into from
Aug 11, 2023
Merged

Basis vectors #598

merged 26 commits into from
Aug 11, 2023

Conversation

unalmis
Copy link
Collaborator

@unalmis unalmis commented Jul 25, 2023

Generalizes basis vectors to include toroidal stream function and adds their third derivatives.

This PR includes the second derivatives of the covariant basis vectors which were generated by Rory's code, and the following quantities that I coded:

  • 3rd derivatives of covariant basis vectors (review this more thoroughly)
  • 1st derivatives of contravariant basis vectors (Already checked for correctness with finite difference of the contravariant elements of the metric tensor)
  • Magnetic axis limits (Already checked for correctness in Magnetic axis limits and new variables #556 ).

@f0uriest Here is a diff of _basis_vectors.py from this branch with the sorted version _basis_vectors.py from #568.
https://diffy.org/diff/a1af98d05be0a.

@unalmis unalmis changed the base branch from master to rc/toroidal_angle July 25, 2023 18:11
@unalmis unalmis changed the base branch from rc/toroidal_angle to master July 25, 2023 18:13
git checkout add_all_limits tests/test_axis_limits.py
f0uriest and others added 5 commits July 28, 2023 14:50
@unalmis unalmis marked this pull request as ready for review August 1, 2023 00:05
Mark augmented lagrangian test xfail. from commit 248e158
Increase tolerance for QuasisymmetryTripleProduct. from commit 3ed6cff
@@ -917,6 +917,7 @@ def test_constrained_AL_lsq():

@pytest.mark.slow
@pytest.mark.regression
@pytest.mark.xfail
Copy link
Collaborator Author

@unalmis unalmis Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -665,7 +665,7 @@ def test_NAE_QIC_solve():
grid = LinearGrid(L=10, M=20, N=20, NFP=eq.NFP, sym=True, axis=False)
iota = compress(grid, eq.compute("iota", grid=grid)["iota"], "rho")

np.testing.assert_allclose(iota[1], qsc.iota, atol=1e-5)
np.testing.assert_allclose(iota[1], qsc.iota, atol=5e-4)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@f0uriest
Copy link
Member

f0uriest commented Aug 1, 2023

This might be a good chance to add tests for the covariant basis vectors by comparing to finite differences of [X, Y, Z], similar to test_magnetic_field_derivatives

@f0uriest
Copy link
Member

f0uriest commented Aug 1, 2023

the finite differencing test seems to fail consistently for e_zeta_rtt, you might want to check that one.

@codecov
Copy link

codecov bot commented Aug 1, 2023

Codecov Report

Merging #598 (309c4ef) into master (cc10a94) will increase coverage by 0.06%.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #598      +/-   ##
==========================================
+ Coverage   94.30%   94.37%   +0.06%     
==========================================
  Files          77       77              
  Lines       17696    17821     +125     
==========================================
+ Hits        16689    16818     +129     
+ Misses       1007     1003       -4     
Files Changed Coverage Δ
desc/compute/_basis_vectors.py 99.29% <ø> (-0.71%) ⬇️
desc/compute/_bootstrap.py 100.00% <ø> (ø)
desc/compute/_geometry.py 100.00% <ø> (ø)
desc/compute/_metric.py 100.00% <ø> (ø)
desc/compute/_field.py 100.00% <100.00%> (ø)
desc/compute/_profiles.py 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

desc/compute/_geometry.py Show resolved Hide resolved
docs/sort_compute_funs.py Outdated Show resolved Hide resolved
tests/test_axis_limits.py Show resolved Hide resolved
Comment on lines +396 to +398
rtol = 1e-3
atol = 1e-3
num_zeta = 180
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we need to increase the tolerances, despite also increasing the finite difference resolution?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably not, I just went for a consistent tolerance that worked for everything rather than trying to fine tune the tolerance for each different quantity.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's fine for rtol, but in general could be dangerous for atol since some derivates might be close to zero

desc/compute/_bootstrap.py Outdated Show resolved Hide resolved
f0uriest
f0uriest previously approved these changes Aug 2, 2023
Can't sort compute functions by quantity name anymore because
there are multiple quantities with the same name. Have to sort
by function name instead.

Needed to update tests/test_axis_limits for the dependency check
test.
f0uriest
f0uriest previously approved these changes Aug 9, 2023
@unalmis unalmis requested a review from ddudt August 10, 2023 19:57
@@ -173,94 +177,94 @@ def test_magnetic_field_derivatives(DummyStellarator):
B_rr = np.apply_along_axis(my_convolve, 0, data["B"], FD_COEF_2_4) / drho**2

np.testing.assert_allclose(
data["B^theta_r"][3:-2],
B_sup_theta_r[3:-2],
data["B^theta_r"][4:-4],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why make these further from the bdry? because you increased nrho so want to keep it at the same rho values roughly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess is same reason as #598 (comment)

@unalmis unalmis merged commit 7e0dcf1 into master Aug 11, 2023
21 checks passed
@unalmis unalmis deleted the basis_vectors branch August 11, 2023 19:02
@unalmis unalmis self-assigned this Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants