From ca9c0e39a1a1e65259a5a1d0c9615b3e0c5f6b19 Mon Sep 17 00:00:00 2001 From: Sviatoslav Eroshkin <109044598+Sviatose@users.noreply.github.com> Date: Tue, 25 Jul 2023 13:48:28 +0000 Subject: [PATCH] fix: Total length Pipe Beggs And Brills --- .../pipeline/PipeBeggsAndBrills.java | 90 +++++++++++++------ 1 file changed, 61 insertions(+), 29 deletions(-) diff --git a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeBeggsAndBrills.java b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeBeggsAndBrills.java index 10225c458..6f1212fa9 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeBeggsAndBrills.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/pipeline/PipeBeggsAndBrills.java @@ -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; @@ -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 pressureProfile = new ArrayList<>(); - private List temperatureProfile = new ArrayList<>(); - private List pressureDropProfile = new ArrayList<>(); - private List flowRegimeProfile = new ArrayList<>(); + private List pressureProfile; + private List temperatureProfile; + private List pressureDropProfile; + private List flowRegimeProfile; - private List liquidSuperficialVelocityProfile = new ArrayList<>(); - private List gasSuperficialVelocityProfile = new ArrayList<>(); - private List mixtureSuperficialVelocityProfile = new ArrayList<>(); + private List liquidSuperficialVelocityProfile; + private List gasSuperficialVelocityProfile; + private List mixtureSuperficialVelocityProfile; - private List mixtureViscosityProfile = new ArrayList<>(); - private List mixtureDensityProfile = new ArrayList<>(); - private List liquidHoldupProfile = new ArrayList<>(); - private List mixtureReynoldsNumber = new ArrayList<>(); + private List mixtureViscosityProfile; + private List mixtureDensityProfile; + private List liquidHoldupProfile; + private List mixtureReynoldsNumber; - private List lengthProfile = new ArrayList<>(); - private List elevationProfile = new ArrayList<>(); + private List lengthProfile; + private List elevationProfile; /** *

@@ -196,7 +200,7 @@ public SystemInterface getThermoSystem() { * @param elevation a double */ public void setElevation(double elevation) { - this.elevation = elevation; + this.totalElevation = elevation; } @@ -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; } /** @@ -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")); + } + } /** @@ -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)); } /** @@ -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)); } /** @@ -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)); } /** @@ -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;