# Multigroup neutron diffusion k-eigenvalue with zero custom C++

**MOOSE has no neutronics module.** That's Griffin / MAMMOTH, and both are
export-controlled — `idaholab/griffin` and `idaholab/mammoth` are 404 on GitHub.
But multigroup diffusion criticality is entirely reachable with stock framework
objects. This is how.

Canonical template in-tree: **`test/tests/executioners/eigen_convergence/a.i`**
— a 1-group neutron diffusion k-eigenproblem, written by the MOOSE team as
exactly this use case.

---

## 1. The eigenvalue plumbing

```
[Problem]
  type = EigenProblem
[]

[Executioner]
  type = Eigenvalue
  solve_type = NEWTON
  free_power_iterations = 4      # power iterations before the first Newton
  nl_abs_tol = 1e-10
  nl_rel_tol = 1e-8
  l_tol = 1e-4
  petsc_options_iname = '-pc_type -pc_hypre_type'
  petsc_options_value = 'hypre    boomeramg'
[]

[VectorPostprocessors]
  [eigen]
    type = Eigenvalues
    inverse_eigenvalue = true    # report k_eff = 1/lambda, not lambda
  []
[]
```

**The fission source is any kernel carrying `extra_vector_tags = 'eigen'`.**
That tag is what makes `EigenProblem` treat the term as the RHS eigen-operator
rather than part of the LHS. Forget the tag and you get a meaningless eigenvalue
with no error message.

`NonlinearEigen` is the executioner to switch to once cross sections depend on
temperature — it handles the nonlinear (Picard-like) eigenproblem properly.

---

## 2. THE SIGN TRAPS

Read `framework/src/kernels/MatReaction.C`:

```cpp
params.addClassDescription("Kernel to add -L*v, where L=reaction rate, v=variable");
...
template <bool is_ad>
GenericReal<is_ad> MatReactionTempl<is_ad>::computeQpResidual()
{
  return -_rate[_qp] * _v[_qp] * _test[_i][_qp];
}
```

**`MatReaction` residual = `-rate · v · test`.** The minus is baked in. So:

| Physics term | Appears in the equation as | `reaction_rate` you must supply |
|---|---|---|
| Absorption / removal | `+Σ φ` on the LHS | **`-Σ`** (negated) |
| Eigen-tagged fission source | `-(1/k) νΣf φ` moved to the LHS | **`+νΣf`** (positive) |

A clean way to keep this from rotting: name the material properties
`minus_Sigma_r1`, `minus_Sigma_a2` so the negation is visible at the call site,
and leave a comment block at the top of the input file spelling out the three
residual formulas.

### `MatCoupledForce` is a forcing term, and it refuses self-coupling

`MatCoupledForce` residual = `-Σ_j c_j m_j v_j test` — an **RHS** forcing term
over *other* variables. Its constructor `paramError`s if you set `v` to the
kernel's own variable. Consequence:

- **Off-diagonal** group coupling (downscatter `Σ_s12 φ1` into group 2,
  upscatter, cross-group fission) → `MatCoupledForce` with `v = <other group>`.
- **Own-group** fission (`νΣf,g φ_g` into group g) → **must** be `MatReaction`
  with `extra_vector_tags = 'eigen'`.

### `MatDiffusion` — the parameter is `diffusivity`, NOT `D_name`

From `framework/src/kernels/MatDiffusionBase.C`:

```cpp
params.addParam<MaterialPropertyName>(
    "diffusivity", "D", "The diffusivity value or material property");
```

**The parameter is `diffusivity` and its DEFAULT is the property name `"D"`.**
Writing `D_name = D1` does not do what it looks like — you get

```
Material property 'D', requested by 'g1_streaming' is not defined on block core
```

i.e. MOOSE went looking for a property literally named `D`. Correct form:

```
[g1_streaming]
  type = MatDiffusion
  variable = phi1
  diffusivity = D1
[]
```

