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

Refactor iota computation and add limit #448

Merged
merged 44 commits into from
Jun 15, 2023
Merged

Conversation

unalmis
Copy link
Collaborator

@unalmis unalmis commented Mar 8, 2023

  • Refactor the computation of iota and add ability to compute iota at the rho=0 axis
    • Computation shows the limit appears to be a continuous extension of iota to the axis. As long as it actually is, I think this is sufficient to formally justify that interchange of the integral and limit we discussed. my_math.pdf
  • Correct QAS input file
    • The input file on master for QAS was generated sometime between September (I think) and October 15. The one I uploaded in thie PR is the one generated by DESC on October 15 (and could be regenerated when this PR was made) that had better agreement with VMEC's QAS solve. Although, the VMEC input input.QAS.txt to DESC input converter recently (as in sometime close to June 6 2023) gives something different now.
    • The reason this change is included in this PR is because one test on QAS for the iota limit computation includes a comparison to a hardcoded value of iota that comes from solving the QAS input file. So if I want that test to be more accurate I should make sure QAS is being solved well.
  • Implement efficient API for limits.pdf
    • Skipped part 3 for now due to Rory's suggestion; although the broadcasting is not an issue (updated the pdf to show why)

desc/compute/_profiles.py Outdated Show resolved Hide resolved
desc/compute/_profiles.py Outdated Show resolved Hide resolved
desc/compute/_profiles.py Outdated Show resolved Hide resolved
desc/compute/_profiles.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Mar 9, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +26.25 🎉

Comparison is base (c4d61e3) 67.76% compared to head (c8257ab) 94.01%.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #448       +/-   ##
===========================================
+ Coverage   67.76%   94.01%   +26.25%     
===========================================
  Files          73       73               
  Lines       16452    16497       +45     
===========================================
+ Hits        11148    15510     +4362     
+ Misses       5304      987     -4317     
Impacted Files Coverage Δ
desc/compute/data_index.py 100.00% <ø> (ø)
desc/equilibrium/coords.py 98.21% <ø> (+43.75%) ⬆️
desc/grid.py 96.60% <ø> (+22.90%) ⬆️
desc/compute/__init__.py 100.00% <100.00%> (ø)
desc/compute/_field.py 100.00% <100.00%> (+29.27%) ⬆️
desc/compute/_profiles.py 100.00% <100.00%> (+24.15%) ⬆️
desc/compute/utils.py 96.01% <100.00%> (+16.62%) ⬆️
desc/equilibrium/configuration.py 98.97% <100.00%> (+13.06%) ⬆️
desc/objectives/_bootstrap.py 98.88% <100.00%> (+11.11%) ⬆️
desc/objectives/_equilibrium.py 96.29% <100.00%> (+0.92%) ⬆️
... and 5 more

... and 47 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

tests/test_constrain_current.py Outdated Show resolved Hide resolved
tests/test_constrain_current.py Outdated Show resolved Hide resolved
@unalmis unalmis changed the title Current verification Refactor iota computation and add limit Apr 12, 2023
@unalmis unalmis marked this pull request as ready for review April 12, 2023 04:14
tests/test_compute_utils.py Outdated Show resolved Hide resolved
tests/test_compute_utils.py Outdated Show resolved Hide resolved
@unalmis unalmis requested review from f0uriest and ddudt April 12, 2023 04:23
@unalmis unalmis added low priority Nice to have, but not needed right away good first issue Good for newcomers speed New feature or request to make the code faster labels Apr 12, 2023
@unalmis unalmis marked this pull request as draft April 13, 2023 18:14
@dpanici
Copy link
Collaborator

dpanici commented May 2, 2023

@unalmis what is the status on this? I am starting to write my paper where I use on-axis quantitites from DESC as a verification against near-axis theory, and it could be nice to be able to just say "on-axis values from DESC" and not have to sweep under the rug the fact that we are calculating things at $\rho=1e-6$ instead of at 0 (though maybe not completely necessary)

@unalmis
Copy link
Collaborator Author

unalmis commented May 2, 2023

@unalmis what is the status on this? I am starting to write my paper where I use on-axis quantitites from DESC as a verification against near-axis theory, and it could be nice to be able to just say "on-axis values from DESC" and not have to sweep under the rug the fact that we are calculating things at ρ=1e−6 instead of at 0 (though maybe not completely necessary)

Would you like to just compute iota and its derivatives at 0, or are you asking for the status of #486? If its the former, I can probably do the math for the iota_r and iota_rr and add them with tests within the next few days.

desc/plotting.py Outdated Show resolved Hide resolved
desc/compute/_profiles.py Outdated Show resolved Hide resolved
tests/test_axis_limits.py Outdated Show resolved Hide resolved
tests/test_axis_limits.py Outdated Show resolved Hide resolved
dpanici
dpanici previously approved these changes Jun 14, 2023
desc/compute/__init__.py Outdated Show resolved Hide resolved
desc/compute/utils.py Outdated Show resolved Hide resolved
desc/compute/utils.py Outdated Show resolved Hide resolved
@@ -528,7 +534,9 @@ def build(self, eq, use_jit=True, verbose=1):

self._dim_f = surface_grid.num_nodes
self._data_keys = ["R", "phi", "Z"]
self._args = get_params(self._data_keys)
self._args = get_params(
self._data_keys, has_axis=plasma_grid.axis.size or surface_grid.axis.size
Copy link
Member

Choose a reason for hiding this comment

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

FYI the surface grid should never have a point at the axis (since its a 2d grid over a surface) and realistically the plasma grid shouldn't either.

@unalmis unalmis requested review from f0uriest and dpanici June 14, 2023 19:46
Copy link
Collaborator

@ddudt ddudt left a comment

Choose a reason for hiding this comment

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

Can we make a list of which quantities can now be computed at the axis and which axis limits still need to be implemented?

desc/objectives/utils.py Show resolved Hide resolved
"""
deps = {
"params": params,
"transforms": transforms,
"profiles": profiles,
"data": data,
"axis_limit_data": [] if axis_limit_data is None else axis_limit_data,
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not have the default be axis_limit_data=[] instead of None, and then this line can simply be "axis_limit_data": axis_limit_data (like all the other fields)

Copy link
Collaborator Author

@unalmis unalmis Jun 14, 2023

Choose a reason for hiding this comment

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

Using a mutable object as a default parameter can lead to bugs. Because the default parameter of the function stores a reference to some list, if that list is modified, then the default value of the function changes accordingly to the modified list.
We don't plan to ever modify a quantity's axis_limit_data list, so you're right that we can use the same empty list for axis_limit_data for all quantities that don't specify it in the compute_funs.
We use this same None to new empty list design pattern in other places of the code. Let me know if you still want me to change

desc/plotting.py Outdated Show resolved Hide resolved
@unalmis
Copy link
Collaborator Author

unalmis commented Jun 15, 2023

I'm going to merge this since the changes since Dario's approval were cosmetic

@unalmis unalmis merged commit 9160c33 into master Jun 15, 2023
@unalmis unalmis deleted the current_verification branch June 15, 2023 02:45
@unalmis unalmis added the theory Requires theory work before coding label Jul 22, 2024
@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
good first issue Good for newcomers theory Requires theory work before coding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants