Skip to content

Commit

Permalink
Remove debugging output and add more comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
cianciosa committed Nov 21, 2024
1 parent f669c7c commit 00ebac8
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 6 deletions.
32 changes: 32 additions & 0 deletions Sources/General/bcovar.f
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
!-------------------------------------------------------------------------------
!> @brief Compute the covariant magnetic field.
!>
!> The contravariant magnetic field are defined as.
!>
!> B^u = 1/sqrt(g)(χ' - φ'/dv) (1)
!>
!> B^v = 1/sqrt(g)(φ' + φ'/du) (2)
!>
!> This can be converted to covariant components using the metric tensors.
!>
!> g_uu = dr/du*dr/du + dz/du*dz/du (3)
!>
!> g_uv = dr/du*dr/dv + dz/du*dz/dv (4)
!>
!> g_uu = dr/dv*dr/dv + R^2 + dz/dv*dz/dv (5)
!>
!> The covariant magnetic field are
!>
!> B_u = guu*B^u + guv*B^v (6)
!>
!> B_v = guv*B^u + gvv*B^v (7)
!>
!> On exit the parameter lu contains the quantity.
!>
!> P = R(p + |B^2|/(2μ0))
!>
!> @param[inout] lu Poloidal derivative of lambda.
!> @param[inout] lv Toroidal derivative of lambda.
!> @param[in] tpxc
!> @param[inout] ier_flag Error status.
!-------------------------------------------------------------------------------
SUBROUTINE bcovar_par(lu, lv, tpxc, ier_flag)
USE vmec_main, fpsi => bvco, p5 => cp5
USE vmec_params, ONLY: ns4, signgs, pdamp, lamscale, ntmax,
Expand Down
9 changes: 8 additions & 1 deletion Sources/General/forces.f
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
!-------------------------------------------------------------------------------
!> @brief Compute variation in the forces.
!>
!> The variation in the forces is defined as:
!>
!> d/ds(dZ/du)
!-------------------------------------------------------------------------------
SUBROUTINE forces_par
USE vmec_main, p5 => cp5
USE realspace
Expand Down Expand Up @@ -40,7 +47,7 @@ SUBROUTINE forces_par
DO l = nsmin, nsmax
guus(:,l) = pguu(:,l)*pshalf(:,l)
guvs(:,l) = pguv(:,l)*pshalf(:,l)
gvvs(:,l) = pgvv(:,l)* pshalf(:,l)
gvvs(:,l) = pgvv(:,l)*pshalf(:,l)

parmn_e(:,l) = ohs*zu12(:,l)*lu_e(:,l)
pazmn_e(:,l) =-ohs*ru12(:,l)*lu_e(:,l)
Expand Down
18 changes: 15 additions & 3 deletions Sources/General/jacobian.f
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
!-------------------------------------------------------------------------------
!> @brief Compute quantities need to compute the jacobian.
!>
!> The jacobian is defined by:
!>
!> sqrt(g) = R(dZ/ds*dR/du - dR/ds*dZ/du)
!>
!> Radial derivatives naturally fall on the half mesh so these quantities
!> become half mesh values.
!-------------------------------------------------------------------------------
SUBROUTINE jacobian_par
USE vmec_input, ONLY: nzeta
USE vmec_main, ONLY: ohs, nrzt, irst, nznt, iter2
Expand Down Expand Up @@ -31,9 +41,11 @@ SUBROUTINE jacobian_par
irst = 1

DO i = nsmin, nsmax
! drdu on the half mesh.
pru12(:,i) = p5*(pru(:,i,meven) + pru(:,i-1,meven) +
& pshalf(:,i)*(pru(:,i,modd) +
& pru(:,i-1,modd)))
! dzds on the half mesh.
pzs(:,i) = ohs*(pz1(:,i,meven) - pz1(:,i-1,meven) +
& pshalf(:,i)*(pz1(:,i,modd) -
& pz1(:,i-1,modd)))
Expand All @@ -43,15 +55,15 @@ SUBROUTINE jacobian_par
& (pru(:,i,meven)*pz1(:,i,modd) +
& pru(:,i-1,meven)*pz1(:,i-1,modd)) /
& pshalf(:,i))
END DO

DO i = nsmin, nsmax
! dzdu on the half mesh.
pzu12(:,i) = p5*(pzu(:,i,meven) + pzu(:,i-1,meven) +
& pshalf(:,i)*(pzu(:,i,modd) +
& pzu(:,i-1,modd)))
! drds on the half mesh.
prs(:,i) = ohs*(pr1(:,i,meven) - pr1(:,i-1,meven) +
& pshalf(:,i)*(pr1(:,i,modd) -
& pr1(:,i-1,modd)))
! R on the half mesh.
pr12(:,i) = p5*(pr1(:,i,meven) + pr1(:,i-1,meven) +
& pshalf(:,i)*(pr1(:,i,modd) +
& pr1(:,i-1,modd)))
Expand Down
2 changes: 0 additions & 2 deletions Sources/TimeStep/evolve.f
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ SUBROUTINE evolve(time_step, ier_flag, liter_flag, lscreen)

IF (PARVMEC) THEN
IF (lactive) THEN
WRITE (*,*) MAXVAL(pxcdot), MINVAL(pxcdot), MAXVAL(pgc), &
& MINVAL(pgc)
CALL SaxpbyLastNtype(fac*time_step, pgc, fac*b1, pxcdot,
& pxcdot)
CALL SaxpbyLastNtype(time_step, pxcdot, one, pxc, pxc)
Expand Down

0 comments on commit 00ebac8

Please sign in to comment.