SPEC 3.20
Stepped Pressure Equilibrium Code
basefn.f90 File Reference

Polynomials evaluation. More...

Functions/Subroutines

subroutine get_cheby (lss, lrad, cheby)
 Get the Chebyshev polynomials with zeroth, first derivatives. More...
 
subroutine get_cheby_d2 (lss, lrad, cheby)
 Get the Chebyshev polynomials with zeroth, first and second derivatives The Chebyshev polynomial has been recombined and rescaled. See get_cheby for more detail. More...
 
subroutine get_zernike (r, lrad, mpol, zernike)
 Get the Zernike polynomials \(\hat{R}^{m}_{l}\) with zeroth, first derivatives. More...
 
subroutine get_zernike_d2 (r, lrad, mpol, zernike)
 Get the Zernike polynomials \(\hat{R}^{m}_{l}\) with zeroth, first, second derivatives. More...
 
subroutine get_zernike_rm (r, lrad, mpol, zernike)
 Get the Zernike polynomials \(\hat{R}^{m}_{l}/r^m\). More...
 

Detailed Description

Polynomials evaluation.

Function/Subroutine Documentation

◆ get_cheby()

subroutine get_cheby ( real, intent(in)  lss,
integer, intent(in)  lrad,
real, dimension(0:lrad,0:1), intent(inout)  cheby 
)

Get the Chebyshev polynomials with zeroth, first derivatives.

The Chebyshev polynomial has been recombined and rescaled. By doing so, the Chebyshev polynomial satisfy the zero Dirichlet boundary condition on the inner surface of the annulus with reduced ill-conditioning problem.

Let \(T_{l}\) be the Chebyshev polynomial of the first kind with degree \(l\). This subroutine computes

\[\bar{T}_0 = 1, \]

and

\[\bar{T}_l = \frac{T_l - (-1)^{l}}{l+1} . \]

\( T_l \) are computed iteratively.

\[ T_0(s) = 1, \]

\[ T_1(s) = s, \]

\[ T_{l+1}(s) = 2 s T_l(s) - T_{l-1}(s). \]

Parameters
[in]lsscoordinate input lss
[in]lradradial resolution
[out]chebythe value, first derivative of Chebyshev polynomial

References constants::one, constants::two, and constants::zero.

Referenced by bfield(), intghs(), ma00aa(), preset(), and spsint().

Here is the caller graph for this function:

◆ get_cheby_d2()

subroutine get_cheby_d2 ( real, intent(in)  lss,
integer, intent(in)  lrad,
real, dimension(0:lrad,0:2), intent(inout)  cheby 
)

Get the Chebyshev polynomials with zeroth, first and second derivatives The Chebyshev polynomial has been recombined and rescaled. See get_cheby for more detail.

Parameters
[in]lsscoordinate input lss
[in]lradradial resolution
[out]chebythe value, first and second derivative of Chebyshev polynomial

References constants::one, constants::two, and constants::zero.

Referenced by bfield_tangent(), and jo00aa().

Here is the caller graph for this function:

◆ get_zernike()

subroutine get_zernike ( real, intent(in)  r,
integer, intent(in)  lrad,
integer, intent(in)  mpol,
real, dimension(0:lrad,0:mpol,0:1), intent(inout)  zernike 
)

Get the Zernike polynomials \(\hat{R}^{m}_{l}\) with zeroth, first derivatives.

The original Zernike polynomial is defined by The Zernike polynomials take the form

\begin{eqnarray*} Z^{-m}_{l}(s,\theta) &= R^{m}_{l}(s) \sin m\theta,\\ Z^{m}_{l}(s,\theta) &= R^{m}_{l}(s) \cos m\theta, \end{eqnarray*}

where \(R^{m}_{l}(s)\) is a \(l\)-th order polynomial given by

\begin{eqnarray*} R_l^m(s) = \sum^{\frac{l-m}{2}}_{k=0} \frac{(-1)^k (l-k)!} {k!\left[\frac{1}{2}(l+m) - k \right]! \left[\frac{1}{2}(l-m) - k \right]!} s^{l-2k}, \end{eqnarray*}

and is only non-zero for \(l \ge m\) and even \(l-m\).

In this subroutine, \(R^{m}_{l}(s) \) is computed using the iterative relationship

\begin{eqnarray*} R_l^m(s) = \frac{2(l-1)(2l(l-2)s^2 -m^2 -l(l-2))R_{l-2}^m(s) - l (l+m-2) (l-m-2)R_{l-4}^m(s) }{(l+m)(l-m)(l-2)} \end{eqnarray*}

For \( m=0 \) and \( m=1 \), a basis recombination method is used by defining new radial basis functions as

\begin{eqnarray*} \hat{R}_{0}^{0} &= 1, \hat{R}^{0}_{l} &= \frac{1}{l+1}R^{0}_{l} - \frac{(-1)^{l/2}}{l+1}, \\ \hat{R}_{1}^{1} &= s, \hat{R}^{1}_{l} &= \frac{1}{l+1}R^{1}_{l} - \frac{(-1)^{(l-1)/2}}{2} s. \end{eqnarray*}

so that the basis scales as \(s^{m+2}\) except for \(\hat{R}_{0}^{0}\) and \(\hat{R}_{1}^{1}\), which are excluded from the representation of \({A}_{\theta,m,n}\). For \(m\ge2\), the radial basis functions are only rescaled as

\[ \hat{R}^{m}_{l} = \frac{1}{l+1}R^{m}_{l}. \]

Parameters
[in]rcoordinate input, note that this is normalized to \([0, 1]\)
[in]lradradial resolution
[in]mpolpoloidal resolution
[out]zernikethe value, first derivative of Zernike polynomial

References constants::one, constants::two, and constants::zero.

Referenced by bfield(), intghs(), ma00aa(), preset(), and spsint().

Here is the caller graph for this function:

◆ get_zernike_d2()

subroutine get_zernike_d2 ( real, intent(in)  r,
integer, intent(in)  lrad,
integer, intent(in)  mpol,
real, dimension(0:lrad,0:mpol,0:2), intent(inout)  zernike 
)

Get the Zernike polynomials \(\hat{R}^{m}_{l}\) with zeroth, first, second derivatives.

See get_zernike for more detail.

Parameters
[in]rcoordinate input, note that this is normalized to \([0, 1]\)
[in]lradradial resolution
[in]mpolpoloidal resolution
[out]zernikethe value, first/second derivative of Zernike polynomial

References constants::one, constants::two, and constants::zero.

Referenced by bfield_tangent(), and jo00aa().

Here is the caller graph for this function:

◆ get_zernike_rm()

subroutine get_zernike_rm ( real, intent(in)  r,
integer, intent(in)  lrad,
integer, intent(in)  mpol,
real, dimension(0:lrad,0:mpol), intent(inout)  zernike 
)

Get the Zernike polynomials \(\hat{R}^{m}_{l}/r^m\).

See get_zernike for more detail.

Parameters
[in]rcoordinate input, note that this is normalized to \([0, 1]\)
[in]lradradial resolution
[in]mpolpoloidal resolution
[out]zernikethe value

References constants::one, constants::two, and constants::zero.

Referenced by preset().

Here is the caller graph for this function: