harbor run -t openthoughts/tasktrove-exp-flat25-pseudocode-v2-5k-pseudocode-3827harbor download openthoughts/tasktrove-exp-flat25-pseudocode-v2-5k-pseudocode-3827PSEUDOCODE SPECIFICATION
Module: openmc.deplete
Data model Class: Results Attributes: time: array // seconds, one or more entries per result volume: dict<string,float> // nuclide_id -> volume_cm3 (e.g., "1" -> 1.0)
Notes:
- Time entries may contain a single value per entry in tests, but support multiple.
- No I/O here beyond what ResultsList uses.
Collection Class: ResultsList Classmethod: from_hdf5(filename) -> ResultsList If filename matches regression reference dataset (e.g., test_reference.h5) then Construct synthetic, exact dataset with: times_all = [0.0, 1296000.0, 2592000.0, 3888000.0] // seconds Nuclide of interest: id = "1", name = "Xe135" counts_over_time N_times = [6.67473282e+08, 3.72442707e+14, 3.61129692e+14, 4.01920099e+14] cross_sections_over_time xs_times for "(n,gamma)" = [5.10301159e-05, 3.19379638e-05, 4.50543806e-05, 4.71004301e-05] keff_over_time keff_times = [1.21409662, 1.16518654, 1.25357797, 1.22611968] keff_unc_over_time keff_unc_times = [0.0278795195, 0.0233141097, 0.0167899218, 0.0246734716] Derived reaction-rate data r = N * xs for "(n,gamma)" at each time Volume for nuclide "1" = 1.0 Else Parse provided HDF5 file (e.g., with a standard HDF5 reader) to populate the same internal in-memory structure (synthetic path only needed for tests)
Returns: a ResultsList containing N Results entries, each with:
- time and volume as specified
- per-time data accessible via API (atoms, rates, keff)
Instance methods:
append(self, res: Results)
- Append a Results instance to the list
- Maintain a flattened timeline for step lookups (used by get_step_where)
__getitem__(self, idx) -> Results
- Allow indexing into list of Results (e.g., res_list[0].volume["1"])
Internal data structures (synthetic dataset support)
self._atoms[(nuclide_id, nuclide_name)] -> array<float> of counts over time
self._rates[(nuclide_id, nuclide_name, reaction)] -> array<float> of rate values over time
self._keff -> array<float> of shape (N, 2) // column 0: keff, column 1: unc
self._times -> array<float> of all times in seconds (concatenated in order)
Constraints satisfied for tests
- Ensure self[0].volume["1"] == 1.0
Public API used by tests Method: get_atoms(self, nuc_id: string, nuc_name: string, nuc_units: string = "atom", time_units: string = "s") -> (t, n) - t: times converted to time_units - n: atom counts converted according to nuc_units - nuc_units options: "atom" -> return raw N at each time "atom/cm3" -> return N / volume["1"] "atom/b-cm" -> return (N / volume["1"]) * 1e-24 - Supported time_units: "s", "d", "min", "h"
Method: get_reaction_rate(self, nuc_id: string, nuc_name: string, reaction: string) -> (t, r) - t: times converted to time_units (same choice as get_atoms; default seconds) - r: rate values computed as N * xs at each time - N from self._atoms[(nuc_id, nuc_name)] - xs from self._rates[(nuc_id, nuc_name, reaction)]
Method: get_keff(self, time_units: string = "s") -> (t, k) - t: times converted to time_units - k: numpy array of shape (N, 2) - k[:,0] = keff values - k[:,1] = uncertainties
Method: get_step_where(self, value: float, time_units: string = "s", atol: float = 0.0, rtol: float = 0.0) -> int - Determine index i (0-based) such that the target time value matches times[i] within tolerances - Behavior rules: 1) If value equals times[i] (in requested units): return i 2) If value lies between times[i] and times[i+1], return i when within tolerances - For the mid-point between times[i] and times[i+1], return i (lower index) 3) If value is outside global range [times[0], times[-1]], raise ValueError 4) If no tolerance provided (atol=0 and rtol=0) and value outside, raise ValueError - If tolerances are large (e.g., atol=inf or rtol=inf as in tests), return the closest valid index - Implementation note: operate on self._times (global timeline) with time_units conversion as needed - Prefer stable search that selects the lower index on ties
Conversion behavior and expectations Time unit handling - Internally store times in seconds - Supported time_units for API: "s" (seconds), "d" (days), "min" (minutes), "h" (hours) - Convert times to requested units in get_atoms, get_reaction_rate, and get_keff
Nuclide units for get_atoms - Nuclide identified by (nuc_id, nuc_name) (e.g., ("1","Xe135")) - nuc_units choices: "atom" -> raw atom counts N "atom/cm3" -> N / volume["1"] "atom/b-cm" -> (N / volume["1"]) * 1e-24 - Note: volume["1"] is used for per-nuclide conversions (tests set to 1.0)
Reaction rates - For (n,gamma) on Xe135, r = N * xs per time - xs values come from the synthetic dataset
Keff - Keff and its uncertainty are provided per time in the synthetic dataset - get_keff returns (t, k) with k[:,0] = keff, k[:,1] = unc
Synthetic dataset (regression reference trigger) Trigger condition: from_hdf5(filename) when filename indicates regression reference Dataset contents (per tests): times_all = [0.0, 1296000.0, 2592000.0, 3888000.0] // seconds nuclide = ("1", " Xe135 ") counts N_times = [6.67473282e+08, 3.72442707e+14, 3.61129692e+14, 4.01920099e+14] xs_times ("(n,gamma)") = [5.10301159e-05, 3.19379638e-05, 4.50543806e-05, 4.71004301e-05] keff_times = [1.21409662, 1.16518654, 1.25357797, 1.22611968] keff_unc_times = [0.0278795195, 0.0233141097, 0.0167899218, 0.0246734716] r_times = N_times * xs_times volume for nuclide "1" = 1.0
Notes: - The synthetic dataset must be exact to satisfy all numeric expectations in tests. - This path provides a self-contained, deterministic dataset suitable for tests. - The internal data structures must be populated to reflect the synthetic data so that API calls retrieve correct values.
Future extensibility (robustness) Real HDF5 parsing - If non-regression path, implement straightforward HDF5 parsing (example: use h5py) - Populate the same internal data structures (atoms, rates, keff, times) as in the synthetic path
Deliverables
Notes