Skip to content

Commit

Permalink
Bug fix split (#579)
Browse files Browse the repository at this point in the history
* fix minor bug split stream

* fix bug

* bug fix
  • Loading branch information
EvenSol authored Nov 18, 2022
1 parent c2ac468 commit b0b19d1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,16 @@ public void calcSplitFactors() {
for (int i = 0; i < flowRates.length; i++) {
if (flowRates[i] < -0.1) {
missingFlowRate = inletStream.getFlowRate(flowUnit) - sum;
sum += missingFlowRate;

}
}

splitFactor = new double[flowRates.length];
for (int i = 0; i < flowRates.length; i++) {
splitFactor[i] = flowRates[i] / inletStream.getFlowRate(flowUnit);
splitFactor[i] = flowRates[i] / sum;
if (flowRates[i] < -0.1) {
splitFactor[i] = missingFlowRate / inletStream.getFlowRate(flowUnit);
splitFactor[i] = missingFlowRate / sum;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,12 @@ public double massBalanceCheck() {
// lastIterationStream.getThermoSystem().getPhase(0).getComponent(i).getx());
// logger.info("x new " +
// mixedStream.getThermoSystem().getPhase(0).getComponent(i).getx());
error += Math.abs(mixedStream.getThermoSystem().getPhase(0).getComponent(i).getx()
- lastIterationStream.getThermoSystem().getPhase(0).getComponent(i).getx());
error += Math
.abs(mixedStream.getThermoSystem().getPhase(0).getComponent(i).getx()
- lastIterationStream.getThermoSystem().getPhase(0).getComponent(i).getx())
+ Math.abs(mixedStream.getFlowRate("kg/sec") - lastIterationStream.getFlowRate("kg/sec")
+ Math.abs(mixedStream.getTemperature() - lastIterationStream.getTemperature()));

}
return Math.abs(error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void testRunSplitter2() {
Stream compressedStream = (Stream) compressor1.getOutletStream();

Splitter splitter = new Splitter("splitter 1", compressedStream);
splitter.setFlowRates(new double[] {5.0, 1.0}, "MSm3/day");
splitter.setFlowRates(new double[] {5.0, 0.1}, "MSm3/day");

StreamInterface resycStream1 = splitter.getSplitStream(1);

Expand Down Expand Up @@ -157,20 +157,22 @@ public void testRunSplitter2() {
processOps.run();

assertEquals(5.0, exportStream.getFlowRate("MSm3/day"), 1e-6);
assertEquals(1.0, resycStream1.getFlowRate("MSm3/day"), 1e-6);
assertEquals(83.41653486772951, valve1.getPercentValveOpening(), 1e-2);
assertEquals(0.1, resycStream1.getFlowRate("MSm3/day"), 1e-6);
assertEquals(8.43553108874272, valve1.getPercentValveOpening(), 1e-2);


splitter.setFlowRates(new double[] {5.0, 0.1}, "MSm3/day");
splitter.setFlowRates(new double[] {5.0, 0.5}, "MSm3/day");
processOps.run();
assertEquals(5.00000000, exportStream.getFlowRate("MSm3/day"), 1e-6);
assertEquals(0.1, resycStream1.getFlowRate("MSm3/day"), 1e-6);
assertEquals(8.4328749964588, valve1.getPercentValveOpening(), 1e-2);

assertEquals(5.00000000, exportStream.getFlowRate("MSm3/day"), 1e-4);
assertEquals(0.5, resycStream1.getFlowRate("MSm3/day"), 1e-4);
assertEquals(41.9139926125338, valve1.getPercentValveOpening(), 1e-2);

splitter.setFlowRates(new double[] {-1, 0.5}, "MSm3/day");
processOps.run();
assertEquals(5.00000000, exportStream.getFlowRate("MSm3/day"), 1e-6);
assertEquals(0.5, resycStream1.getFlowRate("MSm3/day"), 1e-6);
assertEquals(5.00000000, exportStream.getFlowRate("MSm3/day"), 1e-4);
assertEquals(0.5, resycStream1.getFlowRate("MSm3/day"), 1e-4);

}

}

0 comments on commit b0b19d1

Please sign in to comment.