Skip to content

Commit 2d68c3d

Browse files
authored
add ejector (#1301)
1 parent db49b70 commit 2d68c3d

File tree

2 files changed

+134
-0
lines changed

2 files changed

+134
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
package neqsim.process.equipment.ejector;
2+
3+
import java.util.UUID;
4+
import neqsim.process.equipment.ProcessEquipmentBaseClass;
5+
import neqsim.process.equipment.stream.StreamInterface;
6+
7+
/**
8+
* Ejector class represents an ejector in a process simulation. It mixes a motive stream with a
9+
* suction stream and calculates the resulting mixed stream.
10+
*/
11+
public class Ejector extends ProcessEquipmentBaseClass {
12+
private static final long serialVersionUID = 1L;
13+
14+
private StreamInterface motiveStream;
15+
private StreamInterface suctionStream;
16+
private StreamInterface mixedStream;
17+
18+
private double dischargePressure;
19+
private double efficiencyIsentropic = 0.75; // default nozzle mixing efficiency
20+
private double diffuserEfficiency = 0.8; // diffuser pressure recovery efficiency
21+
private double throatArea = 0.001; // default throat area [m2]
22+
23+
/**
24+
* Constructs an Ejector with the specified name, motive stream, and suction stream.
25+
*
26+
* @param name the name of the ejector
27+
* @param motiveStream the motive stream
28+
* @param suctionStream the suction stream
29+
*/
30+
public Ejector(String name, StreamInterface motiveStream, StreamInterface suctionStream) {
31+
super(name);
32+
this.motiveStream = motiveStream;
33+
this.suctionStream = suctionStream;
34+
this.mixedStream = motiveStream.clone();
35+
}
36+
37+
public void setDischargePressure(double dischargePressure) {
38+
this.dischargePressure = dischargePressure;
39+
}
40+
41+
public void setEfficiencyIsentropic(double efficiencyIsentropic) {
42+
this.efficiencyIsentropic = efficiencyIsentropic;
43+
}
44+
45+
public void setDiffuserEfficiency(double diffuserEfficiency) {
46+
this.diffuserEfficiency = diffuserEfficiency;
47+
}
48+
49+
public void setThroatArea(double throatArea) {
50+
this.throatArea = throatArea;
51+
}
52+
53+
@Override
54+
public void run(UUID id) {
55+
motiveStream.run();
56+
suctionStream.run();
57+
// Mixing streams at constant discharge pressure
58+
motiveStream.setPressure(dischargePressure);
59+
suctionStream.setPressure(dischargePressure);
60+
61+
double hMotive = motiveStream.getFluid().getEnthalpy();
62+
double hSuction = suctionStream.getFluid().getEnthalpy();
63+
64+
double mDotMotive = motiveStream.getFlowRate("kg/s");
65+
double mDotSuction = suctionStream.getFlowRate("kg/s");
66+
67+
double idealMixedEnthalpy =
68+
calculateIdealMixedEnthalpy(hMotive, hSuction, mDotMotive, mDotSuction);
69+
double hMixedActual = calculateActualMixedEnthalpy(hMotive, idealMixedEnthalpy);
70+
71+
mixedStream = motiveStream.clone();
72+
//mixedStream.add(suctionStream);
73+
mixedStream.getFluid().setTotalFlowRate(mDotMotive + mDotSuction, "kg/s");
74+
//mixedStream.getFluid().setEnthalpy(hMixedActual, "J/kg");
75+
mixedStream.setPressure(dischargePressure);
76+
//mixedStream.runPHflash();
77+
78+
checkChokedFlow(mDotMotive, mDotSuction);
79+
80+
double hActualDiffuserOut = calculateDiffuserOutput(hMixedActual);
81+
//mixedStream.getFluid().setEnthalpy(hActualDiffuserOut, "J/kg");
82+
//mixedStream.runPHflash();
83+
84+
// Update final state
85+
mixedStream.setPressure(mixedStream.getFluid().getPressure());
86+
}
87+
88+
private double calculateIdealMixedEnthalpy(double hMotive, double hSuction, double mDotMotive,
89+
double mDotSuction) {
90+
return (hMotive * mDotMotive + hSuction * mDotSuction) / (mDotMotive + mDotSuction);
91+
}
92+
93+
private double calculateActualMixedEnthalpy(double hMotive, double idealMixedEnthalpy) {
94+
return hMotive + (idealMixedEnthalpy - hMotive) / efficiencyIsentropic;
95+
}
96+
97+
private void checkChokedFlow(double mDotMotive, double mDotSuction) {
98+
double density = mixedStream.getFluid().getDensity("kg/m3");
99+
double speedOfSound = mixedStream.getFluid().getSoundSpeed();
100+
double velocity = (mDotMotive + mDotSuction) / (density * throatArea);
101+
double machNumber = velocity / speedOfSound;
102+
103+
if (machNumber >= 1.0) {
104+
System.out.println("Choked flow detected! Mach number: " + machNumber);
105+
} else {
106+
System.out.println("Flow not choked. Mach number: " + machNumber);
107+
}
108+
}
109+
110+
private double calculateDiffuserOutput(double hMixedActual) {
111+
double vInlet = (motiveStream.getFlowRate("kg/s") + suctionStream.getFlowRate("kg/s"))
112+
/ (mixedStream.getFluid().getDensity("kg/m3") * throatArea);
113+
double hIdealDiffuserOut = hMixedActual + 0.5 * vInlet * vInlet;
114+
return hMixedActual + (hIdealDiffuserOut - hMixedActual) / diffuserEfficiency;
115+
}
116+
117+
public StreamInterface getOutStream() {
118+
return mixedStream;
119+
}
120+
121+
public double getEntrainmentRatio() {
122+
return suctionStream.getFlowRate("kg/s") / motiveStream.getFlowRate("kg/s");
123+
}
124+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package neqsim.process.equipment.ejector;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
public class EjectorTest {
6+
@Test
7+
void testRun() {
8+
9+
}
10+
}

0 commit comments

Comments
 (0)