Skip to content

Added units for resonant flux/current overlaps in gpec_control_nn.nc#185

Open
matt-pharr wants to merge 2 commits intodevelopfrom
overlap-units-fix
Open

Added units for resonant flux/current overlaps in gpec_control_nn.nc#185
matt-pharr wants to merge 2 commits intodevelopfrom
overlap-units-fix

Conversation

@matt-pharr
Copy link
Collaborator

Smalll tweak. I noticed when doing SPARC calculations that these overlaps were not normalized, so I added units for clarity. Let me know if you know what the units should be for "Full width of saturated island overlap," or "Penetrated flux overlap," should be off the top of your head @logan-nc or otherwise I will trace through the code tomorrow afternoon.

@matt-pharr matt-pharr requested a review from logan-nc December 6, 2024 07:12
@logan-nc logan-nc self-assigned this Dec 6, 2024
@logan-nc
Copy link
Contributor

logan-nc commented Dec 6, 2024

Thanks @matt-pharr - I appreciate the initiative here. It's nice to feel like I have co-developers!!

Island widths are in normalized poloidal flux. So technically unitless, but you can put psi_n or something if you wish. Do whatever you think new users will find most helpful.

Penetrated flux is hopefully Tesla? Worth double checking for factors of area or half area though. I can't be 100% sure off the top of my head.

I'll happily merge once you give the green light.

CALL check( nf90_def_var(mncid, "I_overlap", nf90_double,
$ (/m_id,i_id/), c_id) )
CALL check( nf90_put_att(mncid, c_id, "units", "unitless") )
CALL check( nf90_put_att(mncid, c_id, "units", "Amps") )
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't all the overlaps be the same @matt-pharr? The un-normalized overlap is Phi_1 (unitless, unit vector) dot Phi_x (energy normalized flux). So I guess it is T m? The singular value s_1 carries the units that convert from Phi_x to whatever the target is (so unitless for Phi, A/Tm for current, etc.) I never thought about it before, but now that I write this... does this mean that the Bt normalization leaves the units as m? So we should actually be normalizing by sqrt(A)Bt? hmmm. Thoughts @parkjk?

Copy link
Collaborator Author

@matt-pharr matt-pharr Feb 2, 2025

Choose a reason for hiding this comment

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

I see what you mean here, I think you are right. Per Logan et al 2021 the units are easy to follow -- regardless of the units of $\mathcal{C}_{xe}$ (or $\mathcal{D}_c$ in the aforementioned reference) its right singular vector $\Phi_1$ is unitless, and since
$$\displaystyle \Phi_{xe}\cdot\Phi_{xe} = \oint da \left(\vec{B} \cdot \hat n\right)^2 \sim T^2m^2,$$
$\Phi_{xe}$ and the right-singular pitch-resonant flux overlap $\delta=\Phi_1 \cdot\Phi_{xe} / B_T$ should have units of Tm and m respectively. I wonder the effect using $\sqrt A B_T$ to normalize would have on the tightness of the uncertainty interval in the scaling law exponents?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this closed? I am still not following this... $\Phi_{xe}$ is sbno_mn in gpout.f, and is normalized by sqrt(jarea) to have the units of Tesla. At least for gpec_singfld_n#.out, I don't see a way that makes $\Phi_{xe}$ being the units of Tesla-meter.

@logan-nc
Copy link
Contributor

What is the status of this @matt-pharr?

@matt-pharr
Copy link
Collaborator Author

@logan-nc I think you are right about the units of $\delta B_T$ being Tesla-meters. See my reply to your code comment.

@claude
Copy link

claude bot commented Feb 14, 2026

Code Review

This PR adds units to the flux and current overlap variables in NetCDF output files. The changes appear correct based on the code analysis:

Positive Points

  • The unit clarifications are useful for users analyzing SPARC calculations and other outputs
  • The units Tesla for Phi_overlap and Amps for I_overlap align with the underlying physics:
    • Line 656: singbnoflxs is documented as effective resonant area-normalized flux (Phi_r/A) shielded by current (Tesla)
    • Line 657: singcurstwopinn is documented as resonant current (amps)
  • The typo fixes (Extrenal to External) are good corrections

Issues Found

1. Pre-existing typo in surrounding code (not introduced by this PR):

The file contains 12 instances of untiless (missing e) instead of unitless on lines:

  • 2151, 2156, 2161, 2166, 2171, 2176 (main overlap section)
  • 2261, 2266, 2271, 2276, 2281, 2286 (local overlap section)

These should be fixed separately or as part of this PR.

2. Fortran fixed-format line length:

This file is .f format with a 72-character limit. Line length check shows all modified lines are within limits, so no issues there.

3. Outstanding questions from PR description:

The PR author asks about units for:

  • Full width of saturated island overlap - This appears to be olap(3,ising) which corresponds to islandhwids (line 658: square of the penetrated island half-width in normalized poloidal flux). Currently labeled untiless (line 2151), should be dimensionless (psi_n^2).
  • Penetrated flux overlap - This is likely referring to the penetrated resonant field which has units of Tesla based on the code structure.

Recommendation

The core changes (Tesla and Amps) are correct. Consider either:

  1. Fixing the 12 untiless typos in this PR for completeness, or
  2. Creating a separate follow-up PR to fix those typos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

We should double check the units of the BT normalized overlaps

3 participants