From 6b92a1fbc6c6ec10220f6437a5dd22b648fe05f4 Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Sun, 10 Nov 2024 19:35:48 +0000 Subject: [PATCH] update --- .../process/equipment/splitter/Splitter.java | 26 ++++++++++++++++--- .../processmodel/CompressorModule.java | 5 ++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/main/java/neqsim/process/equipment/splitter/Splitter.java b/src/main/java/neqsim/process/equipment/splitter/Splitter.java index 1edc3494c9..3cc898f4cf 100644 --- a/src/main/java/neqsim/process/equipment/splitter/Splitter.java +++ b/src/main/java/neqsim/process/equipment/splitter/Splitter.java @@ -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; @@ -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. @@ -60,8 +63,7 @@ public Splitter(String name, StreamInterface inStream) { *

* * @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) { @@ -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) { @@ -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); } diff --git a/src/test/java/neqsim/process/processmodel/CompressorModule.java b/src/test/java/neqsim/process/processmodel/CompressorModule.java index 38991ce729..e8d4571590 100644 --- a/src/test/java/neqsim/process/processmodel/CompressorModule.java +++ b/src/test/java/neqsim/process/processmodel/CompressorModule.java @@ -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"));