VMEC 8.52
3D Equilibrium solver with nested flux surfaces.
Loading...
Searching...
No Matches
magnetic_fluxes.f90
Go to the documentation of this file.
1
3
7FUNCTION 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)
19 DO i = ubound(tf,1), lbound(tf,1), -1
20 torflux_deriv = x*torflux_deriv + i*tf(i)
21 END DO
22
23END FUNCTION torflux_deriv
24
30FUNCTION 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)
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
48END FUNCTION polflux_deriv
49
53FUNCTION 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
68 END DO
69 torflux = torflux-0.5_dp*(torflux_deriv(0._dp)+torflux_deriv(x))
71
72END FUNCTION torflux
73
77FUNCTION 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
92 END DO
93 polflux = polflux-0.5_dp*(polflux_deriv(0._dp)+polflux_deriv(x))
95
96END FUNCTION polflux
real(rprec) function torflux(x)
Compute the enclosed toroidal magnetic flux.
real(rprec) function torflux_deriv(x)
Compute the radial derivative of the enclosed toroidal magnetic flux.
real(rprec) function polflux(x)
Compute the enclosed poloidal magnetic flux.
real(rprec) function polflux_deriv(x)
Compute the radial derivative of the enclosed poloidal magnetic flux.
integer, parameter rprec
real(rprec), dimension(1:20) aphi
real(rprec) function piota(x)