Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol committed Dec 15, 2024
1 parent 0e97302 commit 65abd5f
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 7 deletions.
62 changes: 58 additions & 4 deletions src/main/java/neqsim/process/processmodel/ProcessModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,77 @@
* @version $Id: $Id
*/
public class ProcessModel implements Runnable {
ArrayList<ProcessSystem> processes = new ArrayList<ProcessSystem>(0);
ArrayList<ProcessSystem> processes = new ArrayList<ProcessSystem>();
private boolean runStep = false;


/**
* <p>
* isRunStep.
* </p>
*
*
* @return a {@link java.lang.Boolean} runStep
*
*/
public boolean isRunStep() {
return runStep;
}

/**
* <p>
* runStep.
* </p>
*
* @param runStep run in steps
*
*/
public void setRunStep(boolean runStep) {
this.runStep = runStep;
}


/**
* <p>
* add.
* </p>
*
* @param name name of process
* @param process process to add
*
* @return a {@link java.lang.Boolean} success
*/
public boolean add(String name, ProcessSystem process) {
processes.add(process);
return true;
}

/**
* <p>
* runAsThread.
* run.
* </p>
*
* @return a {@link java.lang.Thread} object
*/
public void run() {
for (int i = 0; i < processes.size(); i++) {
processes.get(i).run();
if (runStep) {
processes.get(i).run_step();
} else {
processes.get(i).run();
}
}
}

/**
* <p>
* runStep.
* </p>
*
*/
public void runStep() {
for (int i = 0; i < processes.size(); i++) {
processes.get(i).run_step();

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.File;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import neqsim.process.equipment.compressor.Compressor;
import neqsim.process.equipment.separator.ThreePhaseSeparator;
Expand Down Expand Up @@ -63,19 +64,22 @@ public void testProcess() {

((Compressor) compressorProcess.getUnit("Compressor1")).setOutletPressure(100.0, "bara");


ProcessModel fullProcess = new ProcessModel();
fullProcess.add("feed process", inletProcess);
fullProcess.add("compressor process", compressorProcess);
fullProcess.setRunStep(true);

try {
fullProcess.run();
} catch (Exception ex) {
logger.debug(ex.getMessage(), ex);
}

((Compressor) compressorProcess.getUnit("Compressor1")).getOutletStream().getFluid()
.prettyPrint();
Assertions.assertEquals(164.44139872, ((Compressor) compressorProcess.getUnit("Compressor1"))
.getOutletStream().getTemperature("C"), 0.1);

// ((Compressor) compressorProcess.getUnit("Compressor1")).getOutletStream().getFluid()
// .prettyPrint();

}

Expand Down

0 comments on commit 65abd5f

Please sign in to comment.