Skip to content

Commit 9042a78

Browse files
committed
refact: reuse twoport methods
1 parent 0ca1dc7 commit 9042a78

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed

src/main/java/neqsim/process/equipment/diffpressure/Orifice.java

+6-16
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
public class Orifice extends TwoPortEquipment {
99
private static final long serialVersionUID = 1L;
10-
private String name;
1110
private StreamInterface inputstream;
1211
private StreamInterface outputstream;
1312
private Double dp;
@@ -33,15 +32,6 @@ public Orifice(String name, double diameter, double orificeDiameter, double pres
3332
this.dischargeCoefficient = dischargeCoefficient;
3433
}
3534

36-
public void setInputStream(StreamInterface stream) {
37-
this.inputstream = stream;
38-
this.outputstream = (StreamInterface) stream.clone();
39-
}
40-
41-
public StreamInterface getOutputStream() {
42-
return outputstream;
43-
}
44-
4535
public void setOrificeParameters(Double diameter, Double diameter_outer, Double C) {
4636
this.diameter = diameter;
4737
this.diameter_outer = diameter_outer;
@@ -65,7 +55,7 @@ public Double calc_dp() {
6555

6656
/**
6757
* Calculates the orifice discharge coefficient using the Reader-Harris Gallagher method.
68-
*
58+
*
6959
* @param D Upstream internal pipe diameter, in meters.
7060
* @param Do Diameter of orifice at flow conditions, in meters.
7161
* @param rho Density of fluid at P1, in kg/m^3.
@@ -84,7 +74,8 @@ public static double calculateDischargeCoefficient(double D, double Do, double r
8474
double beta4 = beta2 * beta2;
8575
double beta8 = beta4 * beta4;
8676

87-
double L1, L2_prime;
77+
double L1;
78+
double L2_prime;
8879
if ("corner".equalsIgnoreCase(taps)) {
8980
L1 = 0.0;
9081
L2_prime = 0.0;
@@ -114,7 +105,7 @@ public static double calculateDischargeCoefficient(double D, double Do, double r
114105

115106
/**
116107
* Calculates the expansibility factor for orifice plate calculations.
117-
*
108+
*
118109
* @param D Upstream internal pipe diameter, in meters.
119110
* @param Do Diameter of orifice at flow conditions, in meters.
120111
* @param P1 Static pressure of fluid upstream, in Pa.
@@ -130,7 +121,7 @@ public static double calculateExpansibility(double D, double Do, double P1, doub
130121

131122
/**
132123
* Calculates the non-recoverable pressure drop across the orifice plate.
133-
*
124+
*
134125
* @param D Upstream internal pipe diameter, in meters.
135126
* @param Do Diameter of orifice at flow conditions, in meters.
136127
* @param P1 Static pressure of fluid upstream, in Pa.
@@ -150,7 +141,7 @@ public static double calculatePressureDrop(double D, double Do, double P1, doubl
150141

151142
/**
152143
* Calculates the diameter ratio (beta) of the orifice plate.
153-
*
144+
*
154145
* @param D Upstream internal pipe diameter, in meters.
155146
* @param Do Diameter of orifice at flow conditions, in meters.
156147
* @return Diameter ratio (beta).
@@ -169,5 +160,4 @@ public void run(UUID uuid) {
169160
outStream.run();
170161
}
171162
}
172-
173163
}

src/test/java/neqsim/process/equipment/diffpressure/OrificeTest.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ void testCalc_dp() {
2020

2121
// Step 3: Define and set up the orifice unit operation
2222
Orifice orif1 = new Orifice("orifice 1");
23-
orif1.setInputStream(stream1);
23+
orif1.setInletStream(stream1);
2424
orif1.setOrificeParameters(0.07366, 0.05, 0.61); // Diameter, outer diameter, and discharge
2525
// coefficient
2626

2727
// Step 4: Define the output stream after the orifice
28-
Stream stream2 = new Stream("stream 2", orif1.getOutputStream());
28+
Stream stream2 = new Stream("stream 2", orif1.getOutletStream());
2929

3030
// Step 5: Set up and run the process system
3131
ProcessSystem oilProcess = new ProcessSystem();
@@ -37,6 +37,5 @@ void testCalc_dp() {
3737

3838
// Output the pressure after the orifice
3939
System.out.println("Pressure out of orifice: " + stream2.getPressure("bara") + " bara");
40-
4140
}
4241
}

0 commit comments

Comments
 (0)