From efabab67b53bf2728a1d0ed61e0df220cfc5eb18 Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Thu, 13 Jul 2023 20:50:22 +0300 Subject: [PATCH] Add new process plant test (#771) * added test * bug fix separator * logging off --- src/main/java/neqsim/log4j2.properties | 2 +- .../processEquipment/separator/Separator.java | 1 + .../processSystem/ProcessSystem.java | 2 - src/main/java/neqsim/util/unit/RateUnit.java | 4 +- .../processSystem/OilGasProcessTest.java | 132 ++++++++++++++++++ 5 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 src/test/java/neqsim/processSimulation/processSystem/OilGasProcessTest.java diff --git a/src/main/java/neqsim/log4j2.properties b/src/main/java/neqsim/log4j2.properties index 90cd5b571..006b69e07 100644 --- a/src/main/java/neqsim/log4j2.properties +++ b/src/main/java/neqsim/log4j2.properties @@ -15,6 +15,6 @@ appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n # Define the root logger with appender file - see https://www.tutorialspoint.com/log4j/log4j_logging_levels.htm -rootLogger.level = DEBUG +rootLogger.level = OFF rootLogger.appenderRefs = stdout rootLogger.appenderRef.stdout.ref = STDOUT \ No newline at end of file diff --git a/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java b/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java index 58fc40181..422cbde23 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/separator/Separator.java @@ -107,6 +107,7 @@ public Separator(String name) { public Separator(String name, StreamInterface inletStream) { this(name); setInletStream(inletStream); + numberOfInputStreams++; } /** diff --git a/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java b/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java index 2a72b3ba0..22f009503 100644 --- a/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java +++ b/src/main/java/neqsim/processSimulation/processSystem/ProcessSystem.java @@ -8,11 +8,9 @@ import java.util.Arrays; import java.util.Objects; import java.util.UUID; - import org.apache.commons.lang.SerializationUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import neqsim.processSimulation.SimulationBaseClass; import neqsim.processSimulation.conditionMonitor.ConditionMonitor; import neqsim.processSimulation.costEstimation.CostEstimateBaseClass; diff --git a/src/main/java/neqsim/util/unit/RateUnit.java b/src/main/java/neqsim/util/unit/RateUnit.java index 43da94497..15d47b6e1 100644 --- a/src/main/java/neqsim/util/unit/RateUnit.java +++ b/src/main/java/neqsim/util/unit/RateUnit.java @@ -9,6 +9,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import neqsim.thermo.ThermodynamicConstantsInterface; +import neqsim.util.exception.InvalidInputException; /** *

@@ -113,7 +114,8 @@ public double getConversionFactor(String name) { } else if (name.equals("idSm3/day")) { factor = 1.0 / molarmass / (3600.0 * 24.0) * stddens; } else { - logger.error("unit not supported " + name); + throw new RuntimeException( + new InvalidInputException(this, "getConversionFactor", "unit", "not supported")); } return factor; diff --git a/src/test/java/neqsim/processSimulation/processSystem/OilGasProcessTest.java b/src/test/java/neqsim/processSimulation/processSystem/OilGasProcessTest.java new file mode 100644 index 000000000..4c11b6c94 --- /dev/null +++ b/src/test/java/neqsim/processSimulation/processSystem/OilGasProcessTest.java @@ -0,0 +1,132 @@ +package neqsim.processSimulation.processSystem; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import neqsim.processSimulation.processEquipment.heatExchanger.Heater; +import neqsim.processSimulation.processEquipment.pump.Pump; +import neqsim.processSimulation.processEquipment.separator.Separator; +import neqsim.processSimulation.processEquipment.stream.Stream; +import neqsim.processSimulation.processEquipment.stream.StreamInterface; +import neqsim.processSimulation.processEquipment.util.Recycle; +import neqsim.processSimulation.processEquipment.valve.ThrottlingValve; +import neqsim.thermo.system.SystemInterface; +import neqsim.thermo.system.SystemSrkEos; + +public class OilGasProcessTest extends neqsim.NeqSimTest { + + @Test + public void runProcess() throws InterruptedException { + SystemInterface thermoSystem = new SystemSrkEos(298.0, 10.0); + thermoSystem.addComponent("water", 51.0); + thermoSystem.addComponent("nitrogen", 51.0); + thermoSystem.addComponent("CO2", 51.0); + thermoSystem.addComponent("methane", 51.0); + thermoSystem.addComponent("ethane", 51.0); + thermoSystem.addComponent("propane", 51.0); + thermoSystem.addComponent("i-butane", 51.0); + thermoSystem.addComponent("n-butane", 51.0); + thermoSystem.addComponent("iC5", 51.0); + thermoSystem.addComponent("nC5", 1.0); + + thermoSystem.addTBPfraction("C6", 1.0, 86.0 / 1000.0, 0.66); + thermoSystem.addTBPfraction("C7", 1.0, 91.0 / 1000.0, 0.74); + thermoSystem.addTBPfraction("C8", 1.0, 103.0 / 1000.0, 0.77); + thermoSystem.addTBPfraction("C9", 1.0, 117.0 / 1000.0, 0.79); + thermoSystem.addPlusFraction("C10_C12", 1.0, 145.0 / 1000.0, 0.80); + thermoSystem.addPlusFraction("C13_C14", 1.0, 181.0 / 1000.0, 0.8279); + thermoSystem.addPlusFraction("C15_C16", 1.0, 212.0 / 1000.0, 0.837); + thermoSystem.addPlusFraction("C17_C19", 1.0, 248.0 / 1000.0, 0.849); + thermoSystem.addPlusFraction("C20_C22", 1.0, 289.0 / 1000.0, 0.863); + thermoSystem.addPlusFraction("C23_C25", 1.0, 330.0 / 1000.0, 0.875); + thermoSystem.addPlusFraction("C26_C30", 1.0, 387.0 / 1000.0, 0.88); + thermoSystem.addPlusFraction("C31_C38", 1.0, 471.0 / 1000.0, 0.90); + thermoSystem.addPlusFraction("C38_C80", 1.0, 662.0 / 1000.0, 0.92); + thermoSystem.setMixingRule("classic"); + thermoSystem.setMultiPhaseCheck(true); + thermoSystem.setMolarComposition(new double[] {0.034266, 0.005269, 0.039189, 0.700553, 0.091154, + 0.050908, 0.007751, 0.014665, 0.004249, 0.004878, 0.004541, 0.007189, 0.006904, 0.004355, + 0.007658, 0.003861, 0.003301, 0.002624, 0.001857, 0.001320, 0.001426, 0.001164, 0.000916}); + // thermoSystem.prettyPrint(); + + Stream feedStream = new Stream("feed stream", thermoSystem); + feedStream.setFlowRate(604094, "kg/hr"); + feedStream.setTemperature(25.5, "C"); + feedStream.setPressure(26.0, "bara"); + + neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator seprator1stStage = + new neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator( + "1st stage separator", feedStream); + + ThrottlingValve valve1 = new ThrottlingValve("valve1", seprator1stStage.getLiquidOutStream()); + valve1.setOutletPressure(19.0); + + Heater oilHeater = new Heater("oil heater", valve1.getOutletStream()); + oilHeater.setOutTemperature(359.0); + + neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator seprator2ndStage = + new neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator( + "2nd stage separator", oilHeater.getOutletStream()); + + ThrottlingValve valve2 = new ThrottlingValve("valve2", seprator2ndStage.getLiquidOutStream()); + valve2.setOutletPressure(2.7); + + StreamInterface recircstream1 = valve2.getOutletStream().clone(); + recircstream1.setName("oilRecirc1"); + recircstream1.setFlowRate(1e-6, "kg/hr"); + + neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator seprator3rdStage = + new neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator( + "3rd stage separator"); + seprator3rdStage.addStream(valve2.getOutletStream()); + seprator3rdStage.addStream(recircstream1); + + + + ThrottlingValve pipeloss1st = + new ThrottlingValve("pipeloss1st", seprator3rdStage.getGasOutStream()); + pipeloss1st.setOutletPressure(2.7 - 0.03); + + Heater coolerLP = new Heater("cooler LP", pipeloss1st.getOutletStream()); + coolerLP.setOutTemperature(273.15 + 25.0); + + Separator sepregenGas = new Separator("sepregenGas", coolerLP.getOutletStream()); + + Pump oil1pump = new Pump("oil1pump", sepregenGas.getLiquidOutStream()); + oil1pump.setOutletPressure(19.); + + ThrottlingValve valveLP1 = new ThrottlingValve("valvseLP1", oil1pump.getOutletStream()); + valveLP1.setOutletPressure(2.7); + + Recycle recycle1 = new Recycle("oil recirc 1"); + recycle1.addStream(valveLP1.getOutletStream()); + recycle1.setOutletStream(recircstream1); + + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); + operations.add(feedStream); + operations.add(seprator1stStage); + operations.add(valve1); + operations.add(oilHeater); + operations.add(seprator2ndStage); + operations.add(valve2); + operations.add(recircstream1); + operations.add(seprator3rdStage); + operations.add(pipeloss1st); + operations.add(coolerLP); + operations.add(sepregenGas); + operations.add(oil1pump); + operations.add(valveLP1); + operations.add(recycle1); + + operations.run(); + + assertEquals(17195.25050, seprator3rdStage.getGasOutStream().getFlowRate("kg/hr"), 0.001); + + assertEquals(seprator3rdStage.getGasOutStream().getFlowRate("kg/hr"), + coolerLP.getOutletStream().getFlowRate("kg/hr"), 1e-4); + + // System.out.println("recycle flow " + recycle1.getOutletStream().getFlowRate("kg/hr")); + // valveLP1.getOutletStream().getFluid().prettyPrint(); + + } +}