{ "cells": [ { "cell_type": "markdown", "id": "cell-00", "metadata": {}, "source": [ "# Parameters and a water state\n", "\n", "\n", "**Evidence: numerical verification.** Compute liquid water at 298.15 K and\n", "100,000 Pa, then return to the same density to check pressure closure.\n", "\n", "The canonical input is `held-cameretti-sadowski-2008/4`. Its water coefficients\n", "come from Held, Cameretti and Sadowski (2008), Table 1\n", "([paper](https://doi.org/10.1016/j.fluid.2008.06.010)); the packet retains the\n", "NIST molar mass and source-specific input conventions. Read `packet.toml`\n", "beside the parameter file for its exact provenance and use basis.\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:34.501139Z", "iopub.status.busy": "2026-10-20T20:17:34.501033Z", "iopub.status.idle": "2026-10-20T20:17:34.851040Z", "shell.execute_reply": "2026-10-20T20:17:34.850322Z" } }, "outputs": [], "source": [ "from pathlib import Path\n", "import pandas as pd\n", "from IPython.display import display\n", "from epcsaft import (\n", " Parameters,\n", " Pure,\n", " ThermochemistryStatus,\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": [ "## Resolve pressure to density\n", "\n", "`Pure` selects one component from the packet. A pressure request asks the Engine\n", "for the liquid density branch; a density request evaluates that state directly.\n", "The numerical criterion is an absolute pressure difference below 0.001 Pa.\n", "Molar density times molar mass gives mass density in kg/m³.\n" ] }, { "cell_type": "code", "execution_count": 2, "id": "cell-04", "metadata": { "execution": { "iopub.execute_input": "2026-10-20T20:17:34.853060Z", "iopub.status.busy": "2026-10-20T20:17:34.852813Z", "iopub.status.idle": "2026-10-20T20:17:34.865610Z", "shell.execute_reply": "2026-10-20T20:17:34.864750Z" } }, "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", "
Molar density / mol m^-3Mass density / kg m^-3Pressure closure / Patotal_enthalpythermal_cause
055342.16982997.0046850.000002NoneMissingRecord
\n", "
" ], "text/plain": [ " Molar density / mol m^-3 Mass density / kg m^-3 Pressure closure / Pa \\\n", "0 55342.16982 997.004685 0.000002 \n", "\n", " total_enthalpy thermal_cause \n", "0 None MissingRecord " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "parameters = Parameters.from_json(\n", " PACKETS / \"held-cameretti-sadowski-2008/4/parameters/parameters.json\",\n", " components=[\"water\"],\n", ")\n", "model = Pure(parameters)\n", "state = model.state(298.15, P=100000.0, phase=\"liquid\")\n", "density_state = model.state(298.15, rho=state.molar_density)\n", "assert abs(density_state.pressure - 100000.0) < 0.001\n", "values = dict(\n", " rho_mol_m3=state.molar_density,\n", " rho_kg_m3=state.molar_density * parameters.molar_masses[0],\n", " closure_Pa=density_state.pressure - 100000.0,\n", " total_enthalpy=state.total_enthalpy,\n", " thermal_cause=state.thermochemistry_status.name,\n", ")\n", "assert state.total_enthalpy is None\n", "assert state.thermochemistry_status == ThermochemistryStatus.MissingRecord\n", "display(\n", " pd.DataFrame([values]).rename(\n", " columns={\n", " \"rho_mol_m3\": \"Molar density / mol m^-3\",\n", " \"rho_kg_m3\": \"Mass density / kg m^-3\",\n", " \"closure_Pa\": \"Pressure closure / Pa\",\n", " }\n", " )\n", ")\n" ] }, { "cell_type": "markdown", "id": "cell-05", "metadata": {}, "source": [ "## Meaning and limits\n", "\n", "\n", "The density is a source-parameter model prediction. No observed water density\n", "is used here, so pressure closure verifies the calculation rather than physical\n", "accuracy. Missing ideal thermal inputs leave total enthalpy unavailable with\n", "`MissingRecord`; valid density and residual properties remain usable.\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 }