Skip to content

Commit

Permalink
Doc the reason for naming
Browse files Browse the repository at this point in the history
Closes #104
  • Loading branch information
ianhbell committed Mar 8, 2024
1 parent 4ec22ec commit 77056a9
Showing 1 changed file with 43 additions and 124 deletions.
167 changes: 43 additions & 124 deletions doc/source/derivs/derivs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,38 @@
"$$\n",
"\\frac{c_v}{R} = -\\Lambda^{\\rm tot}_{20}\n",
"$$\n",
"Isobaric specific heat ($c_p\\equiv (\\partial h/\\partial T)_p$; see Eq. 3.56 from Span \\cite{Span-BOOK-2000} for the derivation):\n",
"Isobaric specific heat ($c_p\\equiv (\\partial h/\\partial T)_p$; see Eq. 3.56 from Span for the derivation):\n",
"$$\n",
"\\frac{c_p}{R} = -\\Lambda^{\\rm tot}_{20}+\\frac{(1+\\Lambda^r_{01}-\\Lambda^r_{11})^2}{1+2\\Lambda^r_{01}+\\Lambda^r_{02}}\n",
"$$"
]
},
{
"cell_type": "raw",
"id": "4e621170",
"metadata": {
"raw_mimetype": "text/restructuredtext"
},
"source": [
"In teqp, these derivatives are obtained from methods like \n",
"\n",
"* :py:meth:`~teqp.teqp.AbstractModel.get_Arxy`\n",
"* :py:meth:`~teqp.teqp.AbstractModel.get_Ar06n`"
]
},
{
"cell_type": "markdown",
"id": "7622b9b7",
"metadata": {
"raw_mimetype": "text/restructuredtext"
},
"source": [
"where the ``A`` in this context indicates the variable $\\Lambda$ above. This naming is perhaps not ideal, since $A$ is sometimes the total Helmholtz energy, but it was a close visual mnemonic to the character $\\Lambda$."
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "2ced52fd",
"metadata": {
"execution": {
Expand All @@ -74,26 +97,15 @@
"shell.execute_reply": "2022-07-06T18:39:50.261181Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"'0.15.3'"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"import teqp\n",
"teqp.__version__"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "ca35cc29",
"metadata": {
"execution": {
Expand All @@ -110,7 +122,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "8d254c40",
"metadata": {
"execution": {
Expand All @@ -130,7 +142,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "49ee3453",
"metadata": {
"execution": {
Expand All @@ -140,18 +152,7 @@
"shell.execute_reply": "2022-07-06T18:39:50.292555Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"-0.06836660379313926"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"z = np.array([1.0])\n",
"model.get_Ar01(300,300,z)"
Expand All @@ -167,27 +168,10 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "3ae755e1",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[-0.06966138343515413,\n",
" -0.06836660379313926,\n",
" 0.0025357822532378147,\n",
" -0.00015701162203571184,\n",
" 1.6818628788290574e-05,\n",
" -2.2305940927885907e-06,\n",
" 3.8259258513417917e-07]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"model.get_Ar06n(300,300,z) # derivatives 00, 01, 02, ... 06"
]
Expand All @@ -202,19 +186,10 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "4e0609ae",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1.9 µs ± 38.5 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)\n",
"2.07 µs ± 24.8 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)\n"
]
}
],
"outputs": [],
"source": [
"%timeit model.get_Ar01(300,300,z)\n",
"%timeit model.get_Ar04n(300,300,z)"
Expand Down Expand Up @@ -251,21 +226,10 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "720e120c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-0.00023661263734465424"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"model.get_B2vir(300, z)"
]
Expand All @@ -280,26 +244,10 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "92d01992",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{2: -0.0002366126373446542,\n",
" 3: 3.001768410777936e-08,\n",
" 4: -3.2409760373816355e-12,\n",
" 5: 3.9617816466337214e-16,\n",
" 6: -4.552923983836698e-20,\n",
" 7: 5.3759278511184914e-24}"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"model.get_Bnvir(7, 300, z)"
]
Expand All @@ -316,21 +264,10 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "fa4ff386",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1.0095625628421257e-10"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"model.get_dmBnvirdTm(2, 3, 300, z) # third temperature derivative of the second virial coefficient"
]
Expand Down Expand Up @@ -362,29 +299,10 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"id": "d56640d3",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0.97884567, 0.99866748])"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"array([0.00470644, 0.00480351])"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"model = teqp.build_multifluid_model([\"CO2\",\"Argon\"], teqp.get_datapath())\n",
"T, rhovec = 300, np.array([0.3,0.4])*300 # K, mol/m^3\n",
Expand All @@ -394,6 +312,7 @@
}
],
"metadata": {
"celltoolbar": "Raw Cell Format",
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
Expand Down

0 comments on commit 77056a9

Please sign in to comment.