VMEC
8.52
3D Equilibrium solver with nested flux surfaces.
Toggle main menu visibility
Loading...
Searching...
No Matches
magnetic_fluxes.f90
Go to the documentation of this file.
1
!> \file
2
!> \brief Compute toroidal and poloidal magnetic flux profiles.
3
4
!> \brief Compute the radial derivative of the enclosed toroidal magnetic flux.
5
!>
6
!> @param x evaluation location; radial flux variable (=TOROIDAL FLUX ONLY IF APHI=1)
7
FUNCTION
torflux_deriv
(x)
8
USE
stel_kinds
9
USE
vmec_input
,
ONLY
: tf =>
aphi
10
11
REAL
(
rprec
),
INTENT(IN)
:: x
12
REAL
(
rprec
) ::
torflux_deriv
13
INTEGER
:: i
14
15
! This evaluates the aphi polynomial (possibly modified by the user in the input file).
16
17
! TOKAMAK/STELLARATOR (default is tf(1) = 1)
18
torflux_deriv
= 0
19
DO
i = ubound(tf,1), lbound(tf,1), -1
20
torflux_deriv
= x*
torflux_deriv
+ i*tf(i)
21
END DO
22
23
END FUNCTION
torflux_deriv
24
25
!> \brief Compute the radial derivative of the enclosed poloidal magnetic flux.
26
!>
27
!> polflux_deriv == d(chi)/dx = iota(TF(x)) * torflux_deriv(x)
28
!>
29
!> @param x evaluation location; radial flux variable (=TOROIDAL FLUX ONLY IF APHI=1)
30
FUNCTION
polflux_deriv
(x)
31
USE
stel_kinds
32
33
REAL
(
rprec
),
INTENT(IN)
:: x
34
REAL
(
rprec
) :: tf
35
REAL
(
rprec
) ::
polflux_deriv
36
REAL
(
rprec
),
EXTERNAL
::
torflux
,
torflux_deriv
,
piota
37
38
! TOKAMAK/STELLARATOR: dchi/ds = iota * dphi/ds
39
! piota is assumed to be a function of the TF(x) on input
40
tf =
torflux
(x)
41
tf = min(tf, 1.0_dp)
42
polflux_deriv
=
piota
(tf)*
torflux_deriv
(x)
43
44
! TODO: how does above code work if the iota profile is not specified,
45
! i.e., in constrained-toroidal-current mode?
46
! or is it simply not used...?
47
48
END FUNCTION
polflux_deriv
49
50
!> \brief Compute the enclosed toroidal magnetic flux.
51
!>
52
!> @param x evaluation location; radial flux variable (=TOROIDAL FLUX ONLY IF APHI=1)
53
FUNCTION
torflux
(x)
54
USE
stel_kinds
55
56
REAL
(
rprec
),
INTENT(IN)
:: x
57
REAL
(
rprec
) ::
torflux
, h, xi
58
REAL
(
rprec
),
EXTERNAL
::
torflux_deriv
59
INTEGER
:: i
60
61
! some ad-hoc trapezoidal integration radially outward to given x
62
! with a fixed number (100) of quadrature nodes?
63
h = 1.e-2_dp*x
64
torflux
= 0.0_dp
65
DO
i=1,101
66
xi = (i-1)*h
67
torflux
=
torflux
+
torflux_deriv
(xi)
68
END DO
69
torflux
=
torflux
-0.5_dp*(
torflux_deriv
(0._dp)+
torflux_deriv
(x))
70
torflux
= h*
torflux
71
72
END FUNCTION
torflux
73
74
!> \brief Compute the enclosed poloidal magnetic flux.
75
!>
76
!> @param x evaluation location; radial flux variable (=TOROIDAL FLUX ONLY IF APHI=1)
77
FUNCTION
polflux
(x)
78
USE
stel_kinds
79
80
REAL
(
rprec
),
INTENT(IN)
:: x
81
REAL
(
rprec
) ::
polflux
, h, xi
82
REAL
(
rprec
),
EXTERNAL
::
polflux_deriv
83
INTEGER
:: i
84
85
! some ad-hoc trapezoidal integration radially outward to given x
86
! with a fixed number (100) of quadrature nodes?
87
h = 1.e-2_dp*x
88
polflux
= 0.0_dp
89
DO
i=1,101
90
xi = (i-1)*h
91
polflux
=
polflux
+
polflux_deriv
(xi)
92
END DO
93
polflux
=
polflux
-0.5_dp*(
polflux_deriv
(0._dp)+
polflux_deriv
(x))
94
polflux
= h*
polflux
95
96
END FUNCTION
polflux
torflux
real(rprec) function torflux(x)
Compute the enclosed toroidal magnetic flux.
Definition
magnetic_fluxes.f90:54
torflux_deriv
real(rprec) function torflux_deriv(x)
Compute the radial derivative of the enclosed toroidal magnetic flux.
Definition
magnetic_fluxes.f90:8
polflux
real(rprec) function polflux(x)
Compute the enclosed poloidal magnetic flux.
Definition
magnetic_fluxes.f90:78
polflux_deriv
real(rprec) function polflux_deriv(x)
Compute the radial derivative of the enclosed poloidal magnetic flux.
Definition
magnetic_fluxes.f90:31
stel_kinds
Definition
stel_kinds.f90:2
stel_kinds::rprec
integer, parameter rprec
Definition
stel_kinds.f90:10
vmec_input
Definition
vmec_input.f90:2
vmec_input::aphi
real(rprec), dimension(1:20) aphi
Definition
vmec_input.f90:47
piota
real(rprec) function piota(x)
Definition
profile_functions.f:342
src
magnetic_fluxes.f90
Generated on
for VMEC by
1.17.0