-
Notifications
You must be signed in to change notification settings - Fork 49
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
Enable open upper limits for the grids in interpolation code #440
base: master
Are you sure you want to change the base?
Conversation
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.
Hi Bharat, I do not understand why this PR is needed, could you clarify?
You want to interpolate the BMW field on the cylindrical domain [rmin, rmax] x [phimin, phimax] x [zmin, zmax]. If you do not include the endpoint, what does the field interpolator do on the interval [rmax-h, rmax)?
The field is periodic in phi on 0 to 2pi, so I'm not sure why you can't just always include the endpoint there. If you're interpolating on 0 to 2pi/nfp, then same question as above, what happens on the subinterval (2pi/nfp - h, 2pi/nfp)?
phirange: a 3-tuple of the form ``(phimin, phimax, nphi)``. | ||
zrange: a 3-tuple of the form ``(zmin, zmax, nz)``. | ||
rrange: a 3-tuple of the form ``(rmin, rmax, nr)`` or a 4-tuple of the form ``(rmin, rmax, nr, include_endpoint)``. | ||
The default for `include_endpoint` is True. This mean that the interval :math:`[rmin, rmax]` 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.
typo, this means
rrange: a 3-tuple of the form ``(rmin, rmax, nr)`` or a 4-tuple of the form ``(rmin, rmax, nr, include_endpoint)``. | ||
The default for `include_endpoint` is True. This mean that the interval :math:`[rmin, rmax]` is | ||
split into ``nr`` many subintervals. When `include_endpoint` is False, interval :math:`[rmin, rmax)` is | ||
split into ``nr`` many subintervals. |
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.
what does it mean [rmin, rmax]
is split into nr
many subintervals as opposed to [rmin, rmax)
is split into nr
many subintervals ?
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.
To concretize this, lets suppose you want 5 points between 0 and 1. If you include the end point, the mesh would [0, 0.25, 0.5, 0.75, 1]. If you don't want to include the end point, the mesh generated would be [0, 0.2, 0.4, 0.6, 0.8]. So the mesh would be quite different. Unfortunately, BMW generates phi grid with end point not included.
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.
But then what happens on the small subinterval (2pi/nfp - h, 2pi/nfp)? I guess the behavior would be dictated by the extrapolate
keyword argument.
Since the BMW field is nfp-periodic, you can just rotate the B-field values from B(R, phi=0, Z) to B(R, phi=2pi/nfp, Z) and obtain the endpoint value.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #440 +/- ##
==========================================
- Coverage 92.52% 92.19% -0.34%
==========================================
Files 75 75
Lines 13833 13833
==========================================
- Hits 12799 12753 -46
- Misses 1034 1080 +46
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
My reaction is the same as @andrewgiuliani 's - to avoid extrapolating, the thing to do would be to rotate the BMW field from phi=0 by 2pi/nfp and add the result as a new grid point at phi=2pi/nfp. This could be done in whatever function you have that passes data from BMW to the InterpolatedField. It seems unlikely that a user would have |
I agree with @landreman and @andrewgiuliani, BMW will interpolate between the last phi plane and the first (flipped and copied according to the relevant symmetry), and the equivalently functioning Technically |
This PR enables open endpoints for the upper limits of the meshes when doing interpolation. The main reason to enable this functionality is to allow for [0, phi_max) generated by BMW mesh.