VMEC 8.52
3D Equilibrium solver with nested flux surfaces.
Loading...
Searching...
No Matches
fourp.f90
Go to the documentation of this file.
1
3
8SUBROUTINE fourp (grpmn, grp)
9 USE vacmod, vm_grpmn => grpmn
10
11 use dbgout
13
14 IMPLICIT NONE
15
16 REAL(rprec), INTENT(inout) :: grpmn(0:mf,-nf:nf,nuv2,ndim)
17 REAL(rprec), INTENT(in) :: grp(nuv,nuv2)
18
19 INTEGER :: n, kv, ku, ip, iuv, m, ireflect, isym
20 REAL(rprec) :: cosm, sinm, cosn, sinn, kernel, gcos, gsin
21
22 IF (ndim .GT. 2) stop 'NDIM > 2'
23
24 DO ku = 1,nu2
25 g1 = 0
26 g2 = 0
27
28 ! PERFORM KV (TOROIDAL ANGLE) TRANSFORM (OVER UNPRIMED MESH IN EQ. 2.14)
29 ! THUS, THE (m,n) INDEX HERE CORRESPONDS TO THE FIRST INDEX OF AMATRIX
30 !
31 ! NOTE: THE .5 FACTOR (IN COSN,SINN) ACCOUNTS FOR THE SUM IN KERNEL.
32 ! ON ENTRY THE FIRST TIME, GRPMN IS SIN,COS * Kmn(analytic)
33 !
34 ! THE 3rd INDEX OF GRPMN IS THE PRIMED U,V MESH COORDINATE
35 DO kv = 1,nv
36 iuv = kv+nv*(ku-1)
37 ireflect = imirr(iuv)
38
39 DO n = 0,nf
40 cosn = p5*onp*cosv(n,kv)
41 sinn = p5*onp*sinv(n,kv)
42
43 DO isym = 1, ndim ! ndim == 1 for stellarator-symmetry, 2 for asymmetric (lasym=T)
44 DO ip = 1,nuv2
45 IF (isym .eq. 1) THEN ! only contrib for stellarator-symmetry
46 ! anti-symmetric part (u,v -> -u,-v)
47
48 kernel = grp(iuv,ip) - grp(ireflect,ip)
49
50! if (iuv .eq. ireflect) then
51! print *, "reflecting on self at iuv=", iuv, " ip=", ip, " n=", n, " ku=", ku, " kv=", kv, &
52! " => kernel=", kernel
53! end if
54
55! if (n.eq.0) then
56! ! fourp_kernel.dat
57! print *, iuv, ip, kernel
58! end if
59 ELSEIF (isym .eq. 2) THEN
60 ! symmetric part
61 kernel = grp(iuv,ip) + grp(ireflect,ip)
62 END IF
63
64 g1(ip,n,isym)=g1(ip,n,isym) + cosn*kernel
65 g2(ip,n,isym)=g2(ip,n,isym) + sinn*kernel
66 END DO ! ip
67 END DO ! isym
68 END DO ! n
69 END DO ! kv
70
71 ! PERFORM KU (POLOIDAL ANGLE) TRANFORM [COMPLETE SIN(mu-nv) / COS(mu-nv) TRANSFORM]
72 DO m = 0,mf
73 DO isym = 1, ndim
74 IF (isym .EQ. 1) THEN
75 cosm = -cosui(m,ku)
76 sinm = sinui(m,ku)
77 ELSEIF (isym .EQ. 2) THEN
78 sinm = cosui(m,ku)
79 cosm = sinui(m,ku)
80 END IF
81
82 DO n= 0,nf
83 DO ip = 1,nuv2
84 gcos = g1(ip,n,isym)*sinm
85 gsin = g2(ip,n,isym)*cosm ! has -1
86 grpmn(m, n,ip,isym) = grpmn(m, n,ip,isym) + gcos + gsin
87 IF (n .NE. 0) THEN
88 grpmn(m,-n,ip,isym) = grpmn(m,-n,ip,isym) + gcos - gsin
89 ENDIF
90 END DO ! ip
91 END DO ! n
92 END DO ! isym
93 END DO ! m
94
95 END DO ! ku
96
97 if (open_dbg_context("vac1n_fourp", num_eqsolve_retries)) then
98
99 ! NOTE: This is the sum of the results from analyt and fourp!
100 call add_real_4d("grpmn", mf1, nf1, nv, nu3, grpmn)
101
102 call close_dbg_out()
103 end if
104
105END SUBROUTINE fourp
subroutine fourp(grpmn, grp)
Perform Fourier integrals of Green's function kernel.
Definition fourp.f90:9
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 g1
Definition vacmod.f90:151
real(rprec), dimension(:,:,:), allocatable g2
Definition vacmod.f90:152
real(rprec), dimension(:), allocatable grpmn
Definition vacmod.f90:102
real(rprec), parameter p5
Definition vacmod.f90:13
real(rprec) onp
Definition vacmod.f90:24
integer num_eqsolve_retries