{ "cells": [ { "cell_type": "markdown", "id": "5d189027", "metadata": {}, "source": [ "# Critical candidate and bounded bubble continuation\n", "\n", "These calculations use Gross and Sadowski (2001) pure propane and methane/ethane\n", "packets from the source archive. Temperature is K, pressure Pa, density mol/m³,\n", "and feed amounts mol. They verify native equations, not physical measurements.\n", "A critical-equation candidate has no global stability certificate. The binary\n", "path below covers only the declared bubble branch from 180 to 200 K, not a\n", "complete envelope through a critical point. Physical uncertainty is unquantified.\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "4d07e5ce", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
T / KP / PaMaximum classified residual
0375.1400274.607730e+068.881784e-15
\n", "
" ], "text/plain": [ " T / K P / Pa Maximum classified residual\n", "0 375.140027 4.607730e+06 8.881784e-15" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from pathlib import Path\n", "import pandas as pd\n", "from IPython.display import display\n", "from epcsaft import Parameters, Pure, Mixture, equilibrium as eq\n", "\n", "ROOT = next(p for p in (Path.cwd(), *Path.cwd().parents)\n", " if (p / \"ARCHITECTURE.yaml\").is_file())\n", "packets = ROOT / \"data\" / \"packets\"\n", "propane = Pure(Parameters.from_packets(packets, [(\"gross-2001-propane/3\", [\"propane\"])]))\n", "critical = eq.critical_point(propane, T_guess=375, P_guess=1e6, rho_guess=5000)\n", "assert critical.temperature is not None\n", "assert abs(critical.temperature / 375.14002748147936 - 1) < 1e-8\n", "assert critical.critical is not None\n", "assert abs(critical.critical.eigenvalues[0]) <= critical.critical.zero_band\n", "display(pd.DataFrame({\"T / K\": [critical.temperature], \"P / Pa\": [critical.pressure],\n", " \"Maximum classified residual\": [max(map(abs, critical.classified_residuals))]}))\n" ] }, { "cell_type": "code", "execution_count": 2, "id": "2caa13ed", "metadata": {}, "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", " \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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
PathT / KP / PaMaximum classified residual
00.0000180.001.016243e+061.065814e-14
10.0125180.251.023455e+062.664535e-15
20.0250180.501.030698e+063.108624e-15
30.0375180.751.037973e+068.437695e-15
40.0500181.001.045279e+065.773160e-15
...............
770.9625199.251.666419e+062.664535e-15
780.9750199.501.676160e+069.769963e-15
790.9875199.751.685934e+061.680999e-15
801.0000200.001.695743e+065.329071e-15
811.0000200.001.695743e+061.776357e-15
\n", "

82 rows × 4 columns

\n", "
" ], "text/plain": [ " Path T / K P / Pa Maximum classified residual\n", "0 0.0000 180.00 1.016243e+06 1.065814e-14\n", "1 0.0125 180.25 1.023455e+06 2.664535e-15\n", "2 0.0250 180.50 1.030698e+06 3.108624e-15\n", "3 0.0375 180.75 1.037973e+06 8.437695e-15\n", "4 0.0500 181.00 1.045279e+06 5.773160e-15\n", ".. ... ... ... ...\n", "77 0.9625 199.25 1.666419e+06 2.664535e-15\n", "78 0.9750 199.50 1.676160e+06 9.769963e-15\n", "79 0.9875 199.75 1.685934e+06 1.680999e-15\n", "80 1.0000 200.00 1.695743e+06 5.329071e-15\n", "81 1.0000 200.00 1.695743e+06 1.776357e-15\n", "\n", "[82 rows x 4 columns]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "mixture = Mixture(Parameters.from_packets(\n", " packets, [(\"gross-2001-methane-ethane/3\", [\"methane\", \"ethane\"])]))\n", "feed = eq.Amounts({\"methane\": 0.3, \"ethane\": 0.7})\n", "start = eq.bubble_point(liquid=eq.Phase(\"L\", kind=\"liquid\"), T=180, feed=feed)\n", "target = eq.bubble_point(liquid=eq.Phase(\"L\", kind=\"liquid\"), T=200, feed=feed)\n", "options = eq.Continuation(initial_step=0.1, minimum_step=0.001,\n", " max_steps=512, max_retries_per_step=8)\n", "path = eq.continue_equilibrium(mixture, start, target, options)\n", "assert path.success and path.reached_path == 1.0, path.stop\n", "accepted = pd.DataFrame({\"Path\": path.path_values,\n", " \"T / K\": [s.temperature for s in path.states],\n", " \"P / Pa\": [s.pressure for s in path.states],\n", " \"Maximum classified residual\": [max(map(abs, s.classified_residuals)) for s in path.states]})\n", "assert abs(accepted.iloc[-1][\"T / K\"] - 200) < 1e-8\n", "assert accepted[\"Maximum classified residual\"].max() <= 1e-10\n", "display(accepted)\n" ] }, { "cell_type": "markdown", "id": "3e15d55f", "metadata": {}, "source": [ "Prediction, correction and retries run natively. The table retains every\n", "accepted temperature, pressure and classified residual; `reached_path` must be\n", "one before the final state can be called the target. No branch completeness or\n", "mixture critical-crossing claim follows from this bounded path.\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 }