diff --git a/examples/example1c_PyARC/example1c.py b/examples/example1c_PyARC/example1c.py index d43c0182..491177f4 100644 --- a/examples/example1c_PyARC/example1c.py +++ b/examples/example1c_PyARC/example1c.py @@ -3,13 +3,20 @@ import os import watts +from astropy import units as u +# Uses Astropy for unit conversion +u.imperial.enable() # Enable imperial units +Quantity = u.Quantity params = watts.Parameters() # TH params -params['assembly_pitch'] = 20e-2 # m -params['assembly_length'] = 0.13 # m +params['assembly_pitch'] = Quantity(20, "cm") # 20e-2 m +params['assembly_length'] = Quantity(13, "cm") # 0.13 m +params['temp'] = Quantity(26.85, "Celsius") # 300 K + + params.show_summary(show_metadata=False, sort_by='key') diff --git a/examples/example1c_PyARC/pyarc_template b/examples/example1c_PyARC/pyarc_template index 54a33c6e..0db3bc8d 100644 --- a/examples/example1c_PyARC/pyarc_template +++ b/examples/example1c_PyARC/pyarc_template @@ -3,7 +3,7 @@ geometry{ materials{ material ( LEU ) { - temp = 300 + temp = {{ temp }} adens{ aden ( u235 ) = 2.0e-2 % atom density in at/barn-cm aden ( u238 ) = 2.0e-2 % atom density in at/barn-cm @@ -12,7 +12,7 @@ geometry{ lumped_element_aden( lu35 ) = 1e-3 } material ( LEU2 ) { - temp = 300 + temp = {{ temp }} adens{ aden ( u236 ) = 2.0e-2 % atom density in at/barn-cm aden ( u237 ) = 2.0e-2 % atom density in at/barn-cm diff --git a/src/watts/plugin_pyarc.py b/src/watts/plugin_pyarc.py index 201dc1c3..21ce76d5 100644 --- a/src/watts/plugin_pyarc.py +++ b/src/watts/plugin_pyarc.py @@ -138,9 +138,15 @@ def prerun(self, params: Parameters) -> None: params Parameters used by the PyARC template """ + # Render the template + # Make a copy of params and convert units if necessary + # The original params remains unchanged + + params_copy = super().convert_unit(params, unit_system='si', unit_temperature='K') + print("Pre-run for PyARC Plugin") self._run_time = time.time_ns() - super().prerun(params, filename=self.pyarc_inp_name) + super().prerun(params_copy, filename=self.pyarc_inp_name) def run(self, **kwargs: Mapping): """Run PyARC