Class PropertyGradient
java.lang.Object
neqsim.thermo.util.derivatives.PropertyGradient
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final String[]Component names corresponding to composition derivatives.private final doubleDerivative with respect to pressure [property_unit/bar].private final doubleDerivative with respect to temperature [property_unit/K].private final double[]Derivatives with respect to composition (mole fractions) [property_unit/mol_frac].private final StringName of the property.private static final longprivate final StringUnit of the property.private final doubleCurrent value of the property. -
Constructor Summary
ConstructorsConstructorDescriptionPropertyGradient(String propertyName, String unit, double value, double dT, double dP, double[] dz) Simplified constructor without component names.PropertyGradient(String propertyName, String unit, double value, double dT, double dP, double[] dz, String[] componentNames) Constructor for PropertyGradient. -
Method Summary
Modifier and TypeMethodDescriptiondoubledirectionalDerivative(double deltaT, double deltaP, double[] deltaZ) Compute directional derivative along a perturbation vector.String[]Get component names.doublegetDerivativeWrtComponent(int componentIndex) Get derivative with respect to a specific component.double[]Get derivatives with respect to composition.doubleGet the derivative with respect to pressure.doubleGet the derivative with respect to temperature.intGet the number of components.Get the property name.getUnit()Get the property unit.doublegetValue()Get the current value of the property.double[]toArray()Get gradient as a flat array [dT, dP, dz_0, dz_1, ...].toString()static PropertyGradientCreate a zero gradient for a given property.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
propertyName
Name of the property. -
unit
Unit of the property. -
value
private final double valueCurrent value of the property. -
dT
private final double dTDerivative with respect to temperature [property_unit/K]. -
dP
private final double dPDerivative with respect to pressure [property_unit/bar]. -
dz
private final double[] dzDerivatives with respect to composition (mole fractions) [property_unit/mol_frac]. -
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 propertyunit- unit of the propertyvalue- current value of the propertydT- derivative with respect to temperaturedP- derivative with respect to pressuredz- derivatives with respect to compositioncomponentNames- 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 propertyunit- unit of the propertyvalue- current value of the propertydT- derivative with respect to temperaturedP- derivative with respect to pressuredz- derivatives with respect to composition
-
-
Method Details
-
getPropertyName
-
getUnit
-
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
-
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 perturbationdeltaP- pressure perturbationdeltaZ- 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 propertyunit- unit of the propertyvalue- current valuenumberOfComponents- number of components- Returns:
- zero gradient
-
toString
-