From c450349b1307cbe6701afe57664fcad8c5dddacc Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Thu, 26 May 2022 22:33:20 +0200 Subject: [PATCH] controller initial work (#389) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * initial work * updates * update * Update ProcessSystemControllerTest.java * Update ProcessSystemControllerTest.java * Update ProcessSystemRunTransientTest.java * update * Update ProcessModuleBaseClass.java * update * Update ProcessSystemRunTransientTest.java * refact: rename variable, getters and setters refact: typo * bugfix: invert when to calculate transient as steady state * bugfix: run controller for stream if it exists * Update ProcessEquipmentBaseClass.java * refact: moved code to SimulationInterface * add cache file to gitignore * revert * revert git push * refact: removed unnecessary line Co-authored-by: Åsmund Våge Fannemel <34712686+asmfstatoil@users.noreply.github.com> --- .../processEquipment/stream/Stream.java | 12 ++++--- .../ProcessSystemControllerTest.java | 32 ++++++++++++++++--- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java b/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java index e80afd3f70..bdc1f091ee 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/stream/Stream.java @@ -404,8 +404,14 @@ public String[][] getResultTable() { /** {@inheritDoc} */ @Override public void runTransient(double dt) { - runController(dt); - run(); + if (hasController) { + // This adjusts the flow rate through this stream. + // Typically used to match/manipulate mass balance. + runController(dt); + this.setFlowRate(getController().getResponse(), "kg/hr"); + } + + run(); } /** @@ -418,8 +424,6 @@ public void runTransient(double dt) { public void runController(double dt) { if (hasController) { getController().runTransient(this.getFlowRate("kg/hr"), dt); - thermoSystem.setTotalFlowRate(getController().getResponse(), "kg/hr"); - this.setFlowRate(getController().getResponse(), "kg/hr"); } } diff --git a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemControllerTest.java b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemControllerTest.java index 8583b69a12..edd678ddb8 100644 --- a/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemControllerTest.java +++ b/src/test/java/neqsim/processSimulation/processSystem/ProcessSystemControllerTest.java @@ -71,14 +71,14 @@ public void testStaticSimulationWithController() { VolumeFlowTransmitter flowTransmitter = new VolumeFlowTransmitter(separator_1.getGasOutStream()); flowTransmitter.setUnit("kg/hr"); - flowTransmitter.setMaximumValue(110.0); - flowTransmitter.setMinimumValue(90.0); + flowTransmitter.setMaximumValue(150.0); + flowTransmitter.setMinimumValue(10.0); ControllerDeviceInterface flowController = new ControllerDeviceBaseClass(); flowController.setTransmitter(flowTransmitter); flowController.setReverseActing(true); flowController.setControllerSetPoint(65.0 + getRandomDistrurbanceFlowRate()); - flowController.setControllerParameters(0.01, 0.10, 0.100); + flowController.setControllerParameters(0.5, 100.100, 0.0); p.add(stream_1); p.add(valve_1); @@ -90,7 +90,7 @@ public void testStaticSimulationWithController() { // transient behaviour p.setTimeStep(1.0); - for (int i = 0; i < 25; i++) { + for (int i = 0; i < 55; i++) { flowController.setControllerSetPoint(65.0 + getRandomDistrurbanceFlowRate()); p.runTransient(); System.out.println( @@ -98,8 +98,30 @@ public void testStaticSimulationWithController() { + " controller response " + flowController.getResponse() + " valve opening " + valve_1.getPercentValveOpening() + " pressure " + separator_1.getGasOutStream().getPressure()); + } + + for (int i = 0; i < 100; i++) { + flowController.setControllerSetPoint(55.0 + getRandomDistrurbanceFlowRate()); + // stream_1.runTransient(1.0); + p.runTransient(); + System.out.println( + "flow rate " + valve_1.getOutStream().getFluid().getPhase("gas").getFlowRate("kg/hr") + + " controller response " + flowController.getResponse() + " valve opening " + + valve_1.getPercentValveOpening() + " pressure " + + separator_1.getGasOutStream().getPressure()); + } + + // transient behaviour + p.setTimeStep(1.0); + for (int i = 0; i < 55; i++) { + flowController.setControllerSetPoint(75.0 + getRandomDistrurbanceFlowRate()); + p.runTransient(); + System.out.println( + "flow rate " + valve_1.getOutStream().getFluid().getPhase("gas").getFlowRate("kg/hr") + + " controller response " + flowController.getResponse() + " valve opening " + + valve_1.getPercentValveOpening() + " pressure " + + separator_1.getGasOutStream().getPressure()); // p.runTransient(); } } - }