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");
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.");
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.");
56 "Can be used to limit the maximum value output by the PID controller.");
59 "Can be used to limit the minimum value output by the PID controller.");
61 "maximum_change_rate",
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);
void mooseInfo(Args &&... args) const
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.
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 ...
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.
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 ExecFlagType EXEC_TIMESTEP_END
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 contains(const std::string &value) const
Methods for seeing if a value is set in the MultiMooseEnum.
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.
virtual void initialSetup() override
Called once at the beginning of the simulation, used to initialize recovered control values...
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 ExecFlagEnum & getExecuteOnEnum() const
Return the execute on MultiMooseEnum 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...
virtual void timestepSetup() override
Used to reset the PID when failing a timestep and the control is executed on timestep_end.
Base class for transient executioners that use a FixedPointSolve solve object for multiapp-main app i...
const Real _start_time
The time to start the PID controller on.
MooseApp & _app
The MOOSE application this is associated with.
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 and optionally a file path to the top-level block p...
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
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