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
In [ ]:
# Set up reactor conditions
reactorType = 'IdealGasReactor'
molFracList=[{'CC': 0.05, '[Ar]': 0.95}]
Plist=([3],'atm')
Tlist=([1500,1750,2000],'K')
terminationTime = (5e-5,'s')
In [ ]:
# Set the observables that we care about
observables = {'species':['CC','[CH3]']}
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(reactorType = reactorType,
reactionTime = terminationTime,
molFracList = molFracList,
Tlist = Tlist,
Plist = Plist)
variablesFailed = minimal.compare(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]
print 'Plotting condition {0} comparison for species {1}'.format(conditionIndex, speciesLabel)
display(Image(filename="condition_{0}_species_{1}.png".format(conditionIndex, speciesLabel)))