Class PropertyGradient

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

public class PropertyGradient extends Object implements Serializable
Container for gradients of a scalar thermodynamic property with respect to state variables.

Stores derivatives of a property (e.g., density, enthalpy, entropy) with respect to:

  • Temperature (T)
  • Pressure (P)
  • Composition (mole fractions or moles)

Example usage:


PropertyGradient densityGrad = flash.computePropertyGradient("density");
double dRho_dT = densityGrad.getDerivativeWrtTemperature();
double dRho_dP = densityGrad.getDerivativeWrtPressure();
double[] dRho_dz = densityGrad.getDerivativeWrtComposition();

Since:
3.0
Author:
ESOL
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • propertyName

      private final String propertyName
      Name of the property.
    • unit

      private final String unit
      Unit of the property.
    • value

      private final double value
      Current value of the property.
    • dT

      private final double dT
      Derivative with respect to temperature [property_unit/K].
    • dP

      private final double dP
      Derivative with respect to pressure [property_unit/bar].
    • dz

      private final double[] dz
      Derivatives with respect to composition (mole fractions) [property_unit/mol_frac].
    • componentNames

      private final String[] componentNames
      Component names corresponding to composition derivatives.
  • Constructor Details

    • PropertyGradient

      public PropertyGradient(String propertyName, String unit, double value, double dT, double dP, double[] dz, String[] componentNames)
      Constructor for PropertyGradient.
      Parameters:
      propertyName - name of the property
      unit - unit of the property
      value - current value of the property
      dT - derivative with respect to temperature
      dP - derivative with respect to pressure
      dz - derivatives with respect to composition
      componentNames - names of components
    • PropertyGradient

      public PropertyGradient(String propertyName, String unit, double value, double dT, double dP, double[] dz)
      Simplified constructor without component names.
      Parameters:
      propertyName - name of the property
      unit - unit of the property
      value - current value of the property
      dT - derivative with respect to temperature
      dP - derivative with respect to pressure
      dz - derivatives with respect to composition
  • Method Details

    • getPropertyName

      public String getPropertyName()
      Get the property name.
      Returns:
      property name
    • getUnit

      public String getUnit()
      Get the property unit.
      Returns:
      property unit
    • getValue

      public double getValue()
      Get the current value of the property.
      Returns:
      property value
    • getDerivativeWrtTemperature

      public double getDerivativeWrtTemperature()
      Get the derivative with respect to temperature.
      Returns:
      dProperty/dT [property_unit/K]
    • getDerivativeWrtPressure

      public double getDerivativeWrtPressure()
      Get the derivative with respect to pressure.
      Returns:
      dProperty/dP [property_unit/bar]
    • getDerivativeWrtComposition

      public double[] getDerivativeWrtComposition()
      Get derivatives with respect to composition.
      Returns:
      array of dProperty/dz_i
    • getDerivativeWrtComponent

      public double getDerivativeWrtComponent(int componentIndex)
      Get derivative with respect to a specific component.
      Parameters:
      componentIndex - index of the component
      Returns:
      dProperty/dz_i
    • getComponentNames

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

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

      public double directionalDerivative(double deltaT, double deltaP, double[] deltaZ)
      Compute directional derivative along a perturbation vector.
      Parameters:
      deltaT - temperature perturbation
      deltaP - pressure perturbation
      deltaZ - composition perturbations
      Returns:
      directional derivative
    • toArray

      public double[] toArray()
      Get gradient as a flat array [dT, dP, dz_0, dz_1, ...].
      Returns:
      gradient vector
    • zero

      public static PropertyGradient zero(String propertyName, String unit, double value, int numberOfComponents)
      Create a zero gradient for a given property.
      Parameters:
      propertyName - name of the property
      unit - unit of the property
      value - current value
      numberOfComponents - number of components
      Returns:
      zero gradient
    • toString

      public String toString()
      Overrides:
      toString in class Object