Skip to content

Encapsulate MC/DC models in explicit Simulation instances - #490

Merged
ilhamv merged 69 commits into
mcdc-project:devfrom
ilhamv:encapsulation
Aug 6, 2026
Merged

Encapsulate MC/DC models in explicit Simulation instances#490
ilhamv merged 69 commits into
mcdc-project:devfrom
ilhamv:encapsulation

Conversation

@ilhamv

@ilhamv ilhamv commented Jul 27, 2026

Copy link
Copy Markdown
Member

Summary of changes

This PR redesigns model construction around explicit mcdc.Simulation instances, replacing the global simulation singleton and the global settings, visualization, and run interfaces.

Each simulation now owns and compiles its complete object graph before transport. The associated compiler, input and output workflows, regression problems, public API documentation, and unit tests have been updated for the encapsulated workflow.

Types of changes

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that changes existing functionality)
  • Organization and beautification (changes which improve readability and/or accessibility)

Breaking API change

The singleton-based workflow:

mcdc.simulation.set_root_universe(cells=[cell])
mcdc.Source(...)
mcdc.Tally(...)
mcdc.settings.N_particle = 1_000
mcdc.run()

is replaced by:

simulation = mcdc.Simulation()
simulation.set_model([cell])
simulation.set_sources([source])
simulation.set_tallies([tally])
simulation.settings.N_particle = 1_000
simulation.run()

Models can also be compiled or visualized directly through the simulation instance.

Additional updates

  • Defer continuous-energy material and physics-data initialization until simulation compilation.
  • Normalize and validate Python and NumPy inputs used by sources and distributions.
  • Integrate census-based tally recombination into the simulation output workflow.
  • Update regression problems to use the explicit simulation API.
  • Expand public API docstrings with examples covering model construction, visualization, and execution.
  • Update unit tests for the encapsulated object and transport workflow.

Developer Checklist

Associated Issues and PRs

Associated Developers

@ilhamv
ilhamv requested a review from melekderman July 27, 2026 14:13
@ilhamv ilhamv linked an issue Jul 27, 2026 that may be closed by this pull request
@ilhamv ilhamv added this to the v0.15.0 milestone Jul 27, 2026
@ilhamv ilhamv linked an issue Jul 27, 2026 that may be closed by this pull request
@ilhamv

ilhamv commented Jul 30, 2026

Copy link
Copy Markdown
Member Author

Considerable customizations in the docs are introduced to get a nice documentation of the key nested objects (settings and techniques) in the Simulation class.

@nglaser3 nglaser3 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilhamv, thank you for working on the encapsulation! I am a big fan of the added "examples" to the user facing object docstrings! I have a few super minor comments, but otherwise this looks great!

Comment thread mcdc/code_factory/numba_objects_generator.py Outdated
Comment thread mcdc/object_/base.py
Comment thread mcdc/object_/base.py
Comment thread mcdc/object_/base.py Outdated
Comment thread mcdc/transport/source.py
Comment thread mcdc/object_/simulation.py
@ilhamv

ilhamv commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

Thanks for the review, @nglaser3!

@ilhamv
ilhamv merged commit bce990c into mcdc-project:dev Aug 6, 2026
@ilhamv
ilhamv deleted the encapsulation branch August 6, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants