Skip to content

Commit

Permalink
added option to add energy stream (#1202)
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol authored Dec 8, 2024
1 parent bc77211 commit 92a7b58
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ public void run(UUID id) {
return;
}

if (isSetEnergyStream()) {
setPower(energyStream.getDuty());
}

ThermodynamicOperations thermoOps = new ThermodynamicOperations(getThermoSystem());
thermoOps = new ThermodynamicOperations(getThermoSystem());
getThermoSystem().init(3);
Expand Down
17 changes: 11 additions & 6 deletions src/main/java/neqsim/process/equipment/expander/Expander.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public Expander(String name) {
* </p>
*
* @param name a {@link java.lang.String} object
* @param inletStream a {@link neqsim.process.equipment.stream.StreamInterface}
* object
* @param inletStream a {@link neqsim.process.equipment.stream.StreamInterface} object
*/
public Expander(String name, StreamInterface inletStream) {
super(name, inletStream);
Expand All @@ -51,18 +50,21 @@ public void run(UUID id) {
// double densInn = getThermoSystem().getDensity();
double entropy = getThermoSystem().getEntropy();
inletEnthalpy = hinn;

double hout = hinn;
if (usePolytropicCalc) {
int numbersteps = 40;
double dp = (pressure - getThermoSystem().getPressure()) / (1.0 * numbersteps);

for (int i = 0; i < numbersteps; i++) {
entropy = getThermoSystem().getEntropy();
hinn = getThermoSystem().getEnthalpy();
double hinn_loc = getThermoSystem().getEnthalpy();
getThermoSystem().setPressure(getThermoSystem().getPressure() + dp);
thermoOps.PSflash(entropy);
double hout = hinn + (getThermoSystem().getEnthalpy() - hinn) * polytropicEfficiency;
hout = hinn_loc + (getThermoSystem().getEnthalpy() - hinn_loc) * polytropicEfficiency;
thermoOps.PHflash(hout, 0);
}

dH = hout - hinn;
/*
* HYSYS method double oldPolyt = 10.5; int iter = 0; do {
*
Expand All @@ -87,12 +89,15 @@ public void run(UUID id) {
if (!powerSet) {
dH = (getThermoSystem().getEnthalpy() - hinn) * isentropicEfficiency;
}
double hout = hinn + dH;
hout = hinn + dH;
isentropicEfficiency = dH / (getThermoSystem().getEnthalpy() - hinn);
// System.out.println("isentropicEfficiency.. " + isentropicEfficiency);
dH = hout - hinn;
thermoOps.PHflash(hout, 0);
}
if (isSetEnergyStream()) {
energyStream.setDuty(-dH);
}
// thermoSystem.display();
outStream.setThermoSystem(getThermoSystem());
setCalculationIdentifier(id);
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/neqsim/process/equipment/stream/EnergyStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@
public class EnergyStream implements java.io.Serializable, Cloneable {
private static final long serialVersionUID = 1000;
static Logger logger = LogManager.getLogger(EnergyStream.class);
private String name = "";

private double duty = 0.0;

public EnergyStream() {}

public EnergyStream(String name) {
this.name = name;
}

/** {@inheritDoc} */
@Override
public EnergyStream clone() {
Expand Down Expand Up @@ -73,4 +80,12 @@ public boolean equals(Object obj) {
EnergyStream other = (EnergyStream) obj;
return Double.doubleToLongBits(duty) == Double.doubleToLongBits(other.duty);
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import neqsim.process.equipment.expander.Expander;
import neqsim.process.equipment.stream.EnergyStream;
import neqsim.process.equipment.stream.Stream;
import neqsim.process.processmodel.ProcessSystem;
import neqsim.thermo.system.SystemSrkEos;
Expand Down Expand Up @@ -292,4 +294,54 @@ public void testPowerEffSpec() {
assertEquals(139.7216108, compressor1.getOutletStream().getTemperature("C"), 0.01);
// compressor1.getOutletStream().getFluid().prettyPrint();
}


/**
* <p>
* test run with energy stream input.
* </p>
*/
@Test
public void testRunWithEnergyStreamInput() {
SystemSrkEos testSystem = new SystemSrkEos(315.0, 10.0);
testSystem.addComponent("nitrogen", 2.0);
testSystem.addComponent("methane", 50.0);
testSystem.setMixingRule(2);

Stream inletStream = new Stream("feed stream", testSystem);
inletStream.setPressure(100, "bara");
inletStream.setTemperature(30, "C");
inletStream.setFlowRate(1, "MSm3/day");
inletStream.run();

EnergyStream estream1 = new EnergyStream("e_stream");

Expander expander1 = new Expander("expander 1", inletStream);
expander1.setPolytropicEfficiency(0.8);
expander1.setUsePolytropicCalc(true);
// expander1.setIsentropicEfficiency(1.0);
expander1.setOutletPressure(55.0, "bara");
expander1.setEnergyStream(estream1);
expander1.run();

assertEquals(481376.2230301, estream1.getDuty(), 0.01);

compressor1 = new Compressor("compressor 1", expander1.getOutletStream());
compressor1.setUsePolytropicCalc(true);
compressor1.setPolytropicEfficiency(0.8);
// compressor1.setIsentropicEfficiency(1.0);
compressor1.setEnergyStream(estream1);
compressor1.setCalcPressureOut(true);
compressor1.run();

assertEquals(481376.2230301, compressor1.getPower(), 0.01);

processOps = new ProcessSystem();
processOps.add(inletStream);
processOps.add(expander1);
processOps.add(compressor1);
processOps.run();

assertEquals(81.61462472, compressor1.getOutletPressure(), 0.01);
}
}

0 comments on commit 92a7b58

Please sign in to comment.