-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first version of multi model with test
- Loading branch information
Showing
3 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
src/main/java/neqsim/process/processmodel/ProcessModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
src/test/java/neqsim/process/processmodel/CombinedModelsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
|
||
} | ||
|
||
} |