Residual is `+D ∇u · ∇test` — no sign surprise. `ADMatDiffusion` also exists.
`MatDiffusion` additionally takes an optional coupled `v` (defaults to the
kernel's own variable) and `args` for Jacobian contributions from a
`DerivativeParsedMaterial` diffusivity.

---

## 3. Two-group skeleton

```
[Kernels]
  # ---- group 1 (fast) ----
  [g1_streaming]
    type = MatDiffusion
    variable = phi1
    D_name = D1
  []
  [g1_removal]
    type = MatReaction
    variable = phi1
    reaction_rate = minus_Sigma_r1     # already negated
  []
  [g1_fission_from_g1]
    type = MatReaction
    variable = phi1
    reaction_rate = nuSigmaF1          # positive
    extra_vector_tags = 'eigen'
  []
  [g1_fission_from_g2]
    type = MatCoupledForce
    variable = phi1
    v = phi2
    material_properties = nuSigmaF2
    extra_vector_tags = 'eigen'
  []
  [g1_upscatter_from_g2]
    type = MatCoupledForce
    variable = phi1
    v = phi2
    material_properties = Sigma_s21
  []
  # ---- group 2 (thermal): mirror image ----
[]
```

Scale the two variables differently (`scaling = 1.0` for fast, `1e-2` for
thermal) — thermal flux is typically 1–2 orders larger and an unscaled SMP
converges badly.

---

## 4. Boundary conditions

`VacuumBC` (framework) is the Marshak condition `D ∂u/∂n + u/2 = 0`, with an
optional `alpha` parameter to change the `1/2`. `ArrayVacuumBC` exists for
`MooseArray`-valued variables.

**In RZ, apply it on `right top bottom` only.** The `left` boundary is the
`r = 0` axis and needs **no BC at all** — the Jacobian weight `2πr` vanishes
there and symmetry is natural.

---

## 5. Getting the power shape out for the thermal stage

`ElementIntegralMaterialProperty` integrates a **material property**. Its
parameter is **`mat_prop`**, not `property`, and it takes **no variable**. So to
integrate `νΣf φ` you must first make it a material property:

```
[Materials]
  [fiss_rate_1]
    type = ParsedMaterial
    block = core
    property_name = fiss_rate_1
    coupled_variables = 'phi1'
    material_property_names = 'nuSigmaF1'
    expression = 'nuSigmaF1 * phi1'
  []
[]

[Postprocessors]
  [fission_rate_g1]
    type = ElementIntegralMaterialProperty
    mat_prop = fiss_rate_1
    block = core
    execute_on = 'initial linear timestep_end'
  []
[]
```

The `ParsedMaterial` pays for itself twice: stage 2 reuses `fiss_rate_1`
directly as the `mat_prop` of a `MatHeatSource`, so the power shape is
transferred without a `Transfer` object.

Normalize to a rated power with
`scale = P_nominal / (E_fiss_per_fission × Σ_g fission_rate_g)`,
`E_fiss ≈ 3.204e-11 J` (200 MeV total; ~193 MeV is recoverable in-core, the rest
is neutrinos + decay heat).

Compute that scale **inside the input** with `ParsedPostprocessor`, so stage 2
just reads a number off the CSV. Its parameters are **`pp_names` / `pp_symbols`**,
not `coupled_variables`:

```
[power_scale]
  type = ParsedPostprocessor
  expression = 'P_nom / (E_fiss * (fr1 + fr2))'
  pp_names = 'fission_rate_g1 fission_rate_g2'
  pp_symbols = 'fr1 fr2'
  constant_names = 'P_nom E_fiss'
  constant_expressions = '${P_nominal} 3.204e-11'
  execute_on = 'initial timestep_end'
[]
```

(`constant_expressions` is a vector of strings, each an FParser expression, so
HIT substitution works inside it — that's how `P_nominal` gets consumed and stops
being an "unused parameter" error.)

### Reading k_eff out

The `Eigenvalue` executioner's **console** line prints λ:
`Iteration 28 eigenvalue = 1.0000064961`. The `Eigenvalues` VectorPostprocessor
with `inverse_eigenvalue = true` writes **1/λ** to
`<file_base>_eigen_NNNN.csv` as `eigen_values_real`. With the inverse flag the
two agree when the system is critical and differ by a reciprocal otherwise —
know which one you're looking at.

Also: the eigen solve writes **two** time rows. `time = 0` is the initial
condition, `time = 1` is the converged eigen-solution. **Read the `time = 1`
row.**

---

## 6. Cross sections

`GenericConstantMaterial` with `prop_names` / `prop_values` as parallel quoted
lists, one block per material region. Keep the original `cm⁻¹` values in a
comment above the SI (`m`, `1/m`) numbers you actually pass — the unit slip is
the single easiest way to get a plausible-looking, wrong k_eff.

Wrap `νΣf` in a scale factor exposed as a top-level input parameter:

```
nu_scale = 1.0
...
prop_values = '... ${fparse 0.07*nu_scale} ${fparse 0.20*nu_scale}'
```

Then dialing the model to `k_eff = 1.0` is a one-line change, and a sensitivity
sweep is a `--cli-args` loop. `${...}` is HIT substitution; `${fparse <expr>}`
evaluates an expression.

For real cross sections later: **OpenMC** (pip/conda-installable, and what
Radiant Industries actually uses for Kaleidos) with homogenization onto the RZ
ring mesh, or `Cardinal` — but Cardinal is `neams-hpc/cardinal`, also 404.

---

## 7. Deprecation to know about

`CoefReaction` is deprecated in favour of `Reaction` (parameter `rate`),
effective **01/01/2027**. New inputs should use `Reaction`.

---

## 8. Verified working example

`the-compound/reactor/inputs/stage1_neutronics_2g_rz.i` — 2-group RZ diffusion
k-eigenvalue for a homogenized Kaleidos-like core (core / graphite reflector /
B4C control-drum band), run on 4 MPI ranks against a from-source `combined-opt`:

```
k_eff             = 1.0000065     (nu_scale = 1.5644)
fission_rate_g1   = 3.7717
fission_rate_g2   = 24.926
peak_thermal_flux = 434.44
power_scale       = 3.8065e15     <- x fission-rate shape = 3.5 MWt
29 nonlinear iterations, Solve Converged, ~10 s wall on 4 ranks
```

At `nu_scale = 1.0` the same model gives `k_eff = 0.6392`. One secant step
(`1/0.6392 = 1.5644`) landed it at 0.99999 — **k_eff is very nearly linear in a
global νΣf scale factor**, so re-dialing after any cross-section change is one
CLI override, not a sweep.

Exodus output (`stage1_neutronics.e`, 260 KB) was written by the from-source
build with no SEACAS package, confirming libMesh's bundled exodusii/netcdf.

## 9. Closing the loop with temperature

Stage 3 of any reactor model. Two feedbacks dominate:

1. **Doppler** — fuel temperature broadens resonances → raises `Σ_a` in the
   epithermal/thermal groups. Implement as a `ParsedMaterial` or
   `DerivativeParsedMaterial` whose expression depends on a coupled `T_fuel`.
2. **Moderator density** — for a ZrH-moderated core, moderator temperature sets
   the H/Zr ratio and therefore thermal absorption and downscatter. Same
   mechanism: `Sigma_a2` and `Sigma_s12` become functions of `T_mod`.

Use `DerivativeParsedMaterial` (not plain `ParsedMaterial`) so the Jacobian is
exact — otherwise `NEWTON` degrades to a quasi-Newton and the eigenvalue
iteration stalls. Then either `NonlinearEigen`, or Picard via a `MultiApp` +
`Transfer` pair between a neutronics app and a heat-transfer app.
