| 1 |
/* |
| 2 |
* Main code for computation of binary black hole quasiequilibrium |
| 3 |
* configurations |
| 4 |
* |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
/* |
| 9 |
* Copyright (c) 2002 Philippe Grandclement |
| 10 |
* |
| 11 |
* This file is part of LORENE. |
| 12 |
* |
| 13 |
* LORENE is free software; you can redistribute it and/or modify |
| 14 |
* it under the terms of the GNU General Public License version 2 |
| 15 |
* as published by the Free Software Foundation. |
| 16 |
* |
| 17 |
* LORENE is distributed in the hope that it will be useful, |
| 18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 |
* GNU General Public License for more details. |
| 21 |
* |
| 22 |
* You should have received a copy of the GNU General Public License |
| 23 |
* along with LORENE; if not, write to the Free Software |
| 24 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 |
* |
| 26 |
*/ |
| 27 |
|
| 28 |
char coal_bh_C[] = "$Header: /cvsroot/Lorene/Codes/Bin_BH/coal_bh.C,v 1.6 2014/10/13 08:53:52 j_novak Exp $" ; |
| 29 |
|
| 30 |
/* |
| 31 |
* $Id: coal_bh.C,v 1.6 2014/10/13 08:53:52 j_novak Exp $ |
| 32 |
* $Log: coal_bh.C,v $ |
| 33 |
* Revision 1.6 2014/10/13 08:53:52 j_novak |
| 34 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 35 |
* |
| 36 |
* Revision 1.5 2014/10/06 15:09:41 j_novak |
| 37 |
* Modified #include directives to use c++ syntax. |
| 38 |
* |
| 39 |
* Revision 1.4 2004/03/25 12:35:35 j_novak |
| 40 |
* now using namespace Unites |
| 41 |
* |
| 42 |
* Revision 1.3 2003/11/14 08:14:52 p_grandclement |
| 43 |
* Correction of the codes for binary black holes in circular orbit |
| 44 |
* |
| 45 |
* Revision 1.2 2003/04/09 15:01:14 e_gourgoulhon |
| 46 |
* |
| 47 |
* Added copyright and log messages. |
| 48 |
* |
| 49 |
* |
| 50 |
* revision 1.1 |
| 51 |
* date: 2003/03/31 16:08:23; author: p_grandclement; state: Exp; |
| 52 |
* Add codes for the binary black holes computation : |
| 53 |
* - init_bh.C : computes the Misner-Lindquist solution (used as initial guess for the coal code) |
| 54 |
* - param_statiques.d : example of parameter file for init_bh |
| 55 |
* - coal_bh.C : computation of the binary |
| 56 |
* - param_coal.d : example of the paramater file for coal_bh |
| 57 |
* - lit_holes_bin.C : reads a configuration. |
| 58 |
* |
| 59 |
* $Header: /cvsroot/Lorene/Codes/Bin_BH/coal_bh.C,v 1.6 2014/10/13 08:53:52 j_novak Exp $ |
| 60 |
* |
| 61 |
*/ |
| 62 |
|
| 63 |
|
| 64 |
//standard |
| 65 |
#include <cstdlib> |
| 66 |
#include <cmath> |
| 67 |
|
| 68 |
// LORENE |
| 69 |
#include "type_parite.h" |
| 70 |
#include "nbr_spx.h" |
| 71 |
#include "proto.h" |
| 72 |
#include "coord.h" |
| 73 |
#include "tenseur.h" |
| 74 |
#include "bhole.h" |
| 75 |
#include "utilitaires.h" |
| 76 |
#include "graphique.h" |
| 77 |
|
| 78 |
using namespace Lorene ; |
| 79 |
|
| 80 |
int main(int argc, char** argv) { |
| 81 |
|
| 82 |
// Lecture du fichier de parametres : |
| 83 |
if (argc <3) { |
| 84 |
cout <<" Passer nom des fichiers en arguments SVP !" << endl ; |
| 85 |
abort() ; |
| 86 |
} |
| 87 |
|
| 88 |
char* name_fich = argv[2] ; |
| 89 |
|
| 90 |
FILE* fich = fopen(name_fich, "r") ; |
| 91 |
Mg3d grille (fich) ; |
| 92 |
Map_af map_un (grille, fich) ; |
| 93 |
Map_af map_deux (grille, fich) ; |
| 94 |
Bhole hole_un (map_un, fich) ; |
| 95 |
Bhole hole_deux (map_deux, fich) ; |
| 96 |
fclose(fich) ; |
| 97 |
|
| 98 |
char blabla [120] ; |
| 99 |
name_fich = argv[1] ; |
| 100 |
ifstream param(name_fich) ; |
| 101 |
|
| 102 |
double omega_inf, omega_sup, precis, |
| 103 |
relax, precis_viriel ; |
| 104 |
int nbre_homme ; |
| 105 |
|
| 106 |
param >> omega_inf ; param >> omega_sup ; param.getline(blabla, 120) ; |
| 107 |
param >> precis ; param.getline(blabla, 120) ; |
| 108 |
param >> precis_viriel ; param.getline(blabla, 120) ; |
| 109 |
param >> relax ; param.getline(blabla, 120) ; |
| 110 |
param >> nbre_homme ; param.getline(blabla, 120) ; |
| 111 |
|
| 112 |
param.close() ; |
| 113 |
|
| 114 |
// Le fichier sortie pour la recherche de omega : |
| 115 |
char name_omega[20] ; |
| 116 |
sprintf(name_omega, "omega.dat") ; |
| 117 |
ofstream fiche_omega(name_omega) ; |
| 118 |
fiche_omega.precision(8) ; |
| 119 |
|
| 120 |
Bhole_binaire bin (map_un, map_deux) ; |
| 121 |
bin.set(1) = hole_un ; |
| 122 |
bin.set(2) = hole_deux ; |
| 123 |
bin.set_omega(0) ; |
| 124 |
bin.set(1).fait_n_comp (bin(2)) ; |
| 125 |
bin.set(1).fait_psi_comp (bin(2)) ; |
| 126 |
bin.set(2).fait_n_comp (bin(1)) ; |
| 127 |
bin.set(2).fait_psi_comp (bin(1)) ; |
| 128 |
bin.fait_decouple() ; |
| 129 |
bin.fait_tkij() ; |
| 130 |
|
| 131 |
double beta = bin(1).get_mp().get_ori_x() - bin(2).get_mp().get_ori_x() ; |
| 132 |
beta /= bin(1).get_rayon() ; |
| 133 |
|
| 134 |
cout << "CALCUL AVEC BETA = " << beta << endl ; |
| 135 |
|
| 136 |
Bhole_binaire courant(map_un, map_deux) ; |
| 137 |
|
| 138 |
courant = bin ; |
| 139 |
double omega_min = omega_inf ; |
| 140 |
double erreur_min = courant.coal (omega_min, precis, relax, nbre_homme, 1) ; |
| 141 |
fiche_omega << omega_min << " " << erreur_min << endl ; |
| 142 |
if (erreur_min < 0) { |
| 143 |
cout << "Borne inf. too big" << endl ; |
| 144 |
abort() ; |
| 145 |
} |
| 146 |
|
| 147 |
courant = bin ; |
| 148 |
double omega_max = omega_sup ; |
| 149 |
double erreur_max = courant.coal (omega_max, precis, relax, nbre_homme, 1) ; |
| 150 |
if (erreur_max > 0) { |
| 151 |
cout << "Borne max. too small" << endl ; |
| 152 |
abort() ; |
| 153 |
} |
| 154 |
fiche_omega << omega_max << " " << erreur_max << endl ; |
| 155 |
|
| 156 |
bool boucle = true ; |
| 157 |
double erreur, omega ; |
| 158 |
|
| 159 |
while (boucle) { |
| 160 |
|
| 161 |
courant = bin ; |
| 162 |
omega = omega_min - erreur_min * (omega_max-omega_min)/(erreur_max-erreur_min) ; |
| 163 |
erreur = courant.coal (omega, precis, relax, nbre_homme, 1) ; |
| 164 |
|
| 165 |
fiche_omega << omega << " " << erreur << endl ; |
| 166 |
|
| 167 |
if (fabs(erreur) < precis_viriel) |
| 168 |
boucle = false ; |
| 169 |
|
| 170 |
|
| 171 |
if (erreur > 0) { |
| 172 |
omega_min = omega ; |
| 173 |
erreur_min = erreur ; |
| 174 |
} |
| 175 |
else { |
| 176 |
omega_max = omega ; |
| 177 |
erreur_max = erreur ; |
| 178 |
} |
| 179 |
} |
| 180 |
|
| 181 |
char name[20] ; |
| 182 |
sprintf(name, "bin_%e.dat", omega) ; |
| 183 |
FILE* fich_sortie = fopen(name, "w") ; |
| 184 |
grille.sauve(fich_sortie) ; |
| 185 |
map_un.sauve(fich_sortie) ; |
| 186 |
map_deux.sauve(fich_sortie) ; |
| 187 |
courant(1).sauve(fich_sortie) ; |
| 188 |
courant(2).sauve(fich_sortie) ; |
| 189 |
fclose(fich_sortie) ; |
| 190 |
|
| 191 |
fiche_omega.close() ; |
| 192 |
return 1 ; |
| 193 |
} |