Repository navigation
Conversation
The nickel moves during cooling and is then removed from both the geometry and the source map, leaving the activated iron slab as the only emitter. The photon animation contrasts strong attenuation by the iron with negligible attenuation by the H1 slab. Co-authored-by: jon-proximafusion <174589458+jon-proximafusion@users.noreply.github.com>
Example 3 previews: fixed iron slab, nickel moves then is removedAdded in 83e0a4b (moving_then_removed_volume.py). Same irradiation as Example 2, plus a stationary 6 cm iron slab along the bottom (y from -18 to -12 cm, z from -8 to 8 cm). The slab is its own Neutron irradiation: source fixed at Decay photons after shutdown: the nickel moves through x = 24, 16 and 8 cm. It is then removed from the geometry and given What to look for:
The iron slab is drawn as a dashed outline so its own emission stays visible. |
…ernel index Replay now drops births below the destination photon energy cutoff and excludes them from the photon source rate. External source sites are only checked against the cutoff at their first collision, so these photons could otherwise score a first flight. The production bank keeps every birth. Target instance checks use only as many lattice indices as the lattice has dimensions, so 2-D hexagonal lattices resolve to their instance. Nonzero observations restore DistribcellFilter paths from the target geometry, matching the zero-source branch, so DataFrames work. kernel_index now indexes the returned provenance kernels list, which omits kernels with no surviving births. Co-authored-by: jon-proximafusion <174589458+jon-proximafusion@users.noreply.github.com>
…arrow The CAD example builds the same solids with CadQuery and meshes them to DAGMC with cad_to_dagmc using the cad-to-dagmc-mesher backend. It shares the schedule, mesh and plotting with the CSG example. The neutron source marker is now an arrow along the beam direction. Co-authored-by: jon-proximafusion <174589458+jon-proximafusion@users.noreply.github.com>
Higher-statistics previews with the beam drawn as an arrowThe neutron source marker is now a green arrow at the source point, pointing along the beam (+x). The source is a monodirectional 14.1 MeV pencil beam. Rendered from 8bc6a17.
Example 3 got 4× rather than 10×. Every observation stores a photon replay bank, and at 5M histories the 14 banks would need about 80 GB of disk. Examples 1 and 2 use the nickel test chain; example 3 uses the full ENDF/B-VIII.1 chain. Example 1: moving neutron source, fixed geometryExample 2: fixed neutron source, moving activated nickelThe dark region to the right of the nickel in the later frames is the nickel shadowing itself. Activation concentrates on the beam-entry side of the sphere, and photons heading right cross about 10 cm of nickel. Example 3: fixed iron slab, nickel moves then is removed |
Example 3 in CAD (DAGMC)A CAD version of the iron slab example sits alongside the CSG one: moving_then_removed_volume_cad.py, added in 8bc6a17.
Run on a DAGMC-enabled build with 200,000 × 10 histories and the full ENDF/B-VIII.1 chain, the same settings as the CSG preview. Neutron irradiation Decay photons after shutdown Agreement with CSG
|
D1S writes a statepoint only at the final batch. A caller sourcepoint schedule such as batches [1, 3] stored in the statepoint was then no longer a subset of the statepoint batches, and the backend rejected the input. Drop the sourcepoint batches so the backend follows the statepoint, keeping the other sourcepoint options. Co-authored-by: jon-proximafusion <174589458+jon-proximafusion@users.noreply.github.com>










