Skip to content

Commit ec6f15d

Browse files
authored
Merge pull request #2404 from eepeterson/export_model_xml_on_run
adding export_to_model_xml to model.run
2 parents c5fd211 + b174e78 commit ec6f15d

File tree

177 files changed

+14801
-15430
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+14801
-15430
lines changed

openmc/model/model.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,8 @@ def import_properties(self, filename):
596596

597597
def run(self, particles=None, threads=None, geometry_debug=False,
598598
restart_file=None, tracks=False, output=True, cwd='.',
599-
openmc_exec='openmc', mpi_args=None, event_based=None):
599+
openmc_exec='openmc', mpi_args=None, event_based=None,
600+
export_model_xml=True):
600601
"""Runs OpenMC. If the C API has been initialized, then the C API is
601602
used, otherwise, this method creates the XML files and runs OpenMC via
602603
a system call. In both cases this method returns the path to the last
@@ -639,6 +640,9 @@ def run(self, particles=None, threads=None, geometry_debug=False,
639640
event_based : None or bool, optional
640641
Turns on event-based parallelism if True. If None, the value in
641642
the Settings will be used.
643+
export_model_xml : bool, optional
644+
Exports a single model.xml file rather than separate files.
645+
Defaults to True.
642646
643647
Returns
644648
-------
@@ -688,7 +692,10 @@ def run(self, particles=None, threads=None, geometry_debug=False,
688692

689693
else:
690694
# Then run via the command line
691-
self.export_to_xml()
695+
if export_model_xml:
696+
self.export_to_model_xml()
697+
else:
698+
self.export_to_xml()
692699
openmc.run(particles, threads, geometry_debug, restart_file,
693700
tracks, output, Path('.'), openmc_exec, mpi_args,
694701
event_based)

openmc/plots.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,11 +683,11 @@ def get_id(domain):
683683
if self._meshlines is not None:
684684
subelement = ET.SubElement(element, "meshlines")
685685
subelement.set("meshtype", self._meshlines['type'])
686-
if self._meshlines['id'] is not None:
686+
if 'id' in self._meshlines:
687687
subelement.set("id", str(self._meshlines['id']))
688-
if self._meshlines['linewidth'] is not None:
688+
if 'linewidth' in self._meshlines:
689689
subelement.set("linewidth", str(self._meshlines['linewidth']))
690-
if self._meshlines['color'] is not None:
690+
if 'color' in self._meshlines:
691691
subelement.set("color", ' '.join(map(
692692
str, self._meshlines['color'])))
693693

src/cell.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ CSGCell::CSGCell(pugi::xml_node cell_node)
291291
if (fill_present) {
292292
fill_ = std::stoi(get_node_value(cell_node, "fill"));
293293
if (fill_ == universe_) {
294-
fatal_error(fmt::format("Cell {} is filled with the same universe that"
294+
fatal_error(fmt::format("Cell {} is filled with the same universe that "
295295
"it is contained in.",
296296
id_));
297297
}
Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
<?xml version='1.0' encoding='utf-8'?>
2-
<geometry>
3-
<cell id="1" material="1" region="-1" universe="1" />
4-
<cell id="2" material="2" region="1" universe="1" />
5-
<cell fill="1" id="3" region="2 -3 4 -5 6 -8" rotation="10 20 30" universe="2" />
6-
<cell fill="1" id="4" region="2 -3 4 -5 8 -7" translation="0 0 15" universe="2" />
7-
<surface coeffs="1.0 0.0 0.0 5.0" id="1" type="sphere" />
8-
<surface boundary="vacuum" coeffs="-7.5" id="2" name="minimum x" type="x-plane" />
9-
<surface boundary="vacuum" coeffs="7.5" id="3" name="maximum x" type="x-plane" />
10-
<surface boundary="vacuum" coeffs="-7.5" id="4" name="minimum y" type="y-plane" />
11-
<surface boundary="vacuum" coeffs="7.5" id="5" name="maximum y" type="y-plane" />
12-
<surface boundary="vacuum" coeffs="-7.5" id="6" type="z-plane" />
13-
<surface boundary="vacuum" coeffs="22.5" id="7" type="z-plane" />
14-
<surface coeffs="7.5" id="8" type="z-plane" />
15-
</geometry>
16-
<?xml version='1.0' encoding='utf-8'?>
17-
<materials>
18-
<material depletable="true" id="1">
19-
<density units="g/cc" value="10.0" />
20-
<nuclide ao="1.0" name="U235" />
21-
</material>
22-
<material id="2">
23-
<density units="g/cc" value="0.1" />
24-
<nuclide ao="0.1" name="H1" />
25-
</material>
26-
</materials>
27-
<?xml version='1.0' encoding='utf-8'?>
28-
<settings>
29-
<run_mode>eigenvalue</run_mode>
30-
<particles>10000</particles>
31-
<batches>10</batches>
32-
<inactive>5</inactive>
33-
<source strength="1.0">
34-
<space type="box">
35-
<parameters>-4.0 -4.0 -4.0 4.0 4.0 4.0</parameters>
36-
</space>
37-
</source>
38-
</settings>
2+
<model>
3+
<materials>
4+
<material depletable="true" id="1">
5+
<density units="g/cc" value="10.0" />
6+
<nuclide ao="1.0" name="U235" />
7+
</material>
8+
<material id="2">
9+
<density units="g/cc" value="0.1" />
10+
<nuclide ao="0.1" name="H1" />
11+
</material>
12+
</materials>
13+
<geometry>
14+
<cell id="1" material="1" region="-1" universe="1" />
15+
<cell id="2" material="2" region="1" universe="1" />
16+
<cell fill="1" id="3" region="2 -3 4 -5 6 -8" rotation="10 20 30" universe="2" />
17+
<cell fill="1" id="4" region="2 -3 4 -5 8 -7" translation="0 0 15" universe="2" />
18+
<surface coeffs="1.0 0.0 0.0 5.0" id="1" type="sphere" />
19+
<surface boundary="vacuum" coeffs="-7.5" id="2" name="minimum x" type="x-plane" />
20+
<surface boundary="vacuum" coeffs="7.5" id="3" name="maximum x" type="x-plane" />
21+
<surface boundary="vacuum" coeffs="-7.5" id="4" name="minimum y" type="y-plane" />
22+
<surface boundary="vacuum" coeffs="7.5" id="5" name="maximum y" type="y-plane" />
23+
<surface boundary="vacuum" coeffs="-7.5" id="6" type="z-plane" />
24+
<surface boundary="vacuum" coeffs="22.5" id="7" type="z-plane" />
25+
<surface coeffs="7.5" id="8" type="z-plane" />
26+
</geometry>
27+
<settings>
28+
<run_mode>eigenvalue</run_mode>
29+
<particles>10000</particles>
30+
<batches>10</batches>
31+
<inactive>5</inactive>
32+
<source strength="1.0">
33+
<space type="box">
34+
<parameters>-4.0 -4.0 -4.0 4.0 4.0 4.0</parameters>
35+
</space>
36+
</source>
37+
</settings>
38+
</model>

0 commit comments

Comments
 (0)