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

update separator #1174

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions src/main/java/neqsim/process/equipment/separator/Separator.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@ public SystemInterface getThermoSystem() {
return thermoSystem;
}

/** {@inheritDoc} */
@Override
public boolean needRecalculation() {
if (!inletStreamMixer.needRecalculation()) {
isSolved = true;
return false;
} else {
isSolved = false;
return true;
}
}

/** {@inheritDoc} */
@Override
public void run(UUID id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public ThreePhaseSeparator(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 ThreePhaseSeparator(String name, StreamInterface inletStream) {
super(name, inletStream);
Expand Down Expand Up @@ -135,6 +134,18 @@ public StreamInterface getOilOutStream() {
return liquidOutStream;
}

/** {@inheritDoc} */
@Override
public boolean needRecalculation() {
if (!inletStreamMixer.needRecalculation()) {
isSolved = true;
return false;
} else {
isSolved = false;
return true;
}
}

/** {@inheritDoc} */
@Override
public void run(UUID id) {
Expand Down
26 changes: 23 additions & 3 deletions src/main/java/neqsim/process/equipment/splitter/Splitter.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package neqsim.process.equipment.splitter;

import java.util.Arrays;
import java.util.UUID;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -33,6 +34,8 @@ public class Splitter extends ProcessEquipmentBaseClass implements SplitterInter
double[] splitFactor = new double[1];
double[] flowRates;
String flowUnit = "mole/sec";
protected double[] oldSplitFactor = null;
protected double[] oldFlowRates = null;

/**
* Constructor for Splitter.
Expand Down Expand Up @@ -60,8 +63,7 @@ public Splitter(String name, StreamInterface inStream) {
* </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
* @param i a int
*/
public Splitter(String name, StreamInterface inletStream, int i) {
Expand Down Expand Up @@ -178,6 +180,19 @@ public StreamInterface getSplitStream(int i) {
return splitStream[i];
}

/** {@inheritDoc} */
@Override
public boolean needRecalculation() {
if (!inletStream.needRecalculation() && Arrays.equals(splitFactor, oldSplitFactor)
&& Arrays.equals(oldFlowRates, flowRates)) {
isSolved = true;
return false;
} else {
isSolved = false;
return true;
}
}

/** {@inheritDoc} */
@Override
public void run(UUID id) {
Expand Down Expand Up @@ -215,7 +230,12 @@ public void run(UUID id) {
new ThermodynamicOperations(splitStream[i].getThermoSystem());
thermoOps.TPflash();
}

if (splitFactor != null) {
oldSplitFactor = Arrays.copyOf(splitFactor, splitFactor.length);
}
if (flowRates != null) {
oldFlowRates = Arrays.copyOf(flowRates, flowRates.length);
}
setCalculationIdentifier(id);
}

Expand Down
6 changes: 5 additions & 1 deletion src/main/java/neqsim/process/equipment/stream/Stream.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package neqsim.process.equipment.stream;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.UUID;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -46,6 +47,7 @@ public class Stream extends ProcessEquipmentBaseClass implements StreamInterface
protected double lastTemperature = 0.0;
protected double lastPressure = 0.0;
protected double lastFlowRate = 0.0;
protected double[] lastComposition = null;

/**
* Constructor for Stream.
Expand Down Expand Up @@ -317,7 +319,8 @@ public boolean needRecalculation() {
}
if (getFluid().getTemperature() == lastTemperature && getFluid().getPressure() == lastPressure
&& Math.abs(getFluid().getFlowRate("kg/hr") - lastFlowRate)
/ getFluid().getFlowRate("kg/hr") < 1e-6) {
/ getFluid().getFlowRate("kg/hr") < 1e-6
&& Arrays.equals(getFluid().getMolarComposition(), lastComposition)) {
isSolved = true;
return false;
} else {
Expand Down Expand Up @@ -398,6 +401,7 @@ && getSpecification().equals("TP")) {
thermoSystem.initProperties();

lastFlowRate = thermoSystem.getFlowRate("kg/hr");
lastComposition = thermoSystem.getMolarComposition();
lastTemperature = thermoSystem.getTemperature();
lastPressure = thermoSystem.getPressure();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,10 @@ public void testProcess() {

operations.run();

assertEquals(2042.17826, recycleScrubberStream.getFlowRate("kg/hr"), 0.1);
assertEquals(2038.8824, recycleScrubberStream.getFlowRate("kg/hr"), 0.1);

neqsim.process.equipment.compressor.CompressorChartGenerator compchartgenerator =
new neqsim.process.equipment.compressor.CompressorChartGenerator(
seccondStageCompressor);
new neqsim.process.equipment.compressor.CompressorChartGenerator(seccondStageCompressor);
compchartgenerator.generateCompressorChart("mid range");

seccondStageCompressor.setCompressorChart(compchartgenerator.generateCompressorChart("normal"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public void runProcessTEG() throws InterruptedException {

assertEquals(-19.1886678,
p.getMeasurementDevice("water dew point analyser3").getMeasuredValue("C"), 1e-1);
assertEquals(203.024331,
assertEquals(213.041186,
((Reboiler) ((DistillationColumn) p.getUnit("TEG regeneration column")).getReboiler())
.getDuty() / 1e3,
1e-2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import neqsim.process.equipment.valve.ThrottlingValve;
import neqsim.process.measurementdevice.HydrateEquilibriumTemperatureAnalyser;
import neqsim.process.measurementdevice.WaterDewPointAnalyser;
import neqsim.process.processmodel.ProcessSystem;

/**
* Class for testing ProcessSystem class.
Expand Down Expand Up @@ -581,7 +580,7 @@ public void runTEGProcessTest2() {
* coolerhOTteg3.getOutletStream().getFlowRate("kg/hr")); System.out.println("leantoresirc " +
* leanTEGtoabs.getFlowRate("kg/hr"));
*/
assertEquals(1.5322819175995646E-5, dehydratedGas.getFluid().getComponent("water").getx(),
assertEquals(1.743804E-5, dehydratedGas.getFluid().getComponent("water").getx(),
1e-6);
}

Expand Down
Loading