-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'equinor:master' into getcompname
- Loading branch information
Showing
30 changed files
with
2,892 additions
and
1,243 deletions.
There are no files selected for viewing
163 changes: 163 additions & 0 deletions
163
src/main/java/neqsim/process/equipment/diffpressure/Orifice.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
package neqsim.process.equipment.diffpressure; | ||
|
||
import java.util.UUID; | ||
import neqsim.process.equipment.TwoPortEquipment; | ||
import neqsim.process.equipment.stream.StreamInterface; | ||
import neqsim.thermo.system.SystemInterface; | ||
|
||
public class Orifice extends TwoPortEquipment { | ||
private static final long serialVersionUID = 1L; | ||
private StreamInterface inputstream; | ||
private StreamInterface outputstream; | ||
private Double dp; | ||
private Double diameter; | ||
private Double diameter_outer; | ||
private Double C; | ||
private double orificeDiameter; | ||
private double pressureUpstream; | ||
private double pressureDownstream; | ||
private double dischargeCoefficient; | ||
|
||
public Orifice(String name) { | ||
super(name); | ||
} | ||
|
||
public Orifice(String name, double diameter, double orificeDiameter, double pressureUpstream, | ||
double pressureDownstream, double dischargeCoefficient) { | ||
super(name); | ||
this.diameter = diameter; | ||
this.orificeDiameter = orificeDiameter; | ||
this.pressureUpstream = pressureUpstream; | ||
this.pressureDownstream = pressureDownstream; | ||
this.dischargeCoefficient = dischargeCoefficient; | ||
} | ||
|
||
public void setOrificeParameters(Double diameter, Double diameter_outer, Double C) { | ||
this.diameter = diameter; | ||
this.diameter_outer = diameter_outer; | ||
this.C = C; | ||
} | ||
|
||
public Double calc_dp() { | ||
double beta = orificeDiameter / diameter; | ||
double beta2 = beta * beta; | ||
double beta4 = beta2 * beta2; | ||
double dP = pressureUpstream - pressureDownstream; | ||
|
||
double deltaW = (Math.sqrt(1.0 - beta4 * (1.0 - dischargeCoefficient * dischargeCoefficient)) | ||
- dischargeCoefficient * beta2) | ||
/ (Math.sqrt(1.0 - beta4 * (1.0 - dischargeCoefficient * dischargeCoefficient)) | ||
+ dischargeCoefficient * beta2) | ||
* dP; | ||
|
||
return deltaW; | ||
} | ||
|
||
/** | ||
* Calculates the orifice discharge coefficient using the Reader-Harris Gallagher method. | ||
* | ||
* @param D Upstream internal pipe diameter, in meters. | ||
* @param Do Diameter of orifice at flow conditions, in meters. | ||
* @param rho Density of fluid at P1, in kg/m^3. | ||
* @param mu Viscosity of fluid at P1, in Pa*s. | ||
* @param m Mass flow rate of fluid through the orifice, in kg/s. | ||
* @param taps Tap type ("corner", "flange", "D", or "D/2"). | ||
* @return Discharge coefficient of the orifice. | ||
*/ | ||
public static double calculateDischargeCoefficient(double D, double Do, double rho, double mu, | ||
double m, String taps) { | ||
double A_pipe = 0.25 * Math.PI * D * D; | ||
double v = m / (A_pipe * rho); | ||
double Re_D = rho * v * D / mu; | ||
double beta = Do / D; | ||
double beta2 = beta * beta; | ||
double beta4 = beta2 * beta2; | ||
double beta8 = beta4 * beta4; | ||
|
||
double L1; | ||
double L2_prime; | ||
if ("corner".equalsIgnoreCase(taps)) { | ||
L1 = 0.0; | ||
L2_prime = 0.0; | ||
} else if ("flange".equalsIgnoreCase(taps)) { | ||
L1 = L2_prime = 0.0254 / D; | ||
} else if ("D".equalsIgnoreCase(taps) || "D/2".equalsIgnoreCase(taps)) { | ||
L1 = 1.0; | ||
L2_prime = 0.47; | ||
} else { | ||
throw new IllegalArgumentException("Unsupported tap type: " + taps); | ||
} | ||
|
||
double A = Math.pow(19000 * beta / Re_D, 0.8); | ||
double M2_prime = 2.0 * L2_prime / (1.0 - beta); | ||
|
||
double deltaCUpstream = ((0.043 + 0.08 * Math.exp(-10 * L1) - 0.123 * Math.exp(-7 * L1)) | ||
* (1.0 - 0.11 * A) * beta4 / (1.0 - beta4)); | ||
|
||
double deltaCDownstream = | ||
-0.031 * (M2_prime - 0.8 * Math.pow(M2_prime, 1.1)) * Math.pow(beta, 1.3); | ||
double C_inf_C_s = | ||
0.5961 + 0.0261 * beta2 - 0.216 * beta8 + 0.000521 * Math.pow(1e6 * beta / Re_D, 0.7) | ||
+ (0.0188 + 0.0063 * A) * Math.pow(beta, 3.5) * Math.pow(1e6 / Re_D, 0.3); | ||
|
||
return C_inf_C_s + deltaCUpstream + deltaCDownstream; | ||
} | ||
|
||
/** | ||
* Calculates the expansibility factor for orifice plate calculations. | ||
* | ||
* @param D Upstream internal pipe diameter, in meters. | ||
* @param Do Diameter of orifice at flow conditions, in meters. | ||
* @param P1 Static pressure of fluid upstream, in Pa. | ||
* @param P2 Static pressure of fluid downstream, in Pa. | ||
* @param k Isentropic exponent of fluid. | ||
* @return Expansibility factor (1 for incompressible fluids). | ||
*/ | ||
public static double calculateExpansibility(double D, double Do, double P1, double P2, double k) { | ||
double beta = Do / D; | ||
double beta4 = Math.pow(beta, 4); | ||
return 1.0 - (0.351 + beta4 * (0.93 * beta4 + 0.256)) * (1.0 - Math.pow(P2 / P1, 1.0 / k)); | ||
} | ||
|
||
/** | ||
* Calculates the non-recoverable pressure drop across the orifice plate. | ||
* | ||
* @param D Upstream internal pipe diameter, in meters. | ||
* @param Do Diameter of orifice at flow conditions, in meters. | ||
* @param P1 Static pressure of fluid upstream, in Pa. | ||
* @param P2 Static pressure of fluid downstream, in Pa. | ||
* @param C Discharge coefficient. | ||
* @return Non-recoverable pressure drop, in Pa. | ||
*/ | ||
public static double calculatePressureDrop(double D, double Do, double P1, double P2, double C) { | ||
double beta = Do / D; | ||
double beta2 = beta * beta; | ||
double beta4 = beta2 * beta2; | ||
double dP = P1 - P2; | ||
double deltaW = (Math.sqrt(1.0 - beta4 * (1.0 - C * C)) - C * beta2) | ||
/ (Math.sqrt(1.0 - beta4 * (1.0 - C * C)) + C * beta2) * dP; | ||
return deltaW; | ||
} | ||
|
||
/** | ||
* Calculates the diameter ratio (beta) of the orifice plate. | ||
* | ||
* @param D Upstream internal pipe diameter, in meters. | ||
* @param Do Diameter of orifice at flow conditions, in meters. | ||
* @return Diameter ratio (beta). | ||
*/ | ||
public static double calculateBetaRatio(double D, double Do) { | ||
return Do / D; | ||
} | ||
|
||
@Override | ||
public void run(UUID uuid) { | ||
if (inputstream != null && outputstream != null) { | ||
double newPressure = inputstream.getPressure("bara") - calc_dp(); | ||
SystemInterface outfluid = (SystemInterface) inStream.clone(); | ||
outfluid.setPressure(newPressure); | ||
outStream.setFluid(outfluid); | ||
outStream.run(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/neqsim/process/equipment/pump/PumpChartAlternativeMapLookupExtrapolate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package neqsim.process.equipment.pump; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import neqsim.process.equipment.compressor.CompressorChartAlternativeMapLookupExtrapolate; | ||
|
||
/** | ||
* <p> | ||
* CompressorChartAlternativeMapLookupExtrapolate class. | ||
* </p> | ||
* | ||
* @author ASMF | ||
*/ | ||
public class PumpChartAlternativeMapLookupExtrapolate | ||
extends CompressorChartAlternativeMapLookupExtrapolate implements PumpChartInterface { | ||
/** Serialization version UID. */ | ||
private static final long serialVersionUID = 1000; | ||
/** Logger object for class. */ | ||
static Logger logger = LogManager.getLogger(PumpChartAlternativeMapLookupExtrapolate.class); | ||
boolean usePumpChart = false; | ||
|
||
@Override | ||
public double getHead(double flow, double speed) { | ||
// Implement the method logic here | ||
return getPolytropicHead(flow, speed); | ||
} | ||
|
||
@Override | ||
public boolean isUsePumpChart() { | ||
// Implement the method logic here | ||
return usePumpChart; | ||
} | ||
|
||
@Override | ||
public double getEfficiency(double flow, double speed) { | ||
// Implement the method logic here | ||
return getPolytropicEfficiency(flow, speed); | ||
} | ||
|
||
@Override | ||
public void setUsePumpChart(boolean usePumpChart) { | ||
this.usePumpChart = usePumpChart; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.