Skip to content

Commit 23e8b5a

Browse files
authored
Merge branch 'equinor:master' into getcompname
2 parents f12d319 + 31b92d3 commit 23e8b5a

30 files changed

+2892
-1243
lines changed
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
package neqsim.process.equipment.diffpressure;
2+
3+
import java.util.UUID;
4+
import neqsim.process.equipment.TwoPortEquipment;
5+
import neqsim.process.equipment.stream.StreamInterface;
6+
import neqsim.thermo.system.SystemInterface;
7+
8+
public class Orifice extends TwoPortEquipment {
9+
private static final long serialVersionUID = 1L;
10+
private StreamInterface inputstream;
11+
private StreamInterface outputstream;
12+
private Double dp;
13+
private Double diameter;
14+
private Double diameter_outer;
15+
private Double C;
16+
private double orificeDiameter;
17+
private double pressureUpstream;
18+
private double pressureDownstream;
19+
private double dischargeCoefficient;
20+
21+
public Orifice(String name) {
22+
super(name);
23+
}
24+
25+
public Orifice(String name, double diameter, double orificeDiameter, double pressureUpstream,
26+
double pressureDownstream, double dischargeCoefficient) {
27+
super(name);
28+
this.diameter = diameter;
29+
this.orificeDiameter = orificeDiameter;
30+
this.pressureUpstream = pressureUpstream;
31+
this.pressureDownstream = pressureDownstream;
32+
this.dischargeCoefficient = dischargeCoefficient;
33+
}
34+
35+
public void setOrificeParameters(Double diameter, Double diameter_outer, Double C) {
36+
this.diameter = diameter;
37+
this.diameter_outer = diameter_outer;
38+
this.C = C;
39+
}
40+
41+
public Double calc_dp() {
42+
double beta = orificeDiameter / diameter;
43+
double beta2 = beta * beta;
44+
double beta4 = beta2 * beta2;
45+
double dP = pressureUpstream - pressureDownstream;
46+
47+
double deltaW = (Math.sqrt(1.0 - beta4 * (1.0 - dischargeCoefficient * dischargeCoefficient))
48+
- dischargeCoefficient * beta2)
49+
/ (Math.sqrt(1.0 - beta4 * (1.0 - dischargeCoefficient * dischargeCoefficient))
50+
+ dischargeCoefficient * beta2)
51+
* dP;
52+
53+
return deltaW;
54+
}
55+
56+
/**
57+
* Calculates the orifice discharge coefficient using the Reader-Harris Gallagher method.
58+
*
59+
* @param D Upstream internal pipe diameter, in meters.
60+
* @param Do Diameter of orifice at flow conditions, in meters.
61+
* @param rho Density of fluid at P1, in kg/m^3.
62+
* @param mu Viscosity of fluid at P1, in Pa*s.
63+
* @param m Mass flow rate of fluid through the orifice, in kg/s.
64+
* @param taps Tap type ("corner", "flange", "D", or "D/2").
65+
* @return Discharge coefficient of the orifice.
66+
*/
67+
public static double calculateDischargeCoefficient(double D, double Do, double rho, double mu,
68+
double m, String taps) {
69+
double A_pipe = 0.25 * Math.PI * D * D;
70+
double v = m / (A_pipe * rho);
71+
double Re_D = rho * v * D / mu;
72+
double beta = Do / D;
73+
double beta2 = beta * beta;
74+
double beta4 = beta2 * beta2;
75+
double beta8 = beta4 * beta4;
76+
77+
double L1;
78+
double L2_prime;
79+
if ("corner".equalsIgnoreCase(taps)) {
80+
L1 = 0.0;
81+
L2_prime = 0.0;
82+
} else if ("flange".equalsIgnoreCase(taps)) {
83+
L1 = L2_prime = 0.0254 / D;
84+
} else if ("D".equalsIgnoreCase(taps) || "D/2".equalsIgnoreCase(taps)) {
85+
L1 = 1.0;
86+
L2_prime = 0.47;
87+
} else {
88+
throw new IllegalArgumentException("Unsupported tap type: " + taps);
89+
}
90+
91+
double A = Math.pow(19000 * beta / Re_D, 0.8);
92+
double M2_prime = 2.0 * L2_prime / (1.0 - beta);
93+
94+
double deltaCUpstream = ((0.043 + 0.08 * Math.exp(-10 * L1) - 0.123 * Math.exp(-7 * L1))
95+
* (1.0 - 0.11 * A) * beta4 / (1.0 - beta4));
96+
97+
double deltaCDownstream =
98+
-0.031 * (M2_prime - 0.8 * Math.pow(M2_prime, 1.1)) * Math.pow(beta, 1.3);
99+
double C_inf_C_s =
100+
0.5961 + 0.0261 * beta2 - 0.216 * beta8 + 0.000521 * Math.pow(1e6 * beta / Re_D, 0.7)
101+
+ (0.0188 + 0.0063 * A) * Math.pow(beta, 3.5) * Math.pow(1e6 / Re_D, 0.3);
102+
103+
return C_inf_C_s + deltaCUpstream + deltaCDownstream;
104+
}
105+
106+
/**
107+
* Calculates the expansibility factor for orifice plate calculations.
108+
*
109+
* @param D Upstream internal pipe diameter, in meters.
110+
* @param Do Diameter of orifice at flow conditions, in meters.
111+
* @param P1 Static pressure of fluid upstream, in Pa.
112+
* @param P2 Static pressure of fluid downstream, in Pa.
113+
* @param k Isentropic exponent of fluid.
114+
* @return Expansibility factor (1 for incompressible fluids).
115+
*/
116+
public static double calculateExpansibility(double D, double Do, double P1, double P2, double k) {
117+
double beta = Do / D;
118+
double beta4 = Math.pow(beta, 4);
119+
return 1.0 - (0.351 + beta4 * (0.93 * beta4 + 0.256)) * (1.0 - Math.pow(P2 / P1, 1.0 / k));
120+
}
121+
122+
/**
123+
* Calculates the non-recoverable pressure drop across the orifice plate.
124+
*
125+
* @param D Upstream internal pipe diameter, in meters.
126+
* @param Do Diameter of orifice at flow conditions, in meters.
127+
* @param P1 Static pressure of fluid upstream, in Pa.
128+
* @param P2 Static pressure of fluid downstream, in Pa.
129+
* @param C Discharge coefficient.
130+
* @return Non-recoverable pressure drop, in Pa.
131+
*/
132+
public static double calculatePressureDrop(double D, double Do, double P1, double P2, double C) {
133+
double beta = Do / D;
134+
double beta2 = beta * beta;
135+
double beta4 = beta2 * beta2;
136+
double dP = P1 - P2;
137+
double deltaW = (Math.sqrt(1.0 - beta4 * (1.0 - C * C)) - C * beta2)
138+
/ (Math.sqrt(1.0 - beta4 * (1.0 - C * C)) + C * beta2) * dP;
139+
return deltaW;
140+
}
141+
142+
/**
143+
* Calculates the diameter ratio (beta) of the orifice plate.
144+
*
145+
* @param D Upstream internal pipe diameter, in meters.
146+
* @param Do Diameter of orifice at flow conditions, in meters.
147+
* @return Diameter ratio (beta).
148+
*/
149+
public static double calculateBetaRatio(double D, double Do) {
150+
return Do / D;
151+
}
152+
153+
@Override
154+
public void run(UUID uuid) {
155+
if (inputstream != null && outputstream != null) {
156+
double newPressure = inputstream.getPressure("bara") - calc_dp();
157+
SystemInterface outfluid = (SystemInterface) inStream.clone();
158+
outfluid.setPressure(newPressure);
159+
outStream.setFluid(outfluid);
160+
outStream.run();
161+
}
162+
}
163+
}

