Stellarator-Tools
bivariate Module Reference

This modules contains routines for interpolating points inside a grid. This was originally written by S. P. Hirshman. It has been modified for thread safety converting it to be object oriented by M. Cianciosa. More...

Data Types

interface  bivariate_class
 An object containing persistent data for the bivariate interpolation. More...
 

Functions/Subroutines

class(bivariate_class) function, pointer bivariate_construct (ns, nu)
 Construct a bivariate_type object. More...
 
subroutine bivariate_destruct (this)
 Deconstruct a bivariate_type object. More...
 
subroutine bivariate_set_grids_2d (this, rsu, zsu, rgrid, zgrid)
 Set up the interpolation grid for a phi plane. More...
 
subroutine bivariate_set_grids_1d (this, rsu, zsu, rgrid, zgrid)
 Set up the interpolation grid for a phi plane. More...
 
subroutine bivariate_get_4pt (this, resp_rz, resp_su)
 Interpolate points on to response function grid. More...
 

Detailed Description

This modules contains routines for interpolating points inside a grid. This was originally written by S. P. Hirshman. It has been modified for thread safety converting it to be object oriented by M. Cianciosa.

Function/Subroutine Documentation

◆ bivariate_construct()

class (bivariate_class) function, pointer bivariate::bivariate_construct ( integer, intent(in)  ns,
integer, intent(in)  nu 
)

Construct a bivariate_type object.

Allocates memory and initializes a bivariate_type object.

Parameters
[in]nsNumber of radial grid points.
[in]nuNumber of poloidal grid points.
Returns
A pointer to a constructed bivariate_type object.

◆ bivariate_destruct()

subroutine bivariate::bivariate_destruct ( type (bivariate_class), intent(inout)  this)

Deconstruct a bivariate_type object.

Deallocates memory and uninitializes a bivariate_type object.

Parameters
[in,out]thisA bivariate_type instance.

◆ bivariate_get_4pt()

subroutine bivariate::bivariate_get_4pt ( class (bivariate_class), intent(inout)  this,
real (rprec), dimension(this%nrz), intent(in)  resp_rz,
real (rprec), dimension(this%nsu), intent(out)  resp_su 
)

Interpolate points on to response function grid.

Determin response function on the s,u grid by 4 point bivariate interpolation of response function on the r,z mesh at a fixed toroidal plane. This uses a 2-D interpolation based on the four point formula in Abramowitz and Stegun, Eq. 25.2.66. Note that the arrays need an explicit size in dimension to allow the 2D arrays to be passed to the 1D arguments.

Parameters
[in,out]thisA bivariate_type instance.
[in]resp_rzResponse function on the rz grid.
[out]resp_suResponse function on the su grid.

◆ bivariate_set_grids_1d()

subroutine bivariate::bivariate_set_grids_1d ( class (bivariate_class), intent(inout)  this,
real (rprec), dimension(:), intent(in)  rsu,
real (rprec), dimension(:), intent(in)  zsu,
real (rprec), dimension(:), intent(in)  rgrid,
real (rprec), dimension(:), intent(in)  zgrid 
)

Set up the interpolation grid for a phi plane.

Compute the indices (ir_bi, jz_bi) and weight factors (wij_bi) for performing bivariate (4 pt) interpolation FROM a rectangular (R X Z) grid TO a general (non-orthogonal) grid (s, u). R and Z grids may have different mesh sizes.

Parameters
[in,out]thisA bivariate_type instance.
[in]rsur coordinate at s,u
[in]zsuz coordinate at s,u
[in]rgridR coordinate on a fixed, equally spaced grid
[in]zgridZ coordinate on a fixed, equally spaced grid

◆ bivariate_set_grids_2d()

subroutine bivariate::bivariate_set_grids_2d ( class (bivariate_class), intent(inout)  this,
real (rprec), dimension(:,:), intent(in)  rsu,
real (rprec), dimension(:,:), intent(in)  zsu,
real (rprec), dimension(:), intent(in)  rgrid,
real (rprec), dimension(:), intent(in)  zgrid 
)

Set up the interpolation grid for a phi plane.

Compute the indices (ir_bi, jz_bi) and weight factors (wij_bi) for performing bivariate (4 pt) interpolation FROM a rectangular (R X Z) grid TO a general (non-orthogonal) grid (s, u). R and Z grids may have different mesh sizes.

Parameters
[in,out]thisA bivariate_type instance.
[in]rsur coordinate at s,u
[in]zsuz coordinate at s,u
[in]rgridR coordinate on a fixed, equally spaced grid
[in]zgridZ coordinate on a fixed, equally spaced grid