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

Hypnotoad nonorthogonal fixes #1593

Merged
merged 16 commits into from
Feb 21, 2019
Merged

Hypnotoad nonorthogonal fixes #1593

merged 16 commits into from
Feb 21, 2019

Conversation

johnomotani
Copy link
Contributor

Collection of bugfixes for Hypnotoad (see commit messages). The TORPEX cases I've been trying to grid seem to be good at getting into strange corner cases...

Previously was using number of points in leg segment, could cause error
if the number of points in the core segment happened to be less.
If the grid creation needs to be restarted from create_nonorthogonal, it
should restart the nonorthogonal procedure rather than the orthogonal
one.
Length of z-component was calculated incorrectly because the original
length of the vector was not stored, and the calculation for the
z-component used the normalized r-component.
If the intersection point is in the last segment of the wall, after the
last point in the 'boundary' array, then the index needs to be wrapped
around to the beginning of the array.
The vector that is supposed to be parallel to the wall was hard-coded to
[1,0] for the second wall intersection in the case with only one
X-point.
Add first point on boundary to end so that contour is treated as closed.
DERIV is inaccurate at the first/last points where it uses one-sided
differences. Wrapping around is not correct for open contours, but the
ends of these should not be close to an X-point.
When following lines along separatrix away from the X-point, continue
until both R and Z have reached an extremum. This should take the line
at least a quarter and at most half way around a closed contour. The
previous behaviour risked stopping after a very short distance if the
X-point was not at the top or bottom of the contour.
Finding distance by integrating index derivatives along contours is not
accurate, as the contour points may be very unevenly spaced. The
algorithm from poloidal_grid which directly adds up the distance between
grid points is more robust: this commit copies that algorithm to
line_dist.
Using INTERPOLATE is consistent with how contours are treated elsewhere,
which can prevent errors (for example the projected poloidal location of
the X-point being slightly different when calculated when fft_interp or
INTERPOLATE is used to find the starting position, leading to a position
being found on the wrong side of the X-point).

Also, fft_interp is likely to be inaccurate on contours, as their points
can be very unevenly spaced. INTERPOLATE uses linear interpolation which
is more robust.
Function is defined in follow_gradient_nonorth.pro

Previously was radial_differential, which is a name conflict with the
function defined in follow_gradient.pro, and caused Hypnotoad to crash
when re-running non-orthogonal grid generation.
Copy link
Contributor

@bendudson bendudson left a comment

Choose a reason for hiding this comment

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

Thanks @johnomotani !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants