Skip to content

Commit

Permalink
fix mixer minimum pressure
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol committed Jan 5, 2025
1 parent 3ece80c commit 2300cc1
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/main/java/neqsim/process/equipment/mixer/Mixer.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class Mixer extends ProcessEquipmentBaseClass implements MixerInterface {
protected StreamInterface mixedStream;
private boolean isSetOutTemperature = false;
private double outTemperature = Double.NaN;
double lowestPressure = Double.NEGATIVE_INFINITY;

/**
* <p>
Expand Down Expand Up @@ -106,13 +107,17 @@ public StreamInterface getStream(int i) {
public void mixStream() {
int index = 0;
String compName = new String();
double lowestPressure = mixedStream.getThermoSystem().getPhase(0).getPressure();
lowestPressure = mixedStream.getThermoSystem().getPhase(0).getPressure();
boolean hasAddedNewComponent = false;
for (int k = 1; k < streams.size(); k++) {
if (streams.get(k).getThermoSystem().getPhase(0).getPressure() < lowestPressure) {
lowestPressure = streams.get(k).getThermoSystem().getPhase(0).getPressure();
mixedStream.getThermoSystem().getPhase(0).setPressure(lowestPressure);
}
}
for (int k = 0; k < streams.size(); k++) {
// streams.get(k).getThermoSystem().getPhase(0).setPressure(lowestPressure);
}
for (int k = 1; k < streams.size(); k++) {
for (int i = 0; i < streams.get(k).getThermoSystem().getPhase(0)
.getNumberOfComponents(); i++) {
boolean gotComponent = false;
Expand Down Expand Up @@ -212,7 +217,7 @@ public void run(UUID id) {
mixedStream.getThermoSystem().init(0);

mixStream();

mixedStream.setPressure(lowestPressure);
enthalpy = calcMixStreamEnthalpy();
// System.out.println("temp guess " + guessTemperature());
if (isSetOutTemperature) {
Expand Down Expand Up @@ -244,13 +249,11 @@ public void run(UUID id) {
mixedStream.getThermoSystem().init(2);
}


// System.out.println("enthalpy: " +
// mixedStream.getThermoSystem().getEnthalpy())
// System.out.println("enthalpy: " + en
// System.out.println("temperature: " +


// System.out.println("beta " + mixedStream.getThermoSystem(
// outStream.setThermoSystem(mixedStream.getThermoSystem());
setCalculationIdentifier(id);
Expand Down
27 changes: 27 additions & 0 deletions src/test/java/neqsim/process/equipment/mixer/MixerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import neqsim.process.equipment.stream.Stream;
import neqsim.process.equipment.stream.StreamInterface;
import neqsim.process.processmodel.ProcessSystem;
import neqsim.thermo.system.SystemSrkEos;

Expand Down Expand Up @@ -81,4 +82,30 @@ void testNeedRecalculation() {
processOps.run();
assertFalse(gasStream.needRecalculation());
}

/**
* Test method for {@link neqsim.process.equipment.mixer.Mixer#run()}.
*/
@Test
void testRunDifferentPressures() {
StreamInterface gasStream2 = (StreamInterface) gasStream.clone();
StreamInterface waterStream2 = (StreamInterface) waterStream.clone();

gasStream2.setPressure(10.0, "bara");
waterStream2.setPressure(30.0, "bara");

gasStream2.run();
waterStream2.run();

double totalEnthalpy =
gasStream2.getFluid().getEnthalpy("J") + waterStream2.getFluid().getEnthalpy("J");

Mixer testMixer = new Mixer("test mixer");
testMixer.addStream(waterStream2);
testMixer.addStream(gasStream2);
testMixer.run();

assertEquals(totalEnthalpy, testMixer.getOutletStream().getFluid().getEnthalpy("J"), 1e-1);
assertEquals(10.0, testMixer.getOutletStream().getPressure("bara"), 1e-1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public void testProcess2() {
dewPointControlCooler2.setOutTemperature(-15.0, "C");
dewPointControlCooler2.setOutPressure(59.5, "bara");
dewPointControlCooler2.run();
Assertions.assertEquals(0.967383748675644,
Assertions.assertEquals(0.96737504327,
dewPointControlCooler2.getOutStream().getFluid().getBeta(), 1e-6);
Separator dewPointScrubber2 = new neqsim.process.equipment.separator.Separator(
"dew point scrubber 2", dewPointControlCooler2.getOutStream());
Expand Down

0 comments on commit 2300cc1

Please sign in to comment.