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

Small Miscellaneous coil fixes #1311

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Small Miscellaneous coil fixes #1311

wants to merge 9 commits into from

Conversation

dpanici
Copy link
Collaborator

@dpanici dpanici commented Oct 19, 2024

  • adds setup method for coils, so when loading attributes will be set to None if they do not exist.
  • Add default for current
  • add missing name to docstring of FourierXYZCoil

@dpanici dpanici changed the title Add num_turns attribute to coils Add num_turns attribute to coils Oct 19, 2024
Copy link

codecov bot commented Oct 19, 2024

Codecov Report

Attention: Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.69%. Comparing base (48eb4d0) to head (58c9b27).
Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
desc/coils.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1311   +/-   ##
=======================================
  Coverage   95.69%   95.69%           
=======================================
  Files         101      101           
  Lines       25633    25638    +5     
=======================================
+ Hits        24529    24534    +5     
  Misses       1104     1104           
Files with missing lines Coverage Δ
desc/coils.py 97.95% <87.50%> (-0.13%) ⬇️

... and 1 file with indirect coverage changes

Copy link
Contributor

github-actions bot commented Oct 19, 2024

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     +1.07 +/- 6.60     | +6.10e-03 +/- 3.75e-02 |  5.75e-01 +/- 3.4e-02  |  5.69e-01 +/- 1.6e-02  |
 test_equilibrium_init_medres            |     -0.09 +/- 5.43     | -4.07e-03 +/- 2.43e-01 |  4.47e+00 +/- 1.7e-01  |  4.47e+00 +/- 1.7e-01  |
 test_equilibrium_init_highres           |     -0.81 +/- 4.52     | -4.67e-02 +/- 2.60e-01 |  5.69e+00 +/- 2.0e-01  |  5.74e+00 +/- 1.6e-01  |
 test_objective_compile_dshape_current   |     +1.00 +/- 4.93     | +4.24e-02 +/- 2.10e-01 |  4.30e+00 +/- 1.2e-01  |  4.25e+00 +/- 1.7e-01  |
 test_objective_compute_dshape_current   |     -0.47 +/- 2.43     | -2.49e-05 +/- 1.28e-04 |  5.26e-03 +/- 8.6e-05  |  5.28e-03 +/- 9.6e-05  |
 test_objective_jac_dshape_current       |     +0.60 +/- 6.57     | +2.59e-04 +/- 2.87e-03 |  4.38e-02 +/- 1.5e-03  |  4.36e-02 +/- 2.4e-03  |
 test_perturb_2                          |     -0.80 +/- 1.52     | -1.66e-01 +/- 3.14e-01 |  2.05e+01 +/- 2.4e-01  |  2.06e+01 +/- 2.0e-01  |
 test_proximal_freeb_jac                 |     +0.86 +/- 2.07     | +6.48e-02 +/- 1.55e-01 |  7.55e+00 +/- 1.4e-01  |  7.49e+00 +/- 5.7e-02  |
 test_solve_fixed_iter                   |     -0.52 +/- 2.44     | -1.74e-01 +/- 8.09e-01 |  3.29e+01 +/- 6.1e-01  |  3.31e+01 +/- 5.3e-01  |
 test_LinearConstraintProjection_build   |     +0.49 +/- 3.01     | +5.26e-02 +/- 3.21e-01 |  1.07e+01 +/- 2.4e-01  |  1.07e+01 +/- 2.1e-01  |
 test_build_transform_fft_midres         |     +0.40 +/- 1.75     | +2.41e-03 +/- 1.06e-02 |  6.07e-01 +/- 8.0e-03  |  6.04e-01 +/- 6.9e-03  |
 test_build_transform_fft_highres        |     +1.71 +/- 6.20     | +1.66e-02 +/- 6.03e-02 |  9.88e-01 +/- 6.0e-02  |  9.72e-01 +/- 7.0e-03  |
 test_equilibrium_init_lowres            |     -0.07 +/- 2.04     | -2.56e-03 +/- 7.85e-02 |  3.85e+00 +/- 5.9e-02  |  3.85e+00 +/- 5.2e-02  |
 test_objective_compile_atf              |     +1.22 +/- 3.37     | +1.02e-01 +/- 2.80e-01 |  8.41e+00 +/- 1.3e-01  |  8.31e+00 +/- 2.5e-01  |
 test_objective_compute_atf              |     +0.04 +/- 1.78     | +6.61e-06 +/- 2.80e-04 |  1.57e-02 +/- 2.3e-04  |  1.57e-02 +/- 1.6e-04  |
 test_objective_jac_atf                  |     +0.14 +/- 5.01     | +2.80e-03 +/- 9.93e-02 |  1.98e+00 +/- 5.8e-02  |  1.98e+00 +/- 8.1e-02  |
 test_perturb_1                          |     +0.01 +/- 1.53     | +1.78e-03 +/- 2.25e-01 |  1.47e+01 +/- 1.0e-01  |  1.47e+01 +/- 2.0e-01  |
 test_proximal_jac_atf                   |     +0.85 +/- 1.87     | +7.01e-02 +/- 1.55e-01 |  8.36e+00 +/- 1.2e-01  |  8.29e+00 +/- 9.7e-02  |
 test_proximal_freeb_compute             |     +0.57 +/- 0.97     | +1.14e-03 +/- 1.93e-03 |  2.01e-01 +/- 1.1e-03  |  2.00e-01 +/- 1.6e-03  |
 test_solve_fixed_iter_compiled          |     +0.03 +/- 1.13     | +6.75e-03 +/- 2.34e-01 |  2.07e+01 +/- 1.5e-01  |  2.07e+01 +/- 1.8e-01  |

@dpanici
Copy link
Collaborator Author

dpanici commented Oct 19, 2024

This might not be needed once we decide on #1169 actually, if we have some sort of nfilaments thing there...

@dpanici
Copy link
Collaborator Author

dpanici commented Oct 23, 2024

Better to do a subclass of curve instead of coil for stuff like Rogowski etc

@dpanici dpanici changed the title Add num_turns attribute to coils Small Miscelleneous coil fixes Jan 31, 2025
@dpanici dpanici changed the title Small Miscelleneous coil fixes Small Miscellaneous coil fixes Jan 31, 2025
@dpanici dpanici added the skip_changelog No need to update changelog on this PR label Jan 31, 2025
@dpanici dpanici requested review from a team, rahulgaur104, f0uriest, ddudt, sinaatalay, unalmis and YigitElma and removed request for a team January 31, 2025 20:49
@dpanici dpanici marked this pull request as ready for review January 31, 2025 20:49
@@ -238,6 +252,7 @@ def current(self):

@current.setter
def current(self, new):
new = setdefault(new, 1, new)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the purpose of this? Wouldn't this prevent someone from setting the current to 0, since 0 = False and so it would get replaced with the default value of 1?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you might have meant to do new = setdefault(new, 1)

@@ -689,8 +704,6 @@ def from_values(cls, current, coords, N=10, NFP=1, basis="rpz", sym=False, name=
sym : bool
Whether to enforce stellarator symmetry.
name : str
name for this coil
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why delete this? I think it should still say Name for this coil. like we have for all the similar methods of other coil classes.

Comment on lines -837 to +852
Name for this coil.
name for this coil
Copy link
Collaborator

Choose a reason for hiding this comment

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

I prefer proper punctuation in our doc strings, I think we do that in most cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip_changelog No need to update changelog on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants