From c93e5b7628230cb16681fdbf9493c461395c2743 Mon Sep 17 00:00:00 2001 From: Yeongdo Park Date: Thu, 19 Sep 2019 06:00:49 +0900 Subject: [PATCH] Initial Commit --- .gitignore | 2 + borman-exercise-3-10.ipynb | 131 ++++++++++++++++++++ borman-exercise-3-11.ipynb | 236 +++++++++++++++++++++++++++++++++++++ environment.yml | 8 ++ 4 files changed, 377 insertions(+) create mode 100644 .gitignore create mode 100644 borman-exercise-3-10.ipynb create mode 100644 borman-exercise-3-11.ipynb create mode 100644 environment.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b5f2b45 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.ipynb_checkpoints +.DS_Store diff --git a/borman-exercise-3-10.ipynb b/borman-exercise-3-10.ipynb new file mode 100644 index 0000000..a0f59b9 --- /dev/null +++ b/borman-exercise-3-10.ipynb @@ -0,0 +1,131 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Exercice 3-10 from Borman\n", + "\n", + "Consider the reaction of carbon with stoichiometric air to produce $CO_2$, $CO$, and $O_2$ at 2200 K and 2 atm pressure. \n", + "\n", + "How much $CO$ exists when the products are in equilibrium at 2200 K due to the dissociation of $CO_2$?" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Create gas phase object" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " temperature 0.001 K\n", + " pressure 0.00412448 Pa\n", + " density 0.001 kg/m^3\n", + " mean mol. weight 2.01588 amu\n", + "\n", + " 1 kg 1 kmol\n", + " ----------- ------------\n", + " enthalpy -3.786e+06 -7.632e+06 J\n", + " internal energy -3.786e+06 -7.632e+06 J\n", + " entropy 6210.9 1.252e+04 J/K\n", + " Gibbs function -3.786e+06 -7.632e+06 J\n", + " heat capacity c_p 9669.2 1.949e+04 J/K\n", + " heat capacity c_v 5544.7 1.118e+04 J/K\n", + "\n", + " X Y Chem. Pot. / RT\n", + " ------------- ------------ ------------\n", + " H2 1 1 -917934\n", + " [ +4 minor] 0 0\n", + "\n" + ] + } + ], + "source": [ + "import cantera as ct\n", + "\n", + "# Get all of the Species objects defined in the GRI 3.0 mechanism\n", + "species = {S.name: S for S in ct.Species.listFromFile('gri30.cti')}\n", + "\n", + "# Create an IdealGas object with selected species\n", + "complete_species = [species[S] for S in (str.split(' H2 O2 N2 CO2 CO '))]\n", + "cair = ct.Solution(thermo='IdealGas', species=complete_species)\n", + "\n", + "cair()" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " temperature 2200 K\n", + " pressure 202650 Pa\n", + " density 0.345633 kg/m^3\n", + " mean mol. weight 31.1979 amu\n", + "\n", + " 1 kg 1 kmol\n", + " ----------- ------------\n", + " enthalpy -2.4656e+05 -7.692e+06 J\n", + " internal energy -8.3288e+05 -2.598e+07 J\n", + " entropy 8543.1 2.665e+05 J/K\n", + " Gibbs function -1.9041e+07 -5.941e+08 J\n", + " heat capacity c_p 1319.4 4.116e+04 J/K\n", + " heat capacity c_v 1052.9 3.285e+04 J/K\n", + "\n", + " X Y Chem. Pot. / RT\n", + " ------------- ------------ ------------\n", + " O2 0.00561358 0.00575768 -33.5984\n", + " N2 0.785482 0.705306 -26.8056\n", + " CO2 0.197678 0.278857 -54.6716\n", + " CO 0.0112272 0.0100801 -37.8724\n", + " [ +1 minor] 0 0\n", + "\n" + ] + } + ], + "source": [ + "cair.X = 'N2:3.76, CO2:1.0'\n", + "cair.TP = (2200, ct.one_atm*2)\n", + "cair.equilibrate('TP')\n", + "cair()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/borman-exercise-3-11.ipynb b/borman-exercise-3-11.ipynb new file mode 100644 index 0000000..cbd6a5c --- /dev/null +++ b/borman-exercise-3-11.ipynb @@ -0,0 +1,236 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Exercice 3-11 from Borman\n", + "\n", + "## Two phase equilibrium\n", + "\n", + "Solid carbon reacts with steam at 1000 K and 1 atm to produce carbon monoxide and hydrogen.\n", + "\n", + "Find the equilibrium composition if the initial $C/O$ atom mole ratio is $1/1$ and the initial $C/H$ atom mole ratio $1/1$.\n", + "\n", + "The reaction is $C_{(s)} + H_2O = CO + H_2$ ." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Create multiphase mixture object" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "************ Phase ************\n", + "Moles: 1.0\n", + "\n", + " temperature 300 K\n", + " pressure 101325 Pa\n", + " density 0.0818891 kg/m^3\n", + " mean mol. weight 2.01588 amu\n", + "\n", + " 1 kg 1 kmol\n", + " ----------- ------------\n", + " enthalpy 26470 5.336e+04 J\n", + " internal energy -1.2109e+06 -2.441e+06 J\n", + " entropy 64914 1.309e+05 J/K\n", + " Gibbs function -1.9448e+07 -3.92e+07 J\n", + " heat capacity c_p 14312 2.885e+04 J/K\n", + " heat capacity c_v 10187 2.054e+04 J/K\n", + "\n", + " X Y Chem. Pot. / RT\n", + " ------------- ------------ ------------\n", + " H2 1 1 -15.7173\n", + " [ +2 minor] 0 0\n", + "\n", + "************ Phase graphite ************\n", + "Moles: 0.0\n", + "\n", + " graphite:\n", + "\n", + " temperature 300 K\n", + " pressure 101325 Pa\n", + " density 2160 kg/m^3\n", + " mean mol. weight 12.011 amu\n", + "\n", + " 1 kg 1 kmol\n", + " ----------- ------------\n", + " enthalpy 1318.4 1.584e+04 J\n", + " internal energy 1271.5 1.527e+04 J\n", + " entropy 481.8 5787 J/K\n", + " Gibbs function -1.4322e+05 -1.72e+06 J\n", + " heat capacity c_p 715.32 8592 J/K\n", + " heat capacity c_v 715.32 8592 J/K\n", + "\n", + " X Y Chem. Pot. / RT\n", + " ------------- ------------ ------------\n", + " C(gr) 1 1 -0.689657\n", + "\n" + ] + } + ], + "source": [ + "import cantera as ct\n", + "\n", + "# Get all of the Species objects defined in the GRI 3.0 mechanism\n", + "species = {S.name: S for S in ct.Species.listFromFile('gri30.cti')}\n", + "\n", + "# Create an IdealGas object with selected species\n", + "complete_species = [species[S] for S in (str.split(' H2 CO H2O '))]\n", + "steam = ct.Solution(thermo='IdealGas', species=complete_species)\n", + "\n", + "carbon = ct.Solution('graphite.cti')\n", + "\n", + "mix = ct.Mixture([steam, carbon])\n", + "\n", + "mix()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Set Initial Condtion and Calculate Equilibrium" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "************ Phase ************\n", + "Moles: 2.797483219797536\n", + "\n", + " temperature 1000 K\n", + " pressure 101325 Pa\n", + " density 0.242227 kg/m^3\n", + " mean mol. weight 19.8765 amu\n", + "\n", + " 1 kg 1 kmol\n", + " ----------- ------------\n", + " enthalpy -3.3612e+06 -6.681e+07 J\n", + " internal energy -3.7795e+06 -7.512e+07 J\n", + " entropy 11162 2.219e+05 J/K\n", + " Gibbs function -1.4523e+07 -2.887e+08 J\n", + " heat capacity c_p 1655 3.29e+04 J/K\n", + " heat capacity c_v 1236.7 2.458e+04 J/K\n", + "\n", + " X Y Chem. Pot. / RT\n", + " ------------- ------------ ------------\n", + " H2 0.285072 0.028912 -18.7606\n", + " CO 0.642536 0.905474 -39.3365\n", + " H2O 0.0723925 0.0656136 -56.5747\n", + "\n", + "************ Phase graphite ************\n", + "Moles: 0.202516780202464\n", + "\n", + " graphite:\n", + "\n", + " temperature 1000 K\n", + " pressure 101325 Pa\n", + " density 2160 kg/m^3\n", + " mean mol. weight 12.011 amu\n", + "\n", + " 1 kg 1 kmol\n", + " ----------- ------------\n", + " enthalpy 9.8191e+05 1.179e+07 J\n", + " internal energy 9.8186e+05 1.179e+07 J\n", + " entropy 2035.8 2.445e+04 J/K\n", + " Gibbs function -1.0538e+06 -1.266e+07 J\n", + " heat capacity c_p 1800.4 2.162e+04 J/K\n", + " heat capacity c_v 1800.4 2.162e+04 J/K\n", + "\n", + " X Y Chem. Pot. / RT\n", + " ------------- ------------ ------------\n", + " C(gr) 1 1 -1.52238\n", + "\n" + ] + } + ], + "source": [ + "mix.species_moles = 'CO:2.0, H2:1.0'\n", + "mix.T = 1000\n", + "mix.P = ct.one_atm\n", + "mix.equilibrate('TP')\n", + "\n", + "mix()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Calculate Mole Fractions" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['H2', 'CO', 'H2O', 'C(gr)']\n" + ] + } + ], + "source": [ + "print (mix.species_names)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[0.26582774 0.59916107 0.06750559 0.06750559]\n" + ] + } + ], + "source": [ + "print (mix.species_moles / mix.species_moles.sum())" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..c024871 --- /dev/null +++ b/environment.yml @@ -0,0 +1,8 @@ +name: cantera-latest +channels: + - cantera + - cantera/label/dev +dependencies: + - cantera + - matplotlib + - pandas