5#ifndef CPPPROJCT_RUNGEKUTTASOLVER_H
6#define CPPPROJCT_RUNGEKUTTASOLVER_H
8#include "GeneralSolver.h"
10#include "../macros/macros.h"
13template <
typename Equation>
20 std::vector<double> &b,
21 std::vector<double> &c,
22 std::vector<double> &d,
25 std::vector<double> &RK1,
26 std::vector<double> &RK2,
27 std::vector<double> &RK3,
28 std::vector<double> &RK4,
34 std::vector<double> &b,
35 std::vector<double> &c,
36 std::vector<double> &d,
39 std::vector<double> &RK1,
44 std::vector<double> &b,
45 std::vector<double> &c,
46 std::vector<double> &d,
49 std::vector<double> &RK1,
50 std::vector<double> &RK2,
55 std::vector<double> &b,
56 std::vector<double> &c,
57 std::vector<double> &d,
60 std::vector<double> &RK1,
61 std::vector<double> &RK2,
62 std::vector<double> &RK3,
67 std::vector<double> &b,
68 std::vector<double> &c,
69 std::vector<double> &d,
72 std::vector<double> &RK1,
73 std::vector<double> &RK2,
74 std::vector<double> &RK3,
75 std::vector<double> &RK4,
81template <
typename Equation>
85 std::vector<double> &b,
86 std::vector<double> &c,
87 std::vector<double> &d,
90 std::vector<double> &RK1,
91 std::vector<double> &RK2,
92 std::vector<double> &RK3,
93 std::vector<double> &RK4,
98 answer = a + (*(P+0)) * h * RK1[0] +
99 (*(P+1)) * h * RK2[0] +
100 (*(P+2)) * h * RK3[0] +
101 (*(P+3)) * h * RK4[0];
104template <
typename Equation>
108 std::vector<double> &b,
109 std::vector<double> &c,
110 std::vector<double> &d,
113 std::vector<double> &RK1,
116 std::vector<double> T1={0},T2={1},T3={0},T4={1};
122 E.UpdateFlowSpecs(T1,T2,T3,T4,d.size());
125 RK1[0] = Specs.result;
130template <
typename Equation>
134 std::vector<double> &b,
135 std::vector<double> &c,
136 std::vector<double> &d,
139 std::vector<double> &RK1,
140 std::vector<double> &RK2,
143 std::vector<double> T1={0},T2={1},T3={0},T4={1};
146 T1[0] = h * RK1[0] / 2;
148 T3.resize(RK1.size()-1);
149 for (
int i=1; i<RK1.size(); ++i) T3[i-1] = h*RK1[i]/2;
151 E.UpdateFlowSpecs(T1,T2,T3,T4,d.size());
154 E.Field(t+h/2,a,b,c,d);
155 RK2[0] = Specs.result;
158template <
typename Equation>
162 std::vector<double> &b,
163 std::vector<double> &c,
164 std::vector<double> &d,
167 std::vector<double> &RK1,
168 std::vector<double> &RK2,
169 std::vector<double> &RK3,
173 std::vector<double> T1={0},T2={1},T3={0},T4={1};
176 T1[0] = h * RK2[0] / 2;
178 T3.resize(RK2.size()-1);
179 for (
int i=1; i<RK2.size(); ++i) T3[i-1] = h*RK2[i]/2;
181 E.UpdateFlowSpecs(T1,T2,T3,T4,d.size());
184 E.Field(t+h/2,a,b,c,d);
185 RK3[0] = Specs.result;
189template <
typename Equation>
193 std::vector<double> &b,
194 std::vector<double> &c,
195 std::vector<double> &d,
198 std::vector<double> &RK1,
199 std::vector<double> &RK2,
200 std::vector<double> &RK3,
201 std::vector<double> &RK4,
205 std::vector<double> T1={0},T2={1},T3={0},T4={1};
210 T3.resize(RK1.size()-1);
211 for (
int i=1; i<RK1.size(); ++i) T3[i-1] = h * RK3[i];
213 E.UpdateFlowSpecs(T1,T2,T3,T4,d.size());
216 E.Field(t+h,a,b,c,d);
217 RK4[0] = Specs.result;
Definition: RungeKuttaSolver.h:14
Definition: GeneralDifferentialEquation.h:15