diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeBeggsAndBrills.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeBeggsAndBrills.java index 67b6360854..9b1574ecee 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeBeggsAndBrills.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeBeggsAndBrills.java @@ -21,7 +21,7 @@ public class PipeBeggsAndBrills extends Pipeline { int iteration; // Inlet pressure of the pipeline (initialization) - private double inletPressure = 0; + private double inletPressure = Double.NaN; private double totalPressureDrop = 0; @@ -33,7 +33,7 @@ public class PipeBeggsAndBrills extends Pipeline { String maxflowunit = "kg/hr"; // Inside diameter of the pipe [m] - private double insideDiameter = 0.1; + private double insideDiameter = Double.NaN; // Roughness of the pipe wall [m] private double pipeWallRoughness = 1e-5; @@ -42,7 +42,7 @@ public class PipeBeggsAndBrills extends Pipeline { private boolean runIsothermal = false; // Flow pattern of the fluid in the pipe - private String regime = "unknown"; + private String regime; // Volume fraction of liquid in the input mixture private double inputVolumeFractionLiquid; @@ -129,7 +129,7 @@ public class PipeBeggsAndBrills extends Pipeline { private List mixtureViscosityProfile; private List mixtureDensityProfile; - + private List liquidHoldupProfile; private List mixtureReynoldsNumber; @@ -339,11 +339,11 @@ public void calculateMissingValue() { new neqsim.util.exception.InvalidInputException("PipeBeggsAndBrills", "calcMissingValue", "elevation", "- cannot be higher than length of the pipe" + length)); } - - if (Double.isNaN(totalElevation) || Double.isNaN(totalLength) || Double.isNaN(angle)) { + if (Double.isNaN(totalElevation) || Double.isNaN(totalLength) || Double.isNaN(angle) + || Double.isNaN(insideDiameter)) { throw new RuntimeException( new neqsim.util.exception.InvalidInputException("PipeBeggsAndBrills", "calcMissingValue", - "elevation or length or angle", "cannot be null")); + "elevation or length or angle or inlet diameter", "cannot be null")); } } @@ -397,6 +397,7 @@ public String calcFlowRegime() { } else { supLiquidVel = system.getPhase(1).getFlowRate("ft3/sec") / area; } + supGasVel = system.getPhase(0).getFlowRate("ft3/sec") / area; supMixVel = supLiquidVel + supGasVel; @@ -440,7 +441,8 @@ public String calcFlowRegime() { } else if (mixtureFroudeNumber > L2 && mixtureFroudeNumber < L3) { regime = "TRANSITION"; } else if (inputVolumeFractionLiquid < 0.1 || inputVolumeFractionLiquid > 0.9) { - regime = "Single Phase"; + regime = "INTERMITTENT"; + } else { logger.debug("Flow regime is not found"); } @@ -646,13 +648,13 @@ public double calcFrictionPressureLoss() { */ public double calcPressureDrop() { convertSystemUnitToImperial(); + regime = "unknown"; calcFlowRegime(); hydrostaticPressureDrop = calcHydrostaticPressureDifference(); frictionPressureLoss = calcFrictionPressureLoss(); pressureDrop = (hydrostaticPressureDrop + frictionPressureLoss); convertSystemUnitToMetric(); iteration = iteration + 1; - return pressureDrop; } @@ -702,7 +704,7 @@ public void run(UUID id) { for (int i = 1; i <= numberOfIncrements; i++) { lengthProfile.add(cumulativeLength); elevationProfile.add(cumulativeElevation); - incrementsProfile.add(i-1); + incrementsProfile.add(i - 1); cumulativeLength += length; cumulativeElevation += elevation; @@ -797,7 +799,6 @@ public int getNumberOfIncrements() { - /** * @return angle in degrees */ diff --git a/src/test/java/neqsim/processSimulation/processEquipment/pipeline/BeggsAndBrillsPipeTest.java b/src/test/java/neqsim/processSimulation/processEquipment/pipeline/BeggsAndBrillsPipeTest.java index 65f5ed72d4..83ee14e221 100644 --- a/src/test/java/neqsim/processSimulation/processEquipment/pipeline/BeggsAndBrillsPipeTest.java +++ b/src/test/java/neqsim/processSimulation/processEquipment/pipeline/BeggsAndBrillsPipeTest.java @@ -9,9 +9,8 @@ public class BeggsAndBrillsPipeTest { @Test public void testFlowNoVolumeCorrection() { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 15), - ThermodynamicConstantsInterface.referencePressure); + neqsim.thermo.system.SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos( + (273.15 + 15), ThermodynamicConstantsInterface.referencePressure); testSystem.addComponent("nC10", 50, "MSm^3/day"); testSystem.setMixingRule(2); @@ -28,9 +27,8 @@ public void testFlowNoVolumeCorrection() { @Test public void testFlowVolumeCorrection() { - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 15), - ThermodynamicConstantsInterface.referencePressure); + neqsim.thermo.system.SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos( + (273.15 + 15), ThermodynamicConstantsInterface.referencePressure); testSystem.addComponent("nC10", 50, "MSm^3/day"); testSystem.setMixingRule(2); @@ -52,9 +50,8 @@ public void testPipeLineBeggsAndBrills() { double temperature = 40; // C double massFlowRate = 1100000.000000000; - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 45), - ThermodynamicConstantsInterface.referencePressure); + neqsim.thermo.system.SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos( + (273.15 + 45), ThermodynamicConstantsInterface.referencePressure); testSystem.addComponent("methane", 0.5); testSystem.addComponent("nC10", 0.5); @@ -90,7 +87,8 @@ public void testPipeLineBeggsAndBrills() { Assertions.assertEquals(pressureOut, 27.5402, 1e-4); Assertions.assertEquals(temperatureOut, 39.3374, 1e-4); - Assertions.assertEquals(pipe.getOutletSuperficialVelocity(), pipe.getSegmentMixtureSuperficialVelocity(pipe.getNumberOfIncrements()), 0.1); + Assertions.assertEquals(pipe.getOutletSuperficialVelocity(), + pipe.getSegmentMixtureSuperficialVelocity(pipe.getNumberOfIncrements()), 0.1); } @@ -102,9 +100,8 @@ public void testPipeLineBeggsAndBrills2() { double temperature = 40; // C double massFlowRate = 110000.000000000; - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 45), - ThermodynamicConstantsInterface.referencePressure); + neqsim.thermo.system.SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos( + (273.15 + 45), ThermodynamicConstantsInterface.referencePressure); testSystem.addComponent("methane", 0.5); testSystem.addComponent("nC10", 0.5); @@ -137,10 +134,11 @@ public void testPipeLineBeggsAndBrills2() { double pressureOut = pipe.getOutletPressure(); double temperatureOut = pipe.getOutletTemperature() - 273.15; - - Assertions.assertEquals(pressureOut, 13.735508907175728, 1e-4); - Assertions.assertEquals(temperatureOut, 38.82331519652632, 1e-4); - Assertions.assertEquals(pipe.getOutletSuperficialVelocity(), pipe.getSegmentMixtureSuperficialVelocity(pipe.getNumberOfIncrements()), 0.1); + Assertions.assertEquals(pressureOut, 13.366143179275166, 1e-4); + Assertions.assertEquals(temperatureOut, 38.8, 0.1); + Assertions.assertEquals(pipe.getFlowRegime(), "INTERMITTENT"); + Assertions.assertEquals(pipe.getOutletSuperficialVelocity(), + pipe.getSegmentMixtureSuperficialVelocity(pipe.getNumberOfIncrements()), 0.1); } @@ -153,9 +151,8 @@ public void testPipeLineBeggsAndBrills3() { double temperature = 80; // C double massFlowRate = 110000.000000000; - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 45), - ThermodynamicConstantsInterface.referencePressure); + neqsim.thermo.system.SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos( + (273.15 + 45), ThermodynamicConstantsInterface.referencePressure); testSystem.addComponent("methane", 0.3); testSystem.addComponent("nC10", 0.4); @@ -207,7 +204,8 @@ public void testPipeLineBeggsAndBrills3() { Assertions.assertEquals(pipe.getSegmentMixtureReynoldsNumber(10), 2196973.270922545, 1.0); Assertions.assertEquals(pipe.getSegmentLength(10), 410.0, 1.0); Assertions.assertEquals(pipe.getSegmentElevation(10), 300, 1.0); - Assertions.assertEquals(pipe.getOutletSuperficialVelocity(), pipe.getSegmentMixtureSuperficialVelocity(pipe.getNumberOfIncrements()), 0.1); + Assertions.assertEquals(pipe.getOutletSuperficialVelocity(), + pipe.getSegmentMixtureSuperficialVelocity(pipe.getNumberOfIncrements()), 0.1); } @@ -220,9 +218,8 @@ public void testPipeLineBeggsAndBrills4() { double temperature = 80; // C double massFlowRate = 110000.000000000; - neqsim.thermo.system.SystemInterface testSystem = - new neqsim.thermo.system.SystemSrkEos((273.15 + 45), - ThermodynamicConstantsInterface.referencePressure); + neqsim.thermo.system.SystemInterface testSystem = new neqsim.thermo.system.SystemSrkEos( + (273.15 + 45), ThermodynamicConstantsInterface.referencePressure); testSystem.addComponent("methane", 1); testSystem.setMixingRule(2); @@ -273,12 +270,12 @@ public void testPipeLineBeggsAndBrills4() { Assertions.assertEquals(pipe.getSegmentLength(10), 1500.0, 1.0); Assertions.assertEquals(pipe.getSegmentElevation(10), -1000, 1.0); Assertions.assertEquals(pipe.getNumberOfIncrements(), 10, 0.1); - Assertions.assertEquals(pipe.getOutletSuperficialVelocity(), pipe.getSegmentMixtureSuperficialVelocity(pipe.getNumberOfIncrements()), 0.1); + Assertions.assertEquals(pipe.getOutletSuperficialVelocity(), + pipe.getSegmentMixtureSuperficialVelocity(pipe.getNumberOfIncrements()), 0.1); - neqsim.thermo.system.SystemInterface testSystem2 = - new neqsim.thermo.system.SystemSrkEos((273.15 + 45), - ThermodynamicConstantsInterface.referencePressure); + neqsim.thermo.system.SystemInterface testSystem2 = new neqsim.thermo.system.SystemSrkEos( + (273.15 + 45), ThermodynamicConstantsInterface.referencePressure); testSystem2.addComponent("water", 1); testSystem2.setMixingRule(2); @@ -312,9 +309,8 @@ public void testPipeLineBeggsAndBrills4() { - neqsim.thermo.system.SystemInterface testSystem3 = - new neqsim.thermo.system.SystemSrkEos((273.15 + 45), - ThermodynamicConstantsInterface.referencePressure); + neqsim.thermo.system.SystemInterface testSystem3 = new neqsim.thermo.system.SystemSrkEos( + (273.15 + 45), ThermodynamicConstantsInterface.referencePressure); testSystem3.addComponent("ethane", 1); testSystem3.setMixingRule(2); @@ -357,4 +353,5 @@ public void testPipeLineBeggsAndBrills4() { } + }