src/main/java/neqsim/process/equipment/pump/Pump.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class Pump extends TwoPortEquipment implements PumpInterface {
4242
public double isentropicEfficiency = 1.0;
4343
public boolean powerSet = false;
4444
private String pressureUnit = "bara";
45-
private PumpChart pumpChart = new PumpChart();
45+
private PumpChartInterface pumpChart = new PumpChart();
4646

4747
/**
4848
* Constructor for Pump.
@@ -439,7 +439,7 @@ public double getSpeed() {
439439
*
440440
* @return a {@link neqsim.process.equipment.pump.PumpChart} object
441441
*/
442-
public PumpChart getPumpChart() {
442+
public PumpChartInterface getPumpChart() {
443443
return pumpChart;
444444
}
445445

@@ -449,4 +449,21 @@ public String toJson() {
449449
return new GsonBuilder().serializeSpecialFloatingPointValues().create()
450450
.toJson(new PumpResponse(this));
451451
}
452+
453+
/**
454+
* {@inheritDoc}
455+
*
456+
* <p>
457+
* Set CompressorChartType
458+
* </p>
459+
*/
460+
public void setPumpChartType(String type) {
461+
if (type.equals("simple") || type.equals("fan law")) {
462+
pumpChart = new PumpChart();
463+
} else if (type.equals("interpolate and extrapolate")) {
464+
pumpChart = new PumpChartAlternativeMapLookupExtrapolate();
465+
} else {
466+
pumpChart = new PumpChart();
467+
}
468+
}
452469
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package neqsim.process.equipment.pump;
2+
3+
import org.apache.logging.log4j.LogManager;
4+
import org.apache.logging.log4j.Logger;
5+
import neqsim.process.equipment.compressor.CompressorChartAlternativeMapLookupExtrapolate;
6+
7+
/**
8+
* <p>
9+
* CompressorChartAlternativeMapLookupExtrapolate class.
10+
* </p>
11+
*
12+
* @author ASMF
13+
*/
14+
public class PumpChartAlternativeMapLookupExtrapolate
15+
extends CompressorChartAlternativeMapLookupExtrapolate implements PumpChartInterface {
16+
/** Serialization version UID. */
17+
private static final long serialVersionUID = 1000;
18+
/** Logger object for class. */
19+
static Logger logger = LogManager.getLogger(PumpChartAlternativeMapLookupExtrapolate.class);
20+
boolean usePumpChart = false;
21+
22+
@Override
23+
public double getHead(double flow, double speed) {
24+
// Implement the method logic here
25+
return getPolytropicHead(flow, speed);
26+
}
27+
28+
@Override
29+
public boolean isUsePumpChart() {
30+
// Implement the method logic here
31+
return usePumpChart;
32+
}
33+
34+
@Override
35+
public double getEfficiency(double flow, double speed) {
36+
// Implement the method logic here
37+
return getPolytropicEfficiency(flow, speed);
38+
}
39+
40+
@Override
41+
public void setUsePumpChart(boolean usePumpChart) {
42+
this.usePumpChart = usePumpChart;
43+
}
44+
}

src/main/java/neqsim/process/equipment/pump/PumpInterface.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,13 @@ public interface PumpInterface extends ProcessEquipmentInterface, TwoPortInterfa
2929
* @return a double
3030
*/
3131
public double getPower();
32+
33+
/**
34+
* <p>
35+
* setPumpChartType.
36+
* </p>
37+
*
38+
* @param type a {@link java.lang.String} object
39+
*/
40+
public void setPumpChartType(String type);
3241
}

src/main/java/neqsim/process/equipment/separator/TwoPhaseSeparator.java

Lines changed: 3 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,6 @@ public class TwoPhaseSeparator extends Separator {
1818
/** Serialization version UID. */
1919
private static final long serialVersionUID = 1000;
2020

21-
SystemInterface thermoSystem;
22-
23-
SystemInterface gasSystem;
24-
SystemInterface waterSystem;
25-
SystemInterface liquidSystem;
26-
SystemInterface thermoSystemCloned;
27-
28-
StreamInterface inletStream;
29-
StreamInterface gasOutStream;
30-
StreamInterface liquidOutStream;
31-
3221
/**
3322
* Constructor for TwoPhaseSeparator.
3423
*
@@ -43,68 +32,12 @@ public TwoPhaseSeparator(String name) {
4332
* Constructor for TwoPhaseSeparator.
4433
* </p>
4534
*
46-
* @param name a {@link java.lang.String} object
47-
* @param inletStream a {@link neqsim.process.equipment.stream.StreamInterface} object
35+
* @param name a {@link java.lang.String} object
36+
* @param inletStream a {@link neqsim.process.equipment.stream.StreamInterface}
37+
* object
4838
*/
4939
public TwoPhaseSeparator(String name, StreamInterface inletStream) {
5040
super(name, inletStream);
5141
}
5242

53-
/** {@inheritDoc} */
54-
@Override
55-
public void setInletStream(StreamInterface inletStream) {
56-
this.inletStream = inletStream;
57-
58-
thermoSystem = inletStream.getThermoSystem().clone();
59-
gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[0]);
60-
gasOutStream = new Stream("gasOutStream", gasSystem);
61-
62-
thermoSystem = inletStream.getThermoSystem().clone();
63-
liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]);
64-
liquidOutStream = new Stream("liquidOutStream", liquidSystem);
65-
}
66-
67-
/** {@inheritDoc} */
68-
@Override
69-
public StreamInterface getLiquidOutStream() {
70-
return liquidOutStream;
71-
}
72-
73-
/** {@inheritDoc} */
74-
@Override
75-
public StreamInterface getGasOutStream() {
76-
return gasOutStream;
77-
}
78-
79-
/** {@inheritDoc} */
80-
@Override
81-
public StreamInterface getGas() {
82-
return getGasOutStream();
83-
}
84-
85-
/** {@inheritDoc} */
86-
@Override
87-
public StreamInterface getLiquid() {
88-
return getLiquidOutStream();
89-
}
90-
91-
/** {@inheritDoc} */
92-
@Override
93-
public void run(UUID id) {
94-
thermoSystem = inletStream.getThermoSystem().clone();
95-
gasSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[0]);
96-
gasSystem.setNumberOfPhases(1);
97-
gasOutStream.setThermoSystem(gasSystem);
98-
99-
thermoSystem = inletStream.getThermoSystem().clone();
100-
liquidSystem = thermoSystem.phaseToSystem(thermoSystem.getPhases()[1]);
101-
liquidSystem.setNumberOfPhases(1);
102-
liquidOutStream.setThermoSystem(liquidSystem);
103-
setCalculationIdentifier(id);
104-
}
105-
106-
/** {@inheritDoc} */
107-
@Override
108-
@ExcludeFromJacocoGeneratedReport
109-
public void displayResult() {}
11043
}

0 commit comments

Comments
 (0)