Summary
Adds a staged D1S capture/replay workflow for multiple neutron irradiation models followed by independently specified decay-photon transport models. The public API is exposed through
openmc.deplete.d1s:Configuration,Cells,DAGMCVolumes,Irradiation,Cooling,Simulation,Production,Observation, andResults.This supports, for example, a high-energy/high-rate irradiation in one geometry, a lower-energy/lower-rate irradiation in a second geometry, then shutdown photon transport in a third geometry with components moved or removed. It is D1S with fixed-composition production kernels, not depletion or inventory transfer.
Workflow diagram
flowchart TB subgraph production["Neutron production in static irradiation models"] A["Irradiation model A<br/>Geometry A, source spectrum A"] --> KA["Neutron transport<br/>Capture decay-photon births, do not transport them"] B["Irradiation model B<br/>Geometry B, source spectrum B"] --> KB["Neutron transport<br/>Capture decay-photon births, do not transport them"] end KA --> H["Retained production banks<br/>Positions, directions, energies, weights,<br/>parent radionuclides and component identities"] KB --> H H --> W["At each cooling observation<br/>Normalize per original neutron history<br/>and sum time-weighted contributions<br/>from all completed irradiations"] W --> C{"Component present<br/>in observation source map?"} C -->|"Explicit None"| R["Suppress this component's emission<br/>Retain its decaying history for reinsertion"] C -->|"Present"| X["Transfer each component's source<br/>T_target @ inverse(T_origin)<br/>Move positions, rotate directions, preserve energies"] X --> V["Validate destination containment<br/>and selected CSG or DAGMC instances"] G["User-supplied shutdown model<br/>Actual moved components and shielding<br/>Transforms do not edit geometry"] --> V V --> S["Weighted photon replay<br/>Sample births by physical emission weight<br/>Launch unit-weight photons, source strength 1"] S --> P["Photon transport through shutdown geometry<br/>Normal interactions, attenuation and scattering"] G --> P P --> T["Physical tally results<br/>Scale per-replay-photon results once<br/>by total photon rate Q_gamma"]Each observation is a separate static geometry snapshot, not continuous motion during tracking. Cooling changes decay weights, not photon flight time. An omitted historical component key is an error; explicit
Noneis required for removal. A zero total photon rate skips replay and transport and returns zero-valued tallies. Standard deviations describe photon transport uncertainty conditional on the sampled production banks.How transport works with moving geometry
R * (1 - exp(-λ Δt)) * exp(-λ (t - b)). Contributions from all preceding intervals are added, including repeated irradiation of the same physical component. Cooling adds no production. Reusing the sameConfigurationobject allows one production bank to be reused when only rates and durations change.T_target @ inverse(T_origin)for positions and the corresponding rotation for directions. Sampled energies are unchanged. The original nonuniform spatial, angular, energy, and parent correlations are retained rather than replacing activation with a uniform cell source.GLOBAL_IDvalues scoped to a universe, independently of runtimeauto_geom_ids.Q_gammain photons/s. Replay uses source strength 1, and returned in-memory tally means and standard deviations are multiplied byQ_gammaonce. Raw statepoints retain per-replay-photon normalization. Flux volume normalization and dose conversion remain explicit user operations.Motion is represented by discrete static geometry snapshots. There are no continuously moving surfaces during particle flight. Each irradiation and each photon observation uses a static model. Cooling time changes decay weights, not photon flight time. If a component moves during a period in which observations are needed, represent the required placements with additional configurations and cooling steps.
Removal, reinsertion, and replacement
components={'insert': None}suppresses its emission there but retains its decaying history for later reinsertion under the same identity.None.RegularMesh examples and animations
Three runnable examples, plus a CAD version of the third, cover the requested scenarios. All use the same stationary
openmc.RegularMeshfor neutron irradiation fields and decay-photon cooling fields. The source position and the activated component position are separate inputs.Use this branch's compiled OpenMC executable, configure
OPENMC_CROSS_SECTIONSand a compatibleOPENMC_CHAIN_FILE, and install Matplotlib/Pillow for GIF export. Run from the repository root with new or empty output directories:python examples/d1s_moving/moving_neutron_source.py --output moving-source-results python examples/d1s_moving/moving_activated_volume.py --output moving-volume-results python examples/d1s_moving/moving_then_removed_volume.py --output removed-volume-results # Needs a DAGMC-enabled build and pip install cad_to_dagmc cad-to-dagmc-mesher python examples/d1s_moving/moving_then_removed_volume_cad.py --output removed-volume-cad-resultsExample 3 and its CAD version need a chain with iron activation products, such as the full ENDF/B-VIII.1 chain.
Example 1: static geometry, moving neutron source
The nickel sphere, room, hydrogen shielding slab and mesh remain fixed. A 14.1 MeV neutron beam pointing along +x changes source position between three 20-minute irradiation intervals:
(-12, -4, 0),(-12, 0, 0),(-12, 4, 0)cm. Each changed neutron source has its own production configuration. After shutdown, twelve cooling observations use the same stationary photon geometry and the cumulative history of all three irradiations.The complete driver uses the shared helper in the same example directory:
neutron_flux.gifshows the moving neutron source during irradiation.photon_flux.gifshows the subsequent stationary gamma emitter as its activity and parent contributions decay. No neutron source remains active during cooling.Example 2: static neutron source, one moving activation volume
The neutron source is fixed at
(-15, 0, 0)cm, independently ofemitter_x_cm. The nickel sphere moves through x=0, 12 and 24 cm in three 20-minute irradiation intervals, while the room, shielding and tally grid remain fixed. Because the irradiation geometry changes, there are three production banks. The sameemitteridentity carries all of their history.After neutron shutdown, the sphere moves through x=24, 18, 12, 6, 0 and -6 cm during six 10-minute cooling intervals. Samples at local offsets 0 and 5 minutes produce twelve photon frames. For each frame, source points from all three irradiation banks are transferred into the current sphere placement and transported through that actual geometry.
The source never follows the sphere. Cooling configurations have no assigned neutron source; replay supplies the decay photons. The nickel sphere is the only physical volume that changes placement. The surrounding void fills the remaining space.
RegularMesh tally and animation details
The shared helper creates a fixed world-coordinate grid for every model:
The single z bin has finite 4 cm thickness. Frames show a slab-volume-averaged field, not a zero-thickness plane. For the filter order above:
The helper uses
FuncAnimationandPillowWriterto create GIFs, with one fixed logarithmic color scale across all frames. Photon units are photons/cm²/s, not dose. Neutron production tallies are separately scaled by initial neutrons/s and voxel volume. No ffmpeg or unstructured-mesh backend is needed.Each example saves:
neutron_flux.gif: three irradiation snapshots with the active neutron-source marker.photon_flux.gif: twelve cooling snapshots with the current nickel outline and source sites marked off.neutron_mesh_flux.npzandmesh_flux.npz: physical means, transport/conditional standard deviations, schedule times, source rates and positions. Photon data shape is(frame, nx, ny).Animation previews
Generated using the examples' default
(60, 40, 1)RegularMesh with ENDF/B-VIII.1 data. Examples 1 and 2 used 5 batches of 50,000 histories and the nickel test chain. Example 3 and its CAD version used 10 batches of 200,000 histories and the full ENDF/B-VIII.1 chain. Each GIF has a fixed color scale across its frames. The grid stays fixed in world coordinates. White outlines mark nickel, cyan marks the fixed hydrogen slab, a dashed silver outline marks the iron slab, and the green arrow marks the neutron source, a monodirectional 14.1 MeV pencil beam along +x (shown off during cooling).Example 1: moving neutron source, fixed geometry
Neutron irradiation: three static source positions; the nickel and surrounding geometry do not move.
Decay photons after shutdown: twelve cooling observations of the stationary activated nickel. The earlier neutron sources are off.
Example 2: fixed neutron source, moving activated nickel volume
Neutron irradiation: the source stays at
(-15, 0, 0)cm while the nickel occupies three positions.Decay photons after shutdown: twelve observations as the same activated nickel volume moves through six positions. Its cumulative activation history follows it; the neutron source is off.
Example 3: fixed iron slab, nickel moves then is removed
Same irradiation as Example 2, plus a stationary 6 cm iron slab along the bottom (y from -18 to -12 cm, z from -8 to 8 cm). It is its own
iron slabcomponent, activated mainly by Fe56(n,p)Mn56 from neutrons scattered out of the beam. It needs a chain with iron products, so these previews used the full ENDF/B-VIII.1 chain.Decay photons after shutdown: the nickel moves through x = 24, 16 and 8 cm, then the final 40-minute cooling model has no nickel cell and
'emitter': Nonein its source map. The last eight frames show only the decaying iron slab. The iron photon rate is about 60% of the nickel's at removal (4.1e8 vs ~6.7e8 photons/s), and its emission is spread over a much larger volume.The two shields behave as expected. With the nickel at x = 8 cm, its share of the flux (total minus the iron-only frame) is ~7.6e4 photons/cm²/s just above the iron and indistinguishable from zero just below it. Across the 4 cm, 0.07 g/cm³ H1 slab along y = 0, flux × r² from the nickel centre stays flat at ~5.5e7 from x = 32 to 40 cm, so there is no attenuation step.
Example 3 in CAD (DAGMC)
The iron slab, H1 slab and nickel sphere are CadQuery solids with the CSG dimensions, meshed by
cad_to_dagmcwithmeshing_backend='cad-to-dagmc-mesher'. Each model places the DAGMC universe in a padded CSG box, and components are selected withd1s.DAGMCVolumesby raw H5M volume ID (iron 1, H1 2, nickel 3). The removed state maps'emitter'to None, as in CSG.Against the CSG run, photon source rates agree to four significant figures in every frame, per-voxel flux differences divided by their combined standard deviation have mean -0.13 to 0.09 and standard deviation 0.96 to 0.99, and total mesh flux agrees within 0.3%.
These are sampled flux fields, not dose or continuous-motion tracking. Playback speed is illustrative; titles give the physical schedule times. Photon error estimates exclude neutron production-bank uncertainty. The GIF assets are hosted on a separate preview branch and pinned to an immutable commit, so generated binaries are not part of this implementation PR.
Actual sampled output
Both examples were run at their defaults: 5 batches × 5,000 histories,
(60, 40, 1)mesh, nickel test chain, and local ENDF/B-VIII.1 neutron/photon data. Each completed three neutron captures and twelve photon observations. All four GIFs were checked: three neutron frames and twelve photon frames per example. First/last PNGs were visually checked. Values below are illustrative sampled results, not reference values or a convergence claim.Example 1 (first and last printed cooling rows):
Example 2 (first and last printed cooling rows):
The last column is maximum sampled voxel photon flux in photons/cm²/s. A local maximum need not decay monotonically when the geometry moves or sampled histories change; total source strength follows cumulative decay. Photon errors remain conditional on the finite neutron banks.
These are discrete static transport snapshots. The neutron animation depicts each interval's steady irradiation field; the photon animation depicts cooling, not concurrent emission tracking during irradiation or integrated dose along a continuous travel path. The pure H1 slab is an illustrative non-decay-emitting shield, not an engineering design. Activating replacement shielding needs its own component selector/history.
Additional introductory example: cell detector and three cooling positions
This example irradiates a nickel emitter for one hour at x=0 cm, then observes its decay photons at three successive placements. The detector stays at x=60 cm. Each placement has a separately constructed, actual photon geometry and the matching component transform. The stable component name
emittercarries the original production history across the moves, even though each model has different cell/material IDs.The neutron source is stationary at
(0.0, 0.0, 0.0)and is assigned only to the irradiation model at position A.emitter_x_cmcontrols the nickel component geometry and its photon-bank transform, not the neutron source. No neutron source is assigned to positions B or C. During all Cooling observations, including position A, the workflow installs the banked decay-photon source automatically. The activated nickel moves after shutdown; the neutron source does not become a photon source.Prerequisites: build/install this branch, make its OpenMC executable available on PATH, configure nickel neutron and photon cross sections with
OPENMC_CROSS_SECTIONS, and setOPENMC_CHAIN_FILEto a compatible reaction/decay chain XML file containing the relevant nickel activation products. The chain provides D1S data; this example does not perform depletion. Keep the caller'sopenmc.libsession uninitialized. The output directories must be new or empty.What each API object means
Cells([emitter])selects the emitting material cell in that particular model. Only the nickel emitter needs a source identity here; the void detector and surrounding void do not.Configuration(model, components=..., transforms=...)associates that model-local cell with the physical identityemitterand its reference-to-global placement.configuration_at()moves the actual sphere and declares the same translation for banked births. A transform alone does not move geometry.Irradiation(configuration, duration, source_rate)adds production for the specified neutron model.source_rateis total initial neutrons/s, not local flux. The workflow enables decay-photon capture automatically.Cooling(configuration, duration, sample_times=...)advances time without adding activation. Its configuration is fixed for the whole interval. Different positions require different Cooling steps/configurations, not differentsample_timeswithin one step. Sample offsets are local to their interval;0.0observes immediately after switching placement.Simulation.prepare()runs neutron capture once for the sole irradiation configuration.evaluate()reweights and transfers that retained bank and runs photon transport for each nonzero observation. It automatically replaces the neutron source with photon replay and applies physical-rate normalization once.Results.get_tally(name, step_name, local_time)selects an already physically scaled result.Observation.global_timeincludes irradiation and all preceding cooling durations; the code subtracts the irradiation duration to report time since shutdown.The placement/time sequence is:
position-aposition-bposition-cDecay is cumulative across the entire timeline. Moving to B or C does not reset activation or cooling age and does not require another neutron calculation. The detector response changes due to both decay and the emitter's new location. This is a sequence of static observations, not emission integrated along a continuous travel path. Add more placements/intervals to approximate a sampled trajectory.
The separate
prepare()/evaluate()calls allow the same production to be reused with another cooling path or schedule, provided its irradiation steps reference the same preparedConfigurationobjects. Do not mutate those objects. Alternatively,simulation.run(output_dir='d1s-multi-position', run_kwargs={'threads': 2})performs both stages in one call. To model multiple neutron irradiation states as well, insert additionalIrradiationsteps with a new configuration for each changed neutron geometry or source spectrum.The exact example above was run using the local nickel chain and ENDF/B-VIII.1 data. It completed one neutron capture and seven photon observations. Checks confirmed translated birth positions, preserved birth directions/energies, and cumulative decay across all three placements. The particle counts are illustrative, not a claim of converged dose or full neutron/photon uncertainty.
Implementation and compatibility
Settings.d1s_source_writecapture setting and per-rank photon-bank shards, including normalization counts on empty ranks.FileSourceuniform sampling/stored-weight behavior.settings.cutoff['energy_photon'], default 1 keV), matching what ordinary transport would do at the first collision.kernel_indexin replayed source sites indexes the kernels actually returned inprovenance['kernels'].DistribcellFilterpaths.batches, so a valid sourcepoint schedule cannot become an invalid one.Physics and execution limits
Productionreuse is in-process, not an on-disk restart interface. Configurations must not be mutated after preparation.history_idis the emitting track ID and is not guaranteed to identify original external-source ancestry for shared-bank secondary tracks. The independent original-history normalization count is unaffected.Validation
develop: the D1S unit, edge-case, moving-example, settings andd1s_multimodelregression tests give 126 passed on a DAGMC build before the merge and 116 passed, 10 DAGMC skips on a non-DAGMC build after it.--updatechecks passed.git diff --checkpassed.OMPI_MCA_pml=ob1,OMPI_MCA_btl=self,sm, andOMPI_MCA_coll=^han. This is a local validation environment workaround, not an application default.