Skip to content

Commit

Permalink
update adjuster
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol committed Jan 9, 2024
1 parent c757026 commit 1ecf6b3
Showing 1 changed file with 39 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ public Adjuster(String name) {
* </p>
*
* @param adjustedEquipment a
* {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object
* @param adjstedVariable a {@link java.lang.String} object
* {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface}
* object
* @param adjstedVariable a {@link java.lang.String} object
*/
public void setAdjustedVariable(ProcessEquipmentInterface adjustedEquipment,
String adjstedVariable, String unit) {
Expand All @@ -84,8 +85,9 @@ public void setAdjustedVariable(ProcessEquipmentInterface adjustedEquipment,
* </p>
*
* @param adjustedEquipment a
* {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object
* @param adjstedVariable a {@link java.lang.String} object
* {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface}
* object
* @param adjstedVariable a {@link java.lang.String} object
*/
public void setAdjustedVariable(ProcessEquipmentInterface adjustedEquipment,
String adjstedVariable) {
Expand All @@ -99,10 +101,11 @@ public void setAdjustedVariable(ProcessEquipmentInterface adjustedEquipment,
* </p>
*
* @param targetEquipment a
* {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object
* @param targetVariable a {@link java.lang.String} object
* @param targetValue a double
* @param targetUnit a {@link java.lang.String} object
* {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface}
* object
* @param targetVariable a {@link java.lang.String} object
* @param targetValue a double
* @param targetUnit a {@link java.lang.String} object
*/
public void setTargetVariable(ProcessEquipmentInterface targetEquipment, String targetVariable,
double targetValue, String targetUnit) {
Expand All @@ -118,11 +121,12 @@ public void setTargetVariable(ProcessEquipmentInterface targetEquipment, String
* </p>
*
* @param targetEquipment a
* {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object
* @param targetVariable a {@link java.lang.String} object
* @param targetValue a double
* @param targetUnit a {@link java.lang.String} object
* @param targetPhase a {@link java.lang.String} object
* {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface}
* object
* @param targetVariable a {@link java.lang.String} object
* @param targetValue a double
* @param targetUnit a {@link java.lang.String} object
* @param targetPhase a {@link java.lang.String} object
*/
public void setTargetVariable(ProcessEquipmentInterface targetEquipment, String targetVariable,
double targetValue, String targetUnit, String targetPhase) {
Expand All @@ -139,11 +143,12 @@ public void setTargetVariable(ProcessEquipmentInterface targetEquipment, String
* </p>
*
* @param targetEquipment a
* {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface} object
* @param targetVariable a {@link java.lang.String} object
* @param targetValue a double
* @param targetUnit a {@link java.lang.String} object
* @param targetPhase a {@link java.lang.String} object
* {@link neqsim.processSimulation.processEquipment.ProcessEquipmentInterface}
* object
* @param targetVariable a {@link java.lang.String} object
* @param targetValue a double
* @param targetUnit a {@link java.lang.String} object
* @param targetPhase a {@link java.lang.String} object
* @param targetComponent a {@link java.lang.String} object
*/
public void setTargetVariable(ProcessEquipmentInterface targetEquipment, String targetVariable,
Expand All @@ -165,6 +170,10 @@ public void run(UUID id) {
inputValue = ((Stream) adjustedEquipment).getThermoSystem().getFlowRate("kg/hr");
} else if (adjustedVariable.equals("flow") && adjustedVariableUnit != null) {
inputValue = ((Stream) adjustedEquipment).getThermoSystem().getFlowRate(adjustedVariableUnit);
} else if (adjustedVariable.equals("pressure") && adjustedVariableUnit != null) {
inputValue = ((Stream) adjustedEquipment).getPressure(adjustedVariableUnit);
} else if (adjustedVariable.equals("temperature") && adjustedVariableUnit != null) {
inputValue = ((Stream) adjustedEquipment).getTemperature(adjustedVariableUnit);
} else {
inputValue = ((Stream) adjustedEquipment).getThermoSystem().getNumberOfMoles();
}
Expand Down Expand Up @@ -201,6 +210,10 @@ public void run(UUID id) {
} else if (adjustedVariable.equals("flow") && adjustedVariableUnit != null) {
((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(
inputValue + Math.signum(deviation) * inputValue / 100.0, adjustedVariableUnit);
} else if (adjustedVariable.equals("pressure") && adjustedVariableUnit != null) {
inputValue = ((Stream) adjustedEquipment).setPressure(inputValue + deviation / 10.0, adjustedVariableUnit);
} else if (adjustedVariable.equals("temperature") && adjustedVariableUnit != null) {
inputValue = ((Stream) adjustedEquipment).setTemperature(inputValue + deviation / 10.0, adjustedVariableUnit);
} else {
((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(inputValue + deviation,
"mol/sec");
Expand All @@ -222,6 +235,10 @@ public void run(UUID id) {
} else if (adjustedVariable.equals("flow") && adjustedVariableUnit != null) {
((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(inputValue - newVal,
adjustedVariableUnit);
} else if (adjustedVariable.equals("pressure") && adjustedVariableUnit != null) {
((Stream) adjustedEquipment).setPressure(inputValue - newVal, adjustedVariableUnit);
} else if (adjustedVariable.equals("temperature") && adjustedVariableUnit != null) {
((Stream) adjustedEquipment).setTemperature(inputValue - newVal, adjustedVariableUnit);
} else {
((Stream) adjustedEquipment).getThermoSystem().setTotalFlowRate(inputValue - newVal,
"mol/sec");
Expand All @@ -245,7 +262,8 @@ public boolean solved() {

/** {@inheritDoc} */
@Override
public void displayResult() {}
public void displayResult() {
}

/**
* <p>
Expand Down Expand Up @@ -300,8 +318,7 @@ public void setError(double error) {
*/
public static void main(String[] args) {
// test code for adjuster...
neqsim.thermo.system.SystemInterface testSystem =
new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 20.00);
neqsim.thermo.system.SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 20.00);
testSystem.addComponent("methane", 1000.00);
testSystem.createDatabase(true);
testSystem.setMixingRule(2);
Expand All @@ -311,8 +328,7 @@ public static void main(String[] args) {
adjuster1.setAdjustedVariable(stream_1, "molarFlow");
adjuster1.setTargetVariable(stream_1, "gasVolumeFlow", 10.0, "MSm3/day", "");

neqsim.processSimulation.processSystem.ProcessSystem operations =
new neqsim.processSimulation.processSystem.ProcessSystem();
neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem();
operations.add(stream_1);
operations.add(adjuster1);

Expand Down

0 comments on commit 1ecf6b3

Please sign in to comment.