simsopt icon indicating copy to clipboard operation
simsopt copied to clipboard

ag/cross section fix

Open andrewgiuliani opened this issue 1 year ago • 2 comments

I have used the Surface.cross_section algorithm on the entire QUASR database, and notice that very infrequently, the algorithm fails, see below

image

I rewrote the algorithm, making it simpler, to fix the bug. Rerunning the new algorithm on the entire dataset, I can't find any incorrect cross sections anymore.

image

Note that the jagged cross section where varphi=0 is because it uniformly samples the cross section in the Boozer theta angle, which may be insufficient as you can see.

andrewgiuliani avatar Jun 18 '24 20:06 andrewgiuliani

Codecov Report

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

Project coverage is 92.36%. Comparing base (f0f0ec4) to head (d13538d). Report is 89 commits behind head on master.

Files with missing lines Patch % Lines
src/simsopt/geo/surfacexyztensorfourier.py 50.00% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #428      +/-   ##
==========================================
+ Coverage   92.25%   92.36%   +0.10%     
==========================================
  Files          82       82              
  Lines       16015    16235     +220     
==========================================
+ Hits        14775    14995     +220     
  Misses       1240     1240              
Flag Coverage Δ
unittests 92.36% <97.56%> (+0.10%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar May 07 '25 05:05 codecov[bot]

@mishapadidar for future reference, I'm including the figure illustrating what the algorithm is doing (all angles are normalized by 2*pi for consistency with Surface objects in simsopt).

The first graph shows the cylindrical angle as calculated by atan2(y(varphi, theta),x(varphi, theta))/(2*pi). The problem is that this has a discontinuity when the surface crosses +/- 0.5. So we shift by atan2(y(0, theta),x(0, theta))/(2*pi) in the second graph. Any part of the shifted curve that is less than 0 has crossed +/- 0.5, so we shift negative function values up by 1 to obtain the function in the third graph. The resulting function is continuous provided that the surface crosses +/- 0.5 only once.

shift

andrewgiuliani avatar May 08 '25 20:05 andrewgiuliani

its looking good. just address the couple comments about documentation and we can get this thing landed.

mishapadidar avatar May 10 '25 14:05 mishapadidar