Skip to content

Commit

Permalink
Merge pull request #28168 from ffarha/next
Browse files Browse the repository at this point in the history
Adding maximum rate of change of control value in PIDTransientControl
  • Loading branch information
GiudGiud authored Jul 20, 2024
2 parents fa86bb0 + 369b65c commit ef05966
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
2 changes: 2 additions & 0 deletions framework/include/controls/PIDTransientControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class PIDTransientControl : public Control
const Real _maximum_output_value;
/// Limiting minimum value for the output of the PID controller
const Real _minimum_output_value;
/// Limiting maximum value for the rate of change of output of the PID controller
const Real _maximum_change_rate;
/// Integral of the error
Real _integral;
/// Saved value of the integral at the beginning of a timestep, to recover from a failed solve
Expand Down
17 changes: 15 additions & 2 deletions framework/src/controls/PIDTransientControl.C
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ PIDTransientControl::validParams()
params.addParam<Real>("minimum_output_value",
-std::numeric_limits<Real>::max(),
"Can be used to limit the minimum value output by the PID controller.");

params.addRangeCheckedParam<Real>(
"maximum_change_rate",
std::numeric_limits<Real>::max(),
"maximum_change_rate>0",
"Can be used to limit the absolute rate of change per second of value "
"output by the PID controller.");
return params;
}

Expand All @@ -71,6 +76,7 @@ PIDTransientControl::PIDTransientControl(const InputParameters & parameters)
_reset_integral_windup(getParam<bool>("reset_integral_windup")),
_maximum_output_value(getParam<Real>("maximum_output_value")),
_minimum_output_value(getParam<Real>("minimum_output_value")),
_maximum_change_rate(getParam<Real>("maximum_change_rate")),
_integral(0),
_integral_old(0),
_value_old(0),
Expand Down Expand Up @@ -147,7 +153,14 @@ PIDTransientControl::execute()
if (_dt > 0)
value += _Kder * delta / _dt;

value = std::min(std::max(_minimum_output_value, value), _maximum_output_value);
// If the maxmimum rate of change by the pid is fixed
if (_maximum_change_rate != std::numeric_limits<Real>::max())
{
value = std::min(std::max(_value_old - _dt * _maximum_change_rate, value),
_value_old + _dt * _maximum_change_rate);
}
else
value = std::min(std::max(_minimum_output_value, value), _maximum_output_value);

// Set the new value of the postprocessor
if (isParamValid("parameter"))
Expand Down
22 changes: 22 additions & 0 deletions test/tests/controls/pid_control/gold/abs_max_rate_change.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
time,integral,left_boundary_average
0,0,0
1,0.74999999857139,0.5
2,1.0000000000087,1
3,1.2500000001768,1.5
4,1.5000000010787,2
5,1.7500000000994,2.5
6,1.9999999994641,3
7,2.2499999992713,3.5
8,2.5000000007506,4
9,2.2499999995544,3.5
10,1.9999999993692,3
11,1.7500000011553,2.5
12,1.4999999993654,2
13,1.2500000006843,1.5
14,1.0125000007242,1.0249999996979
15,1.1493749988583,1.2987499986277
16,1.3862812505461,1.7725625007516
17,1.5497484377364,2.0994968754729
18,1.5984344530613,2.1968689065483
19,1.5711259338526,2.1422518677051
20,1.5232741330385,2.046548266139
8 changes: 8 additions & 0 deletions test/tests/controls/pid_control/tests
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
recover = false
cli_args = 'Outputs/file_base=min_max_limits Controls/integral_value/maximum_output_value=4.0 Controls/integral_value/minimum_output_value=2.0 Executioner/nl_abs_tol=1e-12 Executioner/end_time=10'
detail = 'allowing the Proportional Integral Derivative control to have limits for its maximum and minimum output,'
[]
[abs_max_rate_change]
type = 'CSVDiff'
input = 'pid_control.i'
csvdiff = 'abs_max_rate_change.csv'
recover = false
cli_args = 'Outputs/file_base=abs_max_rate_change Controls/integral_value/maximum_change_rate=0.5 Executioner/nl_abs_tol=1e-12'
detail = 'allowing the Proportional Integral Derivative control to have limits for its absolute maximum rate of change of control variable,'
[]
[basic_postprocessor]
type = 'CSVDiff'
Expand Down

0 comments on commit ef05966

Please sign in to comment.