VMEC 8.52
3D Equilibrium solver with nested flux surfaces.
Loading...
Searching...
No Matches
precondn.f90
Go to the documentation of this file.
1
3
24SUBROUTINE precondn(lu1, bsq, gsqrt, r12, &
25 xs, xu12, xue, xuo, xodd, &
26 axm, axd, bxm, bxd, cx, trigmult)
27 USE vmec_main
28 USE vmec_params, ONLY: signgs
29 USE realspace
30 IMPLICIT NONE
31
32 REAL(rprec), DIMENSION(nrzt), INTENT(in) :: lu1, bsq, gsqrt, r12, xs, xu12, xue, xuo, xodd
33 REAL(rprec), DIMENSION(ns+1,2), INTENT(out) :: axm, axd, bxm, bxd
34 REAL(rprec), DIMENSION(ns+1), INTENT(out) :: cx
35 REAL(rprec), DIMENSION(nznt), INTENT(in) :: trigmult
36
37 INTEGER :: js, l, lk
38 REAL(rprec), DIMENSION(:,:), ALLOCATABLE :: ax, bx
39 REAL(rprec) :: temp(ns+1)
40 REAL(rprec), DIMENSION(:), ALLOCATABLE :: ptau, ptau2
41 REAL(rprec) :: t1, t2, t3, pfactor
42
43 ! COMPUTE PRECONDITIONING MATRIX ELEMENTS FOR R,Z FORCE.
44 ! NOTE THAT THE NORMALIZATION IS:
45 !
46 ! AX(off-diag) ~ <(cosmui cosmu cosnv cosnv) 2(R**2 * Xu**2 * bsq/gsqrt)>
47 ! Factor of 2 arising from 1/gsqrt**2 in bsq
48 !
49 ! Now, cosmui cosmu ~ mscale(0)**2, cosnv**2 ~ nscale(0)**2
50 ! Therefore, AX ~ (mscale(0)*nscale(0))**2 2<R**2*Xu**2*bsq/gsqrt>
51 ! ~ 2*r0scale**2 <...>
52 ALLOCATE (ax(ns+1,4), bx(ns+1,4), ptau(nznt), ptau2(nznt))
53
54 ax = 0.0_dp
55 bx = 0.0_dp
56 cx = 0.0_dp
57 temp = 0.0_dp
58
59 ! pfactor = -2*r0scale**2 !v8.50
60 pfactor = -4.0_dp*r0scale**2.0_dp !restored in v8.51
61
62 DO js = 2,ns
63 ! COMPUTE DOMINANT (1/DELTA-S)**2 PRECONDITIONING MATRIX ELEMENTS
64 lk = 0
65 DO l = js,nrzt,ns
66 lk = lk + 1
67 t1 = pfactor*r12(l)*bsq(l)
68 ptau2(lk) = r12(l)*t1/gsqrt(l)
69 t1 = t1*wint(l)
70 temp(js) = temp(js) + t1*trigmult(lk)*xu12(l)
71 ptau(lk) = r12(l)*t1/gsqrt(l)
72 t1 = xu12(l)*ohs
73 t2 = cp25*(xue(l)/shalf(js) + xuo(l))/shalf(js)
74 t3 = cp25*(xue(l-1)/shalf(js) + xuo(l-1))/shalf(js)
75 ax(js,1) = ax(js,1) + ptau(lk)*t1*t1
76 ax(js,2) = ax(js,2) + ptau(lk)*(-t1+t3)*( t1+t2)
77 ax(js,3) = ax(js,3) + ptau(lk)*( t1+t2)*( t1+t2)
78 ax(js,4) = ax(js,4) + ptau(lk)*(-t1+t3)*(-t1+t3)
79 END DO
80
81 ! COMPUTE PRECONDITIONING MATRIX ELEMENTS FOR M**2, N**2 TERMS
82 lk = 0
83 DO l = js,nrzt,ns
84 lk = lk+1
85 t1 = cp5*(xs(l) + cp5*xodd(l)/shalf(js))
86 t2 = cp5*(xs(l) + cp5*xodd(l-1)/shalf(js))
87 bx(js,1) = bx(js,1) + ptau(lk)*t1*t2
88 bx(js,2) = bx(js,2) + ptau(lk)*t1*t1
89 bx(js,3) = bx(js,3) + ptau(lk)*t2*t2
90 cx(js) = cx(js) + cp25*pfactor*lu1(l)**2*gsqrt(l)*wint(l)
91 END DO
92 end do
93
94 temp(1)=0
95 temp(2:ns)=temp(2:ns)/vp(2:ns)
96 temp(ns+1)=0
97 DO js = 1,ns
98 axm(js,1) =-ax(js,1)
99 axd(js,1) = ax(js,1) + ax(js+1,1)
100 axm(js,2) = ax(js,2) * sm(js) * sp(js-1)
101 axd(js,2) = ax(js,3)*sm(js)**2.0_dp + ax(js+1,4)*sp(js)**2.0_dp
102 bxm(js,1) = bx(js,1)
103 bxm(js,2) = bx(js,1) * sm(js) * sp(js-1)
104 bxd(js,1) = bx(js,2) + bx(js+1,3)
105 bxd(js,2) = bx(js,2)*sm(js)**2.0_dp + bx(js+1,3)*sp(js)**2.0_dp
106 cx(js) = cx(js) + cx(js+1)
107 temp(js) = signgs*(temp(js) + temp(js+1))
108 END DO
109
110 axm(ns+1,:) = 0.0_dp
111 axd(ns+1,:) = 0.0_dp
112 bxm(ns+1,:) = 0.0_dp
113 bxd(ns+1,:) = 0.0_dp
114
115 DEALLOCATE (ax, bx, ptau, ptau2)
116
117END SUBROUTINE precondn
real(rprec), dimension(:), allocatable wint
two-dimensional array for normalizing angle integrations
Definition realspace.f90:34
real(rprec), dimension(:), allocatable shalf
sqrt(s) ,two-dimensional array on half-grid
Definition realspace.f90:31
real(rprec), dimension(:), allocatable vp
radial derivative of enclosed volume
Definition vmec_main.f90:56
real(rprec), dimension(:), allocatable sp
shalf(i+1)/sfull(i)
Definition vmec_main.f90:26
real(rprec) ohs
Definition vmec_main.f90:87
real(rprec), dimension(:), allocatable sm
shalf(i)/sfull(i)
Definition vmec_main.f90:25
real(rprec) r0scale
Definition vmec_main.f90:90
real(rprec) signgs
sign of Jacobian : must be =1 (right-handed) or =-1 (left-handed)
subroutine precondn(lu1, bsq, gsqrt, r12, xs, xu12, xue, xuo, xodd, axm, axd, bxm, bxd, cx, trigmult)
Compute preconditioning matrix elements for , force.
Definition precondn.f90:27