Class SubrModlExporter
java.lang.Object
neqsim.process.mpc.SubrModlExporter
- All Implemented Interfaces:
Serializable
Exports NeqSim process models in SubrModl format for nonlinear MPC integration.
This class generates configuration files compatible with industrial nonlinear MPC systems that use programmed model objects (SubrModl). The export includes:
- Model parameters (constants like volume, height, density)
- SubrXvr definitions with DtaIx mappings for variable linking
- State variables (SVR) for internal model states
- Initial values and engineering unit specifications
The SubrModl format supports nonlinear dynamic equations with commands like INIT, STEP, STDSTEP for steady-state, UPDT for state updates, and SAVE for persistence.
Example usage:
ProcessSystem process = new ProcessSystem();
// ... add equipment ...
SubrModlExporter exporter = new SubrModlExporter(process);
exporter.setModelName("WellModel");
exporter.addParameter("Volume", 100.0, "m3");
exporter.addParameter("Height", 2000.0, "m");
// Add SubrXvr definitions
exporter.addSubrXvr("Pdownhole", "pdh", "Downhole pressure", 147.7);
exporter.addSubrXvr("Pwellhead", "pwh", "Wellhead pressure", 10.4);
// Export configuration
exporter.exportConfiguration("wellmodel_config.txt");
- Since:
- 3.0
- Version:
- 1.0
- Author:
- Even Solbraa
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classModel parameter definition.static classState variable (SVR) definition.static classSubrXvr definition for variable linking. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringApplication name for the configuration.Index table entries.private StringModel name for SubrModl/SubrProc.private final List<SubrModlExporter.ModelParameter> Model parameters (constants).private final ProcessSystemThe process system to export.private doubleSample time for the model (seconds).private static final longprivate final List<SubrModlExporter.StateVariable> State variables (SVR).private final List<SubrModlExporter.SubrXvr> SubrXvr definitions. -
Constructor Summary
ConstructorsConstructorDescriptionSubrModlExporter(ProcessSystem processSystem) Construct a SubrModl exporter. -
Method Summary
Modifier and TypeMethodDescriptionaddIndexEntry(String dtaIx) Add an index table entry.addParameter(String name, double value, String unit) Add a model parameter (constant).addParameter(String name, double value, String unit, String description) Add a model parameter with description.addStateVariable(String name, String dtaIx, String description, double modelValue) Add a state variable (SVR).addSubrXvr(String name, String dtaIx, String description, double init) Add a SubrXvr definition.voidexportConfiguration(String filename) Export the model configuration in SubrModl format.voidexportIndexTable(String filename) Export the index table (IxId) for C++ code generation.voidexportJSON(String filename) Export as JSON for programmatic use.voidexportMPCConfiguration(String filename, boolean useNonlinear) Export MPC configuration with nonlinear parameters.private StringformatValue(double value) Format a numeric value for output.private StringgenerateDtaIx(String name) Generate a data index from a variable name.Get the index table.Get the model parameters.Get the state variables.Get the SubrXvr definitions.populateFromMPC(ProcessLinkedMPC controller) Auto-populate from ProcessLinkedMPC controller.setApplicationName(String applicationName) Set the application name.setModelName(String modelName) Set the model name.setSampleTime(double sampleTime) Set the sample time.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
processSystem
The process system to export. -
modelName
Model name for SubrModl/SubrProc. -
applicationName
Application name for the configuration. -
parameters
Model parameters (constants). -
subrXvrs
SubrXvr definitions. -
stateVariables
State variables (SVR). -
indexTable
-
sampleTime
private double sampleTimeSample time for the model (seconds).
-
-
Constructor Details
-
SubrModlExporter
Construct a SubrModl exporter.- Parameters:
processSystem- the process system to export
-
-
Method Details
-
setModelName
Set the model name.- Parameters:
modelName- the model name- Returns:
- this exporter for chaining
-
setApplicationName
Set the application name.- Parameters:
applicationName- the application name- Returns:
- this exporter for chaining
-
setSampleTime
Set the sample time.- Parameters:
sampleTime- sample time in seconds- Returns:
- this exporter for chaining
-
addParameter
Add a model parameter (constant).- Parameters:
name- parameter namevalue- parameter valueunit- engineering unit- Returns:
- this exporter for chaining
-
addParameter
Add a model parameter with description.- Parameters:
name- parameter namevalue- parameter valueunit- engineering unitdescription- parameter description- Returns:
- this exporter for chaining
-
addSubrXvr
Add a SubrXvr definition.- Parameters:
name- variable namedtaIx- data index for C++ linkingdescription- variable descriptioninit- initial value- Returns:
- this exporter for chaining
-
addStateVariable
public SubrModlExporter addStateVariable(String name, String dtaIx, String description, double modelValue) Add a state variable (SVR).- Parameters:
name- variable namedtaIx- data indexdescription- variable descriptionmodelValue- initial model value- Returns:
- this exporter for chaining
-
addIndexEntry
Add an index table entry.- Parameters:
dtaIx- data index to add- Returns:
- this exporter for chaining
-
exportConfiguration
Export the model configuration in SubrModl format.This generates a configuration file compatible with industrial nonlinear MPC systems using the SubrProc/SubrModl pattern.
- Parameters:
filename- the output filename- Throws:
IOException- if writing fails
-
exportMPCConfiguration
Export MPC configuration with nonlinear parameters.This generates the SmpcAppl configuration section with tuning parameters for nonlinear MPC.
- Parameters:
filename- the output filenameuseNonlinear- whether to use nonlinear (SQP) or linear (QP) solver- Throws:
IOException- if writing fails
-
exportIndexTable
Export the index table (IxId) for C++ code generation.- Parameters:
filename- the output filename- Throws:
IOException- if writing fails
-
exportJSON
Export as JSON for programmatic use.- Parameters:
filename- the output filename- Throws:
IOException- if writing fails
-
populateFromMPC
Auto-populate from ProcessLinkedMPC controller.This automatically extracts MVs, CVs, DVs from the MPC controller and creates corresponding SubrXvr definitions.
- Parameters:
controller- the MPC controller- Returns:
- this exporter for chaining
-
generateDtaIx
-
formatValue
Format a numeric value for output.- Parameters:
value- the value- Returns:
- formatted string
-
getParameters
Get the model parameters.- Returns:
- list of parameters
-
getSubrXvrs
Get the SubrXvr definitions.- Returns:
- list of SubrXvrs
-
getStateVariables
Get the state variables.- Returns:
- list of state variables
-
getIndexTable
-