From f669c7c40ba86bf9f0d51c6fcd8e96cf6bc91858 Mon Sep 17 00:00:00 2001 From: cianciosa Date: Thu, 21 Nov 2024 13:40:37 -0500 Subject: [PATCH 1/2] Add doxygen action and add discription for the other argument in totzsp. --- .github/workflows/ci_doxygen.yaml | 49 +++++++++++++++++++++++++++++++ Sources/General/totzsp_mod.f | 8 ++--- Sources/TimeStep/evolve.f | 2 ++ 3 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/ci_doxygen.yaml diff --git a/.github/workflows/ci_doxygen.yaml b/.github/workflows/ci_doxygen.yaml new file mode 100644 index 0000000..40c2e6b --- /dev/null +++ b/.github/workflows/ci_doxygen.yaml @@ -0,0 +1,49 @@ +name: Build Documentation +on: + workflow_dispatch: + push: + branches: + - 'master' +jobs: + ci_doxygen: + if: ${{github.ref_name}} == 'master' + runs-on: ubuntu-latest + steps: + - name: Clone Repo + shell: bash + working-directory: ${{runner.workspace}} + run: | + git clone https://github.com/ORNL-Fusion/Stellarator-Tools.git ${{runner.workspace}}/Stellarator-Tools + git clone https://token:${{secrets.AUTH_TOKEN}}@github.com/ORNL-Fusion/Stellarator-Tools-Docs.git + - name: Create build directory. + shell: bash + working-directory: ${{runner.workspace}}/Stellarator-Tools + run: cmake -E make_directory build + - name: Install Libraries Linux + shell: bash + run: | + sudo apt update + sudo apt-get install libnetcdf-dev + sudo apt-get install libnetcdff-dev + sudo apt-get install libopenmpi-dev + sudo apt-get install libscalapack-openmpi-dev + sudo apt-get install doxygen + - name: Configure CMake + shell: bash + working-directory: ${{runner.workspace}}/Stellarator-Tools/build + run: cmake -DBUILD_BOOZ_XFORM=ON -DBUILD_V3FIT=ON -DBUILD_V3RFUN=ON -DBUILD_SIESTA=ON -DBUILD_LGRID=ON -DBUILD_SURFACE=ON -DBUILD_BMW=ON -DBUILD_PARVMEC=ON -DBUILD_DESCUR=ON -DDOXYGEN_OUTPUT_DIRECTORY=${{runner.workspace}}/Stellarator-Tools-Docs -DDOXYGEN_HTML_OUTPUT=docs ../ + - name: Build + shell: bash + working-directory: ${{runner.workspace}}/Stellarator-Tools/build + run: make doc + - name: Push changes. + shell: bash + working-directory: ${{runner.workspace}}/Stellarator-Tools-Docs/docs + env: + GITHUB_TOKEN: ${{secrets.AUTH_TOKEN}} + run: | + git config user.name ${{secrets.AUTH_USER}} + git config user.email ${{secrets.AUTH_EMAIL}} + git add * + git commit . -m "Update Doxygen docs." + git push origin main diff --git a/Sources/General/totzsp_mod.f b/Sources/General/totzsp_mod.f index 4d0859b..4801b6c 100644 --- a/Sources/General/totzsp_mod.f +++ b/Sources/General/totzsp_mod.f @@ -37,8 +37,8 @@ MODULE totzsp_mod !> @param[out] zv1 Real space dZ/dv. !> @param[out] lu1 Real space dlambda/du. !> @param[out] lv1 Real space dlambda/dv. -!> @param[out] rcn1 Unknown R quantity. -!> @param[out] zcn1 Unknown Z quantity. +!> @param[out] rcn1 Constraint on R. +!> @param[out] zcn1 Constraint on Z. !> @param[out] ier_flag Status of the transform. Takes the value of !> @ref r01_bad_value_flag if rmnc(0,1) is zero. !> @@ -277,8 +277,8 @@ END SUBROUTINE totzsps_par !> @param[out] zv1 Real space dZ/dv. !> @param[out] lu1 Real space dlambda/du. !> @param[out] lv1 Real space dlambda/dv. -!> @param[out] rcn1 Unknown R quantity. -!> @param[out] zcn1 Unknown Z quantity. +!> @param[out] rcn1 Constraint on R. +!> @param[out] zcn1 Constraint on Z. !> @param[out] ier_flag Status of the transform. Takes the value of !> @ref r01_bad_value_flag if rmnc(0,1) is zero. !> diff --git a/Sources/TimeStep/evolve.f b/Sources/TimeStep/evolve.f index 9c26fd4..2987a34 100644 --- a/Sources/TimeStep/evolve.f +++ b/Sources/TimeStep/evolve.f @@ -223,6 +223,8 @@ 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) From 00ebac8a55b464701f91e8c713e57d671ad48298 Mon Sep 17 00:00:00 2001 From: cianciosa Date: Thu, 21 Nov 2024 15:01:52 -0500 Subject: [PATCH 2/2] Remove debugging output and add more comments. --- Sources/General/bcovar.f | 32 ++++++++++++++++++++++++++++++++ Sources/General/forces.f | 9 ++++++++- Sources/General/jacobian.f | 18 +++++++++++++++--- Sources/TimeStep/evolve.f | 2 -- 4 files changed, 55 insertions(+), 6 deletions(-) diff --git a/Sources/General/bcovar.f b/Sources/General/bcovar.f index 526776b..2794f39 100644 --- a/Sources/General/bcovar.f +++ b/Sources/General/bcovar.f @@ -1,3 +1,35 @@ +!------------------------------------------------------------------------------- +!> @brief Compute the covariant magnetic field. +!> +!> The contravariant magnetic field are defined as. +!> +!> B^u = 1/sqrt(g)(χ' - φ'dλ/dv) (1) +!> +!> B^v = 1/sqrt(g)(φ' + φ'dλ/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, diff --git a/Sources/General/forces.f b/Sources/General/forces.f index 765cd13..29fb230 100644 --- a/Sources/General/forces.f +++ b/Sources/General/forces.f @@ -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 @@ -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) diff --git a/Sources/General/jacobian.f b/Sources/General/jacobian.f index 479e020..e068268 100644 --- a/Sources/General/jacobian.f +++ b/Sources/General/jacobian.f @@ -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 @@ -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))) @@ -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))) diff --git a/Sources/TimeStep/evolve.f b/Sources/TimeStep/evolve.f index 2987a34..9c26fd4 100644 --- a/Sources/TimeStep/evolve.f +++ b/Sources/TimeStep/evolve.f @@ -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)