Package neqsim.thermo.util.derivatives


package neqsim.thermo.util.derivatives
Automatic differentiation and gradient computation for thermodynamic calculations.

This package provides classes for computing and storing derivatives of thermodynamic properties with respect to temperature, pressure, and composition. These gradients enable:

  • Gradient-based optimization of process conditions
  • Integration with machine learning frameworks (JAX, PyTorch via custom backward passes)
  • Sensitivity analysis of thermodynamic calculations
  • Physics-informed neural network training

Key Classes:

Usage with Python/JAX:


# Define custom VJP for JAX
# Use @jax.custom_vjp decorator
def flash_density(T, P, z):
    # Forward: call NeqSim
    system = create_system(z)
    system.setTemperature(T)
    system.setPressure(P)
    ops.TPflash()
    return system.getDensity()

def flash_density_bwd(res, g):
    # Backward: use NeqSim's analytical gradients
    grads = DifferentiableFlash(system).computePropertyGradient("density")
    return (g * grads.dT, g * grads.dP, g * grads.dz)

Since:
3.0
Author:
ESOL
  • Classes
    Class
    Description
    Computes gradients of flash calculation results using the implicit function theorem.
    Container for gradients of flash calculation results with respect to input parameters.
    Container for Jacobian matrix of fugacity coefficients.
    Container for gradients of a scalar thermodynamic property with respect to state variables.