|
38 | 38 | from rmgpy.exceptions import DatabaseError, InputError |
39 | 39 | from rmgpy.molecule import Molecule |
40 | 40 | 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 |
42 | 42 | from rmgpy.rmg.model import CoreEdgeReactionModel |
43 | 43 | from rmgpy.rmg.settings import ModelSettings, SimulatorSettings |
44 | 44 | from rmgpy.solver.termination import TerminationTime, TerminationConversion, TerminationRateRatio |
@@ -647,7 +647,7 @@ def liquid_cat_reactor(temperature, |
647 | 647 | concentration = Quantity(conc) |
648 | 648 | # check the dimensions are ok |
649 | 649 | # 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? |
651 | 651 | else: |
652 | 652 | if len(conc) != 2: |
653 | 653 | 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): |
1741 | 1741 | f.write(' temperature = ' + format_temperature(system) + '\n') |
1742 | 1742 | f.write(' initialConcentrations={\n') |
1743 | 1743 | 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) |
1744 | 1747 | f.write(' "{0!s}": ({1:g},"{2!s}"),\n'.format(spcs.label, conc.value, conc.units)) |
1745 | 1748 | elif isinstance(system, SurfaceReactor): |
1746 | 1749 | f.write('surfaceReactor(\n') |
|
0 commit comments