Skip to content

Commit 5e31d49

Browse files
committed
fix liquid initial concenctrations units
1 parent 04b6be6 commit 5e31d49

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

rmgpy/rmg/input.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
from rmgpy.molecule import Molecule
4545
from rmgpy.molecule.fragment import Fragment
4646
from rmgpy.molecule.group import Group
47-
from rmgpy.quantity import Energy, Quantity, RateCoefficient, SurfaceConcentration
47+
from rmgpy.quantity import Energy, Quantity, RateCoefficient, SurfaceConcentration, Concentration
4848
from rmgpy.rmg.model import CoreEdgeReactionModel
4949
from rmgpy.rmg.reactionmechanismsimulator_reactors import (
5050
ConstantTLiquidSurfaceReactor,
@@ -659,7 +659,7 @@ def liquid_cat_reactor(temperature,
659659
concentration = Quantity(conc)
660660
# check the dimensions are ok
661661
# convert to mol/m^3 (or something numerically nice? or must it be SI)
662-
initialConcentrations[spec] = concentration.value_si
662+
initialConcentrations[spec] = concentration.value_si # is this a mistake? shouldn't this also be quantity?
663663
else:
664664
if len(conc) != 2:
665665
raise InputError("Concentration values must either be in the form of (number,units) or a list with 2 "
@@ -1756,6 +1756,9 @@ def format_initial_mole_fractions(system):
17561756
f.write(' temperature = ' + format_temperature(system) + '\n')
17571757
f.write(' initialConcentrations={\n')
17581758
for spcs, conc in system.initial_concentrations.items():
1759+
# conc may have been converted to SI, so we need to convert back
1760+
if type(conc) == float:
1761+
conc = Quantity(conc, Concentration.units)
17591762
f.write(' "{0!s}": ({1:g},"{2!s}"),\n'.format(spcs.label, conc.value, conc.units))
17601763
elif isinstance(system, SurfaceReactor):
17611764
f.write('surfaceReactor(\n')

0 commit comments

Comments
 (0)