Skip to content

Commit

Permalink
Merge pull request #63 from ORNL-Fusion/asym_index
Browse files Browse the repository at this point in the history
Preserve flux surfaces in pchelms and document the restart file. Add …
  • Loading branch information
cianciosa authored Oct 17, 2024
2 parents dd729d4 + f2be29d commit 204ea1a
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 4 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/ci_doxygen.yaml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 4 additions & 2 deletions Sources/evolution.f90
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ MODULE evolution
USE island_params, mpol=>mpol_i, ntor=>ntor_i, ns=>ns_i, &
nfp=>nfp_i, mnmax=>mnmax_i, hs=>hs_i
USE timer_mod
USE siesta_namelist, ONLY: eta_factor, l_force_restart
USE siesta_namelist, ONLY: eta_factor, l_force_restart, lrestart
USE descriptor_mod, ONLY: iam, nprocs
USE nscalingtools, ONLY: SKSDBG, PARSOLVER, PARFUNCTISL, MPI_ERR, &
startglobrow, endglobrow, rcounts, disp
Expand Down Expand Up @@ -302,7 +302,9 @@ SUBROUTINE init_evolution
fsqprev = -1; fsqprev1 = -1
fsq_min = 1.E20_dp
niter = 0
wtotal0 = -1
IF (.not.lrestart) THEN
wtotal0 = -1
END IF
! Initial Newton tolerance parameter.
etak_tol = 1.E-01_dp
delta_t = 1.0
Expand Down
12 changes: 11 additions & 1 deletion Sources/pchelms.f90
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ SUBROUTINE CURLA_PCHELMS(Asubsmnf, Asubumnf, Asubvmnf, &
USE utilities, ONLY: CURL_FtoH, set_bndy_fouier_m0, &
set_bndy_full_origin
USE island_params, ONLY: fourier_context
USE siesta_namelist, ONLY: nsin

IMPLICIT NONE

Expand Down Expand Up @@ -232,8 +233,18 @@ SUBROUTINE CURLA_PCHELMS(Asubsmnf, Asubumnf, Asubvmnf, &
IF (nsmin .eq. 1) THEN
CALL set_bndy_full_origin(asubsmnf, asubumnf, asubvmnf, f_none)
asubsmnf(m1 + moff,:,1) = 0
asubumnf(m0 + moff,:,1) = 0
asubvmnf(m0 + moff,:,1) = 0
END IF
IF (nsmin .le. nsin) THEN
! This ensures the inital solution preseves the VMEC solution inside the last
! closed flux surface.
!
! A_u = phi/2Pi -> A_u (m ≠ 0 and ≠ 0) = 0
! A_v = chi/2Pi -> A_v (m ≠ 0 and ≠ 0) = 0
asubumnf(m1 + moff:,:,:MIN(nsin, nsmax)) = 0
asubvmnf(m1 + moff:,:,:MIN(nsin, nsmax)) = 0
END IF

! At s=0, the poloidal and toroidal flux are zero. This implies that the m=0,
! n=0 components of A_u (~Poloidal Flux) and A_v (~Toroidal Flux) should be
Expand Down Expand Up @@ -1143,7 +1154,6 @@ SUBROUTINE CHECK_CURRENT
IMPLICIT NONE

! Local variables
INTEGER :: i
REAL (dp) :: currv_int

! Start of executable code
Expand Down
120 changes: 119 additions & 1 deletion Sources/restart_mod.f90
Original file line number Diff line number Diff line change
@@ -1,3 +1,112 @@
!-------------------------------------------------------------------------------
! The @header, @table_section, @table_subsection, @item and @end_table commands
! are custom defined commands in Doxygen.in. They are defined under ALIASES.
! For the page created here, the 80 column limit is exceeded. Arguments of
! aliases are separated by ','. If you intended ',' to be a string you must use
! an escaped comma '\,'.
!
!> @page siesta_restart_sec Discription of the SIESTA restart file.
!>
!> @tableofcontents
!> @section siesta_restart_intro_sec Introduction
!> This page documents the contents of a SIESTA restart file.
!>
!> @section siesta_restart_var_sec Namelist Variables
!> @header{Input variable, Description, Code Reference}
!>
!> @table_section{siesta_restart_flag_sec, Control Flags}
!> @item{state_flags, State flags of the model. Aditionally stores the
!> version number in the first 31 bits.
!> * restart_version
!> * restart_lasym, }
!> @item{wout_file, Name of the inital wout_file., siesta_namelist::wout_file}
!> @end_table
!>
!> @table_section{siesta_restart_size_sec, Dimension sizes.}
!> @item{mpol, Number of torodial modes., siesta_namelist::mpolin}
!> @item{nfp, Number of field periods., siesta_namelist::nfpin}
!> @item{nrad, Number of radial surfaces., island_params::ns_i}
!> @item{ntor, Maximum torodal mode., siesta_namelist::ntorin}
!> @end_table
!>
!> @table_section{siesta_restart_norm_fact_sec, Normalization factors.}
!> @item{b_factor, Normalization factor for the magnetic field., quantities::b_factor}
!> @item{p_factor, Normalization factor for the pressure., quantities::p_factor}
!> @end_table
!>
!> @table_section{siesta_restart_scalar_sec, Scalar quantities.}
!> @item{curtor, The toroidal current., shared_data::siesta_curtor}
!> @item{p_max, Maximum pressure., }
!> @item{p_min, Minimum pressure., }
!> @item{rmajor, Major radius., island_params::rmajor_i}
!> @item{wb, Energy stored in the magnetid field., quantities::wb}
!> @item{wp, Energy stored in the pressure., quantities::wb}
!> @end_table
!>
!> @table_section{siesta_restart_1D_arrays_sec, 1D profiles.}
!> @item{chipf_r_, Radial derivative of the poloidal flux., island_params::chipf_i}
!> @item{phipf_r_, Radial derivative of the toroidal flux., island_params::phipf_i}
!> @end_table
!>
!> @table_sections{siesta_restart_2D_arrays_sec, 3D arrays.}
!> @table_subsection{siesta_restart_internal_arrays_sec, Internal arrays}.
!> @item{JBsupssh_m_n_r_, Normalized JB^s component sine parity., quantities::jbsupsmnsh}
!> @item{JBsupuch_m_n_r_, Normalized JB^u component cosine parity., quantities::jbsupumnch}
!> @item{JBsupvch_m_n_r_, Normalized JB^v component cosine parity., quantities::jbsupvmnch}
!> @item{jpresch_m_n_r_, Normalized JP component cosine parity., quantities::jpmnch}
!> @table_subsection{siesta_restart_internal_arrays_asym_sec, Internal arrays asym.}
!> @item{JBsupsch_m_n_r_, Normalized JB^s component cosine parity., quantities::jbsupsmnch}
!> @item{JBsupush_m_n_r_, Normalized JB^u component sine parity., quantities::jbsupumnsh}
!> @item{JBsupvsh_m_n_r_, Normalized JB^v component sine parity., quantities::jbsupvmnsh}
!> @item{jpressh_m_n_r_, Normalized JB^v component sine parity., quantities::jpmnsh}
!> @table_subsection{siesta_restart_grid_arrays_sec, Grid arrays}.
!> @item{rmnc_m_n_r_, R cosine parity., vmec_info::rmnc_i}
!> @item{zmns_m_n_r_, Z sine parity., vmec_info::zmns_i}
!> @table_subsection{siesta_restart_grid_arrays_asym_sec, Gird arrays asym.}
!> @item{rmns_m_n_r_, R sine parity., vmec_info::rmns_i}
!> @item{zmnc_m_n_r_, Z cosine parity., vmec_info::zmnc_i}
!> @table_subsection{siesta_restart_vmec_arrays_sec, VMEC arrays.}
!> @item{lmns_m_n_r_, Lambda sine parity., vmec_info::lmns_i}
!> @table_subsection{siesta_restart_vmec_arrays_asym_sec, VMEC arrays asym.}
!> @item{lmnc_m_n_r_, Lambda cosine parity., vmec_info::lmnc_i}
!> @table_subsection{siesta_restart_mag_arrays_sec, Magnetic fields.}
!> @item{bsubsmnsh_m_n_r_, B_s component sine parity., }
!> @item{bsubumnch_m_n_r_, B_u component cosine parity., }
!> @item{bsubvmnch_m_n_r_, B_v component cosine parity., }
!> @item{bsupsmnsh_m_n_r_, B^s component sine parity., }
!> @item{bsupumnch_m_n_r_, B^u component cosine parity., }
!> @item{bsupvmnch_m_n_r_, B^v component cosine parity., }
!> @table_subsection{siesta_restart_mag_arrays_asym_sec, Magnetic fields.}
!> @item{bsubsmnch_m_n_r_, B_s component cosine parity., }
!> @item{bsubumnsh_m_n_r_, B_u component sine parity., }
!> @item{bsubvmnsh_m_n_r_, B_v component sine parity., }
!> @item{bsupsmnch_m_n_r_, B^s component cosine parity., }
!> @item{bsupumnsh_m_n_r_, B^u component sine parity., }
!> @item{bsupvmnsh_m_n_r_, B^v component sine parity., }
!> @table_subsection{siesta_restart_pres_arrays_sec, Pressure.}
!> @item{pmnch_m_n_r_, Pressure cosine parity., }
!> @table_subsection{siesta_restart_mag_arrays_asym_sec, Magnetic fields.}
!> @item{pmnsh_m_n_r_, Pressure sine parity., }
!> @table_subsection{siesta_restart_mag_arrays_sec, Magnetic fields.}
!> @item{fsubsmnsh_m_n_r_, F_s component sine parity., quantities::fsubsmnsf}
!> @item{fsubumnch_m_n_r_, F_u component cosine parity., quantities::fsubumncf}
!> @item{fsubvmnch_m_n_r_, F_v component cosine parity., quantities::fsubvmncf}
!> @item{fsupsmnsh_m_n_r_, F^s component sine parity., quantities::fsupsmncf}
!> @item{fsupumnch_m_n_r_, F^u component cosine parity., quantities::fsupumnsf}
!> @item{fsupvmnch_m_n_r_, F^v component cosine parity., quantities::fsupvmnsf}
!> @table_subsection{siesta_restart_mag_arrays_asym_sec, Magnetic fields.}
!> @item{fsubsmnch_m_n_r_, F_s component cosine parity., quantities::fsubsmncf}
!> @item{fsubumnsh_m_n_r_, F_u component sine parity., quantities::fsubumnsf}
!> @item{fsubvmnsh_m_n_r_, F_v component sine parity., quantities::fsubvmnsf}
!> @item{fsupsmnch_m_n_r_, F^s component cosine parity., quantities::fsupsmncf}
!> @item{bsupumnsh_m_n_r_, F^u component sine parity., quantities::fsupumnsf}
!> @item{bsupvmnsh_m_n_r_, F^v component sine parity., quantities::fsupvmnsf}
!> @end_table
!>
!> @section siesta_restart_prog_ref_sec Programmers Reference
!> Reference material for the coding to implement this restart file is found in
!> the @ref restart_mod module.
!-------------------------------------------------------------------------------
!*******************************************************************************
!> @file restart_mod.f90
!> @brief Contains module @ref restart_mod.
Expand All @@ -12,7 +121,7 @@ MODULE restart_mod
USE stel_kinds
USE metrics, ONLY: tolowerh
USE descriptor_mod, ONLY: iam
USE shared_data, ONLY: lasym, unit_out
USE shared_data, ONLY: lasym, unit_out, wtotal0
USE v3_utilities, ONLY: assert_eq
USE stel_constants, ONLY: mu0

Expand Down Expand Up @@ -170,6 +279,9 @@ MODULE restart_mod
!> Name for the restart file p_min.
CHARACTER (len=*), PARAMETER :: vn_p_min = 'p_min'

!> Inital stored energy.
CHARACTER (len=*), PARAMETER :: vn_wtotal0 = 'wtotal0'

CONTAINS

!*******************************************************************************
Expand Down Expand Up @@ -256,6 +368,8 @@ FUNCTION restart_read(restart_ext, wout_file, mpolin, ntorin, nfpin, &
CALL cdf_read(ncid, vn_ntorin, ntor)
CALL cdf_read(ncid, vn_nfpin, nfp)

CALL cdf_read(ncid, vn_wtotal0, wtotal0)

ALLOCATE(temp_modes(-ntor:ntor))
CALL cdf_read(ncid, vn_tor_modes, temp_modes)

Expand Down Expand Up @@ -478,6 +592,8 @@ SUBROUTINE restart_write(restart_ext, wout_file)
CALL cdf_define(ncid, vn_nfpin, nfp)
CALL cdf_define(ncid, vn_wout, wout_file)

CALL cdf_define(ncid, vn_wtotal0, wtotal0)

CALL cdf_define(ncid, vn_tor_modes, fourier_context%tor_modes)

CALL cdf_define(ncid, vn_jbsupss, jbsupsmnsh, dimname=restart_dims)
Expand Down Expand Up @@ -555,6 +671,8 @@ SUBROUTINE restart_write(restart_ext, wout_file)
CALL cdf_write(ncid, vn_nfpin, nfp)
CALL cdf_write(ncid, vn_wout, wout_file)

CALL cdf_write(ncid, vn_wtotal0, wtotal0)

CALL cdf_write(ncid, vn_tor_modes, fourier_context%tor_modes)

CALL cdf_write(ncid, vn_jbsupss, jbsupsmnsh)
Expand Down

0 comments on commit 204ea1a

Please sign in to comment.