Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added possiblity to partly saturate #516

Merged
merged 1 commit into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class StreamSaturatorUtil extends TwoPortEquipment {

SystemInterface thermoSystem;
private boolean multiPhase = true;
private double approachToSaturation = 1.0;

/**
* <p>
Expand Down Expand Up @@ -71,10 +72,22 @@ public void run(UUID id) {
}
ThermodynamicOperations thermoOps = new ThermodynamicOperations(thermoSystem);
thermoOps.saturateWithWater();

if(thermoSystem.getPhase(0).hasComponent("water") && approachToSaturation<1.0){
try{
thermoSystem.addComponent("water", -thermoSystem.getComponent("water").getNumberOfmoles()*(1.0-approachToSaturation));
thermoOps.TPflash();
}
catch(Exception e){
e.printStackTrace();
}
}

thermoSystem.init(3);
if (changeBack) {
thermoSystem.setMultiPhaseCheck(false);
}

outStream.setThermoSystem(thermoSystem);
setCalculationIdentifier(id);
}
Expand All @@ -100,4 +113,9 @@ public boolean isMultiPhase() {
public void setMultiPhase(boolean multiPhase) {
this.multiPhase = multiPhase;
}


public void setApprachToSaturation(double approachToSaturation){
this.approachToSaturation = approachToSaturation;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package neqsim.processSimulation.processEquipment.util;

import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import neqsim.processSimulation.processEquipment.stream.Stream;
import neqsim.processSimulation.processSystem.ProcessSystem;
import neqsim.thermo.system.SystemSrkEos;

public class StreamSaturatorUtilTest {
static neqsim.thermo.system.SystemInterface testSystem = null;
double pressure_inlet = 85.0;
double temperature_inlet = 35.0;
double gasFlowRate = 5.0;
ProcessSystem processOps = null;


@Test
void testRun() {
testSystem = new SystemSrkEos(298.0, 10.0);
testSystem.addComponent("methane", 100.0);
testSystem.addComponent("water", 1.0);

Stream inletStream = new Stream("inletStream", testSystem);
inletStream.setName("inlet stream");
inletStream.setPressure(pressure_inlet, "bara");
inletStream.setTemperature(temperature_inlet, "C");
inletStream.setFlowRate(gasFlowRate, "MSm3/day");
StreamSaturatorUtil streamSaturator = new StreamSaturatorUtil("saturator", inletStream);

processOps = new ProcessSystem();
processOps.add(inletStream);
processOps.add(streamSaturator);
processOps.run();

assertEquals(0.0012319218375683974, streamSaturator.getOutletStream().getFluid().getPhase(0).getComponent("water").getx());

}

@Test
void testSetApprachToSaturation() {
testSystem = new SystemSrkEos(298.0, 10.0);
testSystem.addComponent("methane", 100.0);
testSystem.addComponent("water", 1.0);

Stream inletStream = new Stream("inletStream", testSystem);
inletStream.setName("inlet stream");
inletStream.setPressure(pressure_inlet, "bara");
inletStream.setTemperature(temperature_inlet, "C");
inletStream.setFlowRate(gasFlowRate, "MSm3/day");
StreamSaturatorUtil streamSaturator = new StreamSaturatorUtil("saturator", inletStream);
streamSaturator.setApprachToSaturation(0.93);

processOps = new ProcessSystem();
processOps.add(inletStream);
processOps.add(streamSaturator);
processOps.run();

assertEquals(0.0012319218375683974*0.93, streamSaturator.getOutletStream().getFluid().getPhase(0).getComponent("water").getx(), 1e-3);

}
}