Introduced a test suite for Chemkin-format mechanism conversions
This commit is contained in:
parent
b29438eb6d
commit
0e21bfd0e0
4 changed files with 34 additions and 7 deletions
|
|
@ -1588,7 +1588,10 @@ Example:
|
|||
|
||||
def convertMech(inputFile, thermoFile=None,
|
||||
transportFile=None, phaseName='gas',
|
||||
outName=None):
|
||||
outName=None, quiet=False):
|
||||
if quiet:
|
||||
logging.basicConfig(level=logging.ERROR)
|
||||
|
||||
# Read input mechanism files
|
||||
elements, species, reactions = loadChemkinFile(inputFile)
|
||||
|
||||
|
|
@ -1604,8 +1607,9 @@ def convertMech(inputFile, thermoFile=None,
|
|||
|
||||
# Write output file
|
||||
writeCTI(elements, species, reactions, name=phaseName, outName=outName)
|
||||
print 'Wrote CTI mechanism file to {0!r}.'.format(outName)
|
||||
print 'Mechanism contains {0} species and {1} reactions.'.format(len(species), len(reactions))
|
||||
if not quiet:
|
||||
print 'Wrote CTI mechanism file to {0!r}.'.format(outName)
|
||||
print 'Mechanism contains {0} species and {1} reactions.'.format(len(species), len(reactions))
|
||||
|
||||
################################################################################
|
||||
|
||||
|
|
|
|||
|
|
@ -144,10 +144,10 @@ addTestProgram('thermo', 'thermo')
|
|||
addTestProgram('kinetics', 'kinetics')
|
||||
|
||||
if localenv['python_package'] == 'full':
|
||||
pyTest= addTestScript('python', 'runTests.py',
|
||||
interpreter=sys.executable,
|
||||
dependencies=['testSolution.py', 'testReactors.py',
|
||||
localenv['python_module']])
|
||||
pyTest = addTestScript('python', 'runTests.py',
|
||||
interpreter=sys.executable,
|
||||
dependencies=(mglob(localenv, 'python', 'py') +
|
||||
localenv['python_module']))
|
||||
localenv.Alias('test-python', pyTest)
|
||||
env['testNames'].append('python')
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ if __name__ == '__main__':
|
|||
suite.addTests(loader.loadTestsFromName('testPureFluid'))
|
||||
suite.addTests(loader.loadTestsFromName('testEquilibrium'))
|
||||
suite.addTests(loader.loadTestsFromName('testReactors'))
|
||||
suite.addTests(loader.loadTestsFromName('testConvert'))
|
||||
|
||||
results = runner.run(suite)
|
||||
sys.exit(len(results.errors) + len(results.failures))
|
||||
|
|
|
|||
22
test/python/testConvert.py
Normal file
22
test/python/testConvert.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import os
|
||||
import unittest
|
||||
import numpy as np
|
||||
import ck2cti
|
||||
|
||||
import Cantera as ct
|
||||
|
||||
class chemkinConverterTest(unittest.TestCase):
|
||||
def test_gri30(self):
|
||||
if os.path.exists('gri30_test.cti'):
|
||||
os.remove('gri30_test.cti')
|
||||
|
||||
ck2cti.convertMech('../../data/inputs/gri30.inp',
|
||||
transportFile='../../data/transport/gri30_tran.dat',
|
||||
outName='gri30_test.cti', quiet=True)
|
||||
|
||||
ref = ct.IdealGasMix('gri30.xml')
|
||||
gas = ct.IdealGasMix('gri30_test.cti')
|
||||
|
||||
self.assertEqual(ref.speciesNames(), gas.speciesNames())
|
||||
self.assertTrue((ref.reactantStoichCoeffs() == gas.reactantStoichCoeffs()).all())
|
||||
|
||||
Loading…
Add table
Reference in a new issue