106 lines
No EOL
3.3 KiB
C++
106 lines
No EOL
3.3 KiB
C++
#include <algorithm>
|
|
#include <cstdio>
|
|
#include <vector>
|
|
#include "double3.h"
|
|
|
|
struct Bbh_gravity {
|
|
double pot1, pot2;
|
|
double3 a1, a2, adot1, adot2, a_pn1[7], a_pn2[7], adot_pn1[7], adot_pn2[7];
|
|
double spin1[3], spin2[3];
|
|
};
|
|
|
|
class Black_hole_physics {
|
|
public:
|
|
Black_hole_physics()
|
|
: count(0), c(0) {}
|
|
Black_hole_physics(const double m1, const double m2, const int myRank, const int rootRank)
|
|
: m1(m1), m2(m2), count(2), c(0), myRank(myRank), rootRank(rootRank) {}
|
|
void set_post_newtonian(const double c, const int pn_usage[7])
|
|
{
|
|
this->c = c;
|
|
std::copy(pn_usage, pn_usage+7, this->pn_usage);
|
|
}
|
|
void set_spins(const double spin1[3], const double spin2[3])
|
|
{
|
|
std::copy(spin1, spin1+3, this->bbh_grav.spin1);
|
|
std::copy(spin2, spin2+3, this->bbh_grav.spin2);
|
|
}
|
|
void set_xv(const double3& x1, const double3& x2, const double3& v1, const double3& v2)
|
|
{
|
|
this->x1 = x1;
|
|
this->x2 = x2;
|
|
this->v1 = v1;
|
|
this->v2 = v2;
|
|
}
|
|
void set_softening(const double eps_old, const double eps_new)
|
|
{
|
|
this->eps_old = eps_old;
|
|
this->eps_new = eps_new;
|
|
}
|
|
void adjust_softening(
|
|
double& pot1, double& pot2,
|
|
double3& acc1, double3& acc2,
|
|
double3& jrk1, double3& jrk2);
|
|
|
|
void adjust_post_newtonian(
|
|
const double dt_bh, // pn_usage should be const
|
|
double3& acc1, double3& acc2,
|
|
double3& jrk1, double3& jrk2);
|
|
void write_bh_data(double time_cur, const std::vector<double> &m, const std::vector<double3> &x, const std::vector<double3> &v, const std::vector<double> &pot, double3 a[], double3 adot[], double dt[]);
|
|
public: //TODO make private
|
|
double m1, m2;
|
|
int count;
|
|
int myRank, rootRank;
|
|
double eps_old, eps_new;
|
|
double3 x1, v1, x2, v2;
|
|
double c;
|
|
int pn_usage[7];
|
|
Bbh_gravity bbh_grav;
|
|
};
|
|
|
|
class Write_bh_nb_data {
|
|
public:
|
|
Write_bh_nb_data(int nb, int smbh_count, int N, const std::vector<double> &m, const std::vector<double3> &x, const std::vector<double3> &v)
|
|
: nb(nb), smbh_count(smbh_count), N(N), m(m), x(x), v(v)
|
|
{
|
|
ind_sort.resize(N);
|
|
var_sort.resize(N);
|
|
out = fopen("bh_neighbors.dat", "w");
|
|
}
|
|
~Write_bh_nb_data()
|
|
{
|
|
fclose(out);
|
|
}
|
|
void operator()(double time_cur);
|
|
private:
|
|
int nb, smbh_count, N;
|
|
const std::vector<double> &m;
|
|
const std::vector<double3> &x, &v;
|
|
std::vector<int> ind_sort;
|
|
std::vector<double> var_sort;
|
|
FILE *out;
|
|
};
|
|
|
|
class Binary_smbh_influence_sphere_output {
|
|
public:
|
|
Binary_smbh_influence_sphere_output(double factor, int N, const std::vector<double> &m, const std::vector<double3> &x, const std::vector<double3> &v, const std::vector<double> &pot, double *dt)
|
|
: factor(factor), m(m), x(x), v(v), pot(pot), dt(dt)
|
|
{
|
|
inf_event.assign(N, 0);
|
|
out = fopen("bbh_inf.dat", "w");
|
|
}
|
|
|
|
~Binary_smbh_influence_sphere_output()
|
|
{
|
|
fclose(out);
|
|
}
|
|
void operator()(const std::vector<int>& ind_act, int n_act, double timesteps, double time_cur);
|
|
private:
|
|
double factor;
|
|
const std::vector<double> &pot;
|
|
const std::vector<double> &m;
|
|
double /**pot,*/ *dt;
|
|
const std::vector<double3> &x, &v;
|
|
std::vector<int> inf_event;
|
|
FILE *out;
|
|
}; |