Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aoshimash/hermite
A hermite integrator for planetary N-body simulation
https://github.com/aoshimash/hermite
astrophysics cpp n-body
Last synced: 10 days ago
JSON representation
A hermite integrator for planetary N-body simulation
- Host: GitHub
- URL: https://github.com/aoshimash/hermite
- Owner: aoshimash
- Created: 2019-03-12T08:06:59.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-09-08T12:53:30.000Z (over 5 years ago)
- Last Synced: 2024-10-26T17:24:21.929Z (about 2 months ago)
- Topics: astrophysics, cpp, n-body
- Language: C++
- Homepage:
- Size: 500 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# hermite
Hermite integrator for planetary N-body simulation
## Usage
### Test
``` sh
$ cd {PROJECT_ROOT}/build
$ cmake ..
$ make
$ ctest -V
```### Demo
``` sh
$ cd {PROJECT_ROOT}/build
$ cmake ..
$ make
$ cd demo
$ ./twobody
$ jupyter-lab --notebook-dir .
```### Example
``` cpp
#include "hermite.h"
#include "cs.h"
#include
#include
#include
#include
#include
#include// Parameters
std::size_t rep = 3;
int log2_dt_max = -5;
int log2_dt_min = -10;
double eps = 0.0;
double alpha = 1.0;
double eta_s = 0.01;
double eta = 0.03;// Calculate initial position and velocity from orbital elements
std::valarray mass = {1.0, 1e-3};
cs::OrbitalElement oelem0(1.0, 0.1, M_PI, 0.0, 0.0, M_PI);
vector init_oelems {oelem0};
vector> pos_init(mass.size(), valarray(cs::DIM));
vector> vel_init(mass.size(), valarray(cs::DIM));
cs::ConvertOelemToCartesian(mass, init_oelems, &init_pos, &init_vel);// Set solver
hermite::Hermite4thSolver h4sol(rep, exp_dt_max, exp_dt_min, eps, alpha, eta_s, eta);
h4sol.set_mass(mass);
h4sol.set_pos(init_pos);
h4sol.set_vel(init_vel);
h4sol.setup();// Set output file
ofstream ofs(filename);
if (!ofs) {
cerr << "File Open Error: \"" << filename << "\"" << endl;
exit(EX_CANTCREAT);
}// Start orbital calculation
double t = 0.0;
double t_stop = 10.0;
auto pos = h4sol.get_pos();
auto vel = h4sol.get_vel();while (t < t_stop) {
cs::WritePosVel(t, pos, vel, &ofs);
h4sol.step_forward(&t);
pos = h4sol.get_pos();
vel = h4sol.get_vel();
}
```## References
- Kokubo, E., Makino, J., 2004, PASJ, 56, 861
- Kokubo, E., Yoshinaga, K., Makino, J., 1998, MNRAS, 297, 1067