Skip to content

Commit b397bfb

Browse files
committed
fix liquid initial concenctrations units
1 parent 6c0db09 commit b397bfb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

rmgpy/rmg/input.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from rmgpy.exceptions import DatabaseError, InputError
3939
from rmgpy.molecule import Molecule
4040
from rmgpy.molecule.group import Group
41-
from rmgpy.quantity import Quantity, Energy, RateCoefficient, SurfaceConcentration
41+
from rmgpy.quantity import Quantity, Energy, RateCoefficient, SurfaceConcentration, Concentration
4242
from rmgpy.rmg.model import CoreEdgeReactionModel
4343
from rmgpy.rmg.settings import ModelSettings, SimulatorSettings
4444
from rmgpy.solver.termination import TerminationTime, TerminationConversion, TerminationRateRatio
@@ -647,7 +647,7 @@ def liquid_cat_reactor(temperature,
647647
concentration = Quantity(conc)
648648
# check the dimensions are ok
649649
# convert to mol/m^3 (or something numerically nice? or must it be SI)
650-
initialConcentrations[spec] = concentration.value_si
650+
initialConcentrations[spec] = concentration.value_si # is this a mistake? shouldn't this also be quantity?
651651
else:
652652
if len(conc) != 2:
653653
raise InputError("Concentration values must either be in the form of (number,units) or a list with 2 "
@@ -1741,6 +1741,9 @@ def format_initial_mole_fractions(system):
17411741
f.write(' temperature = ' + format_temperature(system) + '\n')
17421742
f.write(' initialConcentrations={\n')
17431743
for spcs, conc in system.initial_concentrations.items():
1744+
# conc may have been converted to SI, so we need to convert back
1745+
if type(conc) == float:
1746+
conc = Quantity(conc, Concentration.units)
17441747
f.write(' "{0!s}": ({1:g},"{2!s}"),\n'.format(spcs.label, conc.value, conc.units))
17451748
elif isinstance(system, SurfaceReactor):
17461749
f.write('surfaceReactor(\n')

0 commit comments

Comments
 (0)