-
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
Vectorize omnigenity objective over multiple surfaces #1225
Open
f0uriest
wants to merge
8
commits into
master
Choose a base branch
from
rc/omni_vectorized
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
24b4bff
Vectorize omnigenity objective over multiple surfaces
f0uriest 8dadee3
Merge branch 'master' into rc/omni_vectorized
f0uriest 0110249
Merge branch 'master' into rc/omni_vectorized
f0uriest f120562
Fix vectorized calculation of B_omni
f0uriest 5f2e24c
Add check for correct number of iotas
f0uriest 2bd7f96
Fix assert
f0uriest a522bc5
Update changelog
f0uriest bfb5651
Merge branch 'master' into rc/omni_vectorized
f0uriest File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1348,6 +1348,58 @@ def test_signed_plasma_vessel_distance(self): | |
) | ||
obj.build() | ||
|
||
@pytest.mark.unit | ||
def test_omnigenity_multiple_surfaces(self): | ||
"""Test omnigenity transform vectorized over multiple surfaces.""" | ||
surf = FourierRZToroidalSurface.from_qp_model( | ||
major_radius=1, | ||
aspect_ratio=20, | ||
elongation=6, | ||
mirror_ratio=0.2, | ||
torsion=0.1, | ||
NFP=1, | ||
sym=True, | ||
) | ||
eq = Equilibrium( | ||
Psi=6e-3, | ||
M=4, | ||
N=4, | ||
surface=surf, | ||
iota=PowerSeriesProfile(1, 0, -1), # ensure diff surfs have diff iota | ||
) | ||
field = OmnigenousField( | ||
L_B=1, | ||
M_B=3, | ||
L_x=1, | ||
M_x=1, | ||
N_x=1, | ||
NFP=eq.NFP, | ||
helicity=(1, 1), | ||
B_lm=np.array( | ||
[ | ||
[0.8, 1.0, 1.2], | ||
[-0.4, 0.0, 0.6], # radially varying B | ||
] | ||
).flatten(), | ||
) | ||
grid1 = LinearGrid(rho=0.5, M=eq.M_grid, N=eq.N_grid) | ||
grid2 = LinearGrid(rho=1.0, M=eq.M_grid, N=eq.N_grid) | ||
grid3 = LinearGrid(rho=np.array([0.5, 1.0]), M=eq.M_grid, N=eq.N_grid) | ||
obj1 = Omnigenity(eq=eq, field=field, eq_grid=grid1) | ||
obj2 = Omnigenity(eq=eq, field=field, eq_grid=grid2) | ||
obj3 = Omnigenity(eq=eq, field=field, eq_grid=grid3) | ||
obj1.build() | ||
obj2.build() | ||
obj3.build() | ||
f1 = obj1.compute(*obj1.xs(eq, field)) | ||
f2 = obj2.compute(*obj2.xs(eq, field)) | ||
f3 = obj3.compute(*obj3.xs(eq, field)) | ||
# the order will be different but the values should be the same so we sort | ||
# before comparing | ||
np.testing.assert_allclose( | ||
np.sort(np.concatenate([f1, f2])), np.sort(f3), atol=1e-14 | ||
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. why is the order different exactly? |
||
) | ||
|
||
|
||
@pytest.mark.regression | ||
def test_derivative_modes(): | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 is probably discussed during the first PR but can we change the docs of
eq_fixed
at line 536 to say "only thefield
is allowed to change" or something on that front? The user probably doesn't know what self.things meanThere 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.
Same for line 542