RadCluster
Graph-based cluster dynamics for irradiated materials
Loading...
Searching...
No Matches
Functions | Variables
py_utils.post_process Namespace Reference

Functions

 _floor_bin_moments (mu0_raw, mu1_raw, nlo, nhi, C_floor, P)
 
 calculate_derived_quantities (t, y, input_data, rate_eq_obj, xmax_history=None, y_sia100=None)
 
 _last_finite (arr)
 
 _safe_scalar (value)
 
 summary_csv_row (results, input_data, solver_label='')
 

Variables

float _kB = 8.617333262e-5
 

Detailed Description

post_process.py — Derived quantities for RadCluster_2_1.

Computes macroscopic observables from the ODE solution, including:
  - Total SIA / vacancy / He contents
  - Mean cluster sizes
  - Void swelling via the swelling identity (Eq. 161)
  - Frenkel pair conservation diagnostic δ_FP (Eq. 164)
  - He conservation diagnostic δ_He (Eq. 165)

Physics reference
-----------------
Ghoniem, N.M. (2026), Section 7 (Rate_Equations.pdf):
  Eqs. 161-165.

Function Documentation

◆ _floor_bin_moments()

py_utils.post_process._floor_bin_moments (   mu0_raw,
  mu1_raw,
  nlo,
  nhi,
  C_floor,
  P 
)
protected
Remove the uniform C_floor IC from a bin's moments, CONSISTENTLY.

For a bin spanning [nlo, nhi) of width Δ, the uniform C_floor initial
condition contributes Δ·C_floor to μ₀ and C_floor·Δ·(nlo+nhi−1)/2 to μ₁.
Subtracting them is exact — but clamping each at zero INDEPENDENTLY is not:
a near-empty bin can clamp μ₀ to exactly 0 while μ₁ stays positive, i.e. an
empty bin that still carries content.  Summed over bins that inflates the
content while the count collapses, and content/count — the reported mean
size — diverges.  That is how ``mean_n_100`` reached 2853 on a grid of
I = 1000, a value arithmetically impossible for a mean size, and why
``bin_moment`` + ``loop_conversion`` appeared to fail silently.

The bug is NOT conversion-specific: the same pattern governed ``mean_n_i``
and ``mean_n_v``.  It stayed latent there only because the ½⟨111⟩ and
vacancy bins are normally well populated, whereas the ⟨100⟩ population is
near-empty for most of a run (it exists only by conversion) and so sits in
the pathological regime continuously.  It still bites the others in the
early transient and in the large-size tail.

Two couplings restore consistency, mirroring the guard the C++
reconstruction already applies (``rate_kernels.cpp``, "clamp n_bar into the
bin"):
  (a) an empty bin carries no content;
  (b) a bin's mean size must lie inside the bin, i.e. μ₁/μ₀ ∈ [nlo, nhi−1].

Accepts scalars or arrays (the ⟨100⟩ path passes whole time series).

Definition at line 22 of file post_process.py.

◆ _last_finite()

py_utils.post_process._last_finite (   arr)
protected
Return the last finite (non-NaN, non-inf) value of an array.

Falls back to an empty string when the array holds no finite value,
so the CSV never carries a literal 'nan'/'inf'.

Definition at line 530 of file post_process.py.

◆ _safe_scalar()

py_utils.post_process._safe_scalar (   value)
protected
Guard a single scalar against NaN/inf for CSV output.

Definition at line 543 of file post_process.py.

◆ calculate_derived_quantities()

py_utils.post_process.calculate_derived_quantities (   t,
  y,
  input_data,
  rate_eq_obj,
  xmax_history = None,
  y_sia100 = None 
)
Compute macroscopic quantities from ODE solution.

Parameters
----------
t           : ndarray [n_t]
y           : ndarray [N_eq, n_t]
input_data  : InputData
rate_eq_obj : RateEquations or BinMomentRateEquations
xmax_history: ignored (kept for API compatibility)

Returns
-------
results : dict

Definition at line 72 of file post_process.py.

◆ summary_csv_row()

py_utils.post_process.summary_csv_row (   results,
  input_data,
  solver_label = '' 
)
Build a summary dict for a single run (for output/summary.csv).

Every numeric value is guarded against NaN/inf: array metrics emit the
last finite element (or empty string if none), scalar metrics emit an
empty string when non-finite.  This prevents literal 'nan' in
summary.csv.

Definition at line 552 of file post_process.py.

Variable Documentation

◆ _kB

float py_utils.post_process._kB = 8.617333262e-5
protected

Definition at line 19 of file post_process.py.