LORENE
bin_ns_bh.C
1/*
2 * Basic methods for class Bin_ns_bh
3 *
4 */
5
6/*
7 * Copyright (c) 2002 Philippe Grandclement, Keisuke Taniguchi,
8 * Eric Gourgoulhon
9 *
10 * This file is part of LORENE.
11 *
12 * LORENE is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2
14 * as published by the Free Software Foundation.
15 *
16 * LORENE is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with LORENE; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27
28
29/*
30 * $Id: bin_ns_bh.C,v 1.16 2016/12/05 16:17:46 j_novak Exp $
31 * $Log: bin_ns_bh.C,v $
32 * Revision 1.16 2016/12/05 16:17:46 j_novak
33 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
34 *
35 * Revision 1.15 2014/10/13 08:52:42 j_novak
36 * Lorene classes and functions now belong to the namespace Lorene.
37 *
38 * Revision 1.14 2014/10/06 15:13:01 j_novak
39 * Modified #include directives to use c++ syntax.
40 *
41 * Revision 1.13 2007/04/26 14:14:59 f_limousin
42 * The function fait_tkij now have default values for bound_nn and lim_nn
43 *
44 * Revision 1.12 2007/04/24 20:13:53 f_limousin
45 * Implementation of Dirichlet and Neumann BC for the lapse
46 *
47 * Revision 1.11 2006/09/25 10:01:49 p_grandclement
48 * Addition of N-dimensional Tbl
49 *
50 * Revision 1.10 2006/03/30 07:33:45 p_grandclement
51 * *** empty log message ***
52 *
53 * Revision 1.9 2005/12/06 07:01:58 p_grandclement
54 * addition of Bhole::mp scaling in affecte()
55 *
56 * Revision 1.8 2005/12/01 12:59:10 p_grandclement
57 * Files for bin_ns_bh project
58 *
59 * Revision 1.6 2005/08/29 15:10:15 p_grandclement
60 * Addition of things needed :
61 * 1) For BBH with different masses
62 * 2) Provisory files for the mixted binaries (Bh and NS) : THIS IS NOT
63 * WORKING YET !!!
64 *
65 * Revision 1.5 2004/03/25 10:28:58 j_novak
66 * All LORENE's units are now defined in the namespace Unites (in file unites.h).
67 *
68 * Revision 1.4 2003/02/13 16:40:25 p_grandclement
69 * Addition of various things for the Bin_ns_bh project, non of them being
70 * completely tested
71 *
72 * Revision 1.3 2002/12/19 14:51:19 e_gourgoulhon
73 * Added the new functions set_omega and set_x_axe
74 *
75 * Revision 1.2 2002/12/18 10:31:15 e_gourgoulhon
76 * irrot : int -> bool
77 *
78 * Revision 1.1 2002/12/17 13:10:11 e_gourgoulhon
79 * Methods for class Bin_ns_bh
80 *
81 *
82 *
83 *
84 * $Header: /cvsroot/Lorene/C++/Source/Bin_ns_bh/bin_ns_bh.C,v 1.16 2016/12/05 16:17:46 j_novak Exp $
85 *
86 */
87
88// C++ headers
89#include "headcpp.h"
90
91// C headers
92#include <cmath>
93
94// Lorene headers
95#include "map.h"
96#include "bhole.h"
97#include "bin_ns_bh.h"
98#include "utilitaires.h"
99#include "unites.h"
100#include "graphique.h"
101#include "param.h"
102
103 //--------------//
104 // Constructors //
105 //--------------//
106
107// Standard constructor
108// --------------------
109namespace Lorene {
110Bin_ns_bh::Bin_ns_bh(Map& mp_ns, int nzet, const Eos& eos, bool irrot_ns,
111 Map_af& mp_bh)
112 : ref_triad(0., "Absolute frame Cartesian basis"),
113 star(mp_ns, nzet, true, eos, irrot_ns, ref_triad),
114 hole(mp_bh),
115 omega(0),
116 x_axe(0) {
117
118 // Pointers of derived quantities initialized to zero :
119 set_der_0x0() ;
120}
121
122// Copy constructor
123// ----------------
125 : ref_triad(0., "Absolute frame Cartesian basis"),
126 star(bibi.star),
127 hole(bibi.hole),
128 omega(bibi.omega),
129 x_axe(bibi.x_axe) {
130
131 // Pointers of derived quantities initialized to zero :
132 set_der_0x0() ;
133}
134
135// Constructor from a file
136// -----------------------
137Bin_ns_bh::Bin_ns_bh(Map& mp_ns, const Eos& eos, Map_af& mp_bh, FILE* fich, bool old)
138 : ref_triad(0., "Absolute frame Cartesian basis"),
139 star(mp_ns, eos, ref_triad, fich, old),
140 hole(mp_bh, fich, old) {
141
142 // omega and x_axe are read in the file:
143 fread_be(&omega, sizeof(double), 1, fich) ;
144 fread_be(&x_axe, sizeof(double), 1, fich) ;
145
146 assert(hole.get_omega() == omega) ;
147
148 // Pointers of derived quantities initialized to zero :
149 set_der_0x0() ;
150}
151
152 //------------//
153 // Destructor //
154 //------------//
155
156Bin_ns_bh::~Bin_ns_bh(){
157
158 del_deriv() ;
159
160}
161
162 //----------------------------------//
163 // Management of derived quantities //
164 //----------------------------------//
165
167
168 if (p_mass_adm != 0x0) delete p_mass_adm ;
169 if (p_mass_kom != 0x0) delete p_mass_kom ;
170 if (p_angu_mom != 0x0) delete p_angu_mom ;
171 if (p_total_ener != 0x0) delete p_total_ener ;
172 if (p_virial != 0x0) delete p_virial ;
173 if (p_virial_gb != 0x0) delete p_virial_gb ;
174 if (p_virial_fus != 0x0) delete p_virial_fus ;
175 if (p_ham_constr != 0x0) delete p_ham_constr ;
176 if (p_mom_constr != 0x0) delete p_mom_constr ;
177
178 set_der_0x0() ;
179}
180
181
182
183
185
186 p_mass_adm = 0x0 ;
187 p_mass_kom = 0x0 ;
188 p_angu_mom = 0x0 ;
189 p_total_ener = 0x0 ;
190 p_virial = 0x0 ;
191 p_virial_gb = 0x0 ;
192 p_virial_fus = 0x0 ;
193 p_ham_constr = 0x0 ;
194 p_mom_constr = 0x0 ;
195
196}
197
198 //--------------//
199 // Assignment //
200 //--------------//
201
202// Assignment to another Binaire
203// -----------------------------
204
206
207 assert( bibi.ref_triad == ref_triad ) ;
208
209 star = bibi.star ;
210 hole = bibi.hole ;
211
212 omega = bibi.omega ;
213 x_axe = bibi.x_axe ;
214
215 // ref_triad remains unchanged
216
217 del_deriv() ; // Deletes all derived quantities
218
219}
220
221void Bin_ns_bh::set_omega(double omega_i) {
222
223 omega = omega_i ;
224 hole.set_omega(omega) ;
225
226 del_deriv() ;
227
228}
229
230void Bin_ns_bh::set_x_axe(double x_axe_i) {
231
232 x_axe = x_axe_i ;
233
234 del_deriv() ;
235
236}
237
238double Bin_ns_bh::separation() const {
239 return star.mp.get_ori_x() - hole.mp.get_ori_x() ;
240}
241
242
243 //--------------//
244 // Outputs //
245 //--------------//
246
247// Save in a file
248// --------------
249void Bin_ns_bh::sauve(FILE* fich) const {
250
251 star.sauve(fich) ;
252 hole.sauve(fich) ;
253
254 fwrite_be(&omega, sizeof(double), 1, fich) ;
255 fwrite_be(&x_axe, sizeof(double), 1, fich) ;
256
257}
258
259
260void Bin_ns_bh::init_auto () {
261
262 // On doit faire fonction pour assurer que tout va bien sur les trucs limites
263 Cmp filtre_ns(star.get_mp()) ;
264 Cmp radius_ns (star.get_mp()) ;
265 radius_ns = star.get_mp().r ;
266 double rlim_ns = star.get_mp().val_r (0, 1, 0, 0) ;
267 filtre_ns = 0.5 * (1 + exp(-radius_ns*radius_ns/rlim_ns/rlim_ns)) ;
268 filtre_ns.std_base_scal() ;
269
270 Cmp filtre_bh(hole.get_mp()) ;
271 Cmp radius_bh (hole.get_mp()) ;
272 radius_bh = hole.get_mp().r ;
273 double rlim_bh = hole.get_mp().val_r (0, 1, 0, 0) ;
274 filtre_bh = 0.5 * (1 + exp(-radius_bh*radius_bh/rlim_bh/rlim_bh)) ;
275 filtre_bh.std_base_scal() ;
276
277 // Facteur conforme : pas de soucis
280 hole.set_psi_auto() = hole.get_psi_auto()() * filtre_bh ;
281 hole.set_psi_auto().std_base_scal() ;
282
283 // Le lapse
284 star.set_n_auto() = sqrt(exp(star.get_beta_auto()()-star.get_logn_auto()()))*filtre_ns ;
286
287 hole.set_n_auto() = hole.get_n_auto()() * filtre_bh ;
288 hole.set_n_auto().std_base_scal() ;
289
290 // On doit assurer que le lapse tot est bien zero sur l'horizon...
291 Cmp soustrait ((filtre_bh-0.5)*2*exp(1.)) ;
292 int nz = hole.get_mp().get_mg()->get_nzone() ;
293 Mtbl xa_hole (hole.get_mp().get_mg()) ;
294 xa_hole = hole.get_mp().xa ;
295 Mtbl ya_hole (hole.get_mp().get_mg()) ;
296 ya_hole = hole.get_mp().ya ;
297 Mtbl za_hole (hole.get_mp().get_mg()) ;
298 za_hole = hole.get_mp().za ;
299 double xa_abs, ya_abs, za_abs ;
300 double air, tet, phi ;
301
302 int np = hole.get_mp().get_mg()->get_np(0) ;
303 int nt = hole.get_mp().get_mg()->get_nt(0) ;
304 for (int k=0 ; k<np ; k++)
305 for (int j=0 ; j<nt ; j++) {
306 double val_hole = hole.n_auto()(1, k,j,0) ;
307 xa_abs = xa_hole(1,k,j,0) ;
308 ya_abs = ya_hole(1,k,j,0) ;
309 za_abs = za_hole(1,k,j,0) ;
310 star.get_mp().convert_absolute (xa_abs, ya_abs, za_abs, air, tet, phi) ;
311 double val_star = star.get_n_auto()().val_point (air, tet, phi) ;
312 for (int l=1 ; l<nz ; l++)
313 for (int i=0 ; i<hole.get_mp().get_mg()->get_nr(l) ; i++)
314 hole.set_n_auto().set(l,k,j,i) -= (val_star+val_hole)*soustrait(l,k,j,i) ;
315 }
316 hole.set_n_auto().std_base_scal() ;
317 hole.set_n_auto().raccord(1) ;
318}
319
320 // *********************************
321 // Affectation to another Bin_ns_bh
322 //**********************************
323
324void Bin_ns_bh::affecte(const Bin_ns_bh& so) {
325
326 // Kinematic quantities :
327 star.nzet = so.star.nzet ;
328 set_omega(so.omega) ;
329 x_axe = so.x_axe ;
330 star.set_mp().set_ori (so.star.mp.get_ori_x(), 0., 0.) ;
331 hole.set_mp().set_ori (so.hole.mp.get_ori_x(), 0., 0.) ;
332 star.set_mp().set_rot_phi (so.star.mp.get_rot_phi()) ;
333 hole.set_mp().set_rot_phi (so.hole.mp.get_rot_phi()) ;
334
335 hole.set_mp().homothetie_interne (so.hole.get_rayon()/hole.rayon) ;
336 hole.set_rayon(so.hole.get_rayon()) ;
337
338 // Faut gêrer le map_et :
339 Map_et* map_et = dynamic_cast<Map_et*>(&star.mp) ;
340 Map_et* map_et_so = dynamic_cast<Map_et*>(&so.star.mp) ;
341
342 int kmax = -1 ;
343 int jmax = -1 ;
344 int np = map_et->get_mg()->get_np(star.nzet-1) ;
345 int nt = map_et->get_mg()->get_nt(star.nzet-1) ;
346 Mtbl phi (map_et->get_mg()) ;
347 phi = map_et->phi ;
348 Mtbl tet (map_et->get_mg()) ;
349 tet = map_et->tet ;
350 double rmax = 0 ;
351 for (int k=0 ; k<np ; k++)
352 for (int j=0 ; j<nt ; j++) {
353 double rcourant = map_et_so->val_r(star.nzet-1, 1, tet(0,k,j,0), phi(0,k,j,0)) ;
354 if (rcourant > rmax) {
355 rmax = rcourant ;
356 kmax = k ;
357 jmax = j ;
358 }
359 }
360
361 double old_r = map_et->val_r(star.nzet-1, 1, tet(0,kmax,jmax,0), phi(0,kmax,jmax,0)) ;
362 map_et->homothetie (rmax/old_r) ;
363
364 star.ent.allocate_all() ;
365 star.ent.set().import(star.nzet, so.star.ent()) ;
366 star.ent.set_std_base() ;
367
368 Param par_adapt ;
369 int nitermax = 100 ;
370 int niter_adapt ;
371 int adapt_flag = 1 ;
372 int nz_search = star.nzet + 1 ;
373 double precis_secant = 1.e-14 ;
374 double alpha_r = 1. ;
375 double reg_map = 1. ;
376 Tbl ent_limit(star.nzet) ;
377
378 par_adapt.add_int(nitermax, 0) ;
379 par_adapt.add_int(star.nzet, 1) ;
380 par_adapt.add_int(nz_search, 2) ;
381 par_adapt.add_int(adapt_flag, 3) ;
382 par_adapt.add_int(jmax, 4) ;
383 par_adapt.add_int(kmax, 5) ;
384 par_adapt.add_int_mod(niter_adapt, 0) ;
385 par_adapt.add_double(precis_secant, 0) ;
386 par_adapt.add_double(reg_map, 1) ;
387 par_adapt.add_double(alpha_r, 2) ;
388 par_adapt.add_tbl(ent_limit, 0) ;
389
390 Map_et mp_prev = *map_et ;
391 ent_limit.set_etat_qcq() ;
392 for (int l=0; l<star.nzet-1; l++) {
393 int nr = map_et->get_mg()->get_nr(l) ;
394 ent_limit.set(l) = star.ent()(l, kmax, jmax, nr-1) ;
395 }
396 ent_limit.set(star.nzet-1) = 0 ;
397
398 // On adapte :
399 map_et->adapt(star.ent(), par_adapt) ;
400 mp_prev.homothetie(alpha_r) ;
401 map_et->reevaluate_symy (&mp_prev, star.nzet, star.ent.set()) ;
402
403 star.ent.set().import(star.nzet, so.star.ent()) ;
404
405 // The BH part :
406 // Lapse :
407 hole.n_auto.allocate_all() ;
408 Cmp auxi_n (so.hole.n_auto()) ;
409 auxi_n.raccord(1) ;
410 hole.n_auto.set().import(auxi_n) ;
411 hole.n_auto.set().std_base_scal() ;
412 hole.n_auto.set().raccord(1) ;
413
414 // Psi :
415 hole.psi_auto.allocate_all() ;
416 Cmp auxi_psi (so.hole.psi_auto()) ;
417 auxi_psi.raccord(1) ;
418 hole.psi_auto.set().import(auxi_psi) ;
419 hole.psi_auto.set().std_base_scal() ;
420 hole.psi_auto.set().raccord(1) ;
421
422 // Shift :
423 hole.shift_auto.allocate_all() ;
424 Tenseur auxi_shift (so.hole.shift_auto) ;
425 for (int i=0 ; i<3 ; i++)
426 auxi_shift.set(i).raccord(1) ;
427 hole.shift_auto.set(0).import(auxi_shift(0)) ;
428 hole.shift_auto.set(1).import(auxi_shift(1)) ;
429 hole.shift_auto.set(2).import(auxi_shift(2)) ;
430 hole.shift_auto.set_std_base() ;
431
432 // The NS part :
433 star.n_auto.allocate_all() ;
434 star.n_auto.set().import(so.star.n_auto()) ;
435 star.n_auto.set().std_base_scal() ;
436
437 // Psi :
438 star.confpsi_auto.allocate_all() ;
439 star.confpsi_auto.set().import(so.star.confpsi_auto()) ;
440 star.confpsi_auto.set().std_base_scal() ;
441 // Shift :
442 star.w_shift.allocate_all() ;
443 star.w_shift.set(0).import(so.star.w_shift(0)) ;
444 star.w_shift.set(1).import(so.star.w_shift(1)) ;
445 star.w_shift.set(2).import(so.star.w_shift(2)) ;
446 star.w_shift.set_std_base() ;
447 star.khi_shift.allocate_all() ;
448 star.khi_shift.set().import(so.star.khi_shift()) ;
449 star.khi_shift.set().std_base_scal() ;
450 star.fait_shift_auto() ;
451
452 Tenseur copie_dpsi (so.star.d_psi) ;
453 copie_dpsi.set(2).dec2_dzpuis() ;
454 if (so.star.is_irrotational()) {
455 star.d_psi.allocate_all() ;
456 star.d_psi.set(0).import(star.nzet, copie_dpsi(0)) ;
457 star.d_psi.set(1).import(star.nzet, copie_dpsi(1)) ;
458 star.d_psi.set(2).import(star.nzet, copie_dpsi(2)) ;
459 star.d_psi.set_std_base() ;
460 }
461
462
463
464 // Reconstruction of the fields :
465 hole.update_metric(star) ;
466 star.update_metric(hole) ;
467 star.update_metric_der_comp(hole) ;
468 fait_tkij() ;
469
470 star.kinematics(omega, x_axe) ;
471 star.equation_of_state() ;
472 star.hydro_euler() ;
473}
474
475
476// Printing
477// --------
478ostream& operator<<(ostream& ost, const Bin_ns_bh& bibi) {
479 bibi >> ost ;
480 return ost ;
481}
482
483
484ostream& Bin_ns_bh::operator>>(ostream& ost) const {
485
486 using namespace Unites ;
487
488 ost << endl ;
489 ost << "Neutron star - black hole binary system" << endl ;
490 ost << "=======================================" << endl ;
491 ost << endl <<
492 "Orbital angular velocity : " << omega * f_unit << " rad/s" << endl ;
493 ost <<
494 "Absolute coordinate X of the rotation axis : " << x_axe / km
495 << " km" << endl ;
496 ost << endl << "Neutron star : " << endl ;
497 ost << "============ " << endl ;
498 ost << star << endl ;
499
500 ost << "Black hole : " << endl ;
501 ost << "========== " << endl ;
502 ost << "Coordinate radius of the throat : " << hole.get_rayon() / km << " km" << endl ;
503 ost << "Absolute abscidia of the throat center : " << (hole.get_mp()).get_ori_x() / km
504 << " km" << endl ;
505 return ost ;
506}
507}
const Tenseur & get_n_auto() const
Returns the part of N generated by the hole.
Definition bhole.h:395
const Map_af & get_mp() const
Returns the mapping (readonly).
Definition bhole.h:339
Tenseur n_auto
Part of N generated by the hole.
Definition bhole.h:286
const Tenseur & get_psi_auto() const
Returns the part of generated by the hole.
Definition bhole.h:412
void sauve(FILE *fich) const
Write on a file.
Definition bhole.C:485
Neutron star - black hole binary system.
Definition bin_ns_bh.h:120
friend ostream & operator<<(ostream &, const Bin_ns_bh &)
Save in a file.
Definition bin_ns_bh.C:478
double * p_mass_kom
Total Komar mass of the system.
Definition bin_ns_bh.h:152
double * p_virial
Virial theorem error.
Definition bin_ns_bh.h:161
void fait_tkij(int bound_nn=-1, double lim_nn=0)
Computation of the extrinsic curvature tensor for both {\tt star} and {\tt bhole}.
void set_omega(double)
Sets the orbital angular velocity [{\tt f_unit}].
Definition bin_ns_bh.C:221
double * p_total_ener
Total energy of the system.
Definition bin_ns_bh.h:158
void operator=(const Bin_ns_bh &)
Assignment to another Bin_ns_bh.
Definition bin_ns_bh.C:205
ostream & operator>>(ostream &) const
Operator >> (function called by the operator <<).
Definition bin_ns_bh.C:484
double x_axe
Absolute X coordinate of the rotation axis.
Definition bin_ns_bh.h:143
void set_x_axe(double)
Sets the absolute coordinate X of the rotation axis [{\tt r_unit}].
Definition bin_ns_bh.C:230
Et_bin_nsbh star
The neutron star.
Definition bin_ns_bh.h:131
double * p_virial_gb
Virial theorem error by E.Gourgoulhon and S.Bonazzola.
Definition bin_ns_bh.h:164
Bhole hole
The black hole.
Definition bin_ns_bh.h:134
Tbl * p_mom_constr
Relative error on the momentum constraint.
Definition bin_ns_bh.h:173
double * p_mass_adm
Total ADM mass of the system.
Definition bin_ns_bh.h:149
double separation() const
Return the separation.
Definition bin_ns_bh.C:238
double * p_ham_constr
Relative error on the Hamiltonian constraint.
Definition bin_ns_bh.h:170
const Base_vect_cart ref_triad
Cartesian triad of the absolute reference frame.
Definition bin_ns_bh.h:128
void set_der_0x0() const
Sets to {\tt 0x0} all the pointers on derived quantities.
Definition bin_ns_bh.C:184
void del_deriv() const
Destructor.
Definition bin_ns_bh.C:166
double * p_virial_fus
Virial theorem error by J.L.Friedman, K.Uryu, and M.Shibata.
Definition bin_ns_bh.h:167
Tbl * p_angu_mom
Total angular momentum of the system.
Definition bin_ns_bh.h:155
Bin_ns_bh(Map &mp_ns, int nzet, const Eos &eos, bool irrot_ns, Map_af &mp_bh)
Standard constructor.
Definition bin_ns_bh.C:110
double omega
Angular velocity with respect to an asymptotically inertial observer.
Definition bin_ns_bh.h:139
void std_base_scal()
Sets the spectral bases of the Valeur va to the standard ones for a scalar.
Definition cmp.C:647
Tbl & set(int l)
Read/write of the value in a given domain.
Definition cmp.h:724
Equation of state base class.
Definition eos.h:206
const Tenseur & get_n_auto() const
Returns the part of the lapse {\it N} generated principaly by the star.
Tenseur & set_n_auto()
Read/write the lapse {\it N} generated principaly by the star.
Tenseur & set_confpsi_auto()
Read/write the conformal factor $\Psi$ generated principaly by the star.
virtual void sauve(FILE *) const
Save in a file.
const Map & get_mp() const
Returns the mapping.
Definition etoile.h:662
const Tenseur & get_beta_auto() const
Returns the logarithm of the part of the product AN generated principaly by the star.
Definition etoile.h:727
const Tenseur & get_logn_auto() const
Returns the logarithm of the part of the lapse N generated principaly by the star.
Definition etoile.h:704
Affine radial mapping.
Definition map.h:2042
virtual double val_r(int l, double xi, double theta, double pphi) const
Returns the value of the radial coordinate r for a given in a given domain.
void set_std_base()
Set the standard spectal basis of decomposition for each component.
Definition tenseur.C:1176
Cmp sqrt(const Cmp &)
Square root.
Definition cmp_math.C:223
Cmp exp(const Cmp &)
Exponential.
Definition cmp_math.C:273
int fread_be(int *aa, int size, int nb, FILE *fich)
Reads integer(s) from a binary file according to the big endian convention.
Definition fread_be.C:72
int fwrite_be(const int *aa, int size, int nb, FILE *fich)
Writes integer(s) into a binary file according to the big endian convention.
Definition fwrite_be.C:73
Lorene prototypes.
Definition app_hor.h:67
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
Definition map.h:777
Map(const Mg3d &)
Constructor from a multi-domain 3D grid.
Definition map.C:142
Coord phi
coordinate centered on the grid
Definition map.h:732
Coord tet
coordinate centered on the grid
Definition map.h:731
Standard units of space, time and mass.