Skip to content

Commit aca9374

Browse files
authored
add separator tests (#1684)
* add separator tests * update
1 parent 74763e1 commit aca9374

File tree

4 files changed

+579
-33
lines changed

4 files changed

+579
-33
lines changed

src/main/java/neqsim/process/equipment/separator/Separator.java

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,15 +1166,17 @@ public double getPressure() {
11661166
public double getEntropyProduction(String unit) {
11671167
double entrop = 0.0;
11681168
for (int i = 0; i < numberOfInputStreams; i++) {
1169-
inletStreamMixer.getStream(i).getFluid().init(3);
1170-
entrop += inletStreamMixer.getStream(i).getFluid().getEntropy(unit);
1169+
if (inletStreamMixer.getStream(i).getFlowRate(unit) > 1e-10) {
1170+
inletStreamMixer.getStream(i).getFluid().init(3);
1171+
entrop += inletStreamMixer.getStream(i).getFluid().getEntropy();
1172+
}
11711173
}
11721174

11731175
double liquidEntropy = 0.0;
11741176
if (thermoSystem.hasPhaseType("aqueous") || thermoSystem.hasPhaseType("oil")) {
11751177
try {
11761178
getLiquidOutStream().getThermoSystem().init(3);
1177-
liquidEntropy = getLiquidOutStream().getThermoSystem().getEntropy(unit);
1179+
liquidEntropy = getLiquidOutStream().getThermoSystem().getEntropy();
11781180
} catch (Exception ex) {
11791181
logger.error(ex.getMessage(), ex);
11801182
}
@@ -1183,7 +1185,7 @@ public double getEntropyProduction(String unit) {
11831185
double gasEntropy = 0.0;
11841186
if (thermoSystem.hasPhaseType("gas")) {
11851187
getGasOutStream().getThermoSystem().init(3);
1186-
gasEntropy = getGasOutStream().getThermoSystem().getEntropy(unit);
1188+
gasEntropy = getGasOutStream().getThermoSystem().getEntropy();
11871189
}
11881190

11891191
return liquidEntropy + gasEntropy - entrop;
@@ -1194,20 +1196,28 @@ public double getEntropyProduction(String unit) {
11941196
public double getMassBalance(String unit) {
11951197
double flow = 0.0;
11961198
for (int i = 0; i < numberOfInputStreams; i++) {
1197-
inletStreamMixer.getStream(i).getFluid().init(3);
1198-
flow += inletStreamMixer.getStream(i).getFluid().getFlowRate(unit);
1199+
if (inletStreamMixer.getStream(i).getFlowRate(unit) > 1e-10) {
1200+
inletStreamMixer.getStream(i).getFluid().init(3);
1201+
flow += inletStreamMixer.getStream(i).getFluid().getFlowRate(unit);
1202+
}
11991203
}
12001204

12011205
double liquidFlow = 0.0;
12021206
if (thermoSystem.hasPhaseType("aqueous") || thermoSystem.hasPhaseType("oil")) {
12031207
getLiquidOutStream().getThermoSystem().init(3);
12041208
liquidFlow = getLiquidOutStream().getThermoSystem().getFlowRate(unit);
1209+
if (liquidFlow < 1e-10) {
1210+
liquidFlow = 0.0;
1211+
}
12051212
}
12061213

12071214
double gasFlow = 0.0;
12081215
if (thermoSystem.hasPhaseType("gas")) {
12091216
getGasOutStream().getThermoSystem().init(3);
12101217
gasFlow = getGasOutStream().getThermoSystem().getFlowRate(unit);
1218+
if (gasFlow < 1e-10) {
1219+
gasFlow = 0.0;
1220+
}
12111221
}
12121222

12131223
return liquidFlow + gasFlow - flow;
@@ -1218,8 +1228,10 @@ public double getMassBalance(String unit) {
12181228
public double getExergyChange(String unit, double surroundingTemperature) {
12191229
double exergy = 0.0;
12201230
for (int i = 0; i < numberOfInputStreams; i++) {
1221-
inletStreamMixer.getStream(i).getFluid().init(3);
1222-
exergy += inletStreamMixer.getStream(i).getFluid().getExergy(surroundingTemperature, unit);
1231+
if (inletStreamMixer.getStream(i).getFlowRate(unit) > 1e-10) {
1232+
inletStreamMixer.getStream(i).getFluid().init(3);
1233+
exergy += inletStreamMixer.getStream(i).getFluid().getExergy(surroundingTemperature, unit);
1234+
}
12231235
}
12241236

12251237
double liquidExergy = 0.0;

src/main/java/neqsim/process/equipment/separator/ThreePhaseSeparator.java

Lines changed: 68 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -684,53 +684,96 @@ public void displayResult() {
684684
public double getEntropyProduction(String unit) {
685685
double entrop = 0.0;
686686
for (int i = 0; i < numberOfInputStreams; i++) {
687-
inletStreamMixer.getStream(i).getFluid().init(3);
688-
entrop += inletStreamMixer.getStream(i).getFluid().getEntropy(unit);
687+
if (inletStreamMixer.getStream(i).getFlowRate(unit) > 1e-10) {
688+
inletStreamMixer.getStream(i).getFluid().init(3);
689+
entrop += inletStreamMixer.getStream(i).getFluid().getEntropy(unit);
690+
}
691+
}
692+
693+
if (thermoSystem.hasPhaseType("aqueous")) {
694+
getWaterOutStream().getThermoSystem().init(3);
695+
entrop -= getWaterOutStream().getThermoSystem().getEntropy(unit);
696+
}
697+
if (thermoSystem.hasPhaseType("oil")) {
698+
getOilOutStream().getThermoSystem().init(3);
699+
entrop -= getOilOutStream().getThermoSystem().getEntropy(unit);
700+
}
701+
if (thermoSystem.hasPhaseType("gas")) {
702+
getGasOutStream().getThermoSystem().init(3);
703+
entrop -= getGasOutStream().getThermoSystem().getEntropy(unit);
689704
}
690-
getWaterOutStream().getThermoSystem().init(3);
691-
getOilOutStream().getThermoSystem().init(3);
692-
getGasOutStream().getThermoSystem().init(3);
693705

694-
return getWaterOutStream().getThermoSystem().getEntropy(unit)
695-
+ getOilOutStream().getThermoSystem().getEntropy(unit)
696-
+ getGasOutStream().getThermoSystem().getEntropy(unit) - entrop;
706+
return entrop;
697707
}
698708

699709
/** {@inheritDoc} */
700710
@Override
701711
public double getMassBalance(String unit) {
702712
double inletFlow = 0.0;
703713
for (int i = 0; i < numberOfInputStreams; i++) {
704-
inletStreamMixer.getStream(i).getFluid().init(3);
705-
inletFlow += inletStreamMixer.getStream(i).getFluid().getFlowRate(unit);
714+
if (inletStreamMixer.getStream(i).getFlowRate(unit) > 1e-10) {
715+
inletStreamMixer.getStream(i).getFluid().init(3);
716+
inletFlow += inletStreamMixer.getStream(i).getFluid().getFlowRate(unit);
717+
}
718+
}
719+
720+
// Only initialize and get flow rates for phases that actually exist
721+
double waterFlow = 0.0;
722+
double oilFlow = 0.0;
723+
double gasFlow = 0.0;
724+
725+
if (thermoSystem.hasPhaseType("aqueous")) {
726+
getWaterOutStream().getThermoSystem().init(3);
727+
waterFlow = getWaterOutStream().getThermoSystem().getFlowRate(unit);
728+
if (waterFlow < 1e-10) {
729+
waterFlow = 0.0;
730+
}
706731
}
707732

708-
getWaterOutStream().getThermoSystem().init(3);
709-
getOilOutStream().getThermoSystem().init(3);
710-
getGasOutStream().getThermoSystem().init(3);
733+
if (thermoSystem.hasPhaseType("oil")) {
734+
getOilOutStream().getThermoSystem().init(3);
735+
oilFlow = getOilOutStream().getThermoSystem().getFlowRate(unit);
736+
if (oilFlow < 1e-10) {
737+
oilFlow = 0.0;
738+
}
739+
}
711740

712-
double waterFlow = getWaterOutStream().getThermoSystem().getFlowRate(unit);
713-
double oilFlow = getOilOutStream().getThermoSystem().getFlowRate(unit);
714-
double gasFlow = getGasOutStream().getThermoSystem().getFlowRate(unit);
741+
if (thermoSystem.hasPhaseType("gas")) {
742+
getGasOutStream().getThermoSystem().init(3);
743+
gasFlow = getGasOutStream().getThermoSystem().getFlowRate(unit);
744+
if (gasFlow < 1e-10) {
745+
gasFlow = 0.0;
746+
}
747+
}
715748

716749
return waterFlow + oilFlow + gasFlow - inletFlow;
717750
}
718751

719752
/** {@inheritDoc} */
720753
@Override
721754
public double getExergyChange(String unit, double surroundingTemperature) {
722-
double entrop = 0.0;
755+
double exergy = 0.0;
723756
for (int i = 0; i < numberOfInputStreams; i++) {
724-
inletStreamMixer.getStream(i).getFluid().init(3);
725-
entrop += inletStreamMixer.getStream(i).getFluid().getExergy(surroundingTemperature, unit);
757+
if (inletStreamMixer.getStream(i).getFlowRate(unit) > 1e-10) {
758+
inletStreamMixer.getStream(i).getFluid().init(3);
759+
exergy += inletStreamMixer.getStream(i).getFluid().getExergy(surroundingTemperature, unit);
760+
}
761+
}
762+
763+
if (thermoSystem.hasPhaseType("aqueous")) {
764+
getWaterOutStream().getThermoSystem().init(3);
765+
exergy -= getWaterOutStream().getThermoSystem().getExergy(surroundingTemperature, unit);
766+
}
767+
if (thermoSystem.hasPhaseType("oil")) {
768+
getOilOutStream().getThermoSystem().init(3);
769+
exergy -= getOilOutStream().getThermoSystem().getExergy(surroundingTemperature, unit);
770+
}
771+
if (thermoSystem.hasPhaseType("gas")) {
772+
getGasOutStream().getThermoSystem().init(3);
773+
exergy -= getGasOutStream().getThermoSystem().getExergy(surroundingTemperature, unit);
726774
}
727-
getWaterOutStream().getThermoSystem().init(3);
728-
getOilOutStream().getThermoSystem().init(3);
729-
getGasOutStream().getThermoSystem().init(3);
730775

731-
return getWaterOutStream().getThermoSystem().getExergy(surroundingTemperature, unit)
732-
+ getOilOutStream().getThermoSystem().getEntropy(unit)
733-
+ getGasOutStream().getThermoSystem().getExergy(surroundingTemperature, unit) - entrop;
776+
return exergy;
734777
}
735778

736779
/** {@inheritDoc} */

0 commit comments

Comments
 (0)