Skip to content

Commit

Permalink
fix: pipeBeggsAndBrills
Browse files Browse the repository at this point in the history
  • Loading branch information
Sviatose committed Feb 8, 2024
1 parent ce64f51 commit e4c23ad
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -129,7 +129,7 @@ public class PipeBeggsAndBrills extends Pipeline {

private List<Double> mixtureViscosityProfile;
private List<Double> mixtureDensityProfile;

private List<Double> liquidHoldupProfile;
private List<Double> mixtureReynoldsNumber;

Expand Down Expand Up @@ -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"));
}

}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -797,7 +799,6 @@ public int getNumberOfIncrements() {




/**
* @return angle in degrees
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);

}

Expand All @@ -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);
Expand Down Expand Up @@ -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);

}

Expand All @@ -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);
Expand Down Expand Up @@ -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);

}

Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -357,4 +353,5 @@ public void testPipeLineBeggsAndBrills4() {

}


}

0 comments on commit e4c23ad

Please sign in to comment.