VMEC 8.52
3D Equilibrium solver with nested flux surfaces.
Loading...
Searching...
No Matches
analyt.f90
Go to the documentation of this file.
1
3
14SUBROUTINE analyt(grpmn, bvec, ivacskip, lasym, m_map, n_map, grpmn_m_map, grpmn_n_map)
15 USE vacmod, vm_grpmn => grpmn
16 use dbgout
18 IMPLICIT NONE
19
20 INTEGER, INTENT(in) :: ivacskip
21 REAL(rprec), INTENT(out) :: grpmn(nuv2*mnpd2)
22 REAL(rprec), INTENT(out) :: bvec(mnpd2)
23 real(rprec), intent(out) :: m_map(mnpd2)
24 real(rprec), intent(out) :: n_map(mnpd2)
25 real(rprec), intent(out) :: grpmn_m_map(nuv2*mnpd2)
26 real(rprec), intent(out) :: grpmn_n_map(nuv2*mnpd2)
27 integer, intent(in) :: lasym
28
29 INTEGER :: l, n, m
30 REAL(rprec) :: fl, fl1, sign1
31
32 ! ALL EQUATIONS REFER TO THE PAPER BY P. MERKEL (PKM)
33 ! IN J. COMPUT. PHYSICS 66, p83 (1986)
34 !
35 ! IN GOING BETWEEN THE COMPLEX NOTATION OF (PKM) AND OUR REAL FORM,
36 ! NOTE THAT THE INTEGRALS (APPENDIX, PKM) Imn AND Kmn ARE BOTH REAL.
37 ! THUS, THE SIN(mu-nv) INTEGRALS OF THE SINGULAR PIECE (ANALYTIC CONTRIBUTION)
38 ! VANISHES.
39 !
40 ! THE REQUIRED SOURCE-TERM INTEGRALS ARE (Eq.2.16-2.17):
41 !
42 ! BVECS(m,n) = Int< SIN(mu' - nv') han(u',v') >
43 ! BVECC(m,n) = Int< COS(mu' - nv') han(u',v') >
44 !
45 ! Where Int<...> means integration over u (theta) and v (zeta) and
46 ! summation over field periods. These can be written in terms of PKM integrals
47 ! Imn(a,b,c), where a(u,v) = guu (g theta-theta), etc.:
48 !
49 ! BVECS(m,n) = ALP * Int<SIN(mu' - nv') * F * Im,-n(a,b,c)>
50 ! BVECC(m,n) = ALP * Int<COS(mu' - nv') * F * Im,-n(a,b,c)>
51 !
52 ! Here, F = - BNORM(u',v') is defined in Eq.(2.13), and ALP = (2*pi/nfp).
53 !
54 ! Similarly, the analytic part of the matrix A(m,n;m',n') can be written:
55 !
56 ! A(m,n;m',n') = (2*pi/nfp) * Int<SIN(mu' - nv')*SIN(m'u' - n'v')
57 ! [Km,-n](a',b',c';A',B',C')>
58 !
59 ! On EXIT, GRPMN(ip,m,n) = ALP * SIN(ip,m,n) * K[m,-n](ip)
60 !
61 ! COMPUTE ALL QUANTITIES INDEPENDENT OF THE MODE INDICES L,M,N
62 ! NOTE: 2b = guv_b HAS FACTOR OF 2 BUILT IN (see SUBROUTINE SURFACE)
63 !
64 ! ADP(M): a +(-)2b + c
65 ! CMA: c - a
66 ! DELTA: 4*(ac - b**2)
67 ! AZP(M): A +(-)2*B + C
68 ! CMA1: C - A
69 ! R1P(M): Coefficient of l*Tl+(-) in eq (A17)
70 ! R0P(M): Coefficient of l*T(l-1)+(-) in eq (A17)
71 ! RA1P(M):Coefficient of Tl+(-) in eq (A17)
72
73 adp = guu_b + guv_b + gvv_b
74 adm = guu_b - guv_b + gvv_b
75 cma = gvv_b - guu_b
76 sqrtc = two*sqrt(gvv_b)
77 sqrta = two*sqrt(guu_b)
78 sqad1u = sqrt(adp)
79 sqad2u = sqrt(adm)
80
81 ! INITIALIZE VECTORS
82 bvec = 0
83 IF (ivacskip .eq. 0) THEN
84 grpmn = 0
85
86 delt1u = adp*adm - cma*cma
87 azp1u = auu + auv + avv
88 azm1u = auu - auv + avv
89 cma11u = avv - auu
94 ra1p = azp1u/adp
95 ra1m = azm1u/adm
96 ENDIF
97
98 ! INITIALIZE T0+ and T0-
99 !
100 ! TLP(M): TL+(-)
101 ! TLP(M)1:T(L-1)+(-)
102 ! TLP(M)2:T(L-2)+(-)
103 tlp1 = 0
104 tlm1 = 0
105 tlp = one/sqad1u*log((sqad1u*sqrtc + adp + cma)/(sqad1u*sqrta - adp + cma))
106 tlm = one/sqad2u*log((sqad2u*sqrtc + adm + cma)/(sqad2u*sqrta - adm + cma))
107 tlpm = tlp + tlm
108
109 ! BEGIN L-SUM IN EQ (A14) TO COMPUTE Imn (and Kmn) INTEGRALS
110 ! NOTE THAT IN THE LOOP OVER L BELOW: L == |m - n| + 2L_A14
111 ! THUS, L BELOW IS THE INDEX OF THE T+- (S+-)
112 sign1 = 1
113 fl1 = 0
114
115 lloop: DO l = 0, mf + nf
116 fl = fl1
117
118 ! here, tlp/m are available for the current value of l
119 ! --> save into matrix for debugging
120 all_tlp(l,:) = tlp
121 all_tlm(l,:) = tlm
122
123 ! COMPUTE SL+ and SL- , Eq (A17)
124 ! SLP(M): SL+(-)
125 IF (ivacskip .eq. 0) THEN
126 slp = (r1p*fl + ra1p)*tlp + r0p*fl*tlp1 - (r1p + r0p)/sqrtc + sign1*(r0p - r1p)/sqrta
127 slm = (r1m*fl + ra1m)*tlm + r0m*fl*tlm1 - (r1m + r0m)/sqrtc + sign1*(r0m - r1m)/sqrta
128 slpm = slp + slm
129
130 ! here, slp/m are available for the current value of l
131 ! --> save into matrix for debugging
132 all_slp(l,:) = slp
133 all_slm(l,:) = slm
134 ENDIF
135
136 ! BEGIN MODE NUMBER (m,n) LOOP
137 DO n = 0, nf
138 DO m = 0, mf
139 ! always call analysum, analysum2 to get bvec fill pattern (m_map, n_map)
140 ! IF (cmns(l,m,n) .eq. zero) CYCLE
141
142 IF (n.eq.0 .or. m.eq.0) THEN
143 ! 1. n = 0 and m >= 0 OR n > 0 and m = 0
144 CALL analysum (grpmn, bvec, slpm, tlpm, m, n, l, ivacskip, lasym, m_map, n_map, &
145 grpmn_m_map, grpmn_n_map)
146 ELSE
147 ! 2. n>=1 and m>=1
148 CALL analysum2 (grpmn, bvec, m, n, l, ivacskip, lasym, m_map, n_map, &
149 grpmn_m_map, grpmn_n_map)
150 ENDIF
151 END DO
152 END DO
153
154 ! UPDATE "TL's" (FOR L -> L+1) USING EQ (A15)
155 tlp2 = tlp1
156 tlm2 = tlm1
157 tlp1 = tlp
158 tlm1 = tlm
159
160 ! next l
161 fl1 = fl1 + 1
162
163 ! (-1)**l (next l now)
164 sign1 = -sign1
165
166 tlp = ((sqrtc + sign1*sqrta) - (two*fl1 - one)*cma*tlp1 - fl*adm*tlp2)/(adp*fl1)
167 tlm = ((sqrtc + sign1*sqrta) - (two*fl1 - one)*cma*tlm1 - fl*adp*tlm2)/(adm*fl1)
168 tlpm = tlp + tlm
169 END DO lloop
170
171 if (open_dbg_context("vac1n_analyt", num_eqsolve_retries)) then
172
173 call add_real_3d("all_tlp", mf+nf+1, nv, nu3, all_tlp)
174 call add_real_3d("all_tlm", mf+nf+1, nv, nu3, all_tlm)
175 call add_real_2d("bvec", mf1, nf1, bvec) ! (mf+1)x(2*nf+1)x(ndim: 1 or 2)
176
177 if (ivacskip .eq. 0) then
178 call add_real_3d("all_slp", mf+nf+1, nv, nu3, all_slp)
179 call add_real_3d("all_slm", mf+nf+1, nv, nu3, all_slm)
180 call add_real_4d("grpmn", mf1, nf1, nv, nu3, grpmn) ! missing dim: (ndim: 1 or 2)
181 else
182 call add_null("all_slp")
183 call add_null("all_slm")
184 call add_null("grpmn")
185 end if
186
187 call close_dbg_out()
188 end if
189
190END SUBROUTINE analyt
subroutine analysum2(grpmn, bvec, m, n, l, ivacskip, lasym, m_map, n_map, grpmn_m_map, grpmn_n_map)
Compute the (m>0 and n>0) part of the DFT of the analytical Fourier transforms of the equivalently-si...
Definition analysum2.f90:19
subroutine analysum(grpmn, bvec, sl, tl, m, n, l, ivacskip, lasym, m_map, n_map, grpmn_m_map, grpmn_n_map)
Compute the (m=0 or n=0) part of the DFT of the analytical Fourier transforms of the equivalently-sin...
Definition analysum.f90:21
subroutine analyt(grpmn, bvec, ivacskip, lasym, m_map, n_map, grpmn_m_map, grpmn_n_map)
Compute the analytical-and-numerical 4D Fourier integrals over the equivalently-singular functions.
Definition analyt.f90:15
logical function open_dbg_context(context_name, repetition, id)
check if any output is desired for the current iteration check if the given context should be openend...
Definition dbgout.f90:17
real(rprec), dimension(:), allocatable tlm2
Definition vacmod.f90:120
real(rprec), dimension(:,:), allocatable all_slp
Definition vacmod.f90:141
real(rprec), dimension(:,:), allocatable all_tlp
Definition vacmod.f90:139
real(rprec), dimension(:), allocatable auu
Definition vacmod.f90:56
real(rprec), dimension(:), allocatable cma
Definition vacmod.f90:125
real(rprec), dimension(:), allocatable r0m
Definition vacmod.f90:113
real(rprec), dimension(:), allocatable sqad1u
Definition vacmod.f90:136
real(rprec), dimension(:), allocatable tlp
Definition vacmod.f90:119
real(rprec), dimension(:), allocatable r1p
Definition vacmod.f90:112
real(rprec), dimension(:), allocatable azp1u
Definition vacmod.f90:133
real(rprec), dimension(:), allocatable tlp1
Definition vacmod.f90:118
real(rprec), dimension(:), allocatable grpmn
Definition vacmod.f90:102
real(rprec), dimension(:), allocatable ra1m
Definition vacmod.f90:127
real(rprec), dimension(:), allocatable slpm
Definition vacmod.f90:131
real(rprec), dimension(:), allocatable sqad2u
Definition vacmod.f90:137
real(rprec), dimension(:), allocatable adm
Definition vacmod.f90:124
real(rprec), dimension(:,:), allocatable all_tlm
Definition vacmod.f90:140
real(rprec), dimension(:), allocatable sqrtc
Definition vacmod.f90:115
real(rprec), dimension(:), allocatable tlm1
Definition vacmod.f90:121
real(rprec), dimension(:), allocatable r1m
Definition vacmod.f90:114
real(rprec), dimension(:), allocatable cma11u
Definition vacmod.f90:135
real(rprec), dimension(:), allocatable slp
Definition vacmod.f90:129
real(rprec), dimension(:), allocatable sqrta
Definition vacmod.f90:116
real(rprec), dimension(:), allocatable azm1u
Definition vacmod.f90:134
real(rprec), dimension(:), allocatable tlp2
Definition vacmod.f90:117
real(rprec), dimension(:), allocatable guu_b
Definition vacmod.f90:66
real(rprec), dimension(:,:), allocatable all_slm
Definition vacmod.f90:142
real(rprec), parameter two
Definition vacmod.f90:14
real(rprec), dimension(:), allocatable adp
Definition vacmod.f90:123
real(rprec), dimension(:), allocatable tlm
Definition vacmod.f90:122
real(rprec), dimension(:), allocatable auv
Definition vacmod.f90:57
real(rprec), dimension(:), allocatable avv
Definition vacmod.f90:58
real(rprec), dimension(:), allocatable gvv_b
Definition vacmod.f90:68
real(rprec), dimension(:), allocatable delt1u
Definition vacmod.f90:132
real(rprec), dimension(:), allocatable guv_b
Definition vacmod.f90:67
real(rprec), dimension(:), allocatable r0p
Definition vacmod.f90:111
real(rprec), dimension(:), allocatable tlpm
Definition vacmod.f90:130
real(rprec), dimension(:), allocatable ra1p
Definition vacmod.f90:126
real(rprec), dimension(:), allocatable slm
Definition vacmod.f90:128
integer num_eqsolve_retries