23SUBROUTINE vacuum(rmnc, rmns, zmns, zmnc, xm, xn, &
24 plascur, rbtor, wint, ivac_skip, ivac, &
25 mnmax, ier_flag, lasym, signgs, &
36 INTEGER,
intent(in) :: ivac_skip, mnmax
37 integer,
intent(inout) :: ivac, ier_flag
38 REAL(rprec),
intent(in) :: plascur, rbtor
39 REAL(rprec),
DIMENSION(mnmax),
INTENT(in) :: rmnc, rmns, zmns, zmnc, xm, xn
40 REAL(rprec),
DIMENSION(nuv2),
INTENT(in) :: wint
41 logical,
intent(in) :: lasym
42 real(rprec),
intent(in) :: signgs
43 real(rprec),
dimension(nv),
intent(in) :: raxis, zaxis
45 INTEGER :: mn, n, n1, m, i, info
46 REAL(rprec),
DIMENSION(:),
POINTER :: potcos, potsin
47 REAL(rprec):: dn2, dm2, cosmn, sinmn, huv, hvv, det, bsupu, bsupv, bsubuvac, fac
48 logical :: vac1n_solver_active
62 IF (.not.
ALLOCATED(
potvac)) stop
'POTVAC not ALLOCATED in VACCUM'
89 call add_real_1d(
"rmnc", mnmax, rmnc)
90 call add_real_1d(
"zmns", mnmax, zmns)
92 call add_real_1d(
"rmns", mnmax, rmns)
93 call add_real_1d(
"zmnc", mnmax, zmnc)
98 call add_real_1d(
"xm", mnmax, xm)
99 call add_real_1d(
"xn", mnmax, xn)
101 call add_real(
"plascur", plascur)
102 call add_real(
"rbtor", rbtor)
104 call add_real_2d(
"wint", nv, nu3, wint)
106 call add_int(
"ivac_skip", ivac_skip)
107 call add_int(
"ivac", ivac)
108 call add_int(
"mnmax", mnmax)
109 call add_int(
"ier_flag", ier_flag)
110 call add_logical(
"lasym", lasym)
111 call add_real(
"signgs", signgs)
122 CALL surface (rmnc, rmns, zmns, zmnc, xm, xn, mnmax, lasym, signgs)
134 if (vac1n_solver_active)
then
135 call add_real_2d(
"amatrix", mnpd2, mnpd2,
amatrix)
136 call add_real_1d(
"potvac_in", mnpd2,
potvac)
140 IF (info .ne. 0) stop
'Error in solver in VACUUM'
145 if (vac1n_solver_active)
then
146 call add_real_1d(
"potvac_out", mnpd2,
potvac)
164 cosmn = cosu1(i,m)*cosv1(i,n1) + csign(n)*sinu1(i,m)*sinv1(i,n1)
165 potu(i) =
potu(i) + dm2*potsin(mn)*cosmn
166 potv(i) =
potv(i) + dn2*potsin(mn)*cosmn
170 sinmn = sinu1(i,m)*cosv1(i,n1) - csign(n)*cosu1(i,m)*sinv1(i,n1)
171 potu(i) =
potu(i) - dm2*potcos(mn)*sinmn
172 potv(i) =
potv(i) - dn2*potcos(mn)*sinmn
184 hvv =
gvv_b(i)*(nfper*nfper)
185 det = one/(
guu_b(i)*hvv-huv*huv)
206 call add_real_1d(
"potsin", mnpd, potsin)
208 call add_real_1d(
"potcos", mnpd, potcos)
210 call add_null(
"potcos")
213 call add_real_2d(
"potu", nv, nu3,
potu)
214 call add_real_2d(
"potv", nv, nu3,
potv)
216 call add_real_2d(
"bsubu", nv, nu3,
bsubu)
217 call add_real_2d(
"bsubv", nv, nu3,
bsubv)
219 call add_real_2d(
"bsqvac", nv, nu3,
bsqvac)
221 call add_real_2d(
"brv", nv, nu3,
brv)
222 call add_real_2d(
"bphiv", nv, nu3,
bphiv)
223 call add_real_2d(
"bzv", nv, nu3,
bzv)
229 IF (ivac .eq. 0)
THEN
232 WRITE (*, 200) nfper, mf, nf, nu, nv
234 200
FORMAT(/,2x,
'In VACUUM, np =',i3,2x,
'mf =',i3,2x,
'nf =',i3,
' nu =',i3,2x,
'nv = ',i4)
237 bsubuvac = sum(
bsubu(:nuv2)*wint(:nuv2))*signgs*
pi2
241 WRITE (*,1000) bsubuvac*fac, plascur*fac,
bsubvvac, rbtor
243 1000
FORMAT(2x,
'2*pi * a * -BPOL(vac) = ',1p,e10.2, &
244 ' TOROIDAL CURRENT = ',e10.2,/,2x,
'R * BTOR(vac) = ', &
245 e10.2,
' R * BTOR(plasma) = ',e10.2)
252 IF (abs((plascur - bsubuvac)/rbtor) .gt. 1.e-2_dp)
THEN
254 print *,
'VAC-VMEC I_TOR MISMATCH : BOUNDARY MAY ENCLOSE EXT. COIL'
subroutine bextern(plascur, wint)
Compute the total magnetic field due to external coils and the net toroidal plasma current.
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...
real(rprec), dimension(:), allocatable bsubv
real(rprec), dimension(:), allocatable bsqvac
real(rprec), dimension(:), allocatable zvb
real(rprec), dimension(:), allocatable r1b
real(rprec), dimension(:), allocatable zub
real(rprec), dimension(:), allocatable bzv
real(rprec), dimension(:), allocatable, target potvac
real(rprec), dimension(:), allocatable brv
real(rprec), dimension(:), allocatable rub
real(rprec), dimension(:), allocatable rvb
real(rprec), dimension(:), allocatable raxis_nestor
real(rprec), dimension(:), allocatable guu_b
real(rprec), dimension(:), allocatable bphiv
real(rprec), dimension(:), allocatable zaxis_nestor
real(rprec), dimension(:), allocatable gvv_b
real(rprec), dimension(:), allocatable bexv
real(rprec), parameter p5
real(rprec), dimension(:), allocatable guv_b
real(rprec), dimension(:), allocatable bsubu
real(rprec), dimension(:), allocatable n_map_wrt
real(rprec), dimension(:), allocatable m_map_wrt
real(rprec), dimension(:), allocatable amatrix
real(rprec), dimension(:), allocatable potv
real(rprec), dimension(:), allocatable bexu
real(rprec), dimension(:), allocatable potu
integer num_eqsolve_retries
integer, parameter phiedge_error_flag
integer, parameter norm_term_flag
subroutine precal
Pre-compute constant terms required for NESTOR.
subroutine scalpot(bvec, amatrix, wint, ivacskip, lasym, m_map, n_map)
Compute all required terms for solving for the scalar magnetic potential.
subroutine solver(amat, b, m, nrhs, info)
Solve a linear system of equations using dgesv.
subroutine surface(rc, rs, zs, zc, xm, xn, mnmax, lasym, signgs)
Evaluate the geometry of the LCFS and tangential derivatives.
subroutine vacuum(rmnc, rmns, zmns, zmnc, xm, xn, plascur, rbtor, wint, ivac_skip, ivac, mnmax, ier_flag, lasym, signgs, raxis, zaxis)
Compute the vacuum contribution to the free-boundary energy functional.