Debian Codegraph @

Codes/Bin_ns_bh/init_ns_bh.C

raw
1 /*
2 * Construction of initial conditions for a NS-BH binary computation.
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 char init_ns_bh_C[] = "$Header: /cvsroot/Lorene/Codes/Bin_ns_bh/init_ns_bh.C,v 1.11 2014/10/13 08:53:53 j_novak Exp $" ;
28
29 /*
30 * $Id: init_ns_bh.C,v 1.11 2014/10/13 08:53:53 j_novak Exp $
31 * $Log: init_ns_bh.C,v $
32 * Revision 1.11 2014/10/13 08:53:53 j_novak
33 * Lorene classes and functions now belong to the namespace Lorene.
34 *
35 * Revision 1.10 2014/10/06 15:09:42 j_novak
36 * Modified #include directives to use c++ syntax.
37 *
38 * Revision 1.9 2008/09/26 08:44:04 p_grandclement
39 * Mixted binaries with non vanishing spin
40 *
41 * Revision 1.6 2006/04/27 09:12:34 p_grandclement
42 * First try at irrotational black holes
43 *
44 * Revision 1.5 2006/04/25 07:22:00 p_grandclement
45 * Various changes for the NS_BH project
46 *
47 * Revision 1.4 2005/08/29 15:10:19 p_grandclement
48 * Addition of things needed :
49 * 1) For BBH with different masses
50 * 2) Provisory files for the mixted binaries (Bh and NS) : THIS IS NOT
51 * WORKING YET !!!
52 *
53 * Revision 1.3 2004/03/25 12:35:35 j_novak
54 * now using namespace Unites
55 *
56 * Revision 1.2 2002/12/19 14:57:15 e_gourgoulhon
57 * New prototype for Bin_ns_bh::set_omega and set_x_axe.
58 * The BH is now of the left (xa <0) and the NS on the right (xa>0).
59 *
60 * Revision 1.1 2002/12/18 10:33:10 e_gourgoulhon
61 * Computations of NS - BH binaries
62 *
63 *
64 *
65 *
66 * $Header: /cvsroot/Lorene/Codes/Bin_ns_bh/init_ns_bh.C,v 1.11 2014/10/13 08:53:53 j_novak Exp $
67 *
68 */
69
70 // C++ headers
71 #include "headcpp.h"
72
73 // C headers
74 #include <cstdlib>
75 #include <cmath>
76
77 // Lorene headers
78 #include "bin_ns_bh.h"
79 #include "nbr_spx.h"
80 #include "eos.h"
81 #include "unites.h"
82 #include "graphique.h"
83
84 using namespace Lorene ;
85
86 int main(){
87
88 using namespace Unites ;
89 // Identification of all the subroutines called by the code :
90
91 // system("ident init_bin") ;
92
93 //-----------------------------------------------------------------------
94 // Input data for the multi-grid no. 1
95 //-----------------------------------------------------------------------
96
97 int nt, np, nz ;
98 char blabla[80] ;
99
100 ifstream fich("par_grid_ns.d") ;
101 fich.getline(blabla, 80);
102 fich.getline(blabla, 80);
103 fich >> nz; fich.getline(blabla, 80) ;
104 int nzet ;
105 fich >> nzet; fich.getline(blabla, 80) ;
106 fich >> nt; fich.getline(blabla, 80) ;
107 fich >> np; fich.getline(blabla, 80) ;
108
109 cout << "total number of domains : nz = " << nz << endl ;
110 cout << "number of points in phi : np = " << np << endl ;
111 cout << "number of points in theta : nt = " << nt << endl ;
112
113 int* nr = new int[nz];
114 int* nt_tab = new int[nz];
115 int* np_tab = new int[nz];
116 double* bornes = new double[nz+1];
117
118 fich.getline(blabla, 80);
119 for (int l=0; l<nz; l++) {
120 fich >> nr[l];
121 fich >> bornes[l]; fich.getline(blabla, 80) ;
122 np_tab[l] = np ;
123 nt_tab[l] = nt ;
124 }
125 bornes[nz] = __infinity ;
126
127 fich.close();
128
129
130 // Type of r sampling :
131 int* type_r = new int[nz];
132 type_r[0] = RARE ;
133 for (int l=1; l<nz-1; l++) {
134 type_r[l] = FIN ;
135 }
136 type_r[nz-1] = UNSURR ;
137
138 // Type of sampling in theta and phi :
139 int type_t = SYM ;
140 int type_p = NONSYM ;
141
142 //-----------------------------------------------------------------------
143 // Construction of multi-grid and mapping for the NS
144 //-----------------------------------------------------------------------
145
146 Mg3d mg_ns(nz, nr, type_r, nt_tab, type_t, np_tab, type_p) ;
147
148 Map_et mp_ns(mg_ns, bornes) ;
149
150 delete [] nr ;
151 delete [] nt_tab ;
152 delete [] np_tab ;
153 delete [] type_r ;
154 delete [] bornes ;
155
156 //-----------------------------------------------------------------------
157 // Input data for the BH multi-grid
158 //-----------------------------------------------------------------------
159
160
161 fich.open("par_grid_bh.d") ;
162 fich.getline(blabla, 80);
163 fich.getline(blabla, 80);
164 fich >> nz; fich.getline(blabla, 80) ;
165 fich >> nt; fich.getline(blabla, 80) ;
166 fich >> np; fich.getline(blabla, 80) ;
167
168 cout << "total number of domains : nz = " << nz << endl ;
169 cout << "number of points in phi : np = " << np << endl ;
170 cout << "number of points in theta : nt = " << nt << endl ;
171
172 nr = new int[nz];
173 nt_tab = new int[nz];
174 np_tab = new int[nz];
175 bornes = new double[nz+1];
176
177 fich.getline(blabla, 80);
178 for (int l=0; l<nz; l++) {
179 fich >> nr[l];
180 fich >> bornes[l]; fich.getline(blabla, 80) ;
181 np_tab[l] = np ;
182 nt_tab[l] = nt ;
183 }
184 bornes[nz] = __infinity ;
185
186 fich.close();
187
188
189 // Type of r sampling :
190 type_r = new int[nz];
191 type_r[0] = RARE ;
192 for (int l=1; l<nz-1; l++) {
193 type_r[l] = FIN ;
194 }
195 type_r[nz-1] = UNSURR ;
196
197 //-----------------------------------------------------------------------
198 // Construction of multi-grid and mapping for the BH
199 //-----------------------------------------------------------------------
200
201 Mg3d mg_bh(nz, nr, type_r, nt_tab, type_t, np_tab, type_p) ;
202
203 Map_af mp_bh(mg_bh, bornes) ;
204
205 delete [] nr ;
206 delete [] nt_tab ;
207 delete [] np_tab ;
208 delete [] type_r ;
209 delete [] bornes ;
210
211 cout << endl << "NS multi-grid : "
212 << endl << "============== " << endl << mg_ns << endl ;
213 cout << "NS mapping : "
214 << endl << "=========== " << endl << mp_ns << endl ;
215
216 cout << endl << "BH multi-grid : "
217 << endl << "============= " << endl << mg_bh << endl ;
218 cout << "BH mapping : "
219 << endl << "=========== " << endl << mp_bh << endl ;
220
221 //-----------------------------------------------------------------------
222 // Equation of state for the star
223 //-----------------------------------------------------------------------
224
225 fich.open("par_eos.d") ;
226
227 Eos* peos = Eos::eos_from_file(fich) ;
228 Eos& eos = *peos ;
229
230 fich.close() ;
231
232 cout << endl << "Equation of state for the star : "
233 << endl << "============================== " << endl << eos << endl ;
234
235 //-----------------------------------------------------------------------
236 // Physical parameters imput
237 //-----------------------------------------------------------------------
238
239 fich.open("par_init.d") ;
240 fich.getline(blabla, 80) ;
241 fich.getline(blabla, 80) ;
242
243 double separ ;
244 fich >> separ; fich.getline(blabla, 80) ;
245 separ *= km ; // translation in Lorene units
246
247 int irrot_i ;
248 int state_rot_bh ;
249 double ent_c ;
250 fich >> ent_c ; fich.getline(blabla, 80) ;
251 fich >> irrot_i ; fich.getline(blabla, 80) ;
252 fich >> state_rot_bh ; fich.getline(blabla, 80) ;
253 bool irrot_ns = (irrot_i == 1) ;
254 double lapse_hori ;
255 fich >> lapse_hori ; fich.getline(blabla, 80) ;
256
257 fich.close() ;
258
259 cout << endl << "Requested orbital separation : " << separ / km
260 << " km" << endl ;
261
262 //-----------------------------------------------------------------------
263 // Construction of the binary system
264 //-----------------------------------------------------------------------
265
266 Bin_ns_bh bibi(mp_ns, nzet, eos, irrot_ns, mp_bh) ;
267 bibi.set_bh().set_rot_state(state_rot_bh) ;
268 bibi.set_bh().set_lapse_hori(lapse_hori) ;
269
270 //-----------------------------------------------------------------------
271 // Computation of two static configurations
272 //-----------------------------------------------------------------------
273
274 double precis = 1.e-6 ;
275
276 cout << endl << "Computation of a static configuration for the star"
277 << endl << "=================================================" << endl ;
278
279 (bibi.set_ns()).equilibrium_spher(ent_c, precis) ;
280
281 cout << endl << "Computation of a static configuration for the black hole"
282 << endl << "=======================================================" << endl ;
283
284 (bibi.set_bh()).init_bhole_seul() ; // Initialization to some kind of Schwarzschild
285
286
287 //-----------------------------------------------------------------------
288 // Sets the stars at Newtonian (Keplerian) position
289 //-----------------------------------------------------------------------
290
291 // Omega and rotation axis
292 // -----------------------
293
294 double mass_ns = (bibi.get_ns()).mass_g() ;
295 double mass_bh = (bibi.get_bh()).masse_adm_seul() / ggrav ;
296 double total_mass = mass_ns + mass_bh ;
297
298 cout << "NS mass : " << mass_ns / msol << " M_sol" << endl ;
299 cout << "BH mass : " << mass_bh / msol << " M_sol" << endl ;
300 bibi.set_x_axe(0.) ;
301
302 // Position of the two objects
303 // ---------------------------
304
305 double xa_ns = mass_bh / total_mass * separ ;
306 ((bibi.set_ns()).set_mp()).set_ori(xa_ns, 0., 0.) ;
307
308 double xa_bh = - mass_ns / total_mass * separ ;
309 ((bibi.set_bh()).set_mp()).set_ori(xa_bh, 0., 0.) ;
310
311 // Orientation of the two stars
312 // ----------------------------
313
314 // NS aligned with the absolute frame :
315 ((bibi.set_ns()).set_mp()).set_rot_phi(M_PI) ;
316
317 // BH anti-aligned with the absolute frame :
318 ((bibi.set_bh()).set_mp()).set_rot_phi(0) ;
319
320 // On decouple
321
322 bibi.init_auto() ;
323 int ite ;
324 bibi.pseudo_misner (ite, 200, 0.7, precis, 0, lapse_hori) ;
325
326
327 cout << endl
328 << "=============================================================" << endl
329 << "=============================================================" << endl ;
330 cout << endl << "Final characteristics of the computed system : " << endl ;
331 cout.precision(16) ;
332 cout << bibi << endl ;
333
334 //-----------------------------------------------------------------------
335 // The result is written in a file
336 //-----------------------------------------------------------------------
337 FILE* fresu = fopen("statiques.dat", "w") ;
338
339 mg_ns.sauve(fresu) ;
340 mp_ns.sauve(fresu) ;
341 eos.sauve(fresu) ;
342
343 mg_bh.sauve(fresu) ;
344 mp_bh.sauve(fresu) ;
345
346 bibi.sauve(fresu) ;
347
348 fclose(fresu) ;
349
350 // Cleaning
351 // --------
352
353 delete peos ;
354
355 return EXIT_SUCCESS ;
356
357 }
358