00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 char bin_ns_bh_C[] = "$Header: /cvsroot/Lorene/C++/Source/Bin_ns_bh/bin_ns_bh.C,v 1.13 2007/04/26 14:14:59 f_limousin Exp $" ;
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 #include "headcpp.h"
00081
00082
00083 #include <math.h>
00084
00085
00086 #include "map.h"
00087 #include "bhole.h"
00088 #include "bin_ns_bh.h"
00089 #include "utilitaires.h"
00090 #include "unites.h"
00091 #include "graphique.h"
00092 #include "param.h"
00093
00094
00095
00096
00097
00098
00099
00100 Bin_ns_bh::Bin_ns_bh(Map& mp_ns, int nzet, const Eos& eos, bool irrot_ns,
00101 Map_af& mp_bh)
00102 : ref_triad(0., "Absolute frame Cartesian basis"),
00103 star(mp_ns, nzet, true, eos, irrot_ns, ref_triad),
00104 hole(mp_bh),
00105 omega(0),
00106 x_axe(0) {
00107
00108
00109 set_der_0x0() ;
00110 }
00111
00112
00113
00114 Bin_ns_bh::Bin_ns_bh(const Bin_ns_bh& bibi)
00115 : ref_triad(0., "Absolute frame Cartesian basis"),
00116 star(bibi.star),
00117 hole(bibi.hole),
00118 omega(bibi.omega),
00119 x_axe(bibi.x_axe) {
00120
00121
00122 set_der_0x0() ;
00123 }
00124
00125
00126
00127 Bin_ns_bh::Bin_ns_bh(Map& mp_ns, const Eos& eos, Map_af& mp_bh, FILE* fich, bool old)
00128 : ref_triad(0., "Absolute frame Cartesian basis"),
00129 star(mp_ns, eos, ref_triad, fich, old),
00130 hole(mp_bh, fich, old) {
00131
00132
00133 fread_be(&omega, sizeof(double), 1, fich) ;
00134 fread_be(&x_axe, sizeof(double), 1, fich) ;
00135
00136 assert(hole.get_omega() == omega) ;
00137
00138
00139 set_der_0x0() ;
00140 }
00141
00142
00143
00144
00145
00146 Bin_ns_bh::~Bin_ns_bh(){
00147
00148 del_deriv() ;
00149
00150 }
00151
00152
00153
00154
00155
00156 void Bin_ns_bh::del_deriv() const {
00157
00158 if (p_mass_adm != 0x0) delete p_mass_adm ;
00159 if (p_mass_kom != 0x0) delete p_mass_kom ;
00160 if (p_angu_mom != 0x0) delete p_angu_mom ;
00161 if (p_total_ener != 0x0) delete p_total_ener ;
00162 if (p_virial != 0x0) delete p_virial ;
00163 if (p_virial_gb != 0x0) delete p_virial_gb ;
00164 if (p_virial_fus != 0x0) delete p_virial_fus ;
00165 if (p_ham_constr != 0x0) delete p_ham_constr ;
00166 if (p_mom_constr != 0x0) delete p_mom_constr ;
00167
00168 set_der_0x0() ;
00169 }
00170
00171
00172
00173
00174 void Bin_ns_bh::set_der_0x0() const {
00175
00176 p_mass_adm = 0x0 ;
00177 p_mass_kom = 0x0 ;
00178 p_angu_mom = 0x0 ;
00179 p_total_ener = 0x0 ;
00180 p_virial = 0x0 ;
00181 p_virial_gb = 0x0 ;
00182 p_virial_fus = 0x0 ;
00183 p_ham_constr = 0x0 ;
00184 p_mom_constr = 0x0 ;
00185
00186 }
00187
00188
00189
00190
00191
00192
00193
00194
00195 void Bin_ns_bh::operator=(const Bin_ns_bh& bibi) {
00196
00197 assert( bibi.ref_triad == ref_triad ) ;
00198
00199 star = bibi.star ;
00200 hole = bibi.hole ;
00201
00202 omega = bibi.omega ;
00203 x_axe = bibi.x_axe ;
00204
00205
00206
00207 del_deriv() ;
00208
00209 }
00210
00211 void Bin_ns_bh::set_omega(double omega_i) {
00212
00213 omega = omega_i ;
00214 hole.set_omega(omega) ;
00215
00216 del_deriv() ;
00217
00218 }
00219
00220 void Bin_ns_bh::set_x_axe(double x_axe_i) {
00221
00222 x_axe = x_axe_i ;
00223
00224 del_deriv() ;
00225
00226 }
00227
00228 double Bin_ns_bh::separation() const {
00229 return star.mp.get_ori_x() - hole.mp.get_ori_x() ;
00230 }
00231
00232
00233
00234
00235
00236
00237
00238
00239 void Bin_ns_bh::sauve(FILE* fich) const {
00240
00241 star.sauve(fich) ;
00242 hole.sauve(fich) ;
00243
00244 fwrite_be(&omega, sizeof(double), 1, fich) ;
00245 fwrite_be(&x_axe, sizeof(double), 1, fich) ;
00246
00247 }
00248
00249
00250 void Bin_ns_bh::init_auto () {
00251
00252
00253 Cmp filtre_ns(star.get_mp()) ;
00254 Cmp radius_ns (star.get_mp()) ;
00255 radius_ns = star.get_mp().r ;
00256 double rlim_ns = star.get_mp().val_r (0, 1, 0, 0) ;
00257 filtre_ns = 0.5 * (1 + exp(-radius_ns*radius_ns/rlim_ns/rlim_ns)) ;
00258 filtre_ns.std_base_scal() ;
00259
00260 Cmp filtre_bh(hole.get_mp()) ;
00261 Cmp radius_bh (hole.get_mp()) ;
00262 radius_bh = hole.get_mp().r ;
00263 double rlim_bh = hole.get_mp().val_r (0, 1, 0, 0) ;
00264 filtre_bh = 0.5 * (1 + exp(-radius_bh*radius_bh/rlim_bh/rlim_bh)) ;
00265 filtre_bh.std_base_scal() ;
00266
00267
00268 star.set_confpsi_auto() = sqrt(exp(star.get_beta_auto()()-star.get_logn_auto()()))*filtre_ns ;
00269 star.set_confpsi_auto().set_std_base() ;
00270 hole.set_psi_auto() = hole.get_psi_auto()() * filtre_bh ;
00271 hole.set_psi_auto().std_base_scal() ;
00272
00273
00274 star.set_n_auto() = sqrt(exp(star.get_beta_auto()()-star.get_logn_auto()()))*filtre_ns ;
00275 star.set_n_auto().set_std_base() ;
00276
00277 hole.set_n_auto() = hole.get_n_auto()() * filtre_bh ;
00278 hole.set_n_auto().std_base_scal() ;
00279
00280
00281 Cmp soustrait ((filtre_bh-0.5)*2*exp(1.)) ;
00282 int nz = hole.get_mp().get_mg()->get_nzone() ;
00283 Mtbl xa_hole (hole.get_mp().get_mg()) ;
00284 xa_hole = hole.get_mp().xa ;
00285 Mtbl ya_hole (hole.get_mp().get_mg()) ;
00286 ya_hole = hole.get_mp().ya ;
00287 Mtbl za_hole (hole.get_mp().get_mg()) ;
00288 za_hole = hole.get_mp().za ;
00289 double xa_abs, ya_abs, za_abs ;
00290 double air, tet, phi ;
00291
00292 int np = hole.get_mp().get_mg()->get_np(0) ;
00293 int nt = hole.get_mp().get_mg()->get_nt(0) ;
00294 for (int k=0 ; k<np ; k++)
00295 for (int j=0 ; j<nt ; j++) {
00296 double val_hole = hole.n_auto()(1, k,j,0) ;
00297 xa_abs = xa_hole(1,k,j,0) ;
00298 ya_abs = ya_hole(1,k,j,0) ;
00299 za_abs = za_hole(1,k,j,0) ;
00300 star.get_mp().convert_absolute (xa_abs, ya_abs, za_abs, air, tet, phi) ;
00301 double val_star = star.get_n_auto()().val_point (air, tet, phi) ;
00302 for (int l=1 ; l<nz ; l++)
00303 for (int i=0 ; i<hole.get_mp().get_mg()->get_nr(l) ; i++)
00304 hole.set_n_auto().set(l,k,j,i) -= (val_star+val_hole)*soustrait(l,k,j,i) ;
00305 }
00306 hole.set_n_auto().std_base_scal() ;
00307 hole.set_n_auto().raccord(1) ;
00308 }
00309
00310
00311
00312
00313
00314 void Bin_ns_bh::affecte(const Bin_ns_bh& so) {
00315
00316
00317 star.nzet = so.star.nzet ;
00318 set_omega(so.omega) ;
00319 x_axe = so.x_axe ;
00320 star.set_mp().set_ori (so.star.mp.get_ori_x(), 0., 0.) ;
00321 hole.set_mp().set_ori (so.hole.mp.get_ori_x(), 0., 0.) ;
00322 star.set_mp().set_rot_phi (so.star.mp.get_rot_phi()) ;
00323 hole.set_mp().set_rot_phi (so.hole.mp.get_rot_phi()) ;
00324
00325 hole.set_mp().homothetie_interne (so.hole.get_rayon()/hole.rayon) ;
00326 hole.set_rayon(so.hole.get_rayon()) ;
00327
00328
00329 Map_et* map_et = dynamic_cast<Map_et*>(&star.mp) ;
00330 Map_et* map_et_so = dynamic_cast<Map_et*>(&so.star.mp) ;
00331
00332 int kmax = -1 ;
00333 int jmax = -1 ;
00334 int np = map_et->get_mg()->get_np(star.nzet-1) ;
00335 int nt = map_et->get_mg()->get_nt(star.nzet-1) ;
00336 Mtbl phi (map_et->get_mg()) ;
00337 phi = map_et->phi ;
00338 Mtbl tet (map_et->get_mg()) ;
00339 tet = map_et->tet ;
00340 double rmax = 0 ;
00341 for (int k=0 ; k<np ; k++)
00342 for (int j=0 ; j<nt ; j++) {
00343 double rcourant = map_et_so->val_r(star.nzet-1, 1, tet(0,k,j,0), phi(0,k,j,0)) ;
00344 if (rcourant > rmax) {
00345 rmax = rcourant ;
00346 kmax = k ;
00347 jmax = j ;
00348 }
00349 }
00350
00351 double old_r = map_et->val_r(star.nzet-1, 1, tet(0,kmax,jmax,0), phi(0,kmax,jmax,0)) ;
00352 map_et->homothetie (rmax/old_r) ;
00353
00354 star.ent.allocate_all() ;
00355 star.ent.set().import(star.nzet, so.star.ent()) ;
00356 star.ent.set_std_base() ;
00357
00358 Param par_adapt ;
00359 int nitermax = 100 ;
00360 int niter_adapt ;
00361 int adapt_flag = 1 ;
00362 int nz_search = star.nzet + 1 ;
00363 double precis_secant = 1.e-14 ;
00364 double alpha_r = 1. ;
00365 double reg_map = 1. ;
00366 Tbl ent_limit(star.nzet) ;
00367
00368 par_adapt.add_int(nitermax, 0) ;
00369 par_adapt.add_int(star.nzet, 1) ;
00370 par_adapt.add_int(nz_search, 2) ;
00371 par_adapt.add_int(adapt_flag, 3) ;
00372 par_adapt.add_int(jmax, 4) ;
00373 par_adapt.add_int(kmax, 5) ;
00374 par_adapt.add_int_mod(niter_adapt, 0) ;
00375 par_adapt.add_double(precis_secant, 0) ;
00376 par_adapt.add_double(reg_map, 1) ;
00377 par_adapt.add_double(alpha_r, 2) ;
00378 par_adapt.add_tbl(ent_limit, 0) ;
00379
00380 Map_et mp_prev = *map_et ;
00381 ent_limit.set_etat_qcq() ;
00382 for (int l=0; l<star.nzet-1; l++) {
00383 int nr = map_et->get_mg()->get_nr(l) ;
00384 ent_limit.set(l) = star.ent()(l, kmax, jmax, nr-1) ;
00385 }
00386 ent_limit.set(star.nzet-1) = 0 ;
00387
00388
00389 map_et->adapt(star.ent(), par_adapt) ;
00390 mp_prev.homothetie(alpha_r) ;
00391 map_et->reevaluate_symy (&mp_prev, star.nzet, star.ent.set()) ;
00392
00393 star.ent.set().import(star.nzet, so.star.ent()) ;
00394
00395
00396
00397 hole.n_auto.allocate_all() ;
00398 Cmp auxi_n (so.hole.n_auto()) ;
00399 auxi_n.raccord(1) ;
00400 hole.n_auto.set().import(auxi_n) ;
00401 hole.n_auto.set().std_base_scal() ;
00402 hole.n_auto.set().raccord(1) ;
00403
00404
00405 hole.psi_auto.allocate_all() ;
00406 Cmp auxi_psi (so.hole.psi_auto()) ;
00407 auxi_psi.raccord(1) ;
00408 hole.psi_auto.set().import(auxi_psi) ;
00409 hole.psi_auto.set().std_base_scal() ;
00410 hole.psi_auto.set().raccord(1) ;
00411
00412
00413 hole.shift_auto.allocate_all() ;
00414 Tenseur auxi_shift (so.hole.shift_auto) ;
00415 for (int i=0 ; i<3 ; i++)
00416 auxi_shift.set(i).raccord(1) ;
00417 hole.shift_auto.set(0).import(auxi_shift(0)) ;
00418 hole.shift_auto.set(1).import(auxi_shift(1)) ;
00419 hole.shift_auto.set(2).import(auxi_shift(2)) ;
00420 hole.shift_auto.set_std_base() ;
00421
00422
00423 star.n_auto.allocate_all() ;
00424 star.n_auto.set().import(so.star.n_auto()) ;
00425 star.n_auto.set().std_base_scal() ;
00426
00427
00428 star.confpsi_auto.allocate_all() ;
00429 star.confpsi_auto.set().import(so.star.confpsi_auto()) ;
00430 star.confpsi_auto.set().std_base_scal() ;
00431
00432 star.w_shift.allocate_all() ;
00433 star.w_shift.set(0).import(so.star.w_shift(0)) ;
00434 star.w_shift.set(1).import(so.star.w_shift(1)) ;
00435 star.w_shift.set(2).import(so.star.w_shift(2)) ;
00436 star.w_shift.set_std_base() ;
00437 star.khi_shift.allocate_all() ;
00438 star.khi_shift.set().import(so.star.khi_shift()) ;
00439 star.khi_shift.set().std_base_scal() ;
00440 star.fait_shift_auto() ;
00441
00442 Tenseur copie_dpsi (so.star.d_psi) ;
00443 copie_dpsi.set(2).dec2_dzpuis() ;
00444 if (so.star.is_irrotational()) {
00445 star.d_psi.allocate_all() ;
00446 star.d_psi.set(0).import(star.nzet, copie_dpsi(0)) ;
00447 star.d_psi.set(1).import(star.nzet, copie_dpsi(1)) ;
00448 star.d_psi.set(2).import(star.nzet, copie_dpsi(2)) ;
00449 star.d_psi.set_std_base() ;
00450 }
00451
00452
00453
00454
00455 hole.update_metric(star) ;
00456 star.update_metric(hole) ;
00457 star.update_metric_der_comp(hole) ;
00458 fait_tkij() ;
00459
00460 star.kinematics(omega, x_axe) ;
00461 star.equation_of_state() ;
00462 star.hydro_euler() ;
00463 }
00464
00465
00466
00467
00468 ostream& operator<<(ostream& ost, const Bin_ns_bh& bibi) {
00469 bibi >> ost ;
00470 return ost ;
00471 }
00472
00473
00474 ostream& Bin_ns_bh::operator>>(ostream& ost) const {
00475
00476 using namespace Unites ;
00477
00478 ost << endl ;
00479 ost << "Neutron star - black hole binary system" << endl ;
00480 ost << "=======================================" << endl ;
00481 ost << endl <<
00482 "Orbital angular velocity : " << omega * f_unit << " rad/s" << endl ;
00483 ost <<
00484 "Absolute coordinate X of the rotation axis : " << x_axe / km
00485 << " km" << endl ;
00486 ost << endl << "Neutron star : " << endl ;
00487 ost << "============ " << endl ;
00488 ost << star << endl ;
00489
00490 ost << "Black hole : " << endl ;
00491 ost << "========== " << endl ;
00492 ost << "Coordinate radius of the throat : " << hole.get_rayon() / km << " km" << endl ;
00493 ost << "Absolute abscidia of the throat center : " << (hole.get_mp()).get_ori_x() / km
00494 << " km" << endl ;
00495 return ost ;
00496 }