diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/Calculator.java b/src/main/java/neqsim/processSimulation/processEquipment/util/Calculator.java index 2cb2f7624f..41a1a026a3 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/Calculator.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/Calculator.java @@ -79,15 +79,12 @@ public void runAntiSurgeCalc(UUID id) { Splitter anitSurgeSplitter = (Splitter) outputVariable; double distToSurge = compressor.getDistanceToSurge(); double flowInAntiSurge = anitSurgeSplitter.getSplitStream(1).getFlowRate("MSm3/day"); - if (compressor.getDistanceToSurge() > 0) { - flowInAntiSurge = anitSurgeSplitter.getSplitStream(1).getFlowRate("MSm3/day") - - anitSurgeSplitter.getSplitStream(1).getFlowRate("MSm3/day") * distToSurge * 0.5; - } else if (compressor.getDistanceToSurge() < 0) { - flowInAntiSurge = anitSurgeSplitter.getSplitStream(1).getFlowRate("MSm3/day") - - distToSurge * compressor.getInletStream().getFlowRate("MSm3/day") * 0.8; - if (flowInAntiSurge > compressor.getInletStream().getFlowRate("MSm3/day")) { - flowInAntiSurge = compressor.getInletStream().getFlowRate("MSm3/day") * 0.99; - } + + flowInAntiSurge = anitSurgeSplitter.getSplitStream(1).getFlowRate("MSm3/day") + - compressor.getInletStream().getFlowRate("MSm3/day") * distToSurge * 0.5; + + if (flowInAntiSurge > compressor.getInletStream().getFlowRate("MSm3/day")) { + flowInAntiSurge = compressor.getInletStream().getFlowRate("MSm3/day") * 0.99; } if (flowInAntiSurge < 1e-6) { flowInAntiSurge = 1e-6; diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java b/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java index 31034cc773..72d1a4a89d 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java @@ -283,8 +283,6 @@ public void run(UUID id) { * if(firstTime || iterations>maxIterations) { firstTime=false; return; } */ double enthalpy = 0.0; - - logger.info("flow rate old in recycle " + outletStream.getFlowRate("kg/hr")); SystemInterface thermoSystem2 = streams.get(0).getThermoSystem().clone(); if (numberOfInputStreams == 1 && thermoSystem2.getFlowRate("kg/hr") < 1e-100) { setError(0); @@ -318,13 +316,9 @@ public void run(UUID id) { mixedStream.setCalculationIdentifier(id); setError(massBalanceCheck()); setErrorFlow(massBalanceCheck2()); - logger.debug("comp recycle error: " + getError()); - logger.debug("flow recycle error: " + getErrorFlow()); lastIterationStream = mixedStream.clone(); outletStream.setThermoSystem(mixedStream.getThermoSystem()); outletStream.setCalculationIdentifier(id); - logger.info( - "flow rate new in recycle " + outletStream.getFlowRate("kg/hr") + " iter " + iterations); // logger.info("enthalpy: " + // mixedStream.getThermoSystem().getEnthalpy()); diff --git a/src/main/java/neqsim/thermo/system/SystemThermo.java b/src/main/java/neqsim/thermo/system/SystemThermo.java index a348ba5b00..a0dc8ec286 100644 --- a/src/main/java/neqsim/thermo/system/SystemThermo.java +++ b/src/main/java/neqsim/thermo/system/SystemThermo.java @@ -3304,9 +3304,10 @@ public final void initBeta() { for (int i = 0; i < numberOfPhases; i++) { this.beta[phaseIndex[i]] = getPhase(i).getNumberOfMolesInPhase() / getTotalNumberOfMoles(); } - if (this.getSumBeta() < 1.0 - ThermodynamicModelSettings.phaseFractionMinimumLimit + if (!isInitialized + && this.getSumBeta() < 1.0 - ThermodynamicModelSettings.phaseFractionMinimumLimit || this.getSumBeta() > 1.0 + ThermodynamicModelSettings.phaseFractionMinimumLimit) { - logger.warn("SystemThermo:initBeta - Sum of beta does not equal 1.0"); + logger.warn("SystemThermo:initBeta - Sum of beta does not equal 1.0 "); } } diff --git a/src/test/java/neqsim/processSimulation/processSystem/OilGasProcessTest.java b/src/test/java/neqsim/processSimulation/processSystem/OilGasProcessTest.java index dbe8179c86..c72a190be2 100644 --- a/src/test/java/neqsim/processSimulation/processSystem/OilGasProcessTest.java +++ b/src/test/java/neqsim/processSimulation/processSystem/OilGasProcessTest.java @@ -47,9 +47,9 @@ public void runProcess() throws InterruptedException { thermoSystem.addPlusFraction("C38_C80", 1.0, 662.0 / 1000.0, 0.92); thermoSystem.setMixingRule("classic"); thermoSystem.setMultiPhaseCheck(true); - thermoSystem.setMolarComposition(new double[] { 0.034266, 0.005269, 0.039189, 0.700553, 0.091154, + thermoSystem.setMolarComposition(new double[] {0.034266, 0.005269, 0.039189, 0.700553, 0.091154, 0.050908, 0.007751, 0.014665, 0.004249, 0.004878, 0.004541, 0.007189, 0.006904, 0.004355, - 0.007658, 0.003861, 0.003301, 0.002624, 0.001857, 0.001320, 0.001426, 0.001164, 0.000916 }); + 0.007658, 0.003861, 0.003301, 0.002624, 0.001857, 0.001320, 0.001426, 0.001164, 0.000916}); // thermoSystem.prettyPrint(); Stream feedStream = new Stream("feed stream", thermoSystem); @@ -57,8 +57,9 @@ public void runProcess() throws InterruptedException { feedStream.setTemperature(25.5, "C"); feedStream.setPressure(26.0, "bara"); - neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator seprator1stStage = new neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator( - "1st stage separator", feedStream); + neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator seprator1stStage = + new neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator( + "1st stage separator", feedStream); ThrottlingValve valve1 = new ThrottlingValve("valve1", seprator1stStage.getLiquidOutStream()); valve1.setOutletPressure(19.0); @@ -66,8 +67,9 @@ public void runProcess() throws InterruptedException { Heater oilHeater = new Heater("oil heater", valve1.getOutletStream()); oilHeater.setOutTemperature(359.0); - neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator seprator2ndStage = new neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator( - "2nd stage separator", oilHeater.getOutletStream()); + neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator seprator2ndStage = + new neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator( + "2nd stage separator", oilHeater.getOutletStream()); ThrottlingValve valve2 = new ThrottlingValve("valve2", seprator2ndStage.getLiquidOutStream()); valve2.setOutletPressure(2.7); @@ -75,12 +77,14 @@ public void runProcess() throws InterruptedException { StreamInterface recircstream1 = valve2.getOutletStream().clone("oilRecirc1"); recircstream1.setFlowRate(1e-6, "kg/hr"); - neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator seprator3rdStage = new neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator( - "3rd stage separator"); + neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator seprator3rdStage = + new neqsim.processSimulation.processEquipment.separator.ThreePhaseSeparator( + "3rd stage separator"); seprator3rdStage.addStream(valve2.getOutletStream()); seprator3rdStage.addStream(recircstream1); - ThrottlingValve pipeloss1st = new ThrottlingValve("pipeloss1st", seprator3rdStage.getGasOutStream()); + ThrottlingValve pipeloss1st = + new ThrottlingValve("pipeloss1st", seprator3rdStage.getGasOutStream()); pipeloss1st.setOutletPressure(2.7 - 0.03); Heater coolerLP = new Heater("cooler LP", pipeloss1st.getOutletStream()); @@ -98,7 +102,8 @@ public void runProcess() throws InterruptedException { recycle1.addStream(valveLP1.getOutletStream()); recycle1.setOutletStream(recircstream1); - neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); operations.add(feedStream); operations.add(seprator1stStage); operations.add(valve1); @@ -156,8 +161,9 @@ public void runAntiSurgeProcess() throws InterruptedException { gascompressor.run(); double fluidh = gascompressor.getPolytropicFluidHead(); - neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator compchartgenerator = new neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator( - gascompressor); + neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator compchartgenerator = + new neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator( + gascompressor); gascompressor.setCompressorChart(compchartgenerator.generateCompressorChart("mid range")); Cooler gascooler = new Cooler("gas cooler"); @@ -171,7 +177,7 @@ public void runAntiSurgeProcess() throws InterruptedException { Splitter gassplitter = new Splitter("gas splitter"); gassplitter.setInletStream(gassep.getGasOutStream()); - gassplitter.setFlowRates(new double[] { 7.0, 1.2 }, "MSm3/day"); + gassplitter.setFlowRates(new double[] {7.0, 1.2}, "MSm3/day"); gassplitter.run(); ThrottlingValve antisurgevalve = new ThrottlingValve("gas valve"); @@ -188,7 +194,8 @@ public void runAntiSurgeProcess() throws InterruptedException { antisurgeCalculator.addInputVariable(gascompressor); antisurgeCalculator.setOutputVariable(gassplitter); - neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); operations.add(gas_from_separator); operations.add(recyclegasstream); operations.add(gasmixer); @@ -279,7 +286,7 @@ public void runAntiSurgeProcess2() throws InterruptedException { Splitter gassplitter = new Splitter("gas splitter"); gassplitter.setInletStream(gassep.getGasOutStream()); - gassplitter.setFlowRates(new double[] { 7.0, 1.2 }, "MSm3/day"); + gassplitter.setFlowRates(new double[] {7.0, 1.2}, "MSm3/day"); ThrottlingValve antisurgevalve = new ThrottlingValve("gas valve"); antisurgevalve.setInletStream(gassplitter.getSplitStream(1)); @@ -288,9 +295,10 @@ public void runAntiSurgeProcess2() throws InterruptedException { Recycle recycl = new Recycle("rec"); recycl.addStream(antisurgevalve.getOutletStream()); recycl.setOutletStream(recyclegasstream); - recycl.setFlowAccuracy(1e-3); + recycl.setFlowAccuracy(1e-2); - neqsim.processSimulation.processSystem.ProcessSystem operations = new neqsim.processSimulation.processSystem.ProcessSystem(); + neqsim.processSimulation.processSystem.ProcessSystem operations = + new neqsim.processSimulation.processSystem.ProcessSystem(); operations.add(gas_from_separator); operations.add(recyclegasstream); operations.add(gasmixer); @@ -306,8 +314,9 @@ public void runAntiSurgeProcess2() throws InterruptedException { double fluidh = gascompressor.getPolytropicFluidHead(); double flowratetocompressor = gascompressor.getInletStream().getFlowRate("MSm3/day"); - neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator compchartgenerator = new neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator( - gascompressor); + neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator compchartgenerator = + new neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator( + gascompressor); gascompressor.setCompressorChart(compchartgenerator.generateCompressorChart("mid range")); gascompressor.setOutletPressure(90.0); gascompressor.getCompressorChart().setUseCompressorChart(false);