|
| 1 | +package neqsim.thermodynamicOperations.flashOps; |
| 2 | + |
| 3 | +import java.util.ArrayList; |
| 4 | +import java.util.List; |
| 5 | +import org.junit.jupiter.api.BeforeEach; |
| 6 | +import org.junit.jupiter.api.Test; |
| 7 | +import neqsim.thermo.phase.PhaseEosInterface; |
| 8 | +import neqsim.thermodynamicOperations.ThermodynamicOperations; |
| 9 | + |
| 10 | +/** |
| 11 | + * @author ESOL |
| 12 | + * |
| 13 | + */ |
| 14 | +class GudrunDegasser { |
| 15 | + static neqsim.thermo.system.SystemInterface testSystem = null; |
| 16 | + static ThermodynamicOperations testOps = null; |
| 17 | + |
| 18 | + /** |
| 19 | + * @throws java.lang.Exception |
| 20 | + */ |
| 21 | + @BeforeEach |
| 22 | + void setUp() throws Exception { |
| 23 | + testSystem = new neqsim.thermo.system.SystemPrEos(243.15, 300.0); |
| 24 | + testSystem.addComponent("methane", 90.0); |
| 25 | + testSystem.addComponent("ethane", 0.0); |
| 26 | + testSystem.addComponent("propane", 0.0); |
| 27 | + testSystem.addComponent("i-butane", 0.0); |
| 28 | + testSystem.addComponent("n-butane", 0.0); |
| 29 | + testSystem.addComponent("i-pentane", 0.0); |
| 30 | + testSystem.addComponent("n-pentane", 0.0); |
| 31 | + testSystem.addComponent("n-hexane", 0.0); |
| 32 | + testSystem.addComponent("nitrogen", 10.0); |
| 33 | + testSystem.setMixingRule("classic"); |
| 34 | + } |
| 35 | + |
| 36 | + /** |
| 37 | + * Test method for {@link neqsim.thermodynamicOperations.flashOps.PHFlash#run()}. |
| 38 | + */ |
| 39 | + @Test |
| 40 | + void testRun() { |
| 41 | + neqsim.thermo.system.SystemInterface fluid1 = |
| 42 | + new neqsim.thermo.system.SystemSrkCPAstatoil(273.15 + 42.0, 10.00); |
| 43 | + |
| 44 | + fluid1.addComponent("nitrogen", 0.110282450914383); |
| 45 | + fluid1.addComponent("CO2", 8.92014980316162); |
| 46 | + fluid1.addComponent("methane", 72.3870849609375); |
| 47 | + fluid1.addComponent("ethane", 5.19349813461304); |
| 48 | + fluid1.addComponent("propane", 5.20273065567017); |
| 49 | + fluid1.addComponent("i-butane", 0.436239510774612); |
| 50 | + fluid1.addComponent("n-butane", 1.39356422424316); |
| 51 | + fluid1.addComponent("i-pentane", 0.769362509250641); |
| 52 | + fluid1.addComponent("n-pentane", 0.543137490749359); |
| 53 | + fluid1.addComponent("n-hexane", 3.90587639808655); |
| 54 | + fluid1.addComponent("n-heptane", 3.90587639808655); |
| 55 | + fluid1.addComponent("water", 40.0); |
| 56 | + fluid1.setMixingRule(10); |
| 57 | + fluid1.setMultiPhaseCheck(true); |
| 58 | + |
| 59 | + ThermodynamicOperations testOps = new ThermodynamicOperations(fluid1); |
| 60 | + |
| 61 | + testOps.TPflash(); |
| 62 | + |
| 63 | + double[] intParameter = { |
| 64 | + |
| 65 | + -0.24, // "CO2" |
| 66 | + |
| 67 | + -0.721, // "methane" |
| 68 | + |
| 69 | + 0.11, // "ethane" |
| 70 | + |
| 71 | + 0.205, // "propane" |
| 72 | + |
| 73 | + 0.081, // "i-butane" |
| 74 | + |
| 75 | + 0.17, // "n-butane" |
| 76 | + |
| 77 | + 0.051, // "i-pentane" |
| 78 | + |
| 79 | + 0.1135, // "n-pentane" |
| 80 | + |
| 81 | + 0.0832, // "n-hexane" |
| 82 | + |
| 83 | + 0.0535 // "n-heptane" |
| 84 | + |
| 85 | + }; |
| 86 | + |
| 87 | + |
| 88 | + String[] componentNames = fluid1.getComponentNames(); |
| 89 | + |
| 90 | + for (int i = 0; i < intParameter.length; i++) { |
| 91 | + |
| 92 | + int componentIndex = findComponentIndex(componentNames, componentNames[i + 1]);// except |
| 93 | + // nitrogen 0 |
| 94 | + int waterIndex = findComponentIndex(componentNames, "water"); |
| 95 | + |
| 96 | + if (componentIndex != -1 && waterIndex != -1) { |
| 97 | + |
| 98 | + ((PhaseEosInterface) fluid1.getPhases()[0]).getMixingRule() |
| 99 | + .setBinaryInteractionParameter(componentIndex, waterIndex, intParameter[i]); |
| 100 | + |
| 101 | + ((PhaseEosInterface) fluid1.getPhases()[1]).getMixingRule() |
| 102 | + .setBinaryInteractionParameter(componentIndex, waterIndex, intParameter[i]); |
| 103 | + |
| 104 | + } else { |
| 105 | + } |
| 106 | + } |
| 107 | + |
| 108 | + testOps.TPflash(); |
| 109 | + fluid1.prettyPrint(); |
| 110 | + |
| 111 | + List<Double> molarComposition = new ArrayList<>(); |
| 112 | + molarComposition.add(0.07649963805789309); |
| 113 | + molarComposition.add(10.028287212684818); |
| 114 | + molarComposition.add(49.52052228615394); |
| 115 | + molarComposition.add(3.64093888905641); |
| 116 | + molarComposition.add(3.6620992636511893); |
| 117 | + molarComposition.add(0.2995511776378937); |
| 118 | + molarComposition.add(0.9605423088257289); |
| 119 | + molarComposition.add(0.5032398365065283); |
| 120 | + molarComposition.add(0.36145746378993904); |
| 121 | + molarComposition.add(0.2364703087561068); |
| 122 | + molarComposition.add(2.732003176453634); |
| 123 | + molarComposition.add(27.978388438425913); |
| 124 | + |
| 125 | + double[] molarCompositionArray = |
| 126 | + molarComposition.stream().mapToDouble(Double::doubleValue).toArray(); |
| 127 | + |
| 128 | + neqsim.thermo.system.SystemInterface fluid_test_separator = fluid1.clone(); |
| 129 | + fluid_test_separator.setMolarComposition(molarCompositionArray); |
| 130 | + |
| 131 | + neqsim.processSimulation.processEquipment.stream.Stream inlet_stream_test_sep = |
| 132 | + new neqsim.processSimulation.processEquipment.stream.Stream("TEST_SEPARATOR_INLET", |
| 133 | + fluid_test_separator); |
| 134 | + inlet_stream_test_sep.setTemperature(72.6675872802734, "C"); |
| 135 | + inlet_stream_test_sep.setPressure(10.6767892837524, "bara"); |
| 136 | + inlet_stream_test_sep.setFlowRate(721.3143271348611, "kg/hr"); |
| 137 | + inlet_stream_test_sep.run(); |
| 138 | + |
| 139 | + |
| 140 | + neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator test_separator = |
| 141 | + new neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator( |
| 142 | + inlet_stream_test_sep); |
| 143 | + test_separator.setName("TEST_SEPARATOR"); |
| 144 | + test_separator.run(); |
| 145 | + test_separator.getWaterOutStream().getThermoSystem().prettyPrint(); |
| 146 | + |
| 147 | + neqsim.processSimulation.processEquipment.heatExchanger.Heater heater_TP_setter_test_stream = |
| 148 | + new neqsim.processSimulation.processEquipment.heatExchanger.Heater( |
| 149 | + "TP_SETTER_FOR_THE_DEGASSER_TEST_SEP_STREAM", test_separator.getWaterOutStream()); |
| 150 | + heater_TP_setter_test_stream.setOutPressure(5.9061164855957 - 0.01, "bara"); |
| 151 | + heater_TP_setter_test_stream.setOutTemperature(79.8487854003906, "C"); |
| 152 | + heater_TP_setter_test_stream.run(); |
| 153 | + System.out.println("Gas out from degasser " + heater_TP_setter_test_stream.getOutStream() |
| 154 | + .getFluid().getPhase("gas").getFlowRate("kg/hr")); |
| 155 | + heater_TP_setter_test_stream.getOutStream().getThermoSystem().prettyPrint(); |
| 156 | + |
| 157 | + neqsim.processSimulation.processEquipment.heatExchanger.Heater heater_TP_setter_test_stream2 = |
| 158 | + new neqsim.processSimulation.processEquipment.heatExchanger.Heater( |
| 159 | + "TP_SETTER_FOR_THE_DEGASSER_TEST_SEP_STREAM", test_separator.getWaterOutStream()); |
| 160 | + heater_TP_setter_test_stream2.setOutPressure(5.9061164855957, "bara"); |
| 161 | + heater_TP_setter_test_stream2.setOutTemperature(79.8487854003906, "C"); |
| 162 | + heater_TP_setter_test_stream2.run(); |
| 163 | + |
| 164 | + System.out.println("Gas out from degasser2 " + heater_TP_setter_test_stream2.getOutStream() |
| 165 | + .getFluid().getPhase("gas").getFlowRate("kg/hr")); |
| 166 | + |
| 167 | + } |
| 168 | + |
| 169 | + |
| 170 | + |
| 171 | + private int findComponentIndex(String[] componentNames, String componentName) { |
| 172 | + |
| 173 | + for (int i = 0; i < componentNames.length; i++) { |
| 174 | + |
| 175 | + if (componentNames[i].equals(componentName)) { |
| 176 | + |
| 177 | + return i; |
| 178 | + |
| 179 | + } |
| 180 | + } |
| 181 | + |
| 182 | + return -1; // Component not found |
| 183 | + |
| 184 | + } |
| 185 | +} |
0 commit comments