Derivatives and consistency¶
A thermodynamic potential connects many properties through derivatives. Consistency means these properties follow from the same potential and reference convention. It does not by itself establish agreement with measured data or global stability of the state.
Excess caloric properties¶
Let \(f(T,P,\mathbf x)=g^E/(RT)\). At fixed P and composition,
Because \(f=\sum_i x_i\ln\gamma_i\),
A temperature-dependent NRTL alpha therefore contributes to hE and CpE, alongside all terms in tau(T). For an EoS-derived activity coefficient, the constant-P derivative also includes changes in the converged density. Holding density fixed would calculate a different derivative.
These are excess properties. Absolute caloric properties require appropriate pure-component references; their units and energy zeros must remain consistent.
Composition derivatives¶
Use mole amounts n as independent variables and normalize x=n/Σn inside the energy. For a model derived from total excess Gibbs energy,
For a smooth potential J is symmetric. Extensivity and Gibbs–Duhem consistency also imply \(\mathbf x^T J=0\) when evaluated at unit total amount. These are useful numerical checks of normalization and implementation. The derivative along a binary composition path is different: changing x₁ also changes x₂.
ThermoWeave's NRTL/SAFT ln_activity_coefficients_jacobian(T, x) uses the
unit-total-amount convention. Differentiating the total energy independently
and comparing with the closed-form activities checks more than reproducing
the implementation's own algebra.
Density response functions¶
For a homogeneous EoS branch,
Compressibility measures the volume response to pressure, and partial molar volumes describe the change when a component is added. Kirkwood–Buff inversion combines these responses with chemical-potential derivatives to obtain concentration-fluctuation integrals. It is a thermodynamic inversion of a homogeneous state; interpreting a metastable or unstable branch as a stable bulk phase would require a separate physical justification.
The API guide documents the KB result's cm³/mol and 1/GPa units, which differ from the SI units used by core EoS calls.
Implicit solutions and automatic differentiation¶
Density and association-site fractions satisfy equations of the form \(F(\mathbf q,\boldsymbol\theta)=0\). At a locally isolated converged root with nonsingular \(F_q\),
ThermoWeave's JAX EoS kernels use implicit differentiation for the density and association roots. NRTL has an explicit energy/activity expression. Both model families can supply exact AD parameter Jacobians for their fitting helpers. Near singular roots or phase boundaries, derivative conditioning needs care.
JAX compilation and a float64 policy support efficient repeated evaluations; they do not fix an unconverged root, a poorly identified fit or a wrong parameter convention. Public model methods handle their documented precision scope; pure-kernel users must configure precision before tracing.
Use in Python: notebook 04, NRTL fitting, the batch calculation recipe and API conventions. Scientific background for KB inversion is listed in the references.