|
11 | 11 | "cell_type": "code", |
12 | 12 | "execution_count": null, |
13 | 13 | "metadata": { |
14 | | - "collapsed": true |
| 14 | + "collapsed": false |
15 | 15 | }, |
16 | 16 | "outputs": [], |
17 | 17 | "source": [ |
18 | | - "from rmgpy.tools.uncertainty import Uncertainty\n", |
| 18 | + "from rmgpy.tools.uncertainty import Uncertainty, ThermoParameterUncertainty, KineticParameterUncertainty\n", |
19 | 19 | "from IPython.display import display\n", |
20 | | - "import copy" |
| 20 | + "import copy\n", |
| 21 | + "import numpy" |
21 | 22 | ] |
22 | 23 | }, |
23 | 24 | { |
|
73 | 74 | }, |
74 | 75 | "outputs": [], |
75 | 76 | "source": [ |
76 | | - "uncertainty.extractSourcesFromModel()" |
| 77 | + "uncertainty.extractSourcesFromModel()\n", |
| 78 | + "uncertainty.compileAllSources()" |
77 | 79 | ] |
78 | 80 | }, |
79 | 81 | { |
|
114 | 116 | " print '\\t\\t', entry\n", |
115 | 117 | " else:\n", |
116 | 118 | " print sourceType\n", |
117 | | - " raise Exception('Kinetics source mut be Library, PDep, Rate Rules, or Training')" |
| 119 | + " raise Exception('Kinetics source must be Library, PDep, Rate Rules, or Training')" |
118 | 120 | ] |
119 | 121 | }, |
120 | 122 | { |
|
175 | 177 | "P = 1e5 # Pa " |
176 | 178 | ] |
177 | 179 | }, |
| 180 | + { |
| 181 | + "cell_type": "code", |
| 182 | + "execution_count": null, |
| 183 | + "metadata": { |
| 184 | + "collapsed": false |
| 185 | + }, |
| 186 | + "outputs": [], |
| 187 | + "source": [ |
| 188 | + "gParamEngine = ThermoParameterUncertainty()\n", |
| 189 | + "kParamEngine = KineticParameterUncertainty()" |
| 190 | + ] |
| 191 | + }, |
178 | 192 | { |
179 | 193 | "cell_type": "code", |
180 | 194 | "execution_count": null, |
|
189 | 203 | " display(rxn)\n", |
190 | 204 | " if 'Library' in source:\n", |
191 | 205 | " print 'Library reaction'\n", |
| 206 | + " print source['Library']\n", |
192 | 207 | " elif 'PDep' in source:\n", |
193 | 208 | " print 'PDep reaction'\n", |
| 209 | + " print source['PDep']\n", |
194 | 210 | " elif 'Rate Rules' in source:\n", |
195 | 211 | " print 'Rate rule estimate'\n", |
196 | 212 | " family = source['Rate Rules'][0]\n", |
|
233 | 249 | "# print reconstructedKinetics\n", |
234 | 250 | "\n", |
235 | 251 | " rxnIndex = uncertainty.reactionList.index(rxn)\n", |
236 | | - " print 'Uncertainty dln(k) = ', uncertainty.kineticInputUncertainties[rxnIndex]" |
| 252 | + " print 'Uncertainty dln(k) = ', uncertainty.kineticInputUncertainties[rxnIndex]\n", |
| 253 | + " \n", |
| 254 | + "# # Test that the partial uncertainty calculation is working\n", |
| 255 | + "# dlnk = 0.0\n", |
| 256 | + "# if 'Rate Rules' in source:\n", |
| 257 | + "# family = source['Rate Rules'][0]\n", |
| 258 | + "# sourceDict = source['Rate Rules'][1]\n", |
| 259 | + "# rules = sourceDict['rules']\n", |
| 260 | + "# training = sourceDict['training']\n", |
| 261 | + "# for ruleEntry, weight in rules:\n", |
| 262 | + "# dlnk += kParamEngine.getPartialUncertaintyValue(source, 'Rate Rules', corrParam=ruleEntry, corrFamily=family)\n", |
| 263 | + "# for ruleEntry, trainingEntry, weight in training:\n", |
| 264 | + "# dlnk += kParamEngine.getPartialUncertaintyValue(source, 'Rate Rules', corrParam=ruleEntry, corrFamily=family)\n", |
| 265 | + "# dlnk += kParamEngine.getPartialUncertaintyValue(source, 'Estimation')\n", |
| 266 | + "# elif 'PDep' in source:\n", |
| 267 | + "# dlnk += kParamEngine.getPartialUncertaintyValue(source, 'PDep', source['PDep'])\n", |
| 268 | + "# elif 'Library' in source:\n", |
| 269 | + "# dlnk += kParamEngine.getPartialUncertaintyValue(source, 'Library', source['Library'])\n", |
| 270 | + "# elif 'Training' in source:\n", |
| 271 | + "# dlnk += kParamEngine.getPartialUncertaintyValue(source, 'Training', source['Training'])\n", |
| 272 | + "# print 'Uncertainty dlnk calculated using sum of partial values = ', dlnk\n", |
| 273 | + " \n", |
| 274 | + " " |
237 | 275 | ] |
238 | 276 | }, |
239 | 277 | { |
|
259 | 297 | " for group, weight in groupList:\n", |
260 | 298 | " print '\\t\\t', group, '=', weight\n", |
261 | 299 | " \n", |
| 300 | + " \n", |
| 301 | + " \n", |
262 | 302 | " spcIndex = uncertainty.speciesList.index(species) \n", |
263 | 303 | " print ''\n", |
264 | | - " print 'Uncertainty dG = ', uncertainty.thermoInputUncertainties[spcIndex], ' kcal/mol'" |
| 304 | + " print 'Uncertainty dG = ', uncertainty.thermoInputUncertainties[spcIndex], ' kcal/mol'\n", |
| 305 | + " \n", |
| 306 | + " \n", |
| 307 | + " # Test that the partial uncertainty calculation is working\n", |
| 308 | + " dG = 0.0\n", |
| 309 | + " if 'Library' in source:\n", |
| 310 | + " dG += gParamEngine.getPartialUncertaintyValue(source, 'Library', corrParam=source['Library'])\n", |
| 311 | + " if 'QM' in source:\n", |
| 312 | + " dG += gParamEngine.getPartialUncertaintyValue(source, 'QM',corrParam=source['QM'])\n", |
| 313 | + " if 'GAV' in source:\n", |
| 314 | + " for groupType, groupList in source['GAV'].iteritems():\n", |
| 315 | + " for group, weight in groupList:\n", |
| 316 | + " dG += gParamEngine.getPartialUncertaintyValue(source, 'GAV', group, groupType)\n", |
| 317 | + " dG += gParamEngine.getPartialUncertaintyValue(source, 'Estimation')\n", |
| 318 | + " print 'Uncertainty dG calculated using sum of partial values = ', dG, ' kcal/mol'" |
| 319 | + ] |
| 320 | + }, |
| 321 | + { |
| 322 | + "cell_type": "code", |
| 323 | + "execution_count": null, |
| 324 | + "metadata": { |
| 325 | + "collapsed": false |
| 326 | + }, |
| 327 | + "outputs": [], |
| 328 | + "source": [ |
| 329 | + "# Assign correlated parameter uncertainties \n", |
| 330 | + "uncertainty.assignParameterUncertainties(correlated=True)" |
| 331 | + ] |
| 332 | + }, |
| 333 | + { |
| 334 | + "cell_type": "code", |
| 335 | + "execution_count": null, |
| 336 | + "metadata": { |
| 337 | + "collapsed": false |
| 338 | + }, |
| 339 | + "outputs": [], |
| 340 | + "source": [ |
| 341 | + "# See the thermo correlated parameter partial uncertainties\n", |
| 342 | + "uncertainty.thermoInputUncertainties" |
| 343 | + ] |
| 344 | + }, |
| 345 | + { |
| 346 | + "cell_type": "code", |
| 347 | + "execution_count": null, |
| 348 | + "metadata": { |
| 349 | + "collapsed": false, |
| 350 | + "scrolled": false |
| 351 | + }, |
| 352 | + "outputs": [], |
| 353 | + "source": [ |
| 354 | + "# See the kinetics correlated parameter partial uncertainties\n", |
| 355 | + "uncertainty.kineticInputUncertainties" |
265 | 356 | ] |
266 | 357 | } |
267 | 358 | ], |
|
281 | 372 | "name": "python", |
282 | 373 | "nbconvert_exporter": "python", |
283 | 374 | "pygments_lexer": "ipython2", |
284 | | - "version": "2.7.12" |
| 375 | + "version": "2.7.11" |
285 | 376 | } |
286 | 377 | }, |
287 | 378 | "nbformat": 4, |
|
0 commit comments