Skip to content

Commit

Permalink
fix: add more get methods (#902)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sviatose authored Jan 12, 2024
1 parent f0ff6fa commit e00626f
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,13 @@ public class PipeBeggsAndBrills extends Pipeline {

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

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

private List<Double> lengthProfile;
private List<Double> elevationProfile;
private List<Integer> incrementsProfile;

/**
* <p>
Expand Down Expand Up @@ -398,10 +400,6 @@ public String calcFlowRegime() {
supGasVel = system.getPhase(0).getFlowRate("ft3/sec") / area;
supMixVel = supLiquidVel + supGasVel;

liquidSuperficialVelocityProfile.add(supLiquidVel / 3.2808399); // to meters
gasSuperficialVelocityProfile.add(supGasVel / 3.2808399);
mixtureSuperficialVelocityProfile.add(supMixVel / 3.2808399);

mixtureFroudeNumber = Math.pow(supMixVel, 2) / (32.174 * insideDiameter);
inputVolumeFractionLiquid = supLiquidVel / supMixVel;
} else {
Expand All @@ -418,6 +416,10 @@ public String calcFlowRegime() {
}
}

liquidSuperficialVelocityProfile.add(supLiquidVel / 3.2808399); // to meters
gasSuperficialVelocityProfile.add(supGasVel / 3.2808399);
mixtureSuperficialVelocityProfile.add(supMixVel / 3.2808399);

double L1 = 316 * Math.pow(inputVolumeFractionLiquid, 0.302);
double L2 = 0.0009252 * Math.pow(inputVolumeFractionLiquid, -2.4684);
double L3 = 0.1 * Math.pow(inputVolumeFractionLiquid, -1.4516);
Expand Down Expand Up @@ -584,11 +586,11 @@ public double calcFrictionPressureLoss() {
if (system.getNumberOfPhases() != 1) {
if (regime != "Single Phase") {
double y = inputVolumeFractionLiquid / (Math.pow(El, 2));
if(1 < y && y < 1.2){
S = Math.log(2.2*y - 1.2);
}
else {
S = Math.log(y) / (-0.0523 + 3.18 * Math.log(y) - 0.872 * Math.pow(Math.log(y), 2.0) + 0.01853 * Math.pow(Math.log(y), 4));
if (1 < y && y < 1.2) {
S = Math.log(2.2 * y - 1.2);
} else {
S = Math.log(y) / (-0.0523 + 3.18 * Math.log(y) - 0.872 * Math.pow(Math.log(y), 2.0)
+ 0.01853 * Math.pow(Math.log(y), 4));
}
if (system.getNumberOfPhases() == 3) {
rhoNoSlip = mixtureLiquidDensity * inputVolumeFractionLiquid
Expand Down Expand Up @@ -649,7 +651,7 @@ public double calcPressureDrop() {
frictionPressureLoss = calcFrictionPressureLoss();
pressureDrop = (hydrostaticPressureDrop + frictionPressureLoss);
convertSystemUnitToMetric();
iteration = iteration + 1;
iteration = iteration + 1;

return pressureDrop;
}
Expand Down Expand Up @@ -677,6 +679,7 @@ public void run(UUID id) {

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

calculateMissingValue();
double enthalpyInlet = Double.NaN;
Expand All @@ -693,20 +696,24 @@ public void run(UUID id) {
double pipeInletPressure = system.getPressure();
cumulativeLength = 0.0;
cumulativeElevation = 0.0;
pressureProfile.add(system.getPressure()); // pressure at segment 0
temperatureProfile.add(system.getTemperature()); // temperature at segment 0
pressureDropProfile.add(0.0); // DP at segment 0
for (int i = 1; i <= numberOfIncrements; i++) {
cumulativeLength += length;
cumulativeElevation += elevation;

lengthProfile.add(cumulativeLength);
elevationProfile.add(cumulativeElevation);
incrementsProfile.add(i-1);

cumulativeLength += length;
cumulativeElevation += elevation;

inletPressure = system.getPressure();
pressureDrop = calcPressureDrop();
pressureDropProfile.add(pressureDrop);
pressureOut = inletPressure - pressureDrop;
pressureProfile.add(pressureOut);
if (pressureOut < 0) {
throw new RuntimeException(new neqsim.util.exception.InvalidInputException(
throw new RuntimeException(new neqsim.util.exception.InvalidOutputException(
"PipeBeggsAndBrills", "run: calcOutletPressure", "pressure out",
"- Outlet pressure is negative" + pressureOut));
}
Expand All @@ -719,8 +726,15 @@ public void run(UUID id) {
temperatureProfile.add(system.getTemperature());
}
totalPressureDrop = pipeInletPressure - system.getPressure();
calcPressureDrop(); // to initialize final parameters
lengthProfile.add(cumulativeLength);
elevationProfile.add(cumulativeElevation);
incrementsProfile.add(getNumberOfIncrements());


outStream.setThermoSystem(system);
outStream.setCalculationIdentifier(id);

}

/**
Expand All @@ -746,18 +760,44 @@ public void displayResult() {

/**
* <p>
* getSuperficialVelocity.
* getInletSuperficialVelocity.
* </p>
*
* @return a double
*/
public double getSuperficialVelocity() {
public double getInletSuperficialVelocity() {
return getInletStream().getThermoSystem().getFlowRate("kg/sec")
/ getInletStream().getThermoSystem().getDensity("kg/m3")
/ (Math.PI / 4.0 * Math.pow(insideDiameter, 2.0));
}


/**
* <p>
* getOutletSuperficialVelocity.
* </p>
*
* @return a double
*/
public double getOutletSuperficialVelocity() {
return getSegmentMixtureSuperficialVelocity(numberOfIncrements);
}


/**
* <p>
* getNumberOfIncrements
* </p>
*
* @return a double
*/
public int getNumberOfIncrements() {
return numberOfIncrements;
}




/**
* @return angle in degrees
*/
Expand Down Expand Up @@ -850,8 +890,8 @@ public List<Double> getPressureProfile() {
* @return segment pressure as double
*/
public Double getSegmentPressure(int index) {
if (index >= 1 && index < pressureProfile.size() + 1) {
return pressureProfile.get(index - 1);
if (index >= 0 && index < pressureProfile.size()) {
return pressureProfile.get(index);
} else {
throw new IndexOutOfBoundsException("Index is out of bounds.");
}
Expand All @@ -873,8 +913,8 @@ public List<Double> getPressureDropProfile() {
* @return Double
*/
public Double getSegmentPressureDrop(int index) {
if (index >= 1 && index < pressureDropProfile.size() + 1) {
return pressureDropProfile.get(index - 1);
if (index >= 0 && index < pressureDropProfile.size()) {
return pressureDropProfile.get(index);
} else {
throw new IndexOutOfBoundsException("Index is out of bounds.");
}
Expand All @@ -894,8 +934,8 @@ public List<Double> getTemperatureProfile() {
* @return Double
*/
public Double getSegmentTemperature(int index) {
if (index >= 1 && index < temperatureProfile.size() + 1) {
return temperatureProfile.get(index - 1);
if (index >= 0 && index < temperatureProfile.size()) {
return temperatureProfile.get(index);
} else {
throw new IndexOutOfBoundsException("Index is out of bounds.");
}
Expand All @@ -915,8 +955,8 @@ public List<String> getFlowRegimeProfile() {
* @return String
*/
public String getSegmentFlowRegime(int index) {
if (index >= 1 && index < flowRegimeProfile.size() + 1) {
return flowRegimeProfile.get(index - 1);
if (index >= 0 && index < flowRegimeProfile.size()) {
return flowRegimeProfile.get(index);
} else {
throw new IndexOutOfBoundsException("Index is out of bounds.");
}
Expand Down Expand Up @@ -993,6 +1033,13 @@ public List<Double> getLengthProfile() {
return new ArrayList<>(lengthProfile);
}

/**
* @return list of increments profile
*/
public List<Integer> getIncrementsProfile() {
return new ArrayList<>(incrementsProfile);
}



/**
Expand All @@ -1009,8 +1056,8 @@ public List<Double> getElevationProfile() {
* @return Double
*/
public Double getSegmentLiquidSuperficialVelocity(int index) {
if (index >= 1 && index <= liquidSuperficialVelocityProfile.size()) {
return liquidSuperficialVelocityProfile.get(index - 1);
if (index >= 0 && index <= liquidSuperficialVelocityProfile.size()) {
return liquidSuperficialVelocityProfile.get(index);
} else {
throw new IndexOutOfBoundsException("Index is out of bounds.");
}
Expand All @@ -1023,8 +1070,8 @@ public Double getSegmentLiquidSuperficialVelocity(int index) {
* @return Double
*/
public Double getSegmentGasSuperficialVelocity(int index) {
if (index >= 1 && index <= gasSuperficialVelocityProfile.size()) {
return gasSuperficialVelocityProfile.get(index - 1);
if (index >= 0 && index <= gasSuperficialVelocityProfile.size()) {
return gasSuperficialVelocityProfile.get(index);
} else {
throw new IndexOutOfBoundsException("Index is out of bounds.");
}
Expand All @@ -1037,8 +1084,8 @@ public Double getSegmentGasSuperficialVelocity(int index) {
* @return Double
*/
public Double getSegmentMixtureSuperficialVelocity(int index) {
if (index >= 1 && index <= mixtureSuperficialVelocityProfile.size()) {
return mixtureSuperficialVelocityProfile.get(index - 1);
if (index >= 0 && index <= mixtureSuperficialVelocityProfile.size()) {
return mixtureSuperficialVelocityProfile.get(index);
} else {
throw new IndexOutOfBoundsException("Index is out of bounds.");
}
Expand All @@ -1050,8 +1097,8 @@ public Double getSegmentMixtureSuperficialVelocity(int index) {
* @return Double
*/
public Double getSegmentMixtureViscosity(int index) {
if (index >= 1 && index <= mixtureViscosityProfile.size()) {
return mixtureViscosityProfile.get(index - 1);
if (index >= 0 && index <= mixtureViscosityProfile.size()) {
return mixtureViscosityProfile.get(index);
} else {
throw new IndexOutOfBoundsException("Index is out of bounds.");
}
Expand All @@ -1064,8 +1111,8 @@ public Double getSegmentMixtureViscosity(int index) {
* @return Double
*/
public Double getSegmentMixtureDensity(int index) {
if (index >= 1 && index <= mixtureDensityProfile.size()) {
return mixtureDensityProfile.get(index - 1);
if (index >= 0 && index <= mixtureDensityProfile.size()) {
return mixtureDensityProfile.get(index);
} else {
throw new IndexOutOfBoundsException("Index is out of bounds.");
}
Expand All @@ -1077,8 +1124,8 @@ public Double getSegmentMixtureDensity(int index) {
* @return Double
*/
public Double getSegmentLiquidHoldup(int index) {
if (index >= 1 && index <= liquidHoldupProfile.size()) {
return liquidHoldupProfile.get(index - 1);
if (index >= 0 && index <= liquidHoldupProfile.size()) {
return liquidHoldupProfile.get(index);
} else {
throw new IndexOutOfBoundsException("Index is out of bounds.");
}
Expand All @@ -1091,8 +1138,8 @@ public Double getSegmentLiquidHoldup(int index) {
* @return Double
*/
public Double getSegmentMixtureReynoldsNumber(int index) {
if (index >= 1 && index <= mixtureReynoldsNumber.size()) {
return mixtureReynoldsNumber.get(index - 1);
if (index >= 0 && index <= mixtureReynoldsNumber.size()) {
return mixtureReynoldsNumber.get(index);
} else {
throw new IndexOutOfBoundsException("Index is out of bounds.");
}
Expand All @@ -1105,8 +1152,8 @@ public Double getSegmentMixtureReynoldsNumber(int index) {
* @return Double
*/
public Double getSegmentLength(int index) {
if (index >= 1 && index <= lengthProfile.size()) {
return lengthProfile.get(index - 1);
if (index >= 0 && index <= lengthProfile.size()) {
return lengthProfile.get(index);
} else {
throw new IndexOutOfBoundsException("Index is out of bounds.");
}
Expand All @@ -1119,8 +1166,8 @@ public Double getSegmentLength(int index) {
* @return Double
*/
public Double getSegmentElevation(int index) {
if (index >= 1 && index <= elevationProfile.size()) {
return elevationProfile.get(index - 1);
if (index >= 0 && index <= elevationProfile.size()) {
return elevationProfile.get(index);
} else {
throw new IndexOutOfBoundsException("Index is out of bounds.");
}
Expand Down
69 changes: 69 additions & 0 deletions src/main/java/neqsim/util/exception/InvalidOutputException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package neqsim.util.exception;

/**
* <p>
* InvalidOutputException class.
* </p>
*
* @author Even Solbraa
* @version $Id: $Id
*/
public class InvalidOutputException extends neqsim.util.exception.ThermoException {
private static final long serialVersionUID = 1000;

/**
* Constructs an <code>InvalidOutputException</code> with the specified detail message.
*
* @param msg the detail message.
*/
@Deprecated
public InvalidOutputException(String msg) {
super(msg);
}

/**
* Constructs an <code>InvalidOutputException</code> with a default message.
*
* @param className Class that exception is raised from
* @param methodName Method that exception is raised from
* @param outputName Name of invalid output
*/
public InvalidOutputException(String className, String methodName, String outputName) {
super(className, methodName, "output " + outputName + " was invalid.");
}

/**
* Constructs an <code>InvalidOutputException</code> with the specified detail message.
*
* @param className Class that exception is raised from
* @param methodName Method that exception is raised from
* @param outputName Name of invalid output
* @param msg error message detailing output problem
*/
public InvalidOutputException(String className, String methodName, String outputName, String msg) {
super(className, methodName, "output " + outputName + " " + msg);
}

/**
* Constructs an <code>InvalidOutputException</code> with a default message.
*
* @param obj Object that exception is raised from
* @param methodName Method that exception is raised from
* @param outputName Name of invalid output
*/
public InvalidOutputException(Object obj, String methodName, String outputName) {
this(obj.getClass().getSimpleName(), methodName, outputName);
}

/**
* Constructs an <code>InvalidOutputException</code> with a default message.
*
* @param obj Object that exception is raised from
* @param methodName Method that exception is raised from
* @param outputName Name of invalid output
* @param msg error message detailing output problem
*/
public InvalidOutputException(Object obj, String methodName, String outputName, String msg) {
this(obj.getClass().getSimpleName(), methodName, outputName, msg);
}
}
Loading

0 comments on commit e00626f

Please sign in to comment.