Skip to content

Commit

Permalink
Bit more for comp derivs
Browse files Browse the repository at this point in the history
  • Loading branch information
ianhbell committed Mar 3, 2024
1 parent ef6833e commit 745bfaf
Showing 1 changed file with 12 additions and 42 deletions.
54 changes: 12 additions & 42 deletions doc/source/derivs/compderivs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "f751a5e0",
"id": "091504b8",
"metadata": {},
"source": [
"# Composition derivatives\n",
Expand Down Expand Up @@ -40,7 +40,7 @@
},
{
"cell_type": "raw",
"id": "59ede80a",
"id": "bc68ade8",
"metadata": {
"raw_mimetype": "text/restructuredtext"
},
Expand All @@ -57,15 +57,12 @@
},
{
"cell_type": "markdown",
"id": "d46932aa",
"id": "e1ac0452",
"metadata": {},
"source": [
"## xN (in)dependent\n",
"\n",
"Let's suppose that some quantity $\\Upsilon$ depends on mole fractions. If all the mole fractions are considered to be independent, the total differential is obtained from\n",
"\n",
"$\\newcommand{\\deriv}[3]{\\left(\\frac{\\partial #1}{\\partial #2}\\right)_{#3}}$\n",
"\n",
"Let's suppose that some quantity $\\Upsilon$ depends on mole fractions. If all the mole fractions are considered to be independent, the total differential is obtained from $\\newcommand{\\deriv}[3]{\\left(\\frac{\\partial #1}{\\partial #2}\\right)_{#3}}$\n",
"$$\n",
"{\\rm d} \\Upsilon = \\sum_j\\deriv{\\Upsilon}{x_j}{x_{i\\neq j}} {\\rm d}x_j\n",
"$$\n",
Expand All @@ -88,53 +85,26 @@
"\\deriv{x_N}{x_i}{} = -1\n",
"$$\n",
"\n",
"So if the library (e.g., CoolProp and TREND) allows for the fractions to be independent, you can use the molar composition derivatives with the mole fractions treated as being indepenent to obtain derivatives with one of the mole fractions dependent on the other $N-1$ fractions."
"So if the library (e.g., CoolProp and TREND) allows for the fractions to be dependent (either option is allowed in CoolProp, TREND uses N-1 independent mole fractions), you can use the molar composition derivatives with the mole fractions treated as being independent to obtain derivatives with one of the mole fractions dependent on the other $N-1$ fractions."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "2ec44ccf",
"execution_count": null,
"id": "7cce6740",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'0.18.1.dev0'"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"import teqp, numpy as np\n",
"teqp.__version__"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "53ba18fe",
"execution_count": null,
"id": "5869e1d6",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"-0.04358738425351122\n",
"-0.21188579988125827\n",
"-0.03650566667904926\n",
"-0.07488856488580686\n",
"-0.20693890096529247\n",
"0.014468933385218725\n",
"-0.005978809921279951\n",
"-0.0027918555000108207\n",
"0.0\n"
]
}
],
"outputs": [],
"source": [
"j = {\n",
" 'components': [\"Methane\", \"Nitrogen\", \"Oxygen\"],\n",
Expand Down Expand Up @@ -206,7 +176,7 @@
},
{
"cell_type": "markdown",
"id": "594e48be",
"id": "b81e55cb",
"metadata": {},
"source": [
"With CoolProp, version 6.6.0, the following script in C++:\n",
Expand Down

0 comments on commit 745bfaf

Please sign in to comment.