VMEC 8.52
3D Equilibrium solver with nested flux surfaces.
Loading...
Searching...
No Matches
calc_fbal.f90
Go to the documentation of this file.
1
3
8SUBROUTINE calc_fbal(bsubu, bsubv)
9
10 USE vmec_main, ONLY: buco, bvco, equif, &
11 jcurv, jcuru, chipf, vp, pres, &
13 input_extension, iter2, num_eqsolve_retries
14 USE vmec_params, ONLY: signgs
15 USE vmec_dim, ONLY: ns, nrzt, ns1
16 USE realspace, ONLY: wint
17 USE stel_kinds, ONLY: dp
18
19 use dbgout
20
21 implicit none
22
23 REAL(dp), INTENT(in) :: bsubu(1:nrzt)
24 REAL(dp), INTENT(in) :: bsubv(1:nrzt)
25
26 INTEGER :: js
27
28 ! compute flux-surface averages of covariant magnetic field components
29 DO js = 2, ns
30 buco(js) = sum(bsubu(js:nrzt:ns)*wint(js:nrzt:ns)) ! toroidal current I (?)
31 bvco(js) = sum(bsubv(js:nrzt:ns)*wint(js:nrzt:ns)) ! poloidal current G (?)
32 END DO
33
34 ! FROM AMPERE'S LAW, JcurX are angle averages of jac*JsupX, so
35 ! JcurX = (dV/ds)/twopi**2 <JsupX> where <...> is flux surface average
36 DO js = 2, ns1
37 ! radial derivatives of covariant magnetic field components give contravariant currents
38 ! --> poloidal, toroidal derivative contributions to curl(B) are averaged out in flux-surface average ?
39 jcurv(js) = (signgs*ohs)*(buco(js+1) - buco(js))
40 jcuru(js) =-(signgs*ohs)*(bvco(js+1) - bvco(js))
41
42 vpphi(js) = (vp(js+1) + vp(js))/2
43
44 ! prescribed pressure gradient from user input
45 presgrad(js) = (pres(js+1) - pres(js))*ohs
46
47 ! total resulting force-imbalance: magnetic pressure + (prescribed) kinetic pressure
48 ! F = grad(p) - <j x B> (or something like this...)
49 equif(js) = (-phipf(js)*jcuru(js) + chipf(js)*jcurv(js))/vpphi(js) + presgrad(js)
50 END DO
51
52 equif(1) = 0
53 equif(ns) = 0
54
55 ! check calc_fbal output
56 if (open_dbg_context("calc_fbal", num_eqsolve_retries)) then
57
58 ! first and last elements are uninitialized and not needed during the iterations
59 jcurv(1) = 0.0_dp ; jcurv(ns) = 0.0_dp
60 jcuru(1) = 0.0_dp ; jcuru(ns) = 0.0_dp
61 vpphi(1) = 0.0_dp ; vpphi(ns) = 0.0_dp
62 presgrad(1) = 0.0_dp ; presgrad(ns) = 0.0_dp
63 equif(1) = 0.0_dp ; equif(ns) = 0.0_dp
64
65 call add_real_1d("buco", ns-1, buco(2:ns))
66 call add_real_1d("bvco", ns-1, bvco(2:ns))
67 call add_real_1d("jcurv", ns, jcurv)
68 call add_real_1d("jcuru", ns, jcuru)
69 call add_real_1d("vpphi", ns, vpphi)
70 call add_real_1d("presgrad", ns, presgrad)
71 call add_real_1d("equif", ns, equif)
72
73 call close_dbg_out()
74 end if
75
76END SUBROUTINE calc_fbal
subroutine calc_fbal(bsubu, bsubv)
Compute flux-surface averaged radial force balance .
Definition calc_fbal.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 wint
two-dimensional array for normalizing angle integrations
Definition realspace.f90:34
integer, parameter dp
integer ns1
ns-1
Definition vmec_dim.f90:18
integer ns
number of flux surfaces
Definition vmec_dim.f90:17
integer nrzt
Definition vmec_dim.f90:13
real(rprec), dimension(:), allocatable equif
radial force balance error: grad(p) - <j x B>
Definition vmec_main.f90:45
real(rprec), dimension(:), allocatable vp
radial derivative of enclosed volume
Definition vmec_main.f90:56
real(rprec), dimension(:), allocatable bvco
enclosed poloidal current profile
Definition vmec_main.f90:43
real(rprec), dimension(:), allocatable buco
enclosed toroidal current profile
Definition vmec_main.f90:42
real(rprec), dimension(:), allocatable jcuru
poloidal current density
Definition vmec_main.f90:39
real(rprec) ohs
Definition vmec_main.f90:87
real(rprec), dimension(:), allocatable pres
pressure profile
Definition vmec_main.f90:55
real(rprec), dimension(:), allocatable chipf
radial derivative of poloidal magnetic flux (full grid)
Definition vmec_main.f90:36
integer num_eqsolve_retries
real(rprec), dimension(:), allocatable presgrad
pressure gradient: dp/ds
Definition vmec_main.f90:61
integer iter2
total number of iterations
real(rprec), dimension(:), allocatable phipf
radial derivative of toroidal magnetic flux (full grid)
Definition vmec_main.f90:35
real(rprec), dimension(:), allocatable vpphi
Definition vmec_main.f90:60
real(rprec), dimension(:), allocatable jcurv
toroidal current density
Definition vmec_main.f90:40
real(rprec) signgs
sign of Jacobian : must be =1 (right-handed) or =-1 (left-handed)