Class StepResponse
java.lang.Object
neqsim.process.mpc.StepResponse
- All Implemented Interfaces:
Serializable
Represents a step response from a single input to a single output.
A step response captures how a controlled variable responds over time to a step change in a manipulated variable. This data is used for system identification and model-based control.
The class provides methods to:
- Access raw step response data
- Fit first-order plus dead-time (FOPDT) models
- Fit second-order plus dead-time (SOPDT) models
- Export step coefficients for DMC-style controllers
- Since:
- 3.0
- Version:
- 1.0
- Author:
- Even Solbraa
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final doubleBaseline CV value before step.private final StringName of the controlled variable.private final StringUnit for the CV.private doubleprivate doubleprivate doubleprivate doubleprivate doubleprivate final StringName of the manipulated variable.private final StringUnit for the MV.private final double[]CV response values at each time point.private final doubleSample time interval.private static final longprivate final doubleStep size applied to MV.private final double[]Time points (in seconds). -
Constructor Summary
ConstructorsConstructorDescriptionStepResponse(String mvName, String cvName, double[] time, double[] response, double stepSize, double baselineValue, double sampleTime, String mvUnit, String cvUnit) Construct a step response. -
Method Summary
Modifier and TypeMethodDescriptionprivate doubleCalculate the mean squared error of the FOPDT fit.double[]convolve(double[] mvMoves) Simulate the CV response to an MV trajectory using convolution.fitFOPDT()Fit a first-order plus dead-time (FOPDT) model to the response.doubleGet the baseline CV value.Get the CV name.doubleGet the fitted dead time.doubleGet the FOPDT fit error.doublegetGain()Get the steady-state gain (Kp).Get the MV name.double[]Get the normalized response (change from baseline per unit MV change).intGet the number of samples.double[]Get the response array.doubleGet the rise time (time from 10% to 90% of final value).doubleGet the sample time.doubleGet the settling time (time to reach 95% of final value).double[]getStepCoefficients(int numCoefficients) Get step response coefficients for DMC-style controllers.doubleGet the step size.double[]getTime()Get the time array.doubleGet the fitted time constant.booleanCheck if the response shows inverse response (wrong-way behavior).toString()
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
mvName
Name of the manipulated variable. -
cvName
Name of the controlled variable. -
time
private final double[] timeTime points (in seconds). -
response
private final double[] responseCV response values at each time point. -
stepSize
private final double stepSizeStep size applied to MV. -
baselineValue
private final double baselineValueBaseline CV value before step. -
sampleTime
private final double sampleTimeSample time interval. -
cvUnit
Unit for the CV. -
mvUnit
Unit for the MV. -
fittedGain
private double fittedGain -
fittedTimeConstant
private double fittedTimeConstant -
fittedDeadTime
private double fittedDeadTime -
fittedBias
private double fittedBias -
fitError
private double fitError
-
-
Constructor Details
-
StepResponse
public StepResponse(String mvName, String cvName, double[] time, double[] response, double stepSize, double baselineValue, double sampleTime, String mvUnit, String cvUnit) Construct a step response.- Parameters:
mvName- name of the manipulated variablecvName- name of the controlled variabletime- array of time points (seconds)response- array of CV response valuesstepSize- the step size applied to MVbaselineValue- CV value before the stepsampleTime- sample interval in secondsmvUnit- unit for MVcvUnit- unit for CV
-
-
Method Details
-
getMvName
-
getCvName
-
getTime
public double[] getTime()Get the time array.- Returns:
- copy of time points
-
getResponse
public double[] getResponse()Get the response array.- Returns:
- copy of response values
-
getNormalizedResponse
public double[] getNormalizedResponse()Get the normalized response (change from baseline per unit MV change).- Returns:
- normalized step response coefficients
-
getStepSize
public double getStepSize()Get the step size.- Returns:
- the MV step magnitude
-
getBaselineValue
public double getBaselineValue()Get the baseline CV value.- Returns:
- CV value before step
-
getSampleTime
public double getSampleTime()Get the sample time.- Returns:
- sample interval in seconds
-
getNumSamples
public int getNumSamples()Get the number of samples.- Returns:
- length of response array
-
getGain
public double getGain()Get the steady-state gain (Kp).The gain is calculated as the final response change divided by the step size.
- Returns:
- the steady-state gain
-
fitFOPDT
Fit a first-order plus dead-time (FOPDT) model to the response.The FOPDT model is: y(t) = K * (1 - exp(-(t-θ)/τ)) for t > θ, else 0 where K is gain, τ is time constant, θ is dead time.
- Returns:
- this step response with fitted parameters
-
calculateFitError
private double calculateFitError()Calculate the mean squared error of the FOPDT fit.- Returns:
- the MSE
-
getTimeConstant
public double getTimeConstant()Get the fitted time constant.- Returns:
- τ in seconds
-
getDeadTime
public double getDeadTime()Get the fitted dead time.- Returns:
- θ in seconds
-
getFitError
public double getFitError()Get the FOPDT fit error.- Returns:
- mean squared error
-
getStepCoefficients
public double[] getStepCoefficients(int numCoefficients) Get step response coefficients for DMC-style controllers.Returns the normalized step response at each sample time, which can be used directly in Dynamic Matrix Control algorithms.
- Parameters:
numCoefficients- number of coefficients to return- Returns:
- array of step response coefficients
-
convolve
public double[] convolve(double[] mvMoves) Simulate the CV response to an MV trajectory using convolution.- Parameters:
mvMoves- array of MV move increments- Returns:
- predicted CV trajectory
-
getSettlingTime
public double getSettlingTime()Get the settling time (time to reach 95% of final value).- Returns:
- settling time in seconds
-
getRiseTime
public double getRiseTime()Get the rise time (time from 10% to 90% of final value).- Returns:
- rise time in seconds
-
hasInverseResponse
public boolean hasInverseResponse()Check if the response shows inverse response (wrong-way behavior).- Returns:
- true if inverse response detected
-
toString
-