Stellarator-Tools
|
This file contains utilities for converting the siesta grids. More...
Data Types | |
interface | to_full_mesh |
Interface to convert between half and full mesh using either to_full_mesh2 or to_full_mesh3. More... | |
interface | to_half_mesh |
Interface to convert between full and half mesh using either to_half_mesh or to_half_mesh_p. More... | |
interface | gradienthalf |
Interface to take the gradianet from full to half mesh using either GradientHalf or GradientHalf_p. More... | |
interface | curl_htof |
Interface to take the curl on a half mesh quantity and return a full mesh using either curl_htof or curl_htof_targ. More... | |
interface | set_bndy_fouier_m0 |
Interface to set the fouier conditions on a quantity for either scalar set_bndy_fouier_m0 or vector set_bndy_fouier_m0_vec quantities. More... | |
Functions/Subroutines | |
subroutine | gradienthalf (gradienth, vecf) |
Calculate the gradient to the half mesh from a full mesh quantity. More... | |
subroutine | gradienthalf_p (gradienth, vecf) |
Calculate the gradient to the half mesh from a full mesh quantity. More... | |
subroutine | gradientfull (gradientf, vech) |
Calculate the gradient to the full mesh from a half mesh quantity. More... | |
subroutine | to_half_mesh (vecf, vech) |
Migrates a full mesh quantity to the half mesh. More... | |
subroutine | to_half_mesh_p (vecf, vech) |
Migrates a full mesh quantity to the half mesh. More... | |
subroutine | to_full_mesh3 (vech, vecf) |
Migrate a three dimensional quantity form the half mesh to the full mesh. More... | |
subroutine | to_full_mesh2 (vech, vecf) |
Migrate a two dimensional quantity form the half mesh to the full mesh. More... | |
subroutine | curl_ftoh (asubsmnf, asubumnf, asubvmnf, |
Compute curl of the full grid quantity a on the half grid. More... | |
subroutine | curl_htof (bsubsmnh, bsubumnh, bsubvmnh, |
Compute curl of the half grid quantity a on the full grid. More... | |
subroutine | curl_htof_targ (bsubsmnh, bsubumnh, bsubvmnh, |
Convert allocatable to pointer for use in curl_htof. More... | |
pure subroutine | set_bndy_half_to_full (amnh, amnf, nsmin, parity, f |
Set fouier boundary conditions for full grid quantity converted from half grid. More... | |
pure subroutine | set_bndy_half_to_full_ds (amnh, amnf_ds, nsmin, par |
Set fouier boundary conditions for full grid radial derivative quantity converted from half grid. More... | |
pure subroutine | set_bndy_full_origin (amnsf, amnuf, amnvf, flags) |
Apply origin vector boundary conditions. More... | |
pure subroutine | set_bndy_fouier_m0 (amn, parity) |
Set vector fourier conditions. More... | |
pure subroutine | set_bndy_fouier_m0_vec (amns, amnu, amnv, parity) |
Set vector fourier conditions. More... | |
subroutine | div_h (jbsupsmnh, jbsupumnh, jbsupvmnh, |
Compute the divergence of a half grid quantity. More... | |
logical function | test_utilities () |
Test utility routines. More... | |
logical function | test_div (jbsupsmnh, jbsupumnh, jbsupvmnh, parity, nsmin, |
Test divergence of a half grid quantity. More... | |
This file contains utilities for converting the siesta grids.
subroutine utilities::curl_ftoh | ( | asubsmnf, | |
asubumnf, | |||
asubvmnf | |||
) |
Compute curl of the full grid quantity a on the half grid.
The contravariant components of jac*Curl A are equal to
sqrt(g)*B^k = dA_j/du^i - dA_i/du^j (j)
for cyclic permutations of i,j,k. This routine does not remove the jacobian factor. The arrays must be passed in as ALLOCATABLE or POINTER to preserve the array bounds.
[in] | asubsmnf | Covariant vector in the s direction full grid. |
[in] | asubsmnf | Covariant vector in the u direction full grid. |
[in] | asubsmnf | Covariant vector in the v direction full grid. |
[in,out] | jbsubsmnh | Contravariant vector in the s direction with jacobian factor half grid. |
[in,out] | jbsubsmnh | Contravariant vector in the u direction with jacobian factor half grid. |
[in,out] | jbsubsmnh | Contravariant vector in the v direction with jacobian factor half grid. |
[in] | parity | Parity flag. |
[in] | nsmin | Minimum radial index. |
[in] | nsmax | Maximum radial index. |
subroutine utilities::curl_htof | ( | real (dp), dimension(:,:,:), intent(in), allocatable | bsubsmnh, |
real (dp), dimension(:,:,:), intent(in), allocatable | bsubumnh, | ||
real (dp), dimension(:,:,:), intent(in), allocatable | bsubvmnh | ||
) |
Compute curl of the half grid quantity a on the full grid.
The contravariant components of jac*Curl A are equal to
sqrt(g)*K^k = dB_j/du^i - dB_i/du^j (j)
for cyclic permutations of i,j,k. This routine does not remove the jacobian factor. The arrays must be passed in as ALLOCATABLE or POINTER to preserve the array bounds.
[in] | bsubsmnh | Covariant vector in the s direction half grid. |
[in] | bsubsmnh | Covariant vector in the u direction half grid. |
[in] | bsubsmnh | Covariant vector in the v direction half grid. |
[in,out] | jKsubsmnf | Contravariant vector in the s direction with jacobian factor full grid. |
[in,out] | jKsubsmnf | Contravariant vector in the u direction with jacobian factor full grid. |
[in,out] | jKsubsmnf | Contravariant vector in the v direction with jacobian factor full grid. |
[in] | parity | Parity flag. |
[in] | nsmin | Minimum radial index. |
[in] | nsmax | Maximum radial index. |
[in] | nsend | Ending row index. |
[in,out] | curtor | Current enclosed at the boundary. |
subroutine utilities::curl_htof_targ | ( | real (dp), dimension(:,:,:), intent(in), allocatable | bsubsmnh, |
real (dp), dimension(:,:,:), intent(in), allocatable | bsubumnh, | ||
real (dp), dimension(:,:,:), intent(in), allocatable | bsubvmnh | ||
) |
Convert allocatable to pointer for use in curl_htof.
[in] | Asubsmnh | Covariant vector in the s direction half grid. |
[in] | Asubsmnh | Covariant vector in the u direction half grid. |
[in] | Asubsmnh | Covariant vector in the v direction half grid. |
[in,out] | jBsubsmnf | Contravariant vector in the s direction with jacobian factor full grid. |
[in,out] | jBsubsmnf | Contravariant vector in the u direction with jacobian factor full grid. |
[in,out] | jBsubsmnf | Contravariant vector in the v direction with jacobian factor full grid. |
[in] | parity | Parity flag. |
[in] | nsmin | Minimum radial index. |
[in] | nsmax | Maximum radial index. |
[in] | nsend | Ending row index. |
[in,out] | curtor | Current enclosed at the boundary. |
subroutine utilities::div_h | ( | jbsupsmnh, | |
jbsupumnh, | |||
jbsupvmnh | |||
) |
Compute the divergence of a half grid quantity.
This operator is used for unit testing of the curl operator. Divergence is defined as
DIV(B) = 1/sqrt(g)d/dx (JB^x} for x = s,u,v (1)
Note for testing that divergence remains zero, add a 1/sqrt(g) term is not necessary to retain.
[in] | jasupsmnh | Contravariant vector in the s direction half grid. |
[in] | jasupsmnh | Contravariant vector in the u direction half grid. |
[in] | jasupsmnh | Contravariant vector in the v direction half grid. |
[in,out] | divmnf | Diverence on the full grid. |
[in] | parity | Parity flag. |
[in] | nsmin | Minimum radial index. |
[in] | nsmax | Maximum radial index. |
subroutine utilities::gradientfull | ( | gradientf, | |
real (dp), dimension(:,:,:), intent(in), allocatable | vech | ||
) |
Calculate the gradient to the full mesh from a half mesh quantity.
The arrays must be passed in as ALLOCATABLE to preserve the array bounds. There are three scenarios we need to anticipate for the radial dimension. The easiest is when the upper bound of gradientf matches vech. Otherwise vech can be the full ns range of one more than the gradientf. To handle this an extra is calculated which can be a maximum of one.
[in,out] | gradientf | Gradient on the full grid. |
[in] | vech | Half grid quantity. |
subroutine utilities::gradienthalf | ( | gradienth, | |
real (dp), dimension(:,:,:), intent(in), allocatable | vecf | ||
) |
Calculate the gradient to the half mesh from a full mesh quantity.
The arrays must be passed in as ALLOCATABLE to preserve the array bounds.
[in,out] | gradienth | Gradient on the half grid. |
[in] | vecf | Full grid quantity. |
subroutine utilities::gradienthalf_p | ( | gradienth, | |
real (dp), dimension(:,:,:), pointer | vecf | ||
) |
Calculate the gradient to the half mesh from a full mesh quantity.
The arrays must be passed in as ALLOCATABLE to preserve the array bounds. Full vector is passed in as a pointer.
[in,out] | gradienth | Gradient on the half grid. |
[in] | vecf | Full grid quantity. |
pure subroutine utilities::set_bndy_fouier_m0 | ( | real (dp), dimension(:,:,:), intent(inout) | amn, |
integer, intent(in) | parity | ||
) |
Set vector fourier conditions.
For fouier modes for m=0 and for the negative n modes. The n=0 modes are zero for quantities with sin parity.
[in,out] | amn | Fourier quantity. |
[in] | parity | Fouier parity flag. |
pure subroutine utilities::set_bndy_fouier_m0_vec | ( | real (dp), dimension(:,:,:), intent(inout) | amns, |
real (dp), dimension(:,:,:), intent(inout) | amnu, | ||
real (dp), dimension(:,:,:), intent(inout) | amnv, | ||
integer, intent(in) | parity | ||
) |
Set vector fourier conditions.
For fouier modes for m=0 and for the negative n modes. The n=0 modes are zero for quantities with sin parity.
[in,out] | amns | Fourier quantity for s component. |
[in,out] | amnu | Fourier quantity for u component. |
[in,out] | amnv | Fourier quantity for v component. |
[in] | parity | Fouier parity flag. |
pure subroutine utilities::set_bndy_full_origin | ( | real (dp), dimension(:,:,:), intent(inout) | amnsf, |
real (dp), dimension(:,:,:), intent(inout) | amnuf, | ||
real (dp), dimension(:,:,:), intent(inout) | amnvf, | ||
integer, intent(in) | flags | ||
) |
Apply origin vector boundary conditions.
At the center of the grid, a vector quantity should have only m=1 modes in the s direction, no modes in the u direction and only m=0 modes in the v direction. See siesta_init::GetFields.
[in,out] | amnsf | Full grid fourier quantity for s component. |
[in,out] | amnuf | Full grid fourier quantity for u component. |
[in,out] | amnvf | Full grid fourier quantity for v component. |
[in] | flags | Control flags. |
pure subroutine utilities::set_bndy_half_to_full | ( | real (dp), dimension(:,:,:), intent(in) | amnh, |
real (dp), dimension(:,:,:), intent(inout) | amnf, | ||
integer, intent(in) | nsmin, | ||
integer, intent(in) | parity, | ||
f | |||
) |
Set fouier boundary conditions for full grid quantity converted from half grid.
At the center of the grid, the quantity should not be a function of u so all m > 0 modes should be zero. For the m = 0 terms, use the value from the half grid.
[in] | amnh | Half grid fourier quantity. |
[in,out] | amnf | Full grid fourier quantity. |
[in] | nsmin | Minimum radial index. |
[in] | parity | Parity flag. |
[in] | flags | Control flags. |
pure subroutine utilities::set_bndy_half_to_full_ds | ( | real (dp), dimension(:,:,:), intent(in) | amnh, |
real (dp), dimension(:,:,:), intent(inout) | amnf_ds, | ||
integer, intent(in) | nsmin, | ||
par | |||
) |
Set fouier boundary conditions for full grid radial derivative quantity converted from half grid.
At the center of the grid the the m=1 quanity flips size across the s=0 point. The results in a doubling of the m=1 component for the first half grid.
[in] | amnh | Half grid fourier quantity. |
[in,out] | amnf_ds | Full grid radial derivative fourier quantity. |
[in] | nsmin | Minimum radial index. |
[in] | parity | Parity flag. |
[in] | flags | Control flags. |
logical function utilities::test_div | ( | real (dp), dimension(:,:,:), intent(in), allocatable | jbsupsmnh, |
real (dp), dimension(:,:,:), intent(in), allocatable | jbsupumnh, | ||
real (dp), dimension(:,:,:), intent(in), allocatable | jbsupvmnh, | ||
integer, intent(in) | parity, | ||
integer, intent(in) | nsmin | ||
) |
Test divergence of a half grid quantity.
[in] | jbsupsmnh | Contravariant vector in the s direction half grid. |
[in] | jbsupumnh | Contravariant vector in the u direction half grid. |
[in] | jbsupvmnh | Contravariant vector in the v direction half grid. |
[in] | parity | Parity flag. |
[in] | nsmin | Minimum radial index. |
[in] | nsmax | Maximum radial index. |
logical function utilities::test_utilities |
Test utility routines.
Test the various operations of in the utilities module. Current tests check:
subroutine utilities::to_full_mesh2 | ( | real (dp), dimension(:,:), intent(in), allocatable | vech, |
real (dp), dimension(:,:), intent(inout), allocatable | vecf | ||
) |
Migrate a two dimensional quantity form the half mesh to the full mesh.
First and last point are extrapolated linearly. The arrays must be passed in as ALLOCATABLE to preserve the array bounds.
[in] | vech | Half mesh qantity. |
[in,out] | vecf | Full mesh quantity. |
subroutine utilities::to_full_mesh3 | ( | real (dp), dimension(:,:,:), intent(in), allocatable | vech, |
real (dp), dimension(:,:,:), intent(inout), allocatable | vecf | ||
) |
Migrate a three dimensional quantity form the half mesh to the full mesh.
First and last point are extrapolated linearly. The arrays must be passed in as ALLOCATABLE to preserve the array bounds.
[in] | vech | Half mesh qantity. |
[in,out] | vecf | Full mesh quantity. |
subroutine utilities::to_half_mesh | ( | real (dp), dimension(:,:,:), intent(in), allocatable | vecf, |
real (dp), dimension(:,:,:), intent(inout), allocatable | vech | ||
) |
Migrates a full mesh quantity to the half mesh.
The arrays must be passed in as ALLOCATABLE to preserve the array bounds.
[in] | vecf | Full grid quantity. |
[in,out] | vech | Half grid quantity. |
subroutine utilities::to_half_mesh_p | ( | real (dp), dimension(:,:,:), pointer | vecf, |
real (dp), dimension(:,:,:), intent(inout), allocatable | vech | ||
) |
Migrates a full mesh quantity to the half mesh.
The arrays must be passed in as ALLOCATABLE to preserve the array bounds. Full vector grid is passed in as pointer.
[in] | vecf | Full grid quantity. |
[in,out] | vech | Half grid quantity. |