Skip to content

Commit

Permalink
controller initial work (#389)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
EvenSol and asmfstatoil authored May 26, 2022
1 parent 5f0e5c6 commit c450349
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand All @@ -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");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -90,16 +90,38 @@ 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(
"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());
}

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();
}
}

}

0 comments on commit c450349

Please sign in to comment.