Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added option to run isothermally pipe Beggs and Brills #779

Merged
merged 3 commits into from
Jul 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ public class PipeBeggsAndBrills extends Pipeline {
private static final long serialVersionUID = 1001;

// Inlet pressure of the pipeline (initialization)
double inletPressure = 0;
double totalPressureDrop = 0;
private double inletPressure = 0;

private double totalPressureDrop = 0;

// Outlet properties initialization [K] and [bar]
protected double temperatureOut = 270;
Expand All @@ -30,97 +31,103 @@ public class PipeBeggsAndBrills extends Pipeline {
String maxflowunit = "kg/hr";

// Inside diameter of the pipe [m]
double insideDiameter = 0.1;
private double insideDiameter = 0.1;

// Roughness of the pipe wall [m]
double pipeWallRoughness = 1e-5;
private double pipeWallRoughness = 1e-5;

// Flag to run isothermal calculations
private boolean runIsothermal = false;

// Flow pattern of the fluid in the pipe
private String regime = "unknown";

// Volume fraction of liquid in the input mixture
double inputVolumeFractionLiquid;
private double inputVolumeFractionLiquid;

// Froude number of the mixture
double mixtureFroudeNumber;
private double mixtureFroudeNumber;

// Specification of the pipe
String pipeSpecification = "AP02";
private String pipeSpecification = "AP02";

// Ref. Beggs and Brills
double A;
private double A;

// Area of the pipe [m2]
double area;
private double area;

// Superficial gas velocity in the pipe [m/s]
double supGasVel;
private double supGasVel;

// Superficial liquid velocity in the pipe [m/s]
double supLiquidVel;
private double supLiquidVel;

// Density of the mixture [kg/m3]
double mixtureDensity;
private double mixtureDensity;

// Hydrostatic pressure drop in the pipe [bar]
double hydrostaticPressureDrop;
private double hydrostaticPressureDrop;

// Holdup ref. Beggs and Brills
double El = 0;
private double El = 0;

// Superficial mixture velocity in the pipe [m/s]
double supMixVel;
private double supMixVel;

// Frictional pressure loss in the pipe [bar]
double frictionPressureLoss;
private double frictionPressureLoss;

// Total pressure drop in the pipe [bar]
double pressureDrop;
private double pressureDrop;

// Number of pipe increments for calculations
int numberOfIncrements = 5;
private int numberOfIncrements = 5;

// Length of the pipe [m]
double length = Double.NaN;
private double length = Double.NaN;

// Elevation of the pipe [m]
double elevation = Double.NaN;
private double elevation = Double.NaN;

// Angle of the pipe [degrees]
double angle = Double.NaN;
private double angle = Double.NaN;

// Density of the liquid in the mixture in case of water and oil phases present together
double mixtureLiquidDensity;
private double mixtureLiquidDensity;

// Viscosity of the liquid in the mixture in case of water and oil phases present together
double mixtureLiquidViscosity;
private double mixtureLiquidViscosity;

// Mass fraction of oil in the mixture in case of water and oil phases present together
double mixtureOilMassFraction;
private double mixtureOilMassFraction;

// Volume fraction of oil in the mixture in case of water and oil phases present together
double mixtureOilVolumeFraction;
private double mixtureOilVolumeFraction;

private double cumulativeLength = 0.0;

private double cumulativeElevation = 0.0;


// Results initialization (for each segment)

List<Double> pressureProfile = new ArrayList<>();
List<Double> temperatureProfile = new ArrayList<>();
List<Double> pressureDropProfile = new ArrayList<>();
List<String> flowRegimeProfile = new ArrayList<>();
private List<Double> pressureProfile = new ArrayList<>();
private List<Double> temperatureProfile = new ArrayList<>();
private List<Double> pressureDropProfile = new ArrayList<>();
private List<String> flowRegimeProfile = new ArrayList<>();

List<Double> liquidSuperficialVelocityProfile = new ArrayList<>();
List<Double> gasSuperficialVelocityProfile = new ArrayList<>();
List<Double> mixtureSuperficialVelocityProfile = new ArrayList<>();
private List<Double> liquidSuperficialVelocityProfile = new ArrayList<>();
private List<Double> gasSuperficialVelocityProfile = new ArrayList<>();
private List<Double> mixtureSuperficialVelocityProfile = new ArrayList<>();

List<Double> mixtureViscosityProfile = new ArrayList<>();
List<Double> mixtureDensityProfile = new ArrayList<>();
List<Double> liquidHoldupProfile = new ArrayList<>();
List<Double> mixtureReynoldsNumber = new ArrayList<>();
private List<Double> mixtureViscosityProfile = new ArrayList<>();
private List<Double> mixtureDensityProfile = new ArrayList<>();
private List<Double> liquidHoldupProfile = new ArrayList<>();
private List<Double> mixtureReynoldsNumber = new ArrayList<>();

List<Double> lengthProfile = new ArrayList<>();
List<Double> elevationProfile = new ArrayList<>();
private List<Double> lengthProfile = new ArrayList<>();
private List<Double> elevationProfile = new ArrayList<>();

/**
* <p>
Expand Down Expand Up @@ -250,6 +257,18 @@ public void setNumberOfIncrements(int numberOfIncrements) {
}


/**
* <p>
* Setter for the field <code>runIsothermal</code>.
* </p>
*
* @param runIsothermal a boolean
*/
public void setRunIsothermal(boolean runIsothermal) {
this.runIsothermal = runIsothermal;
}


/**
* Converts the input values from the system measurement units to imperial units. Needed because
* the main equations and coefficients are developed for imperial system
Expand Down Expand Up @@ -619,19 +638,23 @@ public double calcPressureDrop() {
@Override
public void run(UUID id) {
calculateMissingValue();
double enthalpyInlet = Double.NaN;
length = length / numberOfIncrements;
elevation = elevation / numberOfIncrements;
system = inStream.getThermoSystem().clone();
system.setMultiPhaseCheck(true);
ThermodynamicOperations testOps = new ThermodynamicOperations(system);
testOps.TPflash();
system.initProperties();
double enthalpyInlet = system.getEnthalpy();
if (!runIsothermal){
enthalpyInlet = system.getEnthalpy();
}
double pipeInletPressure = system.getPressure();
for (int i = 1; i <= numberOfIncrements; i++) {
cumulativeLength += length;
cumulativeElevation += elevation;

lengthProfile.add(length);
elevationProfile.add(elevation);
lengthProfile.add(cumulativeLength);
elevationProfile.add(cumulativeElevation);

inletPressure = system.getPressure();
pressureDrop = calcPressureDrop();
Expand All @@ -645,7 +668,9 @@ public void run(UUID id) {
}

system.setPressure(pressureOut);
testOps.PHflash(enthalpyInlet);
if (!runIsothermal){
testOps.PHflash(enthalpyInlet);
}
system.initProperties();
temperatureProfile.add(system.getTemperature());
}
Expand Down Expand Up @@ -675,12 +700,29 @@ public double getSuperficialVelocity() {


/**
* @return total length in meter
* @return angle in degrees
*/
public double getAngle() {
return angle;
}


/**
* @return total length of the pipe in m
*/
public double getLength() {
return length;
return cumulativeLength;
}

/**
* @return total elevation of the pipe in m
*/
public double getElevation() {
return cumulativeElevation;
}



/**
* <p>
* getDiameter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void testPipeLineBeggsAndBrills2() {
Stream stream_1 = new Stream("Stream1", testSystem);
stream_1.setFlowRate(massFlowRate, "kg/hr");

PipeBeggsAndBrills pipe = new PipeBeggsAndBrills(stream_1);
PipeBeggsAndBrills pipe = new PipeBeggsAndBrills("beggs and brils pipe 1", stream_1);
pipe.setPipeWallRoughness(0);
pipe.setLength(750.0);
pipe.setAngle(90);
Expand Down Expand Up @@ -158,7 +158,7 @@ public void testPipeLineBeggsAndBrills3() {
testSystem.setPressure(pressure, "bara");
testSystem.setTemperature(temperature, "C");
testSystem.setTotalFlowRate(massFlowRate, "kg/hr");

testSystem.setMultiPhaseCheck(true);

ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
testOps.TPflash();
Expand All @@ -183,22 +183,22 @@ public void testPipeLineBeggsAndBrills3() {
double pressureOut = pipe.getOutletPressure();
double temperatureOut = pipe.getOutletTemperature() - 273.15;

Assertions.assertEquals(pressureOut, 34.4716898025371, 1e-4);
Assertions.assertEquals(temperatureOut, 79.80343, 1e-4);
Assertions.assertEquals(pipe.getPressureDrop(), 15.5283101974629, 1e-4);
Assertions.assertEquals(pipe.getSegmentPressure(10), 34.4716898025371, 1e-4);
Assertions.assertEquals(pipe.getSegmentPressureDrop(10), 1.5468048987983438, 1e-4);
Assertions.assertEquals(pipe.getSegmentTemperature(10) - 273.15, 79.80343029302054, 1e-4);
Assertions.assertEquals(pressureOut, 34.4716898025371, 1);
Assertions.assertEquals(temperatureOut, 79.80343, 1);
Assertions.assertEquals(pipe.getPressureDrop(), 15.5283101974629, 1.0);
Assertions.assertEquals(pipe.getSegmentPressure(10), 34.4716898025371, 1.0);
Assertions.assertEquals(pipe.getSegmentPressureDrop(10), 1.5468048987983438, 1.0);
Assertions.assertEquals(pipe.getSegmentTemperature(10) - 273.15, 79.80343029302054, 1.0);
Assertions.assertEquals(pipe.getSegmentFlowRegime(10), "INTERMITTENT");
Assertions.assertEquals(pipe.getSegmentMixtureDensity(10), 233.1155792052253, 1e-4);
Assertions.assertEquals(pipe.getSegmentLiquidSuperficialVelocity(10), 3.357338501138603, 1e-4);
Assertions.assertEquals(pipe.getSegmentGasSuperficialVelocity(10), 7.109484383317198, 1e-4);
Assertions.assertEquals(pipe.getSegmentMixtureSuperficialVelocity(10), 10.466822884455802, 1e-4);
Assertions.assertEquals(pipe.getSegmentMixtureViscosity(10), 0.14329203901478244, 1e-4);
Assertions.assertEquals(pipe.getSegmentLiquidHoldup(10), 0.42601098053163294, 1e-4);
Assertions.assertEquals(pipe.getSegmentMixtureReynoldsNumber(10), 2127138.3343691113, 1e-4);
Assertions.assertEquals(pipe.getSegmentLength(10), 41.0, 1e-4);
Assertions.assertEquals(pipe.getSegmentElevation(10), 29.999999999999996, 1e-4);
Assertions.assertEquals(pipe.getSegmentMixtureDensity(10), 233.1155792052253, 1.0);
Assertions.assertEquals(pipe.getSegmentLiquidSuperficialVelocity(10), 3.357338501138603, 1.0);
Assertions.assertEquals(pipe.getSegmentGasSuperficialVelocity(10), 7.109484383317198, 1.0);
Assertions.assertEquals(pipe.getSegmentMixtureSuperficialVelocity(10), 10.466822884455802, 1.0);
Assertions.assertEquals(pipe.getSegmentMixtureViscosity(10), 0.14329203901478244, 1.0);
Assertions.assertEquals(pipe.getSegmentLiquidHoldup(10), 0.42601098053163294, 1.0);
Assertions.assertEquals(pipe.getSegmentMixtureReynoldsNumber(10), 2127138.3343691113, 1.0);
Assertions.assertEquals(pipe.getSegmentLength(10), 410.0, 1.0);
Assertions.assertEquals(pipe.getSegmentElevation(10), 300, 1.0);
}


Expand Down