[CTI] Allow non-integer atomicity

This allows specification of lumped species with average compositions,
such as C10.6H21.8.
This commit is contained in:
Ray Speth 2014-06-06 00:18:13 +00:00
parent 83e38480d6
commit c29ae666c0
3 changed files with 76 additions and 1 deletions

View file

@ -390,7 +390,10 @@ def getAtomicComp(atoms):
d = {}
for t in toks:
b = t.split(':')
d[b[0]] = int(b[1])
try:
d[b[0]] = int(b[1])
except ValueError:
d[b[0]] = float(b[1])
return d
def getReactionSpecies(s):

View file

@ -345,3 +345,8 @@ class CtmlConverterTest(utilities.CanteraTest):
err = e
self.assertIn('Multiply-declared species', err.args[0])
def test_noninteger_atomicity(self):
gas = ct.Solution('../data/noninteger-atomicity.cti')
self.assertNear(gas.molecular_weights[gas.species_index('CnHm')],
10.65*gas.atomic_weight('C') + 21.8*gas.atomic_weight('H'))

View file

@ -0,0 +1,67 @@
units(length = "cm", time = "s", quantity = "mol", act_energy = "cal/mol")
ideal_gas(name = "float",
elements = " O H C ",
species = """ O2 H2O CO2 CnHm """,
reactions = "all",
initial_state = state(temperature = 300.0,
pressure = OneAtm) )
species(name = "O2",
atoms = " O:2 ",
thermo = (
NASA( [ 200.00, 1000.00], [ 3.782456360E+00, -2.996734160E-03,
9.847302010E-06, -9.681295090E-09, 3.243728370E-12,
-1.063943560E+03, 3.657675730E+00] ),
NASA( [ 1000.00, 3500.00], [ 3.282537840E+00, 1.483087540E-03,
-7.579666690E-07, 2.094705550E-10, -2.167177940E-14,
-1.088457720E+03, 5.453231290E+00] )
)
)
species(name = "H2O",
atoms = " H:2 O:1 ",
thermo = (
NASA( [ 200.00, 1000.00], [ 4.198640560E+00, -2.036434100E-03,
6.520402110E-06, -5.487970620E-09, 1.771978170E-12,
-3.029372670E+04, -8.490322080E-01] ),
NASA( [ 1000.00, 3500.00], [ 3.033992490E+00, 2.176918040E-03,
-1.640725180E-07, -9.704198700E-11, 1.682009920E-14,
-3.000429710E+04, 4.966770100E+00] )
)
)
species(name = "CO2",
atoms = " C:1 O:2 ",
thermo = (
NASA( [ 200.00, 1000.00], [ 2.356773520E+00, 8.984596770E-03,
-7.123562690E-06, 2.459190220E-09, -1.436995480E-13,
-4.837196970E+04, 9.901052220E+00] ),
NASA( [ 1000.00, 3500.00], [ 3.857460290E+00, 4.414370260E-03,
-2.214814040E-06, 5.234901880E-10, -4.720841640E-14,
-4.875916600E+04, 2.271638060E+00] )
),
transport = gas_transport(
geom = "linear",
diam = 3.76,
well_depth = 244.00,
polar = 2.65,
rot_relax = 2.10),
note = "L 7/88"
)
species(name = "CnHm",
atoms = " C:10.65 H:21.8 ",
thermo = (
NASA( [ 300.00, 1000.00], [ 9.335538100E-01, 2.642457900E-02,
6.105972700E-06, -2.197749900E-08, 9.514925300E-12,
-1.395852000E+04, 1.920169100E+01] ),
NASA( [ 1000.00, 5000.00], [ 7.534136800E+00, 1.887223900E-02,
-6.271849100E-06, 9.147564900E-10, -4.783806900E-14,
-1.646751600E+04, -1.789234900E+01] )
)
)
reaction( "CnHm + 16.1 O2 => 10.65 CO2 + 10.9 H2O", [3.16000E+07, 1.8, 934])