@@ -1687,9 +1687,13 @@ def save_input_file(path, rmg):
1687
1687
if rmg .surface_site_density or rmg .binding_energies :
1688
1688
f .write ('catalystProperties(\n ' )
1689
1689
if rmg .surface_site_density :
1690
- f .write (' surface_site_density = {0!r} ,' .format (rmg .surface_site_density ) )
1690
+ f .write (' surfaceSiteDensity = ({0:g}, "{1!s}") ,' .format (rmg .surface_site_density . value , rmg . surface_site_density . units ) + ' \n ' )
1691
1691
if rmg .binding_energies :
1692
- f .write (' binding_energies = {0!r},' .format (rmg .binding_energies ))
1692
+ f .write (' bindingEnergies = {\n ' )
1693
+ for spc , be in rmg .binding_energies .items ():
1694
+ f .write (' "{0!s}": ({1:g}, "{2!s}"),\n ' .format (spc , be .value , be .units ))
1695
+ f .write (' },\n ' )
1696
+
1693
1697
f .write (')\n \n ' )
1694
1698
1695
1699
# Species
@@ -1703,17 +1707,36 @@ def save_input_file(path, rmg):
1703
1707
f .write ('"""),\n ' )
1704
1708
f .write (')\n \n ' )
1705
1709
1710
+ def format_temperature (system ):
1711
+ """Get temperature string format for reaction system, whether single value or range"""
1712
+ if system .T is not None :
1713
+ return '({0:g},"{1!s}")' .format (system .T .value , system .T .units )
1714
+
1715
+ return f'[({ system .Trange [0 ].value :g} , "{ system .Trange [0 ].units } "), ({ system .Trange [1 ].value :g} , "{ system .Trange [1 ].units } ")],'
1716
+
1706
1717
# Reaction systems
1707
1718
for system in rmg .reaction_systems :
1719
+ # TODO add ranging pressures
1708
1720
if rmg .solvent :
1709
1721
f .write ('liquidReactor(\n ' )
1710
- f .write (' temperature = ({0:g},"{1!s}"), \n ' . format ( system . T . value , system . T . units ) )
1722
+ f .write (' temperature = ' + format_temperature ( system ) + ' \n ' )
1711
1723
f .write (' initialConcentrations={\n ' )
1712
1724
for spcs , conc in system .initial_concentrations .items ():
1713
1725
f .write (' "{0!s}": ({1:g},"{2!s}"),\n ' .format (spcs .label , conc .value , conc .units ))
1726
+ elif isinstance (system , SurfaceReactor ):
1727
+ f .write ('surfaceReactor(\n ' )
1728
+ f .write (' temperature = ' + format_temperature (system ) + '\n ' )
1729
+ f .write (' initialPressure = ({0:g},"{1!s}"),\n ' .format (system .P_initial .value , system .P_initial .units ))
1730
+ f .write (' initialGasMoleFractions={\n ' )
1731
+ for spcs , molfrac in system .initial_gas_mole_fractions .items ():
1732
+ f .write (' "{0!s}": {1:g},\n ' .format (spcs .label , molfrac ))
1733
+ f .write (' },\n ' )
1734
+ f .write (' initialSurfaceCoverages={\n ' )
1735
+ for spcs , cov in system .initial_surface_coverages .items ():
1736
+ f .write (' "{0!s}": {1:g},\n ' .format (spcs .label , cov ))
1714
1737
else :
1715
1738
f .write ('simpleReactor(\n ' )
1716
- f .write (' temperature = ({0:g},"{1!s}"), \n ' . format ( system . T . value , system . T . units ) )
1739
+ f .write (' temperature = ' + format_temperature ( system ) + ' \n ' )
1717
1740
# Convert the pressure from SI pascal units to bar here
1718
1741
# Do something more fancy later for converting to user's desired units for both T and P..
1719
1742
f .write (' pressure = ({0:g},"{1!s}"),\n ' .format (system .P .value , system .P .units ))
0 commit comments