Skip to content

Commit

Permalink
add export_model_xml arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Linden committed Nov 8, 2024
1 parent 339d78c commit 225a91d
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions openmc/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,8 @@ def run(self, particles=None, threads=None, geometry_debug=False,

def calculate_volumes(self, threads=None, output=True, cwd='.',
openmc_exec='openmc', mpi_args=None,
apply_volumes=True):
apply_volumes=True, export_model_xml=True,
**export_kwargs):
"""Runs an OpenMC stochastic volume calculation and, if requested,
applies volumes to the model
Expand Down Expand Up @@ -748,6 +749,13 @@ def calculate_volumes(self, threads=None, output=True, cwd='.',
apply_volumes : bool, optional
Whether apply the volume calculation results from this calculation
to the model. Defaults to applying the volumes.
export_model_xml : bool, optional
Exports a single model.xml file rather than separate files. Defaults
to True.
**export_kwargs
Keyword arguments passed to either :meth:`Model.export_to_model_xml`
or :meth:`Model.export_to_xml`.
"""

if len(self.settings.volume_calculations) == 0:
Expand All @@ -769,7 +777,10 @@ def calculate_volumes(self, threads=None, output=True, cwd='.',
openmc.lib.calculate_volumes(output)

else:
self.export_to_xml()
if export_model_xml:
self.export_to_model_xml(**export_kwargs)
else:
self.export_to_xml(**export_kwargs)
openmc.calculate_volumes(threads=threads, output=output,
openmc_exec=openmc_exec,
mpi_args=mpi_args)
Expand Down Expand Up @@ -909,7 +920,8 @@ def sample_external_source(
n_samples=n_samples, prn_seed=prn_seed
)

def plot_geometry(self, output=True, cwd='.', openmc_exec='openmc'):
def plot_geometry(self, output=True, cwd='.', openmc_exec='openmc',
export_model_xml=True, **export_kwargs):
"""Creates plot images as specified by the Model.plots attribute
.. versionadded:: 0.13.0
Expand All @@ -924,6 +936,12 @@ def plot_geometry(self, output=True, cwd='.', openmc_exec='openmc'):
openmc_exec : str, optional
Path to OpenMC executable. Defaults to 'openmc'.
This only applies to the case when not using the C API.
export_model_xml : bool, optional
Exports a single model.xml file rather than separate files. Defaults
to True.
**export_kwargs
Keyword arguments passed to either :meth:`Model.export_to_model_xml`
or :meth:`Model.export_to_xml`.
"""

Expand All @@ -937,7 +955,10 @@ def plot_geometry(self, output=True, cwd='.', openmc_exec='openmc'):
# Compute the volumes
openmc.lib.plot_geometry(output)
else:
self.export_to_xml()
if export_model_xml:
self.export_to_model_xml(**export_kwargs)
else:
self.export_to_xml(**export_kwargs)
openmc.plot_geometry(output=output, openmc_exec=openmc_exec)

def _change_py_lib_attribs(self, names_or_ids, value, obj_type,
Expand Down

0 comments on commit 225a91d

Please sign in to comment.