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

first version of component splitter #403

Merged
merged 3 commits into from
May 4, 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 @@ -198,8 +198,12 @@ public void run() {
} else {
liquidOutStream.setThermoSystem(thermoSystem2.getEmptySystemClone());
}
gasOutStream.run();
liquidOutStream.run();
if (thermoSystem2.hasPhaseType("gas")) {
gasOutStream.run();
}
if (thermoSystem2.hasPhaseType("aqueous") || thermoSystem2.hasPhaseType("oil")) {
liquidOutStream.run();
}
// liquidOutStream.setThermoSystemFromPhase(thermoSystem2, "aqueous");
try {
thermoSystem = thermoSystem2.clone();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package neqsim.processSimulation.processEquipment.splitter;

import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass;
import neqsim.processSimulation.processEquipment.stream.Stream;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicOperations.ThermodynamicOperations;

/**
* <p>
* Splitter class.
* </p>
*
* @author Even Solbraa
* @version $Id: $Id
*/
public class ComponentSplitter extends ProcessEquipmentBaseClass {
private static final long serialVersionUID = 1000;

SystemInterface thermoSystem;
StreamInterface inletStream;
StreamInterface[] splitStream;
protected int splitNumber = 1;
double[] splitFactor = new double[1];

/**
* <p>
* Constructor for Splitter.
* </p>
*/
public ComponentSplitter() {
super("Component Splitter");
}

/**
* Constructor for Splitter.
*
* @param name
*/
public ComponentSplitter(String name) {
super(name);
}

/**
* <p>
* Constructor for Splitter.
* </p>
*
* @param name a {@link java.lang.String} object
* @param inletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface}
* object
* @param i a int
*/
public ComponentSplitter(String name, StreamInterface inletStream) {
this(name);
this.setInletStream(inletStream);
}

public void setSplitFactors(double[] factors) {
splitFactor = factors;
}

public void setInletStream(StreamInterface inletStream) {
this.inletStream = inletStream;
splitStream = new Stream[2];
try {
for (int i = 0; i < splitStream.length; i++) {
splitStream[i] = new Stream("Split Stream", inletStream.getThermoSystem().clone());
}
} catch (Exception e) {
e.printStackTrace();
}
}

public StreamInterface getSplitStream(int i) {
return splitStream[i];
}

/** {@inheritDoc} */
@Override
public void run() {
for (int i = 0; i < 2; i++) {
thermoSystem = inletStream.getThermoSystem().clone();
thermoSystem.removeMoles();
if (i == 0) {
for (int k = 0; k < thermoSystem.getNumberOfComponents(); k++) {
thermoSystem.addComponent(k,
inletStream.getThermoSystem().getComponent(k).getNumberOfmoles() * splitFactor[k]);
}
} else {
for (int k = 0; k < thermoSystem.getNumberOfComponents(); k++) {
thermoSystem.addComponent(k,
inletStream.getThermoSystem().getComponent(k).getNumberOfmoles()
* (1.0 - splitFactor[k]));
}
}

thermoSystem.init(0);
splitStream[i].setThermoSystem(thermoSystem);
ThermodynamicOperations thermoOps =
new ThermodynamicOperations(splitStream[i].getThermoSystem());
thermoOps.TPflash();
}
}

/** {@inheritDoc} */
@Override
public void displayResult() {}

/** {@inheritDoc} */
@Override
public void runTransient(double dt) {
run();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,21 @@ public void setTemperature(double temperature, String unitT) {
public void run() {
SystemInterface tempFluid = inletStream.getThermoSystem().clone();
double flow = tempFluid.getFlowRate("kg/sec");
if(flow<1e-6) {
outletStream.setThermoSystem(tempFluid);
return;
}
if(GOR==0 && tempFluid.hasPhaseType("gas")) {
tempFluid.removePhase(0);
ThermodynamicOperations thermoOps = new ThermodynamicOperations(tempFluid);
try {
thermoOps.TPflash();
} catch (Exception e) {
e.printStackTrace();
}
outletStream.setThermoSystem(tempFluid);
return;
}
if (!getReferenceConditions().equals("actual")) {
tempFluid.setTemperature(15.0, "C");
tempFluid.setPressure(1.01325, "bara");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public Standard_ISO6976(String name, String description, SystemInterface thermoS
try {
String compName = "inert";
String compType = this.thermoSystem.getPhase(0).getComponent(i).getComponentType();
if (compType.equals("HC") || compType.equals("TPB") || compType.equals("plus")) {
if (compType.equals("HC") || compType.equals("TBP") || compType.equals("plus")) {
compName = "n-heptane";
} else if (compType.equals("alcohol") || compType.equals("glycol")) {
compName = "methanol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public Standard_ISO6976_2016(SystemInterface thermoSystem) {
String compType =
this.thermoSystem.getPhase(0).getComponent(i).getComponentType();

if (compType.equals("HC") || compType.equals("TPB")
if (compType.equals("HC") || compType.equals("TBP")
|| compType.equals("plus")) {
compName = "n-heptane";
} else if (compType.equals("alcohol") || compType.equals("glycol")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package neqsim.processSimulation.processEquipment.splitter;

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

class ComponentSplitterTest {

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

@BeforeEach
public void setUpBeforeClass() throws Exception {
testSystem = new SystemSrkEos(298.0, 10.0);
testSystem.addComponent("methane", 100.0);
testSystem.addComponent("ethane", 10.0);
testSystem.addComponent("propane", 10.0);
processOps = new ProcessSystem();
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");

ComponentSplitter splitter = new ComponentSplitter("splitter", inletStream);
splitter.setSplitFactors(new double[] {1.00, 0.0, 0.0});

StreamInterface stream1 = new Stream("stream 1", splitter.getSplitStream(0));
StreamInterface stream2 = new Stream("stream 2",splitter.getSplitStream(1));

processOps.add(inletStream);
processOps.add(splitter);
processOps.add(stream1);
processOps.add(stream2);
}

@Test
public void testRun() {
processOps.run();
//((StreamInterface)processOps.getUnit("stream 1")).displayResult();
//((StreamInterface)processOps.getUnit("stream 2")).displayResult();
assertEquals(((StreamInterface)processOps.getUnit("stream 1")).getFluid().getComponent("methane").getx(), 1.0, 1e-6);
assertEquals(((StreamInterface)processOps.getUnit("stream 2")).getFluid().getComponent("methane").getx(), 0.0, 1e-6);
}

}
Loading