/builds/MusicScience37Projects/numerical-analysis/numerical-collection-cpp/include/num_collect/ode/rosenbrock/rodaspr_formula.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2021 MusicScience37 (Kenta Kabashima) |
3 | | * |
4 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | | * you may not use this file except in compliance with the License. |
6 | | * You may obtain a copy of the License at |
7 | | * |
8 | | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | | * |
10 | | * Unless required by applicable law or agreed to in writing, software |
11 | | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | | * See the License for the specific language governing permissions and |
14 | | * limitations under the License. |
15 | | */ |
16 | | /*! |
17 | | * \file |
18 | | * \brief Definition of rodaspr_formula class. |
19 | | */ |
20 | | #pragma once |
21 | | |
22 | | #include "num_collect/base/index_type.h" |
23 | | #include "num_collect/logging/log_tag_view.h" |
24 | | #include "num_collect/ode/concepts/problem.h" |
25 | | #include "num_collect/ode/concepts/rosenbrock_equation_solver.h" |
26 | | #include "num_collect/ode/embedded_solver.h" |
27 | | #include "num_collect/ode/evaluation_type.h" |
28 | | #include "num_collect/ode/rosenbrock/default_rosenbrock_equation_solver.h" |
29 | | #include "num_collect/ode/rosenbrock/rosenbrock_formula_base.h" |
30 | | |
31 | | namespace num_collect::ode::rosenbrock { |
32 | | |
33 | | /*! |
34 | | * \brief Class of RODASPR formula \cite Rang2015 for Rosenbrock method. |
35 | | * |
36 | | * \tparam Problem Type of problem. |
37 | | * \tparam EquationSolver Type of class to solve equations in Rosenbrock |
38 | | * methods. |
39 | | */ |
40 | | template <concepts::problem Problem, |
41 | | concepts::rosenbrock_equation_solver EquationSolver = |
42 | | default_rosenbrock_equation_solver_t<Problem>> |
43 | | class rodaspr_formula |
44 | | : public rosenbrock_formula_base<rodaspr_formula<Problem, EquationSolver>, |
45 | | Problem, EquationSolver> { |
46 | | public: |
47 | | //! Type of base class. |
48 | | using base_type = |
49 | | rosenbrock_formula_base<rodaspr_formula<Problem, EquationSolver>, |
50 | | Problem, EquationSolver>; |
51 | | |
52 | | using typename base_type::equation_solver_type; |
53 | | using typename base_type::problem_type; |
54 | | using typename base_type::scalar_type; |
55 | | using typename base_type::variable_type; |
56 | | |
57 | | using base_type::base_type; |
58 | | using base_type::equation_solver; |
59 | | using base_type::problem; |
60 | | |
61 | | protected: |
62 | | using base_type::coeff; |
63 | | |
64 | | public: |
65 | | //! Number of stages of this formula. |
66 | | static constexpr index_type stages = 6; |
67 | | |
68 | | //! Order of this formula. |
69 | | static constexpr index_type order = 4; |
70 | | |
71 | | /*! |
72 | | * \brief Order of lesser coefficients of this formula. |
73 | | * |
74 | | * \warning Exact information has not been found. |
75 | | */ |
76 | | static constexpr index_type lesser_order = 3; |
77 | | |
78 | | //! Log tag. |
79 | | static constexpr auto log_tag = |
80 | | logging::log_tag_view("num_collect::ode::rosenbrock::rodaspr_formula"); |
81 | | |
82 | | /*! |
83 | | * \name Coefficients in Rosenbrock method. |
84 | | * |
85 | | * - `a` is coefficients of intermidiate variables in calculation of |
86 | | * intermidiate variables. |
87 | | * - `b` is coefficients of time in calculation of intermidiate variables. |
88 | | * - `c` is coefficients of intermidiate variables in calculation of |
89 | | * estimates of next variables. |
90 | | * - `g` is coefficients of intermidiate variables in calculation of |
91 | | * intermidiate variables. |
92 | | */ |
93 | | ///@{ |
94 | | //! Coefficient in Rosenbrock method. |
95 | | static constexpr scalar_type a21 = coeff(0.75); |
96 | | static constexpr scalar_type a31 = coeff(7.5162877593868457e-2); |
97 | | static constexpr scalar_type a32 = coeff(2.4837122406131545e-2); |
98 | | static constexpr scalar_type a41 = coeff(1.6532708886396510); |
99 | | static constexpr scalar_type a42 = coeff(0.21545706385445562); |
100 | | static constexpr scalar_type a43 = coeff(-1.3157488872766792); |
101 | | static constexpr scalar_type a51 = coeff(19.385003738039885); |
102 | | static constexpr scalar_type a52 = coeff(1.2007117225835324); |
103 | | static constexpr scalar_type a53 = coeff(-19.337924059522791); |
104 | | static constexpr scalar_type a54 = coeff(-0.24779140110062559); |
105 | | static constexpr scalar_type a61 = coeff(-7.3844531665375115); |
106 | | static constexpr scalar_type a62 = coeff(-0.30593419030174646); |
107 | | static constexpr scalar_type a63 = coeff(7.8622074209377981); |
108 | | static constexpr scalar_type a64 = coeff(0.57817993590145966); |
109 | | static constexpr scalar_type a65 = coeff(0.25); |
110 | | |
111 | | static constexpr scalar_type b1 = coeff(0); |
112 | | static constexpr scalar_type b2 = a21; |
113 | | static constexpr scalar_type b3 = a31 + a32; |
114 | | static constexpr scalar_type b4 = a41 + a42 + a43; |
115 | | static constexpr scalar_type b5 = a51 + a52 + a53 + a54; |
116 | | static constexpr scalar_type b6 = a61 + a62 + a63 + a64 + a65; |
117 | | |
118 | | static constexpr scalar_type g21 = coeff(-0.75); |
119 | | static constexpr scalar_type g31 = coeff(-8.8644359075349941e-2); |
120 | | static constexpr scalar_type g32 = coeff(-2.8688974257983398e-2); |
121 | | static constexpr scalar_type g41 = coeff(-4.8470034585330284); |
122 | | static constexpr scalar_type g42 = coeff(-0.31583244269672095); |
123 | | static constexpr scalar_type g43 = coeff(4.9536568360123221); |
124 | | static constexpr scalar_type g51 = coeff(-26.769456904577400); |
125 | | static constexpr scalar_type g52 = coeff(-1.5066459128852787); |
126 | | static constexpr scalar_type g53 = coeff(27.200131480460591); |
127 | | static constexpr scalar_type g54 = coeff(0.82597133700208525); |
128 | | static constexpr scalar_type g61 = coeff(6.5876206496361416); |
129 | | static constexpr scalar_type g62 = coeff(0.36807059172993878); |
130 | | static constexpr scalar_type g63 = coeff(-6.7423520694658121); |
131 | | static constexpr scalar_type g64 = coeff(-0.10619631475741095); |
132 | | static constexpr scalar_type g65 = coeff(-0.35714285714285715); |
133 | | static constexpr scalar_type g = coeff(0.25); |
134 | | |
135 | | static constexpr scalar_type g1 = g; |
136 | | static constexpr scalar_type g2 = g21 + g; |
137 | | static constexpr scalar_type g3 = g31 + g32 + g; |
138 | | static constexpr scalar_type g4 = g41 + g42 + g43 + g; |
139 | | static constexpr scalar_type g5 = g51 + g52 + g53 + g54 + g; |
140 | | static constexpr scalar_type g6 = g61 + g62 + g63 + g64 + g65 + g; |
141 | | |
142 | | static constexpr scalar_type c1 = coeff(-0.79683251690137014); |
143 | | static constexpr scalar_type c2 = coeff(6.2136401428192344e-02); |
144 | | static constexpr scalar_type c3 = coeff(1.1198553514719862); |
145 | | static constexpr scalar_type c4 = coeff(0.47198362114404874); |
146 | | static constexpr scalar_type c5 = coeff(-0.10714285714285714); |
147 | | static constexpr scalar_type c6 = coeff(0.25); |
148 | | |
149 | | static constexpr scalar_type cw1 = coeff(-7.3844531665375115); |
150 | | static constexpr scalar_type cw2 = coeff(-0.30593419030174646); |
151 | | static constexpr scalar_type cw3 = coeff(7.8622074209377981); |
152 | | static constexpr scalar_type cw4 = coeff(0.57817993590145966); |
153 | | static constexpr scalar_type cw5 = coeff(0.25); |
154 | | |
155 | | static constexpr scalar_type ce1 = c1 - cw1; |
156 | | static constexpr scalar_type ce2 = c2 - cw2; |
157 | | static constexpr scalar_type ce3 = c3 - cw3; |
158 | | static constexpr scalar_type ce4 = c4 - cw4; |
159 | | static constexpr scalar_type ce5 = c5 - cw5; |
160 | | static constexpr scalar_type ce6 = c6; |
161 | | ///@} |
162 | | |
163 | | /*! |
164 | | * \brief Constructor. |
165 | | * |
166 | | * \param[in] problem Problem. |
167 | | */ |
168 | | explicit rodaspr_formula(const problem_type& problem) |
169 | 15 | : base_type(problem, g) {} _ZN11num_collect3ode10rosenbrock15rodaspr_formulaIN16num_prob_collect3ode33changing_mass_exponential_problemENS1_33scalar_rosenbrock_equation_solverIS5_EEEC2ERKS5_ Line | Count | Source | 169 | 1 | : base_type(problem, g) {} |
_ZN11num_collect3ode10rosenbrock15rodaspr_formulaIN16num_prob_collect3ode19exponential_problemENS1_33scalar_rosenbrock_equation_solverIS5_EEEC2ERKS5_ Line | Count | Source | 169 | 5 | : base_type(problem, g) {} |
_ZN11num_collect3ode10rosenbrock15rodaspr_formulaIN16num_prob_collect3ode32external_force_vibration_problemENS1_29lu_rosenbrock_equation_solverIS5_EEEC2ERKS5_ Line | Count | Source | 169 | 1 | : base_type(problem, g) {} |
_ZN11num_collect3ode10rosenbrock15rodaspr_formulaIN16num_prob_collect3ode28implicit_exponential_problemENS1_33scalar_rosenbrock_equation_solverIS5_EEEC2ERKS5_ Line | Count | Source | 169 | 1 | : base_type(problem, g) {} |
_ZN11num_collect3ode10rosenbrock15rodaspr_formulaIN16num_prob_collect3ode21implicit_kaps_problemENS1_29lu_rosenbrock_equation_solverIS5_EEEC2ERKS5_ Line | Count | Source | 169 | 3 | : base_type(problem, g) {} |
_ZN11num_collect3ode10rosenbrock15rodaspr_formulaIN16num_prob_collect3ode33no_jacobian_implicit_kaps_problemENS1_35bicgstab_rosenbrock_equation_solverIS5_EEEC2ERKS5_ Line | Count | Source | 169 | 3 | : base_type(problem, g) {} |
_ZN11num_collect3ode10rosenbrock15rodaspr_formulaIN16num_prob_collect3ode23spring_movement_problemENS1_29lu_rosenbrock_equation_solverIS5_EEEC2ERKS5_ Line | Count | Source | 169 | 1 | : base_type(problem, g) {} |
|
170 | | |
171 | | //! \copydoc ode::formula_base::step |
172 | | void step(scalar_type time, scalar_type step_size, |
173 | 2 | const variable_type& current, variable_type& estimate) { |
174 | 2 | variable_type unused; |
175 | 2 | step_embedded(time, step_size, current, estimate, unused); |
176 | 2 | } |
177 | | |
178 | | /*! |
179 | | * \brief Compute the next variable and weak estimate of it with embedded |
180 | | * formula. |
181 | | * |
182 | | * \param[in] time Current time. |
183 | | * \param[in] step_size Step size. |
184 | | * \param[in] current Current variable. |
185 | | * \param[out] estimate Estimate of the next variable. |
186 | | * \param[out] error Estimate of error. |
187 | | */ |
188 | | void step_embedded(scalar_type time, scalar_type step_size, |
189 | | const variable_type& current, variable_type& estimate, |
190 | 638 | variable_type& error) { |
191 | 638 | equation_solver().evaluate_and_update_jacobian( |
192 | 638 | problem(), time, step_size, current); |
193 | | |
194 | | // 1st stage |
195 | 638 | temp_rhs_ = problem().diff_coeff(); |
196 | 638 | equation_solver().add_time_derivative_term(step_size, g1, temp_rhs_); |
197 | 638 | equation_solver().solve(temp_rhs_, k1_); |
198 | | |
199 | | // 2nd stage |
200 | 638 | temp_var_ = g21 * k1_; |
201 | 638 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); |
202 | 638 | temp_rhs_ *= step_size; |
203 | 638 | temp_var_ = current + step_size * (a21 * k1_); |
204 | 638 | problem().evaluate_on(time + b2 * step_size, temp_var_, |
205 | 638 | evaluation_type{.diff_coeff = true}); |
206 | 638 | temp_rhs_ += problem().diff_coeff(); |
207 | 638 | equation_solver().add_time_derivative_term(step_size, g2, temp_rhs_); |
208 | 638 | equation_solver().solve(temp_rhs_, k2_); |
209 | | |
210 | | // 3rd stage |
211 | 638 | temp_var_ = g31 * k1_ + g32 * k2_; |
212 | 638 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); |
213 | 638 | temp_rhs_ *= step_size; |
214 | 638 | temp_var_ = current + step_size * (a31 * k1_ + a32 * k2_); |
215 | 638 | problem().evaluate_on(time + b3 * step_size, temp_var_, |
216 | 638 | evaluation_type{.diff_coeff = true}); |
217 | 638 | temp_rhs_ += problem().diff_coeff(); |
218 | 638 | equation_solver().add_time_derivative_term(step_size, g3, temp_rhs_); |
219 | 638 | equation_solver().solve(temp_rhs_, k3_); |
220 | | |
221 | | // 4th stage |
222 | 638 | temp_var_ = g41 * k1_ + g42 * k2_ + g43 * k3_; |
223 | 638 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); |
224 | 638 | temp_rhs_ *= step_size; |
225 | 638 | temp_var_ = current + step_size * (a41 * k1_ + a42 * k2_ + a43 * k3_); |
226 | 638 | problem().evaluate_on(time + b4 * step_size, temp_var_, |
227 | 638 | evaluation_type{.diff_coeff = true}); |
228 | 638 | temp_rhs_ += problem().diff_coeff(); |
229 | 638 | equation_solver().add_time_derivative_term(step_size, g4, temp_rhs_); |
230 | 638 | equation_solver().solve(temp_rhs_, k4_); |
231 | | |
232 | | // 5th stage |
233 | 638 | temp_var_ = g51 * k1_ + g52 * k2_ + g53 * k3_ + g54 * k4_; |
234 | 638 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); |
235 | 638 | temp_rhs_ *= step_size; |
236 | 638 | temp_var_ = current + |
237 | 638 | step_size * (a51 * k1_ + a52 * k2_ + a53 * k3_ + a54 * k4_); |
238 | 638 | problem().evaluate_on(time + b5 * step_size, temp_var_, |
239 | 638 | evaluation_type{.diff_coeff = true}); |
240 | 638 | temp_rhs_ += problem().diff_coeff(); |
241 | 638 | equation_solver().add_time_derivative_term(step_size, g5, temp_rhs_); |
242 | 638 | equation_solver().solve(temp_rhs_, k5_); |
243 | | |
244 | | // 6th stage |
245 | 638 | temp_var_ = g61 * k1_ + g62 * k2_ + g63 * k3_ + g64 * k4_ + g65 * k5_; |
246 | 638 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); |
247 | 638 | temp_rhs_ *= step_size; |
248 | 638 | temp_var_ = current + |
249 | 638 | step_size * |
250 | 638 | (a61 * k1_ + a62 * k2_ + a63 * k3_ + a64 * k4_ + a65 * k5_); |
251 | 638 | problem().evaluate_on(time + b6 * step_size, temp_var_, |
252 | 638 | evaluation_type{.diff_coeff = true}); |
253 | 638 | temp_rhs_ += problem().diff_coeff(); |
254 | 638 | equation_solver().add_time_derivative_term(step_size, g6, temp_rhs_); |
255 | 638 | equation_solver().solve(temp_rhs_, k6_); |
256 | | |
257 | 638 | estimate = current + |
258 | 638 | step_size * |
259 | 638 | (c1 * k1_ + c2 * k2_ + c3 * k3_ + c4 * k4_ + c5 * k5_ + |
260 | 638 | c6 * k6_); |
261 | 638 | error = step_size * |
262 | 638 | (ce1 * k1_ + ce2 * k2_ + ce3 * k3_ + ce4 * k4_ + ce5 * k5_ + |
263 | 638 | ce6 * k6_); |
264 | 638 | } _ZN11num_collect3ode10rosenbrock15rodaspr_formulaIN16num_prob_collect3ode33changing_mass_exponential_problemENS1_33scalar_rosenbrock_equation_solverIS5_EEE13step_embeddedEddRKdRdSB_ Line | Count | Source | 190 | 243 | variable_type& error) { | 191 | 243 | equation_solver().evaluate_and_update_jacobian( | 192 | 243 | problem(), time, step_size, current); | 193 | | | 194 | | // 1st stage | 195 | 243 | temp_rhs_ = problem().diff_coeff(); | 196 | 243 | equation_solver().add_time_derivative_term(step_size, g1, temp_rhs_); | 197 | 243 | equation_solver().solve(temp_rhs_, k1_); | 198 | | | 199 | | // 2nd stage | 200 | 243 | temp_var_ = g21 * k1_; | 201 | 243 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 202 | 243 | temp_rhs_ *= step_size; | 203 | 243 | temp_var_ = current + step_size * (a21 * k1_); | 204 | 243 | problem().evaluate_on(time + b2 * step_size, temp_var_, | 205 | 243 | evaluation_type{.diff_coeff = true}); | 206 | 243 | temp_rhs_ += problem().diff_coeff(); | 207 | 243 | equation_solver().add_time_derivative_term(step_size, g2, temp_rhs_); | 208 | 243 | equation_solver().solve(temp_rhs_, k2_); | 209 | | | 210 | | // 3rd stage | 211 | 243 | temp_var_ = g31 * k1_ + g32 * k2_; | 212 | 243 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 213 | 243 | temp_rhs_ *= step_size; | 214 | 243 | temp_var_ = current + step_size * (a31 * k1_ + a32 * k2_); | 215 | 243 | problem().evaluate_on(time + b3 * step_size, temp_var_, | 216 | 243 | evaluation_type{.diff_coeff = true}); | 217 | 243 | temp_rhs_ += problem().diff_coeff(); | 218 | 243 | equation_solver().add_time_derivative_term(step_size, g3, temp_rhs_); | 219 | 243 | equation_solver().solve(temp_rhs_, k3_); | 220 | | | 221 | | // 4th stage | 222 | 243 | temp_var_ = g41 * k1_ + g42 * k2_ + g43 * k3_; | 223 | 243 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 224 | 243 | temp_rhs_ *= step_size; | 225 | 243 | temp_var_ = current + step_size * (a41 * k1_ + a42 * k2_ + a43 * k3_); | 226 | 243 | problem().evaluate_on(time + b4 * step_size, temp_var_, | 227 | 243 | evaluation_type{.diff_coeff = true}); | 228 | 243 | temp_rhs_ += problem().diff_coeff(); | 229 | 243 | equation_solver().add_time_derivative_term(step_size, g4, temp_rhs_); | 230 | 243 | equation_solver().solve(temp_rhs_, k4_); | 231 | | | 232 | | // 5th stage | 233 | 243 | temp_var_ = g51 * k1_ + g52 * k2_ + g53 * k3_ + g54 * k4_; | 234 | 243 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 235 | 243 | temp_rhs_ *= step_size; | 236 | 243 | temp_var_ = current + | 237 | 243 | step_size * (a51 * k1_ + a52 * k2_ + a53 * k3_ + a54 * k4_); | 238 | 243 | problem().evaluate_on(time + b5 * step_size, temp_var_, | 239 | 243 | evaluation_type{.diff_coeff = true}); | 240 | 243 | temp_rhs_ += problem().diff_coeff(); | 241 | 243 | equation_solver().add_time_derivative_term(step_size, g5, temp_rhs_); | 242 | 243 | equation_solver().solve(temp_rhs_, k5_); | 243 | | | 244 | | // 6th stage | 245 | 243 | temp_var_ = g61 * k1_ + g62 * k2_ + g63 * k3_ + g64 * k4_ + g65 * k5_; | 246 | 243 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 247 | 243 | temp_rhs_ *= step_size; | 248 | 243 | temp_var_ = current + | 249 | 243 | step_size * | 250 | 243 | (a61 * k1_ + a62 * k2_ + a63 * k3_ + a64 * k4_ + a65 * k5_); | 251 | 243 | problem().evaluate_on(time + b6 * step_size, temp_var_, | 252 | 243 | evaluation_type{.diff_coeff = true}); | 253 | 243 | temp_rhs_ += problem().diff_coeff(); | 254 | 243 | equation_solver().add_time_derivative_term(step_size, g6, temp_rhs_); | 255 | 243 | equation_solver().solve(temp_rhs_, k6_); | 256 | | | 257 | 243 | estimate = current + | 258 | 243 | step_size * | 259 | 243 | (c1 * k1_ + c2 * k2_ + c3 * k3_ + c4 * k4_ + c5 * k5_ + | 260 | 243 | c6 * k6_); | 261 | 243 | error = step_size * | 262 | 243 | (ce1 * k1_ + ce2 * k2_ + ce3 * k3_ + ce4 * k4_ + ce5 * k5_ + | 263 | 243 | ce6 * k6_); | 264 | 243 | } |
_ZN11num_collect3ode10rosenbrock15rodaspr_formulaIN16num_prob_collect3ode19exponential_problemENS1_33scalar_rosenbrock_equation_solverIS5_EEE13step_embeddedEddRKdRdSB_ Line | Count | Source | 190 | 57 | variable_type& error) { | 191 | 57 | equation_solver().evaluate_and_update_jacobian( | 192 | 57 | problem(), time, step_size, current); | 193 | | | 194 | | // 1st stage | 195 | 57 | temp_rhs_ = problem().diff_coeff(); | 196 | 57 | equation_solver().add_time_derivative_term(step_size, g1, temp_rhs_); | 197 | 57 | equation_solver().solve(temp_rhs_, k1_); | 198 | | | 199 | | // 2nd stage | 200 | 57 | temp_var_ = g21 * k1_; | 201 | 57 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 202 | 57 | temp_rhs_ *= step_size; | 203 | 57 | temp_var_ = current + step_size * (a21 * k1_); | 204 | 57 | problem().evaluate_on(time + b2 * step_size, temp_var_, | 205 | 57 | evaluation_type{.diff_coeff = true}); | 206 | 57 | temp_rhs_ += problem().diff_coeff(); | 207 | 57 | equation_solver().add_time_derivative_term(step_size, g2, temp_rhs_); | 208 | 57 | equation_solver().solve(temp_rhs_, k2_); | 209 | | | 210 | | // 3rd stage | 211 | 57 | temp_var_ = g31 * k1_ + g32 * k2_; | 212 | 57 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 213 | 57 | temp_rhs_ *= step_size; | 214 | 57 | temp_var_ = current + step_size * (a31 * k1_ + a32 * k2_); | 215 | 57 | problem().evaluate_on(time + b3 * step_size, temp_var_, | 216 | 57 | evaluation_type{.diff_coeff = true}); | 217 | 57 | temp_rhs_ += problem().diff_coeff(); | 218 | 57 | equation_solver().add_time_derivative_term(step_size, g3, temp_rhs_); | 219 | 57 | equation_solver().solve(temp_rhs_, k3_); | 220 | | | 221 | | // 4th stage | 222 | 57 | temp_var_ = g41 * k1_ + g42 * k2_ + g43 * k3_; | 223 | 57 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 224 | 57 | temp_rhs_ *= step_size; | 225 | 57 | temp_var_ = current + step_size * (a41 * k1_ + a42 * k2_ + a43 * k3_); | 226 | 57 | problem().evaluate_on(time + b4 * step_size, temp_var_, | 227 | 57 | evaluation_type{.diff_coeff = true}); | 228 | 57 | temp_rhs_ += problem().diff_coeff(); | 229 | 57 | equation_solver().add_time_derivative_term(step_size, g4, temp_rhs_); | 230 | 57 | equation_solver().solve(temp_rhs_, k4_); | 231 | | | 232 | | // 5th stage | 233 | 57 | temp_var_ = g51 * k1_ + g52 * k2_ + g53 * k3_ + g54 * k4_; | 234 | 57 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 235 | 57 | temp_rhs_ *= step_size; | 236 | 57 | temp_var_ = current + | 237 | 57 | step_size * (a51 * k1_ + a52 * k2_ + a53 * k3_ + a54 * k4_); | 238 | 57 | problem().evaluate_on(time + b5 * step_size, temp_var_, | 239 | 57 | evaluation_type{.diff_coeff = true}); | 240 | 57 | temp_rhs_ += problem().diff_coeff(); | 241 | 57 | equation_solver().add_time_derivative_term(step_size, g5, temp_rhs_); | 242 | 57 | equation_solver().solve(temp_rhs_, k5_); | 243 | | | 244 | | // 6th stage | 245 | 57 | temp_var_ = g61 * k1_ + g62 * k2_ + g63 * k3_ + g64 * k4_ + g65 * k5_; | 246 | 57 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 247 | 57 | temp_rhs_ *= step_size; | 248 | 57 | temp_var_ = current + | 249 | 57 | step_size * | 250 | 57 | (a61 * k1_ + a62 * k2_ + a63 * k3_ + a64 * k4_ + a65 * k5_); | 251 | 57 | problem().evaluate_on(time + b6 * step_size, temp_var_, | 252 | 57 | evaluation_type{.diff_coeff = true}); | 253 | 57 | temp_rhs_ += problem().diff_coeff(); | 254 | 57 | equation_solver().add_time_derivative_term(step_size, g6, temp_rhs_); | 255 | 57 | equation_solver().solve(temp_rhs_, k6_); | 256 | | | 257 | 57 | estimate = current + | 258 | 57 | step_size * | 259 | 57 | (c1 * k1_ + c2 * k2_ + c3 * k3_ + c4 * k4_ + c5 * k5_ + | 260 | 57 | c6 * k6_); | 261 | 57 | error = step_size * | 262 | 57 | (ce1 * k1_ + ce2 * k2_ + ce3 * k3_ + ce4 * k4_ + ce5 * k5_ + | 263 | 57 | ce6 * k6_); | 264 | 57 | } |
_ZN11num_collect3ode10rosenbrock15rodaspr_formulaIN16num_prob_collect3ode32external_force_vibration_problemENS1_29lu_rosenbrock_equation_solverIS5_EEE13step_embeddedEddRKN5Eigen6MatrixIdLi2ELi1ELi0ELi2ELi1EEERSB_SE_ Line | Count | Source | 190 | 46 | variable_type& error) { | 191 | 46 | equation_solver().evaluate_and_update_jacobian( | 192 | 46 | problem(), time, step_size, current); | 193 | | | 194 | | // 1st stage | 195 | 46 | temp_rhs_ = problem().diff_coeff(); | 196 | 46 | equation_solver().add_time_derivative_term(step_size, g1, temp_rhs_); | 197 | 46 | equation_solver().solve(temp_rhs_, k1_); | 198 | | | 199 | | // 2nd stage | 200 | 46 | temp_var_ = g21 * k1_; | 201 | 46 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 202 | 46 | temp_rhs_ *= step_size; | 203 | 46 | temp_var_ = current + step_size * (a21 * k1_); | 204 | 46 | problem().evaluate_on(time + b2 * step_size, temp_var_, | 205 | 46 | evaluation_type{.diff_coeff = true}); | 206 | 46 | temp_rhs_ += problem().diff_coeff(); | 207 | 46 | equation_solver().add_time_derivative_term(step_size, g2, temp_rhs_); | 208 | 46 | equation_solver().solve(temp_rhs_, k2_); | 209 | | | 210 | | // 3rd stage | 211 | 46 | temp_var_ = g31 * k1_ + g32 * k2_; | 212 | 46 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 213 | 46 | temp_rhs_ *= step_size; | 214 | 46 | temp_var_ = current + step_size * (a31 * k1_ + a32 * k2_); | 215 | 46 | problem().evaluate_on(time + b3 * step_size, temp_var_, | 216 | 46 | evaluation_type{.diff_coeff = true}); | 217 | 46 | temp_rhs_ += problem().diff_coeff(); | 218 | 46 | equation_solver().add_time_derivative_term(step_size, g3, temp_rhs_); | 219 | 46 | equation_solver().solve(temp_rhs_, k3_); | 220 | | | 221 | | // 4th stage | 222 | 46 | temp_var_ = g41 * k1_ + g42 * k2_ + g43 * k3_; | 223 | 46 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 224 | 46 | temp_rhs_ *= step_size; | 225 | 46 | temp_var_ = current + step_size * (a41 * k1_ + a42 * k2_ + a43 * k3_); | 226 | 46 | problem().evaluate_on(time + b4 * step_size, temp_var_, | 227 | 46 | evaluation_type{.diff_coeff = true}); | 228 | 46 | temp_rhs_ += problem().diff_coeff(); | 229 | 46 | equation_solver().add_time_derivative_term(step_size, g4, temp_rhs_); | 230 | 46 | equation_solver().solve(temp_rhs_, k4_); | 231 | | | 232 | | // 5th stage | 233 | 46 | temp_var_ = g51 * k1_ + g52 * k2_ + g53 * k3_ + g54 * k4_; | 234 | 46 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 235 | 46 | temp_rhs_ *= step_size; | 236 | 46 | temp_var_ = current + | 237 | 46 | step_size * (a51 * k1_ + a52 * k2_ + a53 * k3_ + a54 * k4_); | 238 | 46 | problem().evaluate_on(time + b5 * step_size, temp_var_, | 239 | 46 | evaluation_type{.diff_coeff = true}); | 240 | 46 | temp_rhs_ += problem().diff_coeff(); | 241 | 46 | equation_solver().add_time_derivative_term(step_size, g5, temp_rhs_); | 242 | 46 | equation_solver().solve(temp_rhs_, k5_); | 243 | | | 244 | | // 6th stage | 245 | 46 | temp_var_ = g61 * k1_ + g62 * k2_ + g63 * k3_ + g64 * k4_ + g65 * k5_; | 246 | 46 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 247 | 46 | temp_rhs_ *= step_size; | 248 | 46 | temp_var_ = current + | 249 | 46 | step_size * | 250 | 46 | (a61 * k1_ + a62 * k2_ + a63 * k3_ + a64 * k4_ + a65 * k5_); | 251 | 46 | problem().evaluate_on(time + b6 * step_size, temp_var_, | 252 | 46 | evaluation_type{.diff_coeff = true}); | 253 | 46 | temp_rhs_ += problem().diff_coeff(); | 254 | 46 | equation_solver().add_time_derivative_term(step_size, g6, temp_rhs_); | 255 | 46 | equation_solver().solve(temp_rhs_, k6_); | 256 | | | 257 | 46 | estimate = current + | 258 | 46 | step_size * | 259 | 46 | (c1 * k1_ + c2 * k2_ + c3 * k3_ + c4 * k4_ + c5 * k5_ + | 260 | 46 | c6 * k6_); | 261 | 46 | error = step_size * | 262 | 46 | (ce1 * k1_ + ce2 * k2_ + ce3 * k3_ + ce4 * k4_ + ce5 * k5_ + | 263 | 46 | ce6 * k6_); | 264 | 46 | } |
_ZN11num_collect3ode10rosenbrock15rodaspr_formulaIN16num_prob_collect3ode28implicit_exponential_problemENS1_33scalar_rosenbrock_equation_solverIS5_EEE13step_embeddedEddRKdRdSB_ Line | Count | Source | 190 | 46 | variable_type& error) { | 191 | 46 | equation_solver().evaluate_and_update_jacobian( | 192 | 46 | problem(), time, step_size, current); | 193 | | | 194 | | // 1st stage | 195 | 46 | temp_rhs_ = problem().diff_coeff(); | 196 | 46 | equation_solver().add_time_derivative_term(step_size, g1, temp_rhs_); | 197 | 46 | equation_solver().solve(temp_rhs_, k1_); | 198 | | | 199 | | // 2nd stage | 200 | 46 | temp_var_ = g21 * k1_; | 201 | 46 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 202 | 46 | temp_rhs_ *= step_size; | 203 | 46 | temp_var_ = current + step_size * (a21 * k1_); | 204 | 46 | problem().evaluate_on(time + b2 * step_size, temp_var_, | 205 | 46 | evaluation_type{.diff_coeff = true}); | 206 | 46 | temp_rhs_ += problem().diff_coeff(); | 207 | 46 | equation_solver().add_time_derivative_term(step_size, g2, temp_rhs_); | 208 | 46 | equation_solver().solve(temp_rhs_, k2_); | 209 | | | 210 | | // 3rd stage | 211 | 46 | temp_var_ = g31 * k1_ + g32 * k2_; | 212 | 46 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 213 | 46 | temp_rhs_ *= step_size; | 214 | 46 | temp_var_ = current + step_size * (a31 * k1_ + a32 * k2_); | 215 | 46 | problem().evaluate_on(time + b3 * step_size, temp_var_, | 216 | 46 | evaluation_type{.diff_coeff = true}); | 217 | 46 | temp_rhs_ += problem().diff_coeff(); | 218 | 46 | equation_solver().add_time_derivative_term(step_size, g3, temp_rhs_); | 219 | 46 | equation_solver().solve(temp_rhs_, k3_); | 220 | | | 221 | | // 4th stage | 222 | 46 | temp_var_ = g41 * k1_ + g42 * k2_ + g43 * k3_; | 223 | 46 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 224 | 46 | temp_rhs_ *= step_size; | 225 | 46 | temp_var_ = current + step_size * (a41 * k1_ + a42 * k2_ + a43 * k3_); | 226 | 46 | problem().evaluate_on(time + b4 * step_size, temp_var_, | 227 | 46 | evaluation_type{.diff_coeff = true}); | 228 | 46 | temp_rhs_ += problem().diff_coeff(); | 229 | 46 | equation_solver().add_time_derivative_term(step_size, g4, temp_rhs_); | 230 | 46 | equation_solver().solve(temp_rhs_, k4_); | 231 | | | 232 | | // 5th stage | 233 | 46 | temp_var_ = g51 * k1_ + g52 * k2_ + g53 * k3_ + g54 * k4_; | 234 | 46 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 235 | 46 | temp_rhs_ *= step_size; | 236 | 46 | temp_var_ = current + | 237 | 46 | step_size * (a51 * k1_ + a52 * k2_ + a53 * k3_ + a54 * k4_); | 238 | 46 | problem().evaluate_on(time + b5 * step_size, temp_var_, | 239 | 46 | evaluation_type{.diff_coeff = true}); | 240 | 46 | temp_rhs_ += problem().diff_coeff(); | 241 | 46 | equation_solver().add_time_derivative_term(step_size, g5, temp_rhs_); | 242 | 46 | equation_solver().solve(temp_rhs_, k5_); | 243 | | | 244 | | // 6th stage | 245 | 46 | temp_var_ = g61 * k1_ + g62 * k2_ + g63 * k3_ + g64 * k4_ + g65 * k5_; | 246 | 46 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 247 | 46 | temp_rhs_ *= step_size; | 248 | 46 | temp_var_ = current + | 249 | 46 | step_size * | 250 | 46 | (a61 * k1_ + a62 * k2_ + a63 * k3_ + a64 * k4_ + a65 * k5_); | 251 | 46 | problem().evaluate_on(time + b6 * step_size, temp_var_, | 252 | 46 | evaluation_type{.diff_coeff = true}); | 253 | 46 | temp_rhs_ += problem().diff_coeff(); | 254 | 46 | equation_solver().add_time_derivative_term(step_size, g6, temp_rhs_); | 255 | 46 | equation_solver().solve(temp_rhs_, k6_); | 256 | | | 257 | 46 | estimate = current + | 258 | 46 | step_size * | 259 | 46 | (c1 * k1_ + c2 * k2_ + c3 * k3_ + c4 * k4_ + c5 * k5_ + | 260 | 46 | c6 * k6_); | 261 | 46 | error = step_size * | 262 | 46 | (ce1 * k1_ + ce2 * k2_ + ce3 * k3_ + ce4 * k4_ + ce5 * k5_ + | 263 | 46 | ce6 * k6_); | 264 | 46 | } |
_ZN11num_collect3ode10rosenbrock15rodaspr_formulaIN16num_prob_collect3ode21implicit_kaps_problemENS1_29lu_rosenbrock_equation_solverIS5_EEE13step_embeddedEddRKN5Eigen6MatrixIdLi2ELi1ELi0ELi2ELi1EEERSB_SE_ Line | Count | Source | 190 | 100 | variable_type& error) { | 191 | 100 | equation_solver().evaluate_and_update_jacobian( | 192 | 100 | problem(), time, step_size, current); | 193 | | | 194 | | // 1st stage | 195 | 100 | temp_rhs_ = problem().diff_coeff(); | 196 | 100 | equation_solver().add_time_derivative_term(step_size, g1, temp_rhs_); | 197 | 100 | equation_solver().solve(temp_rhs_, k1_); | 198 | | | 199 | | // 2nd stage | 200 | 100 | temp_var_ = g21 * k1_; | 201 | 100 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 202 | 100 | temp_rhs_ *= step_size; | 203 | 100 | temp_var_ = current + step_size * (a21 * k1_); | 204 | 100 | problem().evaluate_on(time + b2 * step_size, temp_var_, | 205 | 100 | evaluation_type{.diff_coeff = true}); | 206 | 100 | temp_rhs_ += problem().diff_coeff(); | 207 | 100 | equation_solver().add_time_derivative_term(step_size, g2, temp_rhs_); | 208 | 100 | equation_solver().solve(temp_rhs_, k2_); | 209 | | | 210 | | // 3rd stage | 211 | 100 | temp_var_ = g31 * k1_ + g32 * k2_; | 212 | 100 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 213 | 100 | temp_rhs_ *= step_size; | 214 | 100 | temp_var_ = current + step_size * (a31 * k1_ + a32 * k2_); | 215 | 100 | problem().evaluate_on(time + b3 * step_size, temp_var_, | 216 | 100 | evaluation_type{.diff_coeff = true}); | 217 | 100 | temp_rhs_ += problem().diff_coeff(); | 218 | 100 | equation_solver().add_time_derivative_term(step_size, g3, temp_rhs_); | 219 | 100 | equation_solver().solve(temp_rhs_, k3_); | 220 | | | 221 | | // 4th stage | 222 | 100 | temp_var_ = g41 * k1_ + g42 * k2_ + g43 * k3_; | 223 | 100 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 224 | 100 | temp_rhs_ *= step_size; | 225 | 100 | temp_var_ = current + step_size * (a41 * k1_ + a42 * k2_ + a43 * k3_); | 226 | 100 | problem().evaluate_on(time + b4 * step_size, temp_var_, | 227 | 100 | evaluation_type{.diff_coeff = true}); | 228 | 100 | temp_rhs_ += problem().diff_coeff(); | 229 | 100 | equation_solver().add_time_derivative_term(step_size, g4, temp_rhs_); | 230 | 100 | equation_solver().solve(temp_rhs_, k4_); | 231 | | | 232 | | // 5th stage | 233 | 100 | temp_var_ = g51 * k1_ + g52 * k2_ + g53 * k3_ + g54 * k4_; | 234 | 100 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 235 | 100 | temp_rhs_ *= step_size; | 236 | 100 | temp_var_ = current + | 237 | 100 | step_size * (a51 * k1_ + a52 * k2_ + a53 * k3_ + a54 * k4_); | 238 | 100 | problem().evaluate_on(time + b5 * step_size, temp_var_, | 239 | 100 | evaluation_type{.diff_coeff = true}); | 240 | 100 | temp_rhs_ += problem().diff_coeff(); | 241 | 100 | equation_solver().add_time_derivative_term(step_size, g5, temp_rhs_); | 242 | 100 | equation_solver().solve(temp_rhs_, k5_); | 243 | | | 244 | | // 6th stage | 245 | 100 | temp_var_ = g61 * k1_ + g62 * k2_ + g63 * k3_ + g64 * k4_ + g65 * k5_; | 246 | 100 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 247 | 100 | temp_rhs_ *= step_size; | 248 | 100 | temp_var_ = current + | 249 | 100 | step_size * | 250 | 100 | (a61 * k1_ + a62 * k2_ + a63 * k3_ + a64 * k4_ + a65 * k5_); | 251 | 100 | problem().evaluate_on(time + b6 * step_size, temp_var_, | 252 | 100 | evaluation_type{.diff_coeff = true}); | 253 | 100 | temp_rhs_ += problem().diff_coeff(); | 254 | 100 | equation_solver().add_time_derivative_term(step_size, g6, temp_rhs_); | 255 | 100 | equation_solver().solve(temp_rhs_, k6_); | 256 | | | 257 | 100 | estimate = current + | 258 | 100 | step_size * | 259 | 100 | (c1 * k1_ + c2 * k2_ + c3 * k3_ + c4 * k4_ + c5 * k5_ + | 260 | 100 | c6 * k6_); | 261 | 100 | error = step_size * | 262 | 100 | (ce1 * k1_ + ce2 * k2_ + ce3 * k3_ + ce4 * k4_ + ce5 * k5_ + | 263 | 100 | ce6 * k6_); | 264 | 100 | } |
_ZN11num_collect3ode10rosenbrock15rodaspr_formulaIN16num_prob_collect3ode33no_jacobian_implicit_kaps_problemENS1_35bicgstab_rosenbrock_equation_solverIS5_EEE13step_embeddedEddRKN5Eigen6MatrixIdLi2ELi1ELi0ELi2ELi1EEERSB_SE_ Line | Count | Source | 190 | 100 | variable_type& error) { | 191 | 100 | equation_solver().evaluate_and_update_jacobian( | 192 | 100 | problem(), time, step_size, current); | 193 | | | 194 | | // 1st stage | 195 | 100 | temp_rhs_ = problem().diff_coeff(); | 196 | 100 | equation_solver().add_time_derivative_term(step_size, g1, temp_rhs_); | 197 | 100 | equation_solver().solve(temp_rhs_, k1_); | 198 | | | 199 | | // 2nd stage | 200 | 100 | temp_var_ = g21 * k1_; | 201 | 100 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 202 | 100 | temp_rhs_ *= step_size; | 203 | 100 | temp_var_ = current + step_size * (a21 * k1_); | 204 | 100 | problem().evaluate_on(time + b2 * step_size, temp_var_, | 205 | 100 | evaluation_type{.diff_coeff = true}); | 206 | 100 | temp_rhs_ += problem().diff_coeff(); | 207 | 100 | equation_solver().add_time_derivative_term(step_size, g2, temp_rhs_); | 208 | 100 | equation_solver().solve(temp_rhs_, k2_); | 209 | | | 210 | | // 3rd stage | 211 | 100 | temp_var_ = g31 * k1_ + g32 * k2_; | 212 | 100 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 213 | 100 | temp_rhs_ *= step_size; | 214 | 100 | temp_var_ = current + step_size * (a31 * k1_ + a32 * k2_); | 215 | 100 | problem().evaluate_on(time + b3 * step_size, temp_var_, | 216 | 100 | evaluation_type{.diff_coeff = true}); | 217 | 100 | temp_rhs_ += problem().diff_coeff(); | 218 | 100 | equation_solver().add_time_derivative_term(step_size, g3, temp_rhs_); | 219 | 100 | equation_solver().solve(temp_rhs_, k3_); | 220 | | | 221 | | // 4th stage | 222 | 100 | temp_var_ = g41 * k1_ + g42 * k2_ + g43 * k3_; | 223 | 100 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 224 | 100 | temp_rhs_ *= step_size; | 225 | 100 | temp_var_ = current + step_size * (a41 * k1_ + a42 * k2_ + a43 * k3_); | 226 | 100 | problem().evaluate_on(time + b4 * step_size, temp_var_, | 227 | 100 | evaluation_type{.diff_coeff = true}); | 228 | 100 | temp_rhs_ += problem().diff_coeff(); | 229 | 100 | equation_solver().add_time_derivative_term(step_size, g4, temp_rhs_); | 230 | 100 | equation_solver().solve(temp_rhs_, k4_); | 231 | | | 232 | | // 5th stage | 233 | 100 | temp_var_ = g51 * k1_ + g52 * k2_ + g53 * k3_ + g54 * k4_; | 234 | 100 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 235 | 100 | temp_rhs_ *= step_size; | 236 | 100 | temp_var_ = current + | 237 | 100 | step_size * (a51 * k1_ + a52 * k2_ + a53 * k3_ + a54 * k4_); | 238 | 100 | problem().evaluate_on(time + b5 * step_size, temp_var_, | 239 | 100 | evaluation_type{.diff_coeff = true}); | 240 | 100 | temp_rhs_ += problem().diff_coeff(); | 241 | 100 | equation_solver().add_time_derivative_term(step_size, g5, temp_rhs_); | 242 | 100 | equation_solver().solve(temp_rhs_, k5_); | 243 | | | 244 | | // 6th stage | 245 | 100 | temp_var_ = g61 * k1_ + g62 * k2_ + g63 * k3_ + g64 * k4_ + g65 * k5_; | 246 | 100 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 247 | 100 | temp_rhs_ *= step_size; | 248 | 100 | temp_var_ = current + | 249 | 100 | step_size * | 250 | 100 | (a61 * k1_ + a62 * k2_ + a63 * k3_ + a64 * k4_ + a65 * k5_); | 251 | 100 | problem().evaluate_on(time + b6 * step_size, temp_var_, | 252 | 100 | evaluation_type{.diff_coeff = true}); | 253 | 100 | temp_rhs_ += problem().diff_coeff(); | 254 | 100 | equation_solver().add_time_derivative_term(step_size, g6, temp_rhs_); | 255 | 100 | equation_solver().solve(temp_rhs_, k6_); | 256 | | | 257 | 100 | estimate = current + | 258 | 100 | step_size * | 259 | 100 | (c1 * k1_ + c2 * k2_ + c3 * k3_ + c4 * k4_ + c5 * k5_ + | 260 | 100 | c6 * k6_); | 261 | 100 | error = step_size * | 262 | 100 | (ce1 * k1_ + ce2 * k2_ + ce3 * k3_ + ce4 * k4_ + ce5 * k5_ + | 263 | 100 | ce6 * k6_); | 264 | 100 | } |
_ZN11num_collect3ode10rosenbrock15rodaspr_formulaIN16num_prob_collect3ode23spring_movement_problemENS1_29lu_rosenbrock_equation_solverIS5_EEE13step_embeddedEddRKN5Eigen6MatrixIdLi2ELi1ELi0ELi2ELi1EEERSB_SE_ Line | Count | Source | 190 | 46 | variable_type& error) { | 191 | 46 | equation_solver().evaluate_and_update_jacobian( | 192 | 46 | problem(), time, step_size, current); | 193 | | | 194 | | // 1st stage | 195 | 46 | temp_rhs_ = problem().diff_coeff(); | 196 | 46 | equation_solver().add_time_derivative_term(step_size, g1, temp_rhs_); | 197 | 46 | equation_solver().solve(temp_rhs_, k1_); | 198 | | | 199 | | // 2nd stage | 200 | 46 | temp_var_ = g21 * k1_; | 201 | 46 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 202 | 46 | temp_rhs_ *= step_size; | 203 | 46 | temp_var_ = current + step_size * (a21 * k1_); | 204 | 46 | problem().evaluate_on(time + b2 * step_size, temp_var_, | 205 | 46 | evaluation_type{.diff_coeff = true}); | 206 | 46 | temp_rhs_ += problem().diff_coeff(); | 207 | 46 | equation_solver().add_time_derivative_term(step_size, g2, temp_rhs_); | 208 | 46 | equation_solver().solve(temp_rhs_, k2_); | 209 | | | 210 | | // 3rd stage | 211 | 46 | temp_var_ = g31 * k1_ + g32 * k2_; | 212 | 46 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 213 | 46 | temp_rhs_ *= step_size; | 214 | 46 | temp_var_ = current + step_size * (a31 * k1_ + a32 * k2_); | 215 | 46 | problem().evaluate_on(time + b3 * step_size, temp_var_, | 216 | 46 | evaluation_type{.diff_coeff = true}); | 217 | 46 | temp_rhs_ += problem().diff_coeff(); | 218 | 46 | equation_solver().add_time_derivative_term(step_size, g3, temp_rhs_); | 219 | 46 | equation_solver().solve(temp_rhs_, k3_); | 220 | | | 221 | | // 4th stage | 222 | 46 | temp_var_ = g41 * k1_ + g42 * k2_ + g43 * k3_; | 223 | 46 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 224 | 46 | temp_rhs_ *= step_size; | 225 | 46 | temp_var_ = current + step_size * (a41 * k1_ + a42 * k2_ + a43 * k3_); | 226 | 46 | problem().evaluate_on(time + b4 * step_size, temp_var_, | 227 | 46 | evaluation_type{.diff_coeff = true}); | 228 | 46 | temp_rhs_ += problem().diff_coeff(); | 229 | 46 | equation_solver().add_time_derivative_term(step_size, g4, temp_rhs_); | 230 | 46 | equation_solver().solve(temp_rhs_, k4_); | 231 | | | 232 | | // 5th stage | 233 | 46 | temp_var_ = g51 * k1_ + g52 * k2_ + g53 * k3_ + g54 * k4_; | 234 | 46 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 235 | 46 | temp_rhs_ *= step_size; | 236 | 46 | temp_var_ = current + | 237 | 46 | step_size * (a51 * k1_ + a52 * k2_ + a53 * k3_ + a54 * k4_); | 238 | 46 | problem().evaluate_on(time + b5 * step_size, temp_var_, | 239 | 46 | evaluation_type{.diff_coeff = true}); | 240 | 46 | temp_rhs_ += problem().diff_coeff(); | 241 | 46 | equation_solver().add_time_derivative_term(step_size, g5, temp_rhs_); | 242 | 46 | equation_solver().solve(temp_rhs_, k5_); | 243 | | | 244 | | // 6th stage | 245 | 46 | temp_var_ = g61 * k1_ + g62 * k2_ + g63 * k3_ + g64 * k4_ + g65 * k5_; | 246 | 46 | equation_solver().apply_jacobian(temp_var_, temp_rhs_); | 247 | 46 | temp_rhs_ *= step_size; | 248 | 46 | temp_var_ = current + | 249 | 46 | step_size * | 250 | 46 | (a61 * k1_ + a62 * k2_ + a63 * k3_ + a64 * k4_ + a65 * k5_); | 251 | 46 | problem().evaluate_on(time + b6 * step_size, temp_var_, | 252 | 46 | evaluation_type{.diff_coeff = true}); | 253 | 46 | temp_rhs_ += problem().diff_coeff(); | 254 | 46 | equation_solver().add_time_derivative_term(step_size, g6, temp_rhs_); | 255 | 46 | equation_solver().solve(temp_rhs_, k6_); | 256 | | | 257 | 46 | estimate = current + | 258 | 46 | step_size * | 259 | 46 | (c1 * k1_ + c2 * k2_ + c3 * k3_ + c4 * k4_ + c5 * k5_ + | 260 | 46 | c6 * k6_); | 261 | 46 | error = step_size * | 262 | 46 | (ce1 * k1_ + ce2 * k2_ + ce3 * k3_ + ce4 * k4_ + ce5 * k5_ + | 263 | 46 | ce6 * k6_); | 264 | 46 | } |
|
265 | | |
266 | | private: |
267 | | /*! |
268 | | * \name Intermediate variables. |
269 | | */ |
270 | | ///@{ |
271 | | //! Intermediate variable. |
272 | | variable_type k1_{}; |
273 | | variable_type k2_{}; |
274 | | variable_type k3_{}; |
275 | | variable_type k4_{}; |
276 | | variable_type k5_{}; |
277 | | variable_type k6_{}; |
278 | | ///@} |
279 | | |
280 | | //! Temporary variable. |
281 | | variable_type temp_var_{}; |
282 | | |
283 | | //! Temporary right-hand-side vector. |
284 | | variable_type temp_rhs_{}; |
285 | | }; |
286 | | |
287 | | /*! |
288 | | * \brief Class of solver using RODASPR formula \cite Rang2015. |
289 | | * |
290 | | * \tparam Problem Type of problem. |
291 | | */ |
292 | | template <concepts::problem Problem> |
293 | | using rodaspr_solver = embedded_solver<rodaspr_formula<Problem>>; |
294 | | |
295 | | } // namespace num_collect::ode::rosenbrock |