Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol committed Dec 26, 2024
1 parent 5c689f3 commit 19f4fec
Show file tree
Hide file tree
Showing 7 changed files with 226 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public abstract class ProcessEquipmentBaseClass extends SimulationBaseClass
public HashMap<String, String> properties = new HashMap<String, String>();
public EnergyStream energyStream = new EnergyStream();
private boolean isSetEnergyStream = false;
protected boolean isSolved = false;
protected boolean isSolved = true;

/**
* <p>
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/neqsim/process/equipment/splitter/Splitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,8 @@ public boolean needRecalculation() {
&& Math.abs(inletStream.getFluid().getFlowRate("kg/hr") - lastFlowRate)
/ inletStream.getFluid().getFlowRate("kg/hr") < 1e-6
&& Arrays.equals(splitFactor, oldSplitFactor)) {
isSolved = true;
return false;
} else {
isSolved = false;
return true;
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/neqsim/process/equipment/stream/Stream.java
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,8 @@ public boolean needRecalculation() {
&& Math.abs(getFluid().getFlowRate("kg/hr") - lastFlowRate)
/ getFluid().getFlowRate("kg/hr") < 1e-6
&& Arrays.equals(getFluid().getMolarComposition(), lastComposition)) {
isSolved = true;
return false;
} else {
isSolved = false;
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.ArrayList;
import java.util.Objects;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
* <p>
Expand All @@ -12,6 +14,7 @@
* @version $Id: $Id
*/
public class RecycleController implements java.io.Serializable {
static Logger logger = LogManager.getLogger(RecycleController.class);
private static final long serialVersionUID = 1000;

ArrayList<Recycle> recycleArray = new ArrayList<Recycle>();
Expand Down Expand Up @@ -165,6 +168,7 @@ public boolean hasHigherPriorityLevel() {
*/
public boolean solvedAll() {
for (Recycle recyc : recycleArray) {
logger.info("recycle solved " + recyc.solved());
if (!recyc.solved()) {
return false;
}
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/neqsim/process/processmodel/ProcessModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public class ProcessModel implements Runnable {
private Map<String, ProcessSystem> processes = new LinkedHashMap<>();

private boolean runStep = false;
private boolean runAsThread = false;
private int maxIterations = 50;
private int iterations = 0;

/**
* Checks if the model is running in step mode.
Expand Down Expand Up @@ -99,8 +100,21 @@ public void run() {
e.printStackTrace();
}
}
if (!runStep) {
if (!isFinished() && iterations < maxIterations) {
iterations += 1;
run();
} else {
iterations = 0;
}
}
}

/**
* Checks if all processes are finished.
*
* @return true if all processes are solved, false otherwise.
*/
public boolean isFinished() {
for (ProcessSystem process : processes.values()) {
if (!process.solved()) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/neqsim/process/processmodel/ProcessSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,8 @@ public boolean solved() {
/* */
if (recycleController.solvedAll()) {
for (int i = 0; i < unitOperations.size(); i++) {
logger.info("unit " + unitOperations.get(i).getName() + " solved: "
+ unitOperations.get(i).solved());
if (!unitOperations.get(i).solved()) {
return false;
}
Expand Down
Loading

0 comments on commit 19f4fec

Please sign in to comment.