-
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
Move basis change to main compute function #1027
Conversation
| benchmark_name | dt(%) | dt(s) | t_new(s) | t_old(s) |
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
test_build_transform_fft_lowres | +0.15 +/- 7.20 | +7.85e-04 +/- 3.70e-02 | 5.15e-01 +/- 3.6e-02 | 5.14e-01 +/- 8.9e-03 |
test_build_transform_fft_midres | -0.75 +/- 4.36 | -4.54e-03 +/- 2.63e-02 | 5.98e-01 +/- 1.9e-02 | 6.02e-01 +/- 1.8e-02 |
test_build_transform_fft_highres | -1.39 +/- 5.44 | -1.45e-02 +/- 5.66e-02 | 1.02e+00 +/- 3.9e-02 | 1.04e+00 +/- 4.1e-02 |
test_equilibrium_init_lowres | +0.57 +/- 4.00 | +2.12e-02 +/- 1.50e-01 | 3.76e+00 +/- 1.4e-01 | 3.74e+00 +/- 4.1e-02 |
test_equilibrium_init_medres | +1.76 +/- 2.35 | +7.36e-02 +/- 9.81e-02 | 4.25e+00 +/- 8.6e-02 | 4.17e+00 +/- 4.8e-02 |
test_equilibrium_init_highres | +0.45 +/- 1.83 | +2.55e-02 +/- 1.03e-01 | 5.69e+00 +/- 8.1e-02 | 5.66e+00 +/- 6.5e-02 |
test_objective_compile_dshape_current | -0.47 +/- 1.35 | -1.81e-02 +/- 5.17e-02 | 3.80e+00 +/- 4.3e-02 | 3.82e+00 +/- 2.9e-02 |
test_objective_compile_atf | +0.58 +/- 1.94 | +4.78e-02 +/- 1.60e-01 | 8.26e+00 +/- 9.6e-02 | 8.22e+00 +/- 1.3e-01 |
test_objective_compute_dshape_current | +0.45 +/- 3.33 | +5.58e-06 +/- 4.17e-05 | 1.26e-03 +/- 2.6e-05 | 1.25e-03 +/- 3.3e-05 |
test_objective_compute_atf | -0.33 +/- 4.46 | -1.42e-05 +/- 1.89e-04 | 4.23e-03 +/- 1.3e-04 | 4.25e-03 +/- 1.4e-04 |
test_objective_jac_dshape_current | +6.26 +/- 11.12 | +2.28e-03 +/- 4.06e-03 | 3.88e-02 +/- 3.7e-03 | 3.65e-02 +/- 1.8e-03 |
test_objective_jac_atf | -0.86 +/- 2.85 | -1.62e-02 +/- 5.36e-02 | 1.86e+00 +/- 3.0e-02 | 1.88e+00 +/- 4.4e-02 |
test_perturb_1 | -0.13 +/- 1.53 | -1.74e-02 +/- 2.01e-01 | 1.31e+01 +/- 1.6e-01 | 1.32e+01 +/- 1.3e-01 |
test_perturb_2 | -0.79 +/- 1.32 | -1.45e-01 +/- 2.42e-01 | 1.82e+01 +/- 2.1e-01 | 1.84e+01 +/- 1.2e-01 |
test_proximal_jac_atf | +0.12 +/- 1.08 | +8.69e-03 +/- 7.94e-02 | 7.35e+00 +/- 7.2e-02 | 7.34e+00 +/- 3.4e-02 |
test_proximal_freeb_compute | -1.03 +/- 1.01 | -1.85e-03 +/- 1.81e-03 | 1.77e-01 +/- 1.4e-03 | 1.79e-01 +/- 1.1e-03 |
test_proximal_freeb_jac | -0.74 +/- 1.29 | -5.45e-02 +/- 9.55e-02 | 7.35e+00 +/- 5.3e-02 | 7.41e+00 +/- 7.9e-02 |
test_solve_fixed_iter | +1.24 +/- 9.37 | +1.84e-01 +/- 1.39e+00 | 1.51e+01 +/- 1.0e+00 | 1.49e+01 +/- 9.4e-01 | |
So, the point of this PR is to get rid of repeated code. But if I do so, the test |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1027 +/- ##
==========================================
+ Coverage 94.97% 95.24% +0.27%
==========================================
Files 87 87
Lines 21822 21633 -189
==========================================
- Hits 20726 20605 -121
+ Misses 1096 1028 -68
|
desc/compute/utils.py
Outdated
@@ -140,6 +140,16 @@ def _compute( | |||
data = data_index[parameterization][name]["fun"]( | |||
params=params, transforms=transforms, profiles=profiles, data=data, **kwargs | |||
) | |||
# to reduce repeated code, for 3D and naturally in rtz but desired in xyz basis | |||
# quantities can be converted to xyz basis here | |||
if ( |
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.
move this outside of recursive, have _compute functions assume things come in in rpz
Enforce passed-in data is in rpz always (add to docstring) |
# handle this. | ||
assert queried_deps[p][name]["data"].issubset( | ||
data | axis_limit_data | ||
), err_msg |
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.
If you can't find a better way, then let's instead subtract phi from the latter set. FYI we removed the tests that ensures everything can be computed individually, i.e. without computing the entire dependency tree, and replaced it with this test which explicitly checks for this via inspecting the source code. For functions like the third derivatives of the basis vectors it's useful to keep this check as strict as possible.
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.
Substracting "phi" may cause problems since we only want to remove it if the quantity is one of the 3d vectors which changed basis in the main compute function.
This was a temporary change. i will think of a better way to do it, once I finish the actual coding part.
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 think this should be ok? We're ensuring that the dependencies are a subset of what actually gets computed right? as opposed to ensuring equality?
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.
Actually since we deleted phi
from dependencies, the previous version of this test might still be passing.
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.
@YigitElma In that case can you change this back
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.
Nevermind I changed it back on my branch.
Make every compute function to return in rpz by default and make all of the basis changes in main compute function |
…r different classes
…nto yge/rpz2xyz
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.
We should wait to get an approval from at least one person who hasn't contributed to this PR.
@@ -248,8 +282,8 @@ def get_profiles(keys, obj, grid=None, has_axis=False, jitable=False, **kwargs): | |||
Grid to compute quantity on. | |||
has_axis : bool | |||
Whether the grid to compute on has a node on the magnetic axis. | |||
jitable: bool |
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.
This was unused?
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.
Yes it was
@@ -66,7 +66,7 @@ def test_frenet(self): | |||
c.flip([0, 1, 0]) | |||
c.translate([1, 1, 1]) | |||
data = c.compute( | |||
["frenet_tangent", "frenet_normal", "frenet_binormal"], basis="xyz", grid=0 |
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.
Interesting that these vectors are the same in xyz and rpz
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'm not confident they were being computed correctly on master
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.
Just realized, we should update the change log to reflect this as it's pretty major (that by default the compute function will return things in rpz, as before I think it wasn't always the case?)
Revert changes to tesd_data_index from #1027 https://github.com/PlasmaControl/DESC/pull/1027/files/148d08d97cf6c08b922d0883700b2758dc9b000c#r1704624731
Resolves #992
Resolves #1088
All compute quantities are now returned in toroidal$(R,\phi,Z)$ coordinates.
TODO:
_curve
computes tootest_compute_everthing_xyz