mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-01-09 14:08:08 -05:00
Add Ideal gas methods (#2626)
* Add ability to get at the ideal-gas properties directly Also through the python interface * And python interface files * Fixes the missing reference to ideal gas notebook
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": null,
|
||||
"id": "73e08117",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -39,17 +39,7 @@
|
||||
"execution_count": null,
|
||||
"id": "b3b3722e",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"T: 200 u: 268.7943717754444 h: 326.2041971329565 s: 3.4799573598766878 deltau: 126.2343717754444 deltah: 126.2341971329565 deltas: 2.1843673598766875\n",
|
||||
"T: 440 u: 441.7087305389626 h: 568.010346325489 s: 4.274344979641025 deltau: 126.40873053896257 deltah: 126.40034632548895 deltas: 2.1856449796410256\n",
|
||||
"T: 740 u: 670.468780219468 h: 882.8851340422626 s: 4.818538217796705 deltau: 126.44878021946806 deltah: 126.44513404226257 deltas: 2.1857382177967053\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Some check values from Moran & Shapiro, 6th edition, Table A-22\n",
|
||||
"Ts = [200, 440, 740]\n",
|
||||
@@ -59,19 +49,74 @@
|
||||
"\n",
|
||||
"for T, h0, s0, u0 in zip(Ts, hs, ss, us):\n",
|
||||
" AS = CP.AbstractState(\"HEOS\", \"Air\")\n",
|
||||
" AS.update(CP.PT_INPUTS, 101325, T)\n",
|
||||
" # Use the density obtained from Z=1\n",
|
||||
" rho = 101325/(CP.PropsSI('molemass','Air')*T)\n",
|
||||
" AS.update(CP.DmolarT_INPUTS, rho, T)\n",
|
||||
" R = AS.gas_constant()/AS.molar_mass()\n",
|
||||
" RT = R*T\n",
|
||||
" ucalc_kJkg = RT*(AS.tau()*AS.dalpha0_dTau())/1000 # kJ/kg\n",
|
||||
" hcalc_kJkg = RT*(1+AS.tau()*AS.dalpha0_dTau())/1000 # kJ/kg\n",
|
||||
" scalc_kJkgK = R*(AS.tau()*AS.dalpha0_dTau()-AS.alpha0())/1000 # kJ/kg\n",
|
||||
" scalc_kJkgK = R*(AS.tau()*AS.dalpha0_dTau()-AS.alpha0())/1000 # kJ/kg/K\n",
|
||||
" print('T:', T, 'u:', ucalc_kJkg, 'h:', hcalc_kJkg, 's:', scalc_kJkgK, 'deltau:', ucalc_kJkg-u0, 'deltah:', hcalc_kJkg-h0, 'deltas:', scalc_kJkgK-s0)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "2990c24c-5c54-4450-a6d1-871d166b1a1c",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"As of version 7.2, you can also get the ideal-gas properties directly from the model without additional work:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "f3f6353b-4fae-4ed6-8646-3604aed4d0a9",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for T, h0, s0, u0 in zip(Ts, hs, ss, us):\n",
|
||||
" AS = CP.AbstractState(\"HEOS\", \"Air\")\n",
|
||||
"\n",
|
||||
" # Use the density obtained from Z=1\n",
|
||||
" rho = 101325/(CP.PropsSI('molemass','Air')*T)\n",
|
||||
" AS.update(CP.DmolarT_INPUTS, rho, T)\n",
|
||||
" R = AS.gas_constant()/AS.molar_mass()\n",
|
||||
" RT = R*T\n",
|
||||
" ucalc_kJkg = AS.umass_idealgas()/1000 # kJ/kg\n",
|
||||
" hcalc_kJkg = AS.hmass_idealgas()/1000 # kJ/kg\n",
|
||||
" scalc_kJkgK = AS.smass_idealgas()/1000 # kJ/kg/K\n",
|
||||
" print('T:', T, 'u:', ucalc_kJkg, 'h:', hcalc_kJkg, 's:', scalc_kJkgK, 'deltau:', ucalc_kJkg-u0, 'deltah:', hcalc_kJkg-h0, 'deltas:', scalc_kJkgK-s0)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "456ee5f6-5939-4c02-8036-e2e099fc0065",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Or with the high-level interface (less efficient computationally)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "086d4495-69b5-409b-bd5e-355b1356a21e",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for T, h0, s0, u0 in zip(Ts, hs, ss, us):\n",
|
||||
" # Use the density obtained from Z=1\n",
|
||||
" rho = 101325/(CP.PropsSI('molemass','Air')*T)\n",
|
||||
" ucalc_kJkg = CP.PropsSI('Umass_idealgas','T|phase_gas',T,'Dmolar',rho,'Air')/1000 # kJ/kg\n",
|
||||
" hcalc_kJkg = CP.PropsSI('Hmass_idealgas','T|phase_gas',T,'Dmolar',rho,'Air')/1000 # kJ/kg\n",
|
||||
" scalc_kJkgK = CP.PropsSI('Smass_idealgas','T|phase_gas',T,'Dmolar',rho,'Air')/1000 # kJ/kg/K\n",
|
||||
" print('T:', T, 'u:', ucalc_kJkg, 'h:', hcalc_kJkg, 's:', scalc_kJkgK, 'deltau:', ucalc_kJkg-u0, 'deltah:', hcalc_kJkg-h0, 'deltas:', scalc_kJkgK-s0)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "py313",
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@@ -85,7 +130,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.13.1"
|
||||
"version": "3.13.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
@@ -18,3 +18,4 @@ This section includes information about the CoolProp software, listings of input
|
||||
examples.rst
|
||||
changelog.rst
|
||||
SuperAncillary.ipynb
|
||||
IdealGas.ipynb
|
||||
|
||||
Reference in New Issue
Block a user