Finished moving the BH stuff into their compilation unit
This commit is contained in:
parent
19ce85da88
commit
df5d89a0c8
4 changed files with 127 additions and 236 deletions
136
black_holes.cpp
136
black_holes.cpp
|
|
@ -2,12 +2,13 @@
|
|||
#include <numeric>
|
||||
#include "black_holes.h"
|
||||
|
||||
|
||||
// TODO do not include c files!
|
||||
#define SQR(x) ((x)*(x))
|
||||
/* BEGIN legacy inclusion */
|
||||
// I'm not going to touch this C file
|
||||
#define SQR(x) ((x)*(x))
|
||||
double L[3]; // needed in pn_bh_spin.c
|
||||
#include "n_bh.c"
|
||||
#include "pn_bh_spin.c"
|
||||
#undef SQR
|
||||
/* END legacy inclusion */
|
||||
|
||||
void two_body_gravity(
|
||||
const double m1, const double3 x1, const double3 v1,
|
||||
|
|
@ -32,55 +33,6 @@ void two_body_gravity(
|
|||
jrk2 = m1*(dv/r3 - RP*dx/r4);
|
||||
}
|
||||
|
||||
// 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, double m[], double3 x[], double3 v[], 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;
|
||||
// };
|
||||
|
||||
void Black_hole_physics::adjust_softening(
|
||||
double& pot1, double& pot2,
|
||||
double3& acc1, double3& acc2,
|
||||
|
|
@ -215,22 +167,12 @@ void Black_hole_physics::write_bh_data(double time_cur, double m[], double3 x[],
|
|||
fclose(out);
|
||||
}
|
||||
|
||||
void write_bh_nb_data(int nb, int smbh_count, double time_cur, int N, double m[], double3 x[], double3 v[])
|
||||
void Write_bh_nb_data::operator()(double time_cur)
|
||||
{
|
||||
//int nb = config->live_smbh_neighbor_number;
|
||||
// TODO fix below!!! Should be class members.
|
||||
int ind_sort[30000];
|
||||
double var_sort[30000];
|
||||
//TODO you don't want and probably don't need to allocate these here. Maybe just need size nb, or maybe use as private variables.
|
||||
|
||||
auto out = fopen("bh_neighbors.dat", "a");
|
||||
|
||||
/* 1st BH */
|
||||
|
||||
for (int i_bh=0; i_bh < smbh_count; i_bh++) {
|
||||
for (int i=0; i<N; i++) var_sort[i] = (x[i]-x[i_bh]).norm();
|
||||
std::iota(ind_sort, ind_sort+N, 0);
|
||||
std::partial_sort(ind_sort, ind_sort + nb, ind_sort + N, [&](int i, int j) {return var_sort[i] < var_sort[j];});
|
||||
std::iota(ind_sort.begin(), ind_sort.end(), 0);
|
||||
std::partial_sort(ind_sort.begin(), ind_sort.begin() + nb, ind_sort.begin() + N, [&](int i, int j) {return var_sort[i] < var_sort[j];});
|
||||
|
||||
fprintf(out,"%.16E \t %07d \t %.8E \t % .8E % .8E % .8E \t % .8E % .8E % .8E \t",
|
||||
time_cur,
|
||||
|
|
@ -247,9 +189,67 @@ void write_bh_nb_data(int nb, int smbh_count, double time_cur, int N, double m[]
|
|||
x[i][0], x[i][1], x[i][2], (x[i]-x[i_bh]).norm(),
|
||||
v[i][0], v[i][1], v[i][2], (v[i]-v[i_bh]).norm());
|
||||
}
|
||||
|
||||
fprintf(out,"\n");
|
||||
}
|
||||
fprintf(out, "\n"); // this is redundant
|
||||
fclose(out);
|
||||
fflush(out);
|
||||
}
|
||||
|
||||
void Binary_smbh_influence_sphere_output::operator()(int ind_act[], int n_act, double timesteps, double time_cur)
|
||||
{
|
||||
double m_bh1 = m[0];
|
||||
double m_bh2 = m[1];
|
||||
double3 x_bh1 = x[0];
|
||||
double3 x_bh2 = x[1];
|
||||
double3 v_bh1 = v[0];
|
||||
double3 v_bh2 = v[1];
|
||||
|
||||
double3 x_bbhc = (m_bh1*x_bh1 + m_bh2*x_bh2)/(m_bh1 + m_bh2);
|
||||
double3 v_bbhc = (m_bh1*v_bh1 + m_bh2*v_bh2)/(m_bh1 + m_bh2);
|
||||
|
||||
double DR2 = (x_bh1 - x_bh2).norm2();
|
||||
double DV2 = (v_bh1 - v_bh2).norm2();
|
||||
double EB = -(m_bh1 + m_bh2) / sqrt(DR2) + 0.5 * DV2;
|
||||
double SEMI_a = -0.5 * (m_bh1 + m_bh2)/EB;
|
||||
double SEMI_a2 = SEMI_a*SEMI_a;
|
||||
|
||||
for (int i=0; i<n_act; i++) {
|
||||
int j_act = ind_act[i];
|
||||
if (j_act<2) continue;
|
||||
double& pot_bh1 = pot[0];
|
||||
double& pot_bh2 = pot[1];
|
||||
double& m_act = m[j_act];
|
||||
double3& x_act = x[j_act];
|
||||
double3& v_act = v[j_act];
|
||||
double& dt_act = dt[j_act];
|
||||
double& pot_act = pot[j_act];
|
||||
double tmp_r2 = (x_act - x_bbhc).norm2();
|
||||
if (tmp_r2 < SEMI_a2*factor*factor) {
|
||||
if (inf_event[j_act] == 0) {
|
||||
fprintf(out,"INF1 %.6E %.16E %07d %07d %.6E % .6E % .6E % .6E % .6E % .6E % .6E %.6E % .6E % .6E % .6E % .6E % .6E % .6E % .6E %.6E % .6E % .6E % .6E % .6E % .6E % .6E % .6E %.6E %.6E % .6E % .6E % .6E % .6E % .6E % .6E % .6E %.6E \n",
|
||||
timesteps, time_cur, i, j_act,
|
||||
sqrt(DR2), x_bbhc[0], x_bbhc[1], x_bbhc[2], v_bbhc[0], v_bbhc[1], v_bbhc[2],
|
||||
m_bh1, x_bh1[0], x_bh1[1], x_bh1[2], v_bh1[0], v_bh1[1], v_bh1[2], pot_bh1,
|
||||
m_bh2, x_bh2[0], x_bh2[1], x_bh2[2], v_bh2[0], v_bh2[1], v_bh2[2], pot_bh2,
|
||||
sqrt(tmp_r2),
|
||||
m_act, x_act[0], x_act[1], x_act[2], v_act[0], v_act[1], v_act[2], pot_act,
|
||||
dt_act);
|
||||
|
||||
inf_event[j_act] = 1;
|
||||
}
|
||||
} else {
|
||||
if (inf_event[j_act] == 1) {
|
||||
fprintf(out,"INF2 %.6E %.16E %07d %07d %.6E % .6E % .6E % .6E % .6E % .6E % .6E %.6E % .6E % .6E % .6E % .6E % .6E % .6E % .6E %.6E % .6E % .6E % .6E % .6E % .6E % .6E % .6E %.6E %.6E % .6E % .6E % .6E % .6E % .6E % .6E % .6E %.6E \n",
|
||||
timesteps, time_cur, i, ind_act[i],
|
||||
sqrt(DR2), x_bbhc[0], x_bbhc[1], x_bbhc[2], v_bbhc[0], v_bbhc[1], v_bbhc[2],
|
||||
m_bh1, x_bh1[0], x_bh1[1], x_bh1[2], v_bh1[0], v_bh1[1], v_bh1[2], pot_bh1,
|
||||
m_bh2, x_bh2[0], x_bh2[1], x_bh2[2], v_bh2[0], v_bh2[1], v_bh2[2], pot_bh2,
|
||||
sqrt(tmp_r2),
|
||||
m_act, x_act[0], x_act[1], x_act[2], v_act[0], v_act[1], v_act[2], pot_act,
|
||||
dt_act);
|
||||
}
|
||||
inf_event[j_act] = 0;
|
||||
} /* if (tmp_r2 < DR2*R_INF2) */
|
||||
} /* i */
|
||||
fflush(out);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue