Stellarator-Tools
|
Module contains subroutines for computing FFT on parallel radial intervals. Converts quantities between real and fourier space. Note fixarray must be called once before call any of the Fourier subroutines to calculate all necessary sine and cosine factors on a fixed mesh of collocation angles. More...
Data Types | |
interface | fourier_class |
Base class containing fourier memory. More... | |
interface | check |
Interface for checking results of the unit tests. More... | |
Functions/Subroutines | |
class(fourier_class) function, pointer | fourier_construct (mpol, ntor, ntheta, nzeta, nfp, sym, tor_modes) |
Construct a fourier_class object. More... | |
subroutine | fourier_destruct (this) |
Deconstruct a fourier_class object. More... | |
subroutine | fourier_tomnsp_3d (this, xuv, xmn, parity) |
Convert a quantity from real to fourier space in parallel. More... | |
subroutine | fourier_tomnsp_3d_pest (this, xuv, xmn, lmns, lmnc, |
Convert a quantity from real to fourier space in pest coordinates. More... | |
pure subroutine | fourier_tomnsp_2d (this, xuv, xmn, parity) |
Fourier transform a 2D quantity to fourier space. More... | |
pure subroutine | fourier_tomnsp_2d_pest (this, xuv, xmn, lambda, dup |
Fourier transform a 2D quantity to fourier space. More... | |
pure subroutine | fourier_tomnsp_2d_u (this, xuv) |
Sum over the poloidal part. More... | |
pure subroutine | fourier_tomnsp_2d_u_pest (this, xuv, lambda, dupdu, |
Sum over the poloidal part. More... | |
pure subroutine | fourier_tomnsp_2d_v (this, xmn, parity) |
Sum over toroidal angle. More... | |
subroutine | fourier_toijsp_3d (this, xmn, xuv, dflag, parity) |
Convert a quantity from fourier to real space in parallel. More... | |
pure subroutine | fourier_toijsp_2d (this, xmn, xuv, dflag, parity) |
Fourier transform a 2D quantity to real space. More... | |
subroutine | fourier_get_origin (this, xuv, mode, asym) |
Computes the origin value of a half-mesh quantity. More... | |
subroutine | fourier_round_trig (cosi, sini) |
Round trig values to whole number for near numbers. More... | |
logical function | fourier_get_index (this, n) |
The the index position of the toroidal mode if it exists. More... | |
logical function | test_fourier () |
Test fourier routines. More... | |
Variables | |
integer, parameter | f_cos = 0 |
Cosine parity. | |
integer, parameter | f_sin = 1 |
Sine parity. | |
integer, parameter | f_none = 0 |
Do not sum fouier real space transformed quantity. This is used when a stellarator symmetric parity is being converted to real space. | |
integer, parameter | f_ds = 1 |
Radial derivative flag. | |
integer, parameter | f_du = 2 |
Poloidal derivative flag. | |
integer, parameter | f_dv = 4 |
Toroidal derivative flag. | |
integer, parameter | f_dudv = IOR(f_du, f_dv) |
Combined toroidal and poloidal derivatives. | |
integer, parameter | f_sum = 8 |
Sum fouier real space transformed quantity. This is used when a non-stellarator symmetric parity is being converted to real space. | |
integer, parameter | f_jac = 16 |
Quantity, contains jacobian. | |
integer, parameter | f_con = 32 |
Covariant basis. | |
integer, parameter | b_ds = 0 |
Bit position of the f_ds flag. | |
integer, parameter | b_du = 1 |
Bit position of the f_du flag. | |
integer, parameter | b_dv = 2 |
Bit position of the f_dv flag. | |
integer, parameter | b_sum = 3 |
Bit position of the f_sum flag. | |
integer, parameter | b_jac = 4 |
Bit position of the f_jac flag. | |
integer, parameter | b_con = 5 |
Bit position of the f_co flag. | |
integer, parameter | m0 = 0 |
m = 0 mode. | |
integer, parameter | m1 = 1 |
m = 1 mode. | |
integer, parameter | m2 = 2 |
m = 2 mode. | |
integer, parameter | n0 = 0 |
n = 0 mode. | |
integer, parameter | n1 = 1 |
n = 1 mode. | |
Module contains subroutines for computing FFT on parallel radial intervals. Converts quantities between real and fourier space. Note fixarray must be called once before call any of the Fourier subroutines to calculate all necessary sine and cosine factors on a fixed mesh of collocation angles.
class (fourier_class) function, pointer fourier::fourier_construct | ( | integer, intent(in) | mpol, |
integer, intent(in) | ntor, | ||
integer, intent(in) | ntheta, | ||
integer, intent(in) | nzeta, | ||
integer, intent(in) | nfp, | ||
logical, intent(in) | sym, | ||
integer, dimension(-ntor:ntor), intent(in) | tor_modes | ||
) |
Construct a fourier_class object.
Allocates memory and initializes a fourier_class object. Computes the othronorm and cosine and sine buffers.
This subroutine computes the cosine-sine factors that will be needed when moving between Fourier and real space. All normalizations are contained in the poloidal quantities used in the Fourier to real space transformation:
Fourier representations are assumed to have stellarator symmetry: *# cosine (iparity=0): C(u, v) = sum_u sum_v (C_mn COS(mu + n*nfp*v)) *# sine (iparity=1): S(u, v) = sum_u sum_v (S_mn SIN(mu + n*nfp*v))
The number of collocation points have been set initalially equal to the number of modes: theta_j = j*pi/M, j = 0,...,M Where M = mpol - 1 zeta_k = k*2*pi/(2N + 1) k = 0,...,2N Where N = ntor.
[in] | mpol | Number of poloidal modes. |
[in] | ntor | Number of toroidal modes. |
[in] | ntheta | Number of poloidal real grid points. |
[in] | nzeta | Number of toroidal real grid points. |
[in] | nfp | Number of field periods. |
[in] | sym | Symmetry flag. |
[in] | tor_modes | Toroidal mode numbers. |
subroutine fourier::fourier_destruct | ( | type (fourier_class), intent(inout) | this | ) |
Deconstruct a fourier_class object.
Deallocates memory and uninitializes a fourier_class object.
[in,out] | this | A fourier_class instance. |
logical function fourier::fourier_get_index | ( | class (fourier_class), intent(inout) | this, |
integer, intent(inout) | n | ||
) |
The the index position of the toroidal mode if it exists.
[in,out] | this | A fourier_class instance. |
[in,out] | n | Toroidal mode number to check the index on exit. |
subroutine fourier::fourier_get_origin | ( | class (fourier_class), intent(inout) | this, |
real(dp), dimension(:,:,:), intent(inout), allocatable | xuv, | ||
integer, intent(in) | mode, | ||
logical, intent(in) | asym | ||
) |
Computes the origin value of a half-mesh quantity.
The origin quantity is found from the m mode of the js = 2 value.
[in,out] | this | A fourier_class instance. |
[in,out] | xuv | Real space quantity. |
[in] | mode | Poloidal mode number to be retained. |
[in] | asym | Add stellarator asymmetric terms. |
subroutine fourier::fourier_round_trig | ( | real (dp), intent(inout) | cosi, |
real (dp), intent(inout) | sini | ||
) |
Round trig values to whole number for near numbers.
[in,out] | cosi | Cosine value to round. |
[in,out] | sini | Sine value to round. |
pure subroutine fourier::fourier_toijsp_2d | ( | class (fourier_class), intent(inout) | this, |
real (dp), dimension(:,:), intent(in) | xmn, | ||
real (dp), dimension(:,:), intent(inout) | xuv, | ||
integer, intent(in) | dflag, | ||
integer, intent(in) | parity | ||
) |
Fourier transform a 2D quantity to real space.
Works by reshaping to a 3D array then passing to the normal 3D version.
[in] | this | A fourier_class instance. |
[in] | xmn | Fourier space quantity. |
[in,out] | xuv | Real space quantity. |
[in] | dflag | Derivative and sum control flags. |
[in] | parity | Fourier parity flag. |
subroutine fourier::fourier_toijsp_3d | ( | class (fourier_class), intent(inout) | this, |
real (dp), dimension(:,:,:), intent(in) | xmn, | ||
real (dp), dimension(:,:,:), intent(inout) | xuv, | ||
integer, intent(in) | dflag, | ||
integer, intent(in) | parity | ||
) |
Convert a quantity from fourier to real space in parallel.
This subroutine moves a quantity to real space by summing over its Fourier harmonics. If the f_du flag is set take the poloidal derivative. If the f_dv flag is set take the toroidal derivative. If the f_sum flag is set add the real quanity to the previous value.
[in] | this | A fourier_class instance. |
[in] | xmn | Fourier space quantity. |
[in,out] | xuv | Real space quantity. |
[in] | dflag | Derivative and sum control flags. |
[in] | parity | Fourier parity flag. |
pure subroutine fourier::fourier_tomnsp_2d | ( | class (fourier_class), intent(inout) | this, |
real (dp), dimension(:,:), intent(in) | xuv, | ||
real (dp), dimension(:,:), intent(out) | xmn, | ||
integer, intent(in) | parity | ||
) |
Fourier transform a 2D quantity to fourier space.
Works by reshaping to a 3D array then passing to the normal 3D version. Have the 3D function call the 2D function for each slice.
[in,out] | this | A fourier_class instance. |
[in] | xuv | Fourier space quantity. |
[out] | xmn | Real space quantity. |
[in] | parity | Fourier parity flag. |
pure subroutine fourier::fourier_tomnsp_2d_pest | ( | class (fourier_class), intent(inout) | this, |
real (dp), dimension(:,:), intent(in) | xuv, | ||
real (dp), dimension(:,:), intent(out) | xmn, | ||
real (dp), dimension(:,:), intent(in) | lambda, | ||
dup | |||
) |
Fourier transform a 2D quantity to fourier space.
Works by reshaping to a 3D array then passing to the normal 3D version. Have the 3D function call the 2D function for each slice.
[in,out] | this | A fourier_class instance. |
[in] | xuv | Fourier space quantity. |
[out] | xmn | Real space quantity. |
[in] | lambda | Stellarator symmetric lambda. |
[in] | dupdu | Stellarator asymmetric lambda. |
[in] | parity | Fourier parity flag. |
[in] | asym | Add stellarator asymmetric terms. |
pure subroutine fourier::fourier_tomnsp_2d_u | ( | class (fourier_class), intent(inout) | this, |
real (dp), dimension(:,:), intent(in) | xuv | ||
) |
Sum over the poloidal part.
Pest transforms use the same sum over v but different sums over u. To encourage code reuse break the u and v sums into separate methods. This version uses the regular poloidal sum.
[in,out] | this | A fourier_class instance. |
[in] | xuv | Fourier space quantity. |
pure subroutine fourier::fourier_tomnsp_2d_u_pest | ( | class (fourier_class), intent(inout) | this, |
real (dp), dimension(:,:), intent(in) | xuv, | ||
real (dp), dimension(:,:), intent(in) | lambda, | ||
real (dp), dimension(:,:), intent(in) | dupdu | ||
) |
Sum over the poloidal part.
Pest transforms use the same sum over v but different sums over u. To encourage code reuse break the u and v sums into separate methods. This version uses the lambda poloidal sum.
[in,out] | this | A fourier_class instance. |
[in] | xuv | Fourier space quantity. |
[in] | lmns | Stellarator symmetric lambda. |
[in] | lmnc | Stellarator asymmetric lambda. |
[in] | asym | Add stellarator asymmetric terms. |
pure subroutine fourier::fourier_tomnsp_2d_v | ( | class (fourier_class), intent(inout) | this, |
real (dp), dimension(:,:), intent(out) | xmn, | ||
integer, intent(in) | parity | ||
) |
Sum over toroidal angle.
Pest transforms use the same sum over v but different sums over u. To encourage code reuse break the u and v sums into separate methods. This impliments the common toroidal sum.
[in] | this | A fourier_class instance. |
[in] | xuv | Fourier space quantity. |
[out] | xmn | Real space quantity. |
[in] | parity | Fourier parity flag. |
subroutine fourier::fourier_tomnsp_3d | ( | class (fourier_class), intent(inout) | this, |
real (dp), dimension(:,:,:), intent(in) | xuv, | ||
real (dp), dimension(:,:,:), intent(out) | xmn, | ||
integer, intent(in) | parity | ||
) |
Convert a quantity from real to fourier space in parallel.
This subroutine moves a 3D quantity to fourier space by summing over its real represenetation for each surface.
[in,out] | this | A fourier_class instance. |
[in] | xuv | Real space quantity. |
[out] | xmn | Fourier space quantity. |
[in] | parity | Fourier parity flag. |
subroutine fourier::fourier_tomnsp_3d_pest | ( | class (fourier_class), intent(inout) | this, |
real (dp), dimension(:,:,:), intent(in) | xuv, | ||
real (dp), dimension(:,:,:), intent(out) | xmn, | ||
real (dp), dimension(:,:,:), intent(in) | lmns, | ||
real (dp), dimension(:,:,:), intent(in) | lmnc | ||
) |
Convert a quantity from real to fourier space in pest coordinates.
This subroutine moves a 3D quantity to fourier space by summing over its real represenetation for each surface.
[in,out] | this | A fourier_class instance. |
[in] | xuv | Real space quantity. |
[out] | xmn | Fourier space quantity. |
[in] | lmns | Stellarator symmetric lambda. |
[in] | lmnc | Stellarator asymmetric lambda. |
[in] | parity | Fourier parity flag. |
[in] | asym | Add stellarator asymmetric terms. |
logical function fourier::test_fourier |
Test fourier routines.
This tests the routines by fourier transforming form flux to real space then back again.