Class FugacityJacobian

java.lang.Object
neqsim.thermo.util.derivatives.FugacityJacobian
All Implemented Interfaces:
Serializable

public class FugacityJacobian extends Object implements Serializable
Container for Jacobian matrix of fugacity coefficients.

Stores derivatives of log fugacity coefficients (ln φ) for all components with respect to:

  • Temperature: ∂(ln φ_i)/∂T
  • Pressure: ∂(ln φ_i)/∂P
  • Composition: ∂(ln φ_i)/∂n_j (moles) or ∂(ln φ_i)/∂x_j (mole fractions)

These derivatives are fundamental for:

  • Flash calculation convergence (Newton methods)
  • Implicit differentiation through equilibrium
  • Stability analysis
Since:
3.0
Author:
ESOL
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final String[]
    Component names.
    private final double[][]
    Derivatives w.r.t. moles: ∂(ln φ_i)/∂n_j [1/mol].
    private final double[]
    Derivatives w.r.t. pressure: ∂(ln φ_i)/∂P [1/bar].
    private final double[]
    Derivatives w.r.t. temperature: ∂(ln φ_i)/∂T [1/K].
    private final double[]
    Log fugacity coefficients ln(φ_i).
    private final int
    Number of components.
    private final int
    Phase index (0 = liquid-like, 1 = vapor-like).
    private final String
    Phase type description.
    private static final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    FugacityJacobian(int phaseIndex, String phaseType, double[] lnPhi, double[] dlnPhidT, double[] dlnPhidP, double[][] dlnPhidn, String[] componentNames)
    Constructor for FugacityJacobian.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    checkSymmetry(double[] moles, double tolerance)
    Check thermodynamic consistency (symmetry of composition Jacobian).
    double
    directionalDerivative(int componentIndex, double deltaT, double deltaP, double[] deltaN)
    Compute directional derivative of ln(φ_i) along a perturbation.
    Get component names.
    double[][]
    Get full composition Jacobian matrix.
    double
    getDlnPhidn(int i, int j)
    Get derivative of ln(φ_i) w.r.t. moles of component j.
    double[]
    getDlnPhidnRow(int componentIndex)
    Get row of composition Jacobian (derivatives of ln(φ_i) w.r.t. all component moles).
    double[]
    Get all pressure derivatives.
    double
    getDlnPhidP(int componentIndex)
    Get derivative of ln(φ_i) w.r.t. pressure.
    double[]
    Get all temperature derivatives.
    double
    getDlnPhidT(int componentIndex)
    Get derivative of ln(φ_i) w.r.t. temperature.
    double[]
    Get all log fugacity coefficients.
    double
    getLnPhi(int componentIndex)
    Get log fugacity coefficient for a component.
    int
    Get number of components.
    int
    Get phase index.
    Get phase type description.
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • phaseIndex

      private final int phaseIndex
      Phase index (0 = liquid-like, 1 = vapor-like).
    • phaseType

      private final String phaseType
      Phase type description.
    • numberOfComponents

      private final int numberOfComponents
      Number of components.
    • lnPhi

      private final double[] lnPhi
      Log fugacity coefficients ln(φ_i).
    • dlnPhidT

      private final double[] dlnPhidT
      Derivatives w.r.t. temperature: ∂(ln φ_i)/∂T [1/K].
    • dlnPhidP

      private final double[] dlnPhidP
      Derivatives w.r.t. pressure: ∂(ln φ_i)/∂P [1/bar].
    • dlnPhidn

      private final double[][] dlnPhidn
      Derivatives w.r.t. moles: ∂(ln φ_i)/∂n_j [1/mol]. Matrix is [component][d/dn_component].
    • componentNames

      private final String[] componentNames
      Component names.
  • Constructor Details

    • FugacityJacobian

      public FugacityJacobian(int phaseIndex, String phaseType, double[] lnPhi, double[] dlnPhidT, double[] dlnPhidP, double[][] dlnPhidn, String[] componentNames)
      Constructor for FugacityJacobian.
      Parameters:
      phaseIndex - phase index
      phaseType - phase type description
      lnPhi - log fugacity coefficients
      dlnPhidT - derivatives w.r.t. temperature
      dlnPhidP - derivatives w.r.t. pressure
      dlnPhidn - derivatives w.r.t. moles (Jacobian matrix)
      componentNames - component names
  • Method Details

    • getPhaseIndex

      public int getPhaseIndex()
      Get phase index.
      Returns:
      phase index
    • getPhaseType

      public String getPhaseType()
      Get phase type description.
      Returns:
      phase type
    • getNumberOfComponents

      public int getNumberOfComponents()
      Get number of components.
      Returns:
      number of components
    • getLnPhi

      public double getLnPhi(int componentIndex)
      Get log fugacity coefficient for a component.
      Parameters:
      componentIndex - component index
      Returns:
      ln(φ_i)
    • getLnPhi

      public double[] getLnPhi()
      Get all log fugacity coefficients.
      Returns:
      array of ln(φ_i)
    • getDlnPhidT

      public double getDlnPhidT(int componentIndex)
      Get derivative of ln(φ_i) w.r.t. temperature.
      Parameters:
      componentIndex - component index
      Returns:
      ∂(ln φ_i)/∂T [1/K]
    • getDlnPhidT

      public double[] getDlnPhidT()
      Get all temperature derivatives.
      Returns:
      array of ∂(ln φ_i)/∂T
    • getDlnPhidP

      public double getDlnPhidP(int componentIndex)
      Get derivative of ln(φ_i) w.r.t. pressure.
      Parameters:
      componentIndex - component index
      Returns:
      ∂(ln φ_i)/∂P [1/bar]
    • getDlnPhidP

      public double[] getDlnPhidP()
      Get all pressure derivatives.
      Returns:
      array of ∂(ln φ_i)/∂P
    • getDlnPhidn

      public double getDlnPhidn(int i, int j)
      Get derivative of ln(φ_i) w.r.t. moles of component j.
      Parameters:
      i - component index for fugacity
      j - component index for differentiation
      Returns:
      ∂(ln φ_i)/∂n_j [1/mol]
    • getDlnPhidnRow

      public double[] getDlnPhidnRow(int componentIndex)
      Get row of composition Jacobian (derivatives of ln(φ_i) w.r.t. all component moles).
      Parameters:
      componentIndex - component index
      Returns:
      array of ∂(ln φ_i)/∂n_j for all j
    • getDlnPhidn

      public double[][] getDlnPhidn()
      Get full composition Jacobian matrix.
      Returns:
      matrix [i][j] = ∂(ln φ_i)/∂n_j
    • getComponentNames

      public String[] getComponentNames()
      Get component names.
      Returns:
      array of component names
    • checkSymmetry

      public boolean checkSymmetry(double[] moles, double tolerance)
      Check thermodynamic consistency (symmetry of composition Jacobian).

      For a thermodynamically consistent model: n_i * ∂(ln φ_i)/∂n_j = n_j * ∂(ln φ_j)/∂n_i

      Parameters:
      moles - mole numbers
      tolerance - relative tolerance for symmetry check
      Returns:
      true if consistent within tolerance
    • directionalDerivative

      public double directionalDerivative(int componentIndex, double deltaT, double deltaP, double[] deltaN)
      Compute directional derivative of ln(φ_i) along a perturbation.
      Parameters:
      componentIndex - component index
      deltaT - temperature perturbation
      deltaP - pressure perturbation
      deltaN - mole perturbations
      Returns:
      directional derivative of ln(φ_i)
    • toString

      public String toString()
      Overrides:
      toString in class Object