fugacity
v0.2.2
Published
Chemical process simulation built for AI chat artifacts, starting with phase equilibria.
Maintainers
Readme
Fugacity
Open chemical process simulation built for AI chats. Ask your assistant (ChatGPT, Claude, Gemini or another) for a phase diagram, and it opens a live interface that calculates right in the chat, in your browser. Fugacity starts with vapour-liquid equilibria and grows through volunteer contributions, one tested layer at a time, toward full flowsheets.

Status: early (v0.2.2). 16 components, activity models and cubic equations of state, pure-component properties, steam tables, and a workbench with a ribbon. Results are model predictions. Check them against data before using them for design.
Where it's going (roadmap): today phase equilibria and properties → next flash, streams, unit operations, reaction engineering, distillation and flowsheets, growing towards models of all the common units, with bridges to spreadsheets, reports and other simulators → then cost engineering (equipment sizing, capital and operating cost, cost per kg of product) → and the big ambition, agentic process design: AI agents read the open literature, build flowsheets for several process routes, simulate and cost them, and tell you which route is best and why, with every number traced to its source for an engineer to check.
Try it in your chat (30 seconds)
Paste one of these into an assistant that can open web links.
Open the workbench:
Read https://raw.githubusercontent.com/FaireDose/Fugacity/main/ai/instructions/use-fugacity.md and follow it. Open the Fugacity workbench with methanol, acetone and chloroform at 1 atm.
Ask for a property value:
Read https://raw.githubusercontent.com/FaireDose/Fugacity/main/ai/instructions/use-fugacity.md and follow it. What are the density and viscosity of liquid water at 80 °C and 1 bar? Give the source of each value.
(Fugacity answers 971.8 kg/m³ and 0.354 mPa·s, from IAPWS-IF97 and the IAPWS viscosity release.) For the first, the assistant writes a few lines that load Fugacity, and the workbench opens live in the chat (tested in Claude artifacts; other chats: compatibility). To have it always at hand, install the Fugacity skill once: the steps for Claude, ChatGPT, Claude Code and Codex, and one line for the custom instructions of other assistants, are at https://github.com/FaireDose/Fugacity/blob/main/ai/README.md#install-the-skills. The skill itself is https://github.com/FaireDose/Fugacity/releases/latest/download/fugacity.zip. Then just ask, for example "Open the Fugacity workbench with ethanol and water".
What it does today
| | |
|---|---|
| Components | liquids: water, methanol, ethanol, acetone, chloroform, benzene, toluene, ethyl acetate, acetic acid, ethylene glycol; gases: oxygen, nitrogen, hydrogen, methane, ethane, ethylene |
| Pure-component properties | vapour pressure, liquid density, heat capacity (liquid and ideal gas), heat of vaporization, viscosity and thermal conductivity (liquid and vapour), surface tension, enthalpy; each with its source, range and fit deviation |
| Water and steam | IAPWS-IF97 (all regions), IAPWS viscosity (2008) and thermal conductivity (2011) |
| Binary parameters | NRTL/UNIQUAC for 27 pairs, each labelled fitted to data or databank; Peng–Robinson and SRK k_ij for 21 pairs; Henry constants for the 6 gases in water |
| Models | NRTL, UNIQUAC, ideal (with acetic acid dimerization); Peng–Robinson, SRK |
| Calculations | bubble temperature and pressure, T-x-y, P-x-y, ternary grids, residue curves, azeotropes, liquid phase-split check; with PR/SRK bubble and dew points with a stability test; gas solubility in water |
| Interface | Workbench with a ribbon (app): components, T-x-y, ternary map, azeotropes, Peng–Robinson/SRK P-x-y and phase envelope, gas solubility, property curves, steam tables, units, mol/wt %; a button hides the background layers. Single views: mount (T-x-y or ternary), mountProperties (property explorer) |
A full ternary map (861 bubble points plus ten residue curves) takes well under a second in the browser. If a pair has no parameters yet, the interface says which one.
In any web page:
<div id="app"></div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/fugacity.js"></script>
<script>
Fugacity.app("#app", { start: "ternary", components: ["methanol", "acetone", "chloroform"] });
// or a single view: Fugacity.mount("#app", { components: ["water", "acetic acid", "ethylene glycol"] });
</script>From code (K, kPa, mole fractions):
const s = Fugacity.system({ components: ["water", "acetic acid"], model: "UNIQUAC" });
s.bubbleT([0.5, 0.5], 101.325); // { T: 376.36, y: [0.645, 0.355], gamma: [1.306, 1.164] }
s.azeotropes(101.325); // [{ x, T, type }]
Fugacity.pure("water").tsat(101.325); // 373.1243 K (IAPWS-IF97)
Fugacity.pure("benzene").props(298.15, 101.325); // { phase, rho_kg_m3, cp_J_molK, h_J_mol, mu_Pa_s, k_W_mK, sources, notes }
Fugacity.steam(573.15, 1000); // { region: 2, h_kJ_kg: 3051.7, v_m3_kg: 0.25798, ... }
const g = Fugacity.system({ components: ["methane", "ethane"], model: "PR" });
g.bubbleP([0.3, 0.7], 200); // { P: 1618.1, y: [0.862, 0.138], stability, warnings }
Fugacity.gasSolubility("oxygen", 298.15, 21.2); // mole fraction in water, 4.86e-6Property explorer in a page:
<script>
Fugacity.mountProperties("#app", { component: "water", property: "enthalpy", pressures_kPa: [100, 1000] });
</script>More in examples/ and ai/instructions/use-fugacity.md.
How we know the numbers are right
Every model is checked automatically on each change (npm test):
| Check | Result |
|---|---|
| JavaScript engine vs. an independent Python implementation, 446 bubble points in 3 ternaries and 9 binaries | agree to 1e-7 K |
| 10 binary azeotropes at 1 atm vs. handbook values | NRTL within 0.4 K and 0.02 in x; UNIQUAC within 1 K and 0.05 |
| Methanol + acetone + chloroform ternary saddle azeotrope | NRTL 57.1 °C vs. 57.5 °C |
| Acetic acid + ethylene glycol vs. Schmid et al. (2007), P-x at 363.15 K | AAD 1.2 % (NRTL), 0.9 % (UNIQUAC) |
| Water + ethylene glycol vs. T-x-y data at 760 mmHg | AAD 3.0 K (NRTL), 2.6 K (UNIQUAC), within the data scatter |
| Pure-component boiling points at 1 atm | within 0.2 K |
| Steam tables vs. the IAPWS verification tables (IF97, viscosity, thermal conductivity) | all values within 1e-8 relative or to the printed digits |
| Property correlations vs. their sources (CoolProp, ChemSep, NIST WebBook) | within 1 % (thermodynamic) and 3 % (transport); liquid cp and heats of vaporization vs. measured NIST data within about 2 % (worst: ethyl acetate liquid cp, +2.0 %) |
| Peng–Robinson and SRK vs. the thermo library and an independent Python implementation | Z, ln φ, bubble and dew points to about 1e-9 |
| Peng–Robinson vs. nitrogen + methane data (Janisch 2007, ThermoML Archive) | average deviation 1.9 % in P |
| Henry constants vs. the IAPWS G7-04 check table | 18 of 18 values reproduced |
On every pull request an engineering report compares about 320 results with independent references (CoolProp, NIST, handbook azeotropes) and posts the table as a comment, so reviewers judge engineering results, not code.
The source of every parameter is recorded next to it in
src/data/ and shown under every diagram; licenses in
src/data/LICENSES.md.
Known limits: the phase-split check finds the spinodal only, so the real two-liquid region is wider than the shaded one; the UNIQUAC databank set is less accurate than NRTL for some systems (acetone + chloroform + methanol); no ternary VLE data exist yet to check water + acetic acid + ethylene glycol; acetic acid and alcohols or glycols slowly esterify, which the model does not include. Cubic equations of state give poor liquid densities and underestimate the residual enthalpy of polar vapours (methanol, acetone) by 27–45 %; 99 of the 120 pairs have no k_ij yet (treated as 0, with a warning); no flash yet. Liquid properties are at saturation (pressure effect neglected); acetic acid liquid enthalpy is not given until association is included.
Contribute
You bring the engineering judgement, your AI assistant does the typing; you don't need to program. Two ways:
- Talk to your assistant, then submit a form: a proposal, data, or a bug.
- Join as a contributor (anyone can) and let your coding agent open pull requests.
Start with CONTRIBUTING.md. The rules are in AGENTS.md: only sources anyone can read for free, every number cited and checked by a person, every change reviewed by someone other than its author.
More
- ARCHITECTURE.md: the layers from data to flowsheet and the data quality tiers
- ROADMAP.md: what comes next
- GOVERNANCE.md and SECURITY.md: how decisions are made and how the project is protected
License
Code: MIT. Data: under the license of its source, see src/data/LICENSES.md.
