| 1 |
/* |
| 2 |
* Prepare a file describing a sequence from a list of resformat.d files |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
/* |
| 7 |
* Copyright (c) 2003 Eric Gourgoulhon |
| 8 |
* |
| 9 |
* This file is part of LORENE. |
| 10 |
* |
| 11 |
* LORENE is free software; you can redistribute it and/or modify |
| 12 |
* it under the terms of the GNU General Public License version 2 |
| 13 |
* as published by the Free Software Foundation. |
| 14 |
* |
| 15 |
* LORENE is distributed in the hope that it will be useful, |
| 16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
* GNU General Public License for more details. |
| 19 |
* |
| 20 |
* You should have received a copy of the GNU General Public License |
| 21 |
* along with LORENE; if not, write to the Free Software |
| 22 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 23 |
* |
| 24 |
*/ |
| 25 |
|
| 26 |
char prepare_seq_C[] = "$Header: /cvsroot/Lorene/Codes/Binary_star/prepare_seq.C,v 1.4 2014/10/13 08:53:55 j_novak Exp $" ; |
| 27 |
|
| 28 |
/* |
| 29 |
* $Id: prepare_seq.C,v 1.4 2014/10/13 08:53:55 j_novak Exp $ |
| 30 |
* $Log: prepare_seq.C,v $ |
| 31 |
* Revision 1.4 2014/10/13 08:53:55 j_novak |
| 32 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 33 |
* |
| 34 |
* Revision 1.3 2014/10/06 15:09:41 j_novak |
| 35 |
* Modified #include directives to use c++ syntax. |
| 36 |
* |
| 37 |
* Revision 1.2 2005/09/13 19:47:28 f_limousin |
| 38 |
* Reintroduction of the resolution of the equations in cartesian coordinates. |
| 39 |
* |
| 40 |
* Revision 1.1 2004/09/16 12:15:01 f_limousin |
| 41 |
* *** empty log message *** |
| 42 |
* |
| 43 |
* Revision 1.1 2003/09/16 09:15:33 e_gourgoulhon |
| 44 |
* First version. |
| 45 |
* |
| 46 |
* |
| 47 |
* |
| 48 |
* $Header: /cvsroot/Lorene/Codes/Binary_star/prepare_seq.C,v 1.4 2014/10/13 08:53:55 j_novak Exp $ |
| 49 |
* |
| 50 |
*/ |
| 51 |
|
| 52 |
// C headers |
| 53 |
#include <cmath> |
| 54 |
#include <cstdlib> |
| 55 |
#include "unites.h" |
| 56 |
#include "headcpp.h" |
| 57 |
|
| 58 |
#define maxval(a,b) a < b ? b : a |
| 59 |
#define minval(a,b) a > b ? b : a |
| 60 |
|
| 61 |
using namespace Lorene ; |
| 62 |
|
| 63 |
int main() { |
| 64 |
|
| 65 |
using namespace Unites ; |
| 66 |
|
| 67 |
// For the display : |
| 68 |
char display_bold[]="x[1m" ; display_bold[0] = 27 ; |
| 69 |
char display_normal[] = "x[0m" ; display_normal[0] = 27 ; |
| 70 |
|
| 71 |
ifstream fichlist("list_prepare_seq.d") ; |
| 72 |
if ( !fichlist.good() ) { |
| 73 |
cout << "Problem with opening the file list_prepare_seq.d ! " << endl ; |
| 74 |
abort() ; |
| 75 |
} |
| 76 |
|
| 77 |
ofstream outfich("sequence.d") ; |
| 78 |
|
| 79 |
//----------------------------------------------------- |
| 80 |
// ***** Start of 1st modifiable part ****** |
| 81 |
//----------------------------------------------------- |
| 82 |
|
| 83 |
double m0_half ; |
| 84 |
cout << |
| 85 |
"Gravitational mass of a single star at r->oo [in sollar mass units]? " << endl ; |
| 86 |
cin >> m0_half ; |
| 87 |
double m0 = 2 * m0_half ; |
| 88 |
|
| 89 |
outfich << "# d [km] f_GW [Hz] M_ADM [Msol] Omega*M_inf M_B [Msol] v_m a2/a1 a3/a1 j/m0^2" << endl ; |
| 90 |
|
| 91 |
//----------------------------------------------------- |
| 92 |
// ***** End of 1st modifiable part ****** |
| 93 |
//----------------------------------------------------- |
| 94 |
|
| 95 |
//------------------------------------------------------- |
| 96 |
// Loop of the files seq.d |
| 97 |
//------------------------------------------------------- |
| 98 |
|
| 99 |
char filename[120] ; |
| 100 |
fichlist.getline(filename, 120) ; |
| 101 |
|
| 102 |
while( !fichlist.eof() ) { |
| 103 |
|
| 104 |
cout << filename << endl ; |
| 105 |
if ( (filename[0] != ' ') && (filename[0] != '#') ) { |
| 106 |
|
| 107 |
ifstream infich(filename) ; |
| 108 |
if ( !infich.good() ) { |
| 109 |
cout << "Problem with opening the file " << filename << " ! " << endl ; |
| 110 |
abort() ; |
| 111 |
} |
| 112 |
|
| 113 |
double ve_m ; |
| 114 |
double d_km, d_g_km, d_rel, f_hz, m_adm, m_adm_vol ; |
| 115 |
double m_kom, m_kom_vol, jj ; |
| 116 |
double entc1, enerc1, m_b1, r_eq1, a2sa11, a3sa11 ; |
| 117 |
double entc2, enerc2, m_b2, r_eq2, a2sa12, a3sa12 ; |
| 118 |
|
| 119 |
infich.ignore(1000,'\n') ; // skip first two lines |
| 120 |
infich.ignore(1000,'\n') ; // |
| 121 |
infich >> ve_m ; |
| 122 |
infich.ignore(1000,'\n') ; |
| 123 |
infich.ignore(1000,'\n') ; |
| 124 |
infich >> d_km ; |
| 125 |
infich >> d_g_km ; |
| 126 |
infich >> d_rel ; |
| 127 |
infich >> f_hz ; |
| 128 |
infich >> m_adm ; |
| 129 |
infich >> m_adm_vol ; |
| 130 |
infich >> m_kom ; |
| 131 |
infich >> m_kom_vol ; |
| 132 |
infich >> jj ; |
| 133 |
infich.ignore(1000,'\n') ; |
| 134 |
infich.ignore(1000,'\n') ; |
| 135 |
infich >> entc1 ; |
| 136 |
infich >> enerc1 ; |
| 137 |
infich >> m_b1 ; |
| 138 |
infich >> r_eq1 ; |
| 139 |
infich >> a2sa11 ; |
| 140 |
infich >> a3sa11 ; |
| 141 |
infich.ignore(1000,'\n') ; |
| 142 |
infich.ignore(1000,'\n') ; |
| 143 |
infich >> entc2 ; |
| 144 |
infich >> enerc2 ; |
| 145 |
infich >> m_b2 ; |
| 146 |
infich >> r_eq2 ; |
| 147 |
infich >> a2sa12 ; |
| 148 |
infich >> a3sa12 ; |
| 149 |
infich.ignore(1000,'\n') ; |
| 150 |
|
| 151 |
infich.close() ; |
| 152 |
// --------------------------------------------------- |
| 153 |
// End of file reading |
| 154 |
// --------------------------------------------------- |
| 155 |
|
| 156 |
cout.precision(8); |
| 157 |
cout << "d = " << d_km << display_bold |
| 158 |
<< " f_gw = " << 2*f_hz |
| 159 |
<< " m_adm = " << m_adm |
| 160 |
<< " m_b1 = " << m_b1 |
| 161 |
<< display_normal << " j = " << jj ; |
| 162 |
cout.precision(8) ; |
| 163 |
|
| 164 |
//----------------------------------------------------- |
| 165 |
// ***** Start of 2nd modifiable part ****** |
| 166 |
//----------------------------------------------------- |
| 167 |
|
| 168 |
/* // double m0 = 2 * 2.347359 ; |
| 169 |
// double gm0 = 6.6726E-01 / pow(2.99792458E+8, 3) * |
| 170 |
// 1.989E+20 * m0 ; |
| 171 |
// double om1 = 2.* M_PI * f_hz * gm0 ; |
| 172 |
// double ebind = m_adm / m0 - 1. ; |
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
double om1 = omega_poly * m0 ; |
| 177 |
double ebind = m_adm_poly / m0 - 1. ; |
| 178 |
double jj1 = jj_poly / (m0*m0) ; |
| 179 |
*/ |
| 180 |
|
| 181 |
double kappa = 0.0332 ; |
| 182 |
double gamma = 2. ; |
| 183 |
|
| 184 |
double om1 = f_hz * 2 * M_PI ; |
| 185 |
double jj1 = jj / (m0*m0) ; |
| 186 |
// dM=m_adm-Mg(f=0)+4.056e-4*x^(2/3) |
| 187 |
outfich.setf(ios::scientific) ; |
| 188 |
outfich.precision(4) ; |
| 189 |
outfich << d_km << " "; |
| 190 |
outfich.precision(12) ; |
| 191 |
outfich << f_hz << " "; |
| 192 |
outfich << (m_adm_vol - m0) << " "; |
| 193 |
outfich << om1/f_unit*m0*msol*ggrav << " "; |
| 194 |
outfich << m_b1 << " "; |
| 195 |
outfich.precision(5) ; |
| 196 |
outfich << ve_m << " "; |
| 197 |
outfich << a2sa11 << " "; |
| 198 |
outfich << a3sa11 << " "; |
| 199 |
outfich << jj1 << endl ; |
| 200 |
|
| 201 |
//----------------------------------------------------- |
| 202 |
// ***** End of 2nd modifiable part ***** |
| 203 |
//----------------------------------------------------- |
| 204 |
} |
| 205 |
|
| 206 |
fichlist.getline(filename, 120) ; // next file |
| 207 |
|
| 208 |
} |
| 209 |
|
| 210 |
outfich.close() ; |
| 211 |
|
| 212 |
return 0 ; |
| 213 |
} |