-
Notifications
You must be signed in to change notification settings - Fork 569
Open
Description
Description
Add a description
attribute to the openmc.Model
class, allowing users to store an arbitrary description string for the model. This description should be written as an XML element in the model.xml
file when exported via export_to_model_xml
. If possible, also add support for reading the description back into the model when loading from XML via from_model_xml
.
This feature will make it easier to document models, track provenance, and automate workflows where model metadata is useful.
Proposed change:
- Add a
description
property/attribute to theModel
class, defaulting to an empty string. - Update
export_to_model_xml
to include a<description>...</description>
element right after the<model>
root tag. - Update
from_model_xml
to read the<description>
element and populate the new model attribute. - Ensure round-trip compatibility: description set on model ➜ saved in XML ➜ loaded back into Python.
- Optionally, document and test this feature.
Alternatives
- Continue to use Python-only ad-hoc attributes (not saved in XML).
- Use external metadata files (less convenient, not coupled to model).
- Overload an existing field (not semantically correct).
Compatibility
- This enhancement adds a new attribute and XML element. If implemented to be optional and default to empty, it should not break existing models or workflows.
- Models created with a description will still be readable by older OpenMC versions, which should ignore the unknown
<description>
element in XML.
Relevant code locations
openmc/model/model.py
:Model
class,export_to_model_xml
,from_model_xml
methods.- Example: model.xml export logic
Test example
- Add a test: set
model.description = "Test description"
, export to XML, reload withfrom_model_xml
, and assert the description value is preserved.
Metadata
Metadata
Assignees
Labels
No labels