https://mooseframework.inl.gov
PIDChainControl.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "PIDChainControl.h"
11 #include "MooseUtils.h"
12 
14 
17 {
19 
20  params.addClassDescription("Implements a proportional-integral-derivative (PID) controller.");
21 
22  params.addRequiredParam<std::string>("input", "Input control data");
23  params.addRequiredParam<std::string>("set_point", "Set point control data");
24  params.addParam<Real>("initial_integral", 0.0, "Initial value for the integral component");
25  params.addRequiredParam<Real>("K_p", "Coefficient for the proportional term");
26  params.addRequiredParam<Real>("K_i", "Coefficient for the integral term");
27  params.addRequiredParam<Real>("K_d", "Coefficient for the derivative term");
28 
29  return params;
30 }
31 
33  : ChainControl(parameters),
34  _input(getChainControlData<Real>("input")),
35  _set_point(getChainControlData<Real>("set_point")),
36  _K_p(getParam<Real>("K_p")),
37  _K_i(getParam<Real>("K_i")),
38  _K_d(getParam<Real>("K_d")),
39  _error(declareChainControlData<Real>("error")),
40  _error_old(getChainControlDataOldByName<Real>(fullControlDataName("error"))),
41  _proportional(declareChainControlData<Real>("proportional")),
42  _integral(declareChainControlData<Real>("integral")),
43  _integral_old(getChainControlDataOldByName<Real>(fullControlDataName("integral"))),
44  _derivative(declareChainControlData<Real>("derivative")),
45  _output(declareChainControlData<Real>("value")),
46  _previous_time(declareRestartableData<Real>("previous_time"))
47 {
48  _integral = getParam<Real>("initial_integral");
50 }
51 
52 void
54 {
56  updateValues();
57 
59 }
60 
61 void
63 {
65 
69  _derivative = 0.0;
70  else
72 
74 }
const Real & _K_p
The coefficient for the proportional term.
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether two variables are equal within an absolute tolerance.
Definition: MooseUtils.h:380
const Real & _set_point
set point
Real & _output
The output computed by the PID controller.
const Real & _K_d
The coefficient for the derivative term.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Real & _error
The current value of the error.
virtual void execute() override
Execute the control.
Real & _dt
Time step size.
Real & _proportional
The proportional component.
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
auto max(const L &left, const R &right)
Implements a proportional-integral-derivative (PID) controller.
registerMooseObject("MooseApp", PIDChainControl)
Real & _integral
The integral component.
static InputParameters validParams()
Definition: ChainControl.C:14
const Real & _K_i
The coefficient for the integral term.
const Real & _integral_old
The old value of _integral.
void updateValues()
Updates all control data values.
Real & _derivative
The derivative component.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Real & _input
input data
PIDChainControl(const InputParameters &parameters)
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
const Real & _error_old
The old value of the error.
Real & _previous_time
Previous time for which value was computed.
Control that additionally provides the capability to produce/consume data values, to allow control op...
Definition: ChainControl.h:21