{ "cells": [ { "cell_type": "markdown", "id": "cell-00", "metadata": {}, "source": [ "# Methane caloric properties\n", "\n", "**Evidence: numerical verification.** Evaluate methane vapor at 298.15 K and 100,000 Pa.\n", "\n", "\n", "Gross and Sadowski (2001), Table 2\n", "([paper](https://doi.org/10.1021/ie0003887)), supplies the methane coefficients\n", "in `gross-2001-methane-ethane/3`. McBride, Zehe and Gordon (2002),\n", "[NASA/TP-2002-211556](https://ntrs.nasa.gov/citations/20020085330), Appendix D,\n", "supplies the NASA9 methane record in `nasa-glenn-2002-hda-species/1`.\n", "The packet preserves the source gas constant, 8.314510 J/(mol K), and\n", "100,000 Pa standard pressure; `ThermochemistryPacket` performs the native\n", "gas-constant conversion. The first methane interval is 200–1000 K.\n", "Zotero parent: `AQDUURW4`; PDF: `SYJLCAXZ`.\n" ] }, { "cell_type": "markdown", "id": "cell-01", "metadata": {}, "source": [ "## Read the inputs\n", "\n", "Use a repository checkout with the environment described in the installation\n", "guide. The wheel alone does not contain these data. All density, association,\n", "equilibrium and parameter-fit iterations below run in the native Engine.\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "cell-02", "metadata": { "execution": { "iopub.execute_input": "2026-10-20T20:17:32.018881Z", "iopub.status.busy": "2026-10-20T20:17:32.018748Z", "iopub.status.idle": "2026-10-20T20:17:32.341159Z", "shell.execute_reply": "2026-10-20T20:17:32.340576Z" } }, "outputs": [], "source": [ "from pathlib import Path\n", "import csv\n", "import pandas as pd\n", "from IPython.display import display\n", "from epcsaft import (\n", " Parameters,\n", " Pure,\n", " ThermochemistryPacket,\n", " ThermochemistryStatus,\n", " GAS_CONSTANT_J_PER_MOL_K,\n", " PropertyObservable,\n", " PressureActionDirection,\n", " PropertyActionStatus,\n", ")\n", "\n", "pd.set_option(\"display.max_columns\", None)\n", "pd.set_option(\"display.max_colwidth\", None)\n", "\n", "ROOT = next(\n", " folder\n", " for folder in (Path.cwd(), *Path.cwd().parents)\n", " if (folder / \"ARCHITECTURE.yaml\").is_file()\n", ")\n", "PACKETS = ROOT / \"data\" / \"packets\"\n" ] }, { "cell_type": "markdown", "id": "cell-03", "metadata": {}, "source": [ "## Attach the ideal thermal record\n", "\n", "Residual EOS parameters and ideal thermal coefficients supply different physical\n", "information. Select methane from both files in the same component order.\n" ] }, { "cell_type": "code", "execution_count": 2, "id": "cell-04", "metadata": { "execution": { "iopub.execute_input": "2026-10-20T20:17:32.342633Z", "iopub.status.busy": "2026-10-20T20:17:32.342480Z", "iopub.status.idle": "2026-10-20T20:17:32.345625Z", "shell.execute_reply": "2026-10-20T20:17:32.345057Z" } }, "outputs": [], "source": [ "parameters = Parameters.from_json(\n", " PACKETS / \"gross-2001-methane-ethane/3/parameters/parameters.json\",\n", " components=[\"methane\"],\n", ")\n", "thermal = ThermochemistryPacket(\n", " ROOT / \"data/packets/nasa-glenn-2002-hda-species/1/parameters/nasa9-records.json\"\n", ").select([\"methane\"])\n", "model = Pure(parameters, thermochemistry=thermal)\n" ] }, { "cell_type": "markdown", "id": "cell-05", "metadata": {}, "source": [ "## Compare caloric quantities and an exact action\n", "\n", "The Engine returns Ideal, Residual and Total properties. Compare the ideal\n", "values at the ideal standard density with the retained NASA9 reference row:\n", "enthalpy within 0.001 J/mol, Cp and entropy within 10⁻⁶ J/(mol K).\n", "\n", "For a dimensionless path variable, the action of enthalpy along a **1 K**\n", "temperature increment has units J/mol. Divide by that increment to obtain\n", "the partial derivative in J/(mol K). At fixed pressure this equals Cp;\n", "require a difference below 10⁻¹⁰ J/(mol K).\n" ] }, { "cell_type": "code", "execution_count": 3, "id": "cell-06", "metadata": { "execution": { "iopub.execute_input": "2026-10-20T20:17:32.346760Z", "iopub.status.busy": "2026-10-20T20:17:32.346657Z", "iopub.status.idle": "2026-10-20T20:17:32.360753Z", "shell.execute_reply": "2026-10-20T20:17:32.359937Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
QuantityIdealResidualTotal
0Enthalpy / J mol^-1-74599.999986-16.276263-74616.276249
1Cp / J mol^-1 K^-135.6913260.09352035.784846
2Entropy / J mol^-1 K^-1186.355438-0.023333186.332106
\n", "
" ], "text/plain": [ " Quantity Ideal Residual Total\n", "0 Enthalpy / J mol^-1 -74599.999986 -16.276263 -74616.276249\n", "1 Cp / J mol^-1 K^-1 35.691326 0.093520 35.784846\n", "2 Entropy / J mol^-1 K^-1 186.355438 -0.023333 186.332106" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
h_J_molcp_J_mol_Ks_J_mol_K
0-2.037268e-10-3.077787e-10-4.536105e-11
\n", "
" ], "text/plain": [ " h_J_mol cp_J_mol_K s_J_mol_K\n", "0 -2.037268e-10 -3.077787e-10 -4.536105e-11" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "state = model.state(298.15, P=100000.0, phase=\"vapor\", derived_properties=True)\n", "enthalpy_actions = model.pressure_actions(\n", " 298.15,\n", " 100000.0,\n", " phase=\"vapor\",\n", " observables=[PropertyObservable.TotalEnthalpy],\n", " directions=[PressureActionDirection(temperature=1)],\n", ")\n", "assert enthalpy_actions.results[0].status == PropertyActionStatus.Available\n", "temperature_increment_K = 1.0\n", "dh_dT = enthalpy_actions.results[0].action / temperature_increment_K\n", "error = dh_dT - state.total_isobaric_heat_capacity\n", "assert abs(error) < 1e-10\n", "reference_state = model.state(\n", " 298.15, rho=100000.0 / (GAS_CONSTANT_J_PER_MOL_K * 298.15)\n", ")\n", "with (\n", " ROOT / \"engine/tests/cases/hda-two-flash/results/nasa9_reference_check.csv\"\n", ").open() as stream:\n", " reference = next(\n", " (\n", " row\n", " for row in csv.DictReader(stream)\n", " if row[\"species\"] == \"methane\" and float(row[\"T_K\"]) == 298.15\n", " )\n", " )\n", "assert (\n", " abs(reference_state.ideal_isobaric_heat_capacity - float(reference[\"cp_expected\"]))\n", " < 1e-06\n", ")\n", "assert abs(reference_state.ideal_enthalpy - float(reference[\"h_expected\"])) < 0.001\n", "assert abs(reference_state.ideal_entropy - float(reference[\"s_expected\"])) < 1e-06\n", "values = dict(\n", " h_J_mol=state.total_enthalpy,\n", " cp_J_mol_K=state.total_isobaric_heat_capacity,\n", " dh_dT_J_mol_K=dh_dT,\n", " identity_error_J_mol_K=error,\n", " speed_m_s=state.speed_of_sound,\n", " ideal_cp_J_mol_K=reference_state.ideal_isobaric_heat_capacity,\n", " ideal_h_J_mol=reference_state.ideal_enthalpy,\n", " ideal_s_J_mol_K=reference_state.ideal_entropy,\n", ")\n", "display(\n", " pd.DataFrame(\n", " {\n", " \"Quantity\": [\n", " \"Enthalpy / J mol^-1\",\n", " \"Cp / J mol^-1 K^-1\",\n", " \"Entropy / J mol^-1 K^-1\",\n", " ],\n", " \"Ideal\": [\n", " state.ideal_enthalpy,\n", " state.ideal_isobaric_heat_capacity,\n", " state.ideal_entropy,\n", " ],\n", " \"Residual\": [\n", " state.residual_enthalpy,\n", " state.residual_isobaric_heat_capacity,\n", " state.residual_entropy,\n", " ],\n", " \"Total\": [\n", " state.total_enthalpy,\n", " state.total_isobaric_heat_capacity,\n", " state.total_entropy,\n", " ],\n", " }\n", " )\n", ")\n", "without_thermal = Pure(parameters).state(298.15, P=100000, phase=\"vapor\")\n", "assert without_thermal.total_enthalpy is None\n", "assert without_thermal.thermochemistry_status == ThermochemistryStatus.MissingRecord\n", "values[\"nasa_reference_errors\"] = {\n", " \"h_J_mol\": reference_state.ideal_enthalpy - float(reference[\"h_expected\"]),\n", " \"cp_J_mol_K\": reference_state.ideal_isobaric_heat_capacity\n", " - float(reference[\"cp_expected\"]),\n", " \"s_J_mol_K\": reference_state.ideal_entropy - float(reference[\"s_expected\"]),\n", "}\n", "display(pd.DataFrame([values[\"nasa_reference_errors\"]]))\n" ] }, { "cell_type": "code", "execution_count": 4, "id": "cell-08", "metadata": { "execution": { "iopub.execute_input": "2026-10-20T20:17:32.361918Z", "iopub.status.busy": "2026-10-20T20:17:32.361759Z", "iopub.status.idle": "2026-10-20T20:17:32.364493Z", "shell.execute_reply": "2026-10-20T20:17:32.364005Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Normalized dh/dT / J mol^-1 K^-1dh/dT minus Cp / J mol^-1 K^-1Sound speed / m s^-1NASA reference ideal Cp / J mol^-1 K^-1NASA reference ideal h / J mol^-1NASA reference ideal s / J mol^-1 K^-1
035.784846-7.105427e-15448.4475935.691326-74599.999986186.371072
\n", "
" ], "text/plain": [ " Normalized dh/dT / J mol^-1 K^-1 dh/dT minus Cp / J mol^-1 K^-1 \\\n", "0 35.784846 -7.105427e-15 \n", "\n", " Sound speed / m s^-1 NASA reference ideal Cp / J mol^-1 K^-1 \\\n", "0 448.44759 35.691326 \n", "\n", " NASA reference ideal h / J mol^-1 NASA reference ideal s / J mol^-1 K^-1 \n", "0 -74599.999986 186.371072 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "display(pd.DataFrame([{\n", " \"Normalized dh/dT / J mol^-1 K^-1\": dh_dT,\n", " \"dh/dT minus Cp / J mol^-1 K^-1\": error,\n", " \"Sound speed / m s^-1\": values[\"speed_m_s\"],\n", " \"NASA reference ideal Cp / J mol^-1 K^-1\": values[\"ideal_cp_J_mol_K\"],\n", " \"NASA reference ideal h / J mol^-1\": values[\"ideal_h_J_mol\"],\n", " \"NASA reference ideal s / J mol^-1 K^-1\": values[\"ideal_s_J_mol_K\"],\n", "}]))\n" ] }, { "cell_type": "markdown", "id": "cell-07", "metadata": {}, "source": [ "## Meaning and limits\n", "\n", "\n", "The reference comparison checks transcription and evaluation of NASA9 inputs;\n", "the derivative identity checks numerical consistency. Neither is a comparison\n", "with calorimetric measurements. Total enthalpy includes the residual correction\n", "at the real gas density, whereas ideal entropy depends on the declared density\n", "and reference pressure. Without a thermal record, total calorics are unavailable.\n" ] } ], "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.13.14" } }, "nbformat": 4, "nbformat_minor": 5 }