Class MultiVariableAdjuster
- All Implemented Interfaces:
Serializable, Runnable, ProcessEquipmentInterface, ProcessElementInterface, SimulationInterface, NamedInterface
This class solves the multi-variable analog of the single-variable Adjuster: given N
manipulated (adjusted) variables and N target specifications, it simultaneously drives all
targets to their desired values using damped successive substitution.
The underlying algorithm uses damped successive substitution (x_{n+1} = x_n + alpha * residuals) which provides robust first-order convergence for a wide range of process gains.
Problem Statement
Given N adjusted variables x_1, ..., x_N and N target specifications y_1, ..., y_N with target values t_1, ..., t_N, find the values of x that satisfy:
f_i(x) = y_i(x) - t_i = 0 for i = 1, ..., N
Key Features
- Simultaneous N-variable convergence (vs N independent single-variable loops)
- Damped successive substitution with configurable relaxation
- Variable bounds enforcement with clamping
- Configurable convergence tolerance and maximum iterations
- Support for pressure, temperature, flow rate, and molar flow adjustments
Usage Example
MultiVariableAdjuster adj = new MultiVariableAdjuster("MV-Adj");
// Add adjusted variables (manipulated)
adj.addAdjustedVariable(compressor, "pressure", "bara");
adj.addAdjustedVariable(heater, "temperature", "C");
// Add target specifications (in same order)
adj.addTargetSpecification(separator, "pressure", 85.0, "bara");
adj.addTargetSpecification(cooler, "temperature", 30.0, "C");
// Optional: set bounds
adj.setVariableBounds(0, 50.0, 200.0); // pressure
adj.setVariableBounds(1, 10.0, 100.0); // temperature
// Add to process system and run
process.add(adj);
process.run();
- Version:
- 1.0
- Author:
- NeqSim
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classDefinition of a single adjusted (manipulated) variable.private static classDefinition of a single target specification. -
Field Summary
FieldsModifier and TypeFieldDescriptionList of adjusted (manipulated) variable definitions.private booleanWhether the adjuster has converged.private intCurrent iteration count.private static final org.apache.logging.log4j.LoggerLogger object for class.private intMaximum number of outer iterations.private doubleCurrent maximum residual.private static final longSerialization version UID.List of target specification definitions.private doubleConvergence tolerance on the residual norm.Fields inherited from class ProcessEquipmentBaseClass
conditionAnalysisMessage, energyStream, hasController, isSolved, properties, reportFields inherited from class SimulationBaseClass
calcIdentifier, calculateSteadyState, timeFields inherited from class NamedBaseClass
name -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for MultiVariableAdjuster.MultiVariableAdjuster(String name) Constructor with name. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAdjustedVariable(ProcessEquipmentInterface equipment, String variable, String unit) Add an adjusted (manipulated) variable.voidaddTargetSpecification(ProcessEquipmentInterface equipment, String variable, double targetValue, String unit) Add a target specification.voidaddTargetSpecification(ProcessEquipmentInterface equipment, String variable, double targetValue, String unit, String phase, String component) Add a target specification with phase and component.private double[]Compute the residual vector (target - current) for all specifications.intGet the number of iterations performed in the last run.doubleGet the maximum residual from the last run.intGet the number of adjusted variables.private StreamInterfacegetStreamFromEquipment(ProcessEquipmentInterface equipment) Get a stream interface from equipment, handling various equipment types.booleanCheck if the adjuster converged in the last run.private doublemaxAbsValue(double[] arr) Compute the maximum absolute value in an array.private doublereadAdjustedValue(int index) Read the current value of an adjusted variable from its equipment.private doubleRead the current value of a target specification from its equipment.voidRun one step of the multi-variable adjustment.voidsetMaxIterations(int maxIter) Set maximum number of iterations.voidsetTolerance(double tol) Set convergence tolerance.voidsetVariableBounds(int index, double lower, double upper) Set bounds on an adjusted variable.booleansolved()Check if the adjuster is solved (converged).private voidwriteAdjustedValue(int index, double value) Write a new value to an adjusted variable's equipment.Methods inherited from class ProcessEquipmentBaseClass
addCapacityConstraint, addController, copy, displayResult, equals, getAvailableMargin, getAvailableMarginPercent, getBottleneckConstraint, getCapacityConstraints, getConditionAnalysisMessage, getConstraintEvaluationReport, getController, getController, getControllers, getEffectiveCapacityFactor, getEnergyStream, getEntropyProduction, getExergyChange, getFailureMode, getMassBalance, getMassBalance, getMaxUtilization, getMaxUtilizationPercent, getMechanicalDesign, getMinimumFlow, getPressure, getPressure, getProperty, getReferenceDesignation, getReport_json, getResultTable, getSpecification, getTemperature, getTemperature, getThermoSystem, getUtilizationSummary, hashCode, initElectricalDesign, initializeDefaultConstraints, initInstrumentDesign, initMechanicalDesign, isActive, isActive, isCapacityAnalysisEnabled, isCapacityExceeded, isFailed, isHardLimitExceeded, isNearCapacityLimit, isSetEnergyStream, reportResults, restoreFromFailure, run_step, runConditionAnalysis, setCapacityAnalysisEnabled, setController, setEnergyStream, setEnergyStream, setFailureMode, setFlowValveController, setMinimumFlow, setPressure, setReferenceDesignation, setRegulatorOutSignal, setSpecification, setTemperature, simulateDegradedOperation, simulateTrip, toJson, toJsonMethods inherited from class SimulationBaseClass
getCalculateSteadyState, getCalculationIdentifier, getTime, increaseTime, isRunInSteps, setCalculateSteadyState, setCalculationIdentifier, setRunInSteps, setTimeMethods inherited from class NamedBaseClass
getName, getTagNumber, setName, setTagNumberMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface NamedInterface
getName, getTagName, getTagNumber, setName, setTagName, setTagNumberMethods inherited from interface ProcessEquipmentInterface
getCapacityDuty, getCapacityMax, getElectricalDesign, getEquipmentState, getExergyChange, getExergyDestruction, getExergyDestruction, getFluid, getInletStreams, getInstrumentDesign, getOperatingEnvelopeViolation, getOutletFlowRate, getOutletPressure, getOutletStreams, getOutletTemperature, getReferenceDesignationString, getRestCapacity, getSimulationValidationErrors, isSimulationValid, isWithinOperatingEnvelope, needRecalculation, validateSetupMethods inherited from interface SimulationInterface
getCalculateSteadyState, getCalculationIdentifier, getTime, increaseTime, isRunInSteps, run, run_step, runTransient, runTransient, setCalculateSteadyState, setCalculationIdentifier, setRunInSteps, setTime
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerialization version UID.- See Also:
-
logger
private static final org.apache.logging.log4j.Logger loggerLogger object for class. -
adjustedVariables
List of adjusted (manipulated) variable definitions. -
targetSpecifications
List of target specification definitions. -
maxIterations
private int maxIterationsMaximum number of outer iterations. -
tolerance
private double toleranceConvergence tolerance on the residual norm. -
iterations
private int iterationsCurrent iteration count. -
maxResidual
private double maxResidualCurrent maximum residual. -
converged
private boolean convergedWhether the adjuster has converged.
-
-
Constructor Details
-
MultiVariableAdjuster
public MultiVariableAdjuster()Default constructor for MultiVariableAdjuster. -
MultiVariableAdjuster
-
-
Method Details
-
addAdjustedVariable
Add an adjusted (manipulated) variable.- Parameters:
equipment- the equipment whose variable is manipulatedvariable- the variable name (pressure, temperature, flow)unit- the unit string (bara, C, kg/hr, etc.)
-
addTargetSpecification
public void addTargetSpecification(ProcessEquipmentInterface equipment, String variable, double targetValue, String unit) Add a target specification.- Parameters:
equipment- the equipment whose variable is observedvariable- the variable name (pressure, temperature, flow, volume)targetValue- the desired target valueunit- the unit string
-
addTargetSpecification
public void addTargetSpecification(ProcessEquipmentInterface equipment, String variable, double targetValue, String unit, String phase, String component) Add a target specification with phase and component.- Parameters:
equipment- the equipment whose variable is observedvariable- the variable nametargetValue- the desired target valueunit- the unit stringphase- the phase name (gas, oil, aqueous)component- the component name
-
setVariableBounds
public void setVariableBounds(int index, double lower, double upper) Set bounds on an adjusted variable.- Parameters:
index- zero-based index of the adjusted variablelower- lower boundupper- upper bound
-
setMaxIterations
public void setMaxIterations(int maxIter) Set maximum number of iterations.- Parameters:
maxIter- maximum iterations
-
setTolerance
public void setTolerance(double tol) Set convergence tolerance.- Parameters:
tol- convergence tolerance on max residual
-
getIterations
public int getIterations()Get the number of iterations performed in the last run.- Returns:
- iteration count
-
getMaxResidual
public double getMaxResidual()Get the maximum residual from the last run.- Returns:
- maximum residual value
-
isConverged
public boolean isConverged()Check if the adjuster converged in the last run.- Returns:
- true if converged
-
getNumberOfVariables
public int getNumberOfVariables()Get the number of adjusted variables.- Returns:
- number of adjusted variables
-
run
Run one step of the multi-variable adjustment.Unlike an internal iteration loop, this method performs a single damped step per call. The
ProcessSystemprovides the outer iteration loop: it runs all equipment, calls this method, checkssolved(), and re-runs the process if needed. This ensures downstream equipment is re-evaluated between adjustment steps.- Parameters:
id- calculation identifier for tracking
-
computeResiduals
private double[] computeResiduals()Compute the residual vector (target - current) for all specifications.- Returns:
- array of residuals
-
readAdjustedValue
private double readAdjustedValue(int index) Read the current value of an adjusted variable from its equipment.- Parameters:
index- index of the adjusted variable- Returns:
- current value in the specified unit
-
writeAdjustedValue
private void writeAdjustedValue(int index, double value) Write a new value to an adjusted variable's equipment.- Parameters:
index- index of the adjusted variablevalue- new value to set
-
readTargetValue
Read the current value of a target specification from its equipment.- Parameters:
ts- target specification- Returns:
- current value in the specified unit
-
getStreamFromEquipment
Get a stream interface from equipment, handling various equipment types.- Parameters:
equipment- the equipment to get the stream from- Returns:
- stream interface, or null if not available
-
maxAbsValue
private double maxAbsValue(double[] arr) Compute the maximum absolute value in an array.- Parameters:
arr- the array- Returns:
- maximum absolute value
-
solved
public boolean solved()Check if the adjuster is solved (converged).- Specified by:
solvedin interfaceSimulationInterface- Overrides:
solvedin classProcessEquipmentBaseClass- Returns:
- true if the maximum residual is within tolerance
-