rk5adaptive.cc
Go to the documentation of this file.
1 
8 #include <iostream>
9 #include <iomanip>
10 #include <cmath>
11 #include <boost/program_options.hpp>
12 
13 #include <utl/RK5ODEIntegrator.h>
14 
15 #include "HarmonicOscillator.h"
16 
17 using namespace std;
18 namespace po = boost::program_options;
19 using namespace utl;
20 
21 
22 int
23 main(int argc, char* argv[])
24 {
25  double dx;
26  double accuracy;
27  double x1;
28 
29  po::options_description desc("Allowed options");
30  desc.add_options()
31  ("help,h", "produce help message")
32  ("dx,d", po::value<double>(&dx)->default_value(0.5), "step size")
33  ("x1,1", po::value<double>(&x1)->default_value(1000), "end point")
34  ("accuracy,a", po::value<double>(&accuracy)->default_value(1e-3),
35  "variable step accuracy")
36  ;
37 
38  po::variables_map vm;
39  po::store(po::parse_command_line(argc, argv, desc), vm);
40  po::notify(vm);
41 
42  if (vm.count("help")) {
43  cout << desc << '\n';
44  return EXIT_SUCCESS;
45  }
46 
47  typedef double Vector[2];
48 
49  const double m = 1;
50  const double k = 1;
51  HarmonicOscillator ho(m, k);
52 
54 
55  const double x0 = 0;
56  const Vector y0 = { 1, 0 };
57 
58  cout << setprecision(16);
59 
61  rk5.AdaptiveBegin(x0, dx, y0, accuracy);
62  it.GetX() <= x1; ++it)
63 
64  cout << it.GetX() << ' '
65  << it.GetY()[0] << ' '
66  << it.GetY()[1] << '\n';
67 
68  return EXIT_SUCCESS;
69 }
int main(int argc, char *argv[])
Definition: DBSync.cc:58
AdaptiveRK5Iterator< DerivativeFunctor, VectorType > AdaptiveBegin(const double x, const double dx, const VectorType &y, const double accuracy=1e-5)
Vector object.
Definition: Vector.h:30
constexpr double m
Definition: AugerUnits.h:121

, generated on Tue Sep 26 2023.