Class ProcessLinkedMPC
- All Implemented Interfaces:
Serializable
ProcessLinkedMPC provides automatic integration between NeqSim's ProcessSystem simulation and Model Predictive Control. It handles:
- Automatic model identification through linearization or step testing
- Variable binding between MPC and process equipment
- Model updating during online operation
- Coordinated execution between controller and simulation
Example usage:
// Build process
ProcessSystem process = new ProcessSystem();
Stream feed = new Stream("feed", fluid);
Valve valve = new Valve("valve", feed);
Separator sep = new Separator("separator", valve.getOutletStream());
process.add(feed);
process.add(valve);
process.add(sep);
process.run();
// Create linked MPC
ProcessLinkedMPC mpc = new ProcessLinkedMPC("levelController", process);
// Define variables
mpc.addMV("valve", "opening", 0.0, 1.0);
mpc.addCV("separator", "liquidLevel", 50.0); // setpoint 50%
mpc.setConstraint("separator", "liquidLevel", 20.0, 80.0);
// Auto-identify model
mpc.identifyModel(60.0); // 60s sample time
// Configure tuning
mpc.setPredictionHorizon(20);
mpc.setControlHorizon(5);
mpc.setMoveSuppressionWeight("valve", 0.1);
// Run control step
double[] moves = mpc.calculate();
mpc.applyMoves();
- Since:
- 3.0
- Version:
- 1.0
- Author:
- Even Solbraa
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intControl horizon (number of samples).private final List<ControlledVariable> Controlled variables.private final List<DisturbanceVariable> Disturbance variables.private double[]Error weights for CVs.private UUIDUUID for execution tracking.private double[]Last calculated MV moves.private LinearizationResultLast linearization result.private ProcessLinearizerLinearizer for model identification.private final List<ManipulatedVariable> Manipulated variables.private booleanWhether model has been identified.private intModel update interval (number of steps).private double[]Move suppression weights for MVs.private final StringController name.private NonlinearPredictorNonlinear predictor.private intPrediction horizon (number of samples).private final ProcessSystemThe process system being controlled.private doubleSample time in seconds.private static final longprivate final List<StateVariable> State variables (for nonlinear MPC).private intSteps since last model update.private booleanWhether to use nonlinear prediction. -
Constructor Summary
ConstructorsConstructorDescriptionProcessLinkedMPC(String name, ProcessSystem processSystem) Construct a process-linked MPC controller. -
Method Summary
Modifier and TypeMethodDescriptionAdd a controlled variable with setpoint.Add a controlled variable with zone control.Add a disturbance variable.Add a manipulated variable.addMV(String equipmentName, String propertyName, double minValue, double maxValue, double maxRateOfChange) Add a manipulated variable with rate limits.Add a state variable (SVR) for nonlinear MPC.Add a state variable with a data index.voidApply the calculated MV moves to the process.double[]Calculate the next MV moves.private double[]Create a data exchange interface for real-time integration.Create an industrial MPC exporter for this controller.Create a SubrModl exporter for nonlinear MPC integration.Export the model to a state-space representation.Get a summary of the controller configuration.intGet the control horizon.Get all controlled variables.double[]Get current CV values.double[]Get current MV values.Get all disturbance variables.double[]Get the last calculated moves.Get the linearization result.Get all manipulated variables.getName()Get the controller name.intGet the prediction horizon.Get the process system being controlled.doubleGet the sample time.Get all state variables.voididentifyModel(double sampleTimeSeconds) Identify the process model using linearization.booleanCheck if the model has been identified.voidRun the process simulation.voidsetConstraint(String equipmentName, String propertyName, double minValue, double maxValue) Set constraints on a controlled variable.voidsetControlHorizon(int horizon) Set the control horizon.voidsetErrorWeight(String cvName, double weight) Set error weight for a CV.voidsetModelUpdateInterval(int steps) Set the model update interval.voidsetMoveSuppressionWeight(String mvName, double weight) Set move suppression weight for an MV.voidsetPredictionHorizon(int horizon) Set the prediction horizon.voidsetSampleTime(double sampleTimeSeconds) Set the sample time.voidsetSetpoint(String cvName, double setpoint) Set a CV setpoint.voidsetUseNonlinearPrediction(boolean enable) Enable nonlinear prediction using full NeqSim simulation.double[]step()Execute one complete control step: calculate, apply, and run.toString()voidUpdate DV measurements from the process.voidUpdate CV measurements from the process.voidUpdate the process model at current operating point.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
name
Controller name. -
processSystem
The process system being controlled. -
manipulatedVariables
Manipulated variables. -
controlledVariables
Controlled variables. -
disturbanceVariables
Disturbance variables. -
stateVariables
State variables (for nonlinear MPC). -
linearizer
Linearizer for model identification. -
linearizationResult
Last linearization result. -
sampleTime
private double sampleTimeSample time in seconds. -
predictionHorizon
private int predictionHorizonPrediction horizon (number of samples). -
controlHorizon
private int controlHorizonControl horizon (number of samples). -
modelIdentified
private boolean modelIdentifiedWhether model has been identified. -
lastMoves
private double[] lastMovesLast calculated MV moves. -
useNonlinearPrediction
private boolean useNonlinearPredictionWhether to use nonlinear prediction. -
nonlinearPredictor
Nonlinear predictor. -
modelUpdateInterval
private int modelUpdateIntervalModel update interval (number of steps). -
stepsSinceModelUpdate
private int stepsSinceModelUpdateSteps since last model update. -
executionId
UUID for execution tracking. -
moveSuppressionWeights
private double[] moveSuppressionWeightsMove suppression weights for MVs. -
errorWeights
private double[] errorWeightsError weights for CVs.
-
-
Constructor Details
-
ProcessLinkedMPC
Construct a process-linked MPC controller.- Parameters:
name- the controller nameprocessSystem- the process system to control
-
-
Method Details
-
addMV
public ManipulatedVariable addMV(String equipmentName, String propertyName, double minValue, double maxValue) Add a manipulated variable.- Parameters:
equipmentName- the equipment namepropertyName- the property name (opening, duty, flowRate, etc.)minValue- minimum valuemaxValue- maximum value- Returns:
- the created ManipulatedVariable
-
addMV
public ManipulatedVariable addMV(String equipmentName, String propertyName, double minValue, double maxValue, double maxRateOfChange) Add a manipulated variable with rate limits.- Parameters:
equipmentName- the equipment namepropertyName- the property nameminValue- minimum valuemaxValue- maximum valuemaxRateOfChange- maximum rate of change per sample- Returns:
- the created ManipulatedVariable
-
addCV
Add a controlled variable with setpoint.- Parameters:
equipmentName- the equipment namepropertyName- the property name (pressure, temperature, level, etc.)setpoint- the setpoint value- Returns:
- the created ControlledVariable
-
addCVZone
public ControlledVariable addCVZone(String equipmentName, String propertyName, double lowSetpoint, double highSetpoint) Add a controlled variable with zone control.- Parameters:
equipmentName- the equipment namepropertyName- the property namelowSetpoint- low zone boundaryhighSetpoint- high zone boundary- Returns:
- the created ControlledVariable
-
setConstraint
-
addDV
Add a disturbance variable.- Parameters:
equipmentName- the equipment namepropertyName- the property name- Returns:
- the created DisturbanceVariable
-
addSVR
Add a state variable (SVR) for nonlinear MPC.State variables are internal model states that evolve according to dynamic equations. They are tracked for model accuracy but not directly controlled. Examples include flow rates, internal pressures, and calculated gains.
- Parameters:
equipmentName- the equipment namepropertyName- the property name- Returns:
- the created StateVariable
-
addSVR
Add a state variable with a data index.- Parameters:
equipmentName- the equipment namepropertyName- the property namedtaIx- data index for C++ code linking- Returns:
- the created StateVariable
-
getStateVariables
-
getManipulatedVariables
Get all manipulated variables.- Returns:
- list of MVs
-
getControlledVariables
Get all controlled variables.- Returns:
- list of CVs
-
getDisturbanceVariables
Get all disturbance variables.- Returns:
- list of DVs
-
getProcessSystem
Get the process system being controlled.- Returns:
- the process system
-
setSampleTime
public void setSampleTime(double sampleTimeSeconds) Set the sample time.- Parameters:
sampleTimeSeconds- sample time in seconds
-
getSampleTime
public double getSampleTime()Get the sample time.- Returns:
- sample time in seconds
-
setPredictionHorizon
public void setPredictionHorizon(int horizon) Set the prediction horizon.- Parameters:
horizon- number of samples
-
getPredictionHorizon
public int getPredictionHorizon()Get the prediction horizon.- Returns:
- number of samples
-
setControlHorizon
public void setControlHorizon(int horizon) Set the control horizon.- Parameters:
horizon- number of samples
-
getControlHorizon
public int getControlHorizon()Get the control horizon.- Returns:
- number of samples
-
setMoveSuppressionWeight
Set move suppression weight for an MV.- Parameters:
mvName- the MV nameweight- the suppression weight
-
setErrorWeight
Set error weight for a CV.- Parameters:
cvName- the CV nameweight- the error weight
-
setUseNonlinearPrediction
public void setUseNonlinearPrediction(boolean enable) Enable nonlinear prediction using full NeqSim simulation.- Parameters:
enable- true to enable
-
setModelUpdateInterval
public void setModelUpdateInterval(int steps) Set the model update interval.- Parameters:
steps- number of control steps between model updates (0 = no updates)
-
identifyModel
public void identifyModel(double sampleTimeSeconds) Identify the process model using linearization.- Parameters:
sampleTimeSeconds- the sample time in seconds
-
isModelIdentified
public boolean isModelIdentified()Check if the model has been identified.- Returns:
- true if model is available
-
getLinearizationResult
Get the linearization result.- Returns:
- the linearization result, or null if not identified
-
updateMeasurements
public void updateMeasurements()Update CV measurements from the process. -
updateDisturbances
public void updateDisturbances()Update DV measurements from the process. -
calculate
public double[] calculate()Calculate the next MV moves.- Returns:
- array of MV move values
-
calculateLinear
private double[] calculateLinear() -
applyMoves
public void applyMoves()Apply the calculated MV moves to the process. -
runProcess
public void runProcess()Run the process simulation. -
step
public double[] step()Execute one complete control step: calculate, apply, and run.- Returns:
- the applied MV values
-
updateModel
public void updateModel()Update the process model at current operating point. -
exportModel
Export the model to a state-space representation.- Returns:
- a StateSpaceExporter for export operations
-
getLastMoves
public double[] getLastMoves()Get the last calculated moves.- Returns:
- copy of last moves, or null if none calculated
-
setSetpoint
Set a CV setpoint.- Parameters:
cvName- the CV namesetpoint- the new setpoint
-
getCurrentCVs
public double[] getCurrentCVs()Get current CV values.- Returns:
- array of current CV values
-
getCurrentMVs
public double[] getCurrentMVs()Get current MV values.- Returns:
- array of current MV values
-
getName
-
getConfigurationSummary
Get a summary of the controller configuration.- Returns:
- configuration summary string
-
createIndustrialExporter
Create an industrial MPC exporter for this controller.The exporter can generate model files in formats compatible with industrial MPC platforms, including step response models, gain matrices, and variable configurations.
- Returns:
- a new IndustrialMPCExporter instance
-
createDataExchange
Create a data exchange interface for real-time integration.The data exchange interface provides standardized methods for bidirectional communication with external control systems, including timestamped data vectors, quality flags, and execution status.
- Returns:
- a new ControllerDataExchange instance
-
createSubrModlExporter
Create a SubrModl exporter for nonlinear MPC integration.The SubrModl exporter generates configuration files compatible with industrial nonlinear MPC systems that use programmed model objects. This includes SubrXvr definitions with DtaIx mappings, model parameters, and state variables.
- Returns:
- a new SubrModlExporter instance populated from this controller
-
toString
-