pid_step_adjuster_coefficients.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. boost/numeric/odeint/stepper/detail/pid_step_adjuster_coefficients.hpp
  3. [begin_description]
  4. Coefficients for the PID stepsize controller.
  5. [end_description]
  6. Copyright 2017 Valentin Noah Hartmann
  7. Distributed under the Boost Software License, Version 1.0.
  8. (See accompanying file LICENSE_1_0.txt or
  9. copy at http://www.boost.org/LICENSE_1_0.txt)
  10. */
  11. #ifndef BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_PID_STEP_ADJUSTER_COEFFICIENTS_HPP_INCLUDED
  12. #define BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_PID_STEP_ADJUSTER_COEFFICIENTS_HPP_INCLUDED
  13. #include <boost/array.hpp>
  14. namespace boost {
  15. namespace numeric {
  16. namespace odeint {
  17. namespace detail {
  18. enum adjuster_type{
  19. BASIC,
  20. H0211,
  21. H211b,
  22. H211PI,
  23. H0312,
  24. H312b,
  25. H312PID,
  26. H0321,
  27. H321
  28. };
  29. template<int Type>
  30. class pid_step_adjuster_coefficients;
  31. template<>
  32. class pid_step_adjuster_coefficients<BASIC> : public boost::array<double, 5>
  33. {
  34. public:
  35. pid_step_adjuster_coefficients()
  36. : boost::array<double, 5>()
  37. {
  38. (*this)[0] = 1.0;
  39. (*this)[1] = 0.0;
  40. (*this)[2] = 0.0;
  41. (*this)[3] = 0.0;
  42. (*this)[4] = 0.0;
  43. }
  44. };
  45. template<>
  46. class pid_step_adjuster_coefficients<H0211> : public boost::array<double, 5>
  47. {
  48. public:
  49. pid_step_adjuster_coefficients()
  50. : boost::array<double, 5>()
  51. {
  52. (*this)[0] = 1.0 / 2.0;
  53. (*this)[1] = 1.0 / 2.0;
  54. (*this)[2] = 0.0;
  55. (*this)[3] = 1.0 / 2.0;
  56. (*this)[4] = 0.0;
  57. }
  58. };
  59. template<>
  60. class pid_step_adjuster_coefficients<H211b> : public boost::array<double, 5>
  61. {
  62. public:
  63. pid_step_adjuster_coefficients()
  64. : boost::array<double, 5>()
  65. {
  66. (*this)[0] = 1.0 / 5.0;
  67. (*this)[1] = 2.0 / 5.0;
  68. (*this)[2] = 0.0;
  69. (*this)[3] = 1.0 / 5.0;
  70. (*this)[4] = 0.0;
  71. }
  72. };
  73. template<>
  74. class pid_step_adjuster_coefficients<H211PI> : public boost::array<double, 5>
  75. {
  76. public:
  77. pid_step_adjuster_coefficients()
  78. : boost::array<double, 5>()
  79. {
  80. (*this)[0] = 1.0 / 6.0;
  81. (*this)[1] = 2.0 / 6.0;
  82. (*this)[2] = 0.0;
  83. (*this)[3] = 0.0;
  84. (*this)[4] = 0.0;
  85. }
  86. };
  87. template<>
  88. class pid_step_adjuster_coefficients<H0312> : public boost::array<double, 5>
  89. {
  90. public:
  91. pid_step_adjuster_coefficients()
  92. : boost::array<double, 5>()
  93. {
  94. (*this)[0] = 1.0 / 4.0;
  95. (*this)[1] = 2.0 / 2.0;
  96. (*this)[2] = 1.0 / 4.0;
  97. (*this)[3] = 3.0 / 4.0;
  98. (*this)[4] = 1.0 / 4.0;
  99. }
  100. };
  101. template<>
  102. class pid_step_adjuster_coefficients<H312b> : public boost::array<double, 5>
  103. {
  104. public:
  105. pid_step_adjuster_coefficients()
  106. : boost::array<double, 5>()
  107. {
  108. (*this)[0] = 1.0 / 6.0;
  109. (*this)[1] = 2.0 / 6.0;
  110. (*this)[2] = 1.0 / 6.0;
  111. (*this)[3] = 3.0 / 6.0;
  112. (*this)[4] = 1.0 / 6.0;
  113. }
  114. };
  115. template<>
  116. class pid_step_adjuster_coefficients<H312PID> : public boost::array<double, 5>
  117. {
  118. public:
  119. pid_step_adjuster_coefficients()
  120. : boost::array<double, 5>()
  121. {
  122. (*this)[0] = 1.0 / 18.0;
  123. (*this)[1] = 2.0 / 9.0;
  124. (*this)[2] = 1.0 / 18.0;
  125. (*this)[3] = 0.0;
  126. (*this)[4] = 0.0;
  127. }
  128. };
  129. template<>
  130. class pid_step_adjuster_coefficients<H0321> : public boost::array<double, 5>
  131. {
  132. public:
  133. pid_step_adjuster_coefficients()
  134. : boost::array<double, 5>()
  135. {
  136. (*this)[0] = 5.0 / 4.0;
  137. (*this)[1] = 1.0 / 2.0;
  138. (*this)[2] = -3.0 / 4.0;
  139. (*this)[3] = -1.0 / 4.0;
  140. (*this)[4] = -3.0 / 4.0;
  141. }
  142. };
  143. template<>
  144. class pid_step_adjuster_coefficients<H321> : public boost::array<double, 5>
  145. {
  146. public:
  147. pid_step_adjuster_coefficients()
  148. : boost::array<double, 5>()
  149. {
  150. (*this)[0] = 1.0 / 3.0;
  151. (*this)[1] = 1.0 / 18.0;
  152. (*this)[2] = -5.0 / 18.0;
  153. (*this)[3] = -5.0 / 16.0;
  154. (*this)[4] = -1.0 / 6.0;
  155. }
  156. };
  157. } // detail
  158. } // odeint
  159. } // numeric
  160. } // boost
  161. #endif