Skip to content

Commit

Permalink
Merge pull request #184 from BioSTEAMDevelopmentGroup/EOS-mixture
Browse files Browse the repository at this point in the history
EOS mixture
  • Loading branch information
yoelcortes authored Jan 28, 2024
2 parents 157ebf8 + 35d29da commit d5ab5cd
Show file tree
Hide file tree
Showing 9 changed files with 375 additions and 105 deletions.
20 changes: 10 additions & 10 deletions biosteam/units/stirred_tank_reactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,24 +393,24 @@ class AeratedBioreactor(StirredTankReactor):
>>> R1.show()
AeratedBioreactor: R1
ins...
[0] feed
[0] feed
phase: 'l', T: 305.15 K, P: 101325 Pa
flow (kmol/hr): Water 6.66e+03
Glucose 139
[1] air
[1] air
phase: 'g', T: 305.15 K, P: 101325 Pa
flow (kmol/hr): O2 730
N2 2.75e+03
flow (kmol/hr): O2 1.05e+03
N2 3.93e+03
outs...
[0] vent
[0] vent
phase: 'g', T: 305.15 K, P: 101325 Pa
flow (kmol/hr): Water 109
flow (kmol/hr): Water 136
CO2 416
O2 314
N2 2.75e+03
[1] product
O2 629
N2 3.93e+03
[1] product
phase: 'l', T: 305.15 K, P: 101325 Pa
flow (kmol/hr): Water 6.97e+03
flow (kmol/hr): Water 6.94e+03
Glucose 69.4
"""
Expand Down
62 changes: 31 additions & 31 deletions docs/tutorial/Building_a_biorefinery.ipynb

Large diffs are not rendered by default.

75 changes: 64 additions & 11 deletions docs/tutorial/Convergence.ipynb

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/tutorial/Creating_a_System.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/tutorial/Phase_equilibrium.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.4"
}
},
"nbformat": 4,
Expand Down
89 changes: 75 additions & 14 deletions docs/tutorial/Property_packages.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Creating chemicals"
"## Creating chemicals"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can first start by defining the common chemicals already in the data base:"
"Here is a demonstrative example of how to create chemicals from the databank and define new chemicals. The assumptions used here are reasonable but may not be accurate depending on the lignocellulosic feedstock:"
]
},
{
Expand Down Expand Up @@ -138,7 +138,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Mixture objects"
"## Mixture objects"
]
},
{
Expand All @@ -157,8 +157,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Mixture(\n",
" rule='ideal', ...\n",
"IdealMixture(...\n",
" include_excess_energies=False\n",
")\n"
]
Expand All @@ -167,7 +166,7 @@
"source": [
"# Note that the mixture defaults to ideal mixing rules (weighted by mol)\n",
"# and excess energies are ignored by default\n",
"mixture = tmo.Mixture.from_chemicals(chemicals)\n",
"mixture = tmo.IdealMixture.from_chemicals(chemicals)\n",
"mixture.show()"
]
},
Expand Down Expand Up @@ -264,7 +263,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Thermo objects"
"## Thermo objects"
]
},
{
Expand All @@ -285,8 +284,7 @@
"text": [
"Thermo(\n",
" chemicals=CompiledChemicals([Water, Ethanol, Octane, Glucose, Sucrose, H3PO4, P4O10, CO2, O2, Cellulose, Hemicellulose, Lignin, Flocculant, Solids, DryYeast, CaO, Ash]),\n",
" mixture=Mixture(\n",
" rule='ideal', ...\n",
" mixture=IdealMixture(...\n",
" include_excess_energies=False\n",
" ),\n",
" Gamma=DortmundActivityCoefficients,\n",
Expand Down Expand Up @@ -319,8 +317,7 @@
"text": [
"Thermo(\n",
" chemicals=CompiledChemicals([Water, Ethanol, Octane, Glucose, Sucrose, H3PO4, P4O10, CO2, O2, Cellulose, Hemicellulose, Lignin, Flocculant, Solids, DryYeast, CaO, Ash]),\n",
" mixture=Mixture(\n",
" rule='ideal', ...\n",
" mixture=IdealMixture(...\n",
" include_excess_energies=False\n",
" ),\n",
" Gamma=DortmundActivityCoefficients,\n",
Expand All @@ -335,6 +332,13 @@
"tmo.settings.get_thermo()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### More rigorous thermodynamic calculations"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -360,7 +364,7 @@
],
"source": [
"# Without Poyinting correction factors, the dew point is high\n",
"tmo.settings.set_thermo(['Butanol', 'CO2'])\n",
"tmo.settings.set_thermo(['Butanol', 'CO2'], cache=True)\n",
"eq = tmo.equilibrium\n",
"s = tmo.Stream(None, Butanol=1, CO2=10, P=1e7)\n",
"s.dew_point_at_P()"
Expand All @@ -384,11 +388,68 @@
],
"source": [
"# With Poyinting correction factors, the dew point is lower\n",
"tmo.settings.set_thermo(['Butanol', 'CO2'], PCF=eq.IdealGasPoyintingCorrectionFactors)\n",
"tmo.settings.set_thermo(['Butanol', 'CO2'], cache=True, PCF=eq.IdealGasPoyintingCorrectionFactors)\n",
"s = tmo.Stream(None, Butanol=1, CO2=10, P=1e7)\n",
"s.dew_point_at_P()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You may need more rigorous mixing rules and phase equilibrium for high-pressure processes. BioSTEAM features a wide selection of equations of state for estimating excess free energies and fugacity coefficients:"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"H_ideal_gas: -306734\n",
"MultiStream: ideal_gas\n",
"phases: ('g', 'l'), T: 160 K, P: 1e+07 Pa\n",
"composition (%): (g) H2 8.55\n",
" N2 91\n",
" CO2 0.495\n",
" --- 236 kg/hr\n",
" (l) H2 2.39e-06\n",
" N2 13\n",
" CO2 87\n",
" --- 505 kg/hr\n",
"H_eos: -499936\n",
"MultiStream: eos\n",
"phases: ('g', 'l'), T: 160 K, P: 1e+07 Pa\n",
"composition (%): (g) H2 7.75\n",
" N2 90.3\n",
" CO2 1.94\n",
" --- 260 kg/hr\n",
" (l) H2 2.51e-06\n",
" N2 9.43\n",
" CO2 90.6\n",
" --- 480 kg/hr\n"
]
}
],
"source": [
"chemicals = tmo.Chemicals(['H2', 'N2', 'CO2', 'H2O'])\n",
"tmo.settings.set_thermo(chemicals)\n",
"s_ideal_gas = tmo.Stream('ideal_gas', H2=10, N2=10, CO2=10, phase='g')\n",
"s_ideal_gas.vle(T=160, P=1e7)\n",
"print('H_ideal_gas:', round(s_ideal_gas.H))\n",
"s_ideal_gas.show('cwt')\n",
"\n",
"mixture = tmo.SRKMixture.from_chemicals(chemicals) # Soave-Redlich-Kuang EOS\n",
"tmo.settings.set_thermo(chemicals, mixture=mixture, Phi=tmo.SRKFugacityCoefficients)\n",
"s_eos = tmo.Stream('eos', H2=10, N2=10, CO2=10, phase='g')\n",
"s_eos.vle(T=160, P=1e7)\n",
"print('H_eos:', round(s_eos.H))\n",
"s_eos.show('cwt')\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -429,7 +490,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.4"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit d5ab5cd

Please sign in to comment.