{
“cells”: [
{

“cell_type”: “markdown”, “metadata”: {}, “source”: [

“# Thermodynamic equilibrium”

]

}, {

“cell_type”: “markdown”, “metadata”: {}, “source”: [

“It is not necessary to use a Stream object to use thermodynamic equilibrium methods. In fact, thermosteam makes it just as easy to compute vapor-liquid equilibrium, bubble and dew points, and fugacities. “

]

}, {

“cell_type”: “markdown”, “metadata”: {}, “source”: [

“### Fugacities”

]

}, {

“cell_type”: “markdown”, “metadata”: {}, “source”: [

“The easiest way to calculate fugacities is through LiquidFugacities and GasFugacities objects:”

]

}, {

“cell_type”: “code”, “execution_count”: 1, “metadata”: {}, “outputs”: [

{
“data”: {
“text/plain”: [

“array([43274.119, 58056.67 ])”

]

}, “execution_count”: 1, “metadata”: {}, “output_type”: “execute_result”

}

], “source”: [

“import thermosteam as tmon”, “import numpy as npn”, “chemicals = tmo.Chemicals([‘Water’, ‘Ethanol’])n”, “tmo.settings.set_thermo(chemicals)n”, “n”, “# Create a LiquidFugacities objectn”, “F_l = tmo.equilibrium.LiquidFugacities(chemicals)n”, “n”, “# Compute liquid fugacitiesn”, “liquid_molar_composition = np.array([0.72, 0.28])n”, “f_l = F_l(x=liquid_molar_composition, T=355)n”, “f_l “

]

}, {

“cell_type”: “code”, “execution_count”: 2, “metadata”: {}, “outputs”: [

{
“data”: {
“text/plain”: [

“array([43569.75, 57755.25])”

]

}, “execution_count”: 2, “metadata”: {}, “output_type”: “execute_result”

}

], “source”: [

“# Create a GasFugacities objectn”, “F_g = tmo.equilibrium.GasFugacities(chemicals)n”, “n”, “# Compute gas fugacitiesn”, “gas_molar_composition = np.array([0.43, 0.57])n”, “f_g = F_g(y=gas_molar_composition, T=355, P=101325)n”, “f_g”

]

}, {

“cell_type”: “markdown”, “metadata”: {}, “source”: [

“### Bubble and dew points”

]

}, {

“cell_type”: “markdown”, “metadata”: {}, “source”: [

“Similarly bubble and dew point can be calculated through BubblePoint and DewPoint objects:”

]

}, {

“cell_type”: “code”, “execution_count”: 3, “metadata”: {}, “outputs”: [

{
“data”: {
“text/plain”: [

“BubblePointValues(T=355.00, P=109755, IDs=(‘Water’, ‘Ethanol’), z=[0.5 0.5], y=[0.343 0.657])”

]

}, “execution_count”: 3, “metadata”: {}, “output_type”: “execute_result”

}

], “source”: [

“# Create a BubblePoint objectn”, “BP = tmo.equilibrium.BubblePoint(chemicals)n”, “molar_composition = np.array([0.5, 0.5])n”, “n”, “# Solve bubble point at constant temperaturen”, “bp = BP(z=molar_composition, T=355)n”, “bp”

]

}, {

“cell_type”: “code”, “execution_count”: 4, “metadata”: {}, “outputs”: [

{
“data”: {
“text/plain”: [

“(355,n”, ” 109755.45319869411,n”, ” (‘Water’, ‘Ethanol’),n”, ” array([0.5, 0.5]),n”, ” array([0.343, 0.657]))”

]

}, “execution_count”: 4, “metadata”: {}, “output_type”: “execute_result”

}

], “source”: [

“# Note that the result is a BubblePointValues object which contain all results as attibutesn”, “(bp.T, bp.P, bp.IDs, bp.z, bp.y)”

]

}, {

“cell_type”: “code”, “execution_count”: 5, “metadata”: {}, “outputs”: [

{
“data”: {
“text/plain”: [

“BubblePointValues(T=371.78, P=202650, IDs=(‘Water’, ‘Ethanol’), z=[0.5 0.5], y=[0.35 0.65])”

]

}, “execution_count”: 5, “metadata”: {}, “output_type”: “execute_result”

}

], “source”: [

“# Solve bubble point at constant pressuren”, “BP(z=molar_composition, P=2*101325)”

]

}, {

“cell_type”: “code”, “execution_count”: 6, “metadata”: {}, “outputs”: [

{
“data”: {
“text/plain”: [

“DewPointValues(T=355.00, P=91970, IDs=(‘Water’, ‘Ethanol’), z=[0.5 0.5], x=[0.851 0.149])”

]

}, “execution_count”: 6, “metadata”: {}, “output_type”: “execute_result”

}

], “source”: [

“# Create a DewPoint objectn”, “DP = tmo.equilibrium.DewPoint(chemicals)n”, “n”, “# Solve for dew point at constant temperautren”, “dp = DP(z=molar_composition, T=355)n”, “dp”

]

}, {

“cell_type”: “code”, “execution_count”: 7, “metadata”: {}, “outputs”: [

{
“data”: {
“text/plain”: [

“(355,n”, ” 91970.1496840849,n”, ” (‘Water’, ‘Ethanol’),n”, ” array([0.5, 0.5]),n”, ” array([0.851, 0.149]))”

]

}, “execution_count”: 7, “metadata”: {}, “output_type”: “execute_result”

}

], “source”: [

“# Note that the result is a DewPointValues object which contain all results as attibutesn”, “(dp.T, dp.P, dp.IDs, dp.z, dp.x)”

]

}, {

“cell_type”: “code”, “execution_count”: 8, “metadata”: {}, “outputs”: [

{
“data”: {
“text/plain”: [

“DewPointValues(T=376.26, P=202648, IDs=(‘Water’, ‘Ethanol’), z=[0.5 0.5], x=[0.832 0.168])”

]

}, “execution_count”: 8, “metadata”: {}, “output_type”: “execute_result”

}

], “source”: [

“# Solve for dew point at constant pressuren”, “DP(z=molar_composition, P=2*101324)”

]

}, {

“cell_type”: “markdown”, “metadata”: {}, “source”: [

“### Vapor liquid equilibrium”

]

}, {

“cell_type”: “markdown”, “metadata”: {}, “source”: [

“Vapor-liquid equilibrium can be calculated through a VLE object:”

]

}, {

“cell_type”: “code”, “execution_count”: 9, “metadata”: {}, “outputs”: [

{
“data”: {
“text/plain”: [

“VLE(imol=MaterialIndexer(n”, ” g=[(‘Water’, 0.5), (‘Ethanol’, 0.5)],n”, ” l=[(‘Water’, 0.5), (‘Ethanol’, 0.5)]),n”, ” thermal_condition=ThermalCondition(T=298.15, P=101325))”

]

}, “execution_count”: 9, “metadata”: {}, “output_type”: “execute_result”

}

], “source”: [

“# First create a material indexer for the VLE object to manage material datan”, “imol = tmo.indexer.MaterialIndexer(l=[(‘Water’, 0.5), (‘Ethanol’, 0.5)],n”, ” g=[(‘Water’, 0.5), (‘Ethanol’, 0.5)])n”, “n”, “# Create a VLE objectn”, “vle = tmo.equilibrium.VLE(imol)n”, “vle”

]

}, {

“cell_type”: “markdown”, “metadata”: {}, “source”: [

“You can call the VLE object by setting 2 degrees of freedom from the following list: n”, “n”, “* T - Temperature [K]n”, “* P - Pressure [Pa]n”, “* V - Molar vapor fractionn”, “* H - Enthalpy [kJ/hr]n”, “* y - Binary molar vapor compositionn”, “* x - Binary molar liquid compositionn”, “n”, “Here are some examples:”

]

}, {

“cell_type”: “code”, “execution_count”: 10, “metadata”: {}, “outputs”: [

{
“data”: {
“text/plain”: [

“VLE(imol=MaterialIndexer(n”, ” g=[(‘Water’, 0.6417), (‘Ethanol’, 0.8607)],n”, ” l=[(‘Water’, 0.3583), (‘Ethanol’, 0.1393)]),n”, ” thermal_condition=ThermalCondition(T=355.00, P=101325))”

]

}, “execution_count”: 10, “metadata”: {}, “output_type”: “execute_result”

}

], “source”: [

“vle(T=355, P=101325)n”, “vle”

]

}, {

“cell_type”: “code”, “execution_count”: 11, “metadata”: {}, “outputs”: [

{
“data”: {
“text/plain”: [

“VLE(imol=MaterialIndexer(n”, ” g=[(‘Water’, 0.6161), (‘Ethanol’, 0.8266)],n”, ” l=[(‘Water’, 0.3839), (‘Ethanol’, 0.1734)]),n”, ” thermal_condition=ThermalCondition(T=373.69, P=202650))”

]

}, “execution_count”: 11, “metadata”: {}, “output_type”: “execute_result”

}

], “source”: [

“mixture_enthalpy = vle.mixture.xH(imol, *vle.thermal_condition)n”, “vle(H=mixture_enthalpy, P=202650)n”, “vle”

]

}, {

“cell_type”: “code”, “execution_count”: 12, “metadata”: {}, “outputs”: [

{
“data”: {
“text/plain”: [

“VLE(imol=MaterialIndexer(n”, ” g=[(‘Water’, 0.3861), (‘Ethanol’, 0.6139)],n”, ” l=[(‘Water’, 0.6139), (‘Ethanol’, 0.3861)]),n”, ” thermal_condition=ThermalCondition(T=353.88, P=101325))”

]

}, “execution_count”: 12, “metadata”: {}, “output_type”: “execute_result”

}

], “source”: [

“vle(V=0.5, P=101325)n”, “vle”

]

}, {

“cell_type”: “code”, “execution_count”: 13, “metadata”: {}, “outputs”: [

{
“data”: {
“text/plain”: [

“VLE(imol=MaterialIndexer(n”, ” g=[(‘Water’, 0.3886), (‘Ethanol’, 0.6114)],n”, ” l=[(‘Water’, 0.6114), (‘Ethanol’, 0.3886)]),n”, ” thermal_condition=ThermalCondition(T=360.00, P=128136))”

]

}, “execution_count”: 13, “metadata”: {}, “output_type”: “execute_result”

}

], “source”: [

“vle(V=0.5, T=360)n”, “vle”

]

}, {

“cell_type”: “code”, “execution_count”: 14, “metadata”: {}, “outputs”: [

{
“data”: {
“text/plain”: [

“VLE(imol=MaterialIndexer(n”, ” g=[(‘Water’, 0.8356), (‘Ethanol’, 0.9589)],n”, ” l=[(‘Water’, 0.1644), (‘Ethanol’, 0.04109)]),n”, ” thermal_condition=ThermalCondition(T=356.25, P=128136))”

]

}, “execution_count”: 14, “metadata”: {}, “output_type”: “execute_result”

}

], “source”: [

“vle(x=np.array([0.8, 0.2]), P=101325)n”, “vle”

]

}, {

“cell_type”: “code”, “execution_count”: 15, “metadata”: {}, “outputs”: [

{
“data”: {
“text/plain”: [

“VLE(imol=MaterialIndexer(n”, ” g=[(‘Water’, 0.4691), (‘Ethanol’, 0.7036)],n”, ” l=[(‘Water’, 0.5309), (‘Ethanol’, 0.2964)]),n”, ” thermal_condition=ThermalCondition(T=356.25, P=126727))”

]

}, “execution_count”: 15, “metadata”: {}, “output_type”: “execute_result”

}

], “source”: [

“vle(y=np.array([0.4, 0.6]), T=360)n”, “vle”

]

}, {

“cell_type”: “markdown”, “metadata”: {}, “source”: [

“Note that some compositions are infeasible; so it is not advised to pass x or y unless you know what you’re doing:”

]

}, {

“cell_type”: “code”, “execution_count”: 16, “metadata”: {}, “outputs”: [], “source”: [

“vle(x=np.array([0.2, 0.8]), P=101325)”

]

}, {

“cell_type”: “markdown”, “metadata”: {}, “source”: [

“### Liquid-liquid equilibrium”

]

}, {

“cell_type”: “markdown”, “metadata”: {}, “source”: [

“Liquid-liquid equilibrium can be calculated through a LLE object:”

]

}, {

“cell_type”: “code”, “execution_count”: 17, “metadata”: {}, “outputs”: [

{
“data”: {
“text/plain”: [

“LLE(imol=MolarFlowIndexer(n”, ” L=[(‘Water’, 290.7), (‘Octane’, 0.02063), (‘Butanol’, 4.3)],n”, ” l=[(‘Water’, 13.35), (‘Octane’, 99.98), (‘Butanol’, 25.7)]),n”, ” thermal_condition=ThermalCondition(T=360.00, P=101325))”

]

}, “execution_count”: 17, “metadata”: {}, “output_type”: “execute_result”

}

], “source”: [

“tmo.settings.set_thermo([‘Water’, ‘Octane’, ‘Butanol’])n”, “imol = tmo.indexer.MolarFlowIndexer(n”, ” l=[(‘Water’, 304), (‘Butanol’, 30)],n”, ” L=[(‘Octane’, 100)])n”, “lle = tmo.equilibrium.LLE(imol)n”, “lle(T=360)n”, “lle”

]

}, {

“cell_type”: “markdown”, “metadata”: {}, “source”: [

“Pressure is not a significant factor in liquid-liquid equilibrium, so only temperature is needed.”

]

}

], “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.6”

}

}, “nbformat”: 4, “nbformat_minor”: 2

}