Class StepResponseGenerator
java.lang.Object
neqsim.process.mpc.StepResponseGenerator
- All Implemented Interfaces:
Serializable
Generates step response models by running NeqSim simulations.
The StepResponseGenerator automates the process of system identification by performing step tests on a ProcessSystem. For each MV-CV pair, it:
- Records the baseline CV value
- Applies a step change to the MV
- Runs simulations and records CV response over time
- Fits transfer function models (FOPDT)
The resulting step response data can be used to:
- Configure the existing ModelPredictiveController
- Export to external MPC packages
- Validate process linearity
Example usage:
StepResponseGenerator generator = new StepResponseGenerator(processSystem);
// Add MVs and CVs
generator.addMV(
new ManipulatedVariable("Valve", valve, "opening").setBounds(0.0, 1.0).setInitialValue(0.5));
generator.addCV(new ControlledVariable("Pressure", separator, "pressure", "bara"));
// Configure step test
generator.setStepSize(0.10); // 10% step
generator.setSettlingTime(60, "min"); // Wait 60 min for steady state
generator.setSampleInterval(1, "min"); // Sample every minute
// Run step tests
StepResponseMatrix responses = generator.generateAllResponses();
// Access individual response
StepResponse pressureToValve = responses.get("Pressure", "Valve");
double gain = pressureToValve.getGain();
double tau = pressureToValve.getTimeConstant();
- Since:
- 3.0
- Version:
- 1.0
- Author:
- Even Solbraa
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMatrix container for step responses from all MV-CV pairs. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanWhether to run both positive and negative steps for averaging.private final List<ControlledVariable> List of controlled variables.private final List<ManipulatedVariable> List of manipulated variables.private booleanWhether to use positive step (true) or negative (false).private final ProcessSystemThe process system to test.private doubleSample interval in seconds.private static final longprivate doubleSettling time in seconds.private doubleStep size as fraction of MV range. -
Constructor Summary
ConstructorsConstructorDescriptionStepResponseGenerator(ProcessSystem processSystem) Construct a step response generator for a ProcessSystem. -
Method Summary
Modifier and TypeMethodDescriptionAdd a controlled variable to monitor.Add a manipulated variable for step testing.private StepResponseaverageResponses(StepResponse pos, StepResponse neg) Average two step responses (for bidirectional testing).private doublecalculateStepSize(ManipulatedVariable mv, double currentValue) Calculate the step size for an MV.clear()Clear all variable definitions.private doubleconvertToSeconds(double value, String unit) Generate step responses for all MV-CV pairs.doubleGet the configured sample interval.doubleGet the configured settling time.doubleGet the configured step size fraction.private List<StepResponse> runSingleStep(ManipulatedVariable mv, double baseValue, double stepSize) Run a single step test.Run a step test for a single MV.setBidirectionalTest(boolean bidirectional) Set whether to run bidirectional tests.setPositiveStep(boolean positive) Set whether to use positive step direction.setSampleInterval(double value, String unit) Set the sample interval.setSettlingTime(double value, String unit) Set the settling time for step tests.setStepSize(double fraction) Set the step size as a fraction of MV range.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
processSystem
The process system to test. -
manipulatedVariables
List of manipulated variables. -
controlledVariables
List of controlled variables. -
stepSizeFraction
private double stepSizeFractionStep size as fraction of MV range. -
settlingTimeSeconds
private double settlingTimeSecondsSettling time in seconds. -
sampleIntervalSeconds
private double sampleIntervalSecondsSample interval in seconds. -
positiveStep
private boolean positiveStepWhether to use positive step (true) or negative (false). -
bidirectionalTest
private boolean bidirectionalTestWhether to run both positive and negative steps for averaging.
-
-
Constructor Details
-
StepResponseGenerator
Construct a step response generator for a ProcessSystem.- Parameters:
processSystem- the NeqSim process to test
-
-
Method Details
-
addMV
Add a manipulated variable for step testing.- Parameters:
mv- the manipulated variable- Returns:
- this generator for method chaining
-
addCV
Add a controlled variable to monitor.- Parameters:
cv- the controlled variable- Returns:
- this generator for method chaining
-
setStepSize
Set the step size as a fraction of MV range.- Parameters:
fraction- step size (0.10 = 10%)- Returns:
- this generator for method chaining
-
setSettlingTime
Set the settling time for step tests.- Parameters:
value- the settling time valueunit- the time unit ("s", "min", "hr")- Returns:
- this generator for method chaining
-
setSampleInterval
Set the sample interval.- Parameters:
value- the sample interval valueunit- the time unit ("s", "min", "hr")- Returns:
- this generator for method chaining
-
setPositiveStep
Set whether to use positive step direction.- Parameters:
positive- true for positive step, false for negative- Returns:
- this generator for method chaining
-
setBidirectionalTest
Set whether to run bidirectional tests.- Parameters:
bidirectional- true to run both positive and negative steps- Returns:
- this generator for method chaining
-
convertToSeconds
-
generateAllResponses
Generate step responses for all MV-CV pairs.- Returns:
- matrix of step responses
-
runStepTest
Run a step test for a single MV.- Parameters:
mv- the manipulated variable to step- Returns:
- list of step responses for all CVs
-
runSingleStep
Run a single step test.- Parameters:
mv- the MV to stepbaseValue- the baseline MV valuestepSize- the step magnitude (can be negative)- Returns:
- list of step responses for all CVs
-
calculateStepSize
Calculate the step size for an MV.- Parameters:
mv- the manipulated variablecurrentValue- current MV value- Returns:
- the step magnitude
-
averageResponses
Average two step responses (for bidirectional testing).- Parameters:
pos- positive step responseneg- negative step response- Returns:
- averaged response
-
clear
Clear all variable definitions.- Returns:
- this generator for method chaining
-
getSettlingTimeSeconds
public double getSettlingTimeSeconds()Get the configured settling time.- Returns:
- settling time in seconds
-
getSampleIntervalSeconds
public double getSampleIntervalSeconds()Get the configured sample interval.- Returns:
- sample interval in seconds
-
getStepSizeFraction
public double getStepSizeFraction()Get the configured step size fraction.- Returns:
- step size as fraction
-