22 "Sets the value of a 'Real' input parameter (or postprocessor) based on a Proportional " 23 "Integral Derivative control of a postprocessor to match a target a target value.");
25 "postprocessor",
"The postprocessor to watch for controlling the specified parameter.");
27 "The target value 1D time function for the postprocessor");
30 "The coefficient multiplying the difference term");
31 params.
addRequiredParam<
Real>(
"K_derivative",
"The coefficient multiplying the derivative term");
34 "The input parameter(s) to control. Specify a single parameter name and all " 35 "parameters in all objects matching the name will be updated");
36 params.
addParam<std::string>(
"parameter_pp",
37 "The postprocessor to control. Should be accessed by reference by " 38 "the objects depending on its value.");
44 "reset_every_timestep",
46 "Reset the PID integral when changing timestep, for coupling iterations within a timestep");
47 params.
addParam<
bool>(
"reset_integral_windup",
49 "Reset the PID integral when the error crosses zero and the integral is " 50 "larger than the error.");
54 "Can be used to limit the maximum value output by the PID controller.");
57 "Can be used to limit the minimum value output by the PID controller.");
59 "maximum_change_rate",
61 "maximum_change_rate>0",
62 "Can be used to limit the absolute rate of change per second of value " 63 "output by the PID controller.");
69 _current(getPostprocessorValueByName(getParam<PostprocessorName>(
"postprocessor"))),
70 _target(getFunction(
"target")),
71 _Kint(getParam<
Real>(
"K_integral")),
72 _Kpro(getParam<
Real>(
"K_proportional")),
73 _Kder(getParam<
Real>(
"K_derivative")),
74 _start_time(getParam<
Real>(
"start_time")),
75 _stop_time(getParam<
Real>(
"stop_time")),
76 _reset_every_timestep(getParam<bool>(
"reset_every_timestep")),
77 _reset_integral_windup(getParam<bool>(
"reset_integral_windup")),
78 _maximum_output_value(getParam<
Real>(
"maximum_output_value")),
79 _minimum_output_value(getParam<
Real>(
"minimum_output_value")),
80 _maximum_change_rate(getParam<
Real>(
"maximum_change_rate")),
81 _integral(declareRestartableData<
Real>(
"pid_integral", 0)),
82 _integral_old(declareRestartableData<
Real>(
"pid_integral_old", 0)),
83 _value(declareRestartableData<
Real>(
"pid_value", 0)),
84 _value_old(declareRestartableData<
Real>(
"pid_value_old", 0)),
85 _t_step_old(declareRestartableData<
int>(
"pid_tstep_old", -1)),
86 _old_delta(declareRestartableData<
Real>(
"pid_delta_old", 0)),
90 mooseError(
"PIDTransientControl is only meant to be used when the problem is transient, for " 91 "example with a Transient Executioner. Support for Steady " 92 "Executioner can be added in the future, however certain parameters are currently " 93 "not well defined for use with Picard iterations.");
97 "Either a controllable parameter or a postprocessor to control should be specified, " 100 mooseError(
"A parameter or a postprocessor to control should be specified.");
103 "reset_every_timestep",
104 "Resetting the PID every time step is only supported using controlled postprocessors");
107 "The parameters maximum_output_value and minimum_output_value are inconsistent. The value " 108 "of maximum_output_value should be greater than the value of minimum_output_value.");
119 mooseInfo(
"Skipping execution on recover + INITIAL.");
134 _value = getControllableValue<Real>(
"parameter");
188 setControllableValue<Real>(
"parameter",
_value);
const Real _Kint
The coefficient multiplying the integral of the error.
const PostprocessorValue & _current
The current value of the target postprocessor.
static InputParameters validParams()
Class constructor.
Real & _integral
Integral of the error.
const Real _stop_time
The time to stop using the PID controller on.
static InputParameters validParams()
const bool _reset_every_timestep
Whether to reset the PID integral error when changing timestep, to limit its action to within couplin...
void setPostprocessorValueByName(const PostprocessorName &name, const PostprocessorValue &value, std::size_t t_index=0)
Set the value of a PostprocessorValue.
void mooseInfo(Args &&... args) const
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
const Real _Kder
The coefficient multiplying the derivative of the error.
Real _delta_prev_tstep
the difference with the target from the previous time step, used if a time step fails ...
Real & _dt
Time step size.
const bool _reset_integral_windup
Whether to reset the PID integral error when the error crosses 0, to avoid windup.
Real & _value_old
Saved value of the controlled parameter at the beginning of a timestep, to recover from a failed solv...
unsigned int numFixedPointIts() const
Get the number of fixed point iterations performed Because this returns the number of fixed point ite...
registerMooseObject("MooseApp", PIDTransientControl)
Real & _value
Saved value of the controlled parameter at the end of a timestep.
A time-dependent control of an input parameter or a postprocessor, which aims at making a postprocess...
auto max(const L &left, const R &right)
bool _has_recovered
whether the app has recovered once, because the logic for setting the value is different after having...
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
int & _t_step
The number of the time step.
const Real _minimum_output_value
Limiting minimum value for the output of the PID controller.
const Real _Kpro
The coefficient multiplying the error.
const Real _maximum_output_value
Limiting maximum value for the output of the PID controller.
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this object.
const Function & _target
The target 1D time-dependent function for the postprocessor.
virtual void execute() override
Execute the control.
Real & _old_delta
the previous value of the difference with the target, to detect changes of sign, and to compute the d...
Real _old_delta_prev_tstep
the difference with the target from the second-to-last iteration of previous time step...
const Real _start_time
The time to start the PID controller on.
MooseApp & _app
The MOOSE application this is associated with.
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 ...
int & _t_step_old
the previous time step
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
virtual const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName &name) const
Retrieve the value of the Postprocessor.
Real & _integral_old
Saved value of the integral at the beginning of a timestep, to recover from a failed solve...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Base class for Control objects.
PIDTransientControl(const InputParameters ¶meters)
Class constructor.
FixedPointSolve & fixedPointSolve()
const Real _maximum_change_rate
Limiting maximum value for the rate of change of output of the PID controller.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
virtual bool isTransient() const override
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...
bool isRecovering() const
Whether or not this is a "recover" calculation.
auto min(const L &left, const R &right)
void ErrorVector unsigned int
const ExecFlagType EXEC_INITIAL