From b3da7de08e2b57b56029efc942f9b6d7f33d906a Mon Sep 17 00:00:00 2001 From: Sviatoslav Eroshkin <109044598+Sviatose@users.noreply.github.com> Date: Tue, 19 Nov 2024 20:52:56 +0100 Subject: [PATCH] feat: param process run step (#1158) * feat: param process run step * update * update --------- Co-authored-by: Even Solbraa <41290109+EvenSol@users.noreply.github.com> --- .../process/processmodel/ProcessSystem.java | 56 +++++++++++-------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/src/main/java/neqsim/process/processmodel/ProcessSystem.java b/src/main/java/neqsim/process/processmodel/ProcessSystem.java index ada973b75..62775dbcd 100644 --- a/src/main/java/neqsim/process/processmodel/ProcessSystem.java +++ b/src/main/java/neqsim/process/processmodel/ProcessSystem.java @@ -43,6 +43,7 @@ public class ProcessSystem extends SimulationBaseClass { new ArrayList(0); RecycleController recycleController = new RecycleController(); private double timeStep = 1.0; + private boolean runStep = false; /** *

@@ -67,8 +68,7 @@ public ProcessSystem(String name) { * Add to end. *

* - * @param operation a {@link neqsim.process.equipment.ProcessEquipmentInterface} - * object + * @param operation a {@link neqsim.process.equipment.ProcessEquipmentInterface} object */ public void add(ProcessEquipmentInterface operation) { // Add to end @@ -81,8 +81,7 @@ public void add(ProcessEquipmentInterface operation) { *

* * @param position 0-based position - * @param operation a {@link neqsim.process.equipment.ProcessEquipmentInterface} - * object + * @param operation a {@link neqsim.process.equipment.ProcessEquipmentInterface} object */ public void add(int position, ProcessEquipmentInterface operation) { ArrayList units = this.getUnitOperations(); @@ -113,8 +112,8 @@ public void add(int position, ProcessEquipmentInterface operation) { * Add measurementdevice. *

* - * @param measurementDevice a - * {@link neqsim.process.measurementdevice.MeasurementDeviceInterface} object + * @param measurementDevice a {@link neqsim.process.measurementdevice.MeasurementDeviceInterface} + * object */ public void add(MeasurementDeviceInterface measurementDevice) { measurementDevices.add(measurementDevice); @@ -125,8 +124,8 @@ public void add(MeasurementDeviceInterface measurementDevice) { * Add multiple process equipment to end. *

* - * @param operations an array of - * {@link neqsim.process.equipment.ProcessEquipmentInterface} objects + * @param operations an array of {@link neqsim.process.equipment.ProcessEquipmentInterface} + * objects */ public void add(ProcessEquipmentInterface[] operations) { getUnitOperations().addAll(Arrays.asList(operations)); @@ -222,8 +221,7 @@ public int getUnitNumber(String name) { *

* * @param unitName a {@link java.lang.String} object - * @param operation a {@link neqsim.process.equipment.ProcessEquipmentBaseClass} - * object + * @param operation a {@link neqsim.process.equipment.ProcessEquipmentBaseClass} object */ public void replaceObject(String unitName, ProcessEquipmentBaseClass operation) { unitOperations.set(getUnitNumber(name), operation); @@ -440,8 +438,7 @@ public void run(UUID id) { for (int i = 0; i < unitOperations.size(); i++) { if (unitOperations.get(i).getClass().getSimpleName().equals("Adjuster")) { - if (!((neqsim.process.equipment.util.Adjuster) unitOperations.get(i)) - .solved()) { + if (!((neqsim.process.equipment.util.Adjuster) unitOperations.get(i)).solved()) { isConverged = false; break; } @@ -459,7 +456,7 @@ public void run(UUID id) { * signalDB[timeStepNumber][3 * i + 3] = ((MeasurementDeviceInterface) * measurementDevices.get(i)) .getUnit(); } */ - } while ((!isConverged || (iter < 2 && hasRecycle)) && iter < 100); + } while (((!isConverged || (iter < 2 && hasRecycle)) && iter < 100) && !runStep); for (int i = 0; i < unitOperations.size(); i++) { unitOperations.get(i).setCalculationIdentifier(id); @@ -736,6 +733,24 @@ public void setName(String name) { this.name = name; } + /** + * Setter for the field runStep. + * + * @param runStep A boolean value if run only one iteration + */ + public void setRunStep(boolean runStep) { + this.runStep = runStep; + } + + /** + * Getter for the field runStep. + * + * @return A boolean value if run only one iteration + */ + public boolean isRunStep() { + return runStep; + } + /** *

* getEntropyProduction. @@ -784,11 +799,10 @@ public double getPower(String unit) { double power = 0.0; for (int i = 0; i < unitOperations.size(); i++) { if (unitOperations.get(i).getClass().getSimpleName().equals("Compressor")) { - power += ((neqsim.process.equipment.compressor.Compressor) unitOperations - .get(i)).getPower(); + power += + ((neqsim.process.equipment.compressor.Compressor) unitOperations.get(i)).getPower(); } else if (unitOperations.get(i).getClass().getSimpleName().equals("Pump")) { - power += ((neqsim.process.equipment.pump.Pump) unitOperations.get(i)) - .getPower(); + power += ((neqsim.process.equipment.pump.Pump) unitOperations.get(i)).getPower(); } } if (unit.equals("MW")) { @@ -812,9 +826,7 @@ public double getCoolerDuty(String unit) { double heat = 0.0; for (int i = 0; i < unitOperations.size(); i++) { if (unitOperations.get(i).getClass().getSimpleName().equals("Cooler")) { - heat += - ((neqsim.process.equipment.heatexchanger.Cooler) unitOperations.get(i)) - .getDuty(); + heat += ((neqsim.process.equipment.heatexchanger.Cooler) unitOperations.get(i)).getDuty(); } } if (unit.equals("MW")) { @@ -838,9 +850,7 @@ public double getHeaterDuty(String unit) { double heat = 0.0; for (int i = 0; i < unitOperations.size(); i++) { if (unitOperations.get(i).getClass().getSimpleName().equals("Heater")) { - heat += - ((neqsim.process.equipment.heatexchanger.Heater) unitOperations.get(i)) - .getDuty(); + heat += ((neqsim.process.equipment.heatexchanger.Heater) unitOperations.get(i)).getDuty(); } } if (unit.equals("MW")) {