24 "Sets the value of a 'Real' input parameter (or postprocessor) based on a Proportional "
25 "Integral Derivative control of a postprocessor to match a target a target value.");
27 "postprocessor",
"The postprocessor to watch for controlling the specified parameter.");
29 "The target value 1D time function for the postprocessor");
30 params.
addRequiredParam<Real>(
"K_integral",
"The coefficient multiplying the integral term");
32 "The coefficient multiplying the difference term");
33 params.
addRequiredParam<Real>(
"K_derivative",
"The coefficient multiplying the derivative term");
36 "The input parameter(s) to control. Specify a single parameter name and all "
37 "parameters in all objects matching the name will be updated");
38 params.
addParam<std::string>(
"parameter_pp",
39 "The postprocessor to control. Should be accessed by reference by "
40 "the objects depending on its value.");
42 "start_time", -std::numeric_limits<Real>::max(),
"The time to start the PID controller at");
44 "stop_time", std::numeric_limits<Real>::max(),
"The time to stop the PID controller at");
46 "reset_every_timestep",
48 "Reset the PID integral when changing timestep, for coupling iterations within a timestep");
49 params.
addParam<
bool>(
"reset_integral_windup",
51 "Reset the PID integral when the error crosses zero and the integral is "
52 "larger than the error.");
54 params.
addParam<Real>(
"maximum_output_value",
55 std::numeric_limits<Real>::max(),
56 "Can be used to limit the maximum value output by the PID controller.");
57 params.
addParam<Real>(
"minimum_output_value",
58 -std::numeric_limits<Real>::max(),
59 "Can be used to limit the minimum value output by the PID controller.");
61 "maximum_change_rate",
62 std::numeric_limits<Real>::max(),
63 "maximum_change_rate>0",
64 "Can be used to limit the absolute rate of change per second of value "
65 "output by the PID controller.");
71 _current(getPostprocessorValueByName(getParam<PostprocessorName>(
"postprocessor"))),
72 _target(getFunction(
"target")),
73 _Kint(getParam<Real>(
"K_integral")),
74 _Kpro(getParam<Real>(
"K_proportional")),
75 _Kder(getParam<Real>(
"K_derivative")),
76 _start_time(getParam<Real>(
"start_time")),
77 _stop_time(getParam<Real>(
"stop_time")),
78 _reset_every_timestep(getParam<bool>(
"reset_every_timestep")),
79 _reset_integral_windup(getParam<bool>(
"reset_integral_windup")),
80 _maximum_output_value(getParam<Real>(
"maximum_output_value")),
81 _minimum_output_value(getParam<Real>(
"minimum_output_value")),
82 _maximum_change_rate(getParam<Real>(
"maximum_change_rate")),
83 _integral(declareRestartableData<Real>(
"pid_integral", 0)),
84 _integral_old(declareRestartableData<Real>(
"pid_integral_old", 0)),
85 _value(declareRestartableData<Real>(
"pid_value", 0)),
86 _value_old(declareRestartableData<Real>(
"pid_value_old", 0)),
87 _t_step_old(declareRestartableData<
int>(
"pid_tstep_old", -1)),
88 _old_delta(declareRestartableData<Real>(
"pid_delta_old", 0)),
92 mooseError(
"PIDTransientControl is only meant to be used when the problem is transient, for "
93 "example with a Transient Executioner. Support for Steady "
94 "Executioner can be added in the future, however certain parameters are currently "
95 "not well defined for use with Picard iterations.");
99 "Either a controllable parameter or a postprocessor to control should be specified, "
102 mooseError(
"A parameter or a postprocessor to control should be specified.");
105 "reset_every_timestep",
106 "Resetting the PID every time step is only supported using controlled postprocessors");
109 "The parameters maximum_output_value and minimum_output_value are inconsistent. The value "
110 "of maximum_output_value should be greater than the value of minimum_output_value.");
121 mooseInfo(
"Skipping execution on recover + INITIAL.");
136 _value = getControllableValue<Real>(
"parameter");
190 setControllableValue<Real>(
"parameter",
_value);
206 setControllableValue<Real>(
"parameter",
_value);
216 if (t_ex && t_ex->getTimeStepper()->justFailedTimeStep() &&
224 setControllableValue<Real>(
"parameter",
_value);
const ExecFlagType EXEC_TIMESTEP_END
const ExecFlagType EXEC_INITIAL
registerMooseObject("MooseApp", PIDTransientControl)
void ErrorVector unsigned int
Base class for Control objects.
static InputParameters validParams()
Class constructor.
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this object.
FixedPointSolve & fixedPointSolve()
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
void setPostprocessorValueByName(const PostprocessorName &name, const PostprocessorValue &value, std::size_t t_index=0)
Set the value of a PostprocessorValue.
virtual bool isTransient() const override
unsigned int numFixedPointIts() const
Get the number of fixed point iterations performed Because this returns the number of fixed point ite...
virtual Real value(Real t, const Point &p) const
Override this to evaluate the scalar function at point (t,x,y,z), by default this returns zero,...
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
bool isRecovering() const
Whether or not this is a "recover" calculation.
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
void mooseInfo(Args &&... args) const
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
MooseApp & _app
The MOOSE application this is associated with.
bool contains(const std::string &value) const
Methods for seeing if a value is set in the MultiMooseEnum.
A time-dependent control of an input parameter or a postprocessor, which aims at making a postprocess...
Real _delta_prev_tstep
the difference with the target from the previous time step, used if a time step fails
const bool _reset_integral_windup
Whether to reset the PID integral error when the error crosses 0, to avoid windup.
const Real _minimum_output_value
Limiting minimum value for the output of the PID controller.
bool _has_recovered
whether the app has recovered once, because the logic for setting the value is different after having...
const Function & _target
The target 1D time-dependent function for the postprocessor.
Real & _value
Saved value of the controlled parameter at the end of a timestep.
Real & _integral_old
Saved value of the integral at the beginning of a timestep, to recover from a failed solve.
const PostprocessorValue & _current
The current value of the target postprocessor.
const bool _reset_every_timestep
Whether to reset the PID integral error when changing timestep, to limit its action to within couplin...
const Real _maximum_output_value
Limiting maximum value for the output of the PID controller.
Real & _integral
Integral of the error.
const Real _Kder
The coefficient multiplying the derivative of the error.
const Real _Kpro
The coefficient multiplying the error.
virtual void initialSetup() override
Called once at the beginning of the simulation, used to initialize recovered control values.
Real & _old_delta
the previous value of the difference with the target, to detect changes of sign, and to compute the d...
virtual void timestepSetup() override
Used to reset the PID when failing a timestep and the control is executed on timestep_end.
virtual void execute() override
Execute the control.
const Real _stop_time
The time to stop using the PID controller on.
static InputParameters validParams()
const Real _maximum_change_rate
Limiting maximum value for the rate of change of output of the PID controller.
const Real _start_time
The time to start the PID controller on.
int & _t_step_old
the previous time step
Real & _value_old
Saved value of the controlled parameter at the beginning of a timestep, to recover from a failed solv...
Real _old_delta_prev_tstep
the difference with the target from the second-to-last iteration of previous time step,...
const Real _Kint
The coefficient multiplying the integral of the error.
PIDTransientControl(const InputParameters ¶meters)
Class constructor.
virtual const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName &name) const
Retrieve the value of the Postprocessor.
const ExecFlagEnum & getExecuteOnEnum() const
Return the execute on MultiMooseEnum for this object.
Base class for transient executioners that use a FixedPointSolve solve object for multiapp-main app i...
Real & _dt
Time step size.
int & _t_step
The number of the time step.