This demonstrates using the ObservablesTestCase class through cantera that can compare between two version of a model. It is expected to also compare against experimental data in the future (currently not implemented).
In [ ]:
from rmgpy.tools.observablesRegression import ObservablesTestCase
from IPython.display import display, Image
from rmgpy.species import Species
In [ ]:
# Set up reactor conditions
ethane=Species().fromSMILES('CC')
argon=Species().fromSMILES('[Ar]')
methyl=Species().fromSMILES('[CH3]')
reactorTypeList = ['IdealGasReactor']
molFracList=[{ethane: 0.05, argon: 0.95}]
Plist=([3],'atm')
Tlist=([1500,1750,2000],'K')
terminationTime = ([5e-5],'s')
In [ ]:
# Set the observables that we care about
observables = {'species':[ethane, methyl]}
In [ ]:
# Create observables test case and compare the old and new models
minimal = ObservablesTestCase(title = 'Ethane Pyrolysis',
oldDir = 'data/regression/old',
newDir = 'data/regression/new',
observables = observables,
#ck2cti = False, # Set to false means we use RMG's internal conversion to Cantera objects
# rather than using cantera's ck2cti parser on the chemkin file.
)
minimal.generateConditions(reactorTypeList = reactorTypeList,
reactionTimeList = terminationTime,
molFracList = molFracList,
Tlist = Tlist,
Plist = Plist)
variablesFailed = minimal.compare(tol=0.05, plot = True)
In [ ]:
# Display the plots for the conditions
observableSpecies = observables['species']
for i in range(len(minimal.conditions)):
for j in range(len(observables['species'])):
conditionIndex = i+1
speciesLabel = observableSpecies[j].molecule[0].toSMILES()
print 'Plotting condition {0} comparison for species {1}'.format(conditionIndex, speciesLabel)
display(Image(filename="condition_{0}_species_{1}.png".format(conditionIndex, speciesLabel)))