-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
40 lines (28 loc) · 985 Bytes
/
main.cpp
File metadata and controls
40 lines (28 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <cmath> //to use exp and trigonometry funcions
#include "cauchyProblem.hpp" // Class to handle Cauchy problems
using ODE = std::function<double(double,double)>;
int main(){
// ODE of the challenge
const ODE ChallengeOde = [](double t, double y){return -t*exp(-y);};
//Other ODE's
const ODE odeTest1 = [](double t, double y){return 2*y;};
const ODE odeTest2 = [](double t, double y){return cos(3*t) + y/tan(2*t);};
//Declaration and initialization of Cauchy problems
CauchyProblem challengeProblem(ChallengeOde);
// (ode, initial value, initial time, end time)
CauchyProblem testCP1(odeTest1, 2, 1.2, 3);
CauchyProblem testCP2(odeTest2, 0, 0, 6);
//Set resolution parameters
testCP1.SetNumberOfSteps(200);
testCP1.SetTheta(0.2); //set theta = 0.2
testCP2.SetNumberOfSteps(10000);
//Plots
challengeProblem.plot();
testCP1.plot();
testCP2.plot();
//Print solution
challengeProblem.print();
//Save solution
challengeProblem.save();
return(0);
}