VMEC 8.52
3D Equilibrium solver with nested flux surfaces.
Loading...
Searching...
No Matches
flip_theta.f90
Go to the documentation of this file.
2 implicit none
3
4! Subroutines with optional arguments need to be put into a separate module
5! to get the detection of arguments to work correctly.
6! See also: https://stackoverflow.com/a/3122736
7contains
8
11
17SUBROUTINE flip_theta(rmn, zmn, lmn)
18 USE vmec_main
19 USE vmec_params, ONLY: ntmax, rcc, rss, zsc, zcs, zcc, zss, rsc, rcs
20 implicit none
21
22 REAL(rprec), DIMENSION(0:ntor,0:mpol1,ntmax), INTENT(inout) :: rmn, zmn
23 REAL(rprec), DIMENSION(0:ntor,0:mpol1,ntmax), INTENT(inout), OPTIONAL :: lmn
24
25 INTEGER :: n, m
26 REAL(rprec) :: mul1
27 LOGICAL :: l_lmn
28
29 ! FLIP THETA -> PI - THETA (INITIALLY, TO MAKE JACOBIAN < 0)
30 mul1=-1.0_dp
31
32 ! logical flag to indicate that lambda coeffs shall be flipped as well
33 l_lmn = PRESENT(lmn)
34
35 DO m=1,mpol1
36
37 ! here, mul1 == (-1)**mod(m, 2)
38 ! --> m even: mul1 == +1
39 ! --> m odd: mul1 == -1
40
41 DO n=0,ntor
42
43 rmn(n,m,rcc) = mul1*rmn(n,m,rcc)
44 zmn(n,m,zsc) =-mul1*zmn(n,m,zsc)
45 IF (l_lmn) lmn(n,m,zsc) =-mul1*lmn(n,m,zsc)
46
47 IF (lthreed) THEN
48 rmn(n,m,rss) =-mul1*rmn(n,m,rss)
49 zmn(n,m,zcs) = mul1*zmn(n,m,zcs)
50 IF (l_lmn) lmn(n,m,zcs) = mul1*lmn(n,m,zcs)
51 END IF
52
53 IF (lasym) THEN
54
55 rmn(n,m,rsc) =-mul1*rmn(n,m,rsc)
56 zmn(n,m,zcc) = mul1*zmn(n,m,zcc)
57 IF (l_lmn) lmn(n,m,zcc) = mul1*lmn(n,m,zcc)
58
59 IF (lthreed) THEN
60 rmn(n,m,rcs) = mul1*rmn(n,m,rcs)
61 zmn(n,m,zss) =-mul1*zmn(n,m,zss)
62 IF (l_lmn) lmn(n,m,zss) =-mul1*lmn(n,m,zss)
63 END IF
64
65 END IF
66 END DO
67
68 ! flip mul1
69 mul1 = -mul1
70
71 END DO
72
73END SUBROUTINE flip_theta
74
75end module theta_flip
subroutine flip_theta(rmn, zmn, lmn)
Flip the definition of the poloidal angle in the user-provided initial guess for the LCFS geometry.
logical lthreed
integer ntmax
number of contributing Fourier basis function (can be 1, 2 or 4); assigned in read_indata()