-
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
iota vacuum and current contributions #642
Conversation
I left the existing |
|
I think we might not want to do your first point. Because |
But Daniel wants to be able to compute |
desc/compute/_profiles.py
Outdated
@@ -701,7 +884,7 @@ def _iota_num_r(params, transforms, profiles, data, **kwargs): | |||
/ data["psi_r"] ** 2, | |||
lambda: ( | |||
profiles["current"].compute(params["c_l"], dr=2) * data["psi_rr"] | |||
- current_r * data["psi_rrr"] | |||
- current_r * data["psi_rrr"] # FIXME: psi_rrr=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.
psi_rrr
(and higher derivatives) are always 0. Can we remove all references to them from the compute functions to simplify the code?
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.
In #385 you modified the magnetic field computations to include psi_rrr
. So I included psi_rrr
to be consistent with all the other compute functions. I think either you or Rory mentioned in one of the meetings months ago that it could be useful to change psi_rrr
is not zero.
If you decide to remove this please add psi_rrr
to the zero_limits
list here:
DESC/tests/test_axis_limits.py
Line 17 in c0b4441
zero_limits = {"rho", "psi", "psi_r", "e_theta", "sqrt(g)", "B_t"} |
I prefer names like To compute Same thing for Currently on master, the only physics constraint I used to compute these limits is that the magnetic field is physical. (This was necessary because there is an if and only if relationship between this and the limit of iota being finite). FYI, there are two other perhaps weaker physics conditions which can make computing the limits easier. These conditions are that
|
The new quantities are working except for the axis limit of iota from the current. I think I understand why: I changed the references from things like The axis limits then depend on the value of |
equilibrium with fixed iota profiles. This is needed so that quantities like iota_current and iota_vacuum can be computed on equilibrium with fixed iota profiles.
The test was failing because
The computation of |
If Rory is okay with 6e9b9e2 then the master data will need to be updated in this PR since |
I'm generally fine with the above, it would be good if you did some basic benchmarking to see if it slows things down appreciably, but I doubt there will be a noticeable difference for most use cases |
This should be working now, I just need to add tests. Everything can be computed fine when the equilibrium has a current profile assigned. The only thing that can't be computed from an iota profile is |
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.
Fine as is (assuming the tests pass and the new code is covered) but may want to consider implementing stuff where we now return NaN, I don't think it would be too complicated
also make sure to update the changelog |
I implemented these, but you should check my formulas. The logic is a little tricky to avoid circular dependencies. Also these quantities will probably never actually be called by the user, since |
wasany benchmarking done? like how long it takes to to cmpute iota here versus master? |
| benchmark_name | dt(%) | dt(s) | t_new(s) | t_old(s) |
| ------------------------------- | ------------------- | ------------------- | ------------------ | ------------------ |
test_build_transform_fft_lowres | -5.57+/-7.86 | -1.66e-03+/-2.3e-03 | 2.82e-02+/-1.8e-03 | 2.99e-02+/-1.5e-03 |
+test_build_transform_fft_midres | -15.30+/-7.98 | -2.84e-02+/-1.5e-02 | 1.57e-01+/-1.0e-02 | 1.85e-01+/-1.1e-02 |
+test_build_transform_fft_highres | -10.10+/-4.52 | -8.56e-02+/-3.8e-02 | 7.62e-01+/-2.7e-02 | 8.47e-01+/-2.8e-02 |
test_equilibrium_init_lowres | -1.28+/-3.50 | -8.23e-03+/-2.2e-02 | 6.33e-01+/-1.2e-02 | 6.41e-01+/-1.9e-02 |
test_equilibrium_init_medres | -3.71+/-3.83 | -2.98e-02+/-3.1e-02 | 7.74e-01+/-2.1e-02 | 8.03e-01+/-2.2e-02 |
test_equilibrium_init_highres | -1.31+/-2.90 | -1.73e-02+/-3.8e-02 | 1.30e+00+/-2.9e-02 | 1.32e+00+/-2.5e-02 |
test_objective_compile_heliotron | +0.35+/-3.31 | +6.69e-02+/-6.4e-01 | 1.95e+01+/-5.5e-01 | 1.94e+01+/-3.3e-01 |
test_objective_compile_dshape_current | +0.13+/-4.44 | +1.00e-02+/-3.3e-01 | 7.42e+00+/-3.0e-01 | 7.41e+00+/-1.4e-01 |
test_objective_compile_atf | +2.23+/-3.85 | +4.61e-01+/-8.0e-01 | 2.11e+01+/-6.6e-01 | 2.06e+01+/-4.4e-01 |
test_objective_compute_heliotron | +0.63+/-316.88 | +3.33e-04+/-1.7e-01 | 5.35e-02+/-1.2e-01 | 5.32e-02+/-1.2e-01 |
test_objective_compute_dshape_current | -1.54+/-373.72 | -4.07e-04+/-9.9e-02 | 2.60e-02+/-6.9e-02 | 2.64e-02+/-7.0e-02 |
test_objective_compute_atf | -0.40+/-316.30 | -2.10e-04+/-1.7e-01 | 5.22e-02+/-1.2e-01 | 5.24e-02+/-1.2e-01 |
test_objective_jac_heliotron | +0.68+/-1.43 | +4.83e-02+/-1.0e-01 | 7.16e+00+/-1.0e-01 | 7.11e+00+/-1.7e-02 |
test_objective_jac_dshape_current | +5.37+/-8.50 | +6.83e-03+/-1.1e-02 | 1.34e-01+/-1.0e-02 | 1.27e-01+/-3.4e-03 |
-test_objective_jac_atf | +2.14+/-0.99 | +1.73e-01+/-8.0e-02 | 8.23e+00+/-5.7e-02 | 8.06e+00+/-5.7e-02 |
test_perturb_1 | +10.45+/-39.57 | +1.37e+00+/-5.2e+00 | 1.44e+01+/-3.7e+00 | 1.31e+01+/-3.6e+00 |
test_perturb_2 | +4.44+/-5.54 | +1.01e+00+/-1.3e+00 | 2.37e+01+/-8.9e-01 | 2.27e+01+/-8.9e-01 | |
I did this quickly for the DSHAPE and DSHAPE_current examples, seems it is as expected, in that an equilibrium with an iota profile and an equilibrium with a current profile now take the same time to calculate iota (because the iota profile eq still computes the iota contributions from the geometry/current of the equilibrium, even though it is not necessary) for the DSHAPE this is a slowdown of about 2X but since in optimization current profiles are almost always used this is fine. the current profile eq's iota compute speed has not changed significantly, it is now slightly slower but only by like 5% |
No description provided.