Skip to content

Commit

Permalink
first version of multi model with test
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol committed Dec 15, 2024
1 parent 93be1b3 commit 0e97302
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/main/java/neqsim/process/processmodel/ProcessModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package neqsim.process.processmodel;

import java.util.ArrayList;

/**
* <p>
* ProcessModel class.
* </p>
*
* @author Even Solbraa
* @version $Id: $Id
*/
public class ProcessModel implements Runnable {
ArrayList<ProcessSystem> processes = new ArrayList<ProcessSystem>(0);

public boolean add(String name, ProcessSystem process) {
processes.add(process);
return true;
}

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

/**
* <p>
* runAsThread.
* </p>
*
* @return a {@link java.lang.Thread} object
*/
public Thread runAsThread() {
Thread processThread = new Thread(this);
processThread.start();
return processThread;
}

}
19 changes: 19 additions & 0 deletions src/main/java/neqsim/process/processmodel/ProcessSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,25 @@ public void add(ProcessEquipmentInterface[] operations) {
getUnitOperations().addAll(Arrays.asList(operations));
}

/**
* <p>
* Replace a unitoperation
* </p>
*
* @param name Name of the object to replace
* @param newObject the object to replace it with
* @return a {@link java.lang.Boolean} object
*/
public boolean replaceUnit(String name, ProcessEquipmentInterface newObject) {
try {
ProcessEquipmentInterface unit = (ProcessEquipmentInterface) getUnit(name);
unit = newObject;
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return true;
}

/**
* <p>
* Get process equipmen by name.
Expand Down
82 changes: 82 additions & 0 deletions src/test/java/neqsim/process/processmodel/CombinedModelsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package neqsim.process.processmodel;

import java.io.File;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.Test;
import neqsim.process.equipment.compressor.Compressor;
import neqsim.process.equipment.separator.ThreePhaseSeparator;
import neqsim.process.equipment.stream.Stream;
import neqsim.thermo.system.SystemInterface;

public class CombinedModelsTest {
static Logger logger = LogManager.getLogger(CombinedModelsTest.class);

public ProcessSystem getinletModel() {
File file = new File("src/test/java/neqsim/process/processmodel");
String fileFluid1 = file.getAbsolutePath() + "/feedfluid.e300";
SystemInterface wellFluid = neqsim.thermo.util.readwrite.EclipseFluidReadWrite.read(fileFluid1);
// wellFluid.setMultiPhaseCheck(true);

Stream wellStreamHP = new neqsim.process.equipment.stream.Stream("HP well stream", wellFluid);
wellStreamHP.setFlowRate(10.0, "MSm3/day");

ThreePhaseSeparator firstStageSeparator =
new neqsim.process.equipment.separator.ThreePhaseSeparator("1st stage separator",
wellStreamHP);

ProcessSystem process1 = new ProcessSystem();
process1.add(wellStreamHP);
process1.add(firstStageSeparator);

return process1;
};

public ProcessSystem getCompressorProcess() {

neqsim.process.equipment.stream.Stream gasFeedStream =
new neqsim.process.equipment.stream.Stream("compressor feed stream");

neqsim.process.equipment.compressor.Compressor compressor1 =
new neqsim.process.equipment.compressor.Compressor("Compressor1", gasFeedStream);
compressor1.setPolytropicEfficiency(0.56);
compressor1.setUsePolytropicCalc(true);

ProcessSystem process1 = new ProcessSystem();
process1.add(gasFeedStream);
process1.add(compressor1);

return process1;
}

@Test
public void testProcess() {

ProcessSystem inletProcess = getinletModel();
ProcessSystem compressorProcess = getCompressorProcess();
((Compressor) compressorProcess.getUnit("Compressor1")).setInletStream(
((ThreePhaseSeparator) inletProcess.getUnit("1st stage separator")).getGasOutStream());

// Set pro1 properties;
((Stream) inletProcess.getUnit("HP well stream")).setTemperature(80.0, "C");
((Stream) inletProcess.getUnit("HP well stream")).setPressure(50.0, "bara");

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


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

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

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

}

}

0 comments on commit 0e97302

Please sign in to comment.