Skip to content

Commit 92a7b58

Browse files
authored
added option to add energy stream (#1202)
1 parent bc77211 commit 92a7b58

File tree

4 files changed

+82
-6
lines changed

4 files changed

+82
-6
lines changed

src/main/java/neqsim/process/equipment/compressor/Compressor.java

+4
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ public void run(UUID id) {
296296
return;
297297
}
298298

299+
if (isSetEnergyStream()) {
300+
setPower(energyStream.getDuty());
301+
}
302+
299303
ThermodynamicOperations thermoOps = new ThermodynamicOperations(getThermoSystem());
300304
thermoOps = new ThermodynamicOperations(getThermoSystem());
301305
getThermoSystem().init(3);

src/main/java/neqsim/process/equipment/expander/Expander.java

+11-6
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ public Expander(String name) {
3131
* </p>
3232
*
3333
* @param name a {@link java.lang.String} object
34-
* @param inletStream a {@link neqsim.process.equipment.stream.StreamInterface}
35-
* object
34+
* @param inletStream a {@link neqsim.process.equipment.stream.StreamInterface} object
3635
*/
3736
public Expander(String name, StreamInterface inletStream) {
3837
super(name, inletStream);
@@ -51,18 +50,21 @@ public void run(UUID id) {
5150
// double densInn = getThermoSystem().getDensity();
5251
double entropy = getThermoSystem().getEntropy();
5352
inletEnthalpy = hinn;
54-
53+
double hout = hinn;
5554
if (usePolytropicCalc) {
5655
int numbersteps = 40;
5756
double dp = (pressure - getThermoSystem().getPressure()) / (1.0 * numbersteps);
57+
5858
for (int i = 0; i < numbersteps; i++) {
5959
entropy = getThermoSystem().getEntropy();
60-
hinn = getThermoSystem().getEnthalpy();
60+
double hinn_loc = getThermoSystem().getEnthalpy();
6161
getThermoSystem().setPressure(getThermoSystem().getPressure() + dp);
6262
thermoOps.PSflash(entropy);
63-
double hout = hinn + (getThermoSystem().getEnthalpy() - hinn) * polytropicEfficiency;
63+
hout = hinn_loc + (getThermoSystem().getEnthalpy() - hinn_loc) * polytropicEfficiency;
6464
thermoOps.PHflash(hout, 0);
6565
}
66+
67+
dH = hout - hinn;
6668
/*
6769
* HYSYS method double oldPolyt = 10.5; int iter = 0; do {
6870
*
@@ -87,12 +89,15 @@ public void run(UUID id) {
8789
if (!powerSet) {
8890
dH = (getThermoSystem().getEnthalpy() - hinn) * isentropicEfficiency;
8991
}
90-
double hout = hinn + dH;
92+
hout = hinn + dH;
9193
isentropicEfficiency = dH / (getThermoSystem().getEnthalpy() - hinn);
9294
// System.out.println("isentropicEfficiency.. " + isentropicEfficiency);
9395
dH = hout - hinn;
9496
thermoOps.PHflash(hout, 0);
9597
}
98+
if (isSetEnergyStream()) {
99+
energyStream.setDuty(-dH);
100+
}
96101
// thermoSystem.display();
97102
outStream.setThermoSystem(getThermoSystem());
98103
setCalculationIdentifier(id);

src/main/java/neqsim/process/equipment/stream/EnergyStream.java

+15
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,16 @@
1515
public class EnergyStream implements java.io.Serializable, Cloneable {
1616
private static final long serialVersionUID = 1000;
1717
static Logger logger = LogManager.getLogger(EnergyStream.class);
18+
private String name = "";
1819

1920
private double duty = 0.0;
2021

22+
public EnergyStream() {}
23+
24+
public EnergyStream(String name) {
25+
this.name = name;
26+
}
27+
2128
/** {@inheritDoc} */
2229
@Override
2330
public EnergyStream clone() {
@@ -73,4 +80,12 @@ public boolean equals(Object obj) {
7380
EnergyStream other = (EnergyStream) obj;
7481
return Double.doubleToLongBits(duty) == Double.doubleToLongBits(other.duty);
7582
}
83+
84+
public String getName() {
85+
return name;
86+
}
87+
88+
public void setName(String name) {
89+
this.name = name;
90+
}
7691
}

src/test/java/neqsim/process/equipment/compressor/CompressorTest.java

+52
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import org.junit.jupiter.api.Assertions;
1313
import org.junit.jupiter.api.BeforeEach;
1414
import org.junit.jupiter.api.Test;
15+
import neqsim.process.equipment.expander.Expander;
16+
import neqsim.process.equipment.stream.EnergyStream;
1517
import neqsim.process.equipment.stream.Stream;
1618
import neqsim.process.processmodel.ProcessSystem;
1719
import neqsim.thermo.system.SystemSrkEos;
@@ -292,4 +294,54 @@ public void testPowerEffSpec() {
292294
assertEquals(139.7216108, compressor1.getOutletStream().getTemperature("C"), 0.01);
293295
// compressor1.getOutletStream().getFluid().prettyPrint();
294296
}
297+
298+
299+
/**
300+
* <p>
301+
* test run with energy stream input.
302+
* </p>
303+
*/
304+
@Test
305+
public void testRunWithEnergyStreamInput() {
306+
SystemSrkEos testSystem = new SystemSrkEos(315.0, 10.0);
307+
testSystem.addComponent("nitrogen", 2.0);
308+
testSystem.addComponent("methane", 50.0);
309+
testSystem.setMixingRule(2);
310+
311+
Stream inletStream = new Stream("feed stream", testSystem);
312+
inletStream.setPressure(100, "bara");
313+
inletStream.setTemperature(30, "C");
314+
inletStream.setFlowRate(1, "MSm3/day");
315+
inletStream.run();
316+
317+
EnergyStream estream1 = new EnergyStream("e_stream");
318+
319+
Expander expander1 = new Expander("expander 1", inletStream);
320+
expander1.setPolytropicEfficiency(0.8);
321+
expander1.setUsePolytropicCalc(true);
322+
// expander1.setIsentropicEfficiency(1.0);
323+
expander1.setOutletPressure(55.0, "bara");
324+
expander1.setEnergyStream(estream1);
325+
expander1.run();
326+
327+
assertEquals(481376.2230301, estream1.getDuty(), 0.01);
328+
329+
compressor1 = new Compressor("compressor 1", expander1.getOutletStream());
330+
compressor1.setUsePolytropicCalc(true);
331+
compressor1.setPolytropicEfficiency(0.8);
332+
// compressor1.setIsentropicEfficiency(1.0);
333+
compressor1.setEnergyStream(estream1);
334+
compressor1.setCalcPressureOut(true);
335+
compressor1.run();
336+
337+
assertEquals(481376.2230301, compressor1.getPower(), 0.01);
338+
339+
processOps = new ProcessSystem();
340+
processOps.add(inletStream);
341+
processOps.add(expander1);
342+
processOps.add(compressor1);
343+
processOps.run();
344+
345+
assertEquals(81.61462472, compressor1.getOutletPressure(), 0.01);
346+
}
295347
}

0 commit comments

Comments
 (0)