5.2. Construction of FineContour objects¶
FineContour objects are
created initially from PsiContour objects; this is largely for
historical reasons, as PsiContour was introduced first, and
FineContour added later to
improve accuracy and robustness.
After the FineContour is
created, or when it is modified (for example adding extra points beyond a
boundary, or decreasing the length when a wall intersects the initial contour),
it is then adjusted to ensure constant poloidal spacing of its points, using:
- FineContour.equaliseSpacing(*, psi, reallocate=False)
Adjust the positions of points in this
FineContourso they have a constant distance between them.Algorithm:
Refine all points using
refine().Calculate the poloidal distances along the
FineContour, and the spacings between adjacent points.Check if the spacings are constant, with an absolute tolerance given by the
finecontour_atolsetting. If so, stop iterating.Create an interpolation function for the R and Z positions of this
FineContouras a function of poloidal distance, usinginterpFunction().Create a new set of points using the interpolation functions, with a uniform grid of poloidal distances as input.
If the iteration count is greater than 8 and
finecontour_overdamping_factoris not 1.0, ‘overdamp’ the iteration by setting the new points as a sum of the new interpolated values (weighted byfinecontour_overdamping_factor) and the old values (weighted by(1-finecontour_overdamping_factor)).Return to 1.
As the interpolation is very accurate when the new points are very close to the old points (Taylor expansion around the old points is accurate because the displacement is small), this iteration usually converges fairly quickly.
If this method produces errors, setting
finecontour_diagnose = Truewill produce some more output which may help diagnose them.
The FineContour objects only
depend on the \(\psi\)-value of the contour and number of points (set by
finecontour_Nfine), not on the poloidal spacing settings for the grid, etc.
(the initial guess for the iteration may depend on these, but this dependence
is eliminated by the iteration, up to the finecontour_atol tolerance). This
independence should ensure the consistency of the calculated poloidal
distances, metric coefficients, etc. when input parameters, e.g. resolution,
are varied.