From 2a55df1dfd02514294e7c06a952beae8d8cc56a5 Mon Sep 17 00:00:00 2001 From: John Omotani Date: Tue, 3 Jun 2025 17:11:53 +0100 Subject: [PATCH 1/2] "linear" option for `nonorthogonal_spacing_method` --- doc/whats-new.md | 1 + hypnotoad/core/equilibrium.py | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/doc/whats-new.md b/doc/whats-new.md index 1c65d9b9..e85aa3d6 100644 --- a/doc/whats-new.md +++ b/doc/whats-new.md @@ -17,6 +17,7 @@ Release history of the grid with the wall. This enables immersed boundary conditions. - Wall coordinates are written to output grid as `closed_wall_R` and `closed_wall_Z` (#176) +- Linear poloidal spacing option for nonorthogonal grids (#190). 0.5.2 (13th March 2023) ------------------------- diff --git a/hypnotoad/core/equilibrium.py b/hypnotoad/core/equilibrium.py index d4b75f04..ece69a31 100644 --- a/hypnotoad/core/equilibrium.py +++ b/hypnotoad/core/equilibrium.py @@ -2372,6 +2372,7 @@ class EquilibriumRegion(PsiContour): "poloidal_orthogonal_combined", "perp_orthogonal_combined", "orthogonal", + "linear", ], ), ) @@ -2851,6 +2852,14 @@ def getSfuncFixedSpacing( spacing_lower=spacings["nonorthogonal_orthogonal_d_lower"], spacing_upper=spacings["nonorthogonal_orthogonal_d_upper"], ) + elif ( + self.nonorthogonal_options.nonorthogonal_spacing_method == "orthogonal" + ): + sfunc = self.getLinearPoloidalDistanceFunc( + distance, + npoints - 1, + ) + self._checkMonotonic([(sfunc, "linear")], total_distance=distance) else: sfunc = self.getSfuncFixedSpacing( npoints, From 3b757640c134054c2ef49688dd9085c7175924ee Mon Sep 17 00:00:00 2001 From: John Omotani Date: Tue, 19 Aug 2025 14:06:54 +0100 Subject: [PATCH 2/2] Documentation for linear poloidal spacing --- doc/nonorthogonal-grid.rst | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/doc/nonorthogonal-grid.rst b/doc/nonorthogonal-grid.rst index e5a23387..530b8ccc 100644 --- a/doc/nonorthogonal-grid.rst +++ b/doc/nonorthogonal-grid.rst @@ -20,6 +20,19 @@ way that varies smoothly with :math:`\psi`. see `feature request #146 `_. +There are a few options for setting the poloidal spacing, described in +detail in the subsections below: + +* Default method: can produce good-quality grids for production simulations. + Has may input parameters and usually requires extensive manual tweaking. Not + very robust. +* Linear spacing: Robust but inflexible, and produces grids with discontinuous + spacing. Not recommended for simulations, but may be useful for + exploration/scoping or to provide inputs to other tools. + +Default method +-------------- + The default method for nonorthogonal grids combines three properties: * Close to orthogonal far from X-points and targets @@ -147,8 +160,7 @@ file. moving radially away from the X-point is limited -- far from the X-point the poloidal spacing is approximately constant with changes in radius. -Technical details ------------------ +### Technical details The spacing is implemented by defining three separate :ref:`spacing functions ` and combining them with certain weights @@ -179,3 +191,12 @@ is created by :meth:`EquilibriumRegion.getSfuncFixedPerpSpacing() .. note:: Other methods for poloidal spacing than the default described on this page can be chosen by changing the ``nonorthogonal_spacing_method`` setting, but the other methods are intended mostly for debugging. + +Linear spacing +-------------- + +To use set `nonorthogonal_spacing_method = "linear"` and +`poloidal_spacing_option = "linear"`. + +In each region (target to X-point, or X-point to X-point) distributes the grid +points poloidally with a uniform spacing in poloidal (not parallel!) distance.