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