9 #ifndef Tempus_TimeStepControlStrategy_PID_hpp
10 #define Tempus_TimeStepControlStrategy_PID_hpp
12 #include "Tempus_TimeStepControl.hpp"
14 #include "Tempus_SolutionState.hpp"
15 #include "Tempus_SolutionHistory.hpp"
24 template<
class Scalar>
41 Status & integratorStatus)
override
50 Teuchos::RCP<SolutionState<Scalar> > workingState=solutionHistory->getWorkingState();
51 const Scalar errorAbs = workingState->getErrorAbs();
52 volatile const int iStep = workingState->getIndex();
53 volatile const Scalar errorRel = workingState->getErrorRel();
54 int order = workingState->getOrder();
55 Scalar dt = workingState->getTimeStep();
58 Teuchos::RCP<Teuchos::FancyOStream> out = tsc.getOStream();
59 Teuchos::OSTab ostab(out,1,
"getNextTimeStep");
77 Scalar k1 = Teuchos::as<Scalar>(-
k1_ / order);
78 Scalar k2 = Teuchos::as<Scalar>(
k2_ / order);
79 Scalar k3 = Teuchos::as<Scalar>(-
k3_ / order);
81 k1 = std::pow(
errN_, k1);
94 dt = std::min(dt, workingState->getTimestep());
105 workingState->setTimeStep(dt);
112 if (pList == Teuchos::null) {
114 if (
tscsPL_ == Teuchos::null) {
115 tscsPL_ = Teuchos::parameterList(
"TimeStepControlStrategyPID");
133 TEUCHOS_TEST_FOR_EXCEPTION(safetyFactor_ <= 0.0, std::out_of_range,
134 "Error - Invalid value of Safety Factory= " << safetyFactor_ <<
"! \n"
135 <<
"Safety Factor must be > 0.0.\n");
137 TEUCHOS_TEST_FOR_EXCEPTION(facMax_ <= 0.0, std::out_of_range,
138 "Error - Invalid value of Maximum Safety Factory= " << facMax_ <<
"! \n"
139 <<
"Maximum Safety Factor must be > 0.0.\n");
141 TEUCHOS_TEST_FOR_EXCEPTION(facMax_<= 0.0, std::out_of_range,
142 "Error - Invalid value of Minimum Safety Factory= " << facMin_ <<
"! \n"
143 <<
"Minimum Safety Factor must be > 0.0.\n");
148 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
150 pl->set<std::string>(
"Name",
"PID");
151 pl->set<Scalar>(
"K1" , 0.58,
"");
152 pl->set<Scalar>(
"K2" , 0.21,
"");
153 pl->set<Scalar>(
"K3" , 0.10,
"");
154 pl->set<Scalar>(
"Safety Factor" , 0.90,
"Safety Factor");
155 pl->set<Scalar>(
"Maximum Safety Factor" , 5.0,
"Maximum Safety Factor");
156 pl->set<Scalar>(
"Minimum Safety Factor" , 0.5,
"Minimum Safety Factor");
165 Teuchos::RCP<Teuchos::ParameterList> temp_plist =
tscsPL_;
187 #endif // Tempus_TimeStepControlStrategy_PID_hpp
virtual void getNextTimeStep(const TimeStepControl< Scalar > tsc, Teuchos::RCP< SolutionHistory< Scalar > > solutionHistory, Status &integratorStatus) override
Determine the time step size.
bool firstSuccessfulStep_
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
TimeStepControlStrategyPID(Teuchos::RCP< Teuchos::ParameterList > pList=Teuchos::null)
Constructor.
StepControlStrategy class for TimeStepControl.
Teuchos::RCP< Teuchos::ParameterList > getNonconstParameterList()
Status
Status for the Integrator, the Stepper and the SolutionState.
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &pList)
TimeStepControl manages the time step size. There several mechanicisms that effect the time step size...
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
Teuchos::RCP< Teuchos::ParameterList > unsetParameterList()
virtual ~TimeStepControlStrategyPID()
Destructor.
Teuchos::RCP< Teuchos::ParameterList > tscsPL_
StepControlStrategy class for TimeStepControl.