From 4bffb7754d67fb9c653de8a7af6a3c91046aff00 Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Fri, 8 Dec 2023 08:44:20 +0000 Subject: [PATCH] some further work to get dynamic compressor to work --- .../compressor/Compressor.java | 8 +-- .../compressor/CompressorChart.java | 5 +- .../ProcessSystemRunTransientTest.java | 58 ++++++++++--------- 3 files changed, 38 insertions(+), 33 deletions(-) diff --git a/src/main/java/neqsim/processSimulation/processEquipment/compressor/Compressor.java b/src/main/java/neqsim/processSimulation/processEquipment/compressor/Compressor.java index 025d40bd38..66e052f37c 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/compressor/Compressor.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/compressor/Compressor.java @@ -680,15 +680,15 @@ public void runTransient(double dt, UUID id) { } // runController(dt, id); - System.out.println("delta p compressor " - + (outStream.getThermoSystem().getPressure() - inStream.getThermoSystem().getPressure())); - + // System.out.println("delta p compressor " + // + (outStream.getThermoSystem().getPressure() - inStream.getThermoSystem().getPressure())); + inStream.getThermoSystem().initProperties(); double guessFlow = inStream.getThermoSystem().getFlowRate("m3/hr"); outStream.getThermoSystem().init(3); inStream.getThermoSystem().init(3); double polytropicHead = outStream.getThermoSystem().getEnthalpy("kJ/kg") - inStream.getThermoSystem().getEnthalpy("kJ/kg"); - System.out.println("polytropic head " + polytropicHead); + // System.out.println("polytropic head " + polytropicHead); double actualFlowRateNew = 10.0; actualFlowRateNew = getCompressorChart().getFlow(polytropicHead, getSpeed(), guessFlow); diff --git a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChart.java b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChart.java index 7813e34f47..c74485b015 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChart.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/compressor/CompressorChart.java @@ -178,9 +178,8 @@ public double getFlow(double head, int speed, double guessFlow) { newhead = getPolytropicHead(newflow, speed); error = newhead - head; derrordspeed = (error - olderror) / (newflow - oldflow); - if (Math.abs(error) > 1e-6) - newflow -= error / derrordspeed; - System.out.println("newflow " + newflow); + newflow -= error / derrordspeed; + // System.out.println("newflow " + newflow); } while (Math.abs(error) > 1e-6 && iter < 100); // change speed to minimize diff --git a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemRunTransientTest.java b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemRunTransientTest.java index 6d26a02453..941e01632c 100644 --- a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemRunTransientTest.java +++ b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemRunTransientTest.java @@ -223,8 +223,6 @@ public void testDynamicCalculation2() { assertEquals(0.45, separatorLevelTransmitter.getMeasuredValue(), 0.01); } - - @Test public void testDynamicCompressor() { neqsim.thermo.system.SystemInterface testSystem2 = @@ -234,7 +232,7 @@ public void testDynamicCompressor() { testSystem2.setMixingRule(2); Stream stream1 = new Stream("Stream1", testSystem2); - stream1.setFlowRate(100.0, "kg/hr"); + stream1.setFlowRate(50.0, "kg/hr"); stream1.setPressure(100.0, "bara"); stream1.setTemperature(55.0, "C"); @@ -246,18 +244,18 @@ public void testDynamicCompressor() { Separator separator1 = new Separator("separator_1"); separator1.addStream(valve1.getOutletStream()); separator1.setCalculateSteadyState(false); - separator1.setSeparatorLength(1.0); + separator1.setSeparatorLength(3.0); separator1.setInternalDiameter(0.8); separator1.setLiquidLevel(0.0); Compressor compressor1 = new Compressor(separator1.getGasOutStream()); - compressor1.setCalculateSteadyState(true); + compressor1.setCalculateSteadyState(false); compressor1.setOutletPressure(100.0); Separator separator2 = new Separator("separator_2"); separator2.addStream(compressor1.getOutletStream()); separator2.setCalculateSteadyState(false); - separator2.setSeparatorLength(1.0); + separator2.setSeparatorLength(3.0); separator2.setInternalDiameter(0.8); separator2.setLiquidLevel(0.0); @@ -274,6 +272,7 @@ public void testDynamicCompressor() { p.add(valve2); p.run(); + assertEquals(100.0, compressor1.getOutletStream().getPressure(), 0.01); neqsim.processSimulation.processEquipment.compressor.CompressorChartGenerator compchartgenerator = @@ -281,31 +280,38 @@ public void testDynamicCompressor() { compressor1); compressor1.setCompressorChart(compchartgenerator.generateCompressorChart("normal")); compressor1.getCompressorChart().setUseCompressorChart(true); + p.run(); assertEquals(102.7, compressor1.getOutletStream().getPressure(), 2.01); - compressor1.setSpeed(compressor1.getSpeed() + 500); - p.run(); - assertEquals(156.264, compressor1.getOutletStream().getPressure(), 2.01); - + assertEquals(50.0, separator1.getGasOutStream().getPressure(), 0.01); System.out.println("speed " + compressor1.getSpeed()); p.setTimeStep(1.0); - // p.runTransient(); - - assertEquals(50.0, separator1.getGasOutStream().getPressure(), 0.01); + p.runTransient(); + + // compressor1.setSpeed(compressor1.getSpeed() + 500); + for (int i = 0; i < 1000; i++) { + System.out.println("time " + i + " speed " + compressor1.getSpeed() + "feed flow " + + stream1.getFlowRate("kg/hr") + " compressor flow rate " + + compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " + + valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " + + (compressor1.getOutletStream().getPressure() + - compressor1.getInletStream().getPressure()) + + " pres inn " + compressor1.getInletStream().getPressure() + " pres out " + + compressor1.getOutletStream().getPressure()); + p.runTransient(); + } - compressor1.setCalculateSteadyState(false); - compressor1.runTransient(1); - compressor1.setSpeed(compressor1.getSpeed() + 500); - compressor1.runTransient(1); - compressor1.setSpeed(compressor1.getSpeed() + 500); - compressor1.runTransient(1); - compressor1.setSpeed(compressor1.getSpeed() + 500); - compressor1.runTransient(1); compressor1.setSpeed(compressor1.getSpeed() - 500); - compressor1.runTransient(1); - compressor1.setSpeed(compressor1.getSpeed() - 500); - compressor1.runTransient(1); - compressor1.setSpeed(compressor1.getSpeed() - 500); - compressor1.runTransient(1); + for (int i = 0; i < 2000; i++) { + System.out.println("time " + i + " speed " + compressor1.getSpeed() + "feed flow " + + stream1.getFlowRate("kg/hr") + " compressor flow rate " + + compressor1.getInletStream().getFlowRate("kg/hr") + " out flow " + + valve2.getOutletStream().getFlowRate("kg/hr") + " delta p " + + (compressor1.getOutletStream().getPressure() + - compressor1.getInletStream().getPressure()) + + " pres inn " + compressor1.getInletStream().getPressure() + " pres out " + + compressor1.getOutletStream().getPressure()); + p.runTransient(); + } } }