OGS
|
This class gives an adaptive algorithm whose time step control is evolutionary PID controller. With an definition of relative solution change \(e_n=\frac{\|u^{n+1}-u^n\|}{\|u^{n+1}\|}\), the algorithm gives a time step size estimation as
\[ h_{n+1} = \left(\frac{e_{n-1}}{e_n}\right)^{k_P} \left(\frac{TOL}{e_n}\right)^{k_I} \left(\frac{e^2_{n-1}}{e_n e_{n-2}}\right)^{k_D} \]
where \(k_P=0.075\), \(k_I=0.175\), \(k_D=0.01\) are empirical PID parameters.
In the computation, \( e_n\) is calculated firstly. If \(e_n>TOL\), the current time step is rejected and repeated with a new time step size of \(h=\frac{TOL}{e_n} h_n\).
Limits of the time step size are given as
\[ h_{\mbox{min}} \leq h_{n+1} \leq h_{\mbox{max}}, l \leq \frac{h_{n+1}}{h_n} \leq L \]
Similar algorithm can be found in [1] .
Definition at line 51 of file EvolutionaryPIDcontroller.h.
#include <EvolutionaryPIDcontroller.h>
Public Member Functions | |
EvolutionaryPIDcontroller (const double t0, const double t_end, const double h0, const double h_min, const double h_max, const double rel_h_min, const double rel_h_max, const double tol) | |
std::tuple< bool, double > | next (double solution_error, int number_iterations) override |
bool | accepted () const override |
return if current time step is accepted or not More... | |
void | setAcceptedOrNot (const bool accepted) override |
bool | isSolutionErrorComputationNeeded () const override |
virtual bool | canReduceTimestepSize () const override |
Query the timestepper if further time step size reduction is possible. More... | |
Public Member Functions inherited from NumLib::TimeStepAlgorithm | |
TimeStepAlgorithm (const double t0, const double t_end) | |
TimeStepAlgorithm (const double t0, const double t_end, const double dt) | |
TimeStepAlgorithm (const double t0, const double t_end, const std::vector< double > &all_step_sizes) | |
virtual | ~TimeStepAlgorithm ()=default |
double | begin () const |
return the beginning of time steps More... | |
double | end () const |
return the end of time steps More... | |
const TimeStep | getTimeStep () const |
return current time step More... | |
void | resetCurrentTimeStep (const double dt) |
reset the current step size from the previous time More... | |
const std::vector< double > & | getTimeStepSizeHistory () const |
return a history of time step sizes More... | |
Private Member Functions | |
double | limitStepSize (const double h_new, const bool previous_step_accepted) const |
Private Attributes | |
const double | _kP = 0.075 |
Parameter. More... | |
const double | _kI = 0.175 |
Parameter. More... | |
const double | _kD = 0.01 |
Parameter. More... | |
const double | _h0 |
initial time step size. More... | |
const double | _h_min |
minimum step size. More... | |
const double | _h_max |
maximum step size. More... | |
const double | _rel_h_min |
\(l\) in \( h_{\mbox{min}} \leq h_{n+1} \leq h_{\mbox{max}},\) More... | |
const double | _rel_h_max |
\(L\) in \( h_{\mbox{min}} \leq h_{n+1} \leq h_{\mbox{max}},\) More... | |
const double | _tol |
double | _e_n_minus1 |
\(e_{n-1}\). More... | |
double | _e_n_minus2 |
\(e_{n-2}\). More... | |
bool | _is_accepted |
Additional Inherited Members | |
Protected Attributes inherited from NumLib::TimeStepAlgorithm | |
const double | _t_initial |
initial time More... | |
const double | _t_end |
end time More... | |
TimeStep | _ts_prev |
previous time step information More... | |
TimeStep | _ts_current |
current time step information More... | |
std::vector< double > | _dt_vector |
a vector of time step sizes More... | |
|
inline |
Definition at line 54 of file EvolutionaryPIDcontroller.h.
|
inlineoverridevirtual |
return if current time step is accepted or not
Implements NumLib::TimeStepAlgorithm.
Definition at line 74 of file EvolutionaryPIDcontroller.h.
References _is_accepted.
Referenced by setAcceptedOrNot().
|
overridevirtual |
Query the timestepper if further time step size reduction is possible.
Reimplemented from NumLib::TimeStepAlgorithm.
Definition at line 139 of file EvolutionaryPIDcontroller.cpp.
References _h_min, NumLib::TimeStepAlgorithm::_ts_current, NumLib::TimeStepAlgorithm::_ts_prev, and NumLib::TimeStep::dt().
|
inlineoverridevirtual |
Get a flag to indicate whether this algorithm needs to compute solution error. The default return value is false.
Reimplemented from NumLib::TimeStepAlgorithm.
Definition at line 81 of file EvolutionaryPIDcontroller.h.
|
private |
Forced the computed time step size in the given range (see the formulas in the documentation of the class) or use the half of the previous time step size under some other constrains.
h_new | The computed time step size. |
previous_step_accepted | An indicator for whether the previous time step is rejected. |
Definition at line 103 of file EvolutionaryPIDcontroller.cpp.
References _h_max, _h_min, _rel_h_max, _rel_h_min, NumLib::TimeStepAlgorithm::_ts_current, and NumLib::TimeStep::dt().
Referenced by next().
|
overridevirtual |
Move to the next time step
solution_error | Solution error \(e_n\) between two successive time steps. |
number_iterations | Number of non-linear iterations used. |
Implements NumLib::TimeStepAlgorithm.
Definition at line 23 of file EvolutionaryPIDcontroller.cpp.
References _e_n_minus1, _e_n_minus2, _h0, _is_accepted, _kD, _kI, _kP, _tol, NumLib::TimeStepAlgorithm::_ts_current, NumLib::TimeStep::dt(), limitStepSize(), NumLib::TimeStep::steps(), and WARN().
|
inlineoverridevirtual |
Set the status of the step.
accepted | A boolean parameter is needed to indicated whether the step is accepted or not. |
Reimplemented from NumLib::TimeStepAlgorithm.
Definition at line 76 of file EvolutionaryPIDcontroller.h.
References _is_accepted, and accepted().
|
private |
|
private |
|
private |
initial time step size.
Definition at line 90 of file EvolutionaryPIDcontroller.h.
Referenced by next().
|
private |
maximum step size.
Definition at line 92 of file EvolutionaryPIDcontroller.h.
Referenced by limitStepSize().
|
private |
minimum step size.
Definition at line 91 of file EvolutionaryPIDcontroller.h.
Referenced by canReduceTimestepSize(), and limitStepSize().
|
private |
Definition at line 104 of file EvolutionaryPIDcontroller.h.
Referenced by accepted(), next(), and setAcceptedOrNot().
|
private |
Parameter.
Definition at line 88 of file EvolutionaryPIDcontroller.h.
Referenced by next().
|
private |
Parameter.
Definition at line 87 of file EvolutionaryPIDcontroller.h.
Referenced by next().
|
private |
Parameter.
Definition at line 86 of file EvolutionaryPIDcontroller.h.
Referenced by next().
|
private |
\(L\) in \( h_{\mbox{min}} \leq h_{n+1} \leq h_{\mbox{max}},\)
Definition at line 97 of file EvolutionaryPIDcontroller.h.
Referenced by limitStepSize().
|
private |
\(l\) in \( h_{\mbox{min}} \leq h_{n+1} \leq h_{\mbox{max}},\)
Definition at line 95 of file EvolutionaryPIDcontroller.h.
Referenced by limitStepSize().
|
private |
Definition at line 99 of file EvolutionaryPIDcontroller.h.
Referenced by next().