Skip to content

Commit

Permalink
feat: param process run step (#1158)
Browse files Browse the repository at this point in the history
* feat: param process run step

* update

* update

---------

Co-authored-by: Even Solbraa <[email protected]>
  • Loading branch information
Sviatose and EvenSol authored Nov 19, 2024
1 parent a87a457 commit b3da7de
Showing 1 changed file with 33 additions and 23 deletions.
56 changes: 33 additions & 23 deletions src/main/java/neqsim/process/processmodel/ProcessSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class ProcessSystem extends SimulationBaseClass {
new ArrayList<MeasurementDeviceInterface>(0);
RecycleController recycleController = new RecycleController();
private double timeStep = 1.0;
private boolean runStep = false;

/**
* <p>
Expand All @@ -67,8 +68,7 @@ public ProcessSystem(String name) {
* Add to end.
* </p>
*
* @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
Expand All @@ -81,8 +81,7 @@ public void add(ProcessEquipmentInterface operation) {
* </p>
*
* @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<ProcessEquipmentInterface> units = this.getUnitOperations();
Expand Down Expand Up @@ -113,8 +112,8 @@ public void add(int position, ProcessEquipmentInterface operation) {
* Add measurementdevice.
* </p>
*
* @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);
Expand All @@ -125,8 +124,8 @@ public void add(MeasurementDeviceInterface measurementDevice) {
* Add multiple process equipment to end.
* </p>
*
* @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));
Expand Down Expand Up @@ -222,8 +221,7 @@ public int getUnitNumber(String name) {
* </p>
*
* @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);
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down Expand Up @@ -736,6 +733,24 @@ public void setName(String name) {
this.name = name;
}

/**
* Setter for the field <code>runStep</code>.
*
* @param runStep A <code>boolean</code> value if run only one iteration
*/
public void setRunStep(boolean runStep) {
this.runStep = runStep;
}

/**
* Getter for the field <code>runStep</code>.
*
* @return A <code>boolean</code> value if run only one iteration
*/
public boolean isRunStep() {
return runStep;
}

/**
* <p>
* getEntropyProduction.
Expand Down Expand Up @@ -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")) {
Expand All @@ -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")) {
Expand All @@ -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")) {
Expand Down

0 comments on commit b3da7de

Please sign in to comment.