VMEC 8.52
3D Equilibrium solver with nested flux surfaces.
Loading...
Searching...
No Matches
alias.f90
Go to the documentation of this file.
1
3
14SUBROUTINE alias(gcons, ztemp, gcs, gsc, gcc, gss)
15 USE vmec_main
16 IMPLICIT NONE
17
18 REAL(rprec), DIMENSION(ns*nzeta,ntheta3), INTENT(out) :: gcons
19 REAL(rprec), DIMENSION(ns*nzeta,ntheta3), INTENT(in) :: ztemp
20 REAL(rprec), DIMENSION(ns,0:ntor,0:mpol1), intent(inout) :: gcs, gsc, gcc, gss
21
22 REAL(rprec), PARAMETER :: p5 = 0.5_dp
23
24 INTEGER :: m, i, ir, jk, jka, n, k, js, l
25 REAL(rprec), DIMENSION(:,:), ALLOCATABLE :: work, gcona
26
27 ! Fourier transform alias force from ztemp to gcons
28 ! and also return intermediate output in g(c,s)(c,s)
29
30 ALLOCATE (work(ns*nzeta,4), gcona(ns*nzeta,ntheta3))
31
32 gcons = 0.0_dp
33 gcona = 0.0_dp
34
35 gcs = 0.0_dp; gsc = 0.0_dp
36 gcc = 0.0_dp; gss = 0.0_dp
37
38 ! The start of this loop at m=1 and its end at mpol1-1=mpol-2
39 ! is what makes this routine a Fourier-space bandpass filter.
40 DO m = 1, mpol1-1
41 work = 0
42 DO i = 1, ntheta2
43 DO jk = 1, ns*nzeta
44 work(jk,1) = work(jk,1) + ztemp(jk,i)*cosmui(i,m)
45 work(jk,2) = work(jk,2) + ztemp(jk,i)*sinmui(i,m)
46 END DO
47 IF (lasym) then
48 ir = ntheta1 + 2 - i
49 IF (i .eq. 1) ir = 1
50 DO jk = 1, ns*nzeta
51 jka = ireflect(jk)
52 work(jk,3) = work(jk,3) + ztemp(jka,ir)*cosmui(i,m)
53 work(jk,4) = work(jk,4) + ztemp(jka,ir)*sinmui(i,m)
54 END DO
55 end if
56 END DO
57
58 DO n = 0, ntor ! retain full toroidal resolution
59 DO k = 1, nzeta
60 l = ns*(k-1)
61 IF (.not.lasym) THEN
62 DO js = 2,ns
63 gcs(js,n,m) = gcs(js,n,m) + tcon(js)*work(js+l,1)*sinnv(k,n)
64 gsc(js,n,m) = gsc(js,n,m) + tcon(js)*work(js+l,2)*cosnv(k,n)
65 END DO
66 ELSE
67 DO js = 2,ns
68 gcs(js,n,m) = gcs(js,n,m) + p5*tcon(js)*sinnv(k,n)*(work(js+l,1)-work(js+l,3))
69 gsc(js,n,m) = gsc(js,n,m) + p5*tcon(js)*cosnv(k,n)*(work(js+l,2)-work(js+l,4))
70 gss(js,n,m) = gss(js,n,m) + p5*tcon(js)*sinnv(k,n)*(work(js+l,2)+work(js+l,4))
71 gcc(js,n,m) = gcc(js,n,m) + p5*tcon(js)*cosnv(k,n)*(work(js+l,1)+work(js+l,3))
72 END DO
73 END IF
74 END DO
75 END DO
76
77 ! INVERSE FOURIER TRANSFORM DE-ALIASED GCON
78 work = 0.0_dp
79
80 DO n = 0, ntor
81 DO k = 1, nzeta
82 l = ns*(k-1)
83 DO js = 2, ns
84 work(js+l,3) = work(js+l,3) + gcs(js,n,m)*sinnv(k,n)
85 work(js+l,4) = work(js+l,4) + gsc(js,n,m)*cosnv(k,n)
86 END DO
87 IF (lasym) then
88 DO js = 2, ns
89 work(js+l,1) = work(js+l,1) + gcc(js,n,m)*cosnv(k,n)
90 work(js+l,2) = work(js+l,2) + gss(js,n,m)*sinnv(k,n)
91 END DO
92 end if
93 END DO
94 END DO
95
96 DO i = 1, ntheta2
97 DO jk = 1, ns*nzeta
98 gcons(jk,i) = gcons(jk,i) + (work(jk,3)*cosmu(i,m) + work(jk,4)*sinmu(i,m))*faccon(m)
99 END DO
100 IF (lasym) then
101 DO jk = 1, ns*nzeta
102 gcona(jk,i) = gcona(jk,i) + (work(jk,1)*cosmu(i,m) + work(jk,2)*sinmu(i,m))*faccon(m)
103 END DO
104 end if
105 END DO
106
107 END DO
108
109 IF (lasym) THEN
110
111 ! EXTEND GCON INTO THETA = PI,2*PI DOMAIN
112 DO i = 1 + ntheta2, ntheta1
113 ir = ntheta1 + 2 - i
114 DO jk = 1, ns*nzeta
115 jka = ireflect(jk)
116 gcons(jk,i) = -gcons(jka,ir) + gcona(jka,ir)
117 END DO
118 END DO
119
120 ! ADD SYMMETRIC, ANTI-SYMMETRIC PIECES IN THETA = 0,PI DOMAIN
121 gcons(:,:ntheta2) = gcons(:,:ntheta2) + gcona(:,:ntheta2)
122
123 END IF
124
125 DEALLOCATE (work, gcona)
126
127END SUBROUTINE alias
subroutine alias(gcons, ztemp, gcs, gsc, gcc, gss)
Fourier-space bandpass filter on constraint force for spectral condensation.
Definition alias.f90:15
integer, dimension(:), allocatable ireflect
two-dimensional array for computing 2pi-v angle
real(rprec), dimension(0:mpol1d) faccon
factor for spectral constraint
Definition vmec_main.f90:82
real(rprec), dimension(:), allocatable tcon
constraint-force multiplier
Definition vmec_main.f90:47