Skip to content

Commit

Permalink
fix: Total length Pipe Beggs And Brills (#783)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sviatose authored Jul 25, 2023
1 parent f6ac3ab commit c25cf0c
Showing 1 changed file with 61 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ public class PipeBeggsAndBrills extends Pipeline {
private int numberOfIncrements = 5;

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

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

// Angle of the pipe [degrees]
private double angle = Double.NaN;
Expand All @@ -105,29 +105,33 @@ public class PipeBeggsAndBrills extends Pipeline {
// Volume fraction of oil in the mixture in case of water and oil phases present together
private double mixtureOilVolumeFraction;

private double cumulativeLength = 0.0;
private double cumulativeLength;

private double cumulativeElevation = 0.0;
private double cumulativeElevation;

//For segment calculation
double length;
double elevation;


// Results initialization (for each segment)

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

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

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

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

/**
* <p>
Expand Down Expand Up @@ -196,7 +200,7 @@ public SystemInterface getThermoSystem() {
* @param elevation a double
*/
public void setElevation(double elevation) {
this.elevation = elevation;
this.totalElevation = elevation;
}


Expand All @@ -208,7 +212,7 @@ public void setElevation(double elevation) {
* @param length the length to set
*/
public void setLength(double length) {
this.length = length;
this.totalLength = length;
}

/**
Expand Down Expand Up @@ -319,18 +323,25 @@ public void convertSystemUnitToMetric() {


public void calculateMissingValue() {
if (Double.isNaN(length)) {
length = calculateLength();
} else if (Double.isNaN(elevation)) {
elevation = calculateElevation();
if (Double.isNaN(totalLength)) {
totalLength = calculateLength();
} else if (Double.isNaN(totalElevation)) {
totalElevation = calculateElevation();
} else if (Double.isNaN(angle)) {
angle = calculateAngle();
}
if (Math.abs(elevation) > Math.abs(length)) {
if (Math.abs(totalElevation) > Math.abs(totalLength)) {
throw new RuntimeException(
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)) {
throw new RuntimeException(
new neqsim.util.exception.InvalidInputException("PipeBeggsAndBrills", "calcMissingValue",
"elevation or length or angle", "cannot be null"));
}

}

/**
Expand All @@ -339,7 +350,7 @@ public void calculateMissingValue() {
* @return the calculated length.
*/
private double calculateLength() {
return elevation / Math.sin(Math.toRadians(angle));
return totalElevation / Math.sin(Math.toRadians(angle));
}

/**
Expand All @@ -349,7 +360,7 @@ private double calculateLength() {
* @return the calculated elevation.
*/
private double calculateElevation() {
return length * Math.sin(Math.toRadians(angle));
return totalLength * Math.sin(Math.toRadians(angle));
}

/**
Expand All @@ -359,7 +370,7 @@ private double calculateElevation() {
* @return the calculated angle.
*/
private double calculateAngle() {
return Math.toDegrees(Math.asin(elevation / length));
return Math.toDegrees(Math.asin(totalElevation / totalLength));
}

/**
Expand Down Expand Up @@ -637,18 +648,39 @@ public double calcPressureDrop() {
/** {@inheritDoc} */
@Override
public void run(UUID id) {
pressureProfile = new ArrayList<>();
temperatureProfile = new ArrayList<>();

pressureDropProfile = new ArrayList<>();
flowRegimeProfile = new ArrayList<>();

liquidSuperficialVelocityProfile = new ArrayList<>();
gasSuperficialVelocityProfile = new ArrayList<>();
mixtureSuperficialVelocityProfile = new ArrayList<>();

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

lengthProfile = new ArrayList<>();
elevationProfile = new ArrayList<>();

calculateMissingValue();
double enthalpyInlet = Double.NaN;
length = length / numberOfIncrements;
elevation = elevation / numberOfIncrements;
length = totalLength / numberOfIncrements;
elevation = totalElevation / numberOfIncrements;
system = inStream.getThermoSystem().clone();
ThermodynamicOperations testOps = new ThermodynamicOperations(system);
testOps.TPflash();
system.initProperties();

if (!runIsothermal){
enthalpyInlet = system.getEnthalpy();
}
double pipeInletPressure = system.getPressure();
cumulativeLength = 0.0;
cumulativeElevation = 0.0;
for (int i = 1; i <= numberOfIncrements; i++) {
cumulativeLength += length;
cumulativeElevation += elevation;
Expand Down

0 comments on commit c25cf0c

Please sign in to comment.