Developer Guide & Testing Standards

Developer Guide & Testing Standards

This guide details the coding standards, restart file specifications, testing frameworks, and integration guidelines for core developers maintaining or extending the solver.

1. Coding & Naming Conventions

1.1 Precision Declaration Rule

  • Never hard-code real values as single-precision (real) or native double-precision (double precision).
  • Always import rk (real precision control parameter) from mod_precision and append _rk to numeric literals: fortran use mod_precision, only : rk real(rk) :: temperature, density temperature = 300.0_rk

1.2 Module Structure & Scope Control

  • Always declare implicit none at the top of every module and subroutine.
  • Use private as the default module state, and explicitly declare public for variables, types, and subroutines exported in module interfaces: ```fortran module mod_example use mod_precision, only : rk implicit none private

    public :: example_subroutine, example_type_t ! Module contents... end module mod_example ```

2. Restart File Mismatch Compatibility Specification

A common developer challenge is resuming a simulation using a restart file that has different species configurations (for example, booting up a 21-species reacting simulation from a 6-species cold mixing run).

The restart loader (mod_restart.f90) implements the Sub-selection Mismatch Rule: * The Condition: The loader permits restarts when file_nspecies < params%nspecies. * The Mapping: It maps overlapping indices up to file_nspecies from the file: fortran species%Y(1:min(file_nspecies, params%nspecies), :) = & tmp_matrix(1:min(file_nspecies, params%nspecies), :) * Zero-Initialization: The remaining intermediate species (indices file_nspecies + 1 to params%nspecies) are zero-initialized: fortran species%Y(file_nspecies+1:params%nspecies, :) = 0.0_rk Since the newly introduced intermediate species are exactly , the simplex sum sum() remains mathematically , preventing mass conservation checks from crashing during startup.

3. Regression Testing & Validation Guidelines

Before committing code changes or merging branches:

  1. Verify Compilation: Ensure the solver compiles successfully under both backends: bash make CHEMISTRY_BACKEND=cantera make CHEMISTRY_BACKEND=pelephysics CHEMISTRY_MODEL=drm19
  2. Verify Conservation: Run the 100-step short validation case: bash ./lowmach_react_hex cases/counterflow_reacting/case_nonreacting.nml Audit diagnostics.csv to ensure total mass and energy conservation sum defects are bounded below .
  3. Verify Parallel Consistency: Run the same case in serial (1 rank) and in parallel (4 ranks) for 50 steps. The cell-centered fields must match exactly to machine precision.