freegsnke.Myy_builder module

Defines the plasma_current Object, which handles the lumped parameter model used as an effective circuit equation for the plasma.

Copyright 2025 UKAEA, UKRI-STFC, and The Authors, as per the COPYRIGHT and README files.

This file is part of FreeGSNKE.

FreeGSNKE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

FreeGSNKE is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

You should have received a copy of the GNU Lesser General Public License along with FreeGSNKE. If not, see <http://www.gnu.org/licenses/>.

class freegsnke.Myy_builder.Myy_handler(limiter_handler, layer_size=5, tolerance=3)[source]

Bases: object

Object handling all operations which involve the Myy matrix, i.e. the mututal inductance matrix of all domain grid points. To reduce memory usage, the domain on which myy is built and stored is set adaptively, so to cover the plasma. This object handles this adaptive aspect.

__init__(limiter_handler, layer_size=5, tolerance=3)[source]

Instantiates the object

Parameters:
  • limiter_handler (FreeGSNKE limiter object, i.e. eq.limiter_handler) – Sets the properties of the domain grid and those of the limiter

  • layer_size (int, optional) – Used when recalculating myy. A layer of layer_size pixels is added to envelop the mask defined by the plasma. This ‘broadened’ mask defines the pixels included in the myy matrix By default 5

  • tolerance (int, optional) – Used to check if myy needs recalculating. Myy is not recalculated if the mask defined by the plasma region, broadened by tolerance pixels, is fully contained in the domain of the current myy matrix, By default 3

build_Myy_from_mask(mask)[source]

Build the Myy matrix only including domain points in the input mask

Parameters:

mask (np.ndarray) – mask of the domain points to include. Map is defined on the reduced rectangular domain grid, i.e. the smallest rectangular domain around limiter mask (same size as self.mask_inside_limiter_red)

build_mask_from_hatIy(hatIy, layer_size)[source]

Builds the mask that will be used by build_myy_from_mask based on the hatIy map. The mask is broadened by a number of pixels equal to layer mask. The limiter mask is taken into account.

Parameters:
  • hatIy (np.ndarray) – 1d vector on reduced plasma domain, e.g. inside the limiter

  • layer_size (int, optional) – _description_, by default 3

check_Myy(hatIy)[source]

Rebuilds myy when the input hatIy, broadened by a number of pixels set by tolerance, is not fully inside the current myy_mask Note 1. tolerance should be smaller than ‘layer_size’ in build_mask_from_hatIy Note 2. tolerance should be larger than the number of pixels by which the plasma is expected to ‘move’ every timestep of the evolution.

Parameters:
  • hatIy (np.ndarray) – 1d vector on reduced plasma domain, e.g. inside the limiter

  • tolerance (int) – number of pixels by which hatIy should be ‘inside self.myy_mask_red’

dot(hatIy)[source]

Performs the product with a vector defined on the reduced domain, i.e. inside the limiter. Returns a vector on the same domain.

Parameters:

hatIy (np.ndarray) – 1d vector on reduced plasma domain, e.g. inside the limiter

force_build_Myy(hatIy)[source]

Builds the Myy matrix only including domain points in the input vector (not necessarily a mask)

Parameters
hatIynp.ndarray

1d vector on reduced plasma domain, e.g. inside the limiter

grid_greens(R, Z)[source]

Calculates and stores the green function values on the minimal rectangular region that fully encompasses the limiter. Uses that the green functions are invariant for vertical translations.

Parameters:
  • R (np.ndarray) – Like eq.R, but on the rectangular reduced domain, i.e. self.reduce_rect_domain(limiter_handler.eqR)

  • Z (np.ndarray) – Like eq.Z, but on the rectangular reduced domain