Stellarator-Tools
|
Module for reading in VMEC input and computing metric elements on the SIESTA (sqrt-flux) radial grid. Computes and stores the real-space metric elements, Jacobian based on square root of fluc splined vmec coordinate system. More...
Functions/Subroutines | |
subroutine | init_metric_elements () |
Initialize the metric elements. More... | |
subroutine | set_grid_sizes (mpol_in, ntor_in, nfp_in, tor_modes) |
Set grid sizes. More... | |
subroutine | surfavg (average, q3d, nsmin, nsmax) |
Surface average a quantity. More... | |
subroutine | loadgrid (istat) |
Load the R, Z and lambda arrays from VMEC. More... | |
subroutine | rz_to_ijsp (rmn, zmn, lasym) |
Transform from fourier R Z to real space qauntities. More... | |
subroutine | half_mesh_metrics (r1_i, ru_i, rv_i, z1_i, zu_i, zv_i) |
Compute the metric elements on the half mesh. More... | |
subroutine | full_mesh_metrics |
Gets the full grid metric elements. More... | |
subroutine | check_metrics |
@ brief Test to check that we computed the upper metric elements correctly. More... | |
subroutine | toupper (xsubsij, xsubuij, xsubvij, |
Converts to contravariant component full grid. More... | |
subroutine | tolowerh (xsupsij, xsupuij, xsupvij, |
Converts to covariant component half grid. More... | |
subroutine | tolowerf (xsupsij, xsupuij, xsupvij, |
Converts to covariant component full grid. More... | |
subroutine | cleanup_metric_elements |
Deallocate memory containing metric elements on the half mesh. More... | |
subroutine | dealloc_full_lower_metrics |
Deallocate memory containing metric elements on the full mesh. | |
Variables | |
real(dp), dimension(:,:), allocatable | sqrtg |
Jacobian on half grid. | |
real(dp), dimension(:,:), allocatable | gss |
Lower metric tensor half grid. e_s . e_s. | |
real(dp), dimension(:,:), allocatable | gsu |
Lower metric tensor half grid. e_s . e_u. | |
real(dp), dimension(:,:), allocatable | gsv |
Lower metric tensor half grid. e_s . e_v. | |
real(dp), dimension(:,:), allocatable | guu |
Lower metric tensor half grid. e_u . e_u. | |
real(dp), dimension(:,:), allocatable | guv |
Lower metric tensor half grid. e_u . e_v. | |
real(dp), dimension(:,:), allocatable | gvv |
Lower metric tensor half grid. e_v . e_v. | |
real(dp), dimension(:,:), allocatable | hss |
Upper metric tensor half grid. e^s . e^s. | |
real(dp), dimension(:,:), allocatable | hsu |
Upper metric tensor. e^s . e^u. | |
real(dp), dimension(:,:), allocatable | hsv |
Upper metric tensor. e^s . e^v. | |
real(dp), dimension(:,:), allocatable | huu |
Upper metric tensor. e^u . e^u. | |
real(dp), dimension(:,:), allocatable | huv |
Upper metric tensor. e^u . e^v. | |
real(dp), dimension(:,:), allocatable | hvv |
Upper metric tensor. e^v . e^v. | |
real(dp), dimension(:,:), allocatable | gssf |
Lower metric tensor full grid. e_s . e_s. | |
real(dp), dimension(:,:), allocatable | gsuf |
Lower metric tensor full grid. e_s . e_u. | |
real(dp), dimension(:,:), allocatable | gsvf |
Lower metric tensor full grid. e_s . e_v. | |
real(dp), dimension(:,:), allocatable | guuf |
Lower metric tensor full grid. e_u . e_u. | |
real(dp), dimension(:,:), allocatable | guvf |
Lower metric tensor full grid. e_u . e_v. | |
real(dp), dimension(:,:), allocatable | gvvf |
Lower metric tensor full grid. e_v . e_v. | |
real(dp) | rmax |
Maximum of the grid R inside the last closed flux surface. | |
real(dp) | rmin |
Minimum of the grid R inside the last closed flux surface. | |
real(dp) | zmax |
Maximum of the grid Z inside the last closed flux surface. | |
real(dp) | zmin |
Minimum of the grid Z inside the last closed flux surface. | |
real(dp) | skston |
Start timer. | |
real(dp) | skstoff |
Stop timer. | |
Module for reading in VMEC input and computing metric elements on the SIESTA (sqrt-flux) radial grid. Computes and stores the real-space metric elements, Jacobian based on square root of fluc splined vmec coordinate system.
subroutine metrics::check_metrics |
@ brief Test to check that we computed the upper metric elements correctly.
Check that the metric elements conform to the following relation to machine precission.
hij*gjk = delta_ik (1)
Note the repeated index implys a sum.
subroutine metrics::cleanup_metric_elements |
Deallocate memory containing metric elements on the half mesh.
Also deallocates the grid variables.
subroutine metrics::full_mesh_metrics |
Gets the full grid metric elements.
This subroutine gets the lower metric elements on the full mesh. Preserves positive definiteness of metric tensor.
subroutine metrics::half_mesh_metrics | ( | real(dp), dimension(nuv,ns_i), intent(in) | r1_i, |
real(dp), dimension(nuv,ns_i), intent(in) | ru_i, | ||
real(dp), dimension(nuv,ns_i), intent(in) | rv_i, | ||
real(dp), dimension(nuv,ns_i), intent(in) | z1_i, | ||
real(dp), dimension(nuv,ns_i), intent(in) | zu_i, | ||
real(dp), dimension(nuv,ns_i), intent(in) | zv_i | ||
) |
Compute the metric elements on the half mesh.
[in] | r1_i | R on the full mesh. |
[in] | ru_i | dRdu on the full mesh. |
[in] | rv_i | dRdv on the full mesh. |
[in] | z1_i | Z on the full mesh. |
[in] | zu_i | dZdu on the full mesh. |
[in] | zv_i | dZdv on the full mesh. |
subroutine metrics::init_metric_elements |
Initialize the metric elements.
Loads values on to the SIESTA meshes. This involves splining and interpolating the VMEC quantities from the VMEC radial grid to the SIESTA radial grid.
subroutine metrics::loadgrid | ( | integer, intent(out) | istat | ) |
Load the R, Z and lambda arrays from VMEC.
R, Z and Lambda are recast onto the SIESTA grid.
[out] | istat | Error status. |
subroutine metrics::rz_to_ijsp | ( | real(dp), dimension(:,:,:), intent(in) | rmn, |
real(dp), dimension(:,:,:), intent(in) | zmn, | ||
logical, intent(in) | lasym | ||
) |
Transform from fourier R Z to real space qauntities.
Computes R, Z, dr/du, dr/dv, dz/du and dz/dv from the fourier representation.
[in] | rmn | Radial fourier amplitudes. |
[in] | zmn | Vertical fourier amplitudes. |
[in] | lasym | A symmetric flag. |
subroutine metrics::set_grid_sizes | ( | integer, intent(in) | mpol_in, |
integer, intent(in) | ntor_in, | ||
integer, intent(in) | nfp_in, | ||
integer, dimension(-ntor_in:ntor_in), intent(in) | tor_modes | ||
) |
Set grid sizes.
The real space grid is determined from the number of toroidal and poloidal modes.
[in] | mpol_in | Number of SIESTA poloidal modes. |
[in] | ntor_in | Number of SIESTA toroidal modes. |
[in] | nfp_in | Number of field periods. |
[in] | tor_modes | Toroidal mode numbers. |
subroutine metrics::surfavg | ( | real(dp), dimension(nsmin:nsmax), intent(out) | average, |
real(dp), dimension(nu_i,nv_i,nsmin:nsmax), intent(in) | q3d, | ||
integer, intent(in) | nsmin, | ||
integer, intent(in) | nsmax | ||
) |
Surface average a quantity.
[out] | average | Surface average |
[in] | q3d | 3D quantity is real space. |
[in] | nsmin | Minimum radial index. |
[in] | nsmax | Maximum radial index. |
subroutine metrics::tolowerf | ( | real(dp), dimension(nuv,ns), intent(in) | xsupsij, |
real(dp), dimension(nuv,ns), intent(in) | xsupuij, | ||
real(dp), dimension(nuv,ns), intent(in) | xsupvij | ||
) |
Converts to covariant component full grid.
Computes covariant (lower) from contravariant (upper) magnetic field components on the full mesh.
xsubsij = gssf*xsupsij + gsuf*xsupuij + gsvf*xsupvij xsubuij = gsuf*xsupsij + guuf*xsupuij + guvf*xsupvij xsubvij = gsvf*xsupsij + guvf*xsupuij + gvvf*xsupvij
[in] | xsupsij | Contravariant s component. |
[in] | xsupuij | Contravariant u component. |
[in] | xsupvij | Contravariant v component. |
[out] | xsubsij | Covariant s component. |
[out] | xsubuij | Covariant u component. |
[out] | xsubvij | Covariant v component. |
[in] | nsmin | Min radial index. |
[in] | nsmax | Max radial index. |
subroutine metrics::tolowerh | ( | real(dp), dimension(nuv,nsmin:nsmax), intent(in) | xsupsij, |
real(dp), dimension(nuv,nsmin:nsmax), intent(in) | xsupuij, | ||
real(dp), dimension(nuv,nsmin:nsmax), intent(in) | xsupvij | ||
) |
Converts to covariant component half grid.
Computes covariant (lower) from contravariant (upper) magnetic field components on the half mesh.
xsubsij = gss*xsupsij + gsu*xsupuij + gsv*xsupvij xsubuij = gsu*xsupsij + guu*xsupuij + guv*xsupvij xsubvij = gsv*xsupsij + guv*xsupuij + gvv*xsupvij
[in] | xsupsij | Contravariant s component. |
[in] | xsupuij | Contravariant u component. |
[in] | xsupvij | Contravariant v component. |
[out] | xsubsij | Covariant s component. |
[out] | xsubuij | Covariant u component. |
[out] | xsubvij | Covariant v component. |
[in] | nsmin | Min radial index. |
[in] | nsmax | Max radial index. |
subroutine metrics::toupper | ( | real(dp), dimension(nuv,nsmin:nsmax), intent(in) | xsubsij, |
real(dp), dimension(nuv,nsmin:nsmax), intent(in) | xsubuij, | ||
real(dp), dimension(nuv,nsmin:nsmax), intent(in) | xsubvij | ||
) |
Converts to contravariant component full grid.
Computes contravariant (upper) from covariant (lower) components on the full mesh.
xsupsij = hss*xsubsij + hsu*xsupuij + hsv*xsubvij xsupuij = hsu*xsubsij + huu*xsupuij + huv*xsubvij xsupvij = hsv*xsubsij + huv*xsupuij + hvv*xsubvij
[in] | xsubsij | Covariant s component. |
[in] | xsubuij | Covariant u component. |
[in] | xsubvij | Covariant v component. |
[out] | xsupsij | Contravariant s component. |
[out] | xsupuij | Contravariant u component. |
[out] | xsupvij | Contravariant v component. |
[in] | nsmin | Min radial index. |
[in] | nsmax | Max radial index. |