diff --git a/interfaces/python/ck2cti.py b/interfaces/python/ck2cti.py index 06846841e..6791542e2 100755 --- a/interfaces/python/ck2cti.py +++ b/interfaces/python/ck2cti.py @@ -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)) ################################################################################ diff --git a/test/SConscript b/test/SConscript index dbdc0ac6e..8ac93020f 100644 --- a/test/SConscript +++ b/test/SConscript @@ -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') diff --git a/test/python/runTests.py b/test/python/runTests.py index 1b2391c6e..fb6bd01f5 100644 --- a/test/python/runTests.py +++ b/test/python/runTests.py @@ -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)) diff --git a/test/python/testConvert.py b/test/python/testConvert.py new file mode 100644 index 000000000..c50a59416 --- /dev/null +++ b/test/python/testConvert.py @@ -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()) +