first commit
This commit is contained in:
commit
aaf40315c8
15 changed files with 17524 additions and 0 deletions
76
n_bh.c
Normal file
76
n_bh.c
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/***************************************************************************/
|
||||
/*
|
||||
Coded by : Peter Berczik
|
||||
Version number : 1.0
|
||||
Last redaction : 2011.II.20. 13:00
|
||||
*/
|
||||
|
||||
int calc_force_n_BH(double m1, double xx1[], double vv1[],
|
||||
double m2, double xx2[], double vv2[],
|
||||
double eps_BH,
|
||||
double *pot_n1, double a_n1[], double adot_n1[],
|
||||
double *pot_n2, double a_n2[], double adot_n2[])
|
||||
{
|
||||
|
||||
/*
|
||||
INPUT
|
||||
|
||||
m1 - mass of the 1 BH
|
||||
xx1[0,1,2] - coordinate of the 1 BH
|
||||
vv1[0,1,2] - velocity of the 1 BH
|
||||
|
||||
m2 - mass of the 2 BH
|
||||
xx2[0,1,2] - coordinate of the 2 BH
|
||||
vv2[0,1,2] - velocity of the 2 BH
|
||||
|
||||
eps_BH - force softening, can be even exactly 0.0 !
|
||||
|
||||
OUTPUT
|
||||
|
||||
pot_n1 for the 1 BH
|
||||
a_n1 [0,1,2] for the 1 BH
|
||||
adot_n1 [0,1,2] for the 1 BH
|
||||
|
||||
pot_n2 for the 2 BH
|
||||
a_n2 [0,1,2] for the 2 BH
|
||||
adot_n2 [0,1,2] for the 2 BH
|
||||
*/
|
||||
|
||||
|
||||
int k;
|
||||
|
||||
double r, r2, r3, r4, RP, x[3], v[3];
|
||||
|
||||
|
||||
for(k=0;k<3;k++)
|
||||
{
|
||||
x[k] = xx1[k] - xx2[k];
|
||||
v[k] = vv1[k] - vv2[k];
|
||||
}
|
||||
|
||||
r2 = SQR(x[0]) + SQR(x[1]) + SQR(x[2]) + SQR(eps_BH);
|
||||
|
||||
r = sqrt(r2);
|
||||
r3 = r2*r;
|
||||
r4 = r2*r2;
|
||||
|
||||
RP = 3.0*(x[0]*v[0]+x[1]*v[1]+x[2]*v[2])/r;
|
||||
|
||||
// Newton pot + acc & jerks
|
||||
|
||||
*pot_n1 = -m2/r;
|
||||
*pot_n2 = -m1/r;
|
||||
|
||||
for(k=0;k<3;k++)
|
||||
{
|
||||
a_n1[k] = -m2*x[k]/r3;
|
||||
a_n2[k] = m1*x[k]/r3;
|
||||
|
||||
adot_n1[k] = -m2*(v[k]/r3 - RP*x[k]/r4);
|
||||
adot_n2[k] = m1*(v[k]/r3 - RP*x[k]/r4);
|
||||
}
|
||||
|
||||
return(0);
|
||||
|
||||
}
|
||||
/***************************************************************************/
|
||||
Loading…
Add table
Add a link
Reference in a new issue