VMEC 8.52
3D Equilibrium solver with nested flux surfaces.
Loading...
Searching...
No Matches
bss.f90
Go to the documentation of this file.
1
3
17SUBROUTINE bss(r12, rs, zs, ru12, zu12, bsubs, bsupu, bsupv, br, bphi, bz)
18 USE vmec_main
19 USE realspace
20
21 use dbgout
22
23 IMPLICIT NONE
24
25 REAL(rprec), DIMENSION(nrzt), INTENT(in) :: r12, rs, zs, ru12, zu12, bsupu, bsupv
26 REAL(rprec), DIMENSION(nrzt), INTENT(out) :: br, bphi, bz, bsubs
27
28 REAL(rprec), PARAMETER :: p5 = 0.5_dp
29 REAL(rprec), PARAMETER :: p25 = p5*p5, dshalfds=p25
30
31 INTEGER :: l
32 REAL(rprec), DIMENSION(:), allocatable :: rv12, zv12, rs12, zs12, gsu, gsv
33
34 ! Computes br, bphi, bz, bsubs on HALF-RADIAL mesh
35 ! bsubs will be averaged onto the FULL-RADIAL mesh in jxbforce before output to WOUT file
36
37 allocate(rv12(nrzt), zv12(nrzt), &
38 rs12(nrzt), zs12(nrzt), &
39 gsu(nrzt), gsv(nrzt))
40
41 ! initialize first entry, as this is otherwise never set and floats around -> noise in Git!
42 rv12(1) = zero
43 zv12(1) = zero
44
45 rs12(1) = zero
46 zs12(1) = zero
47
48 gsu(1) = zero
49 gsv(1) = zero
50
51 bsubs(1) = zero
52
53 br(1) = zero
54 bphi(1) = zero
55 bz(1) = zero
56
57 DO l = 2, nrzt
58
59 rv12(l) = p5*(rv(l,0)+rv(l-1,0) + shalf(l)*(rv(l,1) + rv(l-1,1)))
60 zv12(l) = p5*(zv(l,0)+zv(l-1,0) + shalf(l)*(zv(l,1) + zv(l-1,1)))
61
62 ! -------------
63
64 rs12(l) = rs(l) + dshalfds*(r1(l,1) + r1(l-1,1))/shalf(l)
65 zs12(l) = zs(l) + dshalfds*(z1(l,1) + z1(l-1,1))/shalf(l)
66
67 gsu(l) = rs12(l)*ru12(l) + zs12(l)*zu12(l)
68 gsv(l) = rs12(l)*rv12(l) + zs12(l)*zv12(l)
69
70 bsubs(l) = bsupu(l)*gsu(l) + bsupv(l)*gsv(l)
71
72 ! -------------
73
74 br(l) = bsupu(l)*ru12(l) + bsupv(l)*rv12(l)
75 bphi(l) = bsupv(l)*r12(l)
76 bz(l) = bsupu(l)*zu12(l) + bsupv(l)*zv12(l)
77
78 END DO
79
80 if (open_dbg_context("bss", id=0)) then
81
82 call add_real_3d("rv12", ns, nzeta, ntheta3, rv12)
83 call add_real_3d("zv12", ns, nzeta, ntheta3, zv12)
84
85 call add_real_3d("rs12", ns, nzeta, ntheta3, rs12)
86 call add_real_3d("zs12", ns, nzeta, ntheta3, zs12)
87
88 call add_real_3d("gsu", ns, nzeta, ntheta3, gsu)
89 call add_real_3d("gsv", ns, nzeta, ntheta3, gsv)
90
91 call add_real_3d("br", ns, nzeta, ntheta3, br )
92 call add_real_3d("bphi", ns, nzeta, ntheta3, bphi)
93 call add_real_3d("bz", ns, nzeta, ntheta3, bz )
94
95 call add_real_3d("bsubs", ns, nzeta, ntheta3, bsubs)
96
97 call close_dbg_out()
98 end if
99
100 deallocate(rv12, zv12, rs12, zs12, gsu, gsv)
101
102END SUBROUTINE bss
subroutine bss(r12, rs, zs, ru12, zu12, bsubs, bsupu, bsupv, br, bphi, bz)
Computes br, bphi, bz, bsubs on half-radial mesh.
Definition bss.f90:18
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 rv
Definition realspace.f90:10
real(rprec), dimension(:,:), allocatable zv
Definition realspace.f90:13
real(rprec), dimension(:), allocatable shalf
sqrt(s) ,two-dimensional array on half-grid
Definition realspace.f90:31
real(rprec), dimension(:,:), allocatable, target z1
Definition realspace.f90:11
real(rprec), dimension(:,:), allocatable r1
Definition realspace.f90:8