# Finite-volume stacks and transients: every trap that cost a run

Earned on the-compound reactor stages 4-5: a seven-block axisymmetric stack
(core -> reflector -> drum -> insulation -> RPV -> air gap -> shield) solved
with one `INSFVEnergyVariable` and an effective-conductivity gap, then marched
through a 10-day decay-heat transient. Every item below was observed, not
recalled. The companion `object-inventory.md` has the object parameters; this
file has the failure modes.

## The upwind boolean: why a resolved gap cannot be marched to equilibrium

`INSFVEnergyAdvection` picks its upwind side on the **boolean**
`raw_value(v) * _normal > 0`. At a face with zero mass flux the residual is
therefore only C0 in the solution - the derivative flips discontinuously. In a
buoyant annulus the gap air has a tiny thermal mass (~546 J/K, relaxation
~0.3 s) and a ~1.5 s circulation turnover, so usable dt is ~1-3 s. Above that,
Newton locks into an **exact period-2 limit cycle** (|R| alternating between two
values to all printed digits, DIVERGED_MAX_ITERATIONS) *even with an exact LU
solve*. `line_search = bt`, a C-inf soft-max in place of `max()` in the heat
transfer coefficient, and a looser `nl_rel_tol` only postpone it.

The equilibrium of a passive stack needs ~2e5 s (shield diffusion L^2/alpha
~18 h; stack thermal mass ~6e6 J/K) = ~1e5 steps at dt ~1-3 s. Unreachable.

**The fix that works:** model the gap as a nonlinear EFFECTIVE CONDUCTIVITY
`k_gap(T) = W * (h_conv(T) + 4 sigma T^3 / D)` on a single conduction variable -
smooth, no upwind advection, converges in 7-8 Newton iterations - and verify
the closure separately with a resolved INSFV Boussinesq cavity run over the
short timescales. Make the radiation part T^4-EXACT: with
`D = 1/eps1 + (R1/R2)(1/eps2 - 1)`, `k_rad = W*4 sigma T^3/D` integrates across
the gap to exactly `sigma (T_hot^4 - T_cold^4)/D`, the true concentric-cylinder
exchange. Then the only approximation left is the convection correlation, and
a resolved cavity tells you how wrong it is (see the Churchill-Chu vs Hollands
note in `object-inventory.md`'s natural-convection section: the open-plate
family over-predicts a SEALED annulus ~3x, which matters little when radiation
is >99% of the gap conductance).

## INSFVEnthalpyFunctorMaterial: one per problem, parameters named `h`/`rho_h`

Its parameters are literally **`h` and `rho_h`** (it sets
`NS::specific_enthalpy = "h"` internally), NOT `specific_enthalpy` /
`enthalpy_density`. Worse, it **hard-names** the properties it provides, so
**only ONE instance may exist per problem**. A multi-block stack that needs
different rho/cp per block (gap air vs five solids) therefore cannot get them
from enthalpy materials. Fold them in instead:

```
[air_rho]  type = ADParsedFunctorMaterial   block = airgap
  property_name = rho_solid    expressions = '<ideal gas rho(T)>'
[air_cp]   type = ADParsedFunctorMaterial   block = airgap
  property_name = cp_solid     expressions = '<cp(T)>'
[]
[et]  type = INSFVEnergyTimeDerivative
  rho = rho_solid    dh_dt = dh_dt
[]
```

The time-derivative functor the kernel wants is `d<h-param>_dt`, i.e. `dh_dt`
when the `h` parameter is named `h`.

## ParsedFunctorMaterial sees only x, y, z, t and other functors

No postprocessors, no coupled variables. Anything you want inside one that is
not a coordinate, `t`, or another functor must be a **constant**. A gap bulk
temperature used as the reference for a Rayleigh number therefore has to be a
hard-coded number (argue the sensitivity in a comment; here it moved T_rpv by
<= 1 K).

Forward references ARE fine - a kernel may name a functor defined later in the
file. A genuinely missing functor name is caught at `initialSetup` with
`No functor ever provided ...`, not at parse time.

## Sources, extremes and integrals on FV variables

- **`INSFVBodyForce` hard-requires `rhie_chow_user_object`** - it is a momentum
  object. To impose a volumetric heat source on an FV energy variable without
  solving flow, use **`FVCoupledForce(v = <aux variable>)`** with the source in
  a MONOMIAL/CONSTANT aux variable (which is also how you freeze a previous
  solve's shape in: `SolutionUserObject` + `SolutionAux`).
- **`ADElementExtremeFunctorValue` ignores `boundary`** - it is element-based.
  Surface extremes and surface integrals need
  **`ADSideIntegralFunctorPostprocessor`** (divide by the area in a
  `ParsedPostprocessor` for an average). Note a side INTEGRAL of T is in K*m,
  not K - an easy "the outer surface is 2736 K" scare.
- **`ParsedPostprocessor`**: the inputs are `pp_names` / `pp_symbols`, and
  there is **no `pi`** in the expression language - spell it out.
- FV variables are **CONST-only** (family MONOMIAL, order CONSTANT). Anything
  you want to plot per-cell is already there; anything nodal is a different
  world.
- `GeneratedMeshGenerator`'s lower corner is `xmin` / `ymin` / `zmin`; there is
  no `origin` parameter, and omitting `xmin` on an RZ annulus silently builds
  it at the wrong radius.
- `PiecewiseByBlockLambdaFunctor` **SIGSEGVs** in this stack. Do not reach for
  it to make a per-block property; use one `ADParsedFunctorMaterial` per block
  with the same `property_name`.
- An `EigenProblem` **drops FV residuals** - FV kernels do not assemble into
  the eigen system. Keep the k-eigenvalue stage purely FE.
- `SolutionIC` on an imported Exodus file warns about `weighting_type` once per
  variable. Harmless; the nodal field is interpolated as-is.

## Transients: dt control and the IC

- **`timestep_limiting_function` requires a `PiecewiseBase` function.**
  `ParsedFunction` is not one and hard-errors. To cap dt growth on a log-time
  march, build a **`PiecewiseLinear`** whose (x, y) pairs are
  `(log(1+t), t)` sampled densely, with `max_function_change` as the per-step
  cap on the *function* value.
- `IterationAdaptiveDT(dt=0.1, growth 1.4, optimal_iterations 5)` plus that cap
  marches 10 days in ~175 steps and ~20 s wall on 4 ranks.
- **Seed the IC from an operating point on the SAME geometry.** Importing a
  field solved on an earlier geometry (no gap, thicker shield) biases the
  vessel by tens of K and injects a spurious multi-kW surge plus an hour-long
  dip into the transient before it settles. A cheap steady solve of the
  operating point on the final geometry (a few Newton iterations) removes it.
- CLI overrides: root-level HIT variables take a bare override
  (`decay_fraction=0.0047 Outputs/file_base=foo`); anything inside a block
  needs the full path (`Executioner/end_time=864000`,
  `Outputs/exodus/time_step_interval=1`).

## Judging a transient: the cross-check that catches a wrong answer

A transient that never exceeds a limit is not yet believable. Solve the SAME
stack STEADY at the decay fraction the transient sees at t1 and t2
(`decay_fraction=F(t1)`, `F(t2)`). The transient must sit BELOW the t1
equilibrium while it is still charging (q_rejected < q_decay) and ABOVE the t2
equilibrium while discharging. If it does not, the IC or the source is wrong.
