{
"cells": [
{
"cell_type": "markdown",
"id": "cell-00",
"metadata": {},
"source": [
"# Ammonia synthesis equilibrium\n",
"\n",
"\n",
"**Evidence: numerical verification**, plus source-parameter predictions.\n",
"Study N₂ + 3 H₂ ⇌ 2 NH₃ at **573.15 K**, one declared vapor phase, feed\n",
"1 mol N₂ + 3 mol H₂, and pressures 100, 1000, 100,000 and 20,000,000 Pa.\n",
"\n",
"Pure parameters come from Gross and Sadowski (2001), Table 2, nitrogen\n",
"([paper](https://doi.org/10.1021/ie0003887)); Ghosh, Chapman and French (2003),\n",
"Table 1, p. 233, hydrogen (`hda-pc-saft/1`); and Esper et al. (2023), pinned\n",
"FeOs `esper2023.json[1714]`, ammonia\n",
"([paper](https://doi.org/10.1021/acs.iecr.3c02255)). These are published pure\n",
"records assembled for teaching, without a fitted ternary parameter set.\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:19.089478Z",
"iopub.status.busy": "2026-10-20T20:17:19.089382Z",
"iopub.status.idle": "2026-10-20T20:17:19.534234Z",
"shell.execute_reply": "2026-10-20T20:17:19.533769Z"
}
},
"outputs": [],
"source": [
"from pathlib import Path\n",
"import json\n",
"import math\n",
"import pandas as pd\n",
"from IPython.display import display\n",
"from epcsaft import (\n",
" Parameters,\n",
" Mixture,\n",
" GAS_CONSTANT_J_PER_MOL_K,\n",
")\n",
"from epcsaft import equilibrium as eq\n",
"from epcsaft import ThermochemistryRecord, IdealInterval, IdealCorrelation, IdealShomate\n",
"\n",
"# Start the kernel anywhere within the documented repository checkout.\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": [
"## Assemble the three canonical pure records\n",
"\n",
"Read the named components from their packets and preserve the coefficient\n",
"locators. All three unlike binary interaction parameters **kᵢⱼ = 0** are an\n",
"explicit teaching assumption. Ammonia's source dipole coordinates are zero;\n",
"omit that zero contribution exactly and retain its donor/acceptor association\n",
"pair (energy/k 200 K, volume 0.0001). The resulting model is nonpolar with\n",
"general-site association. No cross-site pair exists on N₂ or H₂.\n",
"\n",
"Nitrogen was fitted at 63–126 K, so **573.15 K is extrapolation**. Hydrogen's\n",
"source basis is about 462.5–583.5 K and 1.5–247 bar; the dilute-pressure checks\n",
"are outside that pressure fit range. Esper's retained ammonia row asserts no\n",
"per-record fit interval. Its SI attribution and CC BY-NC use basis remain\n",
"with the packet; this notebook does not relicense those sources.\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "cell-04",
"metadata": {
"execution": {
"iopub.execute_input": "2026-10-20T20:17:19.535848Z",
"iopub.status.busy": "2026-10-20T20:17:19.535686Z",
"iopub.status.idle": "2026-10-20T20:17:19.597525Z",
"shell.execute_reply": "2026-10-20T20:17:19.596897Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Species | \n",
" dispersion_energy_over_k | \n",
" segment_count | \n",
" segment_diameter | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" nitrogen | \n",
" 90.96000 | \n",
" 1.20530 | \n",
" 3.3130 | \n",
"
\n",
" \n",
" | 1 | \n",
" hydrogen | \n",
" 19.27750 | \n",
" 1.00000 | \n",
" 2.9860 | \n",
"
\n",
" \n",
" | 2 | \n",
" ammonia | \n",
" 213.57063 | \n",
" 2.44608 | \n",
" 2.3709 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Species dispersion_energy_over_k segment_count segment_diameter\n",
"0 nitrogen 90.96000 1.20530 3.3130\n",
"1 hydrogen 19.27750 1.00000 2.9860\n",
"2 ammonia 213.57063 2.44608 2.3709"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from copy import deepcopy\n",
"from itertools import combinations\n",
"\n",
"sources = [\n",
" (\"gross-sadowski-2001/3\", \"nitrogen\"),\n",
" (\"hda-pc-saft/1\", \"hydrogen\"),\n",
" (\"feos-esper-2023/1\", \"ammonia\"),\n",
"]\n",
"components = []\n",
"for packet, species in sources:\n",
" document = json.loads((PACKETS / packet / \"parameters/parameters.json\").read_text())\n",
" component = deepcopy(\n",
" next((c for c in document[\"components\"] if c[\"component_id\"] == species))\n",
" )\n",
" if species == \"ammonia\":\n",
" polar = [\n",
" c\n",
" for c in component[\"coefficients\"]\n",
" if c[\"family\"] in (\"dipole_moment\", \"dipole_count\")\n",
" ]\n",
" assert all((c[\"value\"][\"magnitude\"] == 0 for c in polar))\n",
" component[\"coefficients\"] = [\n",
" c for c in component[\"coefficients\"] if c not in polar\n",
" ]\n",
" sites = [\n",
" s for s in document[\"topology\"][\"sites\"] if s[\"component_id\"] == species\n",
" ]\n",
" edges = [\n",
" e\n",
" for e in document[\"topology\"][\"edges\"]\n",
" if e[\"endpoint_a\"][\"component_id\"] == species\n",
" and e[\"endpoint_b\"][\"component_id\"] == species\n",
" ]\n",
" components.append(component)\n",
"pairs = [\n",
" {\n",
" \"component_id_a\": a,\n",
" \"component_id_b\": b,\n",
" \"coefficients\": [\n",
" {\n",
" \"identity\": f\"pair/{a}/{b}/k_ij\",\n",
" \"family\": \"k_ij\",\n",
" \"value\": {\"magnitude\": 0.0, \"unit\": \"dimensionless\"},\n",
" }\n",
" ],\n",
" }\n",
" for a, b in combinations([c[\"component_id\"] for c in components], 2)\n",
"]\n",
"mapping = dict(\n",
" schema=\"epcsaft.parameters\",\n",
" schema_version=1,\n",
" components=components,\n",
" correlations=[],\n",
" pairs=pairs,\n",
" model_coefficients=[],\n",
" topology=dict(sites=sites, edges=edges, no_cross_association=[]),\n",
" model_families=[f for f in document[\"model_families\"] if f[\"kind\"] != \"polar\"],\n",
")\n",
"parameters = Parameters.from_mapping(mapping)\n",
"model = Mixture(parameters)\n",
"display(\n",
" pd.DataFrame(\n",
" [\n",
" {\n",
" \"Species\": c[\"component_id\"],\n",
" **{v[\"family\"]: v[\"value\"][\"magnitude\"] for v in c[\"coefficients\"]},\n",
" }\n",
" for c in components\n",
" ]\n",
" )\n",
")\n",
"\n",
"charges = [c[\"fixed\"][\"charge_number\"][\"value\"][\"magnitude\"] for c in components]\n",
"assert charges == [0, 0, 0]\n"
]
},
{
"cell_type": "markdown",
"id": "cell-05",
"metadata": {},
"source": [
"## Check the thermochemical scalar and solve at fixed temperature\n",
"\n",
"The gas Shomate rows are from the NIST Chemistry WebBook:\n",
"[N₂](https://webbook.nist.gov/cgi/cbook.cgi?ID=C7727379&Type=JANAFG),\n",
"[H₂](https://webbook.nist.gov/cgi/cbook.cgi?ID=C1333740&Type=JANAFG),\n",
"[NH₃](https://webbook.nist.gov/cgi/cbook.cgi?ID=C7664417&Mask=1), citing Chase\n",
"(1998). The intervals are 500–2000 K, 298–1000 K and 298–1400 K, respectively.\n",
"The coefficient rows below retain A–H and set formation enthalpy to 1000 H\n",
"J/mol. The standard pressure is P° = 100,000 Pa. Chase's Zotero record is\n",
"`CWCVM9IE`, snapshot `VXZKCLGY`; no full Chase PDF is claimed.\n",
"\n",
"The native thermal model evaluates ideal h − Ts at density P°/(RT).\n",
"Verify the declared ln Kp = −5.4047677937089755 within 10⁻⁸ J/mol on the\n",
"reaction Gibbs energy. For Δν = −2 and ρ° = 1 mol/m³, check\n",
"\n",
"$$\\ln K_\\rho = \\ln K_p - \\Delta\\nu\\ln(RT\\rho^\\circ/P^\\circ)$$\n",
"\n",
"within 10⁻¹² in ln K. Supply only the fixed scalar Kρ to the native reaction\n",
"solve. A constant Kρ and the Shomate temperature derivatives would be\n",
"inconsistent if both were supplied as reaction standards. Keep T fixed;\n",
"do not request reacting caloric derivatives from this declaration.\n",
"\n",
"Python only checks balances and the independent mass-action relation\n",
"Σνᵢ[ln(xᵢP/P°) + ln φᵢ] − ln Kp. Require atom balances within 10⁻¹⁰ mol,\n",
"positive amounts, normalized fractions within 10⁻¹², positive pressure slope,\n",
"pressure closure within 10⁻¹⁰ relative, classified residuals at most 10⁻¹⁰\n",
"and independent mass action within 10⁻⁹. All species are uncharged.\n",
"\n",
"For the independent analytic ideal comparison, use\n",
"$a=\\sqrt{27K_p}(P/P^\\circ)/16$ and\n",
"$y=2a/(1+2a+\\sqrt{1+4a})$.\n",
"Require relative agreement within 10⁻⁴ at 100/1000 Pa and a visible difference\n",
"above 2% at 200 bar. This algebra is a verification, not a Python root find.\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "cell-06",
"metadata": {
"execution": {
"iopub.execute_input": "2026-10-20T20:17:19.598800Z",
"iopub.status.busy": "2026-10-20T20:17:19.598638Z",
"iopub.status.idle": "2026-10-20T20:17:19.660309Z",
"shell.execute_reply": "2026-10-20T20:17:19.659680Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" P_Pa | \n",
" ideal_ammonia_fraction | \n",
" relative_ideal_difference | \n",
" classified_residual | \n",
" ln_mass_action_residual | \n",
" pressure_closure_relative | \n",
" ammonia_mole_fraction | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" 100.0 | \n",
" 0.000022 | \n",
" 8.692937e-07 | \n",
" 6.661048e-16 | \n",
" -1.243450e-14 | \n",
" 4.440892e-16 | \n",
" 0.000022 | \n",
"
\n",
" \n",
" | 1 | \n",
" 1000.0 | \n",
" 0.000218 | \n",
" 8.693484e-06 | \n",
" 6.658439e-16 | \n",
" -7.993606e-15 | \n",
" 6.661338e-16 | \n",
" 0.000218 | \n",
"
\n",
" \n",
" | 2 | \n",
" 100000.0 | \n",
" 0.020874 | \n",
" 8.743861e-04 | \n",
" 2.795053e-16 | \n",
" 0.000000e+00 | \n",
" 6.661338e-16 | \n",
" 0.020892 | \n",
"
\n",
" \n",
" | 3 | \n",
" 20000000.0 | \n",
" 0.622052 | \n",
" 1.183401e-01 | \n",
" 2.459158e-16 | \n",
" 3.552714e-15 | \n",
" -3.330669e-16 | \n",
" 0.695665 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" P_Pa ideal_ammonia_fraction relative_ideal_difference \\\n",
"0 100.0 0.000022 8.692937e-07 \n",
"1 1000.0 0.000218 8.693484e-06 \n",
"2 100000.0 0.020874 8.743861e-04 \n",
"3 20000000.0 0.622052 1.183401e-01 \n",
"\n",
" classified_residual ln_mass_action_residual pressure_closure_relative \\\n",
"0 6.661048e-16 -1.243450e-14 4.440892e-16 \n",
"1 6.658439e-16 -7.993606e-15 6.661338e-16 \n",
"2 2.795053e-16 0.000000e+00 6.661338e-16 \n",
"3 2.459158e-16 3.552714e-15 -3.330669e-16 \n",
"\n",
" ammonia_mole_fraction \n",
"0 0.000022 \n",
"1 0.000218 \n",
"2 0.020892 \n",
"3 0.695665 "
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"T = 573.15\n",
"p0 = 100000.0\n",
"R = GAS_CONSTANT_J_PER_MOL_K\n",
"ln_Kp = -5.4047677937089755\n",
"ln_Krho = -11.492330833421008\n",
"coefs = [\n",
" [19.50583, 19.88705, -8.598535, 1.369784, 0.527601, -4.935202, 212.39, 0],\n",
" [33.066178, -11.363417, 11.432816, -2.772874, -0.158558, -9.980797, 172.707974, 0],\n",
" [19.99563, 49.77119, -15.37599, 1.921168, 0.189174, -53.30667, 203.8591, -45.89806],\n",
"]\n",
"thermal = ThermochemistryRecord(\n",
" p0,\n",
" [\n",
" [\n",
" IdealInterval(\n",
" lo, hi, True, True, IdealCorrelation(IdealShomate(c, c[-1] * 1000), p0)\n",
" )\n",
" ]\n",
" for c, (lo, hi) in zip(coefs, [(500, 2000), (298, 1000), (298, 1400)])\n",
" ],\n",
")\n",
"reference = Mixture(parameters, thermochemistry=thermal)\n",
"gibbs = []\n",
"for i in range(3):\n",
" x = [0.0, 0.0, 0.0]\n",
" x[i] = 1.0\n",
" state = reference.state(T, rho=p0 / (R * T), x=x)\n",
" gibbs.append(state.ideal_enthalpy - T * state.ideal_entropy)\n",
"thermal_error = sum((nu * g for nu, g in zip((-1.0, -3.0, 2.0), gibbs))) + R * T * ln_Kp\n",
"assert abs(thermal_error) < 1e-08\n",
"assert abs(ln_Krho - ln_Kp - 2 * math.log(R * T / p0)) < 1e-12\n",
"rows = []\n",
"for P in (100.0, 1000.0, 100000.0, 20000000.0):\n",
" problem = eq.Problem(\n",
" T=T,\n",
" P=P,\n",
" phases=[eq.Phase(\"gas\", kind=\"vapor\", composition_guess=(0.2, 0.6, 0.2))],\n",
" feed=eq.Amounts({\"nitrogen\": 1.0, \"hydrogen\": 3.0}),\n",
" reactions=[\n",
" eq.Reaction(\n",
" {\"nitrogen\": -1.0, \"hydrogen\": -3.0, \"ammonia\": 2.0},\n",
" equilibrium_constant=1.0208081643306505e-05,\n",
" )\n",
" ],\n",
" )\n",
" assert abs(math.log(problem.reactions[0].equilibrium_constant) - ln_Krho) < 1e-12\n",
" result = eq.solve_equilibrium(model, problem)\n",
" assert result.success, result.message\n",
" x = result.mole_fractions\n",
" n = [result.amounts[0] * v for v in x]\n",
" element_errors = [2 * n[0] + n[2] - 2.0, 2 * n[1] + 3 * n[2] - 6.0]\n",
" state = model.state(T, rho=result.molar_densities[0], x=x)\n",
" lnphi = state.log_fugacity_coefficient\n",
" law = (\n",
" sum(\n",
" (\n",
" nu * (math.log(v * P / p0) + f)\n",
" for nu, v, f in zip((-1.0, -3.0, 2.0), x, lnphi)\n",
" )\n",
" )\n",
" - ln_Kp\n",
" )\n",
" a = math.sqrt(math.exp(ln_Kp)) * P / p0 * math.sqrt(27.0) / 16.0\n",
" ideal = 2 * a / (1 + 2 * a + math.sqrt(1 + 4 * a))\n",
" classified = max((abs(v) for v in result.classified_residuals))\n",
" assert max((abs(v) for v in element_errors)) < 1e-10\n",
" assert (\n",
" abs(sum(x) - 1) < 1e-12\n",
" and min(n) > 0\n",
" and (state.pressure_density_derivative > 0)\n",
" )\n",
" assert abs(law) < 1e-09 and classified < 1e-10\n",
" assert abs(state.pressure / P - 1) < 1e-10\n",
" if P <= 1000:\n",
" assert abs(x[2] / ideal - 1) < 0.0001\n",
" rows.append(\n",
" dict(\n",
" P_Pa=P,\n",
" amounts_mol=n,\n",
" mole_fractions=x,\n",
" ideal_ammonia_fraction=ideal,\n",
" relative_ideal_difference=x[2] / ideal - 1,\n",
" ln_phi=lnphi,\n",
" element_balance_error_mol=element_errors,\n",
" charge_balance_mol=sum(z * amount for z, amount in zip(charges, n)),\n",
" ln_mass_action_residual=law,\n",
" classified_residual=classified,\n",
" pressure_closure_relative=state.pressure / P - 1,\n",
" )\n",
" )\n",
"assert abs(rows[-1][\"relative_ideal_difference\"]) > 0.02\n",
"values = dict(\n",
" T_K=T,\n",
" ln_Kp=ln_Kp,\n",
" ln_Krho=ln_Krho,\n",
" thermal_gibbs_J_mol=gibbs,\n",
" thermal_error_J_mol=thermal_error,\n",
" rows=rows,\n",
")\n",
"values[\"standard_conversion_error\"] = ln_Krho - ln_Kp - 2 * math.log(R * T / p0)\n",
"display(\n",
" pd.DataFrame(rows)[\n",
" [\n",
" \"P_Pa\",\n",
" \"ideal_ammonia_fraction\",\n",
" \"relative_ideal_difference\",\n",
" \"classified_residual\",\n",
" \"ln_mass_action_residual\",\n",
" \"pressure_closure_relative\",\n",
" ]\n",
" ].assign(ammonia_mole_fraction=[row[\"mole_fractions\"][2] for row in rows])\n",
")\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "cell-08",
"metadata": {
"execution": {
"iopub.execute_input": "2026-10-20T20:17:19.661763Z",
"iopub.status.busy": "2026-10-20T20:17:19.661651Z",
"iopub.status.idle": "2026-10-20T20:17:19.664655Z",
"shell.execute_reply": "2026-10-20T20:17:19.664008Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Pressure / Pa | \n",
" N2, H2, NH3 amounts / mol | \n",
" N2, H2, NH3 fractions / 1 | \n",
" N2, H2, NH3 ln fugacity coefficients / 1 | \n",
" N, H atom balance errors / mol | \n",
" Charge balance / mol | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" 100.0 | \n",
" [0.9999564554816837, 2.99986936644505, 8.708903663315427e-05] | \n",
" [0.24999455681670008, 0.7499836704501001, 2.177273319987838e-05] | \n",
" [4.915850051563298e-07, 4.475280941702228e-07, 4.775341711162814e-08] | \n",
" [4.440892098500626e-16, 0.0] | \n",
" 0.0 | \n",
"
\n",
" \n",
" | 1 | \n",
" 1000.0 | \n",
" [0.9995648072185193, 2.998694421655558, 0.0008703855629615834] | \n",
" [0.2499455890626913, 0.749836767188074, 0.0002176437492346965] | \n",
" [4.914312311222707e-06, 4.475794198607798e-06, 4.736158619205332e-07] | \n",
" [0.0, 8.881784197001252e-16] | \n",
" 0.0 | \n",
"
\n",
" \n",
" | 2 | \n",
" 100000.0 | \n",
" [0.9590703402425576, 2.8772110207276733, 0.08185931951488447] | \n",
" [0.244776902733317, 0.7343307081999512, 0.02089238906673184] | \n",
" [0.0004757427142311511, 0.00045339169951193317, 6.672124227196719e-06] | \n",
" [-4.440892098500626e-16, 0.0] | \n",
" 0.0 | \n",
"
\n",
" \n",
" | 3 | \n",
" 20000000.0 | \n",
" [0.17947806850656361, 0.5384342055196899, 1.641043862986873] | \n",
" [0.07608368196867617, 0.2282510459060281, 0.6956652721252957] | \n",
" [0.1076214620231393, 0.22346882100238727, -0.15609040140853978] | \n",
" [4.440892098500626e-16, -8.881784197001252e-16] | \n",
" 0.0 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Pressure / Pa \\\n",
"0 100.0 \n",
"1 1000.0 \n",
"2 100000.0 \n",
"3 20000000.0 \n",
"\n",
" N2, H2, NH3 amounts / mol \\\n",
"0 [0.9999564554816837, 2.99986936644505, 8.708903663315427e-05] \n",
"1 [0.9995648072185193, 2.998694421655558, 0.0008703855629615834] \n",
"2 [0.9590703402425576, 2.8772110207276733, 0.08185931951488447] \n",
"3 [0.17947806850656361, 0.5384342055196899, 1.641043862986873] \n",
"\n",
" N2, H2, NH3 fractions / 1 \\\n",
"0 [0.24999455681670008, 0.7499836704501001, 2.177273319987838e-05] \n",
"1 [0.2499455890626913, 0.749836767188074, 0.0002176437492346965] \n",
"2 [0.244776902733317, 0.7343307081999512, 0.02089238906673184] \n",
"3 [0.07608368196867617, 0.2282510459060281, 0.6956652721252957] \n",
"\n",
" N2, H2, NH3 ln fugacity coefficients / 1 \\\n",
"0 [4.915850051563298e-07, 4.475280941702228e-07, 4.775341711162814e-08] \n",
"1 [4.914312311222707e-06, 4.475794198607798e-06, 4.736158619205332e-07] \n",
"2 [0.0004757427142311511, 0.00045339169951193317, 6.672124227196719e-06] \n",
"3 [0.1076214620231393, 0.22346882100238727, -0.15609040140853978] \n",
"\n",
" N, H atom balance errors / mol Charge balance / mol \n",
"0 [4.440892098500626e-16, 0.0] 0.0 \n",
"1 [0.0, 8.881784197001252e-16] 0.0 \n",
"2 [-4.440892098500626e-16, 0.0] 0.0 \n",
"3 [4.440892098500626e-16, -8.881784197001252e-16] 0.0 "
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Temperature / K | \n",
" ln Kp / 1 | \n",
" ln Krho / 1 | \n",
" Thermal reaction error / J mol^-1 | \n",
" Standard conversion error / 1 | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" 573.15 | \n",
" -5.404768 | \n",
" -11.492331 | \n",
" 0.0 | \n",
" 8.881784e-16 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Temperature / K ln Kp / 1 ln Krho / 1 Thermal reaction error / J mol^-1 \\\n",
"0 573.15 -5.404768 -11.492331 0.0 \n",
"\n",
" Standard conversion error / 1 \n",
"0 8.881784e-16 "
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Species | \n",
" Ideal standard Gibbs energy / J mol^-1 | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" nitrogen | \n",
" -112733.235745 | \n",
"
\n",
" \n",
" | 1 | \n",
" hydrogen | \n",
" -77796.786453 | \n",
"
\n",
" \n",
" | 2 | \n",
" ammonia | \n",
" -160183.764774 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Species Ideal standard Gibbs energy / J mol^-1\n",
"0 nitrogen -112733.235745\n",
"1 hydrogen -77796.786453\n",
"2 ammonia -160183.764774"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"display(pd.DataFrame(rows)[[\n",
" \"P_Pa\", \"amounts_mol\", \"mole_fractions\", \"ln_phi\",\n",
" \"element_balance_error_mol\", \"charge_balance_mol\",\n",
"]].rename(columns={\n",
" \"P_Pa\": \"Pressure / Pa\",\n",
" \"amounts_mol\": \"N2, H2, NH3 amounts / mol\",\n",
" \"mole_fractions\": \"N2, H2, NH3 fractions / 1\",\n",
" \"ln_phi\": \"N2, H2, NH3 ln fugacity coefficients / 1\",\n",
" \"element_balance_error_mol\": \"N, H atom balance errors / mol\",\n",
" \"charge_balance_mol\": \"Charge balance / mol\",\n",
"}))\n",
"display(pd.DataFrame([{\n",
" \"Temperature / K\": values[\"T_K\"],\n",
" \"ln Kp / 1\": values[\"ln_Kp\"],\n",
" \"ln Krho / 1\": values[\"ln_Krho\"],\n",
" \"Thermal reaction error / J mol^-1\": values[\"thermal_error_J_mol\"],\n",
" \"Standard conversion error / 1\": values[\"standard_conversion_error\"],\n",
"}]))\n",
"display(pd.DataFrame({\n",
" \"Species\": [\"nitrogen\", \"hydrogen\", \"ammonia\"],\n",
" \"Ideal standard Gibbs energy / J mol^-1\": values[\"thermal_gibbs_J_mol\"],\n",
"}))\n"
]
},
{
"cell_type": "markdown",
"id": "cell-07",
"metadata": {},
"source": [
"## Meaning and limits\n",
"\n",
"\n",
"The dilute limit verifies the mathematical reduction to ideal gas behavior.\n",
"The 200 bar result is a prediction from the declared source parameters and\n",
"zero unlike interactions, with unquantified extrapolation and parameter/model\n",
"uncertainty. It does not validate high-pressure ammonia accuracy. One declared\n",
"vapor phase does not establish global stability. Kinetics, catalyst effects,\n",
"condensation, reactor energy balance and industrial performance are outside\n",
"this isothermal example.\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
}