VMEC 8.52
3D Equilibrium solver with nested flux surfaces.
Loading...
Searching...
No Matches
tomnsp_con.f90
Go to the documentation of this file.
1
3
17SUBROUTINE tomnsps_con(frzl_array, &
18 brmn_con, bzmn_con, &
19 arcon, azcon )
20 USE vmec_main
21 USE vmec_params, ONLY: jlam, jmin2, ntmax, rcc, rss, zsc, zcs
22 IMPLICIT NONE
23
24 REAL(rprec), DIMENSION(ns,0:ntor,0:mpol1,3*ntmax), TARGET, INTENT(out) :: frzl_array
25 REAL(rprec), DIMENSION(ns*nzeta*ntheta3,0:1), INTENT(in) :: &
26 brmn_con, bzmn_con, arcon, azcon
27
28 INTEGER :: jmax, m, mparity, i, n, k, l, nsz
29 INTEGER :: ioff, joff, mj, ni, nsl, j2, j2l, jl, jll, jmaxl, js
30 REAL(rprec), DIMENSION(:,:,:), POINTER :: frcc, frss, fzcs, fzsc, flcs, flsc
31 REAL(rprec), ALLOCATABLE, DIMENSION(:,:) :: work1
32 REAL(rprec), DIMENSION(:), ALLOCATABLE :: tempr, tempz
33
34 frcc => frzl_array(:,:,:,rcc) !!COS(mu) COS(nv)
35 fzsc => frzl_array(:,:,:,zsc+ntmax) !!SIN(mu) COS(nv)
36 flsc => frzl_array(:,:,:,zsc+2*ntmax) !!SIN(mu) COS(nv)
37 IF (lthreed) THEN
38 frss => frzl_array(:,:,:,rss) !!SIN(mu) SIN(nv)
39 fzcs => frzl_array(:,:,:,zcs+ntmax) !!COS(mu) SIN(nv)
40 flcs => frzl_array(:,:,:,zcs+2*ntmax) !!COS(mu) SIN(nv)
41 END IF
42
43 nsz = ns*nzeta
44
45 ALLOCATE (work1(nsz,12), tempr(nsz), tempz(nsz), stat=i)
46 IF (i .ne. 0) stop 'Allocation error in VMEC2000 tomnsps'
47
48 ioff = lbound(frcc,2)
49 joff = lbound(frcc,3)
50
51 frzl_array = 0.0_dp
52
53 jmax = ns
54 IF (ivac .lt. 1) jmax = ns1
55
56 ! BEGIN FOURIER TRANSFORM
57 !
58 ! FRmn = ARmn - d(BRmn)/du + d(CRmn)/dv
59 ! FZmn = AZmn - d(BZmn)/du + d(CZmn)/dv
60 ! FLmn = - d(BLmn)/du + d(CLmn)/dv
61 !
62 ! NOTE: sinmumi = -m sin(mu), sinnvn = -n sin(nv)
63 DO m = 0, mpol1
64
65 mparity = mod(m,2)
66 mj = m+joff
67
68 j2 = jmin2(m)
69 jl = jlam(m)
70
71 work1 = 0.0_dp
72
73 ! DO THETA (U) INTEGRATION FIRST ON HALF INTERVAL (0 < U < PI)
74 l = 0
75 DO i = 1, ntheta2
76 jll = l+1 ! start of poloidal slice
77 nsl = l+nsz ! end of poloidal slice
78 l = l+nsz ! jump to next poloidal slice
79
80 tempr(:) = xmpq(m,1)*arcon(jll:nsl,mparity)
81 tempz(:) = xmpq(m,1)*azcon(jll:nsl,mparity)
82
83 work1(:,1) = work1(:,1) + tempr(:)*cosmui(i,m) + brmn_con(jll:nsl,mparity)*sinmumi(i,m)
84 work1(:,7) = work1(:,7) + tempz(:)*sinmui(i,m) + bzmn_con(jll:nsl,mparity)*cosmumi(i,m)
85
86 IF (.not.lthreed) cycle
87
88 work1(:,3) = work1(:,3) + tempr(:)*sinmui(i,m) + brmn_con(jll:nsl,mparity)*cosmumi(i,m)
89 work1(:,5) = work1(:,5) + tempz(:)*cosmui(i,m) + bzmn_con(jll:nsl,mparity)*sinmumi(i,m)
90
91 END DO
92
93 ! NEXT, DO ZETA (V) TRANSFORM
94 DO n = 0, ntor
95 ni = n+ioff
96 l = 0
97 DO k = 1, nzeta
98 j2l = l+j2 ! start of radial slice for R,Z
99 jmaxl = l+jmax ! end of radial slice for R,Z
100
101 jll = l+jl ! start of radial slice for lambda
102 nsl = l+ns ! end of radial slice for lambda
103
104 l = l+ns ! jump to next radial slice
105
106 frcc(j2:jmax,ni,mj) = frcc(j2:jmax,ni,mj) + work1(j2l:jmaxl,1)*cosnv(k,n)
107 fzsc(j2:jmax,ni,mj) = fzsc(j2:jmax,ni,mj) + work1(j2l:jmaxl,7)*cosnv(k,n)
108
109 IF (.not.lthreed) cycle
110
111 frss(j2:jmax,ni,mj) = frss(j2:jmax,ni,mj) + work1(j2l:jmaxl,3)*sinnv(k,n)
112 fzcs(j2:jmax,ni,mj) = fzcs(j2:jmax,ni,mj) + work1(j2l:jmaxl,5)*sinnv(k,n)
113
114 END DO
115 END DO
116 END DO
117
118 DEALLOCATE (work1, tempr, tempz)
119
120END SUBROUTINE tomnsps_con
121
135SUBROUTINE tomnspa_con(frzl_array, &
136 brmn_con, bzmn_con, &
137 arcon, azcon )
138 USE vmec_main
139 USE vmec_params, ONLY: jlam, jmin2, ntmax, rsc, rcs, zcc, zss
140 IMPLICIT NONE
141
142 REAL(rprec), DIMENSION(ns,0:ntor,0:mpol1,3*ntmax), TARGET, INTENT(inout) :: frzl_array
143 REAL(rprec), DIMENSION(ns*nzeta,ntheta3,0:1), INTENT(in) :: &
144 brmn_con, bzmn_con, arcon, azcon
145
146 INTEGER :: jmax, m, mparity, i, n, k, l, nsz
147 INTEGER :: ioff, joff, mj, ni, nsl, j2, j2l, jl, jll, jmaxl, js
148 REAL(rprec), DIMENSION(:,:,:), POINTER :: frcs, frsc, fzcc, fzss, flcc, flss
149 REAL(rprec), DIMENSION(:), ALLOCATABLE :: temp1, temp3
150 REAL(rprec), DIMENSION(:,:), ALLOCATABLE :: work1
151
152 frsc => frzl_array(:,:,:,rsc) !!R-SIN(mu) COS(nv)
153 fzcc => frzl_array(:,:,:,zcc+ntmax) !!Z-COS(mu) COS(nv)
154 flcc => frzl_array(:,:,:,zcc+2*ntmax) !!L-COS(mu) COS(nv)
155 IF (lthreed) THEN
156 frcs => frzl_array(:,:,:,rcs) !!R-COS(mu) SIN(nv)
157 fzss => frzl_array(:,:,:,zss+ntmax) !!Z-SIN(mu) SIN(nv)
158 flss => frzl_array(:,:,:,zss+2*ntmax) !!L-SIN(mu) SIN(nv)
159 END IF
160
161 nsz = ns*nzeta
162 ALLOCATE (work1(nsz,12), temp1(nsz), temp3(nsz), stat=i)
163 IF (i .ne. 0) stop 'Allocation error in VMEC tomnspa'
164
165 ioff = lbound(frsc,2)
166 joff = lbound(frsc,3)
167
168 jmax = ns
169 IF (ivac .lt. 1) jmax = ns1
170
171 ! BEGIN FOURIER TRANSFORM
172 DO m = 0, mpol1
173 mparity = mod(m,2)
174
175 mj = m+joff
176
177 j2 = jmin2(m)
178 jl = jlam(m)
179
180 work1 = 0.0_dp
181
182 ! DO THETA (U) TRANSFORM FIRST
183 DO i = 1, ntheta2
184 temp1(:) = xmpq(m,1)*arcon(:,i,mparity)
185 temp3(:) = xmpq(m,1)*azcon(:,i,mparity)
186
187 work1(:,3) = work1(:,3) + temp1(:)*sinmui(i,m) + brmn_con(:,i,mparity)*cosmumi(i,m)
188 work1(:,5) = work1(:,5) + temp3(:)*cosmui(i,m) + bzmn_con(:,i,mparity)*sinmumi(i,m)
189
190 IF (.not.lthreed) cycle
191
192 work1(:,1) = work1(:,1) + temp1(:)*cosmui(i,m) + brmn_con(:,i,mparity)*sinmumi(i,m)
193 work1(:,7) = work1(:,7) + temp3(:)*sinmui(i,m) + bzmn_con(:,i,mparity)*cosmumi(i,m)
194
195 END DO
196
197 ! NEXT, DO ZETA (V) TRANSFORM
198 DO n = 0, ntor
199 ni = n+ioff
200 DO k = 1, nzeta
201 l = ns*(k-1) ! current slice offset
202
203 j2l = j2+l ! start of radial slice for R,Z
204 jmaxl = jmax+l ! end of radial slice for R,Z
205
206 jll = jl+l ! start of radial slice for lambda
207 nsl = ns+l ! end of radial slice for lambda
208
209 frsc(j2:jmax,ni,mj) = frsc(j2:jmax,ni,mj) + work1(j2l:jmaxl,3)*cosnv(k,n)
210 fzcc(j2:jmax,ni,mj) = fzcc(j2:jmax,ni,mj) + work1(j2l:jmaxl,5)*cosnv(k,n)
211
212 IF (.not.lthreed) cycle
213
214 frcs(j2:jmax,ni,mj) = frcs(j2:jmax,ni,mj) + work1(j2l:jmaxl,1)*sinnv(k,n)
215 fzss(j2:jmax,ni,mj) = fzss(j2:jmax,ni,mj) + work1(j2l:jmaxl,7)*sinnv(k,n)
216
217 END DO
218 END DO
219 END DO
220
221 DEALLOCATE (work1, temp1, temp3)
222
223END SUBROUTINE tomnspa_con
integer ivac
counts number of free-boundary iterations
real(rprec), dimension(0:mpol1d, 3) xmpq
spectral condensation weighting factors
Definition vmec_main.f90:81
logical lthreed
integer, dimension(0:mpold), parameter jmin2
starting js(m) values for which R,Z are evolved
integer, dimension(0:mpold), parameter jlam
starting js(m) values for which Lambda is evolved
integer ntmax
number of contributing Fourier basis function (can be 1, 2 or 4); assigned in read_indata()
subroutine tomnspa_con(frzl_array, brmn_con, bzmn_con, arcon, azcon)
Fourier-transform anti-symmetric forces from real space to Fourier space.
subroutine tomnsps_con(frzl_array, brmn_con, bzmn_con, arcon, azcon)
Fourier-transform symmetric forces from real space to Fourier space.