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

from_values method for FourierRZCoil and FourierPlanarCoil #1116

Merged
merged 34 commits into from
Jul 25, 2024

Conversation

dpanici
Copy link
Collaborator

@dpanici dpanici commented Jul 9, 2024

  • adds from_values method that was present in FourierRZCurve but missing in FourierRZCoil
  • also adds new from_values method for FourierPlanarCurve and FourierPlanarCoil

Resolves #1097

Copy link
Contributor

github-actions bot commented Jul 9, 2024

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     -1.31 +/- 6.92     | -6.88e-03 +/- 3.64e-02 |  5.19e-01 +/- 3.2e-02  |  5.26e-01 +/- 1.7e-02  |
 test_build_transform_fft_midres         |     -0.87 +/- 2.97     | -5.22e-03 +/- 1.79e-02 |  5.97e-01 +/- 1.1e-02  |  6.02e-01 +/- 1.4e-02  |
 test_build_transform_fft_highres        |     -0.18 +/- 3.20     | -1.82e-03 +/- 3.17e-02 |  9.87e-01 +/- 2.6e-02  |  9.89e-01 +/- 1.9e-02  |
 test_equilibrium_init_lowres            |     +0.42 +/- 5.43     | +1.57e-02 +/- 2.02e-01 |  3.73e+00 +/- 1.4e-01  |  3.72e+00 +/- 1.4e-01  |
 test_equilibrium_init_medres            |     +0.18 +/- 4.06     | +7.58e-03 +/- 1.70e-01 |  4.20e+00 +/- 1.2e-01  |  4.20e+00 +/- 1.2e-01  |
 test_equilibrium_init_highres           |     -0.47 +/- 1.59     | -2.62e-02 +/- 8.89e-02 |  5.55e+00 +/- 6.1e-02  |  5.57e+00 +/- 6.4e-02  |
 test_objective_compile_dshape_current   |     -0.13 +/- 1.16     | -5.23e-03 +/- 4.50e-02 |  3.88e+00 +/- 3.3e-02  |  3.88e+00 +/- 3.1e-02  |
 test_objective_compile_atf              |     +0.01 +/- 1.54     | +6.10e-04 +/- 1.30e-01 |  8.43e+00 +/- 7.9e-02  |  8.43e+00 +/- 1.0e-01  |
 test_objective_compute_dshape_current   |     -0.19 +/- 2.92     | -2.41e-06 +/- 3.66e-05 |  1.25e-03 +/- 2.5e-05  |  1.25e-03 +/- 2.7e-05  |
 test_objective_compute_atf              |     +0.49 +/- 5.41     | +2.07e-05 +/- 2.28e-04 |  4.24e-03 +/- 1.2e-04  |  4.22e-03 +/- 2.0e-04  |
 test_objective_jac_dshape_current       |     -7.70 +/- 8.15     | -3.01e-03 +/- 3.18e-03 |  3.61e-02 +/- 2.5e-03  |  3.91e-02 +/- 1.9e-03  |
 test_objective_jac_atf                  |     +3.70 +/- 3.35     | +6.85e-02 +/- 6.19e-02 |  1.92e+00 +/- 4.2e-02  |  1.85e+00 +/- 4.5e-02  |
 test_perturb_1                          |     -0.55 +/- 1.07     | -7.68e-02 +/- 1.48e-01 |  1.38e+01 +/- 1.3e-01  |  1.38e+01 +/- 7.8e-02  |
 test_perturb_2                          |     +0.12 +/- 1.38     | +2.26e-02 +/- 2.58e-01 |  1.88e+01 +/- 1.9e-01  |  1.87e+01 +/- 1.7e-01  |
 test_proximal_jac_atf                   |     -0.10 +/- 1.28     | -7.30e-03 +/- 9.42e-02 |  7.37e+00 +/- 6.5e-02  |  7.38e+00 +/- 6.8e-02  |
 test_proximal_freeb_compute             |     +0.33 +/- 0.91     | +6.00e-04 +/- 1.63e-03 |  1.81e-01 +/- 1.1e-03  |  1.80e-01 +/- 1.2e-03  |
 test_proximal_freeb_jac                 |     +0.02 +/- 1.01     | +1.83e-03 +/- 7.50e-02 |  7.40e+00 +/- 4.4e-02  |  7.40e+00 +/- 6.1e-02  |
 test_solve_fixed_iter                   |     +0.41 +/- 6.29     | +7.44e-02 +/- 1.14e+00 |  1.82e+01 +/- 8.5e-01  |  1.82e+01 +/- 7.7e-01  |

