|
| 1 | +package neqsim.process.processmodel; |
| 2 | + |
| 3 | +import java.io.File; |
| 4 | +import org.apache.logging.log4j.LogManager; |
| 5 | +import org.apache.logging.log4j.Logger; |
| 6 | +import org.junit.jupiter.api.Assertions; |
| 7 | +import org.junit.jupiter.api.Test; |
| 8 | +import neqsim.process.equipment.compressor.Compressor; |
| 9 | +import neqsim.process.equipment.separator.ThreePhaseSeparator; |
| 10 | +import neqsim.process.equipment.stream.Stream; |
| 11 | +import neqsim.thermo.system.SystemInterface; |
| 12 | + |
| 13 | +/** |
| 14 | + * CombinedModelsTest is a test class for validating the combined process model which includes an |
| 15 | + * inlet model and a compressor process. |
| 16 | + * |
| 17 | + * <p> |
| 18 | + * The class contains methods to set up individual process systems and combine them into a single |
| 19 | + * process model. It also includes a test method to verify the behavior of the combined process |
| 20 | + * model. |
| 21 | + * |
| 22 | + * <p> |
| 23 | + * Methods: |
| 24 | + * <ul> |
| 25 | + * <li>{@link #getinletModel()}: Sets up the inlet process model including a well stream and a |
| 26 | + * three-phase separator.</li> |
| 27 | + * <li>{@link #getCompressorProcess()}: Sets up the compressor process model including a gas feed |
| 28 | + * stream and a compressor.</li> |
| 29 | + * <li>{@link #getCombinedModel()}: Combines the inlet process model and the compressor process |
| 30 | + * model into a single process model.</li> |
| 31 | + * <li>{@link #testCombinedProcess()}: Tests the combined process model by configuring the |
| 32 | + * temperature and pressure for the well stream and the outlet pressure for the compressor, running |
| 33 | + * the process, and asserting the expected outlet temperature of the compressor.</li> |
| 34 | + * </ul> |
| 35 | + * |
| 36 | + * <p> |
| 37 | + * Dependencies: |
| 38 | + * <ul> |
| 39 | + * <li>Logger: Used for logging debug information.</li> |
| 40 | + * <li>ProcessSystem: Represents a process system containing various units.</li> |
| 41 | + * <li>Stream: Represents a stream in the process system.</li> |
| 42 | + * <li>ThreePhaseSeparator: Represents a three-phase separator unit in the process system.</li> |
| 43 | + * <li>Compressor: Represents a compressor unit in the process system.</li> |
| 44 | + * <li>ProcessModel: Represents the combined process model.</li> |
| 45 | + * <li>Assertions: Used for asserting expected values in the test method.</li> |
| 46 | + * </ul> |
| 47 | + */ |
| 48 | +public class CombinedModelsTest { |
| 49 | + static Logger logger = LogManager.getLogger(CombinedModelsTest.class); |
| 50 | + |
| 51 | + public ProcessSystem getinletModel() { |
| 52 | + File file = new File("src/test/java/neqsim/process/processmodel"); |
| 53 | + String fileFluid1 = file.getAbsolutePath() + "/feedfluid.e300"; |
| 54 | + SystemInterface wellFluid = neqsim.thermo.util.readwrite.EclipseFluidReadWrite.read(fileFluid1); |
| 55 | + // wellFluid.setMultiPhaseCheck(true); |
| 56 | + |
| 57 | + Stream wellStreamHP = new neqsim.process.equipment.stream.Stream("HP well stream", wellFluid); |
| 58 | + wellStreamHP.setFlowRate(10.0, "MSm3/day"); |
| 59 | + |
| 60 | + ThreePhaseSeparator firstStageSeparator = |
| 61 | + new neqsim.process.equipment.separator.ThreePhaseSeparator("1st stage separator", |
| 62 | + wellStreamHP); |
| 63 | + |
| 64 | + ProcessSystem process1 = new ProcessSystem(); |
| 65 | + process1.add(wellStreamHP); |
| 66 | + process1.add(firstStageSeparator); |
| 67 | + |
| 68 | + return process1; |
| 69 | + }; |
| 70 | + |
| 71 | + public ProcessSystem getCompressorProcess() { |
| 72 | + |
| 73 | + neqsim.process.equipment.stream.Stream gasFeedStream = |
| 74 | + new neqsim.process.equipment.stream.Stream("compressor feed stream"); |
| 75 | + |
| 76 | + neqsim.process.equipment.compressor.Compressor compressor1 = |
| 77 | + new neqsim.process.equipment.compressor.Compressor("Compressor1", gasFeedStream); |
| 78 | + compressor1.setPolytropicEfficiency(0.56); |
| 79 | + compressor1.setUsePolytropicCalc(true); |
| 80 | + |
| 81 | + ProcessSystem process1 = new ProcessSystem(); |
| 82 | + process1.add(gasFeedStream); |
| 83 | + process1.add(compressor1); |
| 84 | + |
| 85 | + return process1; |
| 86 | + } |
| 87 | + |
| 88 | + public ProcessModel getCombinedModel() { |
| 89 | + ProcessSystem inletProcess = getinletModel(); |
| 90 | + ProcessSystem compressorProcess = getCompressorProcess(); |
| 91 | + ((Compressor) compressorProcess.getUnit("Compressor1")).setInletStream( |
| 92 | + ((ThreePhaseSeparator) inletProcess.getUnit("1st stage separator")).getGasOutStream()); |
| 93 | + |
| 94 | + |
| 95 | + ProcessModel combinedProcess = new ProcessModel(); |
| 96 | + combinedProcess.add("feed process", inletProcess); |
| 97 | + combinedProcess.add("compressor process", compressorProcess); |
| 98 | + |
| 99 | + return combinedProcess; |
| 100 | + } |
| 101 | + |
| 102 | + /** |
| 103 | + * Test method for the combined process model. |
| 104 | + * |
| 105 | + * This test sets up a combined process model, configures the temperature and pressure for the "HP |
| 106 | + * well stream" in the "feed process", and sets the outlet pressure for "Compressor1" in the |
| 107 | + * "compressor process". The process is then run, and the test asserts that the outlet temperature |
| 108 | + * of "Compressor1" is as expected. |
| 109 | + * |
| 110 | + * The expected outlet temperature of "Compressor1" is 164.44139872 degrees Celsius with a |
| 111 | + * tolerance of 0.1 degrees. |
| 112 | + */ |
| 113 | + @Test |
| 114 | + public void testCombinedProcess() { |
| 115 | + ProcessModel fullProcess = getCombinedModel(); |
| 116 | + fullProcess.setRunStep(true); |
| 117 | + |
| 118 | + // Set fullProcess properties; |
| 119 | + ((Stream) (fullProcess.get("feed process")).getUnit("HP well stream")).setTemperature(80.0, |
| 120 | + "C"); |
| 121 | + ((Stream) (fullProcess.get("feed process")).getUnit("HP well stream")).setPressure(50.0, |
| 122 | + "bara"); |
| 123 | + |
| 124 | + ((Compressor) (fullProcess.get("compressor process")).getUnit("Compressor1")) |
| 125 | + .setOutletPressure(100.0, "bara"); |
| 126 | + |
| 127 | + |
| 128 | + try { |
| 129 | + fullProcess.run(); |
| 130 | + } catch (Exception ex) { |
| 131 | + logger.debug(ex.getMessage(), ex); |
| 132 | + } |
| 133 | + |
| 134 | + Assertions.assertEquals(164.44139872, |
| 135 | + ((Compressor) fullProcess.get("compressor process").getUnit("Compressor1")) |
| 136 | + .getOutletStream().getTemperature("C"), |
| 137 | + 0.1); |
| 138 | + |
| 139 | + } |
| 140 | + |
| 141 | +} |
0 commit comments