Class StateVariable

java.lang.Object
neqsim.process.mpc.MPCVariable
neqsim.process.mpc.StateVariable
All Implemented Interfaces:
Serializable

public class StateVariable extends MPCVariable implements Serializable
Represents a state variable (SVR) in a nonlinear MPC system.

State variables are internal model states that evolve according to dynamic equations. Unlike CVs (controlled variables), SVRs are not directly controlled but are essential for model accuracy. Examples include:

  • Flow rates (qin, qout)
  • Internal pressures
  • Valve coefficients (cv)
  • Calculated gains

In nonlinear MPC, state variables track the difference between model predictions and measurements, enabling bias correction and model updates.

Key attributes:

  • ModelValue: Current value from model simulation
  • MeasValue: Measured value (if available)
  • Bias: Difference between measurement and model
Since:
3.0
Version:
1.0
Author:
Even Solbraa
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • modelValue

      private double modelValue
      Model-predicted value.
    • measuredValue

      private double measuredValue
      Measured value (if available).
    • hasMeasurement

      private boolean hasMeasurement
      Whether measurement is available.
    • bias

      private double bias
      Bias (measurement - model).
    • biasTfilt

      private double biasTfilt
      Bias filter time constant (seconds).
    • biasTpred

      private double biasTpred
      Bias prediction time constant (seconds).
    • dtaIx

      private String dtaIx
      Data index for C++ code linking.
    • updateFromMeasurement

      private boolean updateFromMeasurement
      Whether to update from measurement.
  • Constructor Details

    • StateVariable

      public StateVariable(String name, ProcessEquipmentInterface equipment, String propertyName)
      Construct a state variable linked to process equipment.
      Parameters:
      name - variable name
      equipment - linked process equipment
      propertyName - property to read from equipment
  • Method Details

    • getModelValue

      public double getModelValue()
      Get the model-predicted value.
      Returns:
      model value
    • setModelValue

      public void setModelValue(double modelValue)
      Set the model-predicted value.
      Parameters:
      modelValue - model value
    • getMeasuredValue

      public double getMeasuredValue()
      Get the measured value.
      Returns:
      measured value, or model value if no measurement
    • setMeasuredValue

      public void setMeasuredValue(double measuredValue)
      Set the measured value.
      Parameters:
      measuredValue - measured value
    • hasMeasurement

      public boolean hasMeasurement()
      Check if measurement is available.
      Returns:
      true if measured
    • clearMeasurement

      public void clearMeasurement()
      Clear the measurement.
    • getBias

      public double getBias()
      Get the bias (measurement - model).
      Returns:
      bias value
    • updateBias

      private void updateBias()
      Update the bias based on current model and measured values.
    • getBiasTfilt

      public double getBiasTfilt()
      Get the bias filter time constant.
      Returns:
      filter time constant (seconds)
    • setBiasTfilt

      public void setBiasTfilt(double biasTfilt)
      Set the bias filter time constant.
      Parameters:
      biasTfilt - filter time constant (seconds)
    • getBiasTpred

      public double getBiasTpred()
      Get the bias prediction time constant.
      Returns:
      prediction time constant (seconds)
    • setBiasTpred

      public void setBiasTpred(double biasTpred)
      Set the bias prediction time constant.
      Parameters:
      biasTpred - prediction time constant (seconds)
    • getDtaIx

      public String getDtaIx()
      Get the data index for C++ code linking.
      Returns:
      data index
    • setDtaIx

      public void setDtaIx(String dtaIx)
      Set the data index for C++ code linking.
      Parameters:
      dtaIx - data index
    • isUpdateFromMeasurement

      public boolean isUpdateFromMeasurement()
      Check if update from measurement is enabled.
      Returns:
      true if updates from measurement
    • setUpdateFromMeasurement

      public void setUpdateFromMeasurement(boolean updateFromMeasurement)
      Set whether to update from measurement.
      Parameters:
      updateFromMeasurement - true to enable updates
    • getCorrectedValue

      public double getCorrectedValue()
      Get the corrected value (model + bias).
      Returns:
      corrected value
    • predictBias

      public double predictBias(double predictionTime, double previousBias, double sampleTime)
      Predict bias at a future time.
      Parameters:
      predictionTime - time into the future (seconds)
      previousBias - bias at previous time step
      sampleTime - sample time (seconds)
      Returns:
      predicted bias
    • getCurrentValue

      public double getCurrentValue()
      Description copied from class: MPCVariable
      Get the current value of this variable.
      Overrides:
      getCurrentValue in class MPCVariable
      Returns:
      the current value
    • readValue

      public double readValue()
      Description copied from class: MPCVariable
      Read the current value from the bound equipment.

      This method uses reflection or equipment-specific accessors to read the property value. The implementation varies by variable type and property.

      Specified by:
      readValue in class MPCVariable
      Returns:
      the current value read from equipment
    • getType

      public MPCVariable.MPCVariableType getType()
      Description copied from class: MPCVariable
      Get the type of this MPC variable.
      Specified by:
      getType in class MPCVariable
      Returns:
      the variable type (MV, CV, or DV)
    • readFromProcess

      public double readFromProcess()
      Read the current value from the process.
      Returns:
      current value from equipment
    • update

      public void update(double measurement)
      Update state from measurement.
      Parameters:
      measurement - measured value
    • toString

      public String toString()
      Overrides:
      toString in class MPCVariable