Skip to content

Commit

Permalink
fix controller (#874)
Browse files Browse the repository at this point in the history
  • Loading branch information
EvenSol authored Dec 6, 2023
1 parent 94d3785 commit ed19e82
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,12 @@ public void runTransient(double initResponse, double dt, UUID id) {
/ (transmitter.getMaximumValue() - transmitter.getMinimumValue()) * 100;

if (Ti != 0) {
TintValue += Kp / Ti * error * dt;
TintValue = Kp / Ti * error;
}
double TderivValue = Kp * Td * (error - oldError) / dt;
response = initResponse + propConstant * (Kp * error + TintValue + TderivValue);
// System.out.println("error " + error + " %");
// error = device.getMeasuredPercentValue()-controlValue;
// double regulatorSignal = error*1.0;
double TderivValue = Kp * Td * ((error - 2 * oldError + oldoldError) / (dt * dt));

response = initResponse
+ propConstant * ((Kp * (error - oldError) / dt) + TintValue + TderivValue) * dt;
calcIdentifier = id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void testDynamicCalculation() {
flowController.setTransmitter(flowTransmitter);
flowController.setReverseActing(true);
flowController.setControllerSetPoint(73.5);
flowController.setControllerParameters(0.4, 10.0, 0.0);
flowController.setControllerParameters(0.2, 100.0, 0.0);

p.add(stream1);
p.add(valve1);
Expand All @@ -97,8 +97,8 @@ public void testDynamicCalculation() {
p.run();

// transient behaviour
p.setTimeStep(1.0);
for (int i = 0; i < 50; i++) {
p.setTimeStep(20.0);
for (int i = 0; i < 200; i++) {
// System.out.println("volume flow " + flowTransmitter.getMeasuredValue() + " valve opening "
// + valve1.getPercentValveOpening() + " pressure "
// + separator1.getGasOutStream().getPressure());
Expand All @@ -125,12 +125,12 @@ public void testDynamicCalculation2() {
testSystem3.setMixingRule(2);

Stream stream1 = new Stream("Stream1", testSystem2);
stream1.setFlowRate(100.0, "kg/hr");
stream1.setFlowRate(1090.0, "kg/hr");
stream1.setPressure(10.0, "bara");
stream1.setTemperature(25.0, "C");

Stream streamPurge = new Stream("StreamPurge", testSystem3);
streamPurge.setFlowRate(5.0, "kg/hr");
streamPurge.setFlowRate(50.0, "kg/hr");
streamPurge.setPressure(10.0, "bara");
streamPurge.setTemperature(25.0, "C");

Expand Down Expand Up @@ -173,7 +173,7 @@ public void testDynamicCalculation2() {
separatorLevelController.setReverseActing(false);
separatorLevelController.setTransmitter(separatorLevelTransmitter);
separatorLevelController.setControllerSetPoint(0.45);
separatorLevelController.setControllerParameters(5.0, 5000.0, 0.0);
separatorLevelController.setControllerParameters(2.0, 500.0, 0.0);

PressureTransmitter separatorPressureTransmitter =
new PressureTransmitter(separator1.getGasOutStream());
Expand All @@ -185,7 +185,7 @@ public void testDynamicCalculation2() {
separatorPressureController.setTransmitter(separatorPressureTransmitter);
separatorPressureController.setReverseActing(false);
separatorPressureController.setControllerSetPoint(7.0);
separatorPressureController.setControllerParameters(0.35, 0, 0.0);
separatorPressureController.setControllerParameters(1, 100, 0.0);

p.add(stream1);
p.add(streamPurge);
Expand All @@ -208,8 +208,8 @@ public void testDynamicCalculation2() {
}

// p.displayResult();
p.setTimeStep(50.0);
for (int i = 0; i < 200; i++) {
p.setTimeStep(10.0);
for (int i = 0; i < 250; i++) {
// System.out.println("pressure " + separator1.getGasOutStream().getPressure() + " flow "
// + separator1.getGasOutStream().getFlowRate("kg/hr") + " sepr height "
// + separatorLevelTransmitter.getMeasuredValue() + "valve2 opening "
Expand Down Expand Up @@ -280,7 +280,7 @@ public void testDynamicCalculation3() {
separatorPressureController.setTransmitter(separatorPressureTransmitter);
separatorPressureController.setReverseActing(false);
separatorPressureController.setControllerSetPoint(5.0);
separatorPressureController.setControllerParameters(0.5, 500.0, 0.0);
separatorPressureController.setControllerParameters(1, 200.0, 0.0);

p.add(stream1);
p.add(streamPurge);
Expand All @@ -298,8 +298,8 @@ public void testDynamicCalculation3() {
}

// p.displayResult();
p.setTimeStep(20.0);
for (int i = 0; i < 200; i++) {
p.setTimeStep(10.0);
for (int i = 0; i < 500; i++) {
// System.out.println("pressure " + separator1.getGasOutStream().getPressure() + " flow "
// + separator1.getGasOutStream().getFlowRate("kg/hr") + "valve3 opening "
// + valve3.getPercentValveOpening());
Expand Down

0 comments on commit ed19e82

Please sign in to comment.