Copy link

codecov bot commented Jul 9, 2024

Codecov Report

Attention: Patch coverage is 81.01266% with 15 lines in your changes missing coverage. Please review.

Project coverage is 95.30%. Comparing base (7fdb093) to head (40f355a).
Report is 1735 commits behind head on master.

Files with missing lines Patch % Lines
desc/geometry/curve.py 82.60% 8 Missing ⚠️
desc/geometry/core.py 30.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1116      +/-   ##
==========================================
+ Coverage   95.26%   95.30%   +0.04%     
==========================================
  Files          87       87              
  Lines       22089    22154      +65     
==========================================
+ Hits        21042    21113      +71     
+ Misses       1047     1041       -6     
Files with missing lines Coverage Δ
desc/coils.py 97.19% <100.00%> (+0.09%) ⬆️
desc/geometry/core.py 91.66% <30.00%> (-2.28%) ⬇️
desc/geometry/curve.py 96.00% <82.60%> (+2.89%) ⬆️

f0uriest
f0uriest previously approved these changes Jul 9, 2024
@ddudt ddudt changed the title Add FourierRZcoil.from_values Method from_values method for FourierRZCoil and FourierPlanarCoil Jul 17, 2024
desc/geometry/curve.py Outdated Show resolved Hide resolved
warnif(
np.max(np.abs(coords[:, 2])) > 1e-14, # check that Z=0 for all points
UserWarning,
"Curve values are not planar!",
Copy link
Member

Choose a reason for hiding this comment

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

Might want to give more info here, ie it still tries a least squares fit? or it takes the projection of the curve into a plane?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It takes the projection into a plane. And now that I made your other requested change about using the average normal vector, that plane is the "best fit" in some sense.

desc/geometry/curve.py Outdated Show resolved Hide resolved
desc/geometry/curve.py Outdated Show resolved Hide resolved
desc/geometry/curve.py Outdated Show resolved Hide resolved
@@ -204,13 +204,27 @@ def test_adding_MagneticField_with_Coil_or_CoilSet(self):
def test_converting_coil_types(self):
"""Test conversions between coil representations."""
s = np.linspace(0, 2 * np.pi, 100, endpoint=False)
coil1 = FourierRZCoil(1e6, [0, 10, 2], [-2, 0, 0])
coil1 = FourierRZCoil(1e6, [0, 10, 0], [0, 0, 0])
Copy link
Collaborator Author

@dpanici dpanici Jul 23, 2024

Choose a reason for hiding this comment

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

The FourierPlanarCoil fails to fit the FourierRZCoil well if I make the n=1 component of it anything but zero... this seems like something it should be able to do with sufficient resolution? Maybe I messed something up in the fitting?

…maControl/DESC into dp/hotfix-fourierrzcoil-from-values
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
desc/coils.py Outdated Show resolved Hide resolved
@f0uriest
Copy link
Member

f0uriest commented Jul 23, 2024

@dpanici I think it's fine, it's just different curve parameter definitions. Plotting them all they're on top of each other (this was using the default grid without endpoint):

image

@dpanici dpanici requested a review from f0uriest July 24, 2024 00:10
f0uriest
f0uriest previously approved these changes Jul 24, 2024
ddudt
ddudt previously approved these changes Jul 24, 2024
@dpanici dpanici added the urgent Something we should fix/improve soon label Jul 24, 2024
@f0uriest f0uriest requested a review from ddudt July 25, 2024 00:15
@dpanici dpanici merged commit ef2bc39 into master Jul 25, 2024
17 of 18 checks passed
@dpanici dpanici deleted the dp/hotfix-fourierrzcoil-from-values branch July 25, 2024 18:30
ddudt added a commit that referenced this pull request Jul 27, 2024
These are methods that we forgot to add to #1116. 

It might also be worth adding an option to
`CoilSet.from_makegrid_coilfile` so that the coil set can be loaded as
any type, instead of always using `SplineXYZCoil`. But at least now we
can load the spline coils and then convert to any other coil type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
urgent Something we should fix/improve soon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add FourierPlanarCurve.from_values Method
4 participants