mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
[ck2cti] Convert surface species with specific site occupancies
Entries in the species list like "C3H6(S)/2/" are now correctly identified as a species named "C3H6(S)" which occupies 2 surface sites. Fixes #444
This commit is contained in:
@@ -103,11 +103,12 @@ class InputParseError(Exception):
|
||||
|
||||
|
||||
class Species(object):
|
||||
def __init__(self, label):
|
||||
def __init__(self, label, sites=None):
|
||||
self.label = label
|
||||
self.thermo = None
|
||||
self.transport = None
|
||||
self.note = None
|
||||
self.sites = sites
|
||||
self.composition = None
|
||||
|
||||
def __str__(self):
|
||||
@@ -130,6 +131,8 @@ class Species(object):
|
||||
'transport={0},'.format(self.transport.to_cti(14+indent)))
|
||||
if self.note:
|
||||
lines.append(prefix + 'note={0!r},'.format(self.note))
|
||||
if self.sites is not None:
|
||||
lines.append(prefix + 'size={0},'.format(self.sites))
|
||||
|
||||
lines[-1] = lines[-1][:-1] + ')'
|
||||
lines.append('')
|
||||
@@ -1626,11 +1629,17 @@ class Parser(object):
|
||||
for token in tokens:
|
||||
if token.upper() == 'END':
|
||||
break
|
||||
if token.count('/') == 2:
|
||||
# species occupies a specific number of sites
|
||||
token, sites, _ = token.split('/')
|
||||
sites = float(sites)
|
||||
else:
|
||||
sites = None
|
||||
if token in self.speciesDict:
|
||||
species = self.speciesDict[token]
|
||||
self.warn('Found additional declaration of species {0}'.format(species))
|
||||
else:
|
||||
species = Species(label=token)
|
||||
species = Species(label=token, sites=sites)
|
||||
self.speciesDict[token] = species
|
||||
surf.speciesList.append(species)
|
||||
|
||||
|
||||
@@ -404,7 +404,8 @@ class chemkinConverterTest(utilities.CanteraTest):
|
||||
surf = ct.Interface('surface1.cti', 'PT_SURFACE', [gas])
|
||||
|
||||
self.assertEqual(gas.n_reactions, 11)
|
||||
self.assertEqual(surf.n_reactions, 14)
|
||||
self.assertEqual(surf.n_reactions, 15)
|
||||
self.assertEqual(surf.species('O2_Pt').size, 3)
|
||||
|
||||
# Different units for rate constants in each input file
|
||||
# 62.1 kJ/gmol = 6.21e7 J/kmol
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
SITE/PT_SURFACE/ SDEN/2.72E-9/
|
||||
_Pt_ H_Pt H2O_Pt OH_Pt O_Pt
|
||||
_Pt_ H_Pt O2_Pt/3/ H2O_Pt OH_Pt O_Pt
|
||||
END
|
||||
THERMO ALL
|
||||
300.0 1000.0 3000.0
|
||||
@@ -7,6 +7,10 @@ O_Pt 92491O 1PT 1 I 300.00 3000.00 1000.00 1
|
||||
0.19454180E+01 0.91761647E-03-0.11226719E-06-0.99099624E-10 0.24307699E-13 2
|
||||
-0.14005187E+05-0.11531663E+02-0.94986904E+00 0.74042305E-02-0.10451424E-05 3
|
||||
-0.61120420E-08 0.33787992E-11-0.13209912E+05 0.36137905E+01 4
|
||||
O2_Pt 92491O 2PT 3 I 300.00 3000.00 1000.00 1
|
||||
0.19454180E+01 0.91761647E-03-0.11226719E-06-0.99099624E-10 0.24307699E-13 2
|
||||
-0.14005187E+05-0.11531663E+02-0.94986904E+00 0.74042305E-02-0.10451424E-05 3
|
||||
-0.61120420E-08 0.33787992E-11-0.13209912E+05 0.36137905E+01 4
|
||||
H_Pt 92491H 1PT 1 I 300.00 3000.00 1000.00 1
|
||||
0.10696996E+01 0.15432230E-02-0.15500922E-06-0.16573165E-09 0.38359347E-13 2
|
||||
-0.50546128E+04-0.71555238E+01-0.13029877E+01 0.54173199E-02 0.31277972E-06 3
|
||||
@@ -51,4 +55,5 @@ END
|
||||
H_Pt + O_Pt = OH_Pt + _Pt_ 3.70E+21 0.00 11500.0
|
||||
H_Pt + OH_Pt = H2O_Pt + _Pt_ 3.70E+21 0.00 17400.0
|
||||
OH_Pt + OH_Pt = H2O_Pt + O_Pt 3.70E+21 0.00 48200.0
|
||||
O2_Pt = O2 + 3 _Pt_ 3.70E+21 0.00 11500.0
|
||||
END
|
||||
|
||||
Reference in New Issue
Block a user