9 #ifndef Tempus_RKButcherTableau_hpp
10 #define Tempus_RKButcherTableau_hpp
14 #pragma clang system_header
19 #include "Teuchos_Assert.hpp"
20 #include "Teuchos_as.hpp"
21 #include "Teuchos_Describable.hpp"
22 #include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
23 #include "Teuchos_VerboseObject.hpp"
24 #include "Teuchos_VerboseObjectParameterListHelpers.hpp"
25 #include "Teuchos_SerialDenseMatrix.hpp"
26 #include "Teuchos_SerialDenseVector.hpp"
27 #include "Thyra_MultiVectorStdOps.hpp"
52 template<
class Scalar>
54 virtual public Teuchos::Describable,
55 virtual public Teuchos::ParameterListAcceptorDefaultBase,
56 virtual public Teuchos::VerboseObject<RKButcherTableau<Scalar> >
60 virtual std::size_t
numStages()
const {
return A_.numRows(); }
62 virtual const Teuchos::SerialDenseMatrix<int,Scalar>&
A()
const
65 virtual const Teuchos::SerialDenseVector<int,Scalar>&
b()
const
68 virtual const Teuchos::SerialDenseVector<int,Scalar>&
bstar()
const
71 virtual const Teuchos::SerialDenseVector<int,Scalar>&
c()
const
87 const Teuchos::SerialDenseMatrix<int,Scalar>&
A,
88 const Teuchos::SerialDenseVector<int,Scalar>&
b,
89 const Teuchos::SerialDenseVector<int,Scalar>&
c,
91 const std::string& longDescription,
93 const Teuchos::SerialDenseVector<int,Scalar>&
94 bstar = Teuchos::SerialDenseVector<int,Scalar>())
101 const Teuchos::SerialDenseMatrix<int,Scalar>& A,
102 const Teuchos::SerialDenseVector<int,Scalar>& b,
103 const Teuchos::SerialDenseVector<int,Scalar>& c,
107 const std::string& longDescription,
109 const Teuchos::SerialDenseVector<int,Scalar>&
110 bstar = Teuchos::SerialDenseVector<int,Scalar>())
113 TEUCHOS_ASSERT_EQUALITY( A.numCols(),
numStages );
114 TEUCHOS_ASSERT_EQUALITY( b.length(),
numStages );
115 TEUCHOS_ASSERT_EQUALITY( c.length(),
numStages );
116 TEUCHOS_ASSERT( order > 0 );
137 Teuchos::RCP<Teuchos::ParameterList>
const& pList)
139 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
143 TEUCHOS_TEST_FOR_EXCEPTION(
144 pl->get<std::string>(
"Stepper Type") != this->description()
147 " Stepper Type = " + pl->get<std::string>(
"Stepper Type"));
148 this->setMyParamList(pl);
152 virtual Teuchos::RCP<const Teuchos::ParameterList>
155 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
156 pl->setName(
"Default Stepper - " + this->
description());
158 pl->set<std::string>(
"Stepper Type", this->
description());
159 pl->set<
bool>(
"Use Embedded",
false);
160 pl->set<
bool>(
"Use FSAL",
false);
161 pl->set<std::string>(
"Initial Condition Consistency",
"None");
162 pl->set<
bool>(
"Initial Condition Consistency Check",
true);
173 const Teuchos::EVerbosityLevel verbLevel)
const
175 if (verbLevel != Teuchos::VERB_NONE) {
178 out <<
"number of Stages = " << this->
numStages() << std::endl;
179 out <<
"A = " << this->
A() << std::endl;
180 out <<
"b = " << this->
b() << std::endl;
181 out <<
"c = " << this->
c() << std::endl;
182 out <<
"bstar = " << this->
bstar() << std::endl;
183 out <<
"order = " << this->
order() << std::endl;
184 out <<
"orderMin = " << this->
orderMin() << std::endl;
185 out <<
"orderMax = " << this->
orderMax() << std::endl;
186 out <<
"isImplicit = " << this->
isImplicit() << std::endl;
187 out <<
"isDIRK = " << this->
isDIRK() << std::endl;
188 out <<
"isEmbedded = " << this->
isEmbedded() << std::endl;
197 void set_A(
const Teuchos::SerialDenseMatrix<int,Scalar>& A) {
A_ =
A; }
198 void set_b(
const Teuchos::SerialDenseVector<int,Scalar>& b) {
b_ =
b; }
199 void set_c(
const Teuchos::SerialDenseVector<int,Scalar>& c) {
c_ =
c; }
205 for (
size_t i = 0; i < this->
numStages(); i++)
206 for (
size_t j = i; j < this->
numStages(); j++)
212 bool nonZero =
false;
213 for (
size_t i = 0; i < this->
numStages(); i++) {
214 if (
A_(i,i) != 0.0) nonZero =
true;
215 for (
size_t j = i+1; j < this->
numStages(); j++)
218 if (nonZero ==
false)
isDIRK_ =
false;
222 Teuchos::SerialDenseMatrix<int,Scalar>
A_;
223 Teuchos::SerialDenseVector<int,Scalar>
b_;
224 Teuchos::SerialDenseVector<int,Scalar>
c_;
233 Teuchos::SerialDenseVector<int,Scalar>
bstar_;
241 template<
class Scalar>
248 template<
class Scalar>
250 const Teuchos::SerialDenseMatrix<int,Scalar>& A,
251 const Teuchos::SerialDenseVector<int,Scalar>& b,
252 const Teuchos::SerialDenseVector<int,Scalar>& c,
254 const std::string& description =
""
257 Teuchos::RCP<RKButcherTableau<Scalar> > rkbt =
259 rkbt->initialize(A,b,c,order,order,order,description);
265 template<
class Scalar>
267 const Teuchos::SerialDenseMatrix<int,Scalar>& A,
268 const Teuchos::SerialDenseVector<int,Scalar>& b,
269 const Teuchos::SerialDenseVector<int,Scalar>& c,
273 const std::string& description =
""
276 Teuchos::RCP<RKButcherTableau<Scalar> > rkbt =
278 rkbt->initialize(A,b,c,order,orderMin,orderMax,description);
282 template<
class Scalar>
291 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
296 TEUCHOS_TEST_FOR_EXCEPTION(
297 pl->get<std::string>(
"Stepper Type") != this->description()
300 " Stepper Type = " + pl->get<std::string>(
"Stepper Type"));
302 Teuchos::RCP<Teuchos::ParameterList> tableauPL = sublist(pl,
"Tableau",
true);
304 int order = tableauPL->get<
int>(
"order");
305 Teuchos::SerialDenseMatrix<int,Scalar>
A;
306 Teuchos::SerialDenseVector<int,Scalar>
b;
307 Teuchos::SerialDenseVector<int,Scalar>
c;
308 Teuchos::SerialDenseVector<int,Scalar>
bstar;
312 std::vector<std::string> A_row_tokens;
317 numStages = A_row_tokens.size();
320 A.shape(as<int>(numStages),as<int>(numStages));
323 for(std::size_t row=0;row<
numStages;row++) {
325 std::vector<std::string> tokens;
328 std::vector<double> values;
331 TEUCHOS_TEST_FOR_EXCEPTION(values.size()!=
numStages,std::runtime_error,
332 "Error parsing A matrix, wrong number of stages in row "
335 for(std::size_t col=0;col<
numStages;col++)
336 A(row,col) = values[col];
341 b.size(as<int>(numStages));
342 c.size(as<int>(numStages));
346 std::vector<std::string> tokens;
348 std::vector<double> values;
351 TEUCHOS_TEST_FOR_EXCEPTION(values.size()!=
numStages,std::runtime_error,
352 "Error parsing b vector, wrong number of stages.\n"
361 std::vector<std::string> tokens;
363 std::vector<double> values;
366 TEUCHOS_TEST_FOR_EXCEPTION(values.size()!=
numStages,std::runtime_error,
367 "Error parsing c vector, wrong number of stages.\n"
374 if (tableauPL->isParameter(
"bstar") and
375 tableauPL->get<std::string>(
"bstar") !=
"1.0") {
376 bstar.size(as<int>(numStages));
379 std::vector<std::string> tokens;
381 tokens, tableauPL->get<std::string>(
"bstar"),
" ",
true);
382 std::vector<double> values;
385 TEUCHOS_TEST_FOR_EXCEPTION(values.size()!=
numStages,std::runtime_error,
386 "Error parsing bstar vector, wrong number of stages.\n"
390 bstar(i) = values[i];
397 this->setMyParamList(pl);
431 template<
class Scalar>
438 std::stringstream Description;
440 <<
"The format of the Butcher Tableau parameter list is\n"
441 <<
" <Parameter name=\"A\" type=\"string\" value=\"# # # ;\n"
444 <<
" <Parameter name=\"b\" type=\"string\" value=\"# # #\"/>\n"
445 <<
" <Parameter name=\"c\" type=\"string\" value=\"# # #\"/>\n\n"
446 <<
"Note the number of stages is implicit in the number of entries.\n"
447 <<
"The number of stages must be consistent.\n"
449 <<
"Default tableau is RK4 (order=4):\n"
450 <<
"c = [ 0 1/2 1/2 1 ]'\n"
455 <<
"b = [ 1/6 1/3 1/3 1/6 ]'" << std::endl;
466 TEUCHOS_TEST_FOR_EXCEPTION(this->
isImplicit() ==
true, std::logic_error,
467 "Error - General ERK received an implicit Butcher Tableau!\n");
470 Teuchos::RCP<const Teuchos::ParameterList>
473 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
474 pl->setName(
"Default Stepper - " + this->
description());
476 pl->set<std::string>(
"Stepper Type", this->
description());
477 pl->set<
bool>(
"Use Embedded",
false);
478 pl->set<
bool>(
"Use FSAL",
false);
479 pl->set<std::string>(
"Initial Condition Consistency",
"Consistent");
480 pl->set<
bool>(
"Initial Condition Consistency Check",
true);
483 Teuchos::RCP<Teuchos::ParameterList> tableauPL = Teuchos::parameterList();
484 tableauPL->set<std::string>(
"A",
485 "0.0 0.0 0.0 0.0; 0.5 0.0 0.0 0.0; 0.0 0.5 0.0 0.0; 0.0 0.0 1.0 0.0");
486 tableauPL->set<std::string>(
"b",
487 "0.166666666666667 0.333333333333333 0.333333333333333 0.166666666666667");
489 tableauPL->set<std::string>(
"c",
"0.0 0.5 0.5 1.0");
490 tableauPL->set<
int>(
"order", 4);
491 pl->set(
"Tableau", *tableauPL);
512 template<
class Scalar>
519 std::ostringstream Description;
523 <<
"b = [ 1 ]'" << std::endl;
529 virtual std::string
description()
const {
return "RK Backward Euler"; }
533 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
538 TEUCHOS_TEST_FOR_EXCEPTION(
539 pl->get<std::string>(
"Stepper Type") != this->description()
542 " Stepper Type = " + pl->get<std::string>(
"Stepper Type"));
544 typedef Teuchos::ScalarTraits<Scalar> ST;
545 Teuchos::SerialDenseMatrix<int,Scalar>
A(1,1);
547 Teuchos::SerialDenseVector<int,Scalar>
b(1);
549 Teuchos::SerialDenseVector<int,Scalar>
c(1);
554 this->setMyParamList(pl);
558 Teuchos::RCP<const Teuchos::ParameterList>
561 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
562 pl->setName(
"Default Stepper - " + this->
description());
564 pl->set<std::string>(
"Stepper Type", this->
description());
565 pl->set<
bool>(
"Use Embedded",
false);
566 pl->set<
bool>(
"Use FSAL",
false);
567 pl->set<std::string>(
"Initial Condition Consistency",
"None");
568 pl->set<
bool>(
"Initial Condition Consistency Check",
false);
569 pl->set<std::string>(
"Solver Name",
"",
570 "Name of ParameterList containing the solver specifications.");
596 template<
class Scalar>
603 std::ostringstream Description;
607 <<
"b = [ 1 ]'" << std::endl;
608 typedef Teuchos::ScalarTraits<Scalar> ST;
609 Teuchos::SerialDenseMatrix<int,Scalar>
A(1,1);
610 Teuchos::SerialDenseVector<int,Scalar>
b(1);
612 Teuchos::SerialDenseVector<int,Scalar>
c(1);
615 this->
initialize(A,b,c,order,Description.str());
617 virtual std::string
description()
const {
return "RK Forward Euler"; }
638 template<
class Scalar>
645 std::ostringstream Description;
647 <<
"\"The\" Runge-Kutta Method (explicit):\n"
648 <<
"Solving Ordinary Differential Equations I:\n"
649 <<
"Nonstiff Problems, 2nd Revised Edition\n"
650 <<
"E. Hairer, S.P. Norsett, G. Wanner\n"
651 <<
"Table 1.2, pg 138\n"
652 <<
"c = [ 0 1/2 1/2 1 ]'\n"
657 <<
"b = [ 1/6 1/3 1/3 1/6 ]'" << std::endl;
658 typedef Teuchos::ScalarTraits<Scalar> ST;
659 const Scalar one = ST::one();
660 const Scalar zero = ST::zero();
661 const Scalar onehalf = one/(2*one);
662 const Scalar onesixth = one/(6*one);
663 const Scalar onethird = one/(3*one);
666 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
667 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
668 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
705 this->
initialize(A,b,c,order,Description.str());
707 virtual std::string
description()
const {
return "RK Explicit 4 Stage"; }
734 template<
class Scalar>
741 std::ostringstream Description;
743 <<
"P. Bogacki and L.F. Shampine.\n"
744 <<
"A 3(2) pair of Runge–Kutta formulas.\n"
745 <<
"Applied Mathematics Letters, 2(4):321 – 325, 1989.\n"
746 <<
"c = [ 0 1/3 2/3 1 ]'\n"
750 <<
" [ 2/9 1/3 4/9 0 ]\n"
751 <<
"b = [ 2/9 1/3 4/9 0 ]\n"
752 <<
"bstar = [ 7/24 1/4 1/3 1/8 ]\n" << std::endl;
753 typedef Teuchos::ScalarTraits<Scalar> ST;
756 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
757 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
758 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
759 Teuchos::SerialDenseVector<int,Scalar>
bstar(NumStages);
761 const Scalar one = ST::one();
762 const Scalar zero = ST::zero();
770 A(1,0) = as<Scalar>(one/(2*one));
776 A(2,1) = as<Scalar>(3*one/(4*one));
780 A(3,0) = as<Scalar>(2*one/(9*one));
781 A(3,1) = as<Scalar>(1*one/(3*one));
782 A(3,2) = as<Scalar>(4*one/(9*one));
793 c(1) = as<Scalar>(1*one/(3*one));
794 c(2) = as<Scalar>(2*one/(3*one));
798 bstar(0) = as<Scalar>(7.0*one/(24*one));
799 bstar(1) = as<Scalar>(1*one/(4*one));
800 bstar(2) = as<Scalar>(1*one/(3*one));
801 bstar(3) = as<Scalar>(1*one/(8*one));
806 virtual std::string
description()
const {
return "Bogacki-Shampine 3(2) Pair"; }
835 template<
class Scalar>
842 std::ostringstream Description;
844 <<
"Solving Ordinary Differential Equations I:\n"
845 <<
"Nonstiff Problems, 2nd Revised Edition\n"
846 <<
"E. Hairer, S.P. Norsett, G. Wanner\n"
847 <<
"Table 4.1, pg 167\n"
848 <<
"c = [ 0 1/3 1/3 1/2 1 ]'\n"
851 <<
" [ 1/6 1/6 0 ]\n"
852 <<
" [ 1/8 0 3/8 0 ]\n"
853 <<
" [ 1/2 0 -3/2 2 0 ]\n"
854 <<
"b = [ 1/6 0 0 2/3 1/6 ]\n"
855 <<
"bstar = [ 1/10 0 3/10 2/5 1/5 ]\n" << std::endl;
856 typedef Teuchos::ScalarTraits<Scalar> ST;
859 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages,
true);
860 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages,
true);
861 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages,
true);
862 Teuchos::SerialDenseVector<int,Scalar>
bstar(NumStages,
true);
864 const Scalar one = ST::one();
865 const Scalar zero = ST::zero();
868 A(1,0) = as<Scalar>(one/(3*one));;
870 A(2,0) = as<Scalar>(one/(6*one));;
871 A(2,1) = as<Scalar>(one/(6*one));;
873 A(3,0) = as<Scalar>(one/(8*one));;
874 A(3,2) = as<Scalar>(3*one/(8*one));;
876 A(4,0) = as<Scalar>(one/(2*one));;
877 A(4,2) = as<Scalar>(-3*one/(2*one));;
881 b(0) = as<Scalar>(one/(6*one));
882 b(3) = as<Scalar>(2*one/(3*one));
883 b(4) = as<Scalar>(one/(6*one));
887 c(1) = as<Scalar>(1*one/(3*one));
888 c(2) = as<Scalar>(1*one/(3*one));
889 c(3) = as<Scalar>(1*one/(2*one));
893 bstar(0) = as<Scalar>(1*one/(10*one));
894 bstar(2) = as<Scalar>(3*one/(10*one));
895 bstar(3) = as<Scalar>(2*one/(5*one));
896 bstar(4) = as<Scalar>(1*one/(5*one));
901 virtual std::string
description()
const {
return "Merson 4(5) Pair"; }
925 template<
class Scalar>
932 std::ostringstream Description;
934 <<
"Solving Ordinary Differential Equations I:\n"
935 <<
"Nonstiff Problems, 2nd Revised Edition\n"
936 <<
"E. Hairer, S.P. Norsett, G. Wanner\n"
937 <<
"Table 1.2, pg 138\n"
938 <<
"c = [ 0 1/3 2/3 1 ]'\n"
943 <<
"b = [ 1/8 3/8 3/8 1/8 ]'" << std::endl;
944 typedef Teuchos::ScalarTraits<Scalar> ST;
947 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
948 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
949 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
951 const Scalar one = ST::one();
952 const Scalar zero = ST::zero();
953 const Scalar one_third = as<Scalar>(one/(3*one));
954 const Scalar two_third = as<Scalar>(2*one/(3*one));
955 const Scalar one_eighth = as<Scalar>(one/(8*one));
956 const Scalar three_eighth = as<Scalar>(3*one/(8*one));
969 A(2,0) = as<Scalar>(-one_third);
975 A(3,1) = as<Scalar>(-one);
993 this->
initialize(A,b,c,order,Description.str());
995 virtual std::string
description()
const {
return "RK Explicit 3/8 Rule"; }
1020 template<
class Scalar>
1027 std::ostringstream Description;
1029 <<
"Solving Ordinary Differential Equations I:\n"
1030 <<
"Nonstiff Problems, 2nd Revised Edition\n"
1031 <<
"E. Hairer, S.P. Norsett, G. Wanner\n"
1032 <<
"Table 1.1, pg 135\n"
1033 <<
"c = [ 0 1/2 1 1 ]'\n"
1038 <<
"b = [ 1/6 2/3 0 1/6 ]'" << std::endl;
1039 typedef Teuchos::ScalarTraits<Scalar> ST;
1041 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
1042 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
1043 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
1045 const Scalar one = ST::one();
1046 const Scalar onehalf = one/(2*one);
1047 const Scalar onesixth = one/(6*one);
1048 const Scalar twothirds = 2*one/(3*one);
1049 const Scalar zero = ST::zero();
1086 this->
initialize(A,b,c,order,Description.str());
1089 {
return "RK Explicit 4 Stage 3rd order by Runge"; }
1113 template<
class Scalar>
1120 std::ostringstream Description;
1122 <<
"Kinnmark & Gray 5 stage, 3rd order scheme \n"
1123 <<
"Modified by P. Ullrich. From the prim_advance_mod.F90 \n"
1124 <<
"routine in the HOMME atmosphere model code.\n"
1125 <<
"c = [ 0 1/5 1/5 1/3 2/3 ]'\n"
1129 <<
" [ 0 0 1/3 0 ]\n"
1130 <<
" [ 0 0 0 2/3 0 ]\n"
1131 <<
"b = [ 1/4 0 0 0 3/4 ]'" << std::endl;
1132 typedef Teuchos::ScalarTraits<Scalar> ST;
1134 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
1135 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
1136 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
1138 const Scalar one = ST::one();
1139 const Scalar onefifth = one/(5*one);
1140 const Scalar onefourth = one/(4*one);
1141 const Scalar onethird = one/(3*one);
1142 const Scalar twothirds = 2*one/(3*one);
1143 const Scalar threefourths = 3*one/(4*one);
1144 const Scalar zero = ST::zero();
1182 b(4) = threefourths;
1193 this->
initialize(A,b,c,order,Description.str());
1196 {
return "RK Explicit 5 Stage 3rd order by Kinnmark and Gray"; }
1216 template<
class Scalar>
1223 std::ostringstream Description;
1225 <<
"c = [ 0 1/2 1 ]'\n"
1229 <<
"b = [ 1/6 4/6 1/6 ]'" << std::endl;
1230 typedef Teuchos::ScalarTraits<Scalar> ST;
1231 const Scalar one = ST::one();
1232 const Scalar two = Teuchos::as<Scalar>(2*one);
1233 const Scalar zero = ST::zero();
1234 const Scalar onehalf = one/(2*one);
1235 const Scalar onesixth = one/(6*one);
1236 const Scalar foursixth = 4*one/(6*one);
1239 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
1240 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
1241 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
1268 this->
initialize(A,b,c,order,Description.str());
1271 {
return "RK Explicit 3 Stage 3rd order"; }
1302 template<
class Scalar>
1309 std::ostringstream Description;
1311 <<
"Sigal Gottlieb and Chi-Wang Shu\n"
1312 <<
"`Total Variation Diminishing Runge-Kutta Schemes'\n"
1313 <<
"Mathematics of Computation\n"
1314 <<
"Volume 67, Number 221, January 1998, pp. 73-85\n"
1315 <<
"c = [ 0 1 1/2 ]'\n"
1318 <<
" [ 1/4 1/4 0 ]\n"
1319 <<
"b = [ 1/6 1/6 4/6 ]'\n"
1320 <<
"This is also written in the following set of updates.\n"
1321 <<
"u1 = u^n + dt L(u^n)\n"
1322 <<
"u2 = 3 u^n/4 + u1/4 + dt L(u1)/4\n"
1323 <<
"u^(n+1) = u^n/3 + 2 u2/2 + 2 dt L(u2)/3"
1325 typedef Teuchos::ScalarTraits<Scalar> ST;
1326 const Scalar one = ST::one();
1327 const Scalar zero = ST::zero();
1328 const Scalar onehalf = one/(2*one);
1329 const Scalar onefourth = one/(4*one);
1330 const Scalar onesixth = one/(6*one);
1331 const Scalar foursixth = 4*one/(6*one);
1334 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
1335 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
1336 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
1363 this->
initialize(A,b,c,order,Description.str());
1366 {
return "RK Explicit 3 Stage 3rd order TVD"; }
1390 template<
class Scalar>
1397 std::ostringstream Description;
1399 <<
"Solving Ordinary Differential Equations I:\n"
1400 <<
"Nonstiff Problems, 2nd Revised Edition\n"
1401 <<
"E. Hairer, S.P. Norsett, G. Wanner\n"
1402 <<
"Table 1.1, pg 135\n"
1403 <<
"c = [ 0 1/3 2/3 ]'\n"
1407 <<
"b = [ 1/4 0 3/4 ]'" << std::endl;
1408 typedef Teuchos::ScalarTraits<Scalar> ST;
1409 const Scalar one = ST::one();
1410 const Scalar zero = ST::zero();
1411 const Scalar onethird = one/(3*one);
1412 const Scalar twothirds = 2*one/(3*one);
1413 const Scalar onefourth = one/(4*one);
1414 const Scalar threefourths = 3*one/(4*one);
1417 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
1418 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
1419 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
1437 b(2) = threefourths;
1446 this->
initialize(A,b,c,order,Description.str());
1449 {
return "RK Explicit 3 Stage 3rd order by Heun"; }
1472 template<
class Scalar>
1479 std::ostringstream Description;
1481 <<
"Also known as Explicit Midpoint\n"
1482 <<
"Solving Ordinary Differential Equations I:\n"
1483 <<
"Nonstiff Problems, 2nd Revised Edition\n"
1484 <<
"E. Hairer, S.P. Norsett, G. Wanner\n"
1485 <<
"Table 1.1, pg 135\n"
1486 <<
"c = [ 0 1/2 ]'\n"
1489 <<
"b = [ 0 1 ]'" << std::endl;
1490 typedef Teuchos::ScalarTraits<Scalar> ST;
1491 const Scalar one = ST::one();
1492 const Scalar zero = ST::zero();
1493 const Scalar onehalf = one/(2*one);
1496 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
1497 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
1498 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
1517 this->
initialize(A,b,c,order,Description.str());
1520 {
return "RK Explicit 2 Stage 2nd order by Runge"; }
1539 template<
class Scalar>
1546 std::ostringstream Description;
1551 <<
"b = [ 1/2 1/2 ]'" << std::endl;
1552 typedef Teuchos::ScalarTraits<Scalar> ST;
1553 const Scalar one = ST::one();
1554 const Scalar zero = ST::zero();
1555 const Scalar onehalf = one/(2*one);
1558 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
1559 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
1560 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
1579 this->
initialize(A,b,c,order,Description.str());
1581 virtual std::string
description()
const {
return "RK Explicit Trapezoidal"; }
1616 template<
class Scalar>
1623 std::stringstream Description;
1625 <<
"The format of the Butcher Tableau parameter list is\n"
1626 <<
" <Parameter name=\"A\" type=\"string\" value=\"# # # ;\n"
1629 <<
" <Parameter name=\"b\" type=\"string\" value=\"# # #\"/>\n"
1630 <<
" <Parameter name=\"c\" type=\"string\" value=\"# # #\"/>\n\n"
1631 <<
"Note the number of stages is implicit in the number of entries.\n"
1632 <<
"The number of stages must be consistent.\n"
1634 <<
"Default tableau is 'SDIRK 2 Stage 2nd order':\n"
1635 <<
" Computer Methods for ODEs and DAEs\n"
1636 <<
" U. M. Ascher and L. R. Petzold\n"
1638 <<
" gamma = (2+-sqrt(2))/2\n"
1639 <<
" c = [ gamma 1 ]'\n"
1640 <<
" A = [ gamma 0 ]\n"
1641 <<
" [ 1-gamma gamma ]\n"
1642 <<
" b = [ 1-gamma gamma ]'" << std::endl;
1653 TEUCHOS_TEST_FOR_EXCEPTION(this->
isImplicit() !=
true, std::logic_error,
1654 "Error - General DIRK did not receive a DIRK Butcher Tableau!\n");
1657 Teuchos::RCP<const Teuchos::ParameterList>
1660 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
1661 pl->setName(
"Default Stepper - " + this->
description());
1663 pl->set<std::string>(
"Stepper Type", this->
description());
1664 pl->set<
bool>(
"Use Embedded",
false);
1665 pl->set<
bool>(
"Use FSAL",
false);
1666 pl->set<std::string>(
"Initial Condition Consistency",
"None");
1667 pl->set<
bool>(
"Initial Condition Consistency Check",
false);
1670 typedef Teuchos::ScalarTraits<Scalar> ST;
1671 const Scalar one = ST::one();
1672 std::string gamma = std::to_string(Teuchos::as<Scalar>((2*one-ST::squareroot(2*one))/(2*one)));
1673 std::string one_gamma = std::to_string(Teuchos::as<Scalar>(one-(2*one-ST::squareroot(2*one))/(2*one)));
1674 Teuchos::RCP<Teuchos::ParameterList> tableauPL = Teuchos::parameterList();
1675 tableauPL->set<std::string>(
"A", gamma +
" 0.0; " + one_gamma +
" "+gamma);
1676 tableauPL->set<std::string>(
"b", one_gamma +
" " + gamma);
1677 tableauPL->set<std::string>(
"c", gamma +
" 1.0");
1678 tableauPL->set<
int>(
"order", 2);
1679 pl->set(
"Tableau", *tableauPL);
1700 template<
class Scalar>
1707 std::stringstream Description;
1711 <<
"b = [ 1 ]'" << std::endl;
1717 virtual std::string
description()
const {
return "SDIRK 1 Stage 1st order"; }
1721 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
1726 TEUCHOS_TEST_FOR_EXCEPTION(
1727 pl->get<std::string>(
"Stepper Type") != this->description()
1728 ,std::runtime_error,
1730 " Stepper Type = " + pl->get<std::string>(
"Stepper Type"));
1732 typedef Teuchos::ScalarTraits<Scalar> ST;
1733 Teuchos::SerialDenseMatrix<int,Scalar>
A(1,1);
1735 Teuchos::SerialDenseVector<int,Scalar>
b(1);
1737 Teuchos::SerialDenseVector<int,Scalar>
c(1);
1742 this->setMyParamList(pl);
1746 Teuchos::RCP<const Teuchos::ParameterList>
1749 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
1750 pl->setName(
"Default Stepper - " + this->
description());
1752 pl->set<std::string>(
"Stepper Type", this->
description());
1753 pl->set<
bool>(
"Use Embedded",
false);
1754 pl->set<
bool>(
"Use FSAL",
false);
1755 pl->set<std::string>(
"Initial Condition Consistency",
"None");
1756 pl->set<
bool>(
"Initial Condition Consistency Check",
false);
1757 pl->set<std::string>(
"Solver Name",
"",
1758 "Name of ParameterList containing the solver specifications.");
1788 template<
class Scalar>
1795 std::ostringstream Description;
1797 <<
"Computer Methods for ODEs and DAEs\n"
1798 <<
"U. M. Ascher and L. R. Petzold\n"
1800 <<
"gamma = (2+-sqrt(2))/2\n"
1801 <<
"c = [ gamma 1 ]'\n"
1802 <<
"A = [ gamma 0 ]\n"
1803 <<
" [ 1-gamma gamma ]\n"
1804 <<
"b = [ 1-gamma gamma ]'" << std::endl;
1806 typedef Teuchos::ScalarTraits<Scalar> ST;
1807 const Scalar one = ST::one();
1808 gamma_default_ = Teuchos::as<Scalar>((2*one-ST::squareroot(2*one))/(2*one));
1815 virtual std::string
description()
const {
return "SDIRK 2 Stage 2nd order"; }
1819 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
1824 TEUCHOS_TEST_FOR_EXCEPTION(
1825 pl->get<std::string>(
"Stepper Type") != this->description()
1826 ,std::runtime_error,
1828 " Stepper Type = " + pl->get<std::string>(
"Stepper Type"));
1832 typedef Teuchos::ScalarTraits<Scalar> ST;
1834 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
1835 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
1836 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
1837 const Scalar one = ST::one();
1838 const Scalar zero = ST::zero();
1841 A(1,0) = Teuchos::as<Scalar>( one -
gamma_ );
1843 b(0) = Teuchos::as<Scalar>( one -
gamma_ );
1852 this->setMyParamList(pl);
1856 Teuchos::RCP<const Teuchos::ParameterList>
1859 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
1860 pl->setName(
"Default Stepper - " + this->
description());
1862 pl->set<std::string>(
"Stepper Type", this->
description());
1863 pl->set<
bool>(
"Use Embedded",
false);
1864 pl->set<
bool>(
"Use FSAL",
false);
1865 pl->set<std::string>(
"Initial Condition Consistency",
"None");
1866 pl->set<
bool>(
"Initial Condition Consistency Check",
false);
1867 pl->set(
"Solver Name",
"",
1868 "Name of ParameterList containing the solver specifications.");
1870 "The default value is gamma = (2-sqrt(2))/2. "
1871 "This will produce an L-stable 2nd order method with the stage "
1872 "times within the timestep. Other values of gamma will still "
1873 "produce an L-stable scheme, but will only be 1st order accurate.");
1911 template<
class Scalar>
1918 std::ostringstream Description;
1920 <<
"Solving Ordinary Differential Equations I:\n"
1921 <<
"Nonstiff Problems, 2nd Revised Edition\n"
1922 <<
"E. Hairer, S. P. Norsett, and G. Wanner\n"
1923 <<
"Table 7.2, pg 207\n"
1924 <<
"gamma = (3+-sqrt(3))/6 -> 3rd order and A-stable\n"
1925 <<
"gamma = (2+-sqrt(2))/2 -> 2nd order and L-stable\n"
1926 <<
"c = [ gamma 1-gamma ]'\n"
1927 <<
"A = [ gamma 0 ]\n"
1928 <<
" [ 1-2*gamma gamma ]\n"
1929 <<
"b = [ 1/2 1/2 ]'" << std::endl;
1935 typedef Teuchos::ScalarTraits<Scalar> ST;
1936 const Scalar one = ST::one();
1938 Teuchos::as<Scalar>( (3*one + ST::squareroot(3*one))/(6*one) );
1947 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
1952 TEUCHOS_TEST_FOR_EXCEPTION(
1953 pl->get<std::string>(
"Stepper Type") != this->description()
1954 ,std::runtime_error,
1956 " Stepper Type = " + pl->get<std::string>(
"Stepper Type"));
1960 TEUCHOS_TEST_FOR_EXCEPTION(
1962 "'3rd Order A-stable' and '2nd Order L-stable' can not both be true.");
1965 typedef Teuchos::ScalarTraits<Scalar> ST;
1968 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
1969 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
1970 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
1971 const Scalar one = ST::one();
1972 const Scalar zero = ST::zero();
1973 const Scalar gammaLStable =
1974 as<Scalar>( (2*one + ST::squareroot(2*one))/(2*one) );
1977 else if (secondOrderLStable_)
1981 A(1,0) = as<Scalar>( one - 2*
gamma_ );
1983 b(0) = as<Scalar>( one/(2*one) );
1984 b(1) = as<Scalar>( one/(2*one) );
1986 c(1) = as<Scalar>( one -
gamma_ );
1992 secondOrderLStable_ =
false;
1993 }
else if ( std::abs((
gamma_-gammaLStable)/
gamma_) < 1.0e-08 ) {
1995 secondOrderLStable_ =
true;
1998 secondOrderLStable_ =
false;
2002 this->setMyParamList(pl);
2006 Teuchos::RCP<const Teuchos::ParameterList>
2009 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
2010 pl->setName(
"Default Stepper - " + this->
description());
2012 pl->set<std::string>(
"Stepper Type", this->
description());
2013 pl->set<
bool>(
"Use Embedded",
false);
2014 pl->set<
bool>(
"Use FSAL",
false);
2015 pl->set<std::string>(
"Initial Condition Consistency",
"None");
2016 pl->set<
bool>(
"Initial Condition Consistency Check",
false);
2017 pl->set(
"Solver Name",
"",
2018 "Name of ParameterList containing the solver specifications.");
2020 "If true, set gamma to gamma = (3+sqrt(3))/6 to obtain "
2021 "a 3rd order A-stable scheme. '3rd Order A-stable' and "
2022 "'2nd Order L-stable' can not both be true.");
2024 "If true, set gamma to gamma = (2+sqrt(2))/2 to obtain "
2025 "a 2nd order L-stable scheme. '3rd Order A-stable' and "
2026 "'2nd Order L-stable' can not both be true.");
2028 "If both '3rd Order A-stable' and '2nd Order L-stable' "
2029 "are false, gamma will be used. The default value is the "
2030 "'3rd Order A-stable' gamma value, (3+sqrt(3))/6.");
2035 virtual std::string
description()
const {
return "SDIRK 2 Stage 3rd order"; }
2066 template<
class Scalar>
2073 std::ostringstream Description;
2075 <<
"Hammer & Hollingsworth method\n"
2076 <<
"Solving Ordinary Differential Equations I:\n"
2077 <<
"Nonstiff Problems, 2nd Revised Edition\n"
2078 <<
"E. Hairer, S. P. Norsett, and G. Wanner\n"
2079 <<
"Table 7.1, pg 205\n"
2080 <<
"c = [ 0 2/3 ]'\n"
2083 <<
"b = [ 1/4 3/4 ]'" << std::endl;
2089 virtual std::string
description()
const {
return "EDIRK 2 Stage 3rd order"; }
2093 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
2098 TEUCHOS_TEST_FOR_EXCEPTION(
2099 pl->get<std::string>(
"Stepper Type") != this->description()
2100 ,std::runtime_error,
2102 " Stepper Type = " + pl->get<std::string>(
"Stepper Type"));
2105 typedef Teuchos::ScalarTraits<Scalar> ST;
2108 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
2109 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
2110 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
2111 const Scalar one = ST::one();
2112 const Scalar zero = ST::zero();
2115 A(1,0) = as<Scalar>( one/(3*one) );
2116 A(1,1) = as<Scalar>( one/(3*one) );
2117 b(0) = as<Scalar>( one/(4*one) );
2118 b(1) = as<Scalar>( 3*one/(4*one) );
2120 c(1) = as<Scalar>( 2*one/(3*one) );
2124 this->setMyParamList(pl);
2128 Teuchos::RCP<const Teuchos::ParameterList>
2131 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
2132 pl->setName(
"Default Stepper - " + this->
description());
2134 pl->set<std::string>(
"Stepper Type", this->
description());
2135 pl->set<
bool>(
"Use Embedded",
false);
2136 pl->set<
bool>(
"Use FSAL",
false);
2137 pl->set<std::string>(
"Initial Condition Consistency",
"None");
2138 pl->set<
bool>(
"Initial Condition Consistency Check",
false);
2139 pl->set(
"Solver Name",
"",
2140 "Name of ParameterList containing the solver specifications.");
2149 template<
class Scalar>
2156 std::ostringstream Description;
2158 <<
"Kuntzmann & Butcher method\n"
2159 <<
"Solving Ordinary Differential Equations I:\n"
2160 <<
"Nonstiff Problems, 2nd Revised Edition\n"
2161 <<
"E. Hairer, S. P. Norsett, and G. Wanner\n"
2162 <<
"Table 7.4, pg 209\n"
2163 <<
"c = [ 1/2-sqrt(15)/10 1/2 1/2+sqrt(15)/10 ]'\n"
2164 <<
"A = [ 5/36 2/9-sqrt(15)/15 5/36-sqrt(15)/30 ]\n"
2165 <<
" [ 5/36+sqrt(15)/24 2/9 5/36-sqrt(15)/24 ]\n"
2166 <<
" [ 5/36+sqrt(15)/30 2/9+sqrt(15)/15 5/36 ]\n"
2167 <<
"b = [ 5/18 4/9 5/18 ]'"
2169 typedef Teuchos::ScalarTraits<Scalar> ST;
2172 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
2173 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
2174 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
2175 const Scalar one = ST::one();
2176 A(0,0) = as<Scalar>( 5*one/(36*one) );
2177 A(0,1) = as<Scalar>( 2*one/(9*one) - ST::squareroot(15*one)/(15*one) );
2178 A(0,2) = as<Scalar>( 5*one/(36*one) - ST::squareroot(15*one)/(30*one) );
2179 A(1,0) = as<Scalar>( 5*one/(36*one) + ST::squareroot(15*one)/(24*one) );
2180 A(1,1) = as<Scalar>( 2*one/(9*one) );
2181 A(1,2) = as<Scalar>( 5*one/(36*one) - ST::squareroot(15*one)/(24*one) );
2182 A(2,0) = as<Scalar>( 5*one/(36*one) + ST::squareroot(15*one)/(30*one) );
2183 A(2,1) = as<Scalar>( 2*one/(9*one) + ST::squareroot(15*one)/(15*one) );
2184 A(2,2) = as<Scalar>( 5*one/(36*one) );
2185 b(0) = as<Scalar>( 5*one/(18*one) );
2186 b(1) = as<Scalar>( 4*one/(9*one) );
2187 b(2) = as<Scalar>( 5*one/(18*one) );
2188 c(0) = as<Scalar>( one/(2*one)-ST::squareroot(15*one)/(10*one) );
2189 c(1) = as<Scalar>( one/(2*one) );
2190 c(2) = as<Scalar>( one/(2*one)+ST::squareroot(15*one)/(10*one) );
2193 this->
initialize(A,b,c,order,Description.str());
2196 {
return "RK Implicit 3 Stage 6th Order Kuntzmann & Butcher"; }
2201 template<
class Scalar>
2208 std::ostringstream Description;
2210 <<
"Kuntzmann & Butcher method\n"
2211 <<
"Solving Ordinary Differential Equations I:\n"
2212 <<
"Nonstiff Problems, 2nd Revised Edition\n"
2213 <<
"E. Hairer, S. P. Norsett, and G. Wanner\n"
2214 <<
"Table 7.5, pg 209\n"
2215 <<
"c = [ 1/2-w2 1/2-w2p 1/2+w2p 1/2+w2 ]'\n"
2216 <<
"A = [ w1 w1p-w3+w4p w1p-w3-w4p w1-w5 ]\n"
2217 <<
" [ w1-w3p+w4 w1p w1p-w5p w1-w3p-w4 ]\n"
2218 <<
" [ w1+w3p+w4 w1p+w5p w1p w1+w3p-w4 ]\n"
2219 <<
" [ w1+w5 w1p+w3+w4p w1p+w3-w4p w1 ]\n"
2220 <<
"b = [ 2*w1 2*w1p 2*w1p 2*w1 ]'\n"
2221 <<
"w1 = 1/8-sqrt(30)/144\n"
2222 <<
"w2 = (1/2)*sqrt((15+2*sqrt(3))/35)\n"
2223 <<
"w3 = w2*(1/6+sqrt(30)/24)\n"
2224 <<
"w4 = w2*(1/21+5*sqrt(30)/168)\n"
2226 <<
"w1p = 1/8+sqrt(30)/144\n"
2227 <<
"w2p = (1/2)*sqrt((15-2*sqrt(3))/35)\n"
2228 <<
"w3p = w2*(1/6-sqrt(30)/24)\n"
2229 <<
"w4p = w2*(1/21-5*sqrt(30)/168)\n"
2230 <<
"w5p = w2p-2*w3p" << std::endl;
2231 typedef Teuchos::ScalarTraits<Scalar> ST;
2234 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
2235 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
2236 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
2237 const Scalar one = ST::one();
2238 const Scalar onehalf = as<Scalar>( one/(2*one) );
2239 const Scalar w1 = as<Scalar>( one/(8*one) - ST::squareroot(30*one)/(144*one) );
2240 const Scalar w2 = as<Scalar>( (one/(2*one))*ST::squareroot((15*one+2*one*ST::squareroot(30*one))/(35*one)) );
2241 const Scalar w3 = as<Scalar>( w2*(one/(6*one)+ST::squareroot(30*one)/(24*one)) );
2242 const Scalar w4 = as<Scalar>( w2*(one/(21*one)+5*one*ST::squareroot(30*one)/(168*one)) );
2243 const Scalar w5 = as<Scalar>( w2-2*w3 );
2244 const Scalar w1p = as<Scalar>( one/(8*one) + ST::squareroot(30*one)/(144*one) );
2245 const Scalar w2p = as<Scalar>( (one/(2*one))*ST::squareroot((15*one-2*one*ST::squareroot(30*one))/(35*one)) );
2246 const Scalar w3p = as<Scalar>( w2p*(one/(6*one)-ST::squareroot(30*one)/(24*one)) );
2247 const Scalar w4p = as<Scalar>( w2p*(one/(21*one)-5*one*ST::squareroot(30*one)/(168*one)) );
2248 const Scalar w5p = as<Scalar>( w2p-2*w3p );
2250 A(0,1) = w1p-w3+w4p;
2251 A(0,2) = w1p-w3-w4p;
2262 A(3,1) = w1p+w3+w4p;
2263 A(3,2) = w1p+w3-w4p;
2269 c(0) = onehalf - w2;
2270 c(1) = onehalf - w2p;
2271 c(2) = onehalf + w2p;
2272 c(3) = onehalf + w2;
2275 this->
initialize(A,b,c,order,Description.str());
2278 {
return "RK Implicit 4 Stage 8th Order Kuntzmann & Butcher"; }
2283 template<
class Scalar>
2290 std::ostringstream Description;
2292 <<
"Hammer & Hollingsworth method\n"
2293 <<
"Solving Ordinary Differential Equations I:\n"
2294 <<
"Nonstiff Problems, 2nd Revised Edition\n"
2295 <<
"E. Hairer, S. P. Norsett, and G. Wanner\n"
2296 <<
"Table 7.3, pg 207\n"
2297 <<
"c = [ 1/2-sqrt(3)/6 1/2+sqrt(3)/6 ]'\n"
2298 <<
"A = [ 1/4 1/4-sqrt(3)/6 ]\n"
2299 <<
" [ 1/4+sqrt(3)/6 1/4 ]\n"
2300 <<
"b = [ 1/2 1/2 ]'" << std::endl;
2301 typedef Teuchos::ScalarTraits<Scalar> ST;
2304 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
2305 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
2306 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
2307 const Scalar one = ST::one();
2308 const Scalar onequarter = as<Scalar>( one/(4*one) );
2309 const Scalar onehalf = as<Scalar>( one/(2*one) );
2310 A(0,0) = onequarter;
2311 A(0,1) = as<Scalar>( onequarter-ST::squareroot(3*one)/(6*one) );
2312 A(1,0) = as<Scalar>( onequarter+ST::squareroot(3*one)/(6*one) );
2313 A(1,1) = onequarter;
2316 c(0) = as<Scalar>( onehalf - ST::squareroot(3*one)/(6*one) );
2317 c(1) = as<Scalar>( onehalf + ST::squareroot(3*one)/(6*one) );
2320 this->
initialize(A,b,c,order,Description.str());
2323 {
return "RK Implicit 2 Stage 4th Order Hammer & Hollingsworth"; }
2328 template<
class Scalar>
2335 std::ostringstream Description;
2337 <<
"Non-standard finite-difference methods\n"
2338 <<
"in dynamical systems, P. Kama,\n"
2339 <<
"Dissertation, University of Pretoria, pg. 49.\n"
2340 <<
"Comment: Generalized Implicit Midpoint Method\n"
2341 <<
"c = [ theta ]'\n"
2342 <<
"A = [ theta ]\n"
2346 typedef Teuchos::ScalarTraits<Scalar> ST;
2356 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
2361 TEUCHOS_TEST_FOR_EXCEPTION(
2362 pl->get<std::string>(
"Stepper Type") != this->description() and
2363 pl->get<std::string>(
"Stepper Type") !=
"Implicit Midpoint"
2364 ,std::runtime_error,
2366 " Stepper Type = " + pl->get<std::string>(
"Stepper Type"));
2369 typedef Teuchos::ScalarTraits<Scalar> ST;
2371 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
2372 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
2373 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
2382 this->setMyParamList(pl);
2386 virtual std::string
description()
const {
return "IRK 1 Stage Theta Method"; }
2388 Teuchos::RCP<const Teuchos::ParameterList>
2391 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
2392 pl->setName(
"Default Stepper - " + this->
description());
2394 pl->set<std::string>(
"Stepper Type", this->
description());
2395 pl->set<
bool>(
"Use Embedded",
false);
2396 pl->set<
bool>(
"Use FSAL",
false);
2397 pl->set<std::string>(
"Initial Condition Consistency",
"None");
2398 pl->set<
bool>(
"Initial Condition Consistency Check",
false);
2399 pl->set<std::string>(
"Solver Name",
"",
2400 "Name of ParameterList containing the solver specifications.");
2402 "Valid values are 0 <= theta <= 1, where theta = 0 "
2403 "implies Forward Euler, theta = 1/2 implies implicit midpoint "
2404 "method (default), and theta = 1 implies Backward Euler. "
2405 "For theta != 1/2, this method is first-order accurate, "
2406 "and with theta = 1/2, it is second-order accurate. "
2407 "This method is A-stable, but becomes L-stable with theta=1.");
2419 template<
class Scalar>
2426 std::ostringstream Description;
2428 <<
"Computer Methods for ODEs and DAEs\n"
2429 <<
"U. M. Ascher and L. R. Petzold\n"
2433 <<
" [ 1-theta theta ]\n"
2434 <<
"b = [ 1-theta theta ]'\n"
2437 typedef Teuchos::ScalarTraits<Scalar> ST;
2447 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
2452 TEUCHOS_TEST_FOR_EXCEPTION(
2453 pl->get<std::string>(
"Stepper Type") != this->description()
2454 ,std::runtime_error,
2456 " Stepper Type = " + pl->get<std::string>(
"Stepper Type"));
2459 typedef Teuchos::ScalarTraits<Scalar> ST;
2460 const Scalar one = ST::one();
2461 const Scalar zero = ST::zero();
2462 TEUCHOS_TEST_FOR_EXCEPTION(
2463 theta_ == zero, std::logic_error,
2464 "'theta' can not be zero, as it makes this IRK stepper explicit.");
2467 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
2468 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
2469 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
2472 A(1,0) = Teuchos::as<Scalar>( one -
theta_ );
2474 b(0) = Teuchos::as<Scalar>( one -
theta_ );
2483 this->setMyParamList(pl);
2487 Teuchos::RCP<const Teuchos::ParameterList>
2490 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
2491 pl->setName(
"Default Stepper - " + this->
description());
2493 pl->set<std::string>(
"Stepper Type", this->
description());
2494 pl->set<
bool>(
"Use Embedded",
false);
2495 pl->set<
bool>(
"Use FSAL",
false);
2496 pl->set<std::string>(
"Initial Condition Consistency",
"None");
2497 pl->set<
bool>(
"Initial Condition Consistency Check",
false);
2498 pl->set<std::string>(
"Solver Name",
"",
2499 "Name of ParameterList containing the solver specifications.");
2501 "Valid values are 0 < theta <= 1, where theta = 0 "
2502 "implies Forward Euler, theta = 1/2 implies trapezoidal "
2503 "method (default), and theta = 1 implies Backward Euler. "
2504 "For theta != 1/2, this method is first-order accurate, "
2505 "and with theta = 1/2, it is second-order accurate. "
2506 "This method is A-stable, but becomes L-stable with theta=1.");
2511 virtual std::string
description()
const {
return "EDIRK 2 Stage Theta Method";}
2520 template<
class Scalar>
2527 std::ostringstream Description;
2530 <<
"Solving Ordinary Differential Equations II:\n"
2531 <<
"Stiff and Differential-Algebraic Problems,\n"
2532 <<
"2nd Revised Edition\n"
2533 <<
"E. Hairer and G. Wanner\n"
2534 <<
"Table 5.2, pg 72\n"
2535 <<
"Also: Implicit midpoint rule\n"
2536 <<
"Solving Ordinary Differential Equations I:\n"
2537 <<
"Nonstiff Problems, 2nd Revised Edition\n"
2538 <<
"E. Hairer, S. P. Norsett, and G. Wanner\n"
2539 <<
"Table 7.1, pg 205\n"
2542 <<
"b = [ 1 ]'" << std::endl;
2543 typedef Teuchos::ScalarTraits<Scalar> ST;
2545 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
2546 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
2547 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
2548 const Scalar onehalf = ST::one()/(2*ST::one());
2549 const Scalar one = ST::one();
2555 this->
initialize(A,b,c,order,Description.str());
2558 {
return "RK Implicit 1 Stage 2nd order Gauss"; }
2563 template<
class Scalar>
2570 std::ostringstream Description;
2573 <<
"Solving Ordinary Differential Equations II:\n"
2574 <<
"Stiff and Differential-Algebraic Problems,\n"
2575 <<
"2nd Revised Edition\n"
2576 <<
"E. Hairer and G. Wanner\n"
2577 <<
"Table 5.2, pg 72\n"
2578 <<
"c = [ 1/2-sqrt(3)/6 1/2+sqrt(3)/6 ]'\n"
2579 <<
"A = [ 1/4 1/4-sqrt(3)/6 ]\n"
2580 <<
" [ 1/4+sqrt(3)/6 1/4 ]\n"
2581 <<
"b = [ 1/2 1/2 ]'" << std::endl;
2582 typedef Teuchos::ScalarTraits<Scalar> ST;
2585 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
2586 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
2587 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
2588 const Scalar one = ST::one();
2589 const Scalar onehalf = as<Scalar>(one/(2*one));
2590 const Scalar three = as<Scalar>(3*one);
2591 const Scalar six = as<Scalar>(6*one);
2592 const Scalar onefourth = as<Scalar>(one/(4*one));
2593 const Scalar alpha = ST::squareroot(three)/six;
2596 A(0,1) = onefourth-alpha;
2597 A(1,0) = onefourth+alpha;
2601 c(0) = onehalf-alpha;
2602 c(1) = onehalf+alpha;
2605 this->
initialize(A,b,c,order,Description.str());
2608 {
return "RK Implicit 2 Stage 4th order Gauss"; }
2613 template<
class Scalar>
2620 std::ostringstream Description;
2623 <<
"Solving Ordinary Differential Equations II:\n"
2624 <<
"Stiff and Differential-Algebraic Problems,\n"
2625 <<
"2nd Revised Edition\n"
2626 <<
"E. Hairer and G. Wanner\n"
2627 <<
"Table 5.2, pg 72\n"
2628 <<
"c = [ 1/2-sqrt(15)/10 1/2 1/2+sqrt(15)/10 ]'\n"
2629 <<
"A = [ 5/36 2/9-sqrt(15)/15 5/36-sqrt(15)/30 ]\n"
2630 <<
" [ 5/36+sqrt(15)/24 2/9 5/36-sqrt(15)/24 ]\n"
2631 <<
" [ 5/36+sqrt(15)/30 2/9+sqrt(15)/15 5/36 ]\n"
2632 <<
"b = [ 5/18 4/9 5/18 ]'"
2634 typedef Teuchos::ScalarTraits<Scalar> ST;
2637 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
2638 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
2639 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
2640 const Scalar one = ST::one();
2641 const Scalar ten = as<Scalar>(10*one);
2642 const Scalar fifteen = as<Scalar>(15*one);
2643 const Scalar twentyfour = as<Scalar>(24*one);
2644 const Scalar thirty = as<Scalar>(30*one);
2645 const Scalar sqrt15over10 = as<Scalar>(ST::squareroot(fifteen)/ten);
2646 const Scalar sqrt15over15 = as<Scalar>(ST::squareroot(fifteen)/fifteen);
2647 const Scalar sqrt15over24 = as<Scalar>(ST::squareroot(fifteen)/twentyfour);
2648 const Scalar sqrt15over30 = as<Scalar>(ST::squareroot(fifteen)/thirty);
2650 A(0,0) = as<Scalar>(5*one/(36*one));
2651 A(0,1) = as<Scalar>(2*one/(9*one))-sqrt15over15;
2652 A(0,2) = as<Scalar>(5*one/(36*one))-sqrt15over30;
2653 A(1,0) = as<Scalar>(5*one/(36*one))+sqrt15over24;
2654 A(1,1) = as<Scalar>(2*one/(9*one));
2655 A(1,2) = as<Scalar>(5*one/(36*one))-sqrt15over24;
2656 A(2,0) = as<Scalar>(5*one/(36*one))+sqrt15over30;
2657 A(2,1) = as<Scalar>(2*one/(9*one))+sqrt15over15;
2658 A(2,2) = as<Scalar>(5*one/(36*one));
2659 b(0) = as<Scalar>(5*one/(18*one));
2660 b(1) = as<Scalar>(4*one/(9*one));
2661 b(2) = as<Scalar>(5*one/(18*one));
2662 c(0) = as<Scalar>(one/(2*one))-sqrt15over10;
2663 c(1) = as<Scalar>(one/(2*one));
2664 c(2) = as<Scalar>(one/(2*one))+sqrt15over10;
2667 this->
initialize(A,b,c,order,Description.str());
2670 {
return "RK Implicit 3 Stage 6th order Gauss"; }
2675 template<
class Scalar>
2682 std::ostringstream Description;
2685 <<
"Solving Ordinary Differential Equations II:\n"
2686 <<
"Stiff and Differential-Algebraic Problems,\n"
2687 <<
"2nd Revised Edition\n"
2688 <<
"E. Hairer and G. Wanner\n"
2689 <<
"Table 5.3, pg 73\n"
2692 <<
"b = [ 1 ]'" << std::endl;
2693 typedef Teuchos::ScalarTraits<Scalar> ST;
2695 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
2696 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
2697 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
2698 const Scalar one = ST::one();
2699 const Scalar zero = ST::zero();
2705 this->
initialize(A,b,c,order,Description.str());
2708 {
return "RK Implicit 1 Stage 1st order Radau left"; }
2713 template<
class Scalar>
2720 std::ostringstream Description;
2723 <<
"Solving Ordinary Differential Equations II:\n"
2724 <<
"Stiff and Differential-Algebraic Problems,\n"
2725 <<
"2nd Revised Edition\n"
2726 <<
"E. Hairer and G. Wanner\n"
2727 <<
"Table 5.3, pg 73\n"
2728 <<
"c = [ 0 2/3 ]'\n"
2729 <<
"A = [ 1/4 -1/4 ]\n"
2730 <<
" [ 1/4 5/12 ]\n"
2731 <<
"b = [ 1/4 3/4 ]'" << std::endl;
2732 typedef Teuchos::ScalarTraits<Scalar> ST;
2735 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
2736 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
2737 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
2738 const Scalar zero = ST::zero();
2739 const Scalar one = ST::one();
2740 A(0,0) = as<Scalar>(one/(4*one));
2741 A(0,1) = as<Scalar>(-one/(4*one));
2742 A(1,0) = as<Scalar>(one/(4*one));
2743 A(1,1) = as<Scalar>(5*one/(12*one));
2744 b(0) = as<Scalar>(one/(4*one));
2745 b(1) = as<Scalar>(3*one/(4*one));
2747 c(1) = as<Scalar>(2*one/(3*one));
2750 this->
initialize(A,b,c,order,Description.str());
2753 {
return "RK Implicit 2 Stage 3rd order Radau left"; }
2758 template<
class Scalar>
2765 std::ostringstream Description;
2768 <<
"Solving Ordinary Differential Equations II:\n"
2769 <<
"Stiff and Differential-Algebraic Problems,\n"
2770 <<
"2nd Revised Edition\n"
2771 <<
"E. Hairer and G. Wanner\n"
2772 <<
"Table 5.4, pg 73\n"
2773 <<
"c = [ 0 (6-sqrt(6))/10 (6+sqrt(6))/10 ]'\n"
2774 <<
"A = [ 1/9 (-1-sqrt(6))/18 (-1+sqrt(6))/18 ]\n"
2775 <<
" [ 1/9 (88+7*sqrt(6))/360 (88-43*sqrt(6))/360 ]\n"
2776 <<
" [ 1/9 (88+43*sqrt(6))/360 (88-7*sqrt(6))/360 ]\n"
2777 <<
"b = [ 1/9 (16+sqrt(6))/36 (16-sqrt(6))/36 ]'"
2779 typedef Teuchos::ScalarTraits<Scalar> ST;
2782 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
2783 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
2784 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
2785 const Scalar zero = ST::zero();
2786 const Scalar one = ST::one();
2787 A(0,0) = as<Scalar>(one/(9*one));
2788 A(0,1) = as<Scalar>( (-one-ST::squareroot(6*one))/(18*one) );
2789 A(0,2) = as<Scalar>( (-one+ST::squareroot(6*one))/(18*one) );
2790 A(1,0) = as<Scalar>(one/(9*one));
2791 A(1,1) = as<Scalar>( (88*one+7*one*ST::squareroot(6*one))/(360*one) );
2792 A(1,2) = as<Scalar>( (88*one-43*one*ST::squareroot(6*one))/(360*one) );
2793 A(2,0) = as<Scalar>(one/(9*one));
2794 A(2,1) = as<Scalar>( (88*one+43*one*ST::squareroot(6*one))/(360*one) );
2795 A(2,2) = as<Scalar>( (88*one-7*one*ST::squareroot(6*one))/(360*one) );
2796 b(0) = as<Scalar>(one/(9*one));
2797 b(1) = as<Scalar>( (16*one+ST::squareroot(6*one))/(36*one) );
2798 b(2) = as<Scalar>( (16*one-ST::squareroot(6*one))/(36*one) );
2800 c(1) = as<Scalar>( (6*one-ST::squareroot(6*one))/(10*one) );
2801 c(2) = as<Scalar>( (6*one+ST::squareroot(6*one))/(10*one) );
2804 this->
initialize(A,b,c,order,Description.str());
2807 {
return "RK Implicit 3 Stage 5th order Radau left"; }
2812 template<
class Scalar>
2819 std::ostringstream Description;
2822 <<
"Solving Ordinary Differential Equations II:\n"
2823 <<
"Stiff and Differential-Algebraic Problems,\n"
2824 <<
"2nd Revised Edition\n"
2825 <<
"E. Hairer and G. Wanner\n"
2826 <<
"Table 5.5, pg 74\n"
2829 <<
"b = [ 1 ]'" << std::endl;
2830 typedef Teuchos::ScalarTraits<Scalar> ST;
2832 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
2833 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
2834 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
2835 const Scalar one = ST::one();
2841 this->
initialize(A,b,c,order,Description.str());
2844 {
return "RK Implicit 1 Stage 1st order Radau right"; }
2849 template<
class Scalar>
2856 std::ostringstream Description;
2859 <<
"Solving Ordinary Differential Equations II:\n"
2860 <<
"Stiff and Differential-Algebraic Problems,\n"
2861 <<
"2nd Revised Edition\n"
2862 <<
"E. Hairer and G. Wanner\n"
2863 <<
"Table 5.5, pg 74\n"
2864 <<
"c = [ 1/3 1 ]'\n"
2865 <<
"A = [ 5/12 -1/12 ]\n"
2867 <<
"b = [ 3/4 1/4 ]'" << std::endl;
2868 typedef Teuchos::ScalarTraits<Scalar> ST;
2871 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
2872 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
2873 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
2874 const Scalar one = ST::one();
2875 A(0,0) = as<Scalar>( 5*one/(12*one) );
2876 A(0,1) = as<Scalar>( -one/(12*one) );
2877 A(1,0) = as<Scalar>( 3*one/(4*one) );
2878 A(1,1) = as<Scalar>( one/(4*one) );
2879 b(0) = as<Scalar>( 3*one/(4*one) );
2880 b(1) = as<Scalar>( one/(4*one) );
2881 c(0) = as<Scalar>( one/(3*one) );
2885 this->
initialize(A,b,c,order,Description.str());
2888 {
return "RK Implicit 2 Stage 3rd order Radau right"; }
2893 template<
class Scalar>
2900 std::ostringstream Description;
2903 <<
"Solving Ordinary Differential Equations II:\n"
2904 <<
"Stiff and Differential-Algebraic Problems,\n"
2905 <<
"2nd Revised Edition\n"
2906 <<
"E. Hairer and G. Wanner\n"
2907 <<
"Table 5.6, pg 74\n"
2908 <<
"c = [ (4-sqrt(6))/10 (4+sqrt(6))/10 1 ]'\n"
2909 <<
"A = [ A1 A2 A3 ]\n"
2910 <<
" A1 = [ (88-7*sqrt(6))/360 ]\n"
2911 <<
" [ (296+169*sqrt(6))/1800 ]\n"
2912 <<
" [ (16-sqrt(6))/36 ]\n"
2913 <<
" A2 = [ (296-169*sqrt(6))/1800 ]\n"
2914 <<
" [ (88+7*sqrt(6))/360 ]\n"
2915 <<
" [ (16+sqrt(6))/36 ]\n"
2916 <<
" A3 = [ (-2+3*sqrt(6))/225 ]\n"
2917 <<
" [ (-2-3*sqrt(6))/225 ]\n"
2919 <<
"b = [ (16-sqrt(6))/36 (16+sqrt(6))/36 1/9 ]'"
2921 typedef Teuchos::ScalarTraits<Scalar> ST;
2924 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
2925 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
2926 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
2927 const Scalar one = ST::one();
2928 A(0,0) = as<Scalar>( (88*one-7*one*ST::squareroot(6*one))/(360*one) );
2929 A(0,1) = as<Scalar>( (296*one-169*one*ST::squareroot(6*one))/(1800*one) );
2930 A(0,2) = as<Scalar>( (-2*one+3*one*ST::squareroot(6*one))/(225*one) );
2931 A(1,0) = as<Scalar>( (296*one+169*one*ST::squareroot(6*one))/(1800*one) );
2932 A(1,1) = as<Scalar>( (88*one+7*one*ST::squareroot(6*one))/(360*one) );
2933 A(1,2) = as<Scalar>( (-2*one-3*one*ST::squareroot(6*one))/(225*one) );
2934 A(2,0) = as<Scalar>( (16*one-ST::squareroot(6*one))/(36*one) );
2935 A(2,1) = as<Scalar>( (16*one+ST::squareroot(6*one))/(36*one) );
2936 A(2,2) = as<Scalar>( one/(9*one) );
2937 b(0) = as<Scalar>( (16*one-ST::squareroot(6*one))/(36*one) );
2938 b(1) = as<Scalar>( (16*one+ST::squareroot(6*one))/(36*one) );
2939 b(2) = as<Scalar>( one/(9*one) );
2940 c(0) = as<Scalar>( (4*one-ST::squareroot(6*one))/(10*one) );
2941 c(1) = as<Scalar>( (4*one+ST::squareroot(6*one))/(10*one) );
2945 this->
initialize(A,b,c,order,Description.str());
2948 {
return "RK Implicit 3 Stage 5th order Radau right"; }
2953 template<
class Scalar>
2960 std::ostringstream Description;
2963 <<
"Solving Ordinary Differential Equations II:\n"
2964 <<
"Stiff and Differential-Algebraic Problems,\n"
2965 <<
"2nd Revised Edition\n"
2966 <<
"E. Hairer and G. Wanner\n"
2967 <<
"Table 5.7, pg 75\n"
2971 <<
"b = [ 1/2 1/2 ]'" << std::endl;
2972 typedef Teuchos::ScalarTraits<Scalar> ST;
2975 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
2976 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
2977 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
2978 const Scalar zero = ST::zero();
2979 const Scalar one = ST::one();
2982 A(1,0) = as<Scalar>( one/(2*one) );
2983 A(1,1) = as<Scalar>( one/(2*one) );
2984 b(0) = as<Scalar>( one/(2*one) );
2985 b(1) = as<Scalar>( one/(2*one) );
2990 this->
initialize(A,b,c,order,Description.str());
2993 {
return "RK Implicit 2 Stage 2nd order Lobatto A"; }
2998 template<
class Scalar>
3005 std::ostringstream Description;
3008 <<
"Solving Ordinary Differential Equations II:\n"
3009 <<
"Stiff and Differential-Algebraic Problems,\n"
3010 <<
"2nd Revised Edition\n"
3011 <<
"E. Hairer and G. Wanner\n"
3012 <<
"Table 5.7, pg 75\n"
3013 <<
"c = [ 0 1/2 1 ]'\n"
3014 <<
"A = [ 0 0 0 ]\n"
3015 <<
" [ 5/24 1/3 -1/24 ]\n"
3016 <<
" [ 1/6 2/3 1/6 ]\n"
3017 <<
"b = [ 1/6 2/3 1/6 ]'" << std::endl;
3018 typedef Teuchos::ScalarTraits<Scalar> ST;
3021 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
3022 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
3023 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
3024 const Scalar zero = ST::zero();
3025 const Scalar one = ST::one();
3029 A(1,0) = as<Scalar>( (5*one)/(24*one) );
3030 A(1,1) = as<Scalar>( (one)/(3*one) );
3031 A(1,2) = as<Scalar>( (-one)/(24*one) );
3032 A(2,0) = as<Scalar>( (one)/(6*one) );
3033 A(2,1) = as<Scalar>( (2*one)/(3*one) );
3034 A(2,2) = as<Scalar>( (1*one)/(6*one) );
3035 b(0) = as<Scalar>( (one)/(6*one) );
3036 b(1) = as<Scalar>( (2*one)/(3*one) );
3037 b(2) = as<Scalar>( (1*one)/(6*one) );
3039 c(1) = as<Scalar>( one/(2*one) );
3043 this->
initialize(A,b,c,order,Description.str());
3046 {
return "RK Implicit 3 Stage 4th order Lobatto A"; }
3051 template<
class Scalar>
3059 typedef Teuchos::ScalarTraits<Scalar> ST;
3060 std::ostringstream Description;
3063 <<
"Solving Ordinary Differential Equations II:\n"
3064 <<
"Stiff and Differential-Algebraic Problems,\n"
3065 <<
"2nd Revised Edition\n"
3066 <<
"E. Hairer and G. Wanner\n"
3067 <<
"Table 5.8, pg 75\n"
3068 <<
"c = [ 0 (5-sqrt(5))/10 (5+sqrt(5))/10 1 ]'\n"
3069 <<
"A = [ A1 A2 A3 A4 ]\n"
3071 <<
" [ (11+sqrt(5)/120 ]\n"
3072 <<
" [ (11-sqrt(5)/120 ]\n"
3075 <<
" [ (25-sqrt(5))/120 ]\n"
3076 <<
" [ (25+13*sqrt(5))/120 ]\n"
3079 <<
" [ (25-13*sqrt(5))/120 ]\n"
3080 <<
" [ (25+sqrt(5))/120 ]\n"
3083 <<
" [ (-1+sqrt(5))/120 ]\n"
3084 <<
" [ (-1-sqrt(5))/120 ]\n"
3086 <<
"b = [ 1/12 5/12 5/12 1/12 ]'" << std::endl;
3087 typedef Teuchos::ScalarTraits<Scalar> ST;
3089 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
3090 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
3091 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
3092 const Scalar zero = ST::zero();
3093 const Scalar one = ST::one();
3098 A(1,0) = as<Scalar>( (11*one+ST::squareroot(5*one))/(120*one) );
3099 A(1,1) = as<Scalar>( (25*one-ST::squareroot(5*one))/(120*one) );
3100 A(1,2) = as<Scalar>( (25*one-13*one*ST::squareroot(5*one))/(120*one) );
3101 A(1,3) = as<Scalar>( (-one+ST::squareroot(5*one))/(120*one) );
3102 A(2,0) = as<Scalar>( (11*one-ST::squareroot(5*one))/(120*one) );
3103 A(2,1) = as<Scalar>( (25*one+13*one*ST::squareroot(5*one))/(120*one) );
3104 A(2,2) = as<Scalar>( (25*one+ST::squareroot(5*one))/(120*one) );
3105 A(2,3) = as<Scalar>( (-one-ST::squareroot(5*one))/(120*one) );
3106 A(3,0) = as<Scalar>( one/(12*one) );
3107 A(3,1) = as<Scalar>( 5*one/(12*one) );
3108 A(3,2) = as<Scalar>( 5*one/(12*one) );
3109 A(3,3) = as<Scalar>( one/(12*one) );
3110 b(0) = as<Scalar>( one/(12*one) );
3111 b(1) = as<Scalar>( 5*one/(12*one) );
3112 b(2) = as<Scalar>( 5*one/(12*one) );
3113 b(3) = as<Scalar>( one/(12*one) );
3115 c(1) = as<Scalar>( (5*one-ST::squareroot(5))/(10*one) );
3116 c(2) = as<Scalar>( (5*one+ST::squareroot(5))/(10*one) );
3120 this->
initialize(A,b,c,order,Description.str());
3123 {
return "RK Implicit 4 Stage 6th order Lobatto A"; }
3128 template<
class Scalar>
3135 std::ostringstream Description;
3138 <<
"Solving Ordinary Differential Equations II:\n"
3139 <<
"Stiff and Differential-Algebraic Problems,\n"
3140 <<
"2nd Revised Edition\n"
3141 <<
"E. Hairer and G. Wanner\n"
3142 <<
"Table 5.9, pg 76\n"
3144 <<
"A = [ 1/2 0 ]\n"
3146 <<
"b = [ 1/2 1/2 ]'" << std::endl;
3147 typedef Teuchos::ScalarTraits<Scalar> ST;
3150 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
3151 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
3152 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
3153 const Scalar zero = ST::zero();
3154 const Scalar one = ST::one();
3155 A(0,0) = as<Scalar>( one/(2*one) );
3157 A(1,0) = as<Scalar>( one/(2*one) );
3159 b(0) = as<Scalar>( one/(2*one) );
3160 b(1) = as<Scalar>( one/(2*one) );
3165 this->
initialize(A,b,c,order,Description.str());
3168 {
return "RK Implicit 2 Stage 2nd order Lobatto B"; }
3173 template<
class Scalar>
3180 std::ostringstream Description;
3183 <<
"Solving Ordinary Differential Equations II:\n"
3184 <<
"Stiff and Differential-Algebraic Problems,\n"
3185 <<
"2nd Revised Edition\n"
3186 <<
"E. Hairer and G. Wanner\n"
3187 <<
"Table 5.9, pg 76\n"
3188 <<
"c = [ 0 1/2 1 ]'\n"
3189 <<
"A = [ 1/6 -1/6 0 ]\n"
3190 <<
" [ 1/6 1/3 0 ]\n"
3191 <<
" [ 1/6 5/6 0 ]\n"
3192 <<
"b = [ 1/6 2/3 1/6 ]'" << std::endl;
3193 typedef Teuchos::ScalarTraits<Scalar> ST;
3196 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
3197 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
3198 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
3199 const Scalar zero = ST::zero();
3200 const Scalar one = ST::one();
3201 A(0,0) = as<Scalar>( one/(6*one) );
3202 A(0,1) = as<Scalar>( -one/(6*one) );
3204 A(1,0) = as<Scalar>( one/(6*one) );
3205 A(1,1) = as<Scalar>( one/(3*one) );
3207 A(2,0) = as<Scalar>( one/(6*one) );
3208 A(2,1) = as<Scalar>( 5*one/(6*one) );
3210 b(0) = as<Scalar>( one/(6*one) );
3211 b(1) = as<Scalar>( 2*one/(3*one) );
3212 b(2) = as<Scalar>( one/(6*one) );
3214 c(1) = as<Scalar>( one/(2*one) );
3218 this->
initialize(A,b,c,order,Description.str());
3221 {
return "RK Implicit 3 Stage 4th order Lobatto B"; }
3226 template<
class Scalar>
3233 std::ostringstream Description;
3236 <<
"Solving Ordinary Differential Equations II:\n"
3237 <<
"Stiff and Differential-Algebraic Problems,\n"
3238 <<
"2nd Revised Edition\n"
3239 <<
"E. Hairer and G. Wanner\n"
3240 <<
"Table 5.10, pg 76\n"
3241 <<
"c = [ 0 (5-sqrt(5))/10 (5+sqrt(5))/10 1 ]'\n"
3242 <<
"A = [ 1/12 (-1-sqrt(5))/24 (-1+sqrt(5))/24 0 ]\n"
3243 <<
" [ 1/12 (25+sqrt(5))/120 (25-13*sqrt(5))/120 0 ]\n"
3244 <<
" [ 1/12 (25+13*sqrt(5))/120 (25-sqrt(5))/120 0 ]\n"
3245 <<
" [ 1/12 (11-sqrt(5))/24 (11+sqrt(5))/24 0 ]\n"
3246 <<
"b = [ 1/12 5/12 5/12 1/12 ]'"
3248 typedef Teuchos::ScalarTraits<Scalar> ST;
3251 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
3252 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
3253 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
3254 const Scalar zero = ST::zero();
3255 const Scalar one = ST::one();
3256 A(0,0) = as<Scalar>( one/(12*one) );
3257 A(0,1) = as<Scalar>( (-one-ST::squareroot(5*one))/(24*one) );
3258 A(0,2) = as<Scalar>( (-one+ST::squareroot(5*one))/(24*one) );
3260 A(1,0) = as<Scalar>( one/(12*one) );
3261 A(1,1) = as<Scalar>( (25*one+ST::squareroot(5*one))/(120*one) );
3262 A(1,2) = as<Scalar>( (25*one-13*one*ST::squareroot(5*one))/(120*one) );
3264 A(2,0) = as<Scalar>( one/(12*one) );
3265 A(2,1) = as<Scalar>( (25*one+13*one*ST::squareroot(5*one))/(120*one) );
3266 A(2,2) = as<Scalar>( (25*one-ST::squareroot(5*one))/(120*one) );
3268 A(3,0) = as<Scalar>( one/(12*one) );
3269 A(3,1) = as<Scalar>( (11*one-ST::squareroot(5*one))/(24*one) );
3270 A(3,2) = as<Scalar>( (11*one+ST::squareroot(5*one))/(24*one) );
3272 b(0) = as<Scalar>( one/(12*one) );
3273 b(1) = as<Scalar>( 5*one/(12*one) );
3274 b(2) = as<Scalar>( 5*one/(12*one) );
3275 b(3) = as<Scalar>( one/(12*one) );
3277 c(1) = as<Scalar>( (5*one-ST::squareroot(5*one))/(10*one) );
3278 c(2) = as<Scalar>( (5*one+ST::squareroot(5*one))/(10*one) );
3282 this->
initialize(A,b,c,order,Description.str());
3285 {
return "RK Implicit 4 Stage 6th order Lobatto B"; }
3290 template<
class Scalar>
3297 std::ostringstream Description;
3300 <<
"Solving Ordinary Differential Equations II:\n"
3301 <<
"Stiff and Differential-Algebraic Problems,\n"
3302 <<
"2nd Revised Edition\n"
3303 <<
"E. Hairer and G. Wanner\n"
3304 <<
"Table 5.11, pg 76\n"
3306 <<
"A = [ 1/2 -1/2 ]\n"
3308 <<
"b = [ 1/2 1/2 ]'" << std::endl;
3309 typedef Teuchos::ScalarTraits<Scalar> ST;
3312 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
3313 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
3314 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
3315 const Scalar zero = ST::zero();
3316 const Scalar one = ST::one();
3317 A(0,0) = as<Scalar>( one/(2*one) );
3318 A(0,1) = as<Scalar>( -one/(2*one) );
3319 A(1,0) = as<Scalar>( one/(2*one) );
3320 A(1,1) = as<Scalar>( one/(2*one) );
3321 b(0) = as<Scalar>( one/(2*one) );
3322 b(1) = as<Scalar>( one/(2*one) );
3327 this->
initialize(A,b,c,order,Description.str());
3330 {
return "RK Implicit 2 Stage 2nd order Lobatto C"; }
3335 template<
class Scalar>
3342 std::ostringstream Description;
3345 <<
"Solving Ordinary Differential Equations II:\n"
3346 <<
"Stiff and Differential-Algebraic Problems,\n"
3347 <<
"2nd Revised Edition\n"
3348 <<
"E. Hairer and G. Wanner\n"
3349 <<
"Table 5.11, pg 76\n"
3350 <<
"c = [ 0 1/2 1 ]'\n"
3351 <<
"A = [ 1/6 -1/3 1/6 ]\n"
3352 <<
" [ 1/6 5/12 -1/12 ]\n"
3353 <<
" [ 1/6 2/3 1/6 ]\n"
3354 <<
"b = [ 1/6 2/3 1/6 ]'" << std::endl;
3355 typedef Teuchos::ScalarTraits<Scalar> ST;
3358 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
3359 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
3360 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
3361 const Scalar zero = ST::zero();
3362 const Scalar one = ST::one();
3363 A(0,0) = as<Scalar>( one/(6*one) );
3364 A(0,1) = as<Scalar>( -one/(3*one) );
3365 A(0,2) = as<Scalar>( one/(6*one) );
3366 A(1,0) = as<Scalar>( one/(6*one) );
3367 A(1,1) = as<Scalar>( 5*one/(12*one) );
3368 A(1,2) = as<Scalar>( -one/(12*one) );
3369 A(2,0) = as<Scalar>( one/(6*one) );
3370 A(2,1) = as<Scalar>( 2*one/(3*one) );
3371 A(2,2) = as<Scalar>( one/(6*one) );
3372 b(0) = as<Scalar>( one/(6*one) );
3373 b(1) = as<Scalar>( 2*one/(3*one) );
3374 b(2) = as<Scalar>( one/(6*one) );
3376 c(1) = as<Scalar>( one/(2*one) );
3380 this->
initialize(A,b,c,order,Description.str());
3383 {
return "RK Implicit 3 Stage 4th order Lobatto C"; }
3388 template<
class Scalar>
3395 std::ostringstream Description;
3398 <<
"Solving Ordinary Differential Equations II:\n"
3399 <<
"Stiff and Differential-Algebraic Problems,\n"
3400 <<
"2nd Revised Edition\n"
3401 <<
"E. Hairer and G. Wanner\n"
3402 <<
"Table 5.12, pg 76\n"
3403 <<
"c = [ 0 (5-sqrt(5))/10 (5+sqrt(5))/10 1 ]'\n"
3404 <<
"A = [ 1/12 -sqrt(5)/12 sqrt(5)/12 -1/12 ]\n"
3405 <<
" [ 1/12 1/4 (10-7*sqrt(5))/60 sqrt(5)/60 ]\n"
3406 <<
" [ 1/12 (10+7*sqrt(5))/60 1/4 -sqrt(5)/60 ]\n"
3407 <<
" [ 1/12 5/12 5/12 1/12 ]\n"
3408 <<
"b = [ 1/12 5/12 5/12 1/12 ]'"
3410 typedef Teuchos::ScalarTraits<Scalar> ST;
3413 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
3414 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
3415 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
3416 const Scalar zero = ST::zero();
3417 const Scalar one = ST::one();
3418 A(0,0) = as<Scalar>( one/(12*one) );
3419 A(0,1) = as<Scalar>( -ST::squareroot(5*one)/(12*one) );
3420 A(0,2) = as<Scalar>( ST::squareroot(5*one)/(12*one) );
3421 A(0,3) = as<Scalar>( -one/(12*one) );
3422 A(1,0) = as<Scalar>( one/(12*one) );
3423 A(1,1) = as<Scalar>( one/(4*one) );
3424 A(1,2) = as<Scalar>( (10*one-7*one*ST::squareroot(5*one))/(60*one) );
3425 A(1,3) = as<Scalar>( ST::squareroot(5*one)/(60*one) );
3426 A(2,0) = as<Scalar>( one/(12*one) );
3427 A(2,1) = as<Scalar>( (10*one+7*one*ST::squareroot(5*one))/(60*one) );
3428 A(2,2) = as<Scalar>( one/(4*one) );
3429 A(2,3) = as<Scalar>( -ST::squareroot(5*one)/(60*one) );
3430 A(3,0) = as<Scalar>( one/(12*one) );
3431 A(3,1) = as<Scalar>( 5*one/(12*one) );
3432 A(3,2) = as<Scalar>( 5*one/(12*one) );
3433 A(3,3) = as<Scalar>( one/(12*one) );
3434 b(0) = as<Scalar>( one/(12*one) );
3435 b(1) = as<Scalar>( 5*one/(12*one) );
3436 b(2) = as<Scalar>( 5*one/(12*one) );
3437 b(3) = as<Scalar>( one/(12*one) );
3439 c(1) = as<Scalar>( (5*one-ST::squareroot(5*one))/(10*one) );
3440 c(2) = as<Scalar>( (5*one+ST::squareroot(5*one))/(10*one) );
3444 this->
initialize(A,b,c,order,Description.str());
3447 {
return "RK Implicit 4 Stage 6th order Lobatto C"; }
3452 template<
class Scalar>
3459 std::ostringstream Description;
3462 <<
"Solving Ordinary Differential Equations II:\n"
3463 <<
"Stiff and Differential-Algebraic Problems,\n"
3464 <<
"2nd Revised Edition\n"
3465 <<
"E. Hairer and G. Wanner\n"
3467 <<
"c = [ (6-sqrt(6))/10 ]\n"
3468 <<
" [ (6+9*sqrt(6))/35 ]\n"
3470 <<
" [ (4-sqrt(6))/10 ]\n"
3471 <<
" [ (4+sqrt(6))/10 ]\n"
3472 <<
"A = [ A1 A2 A3 A4 A5 ]\n"
3473 <<
" A1 = [ (6-sqrt(6))/10 ]\n"
3474 <<
" [ (-6+5*sqrt(6))/14 ]\n"
3475 <<
" [ (888+607*sqrt(6))/2850 ]\n"
3476 <<
" [ (3153-3082*sqrt(6))/14250 ]\n"
3477 <<
" [ (-32583+14638*sqrt(6))/71250 ]\n"
3479 <<
" [ (6-sqrt(6))/10 ]\n"
3480 <<
" [ (126-161*sqrt(6))/1425 ]\n"
3481 <<
" [ (3213+1148*sqrt(6))/28500 ]\n"
3482 <<
" [ (-17199+364*sqrt(6))/142500 ]\n"
3485 <<
" [ (6-sqrt(6))/10 ]\n"
3486 <<
" [ (-267+88*sqrt(6))/500 ]\n"
3487 <<
" [ (1329-544*sqrt(6))/2500 ]\n"
3491 <<
" [ (6-sqrt(6))/10 ]\n"
3492 <<
" [ (-96+131*sqrt(6))/625 ]\n"
3497 <<
" [ (6-sqrt(6))/10 ]\n"
3501 <<
" [ (16-sqrt(6))/36 ]\n"
3502 <<
" [ (16+sqrt(6))/36 ]" << std::endl;
3508 virtual std::string
description()
const {
return "SDIRK 5 Stage 5th order"; }
3512 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
3517 TEUCHOS_TEST_FOR_EXCEPTION(
3518 pl->get<std::string>(
"Stepper Type") != this->description()
3519 ,std::runtime_error,
3521 " Stepper Type = " + pl->get<std::string>(
"Stepper Type"));
3523 typedef Teuchos::ScalarTraits<Scalar> ST;
3526 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
3527 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
3528 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
3529 const Scalar zero = ST::zero();
3530 const Scalar one = ST::one();
3531 const Scalar sqrt6 = ST::squareroot(as<Scalar>(6*one));
3532 const Scalar gamma = as<Scalar>( (6*one - sqrt6) / (10*one) );
3539 A(1,0) = as<Scalar>( (-6*one+5*one*sqrt6)/(14*one) );
3545 A(2,0) = as<Scalar>( (888*one+607*one*sqrt6)/(2850*one) );
3546 A(2,1) = as<Scalar>( (126*one-161*one*sqrt6)/(1425*one) );
3551 A(3,0) = as<Scalar>( (3153*one-3082*one*sqrt6)/(14250*one) );
3552 A(3,1) = as<Scalar>( (3213*one+1148*one*sqrt6)/(28500*one) );
3553 A(3,2) = as<Scalar>( (-267*one+88*one*sqrt6)/(500*one) );
3557 A(4,0) = as<Scalar>( (-32583*one+14638*one*sqrt6)/(71250*one) );
3558 A(4,1) = as<Scalar>( (-17199*one+364*one*sqrt6)/(142500*one) );
3559 A(4,2) = as<Scalar>( (1329*one-544*one*sqrt6)/(2500*one) );
3560 A(4,3) = as<Scalar>( (-96*one+131*sqrt6)/(625*one) );
3565 b(2) = as<Scalar>( one/(9*one) );
3566 b(3) = as<Scalar>( (16*one-sqrt6)/(36*one) );
3567 b(4) = as<Scalar>( (16*one+sqrt6)/(36*one) );
3570 c(1) = as<Scalar>( (6*one+9*one*sqrt6)/(35*one) );
3572 c(3) = as<Scalar>( (4*one-sqrt6)/(10*one) );
3573 c(4) = as<Scalar>( (4*one+sqrt6)/(10*one) );
3578 this->setMyParamList(pl);
3582 Teuchos::RCP<const Teuchos::ParameterList>
3585 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
3586 pl->setName(
"Default Stepper - " + this->
description());
3588 pl->set<std::string>(
"Stepper Type", this->
description());
3589 pl->set<
bool>(
"Use Embedded",
false);
3590 pl->set<
bool>(
"Use FSAL",
false);
3591 pl->set<std::string>(
"Initial Condition Consistency",
"None");
3592 pl->set<
bool>(
"Initial Condition Consistency Check",
false);
3593 pl->set<std::string>(
"Solver Name",
"",
3594 "Name of ParameterList containing the solver specifications.");
3602 template<
class Scalar>
3609 std::ostringstream Description;
3612 <<
"Solving Ordinary Differential Equations II:\n"
3613 <<
"Stiff and Differential-Algebraic Problems,\n"
3614 <<
"2nd Revised Edition\n"
3615 <<
"E. Hairer and G. Wanner\n"
3617 <<
"c = [ 1/4 3/4 11/20 1/2 1 ]'\n"
3620 <<
" [ 17/50 -1/25 1/4 ]\n"
3621 <<
" [ 371/1360 -137/2720 15/544 1/4 ]\n"
3622 <<
" [ 25/24 -49/48 125/16 -85/12 1/4 ]\n"
3623 <<
"b = [ 25/24 -49/48 125/16 -85/12 1/4 ]'\n"
3624 <<
"b' = [ 59/48 -17/96 225/32 -85/12 0 ]'" << std::endl;
3630 virtual std::string
description()
const {
return "SDIRK 5 Stage 4th order"; }
3634 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
3639 TEUCHOS_TEST_FOR_EXCEPTION(
3640 pl->get<std::string>(
"Stepper Type") != this->description()
3641 ,std::runtime_error,
3643 " Stepper Type = " + pl->get<std::string>(
"Stepper Type"));
3645 typedef Teuchos::ScalarTraits<Scalar> ST;
3648 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
3649 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
3650 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
3651 const Scalar zero = ST::zero();
3652 const Scalar one = ST::one();
3653 const Scalar onequarter = as<Scalar>( one/(4*one) );
3654 A(0,0) = onequarter;
3660 A(1,0) = as<Scalar>( one / (2*one) );
3661 A(1,1) = onequarter;
3666 A(2,0) = as<Scalar>( 17*one/(50*one) );
3667 A(2,1) = as<Scalar>( -one/(25*one) );
3668 A(2,2) = onequarter;
3672 A(3,0) = as<Scalar>( 371*one/(1360*one) );
3673 A(3,1) = as<Scalar>( -137*one/(2720*one) );
3674 A(3,2) = as<Scalar>( 15*one/(544*one) );
3675 A(3,3) = onequarter;
3678 A(4,0) = as<Scalar>( 25*one/(24*one) );
3679 A(4,1) = as<Scalar>( -49*one/(48*one) );
3680 A(4,2) = as<Scalar>( 125*one/(16*one) );
3681 A(4,3) = as<Scalar>( -85*one/(12*one) );
3682 A(4,4) = onequarter;
3684 b(0) = as<Scalar>( 25*one/(24*one) );
3685 b(1) = as<Scalar>( -49*one/(48*one) );
3686 b(2) = as<Scalar>( 125*one/(16*one) );
3687 b(3) = as<Scalar>( -85*one/(12*one) );
3699 c(1) = as<Scalar>( 3*one/(4*one) );
3700 c(2) = as<Scalar>( 11*one/(20*one) );
3701 c(3) = as<Scalar>( one/(2*one) );
3707 this->setMyParamList(pl);
3711 Teuchos::RCP<const Teuchos::ParameterList>
3714 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
3715 pl->setName(
"Default Stepper - " + this->
description());
3717 pl->set<std::string>(
"Stepper Type", this->
description());
3718 pl->set<
bool>(
"Use Embedded",
false);
3719 pl->set<
bool>(
"Use FSAL",
false);
3720 pl->set<std::string>(
"Initial Condition Consistency",
"None");
3721 pl->set<
bool>(
"Initial Condition Consistency Check",
false);
3722 pl->set<std::string>(
"Solver Name",
"",
3723 "Name of ParameterList containing the solver specifications.");
3731 template<
class Scalar>
3738 std::ostringstream Description;
3741 <<
"Solving Ordinary Differential Equations II:\n"
3742 <<
"Stiff and Differential-Algebraic Problems,\n"
3743 <<
"2nd Revised Edition\n"
3744 <<
"E. Hairer and G. Wanner\n"
3746 <<
"gamma = (1/sqrt(3))*cos(pi/18)+1/2\n"
3747 <<
"delta = 1/(6*(2*gamma-1)^2)\n"
3748 <<
"c = [ gamma 1/2 1-gamma ]'\n"
3749 <<
"A = [ gamma ]\n"
3750 <<
" [ 1/2-gamma gamma ]\n"
3751 <<
" [ 2*gamma 1-4*gamma gamma ]\n"
3752 <<
"b = [ delta 1-2*delta delta ]'" << std::endl;
3758 virtual std::string
description()
const {
return "SDIRK 3 Stage 4th order"; }
3762 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
3767 TEUCHOS_TEST_FOR_EXCEPTION(
3768 pl->get<std::string>(
"Stepper Type") != this->description()
3769 ,std::runtime_error,
3771 " Stepper Type = " + pl->get<std::string>(
"Stepper Type"));
3773 typedef Teuchos::ScalarTraits<Scalar> ST;
3776 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
3777 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
3778 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
3779 const Scalar zero = ST::zero();
3780 const Scalar one = ST::one();
3781 const Scalar pi = as<Scalar>(4*one)*std::atan(one);
3782 const Scalar gamma = as<Scalar>( one/ST::squareroot(3*one)*std::cos(pi/(18*one))+one/(2*one) );
3783 const Scalar delta = as<Scalar>( one/(6*one*std::pow(2*gamma-one,2*one)) );
3788 A(1,0) = as<Scalar>( one/(2*one) - gamma );
3792 A(2,0) = as<Scalar>( 2*gamma );
3793 A(2,1) = as<Scalar>( one - 4*gamma );
3797 b(1) = as<Scalar>( one-2*delta );
3801 c(1) = as<Scalar>( one/(2*one) );
3802 c(2) = as<Scalar>( one - gamma );
3807 this->setMyParamList(pl);
3811 Teuchos::RCP<const Teuchos::ParameterList>
3814 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
3815 pl->setName(
"Default Stepper - " + this->
description());
3817 pl->set<std::string>(
"Stepper Type", this->
description());
3818 pl->set<
bool>(
"Use Embedded",
false);
3819 pl->set<
bool>(
"Use FSAL",
false);
3820 pl->set<std::string>(
"Initial Condition Consistency",
"None");
3821 pl->set<
bool>(
"Initial Condition Consistency Check",
false);
3822 pl->set<std::string>(
"Solver Name",
"",
3823 "Name of ParameterList containing the solver specifications.");
3847 template<
class Scalar>
3854 std::ostringstream Description;
3859 <<
"b = [ 1/2 1/2 ]\n"
3860 <<
"bstar = [ 1 0 ]\n" << std::endl;
3869 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
3874 TEUCHOS_TEST_FOR_EXCEPTION(
3875 pl->get<std::string>(
"Stepper Type") != this->description()
3876 ,std::runtime_error,
3878 " Stepper Type = " + pl->get<std::string>(
"Stepper Type"));
3880 typedef Teuchos::ScalarTraits<Scalar> ST;
3883 Teuchos::SerialDenseMatrix<int,Scalar>
A(NumStages,NumStages);
3884 Teuchos::SerialDenseVector<int,Scalar>
b(NumStages);
3885 Teuchos::SerialDenseVector<int,Scalar>
c(NumStages);
3886 Teuchos::SerialDenseVector<int,Scalar>
bstar(NumStages);
3888 const Scalar one = ST::one();
3889 const Scalar zero = ST::zero();
3900 b(0) = as<Scalar>(one/(2*one));
3901 b(1) = as<Scalar>(one/(2*one));
3913 this->setMyParamList(pl);
3917 Teuchos::RCP<const Teuchos::ParameterList>
3920 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
3921 pl->setName(
"Default Stepper - " + this->
description());
3923 pl->set<std::string>(
"Stepper Type", this->
description());
3924 pl->set<
bool>(
"Use Embedded",
false);
3925 pl->set<
bool>(
"Use FSAL",
false);
3926 pl->set<std::string>(
"Initial Condition Consistency",
"None");
3927 pl->set<
bool>(
"Initial Condition Consistency Check",
false);
3928 pl->set<std::string>(
"Solver Name",
"",
3929 "Name of ParameterList containing the solver specifications.");
3939 #endif // Tempus_RKButcherTableau_hpp
Teuchos::SerialDenseMatrix< int, Scalar > A_
virtual std::string description() const
Implicit2Stage3rdOrderRadauA_RKBT()
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
virtual std::string description() const
RK Explicit 3 Stage 3rd order TVD.
bool thirdOrderAStable_default_
RK Explicit 2 Stage 2nd order by Runge.
virtual std::string description() const
virtual std::string description() const
ExplicitTrapezoidal_RKBT()
const std::string & getDescription() const
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
virtual std::string description() const
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const &pList)
virtual std::string description() const
virtual std::string description() const
virtual const Teuchos::SerialDenseVector< int, Scalar > & b() const
Return the vector of quadrature weights.
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const &pList)
virtual const Teuchos::SerialDenseVector< int, Scalar > & c() const
Return the vector of stage positions.
virtual std::string description() const
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const &pList)
void set_orderMax(const int &order)
void set_order(const int &order)
Implicit4Stage6thOrderLobattoB_RKBT()
Explicit4Stage4thOrder_RKBT()
SDIRK3Stage4thOrder_RKBT()
Explicit5Stage3rdOrderKandG_RKBT()
virtual std::string description() const
virtual std::string description() const
virtual const Teuchos::SerialDenseVector< int, Scalar > & bstar() const
Return the vector of quadrature weights for embedded methods.
Implicit1Stage1stOrderRadauB_RKBT()
virtual std::string description() const
virtual void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const &pList)
virtual std::string description() const
Implicit2Stage2ndOrderLobattoA_RKBT()
Explicit4Stage3rdOrderRunge_RKBT()
Backward Euler Runge-Kutta Butcher Tableau.
virtual std::string description() const
virtual std::string description() const
Implicit3Stage4thOrderLobattoC_RKBT()
void TokensToDoubles(std::vector< double > &values, const std::vector< std::string > &tokens)
Turn a vector of tokens into a vector of doubles.
virtual std::string description() const
virtual std::string description() const
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Implicit3Stage6thOrderKuntzmannButcher_RKBT()
virtual std::string description() const
void set_c(const Teuchos::SerialDenseVector< int, Scalar > &c)
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Teuchos::SerialDenseVector< int, Scalar > bstar_
Explicit2Stage2ndOrderRunge_RKBT()
virtual std::string description() const
Explicit3Stage3rdOrderHeun_RKBT()
virtual std::string description() const
virtual std::string description() const
virtual bool isImplicit() const
Return true if the RK method is implicit.
virtual std::string description() const
virtual bool isEmbedded() const
Return true if the RK method has embedded capabilities.
void set_orderMin(const int &order)
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const &pList)
Implicit2Stage4thOrderGauss_RKBT()
virtual bool isDIRK() const
Return true if the RK method is Diagonally Implicit.
virtual std::string description() const
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const &pList)
virtual std::string description() const
Implicit4Stage8thOrderKuntzmannButcher_RKBT()
virtual int orderMax() const
Return the maximum order.
SDIRK5Stage4thOrder_RKBT()
EDIRK2Stage3rdOrder_RKBT()
Explicit3Stage3rdOrderTVD_RKBT()
ExplicitBogackiShampine32_RKBT()
void parseGeneralPL(Teuchos::RCP< Teuchos::ParameterList > const &pList)
virtual std::string description() const
Implicit3Stage6thOrderGauss_RKBT()
virtual std::string description() const
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
void set_b(const Teuchos::SerialDenseVector< int, Scalar > &b)
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const &pList)
General Explicit Runge-Kutta Butcher Tableau.
Implicit4Stage6thOrderLobattoA_RKBT()
virtual std::string description() const =0
SDIRK2Stage3rdOrder_RKBT()
void set_A(const Teuchos::SerialDenseMatrix< int, Scalar > &A)
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const &pList)
void set_isDIRK()
DIRK is defined as if a_ij = 0 for j>i and a_ii != 0 for at least one i.
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const &pList)
Teuchos::SerialDenseVector< int, Scalar > b_
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const &pList)
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const &pList)
Implicit1Stage2ndOrderGauss_RKBT()
Forward Euler Runge-Kutta Butcher Tableau.
virtual std::string description() const
Runge-Kutta 4th order Butcher Tableau.
virtual std::string description() const
std::string longDescription_
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Explicit RK 3/8th Rule Butcher Tableau.
virtual std::string description() const
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
virtual std::string description() const
Implicit2Stage3rdOrderRadauB_RKBT()
bool secondOrderLStable_default_
virtual std::string description() const
Implicit2Stage2ndOrderLobattoB_RKBT()
virtual Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
virtual std::string description() const
SDIRK2Stage2ndOrder_RKBT()
virtual std::string description() const
Explicit RK Bogacki-Shampine Butcher Tableau.
virtual std::string description() const
virtual std::string description() const
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Implicit3Stage4thOrderLobattoA_RKBT()
Implicit3Stage4thOrderLobattoB_RKBT()
virtual std::string description() const
Explicit3Stage3rdOrder_RKBT()
virtual void initialize(const Teuchos::SerialDenseMatrix< int, Scalar > &A, const Teuchos::SerialDenseVector< int, Scalar > &b, const Teuchos::SerialDenseVector< int, Scalar > &c, const int order, const int orderMin, const int orderMax, const std::string &longDescription, bool isEmbedded=false, const Teuchos::SerialDenseVector< int, Scalar > &bstar=Teuchos::SerialDenseVector< int, Scalar >())
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
virtual std::string description() const
Implicit4Stage6thOrderLobattoC_RKBT()
Teuchos::RCP< RKButcherTableau< Scalar > > rKButcherTableau()
void StringTokenizer(std::vector< std::string > &tokens, const std::string &str, const std::string delimiters, bool trim)
Tokenize a string, put tokens in a vector.
virtual std::size_t numStages() const
Return the number of stages.
virtual std::string description() const
virtual std::string description() const
Teuchos::SerialDenseVector< int, Scalar > c_
virtual void setDescription(std::string longD)
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const &pList)
Implicit1Stage1stOrderRadauA_RKBT()
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
virtual std::string description() const
virtual std::string description() const
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
virtual std::string description() const
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const &pList)
Teuchos::RCP< Teuchos::ParameterList > rkbtPL_
Implicit2Stage2ndOrderLobattoC_RKBT()
virtual std::string description() const
General Implicit Runge-Kutta Butcher Tableau.
virtual const Teuchos::SerialDenseMatrix< int, Scalar > & A() const
Return the matrix coefficients.
virtual std::string description() const
virtual std::string description() const
Implicit2Stage4thOrderHammerHollingsworth_RKBT()
virtual int order() const
Return the order.
Implicit3Stage5thOrderRadauA_RKBT()
virtual int orderMin() const
Return the minimum order.
Implicit3Stage5thOrderRadauB_RKBT()
virtual std::string description() const
RK Explicit 3 Stage 3rd order by Heun.
RK Explicit 5 Stage 3rd order by Kinnmark and Gray.
RK Explicit 4 Stage 3rd order by Runge.
RK Explicit 3 Stage 3rd order.
virtual void initialize(const Teuchos::SerialDenseMatrix< int, Scalar > &A, const Teuchos::SerialDenseVector< int, Scalar > &b, const Teuchos::SerialDenseVector< int, Scalar > &c, const int order, const std::string &longDescription, bool isEmbedded=false, const Teuchos::SerialDenseVector< int, Scalar > &bstar=Teuchos::SerialDenseVector< int, Scalar >())
SDIRK5Stage5thOrder_RKBT()
Explicit RK Merson Butcher Tableau.
virtual std::string description() const
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const &pList)
SDIRK1Stage1stOrder_RKBT()