Repository navigation
Conversation
…thout fudge factors - Temp_nRE: SHG benchmark field 4pi J_lambda Delta_lambda (exact Mathis field, star diluted at the 3D cell distance), replacing the 1.3e-2 and 7e-8 factors; no P(T) rescaling; no re-emission in benchmark mode; id = 1 race removed - Enthalpy integrated from the heat capacity instead of C(T) T; Misselt heat capacity without the 0.5 factor, DustEM heat capacity in J/K - P(T) normalisation no longer overwrites the lowest bin - Heating rates from the number of photons in each bin's energy width, top bin collecting the photons above it: energy conserved on any wavelength grid - Cooling and absorption times in consistent units, C_abs at the photon wavelength - misselt_load: one header line per atom type - test_suite/benchmarks/Camps2015: benchmark driver, slow test, README; docs for -nT, -benchmark_SHG, -Mathis_field
- Wavelength bin and offset of each heating transition edge computed per grain before the cell loop (photon_edge), instead of a binary search per cell - B matrix stored transposed (contiguous P(T) recursion), not zeroed per cell - Grain enthalpies at the temperature bin centres and edges computed once in init_reemission, after the heat capacity files are read - Bit-for-bit identical; temperature_nRE on W5: 4.42 -> 1.93 s (1 thread), 0.86 -> 0.35 s (8 threads)
…ges, grain selection - E_abs_nRE accumulated per thread (E_abs_nRE_id), summed in emission_nRE: the reduction did not cover the update in propagate_packet - update_proba_abs_nRE: opacity of all grains changing status accumulated; lchange_nRE set on every change, both directions and in the dark zone, the opacity added or removed accordingly (grains going back to nRE were re-added at each iteration) - im_reemission_NLTE: bisection from grain_RE_nLTE_start-1, the smallest grain could not be selected - im_reemission_qRE: J0 at the summed wavelength - nLTE/qRE re-emission: field estimate and temperature index of the thread, as for LTE grains, instead of summing all threads at each event; final nLTE temperature search from the lowest index over threads
- calc_Jth: cst_E set once (unset with nRE grains only); grain zone set before the equilibrium test (uninitialised for stochastic grains); called once per wavelength instead of per inclination and azimuth; Planck function tabulated on the temperature grid; nLTE and nRE loops in parallel - repartition_energie: same tabulation and parallel loop for nRE grains - lect_Temperature: axes, sizes and cfitsio status checked for every HDU (no overflow with a file from another grid or grain distribution), naxes(10) for ftgknj, equilibrium flags read as integers, temperature grid of the file compared with the grid of the run (-nT, -Tmax_PAH) - Bit-for-bit identical; W5 (8 threads): source_fct 2.07 -> 0.56 s, total 6.98 -> 5.51 s (main: 5.85 s)
…option order - ref4.1_multi: same model as ref3.0_multi in the 4.1 format (outputs identical on 1 thread), new reference with the corrected nRE physics; ref3.0 remains the 3.0 parameter file for backward compatibility - Tests and sublimation tests use ref4.1_multi - -Tmax_PAH default documented as 3000 K (docs and -h) - -Mathis_field checked after argument parsing (any option order)
…ture file checks - nLTE, nRE and low-memory LTE re-emission CDFs start at wavelength bin 1, as the full-memory LTE path (bin 1 could not be selected) - Memory estimate of the re-emission CDFs with 8-byte reals - Tests: temperature file from another -nT, -Tmax_PAH or number of grain sizes refused; -Mathis_field in any order with -benchmark_SHG
|
ERROR: # Code Review by Gemini |
Code Review by GeminiHere is the code review for the "pah nre" pull request. Physical & Numerical Purpose of Changed Routines
Detailed Review Findings1. Radiative Transfer Physics & Energy Conservation
2. Parallel Computing & Thread Safety
3. Numerical Precision & Array Bounds Safety
Overall Assessment
|
ifort wraps list-directed output at 80 columns, which split long messages (test_temperature_file_mismatch failed on linux/ifort)
Code Review by GeminiCode Review SummaryOverall, this is a well-engineered pull request that addresses long-standing energy conservation issues in MCFOST's treatment of non-equilibrium grains (PAHs and nRE dust). The removal of arbitrary empirical normalization factors, the introduction of proper enthalpy integration, frequency-bin edge matching according to Draine & Li (2001), and thread-private tracking of absorbed energy ( One HIGH severity bug was identified regarding the reset lifecycle of Key Findings1. [HIGH] Un-reset
|
…calculation - warning/error written with an explicit format: ifort wrapped list-directed output at 80 columns (test_temperature_file_mismatch on linux/ifort) - nre_absorbed_fractions takes the first nRE pass of each temperature calculation instead of every other value: the number of nRE passes varies (test_hydrostatic_nre on linux/gfortran, openmp=no)
Code Review by GeminiHere is a review of the pull request. Physical & Numerical SummaryThe changes significantly improve the physical consistency, energy conservation, and numerical stability of non-equilibrium grain (PAHs, nRE) modeling in MCFOST:
Key Finding1. Accumulator
|
…calculation E_abs_nRE and E_abs_nRE_id reset in reset_temperature: the energy absorbed in the last (converged) pass or in the SED step carried over to the next temperature calculation, e.g. repeated mcfost2phantom calls (Gemini review)
Code Review by GeminiCode Review SummaryOverviewThis PR is a major physics fix and numerical improvement for the stochastic heating of non-equilibrium grains (PAHs and nRE grains) in MCFOST. It replaces previous empirical correction factors with exact energy-conserving enthalpy integration and heating transition matrices (following Draine & Li 2001 / Guhathakurta & Draine 1989), corrects specific heat unit conversions, fixes OpenMP thread safety during photon re-emission, and introduces bounds validation when reading FITS temperature files. Key Findings & Verification1. Energy Conservation & Non-Equilibrium Physics
2. Parallel Computing & Thread Safety
3. Input Validation & Robustness
RecommendationStatus: Safe to merge. The code is well-structured, mathematically sound, thread-safe, and passes the 51-case Camps et al. (2015) benchmark. |
Type of PR:
Bug fix / new physics
Description:
Fixes the stochastic heating of non-equilibrium grains (PAHs, nRE) so that it
conserves energy without empirical factors. MCFOST now passes the Camps et al.
(2015) benchmark for all 51 cases: emitted/absorbed power 0.97-1.00 per grain
size, emissivity within 0.88-1.05 of DustEM from 3 to 1000 um (the other codes of
the paper: 0.48-1.42).
User impact: PAH and nRE emission changes in existing models. Mid-IR bands are
lower where energy was not conserved (ref3.0_multi: PAH emission was 2.2x the
absorbed power; SED 0.56-0.89x the previous one at 6-13 um, unchanged elsewhere),
and 25-50 A PAHs are now correctly treated as stochastic.
Physics
rescaling). They compensated the errors below and a benchmark field 4 pi too
weak since aedccef (2017).
bin collecting all higher transitions: energy conserved on any wavelength grid.
Bug fixes
in both directions.
Performance
function, OpenMP loops.
2.13 -> 1.30 s, total 8.46 -> 7.05 s, despite 2.5x more stochastic grain-cell
pairs. W5 output 1.3x slower (larger Temperature_nRE.fits.gz). W1-W4 unchanged.
Robustness, options, tests
(-nT, -Tmax_PAH) are refused instead of overflowing the arrays.
to utils/benchmarks/Camps2015 (next utils release).
backward compatibility. Test data republished.
Testing:
Did you run the botscheck that the code and comments follow the code of conduct? yes
Did you update relevant documentation in the docs directory? yes