Skip to content

Commit 86cdcc9

Browse files
authored
Merge pull request #2815 from ReactionMechanismGenerator/fix/notebooks
Update Jupyter notebooks and associated codebase [RMG-Py]
2 parents 9a5490a + 21d3cfa commit 86cdcc9

21 files changed

Lines changed: 5580 additions & 74921 deletions

ipython/cantera_sensitivity_comparison.ipynb

Lines changed: 19 additions & 229 deletions
Large diffs are not rendered by default.

ipython/cantera_simulation.ipynb

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@
8080
"#job.load_chemkin_model('data/ethane_model/chem_annotated.inp',transport_file='data/ethane_model/tran.dat')\n",
8181
"\n",
8282
"# Generate the conditions based on the settings we declared earlier\n",
83-
"job.generate_conditions(reactor_type_list, reaction_time_list, mol_frac_list, Tlist, Plist)"
83+
"job.generate_conditions(reactor_type_list=reactor_type_list, reaction_time_list=reaction_time_list, \n",
84+
" mol_frac_list=mol_frac_list, Tlist=Tlist, Plist=Plist)"
8485
]
8586
},
8687
{
@@ -170,20 +171,13 @@
170171
" print('Condition {0}'.format(i+1))\n",
171172
" display(Image(filename=\"temp/{0}_mole_fractions.png\".format(i+1)))"
172173
]
173-
},
174-
{
175-
"cell_type": "code",
176-
"execution_count": null,
177-
"metadata": {},
178-
"outputs": [],
179-
"source": []
180174
}
181175
],
182176
"metadata": {
183177
"kernelspec": {
184-
"display_name": "Python [conda env:rmg_env]",
178+
"display_name": "Python 3 (ipykernel)",
185179
"language": "python",
186-
"name": "conda-env-rmg_env-py"
180+
"name": "python3"
187181
},
188182
"language_info": {
189183
"codemirror_mode": {
@@ -195,9 +189,9 @@
195189
"name": "python",
196190
"nbconvert_exporter": "python",
197191
"pygments_lexer": "ipython3",
198-
"version": "3.7.4"
192+
"version": "3.9.23"
199193
}
200194
},
201195
"nbformat": 4,
202-
"nbformat_minor": 1
196+
"nbformat_minor": 4
203197
}

ipython/combustion_model_and_ignition_delay_demo.ipynb

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@
185185
{
186186
"cell_type": "code",
187187
"execution_count": null,
188-
"metadata": {},
188+
"metadata": {
189+
"scrolled": true
190+
},
189191
"outputs": [],
190192
"source": [
191193
"import time\n",
@@ -245,12 +247,13 @@
245247
"mol_frac_list=[{species_dict[fuel_species]: fuel_stoich,\n",
246248
" species_dict[O2_species]: 1,\n",
247249
" species_dict[N2_species]: 3.76}]\n",
248-
"T_list = ([temperature],'K')\n",
249-
"P_list = ([pressure],'atm')\n",
250+
"Tlist = ([temperature],'K')\n",
251+
"Plist = ([pressure],'atm')\n",
250252
"\n",
251253
"job = Cantera(species_list=species_list, reaction_list=reaction_list, output_directory=directory)\n",
252254
"job.load_chemkin_model(os.path.join(chem_path, 'chem_annotated.inp'), os.path.join(chem_path, 'tran.dat'))\n",
253-
"job.generate_conditions(reactor_type_list, reaction_time_list, mol_frac_list, T_list, P_list)\n",
255+
"job.generate_conditions(reactor_type_list=reactor_type_list, reaction_time_list=reaction_time_list, \n",
256+
" mol_frac_list=mol_frac_list, Tlist=Tlist, Plist=Plist)\n",
254257
"\n",
255258
"alldata = job.simulate()\n",
256259
"print(\"Simulation Completed\")"
@@ -266,9 +269,7 @@
266269
{
267270
"cell_type": "code",
268271
"execution_count": null,
269-
"metadata": {
270-
"scrolled": false
271-
},
272+
"metadata": {},
272273
"outputs": [],
273274
"source": [
274275
"############### Settings ###############\n",
@@ -280,7 +281,6 @@
280281
"import pandas as pd\n",
281282
"from rmgpy.tools import plot as rmg_plot\n",
282283
"from operator import itemgetter\n",
283-
"%matplotlib notebook\n",
284284
"\n",
285285
"times = alldata[0][0].data\n",
286286
"temperatures = alldata[0][1][0].data\n",
@@ -353,9 +353,6 @@
353353
"plt.rcParams['ytick.labelsize'] = 12\n",
354354
"plt.rcParams['figure.autolayout'] = True\n",
355355
"\n",
356-
"plt.style.use('ggplot')\n",
357-
"plt.style.use('seaborn-pastel')\n",
358-
"\n",
359356
"fig = plt.figure(figsize=fsize)\n",
360357
"\n",
361358
"plt.subplot(1,2,1)\n",
@@ -418,16 +415,14 @@
418415
"outputs": [],
419416
"source": [
420417
"import cantera as ct\n",
421-
"gas = ct.Solution(os.path.join(directory, 'cantera', 'chem.cti'))\n",
418+
"gas = ct.Solution(os.path.join(directory, 'cantera', 'chem.yaml'))\n",
422419
"comp = str(species_dict[fuel_species])+\":\"+str(fuel_stoich)+\",\"+str(species_dict[O2_species])+\":1,\"+str(species_dict[N2_species])+\":3.76\"\n",
423420
"gas.TPX = temperature, pressure, comp\n",
424421
"reactor = ct.IdealGasConstPressureReactor(gas)\n",
425422
"network = ct.ReactorNet([reactor])\n",
426423
"network.advance(ign_delay_time)\n",
427424
"ROP_C = ct.ReactionPathDiagram(gas, 'C')\n",
428425
"\n",
429-
"from PIL import Image as PILimg\n",
430-
"ROP1 = plt.subplot(1,1,1)\n",
431426
"dot_file = os.path.join(directory, 'cantera', 'rxnpathC.dot')\n",
432427
"img_file = os.path.join(directory, 'cantera', 'rxnpathC.png')\n",
433428
"ROP_C.title = 'Reaction path diagram following C'\n",
@@ -439,21 +434,14 @@
439434
"fullpath = os.getcwd() + '/' + img_file\n",
440435
"display(Image(fullpath))"
441436
]
442-
},
443-
{
444-
"cell_type": "code",
445-
"execution_count": null,
446-
"metadata": {},
447-
"outputs": [],
448-
"source": []
449437
}
450438
],
451439
"metadata": {
452440
"anaconda-cloud": {},
453441
"kernelspec": {
454-
"display_name": "Python [conda env:rmg_env]",
442+
"display_name": "Python 3 (ipykernel)",
455443
"language": "python",
456-
"name": "conda-env-rmg_env-py"
444+
"name": "python3"
457445
},
458446
"language_info": {
459447
"codemirror_mode": {
@@ -465,9 +453,9 @@
465453
"name": "python",
466454
"nbconvert_exporter": "python",
467455
"pygments_lexer": "ipython3",
468-
"version": "3.7.4"
456+
"version": "3.9.23"
469457
}
470458
},
471459
"nbformat": 4,
472-
"nbformat_minor": 2
460+
"nbformat_minor": 4
473461
}

0 commit comments

Comments
 (0)