Debian Codegraph @

Codes/Bin_star/prepare_seq.C

raw
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/Bin_star/prepare_seq.C,v 1.3 2014/10/13 08:53:54 j_novak Exp $" ;
27
28 /*
29 * $Id: prepare_seq.C,v 1.3 2014/10/13 08:53:54 j_novak Exp $
30 * $Log: prepare_seq.C,v $
31 * Revision 1.3 2014/10/13 08:53:54 j_novak
32 * Lorene classes and functions now belong to the namespace Lorene.
33 *
34 * Revision 1.2 2014/10/06 15:09:43 j_novak
35 * Modified #include directives to use c++ syntax.
36 *
37 * Revision 1.1 2003/09/16 09:15:33 e_gourgoulhon
38 * First version.
39 *
40 *
41 *
42 * $Header: /cvsroot/Lorene/Codes/Bin_star/prepare_seq.C,v 1.3 2014/10/13 08:53:54 j_novak Exp $
43 *
44 */
45
46 // C++ headers
47 #include <iostream>
48 #include <fstream>
49 using namespace std ;
50
51 // C headers
52 #include <cmath>
53 #include <cstdlib>
54
55 int main() {
56
57 ifstream fichlist("list_prepare_seq.d") ;
58 if ( !fichlist.good() ) {
59 cout << "Problem with opening the file list_prepare_seq.d ! " << endl ;
60 abort() ;
61 }
62
63 ofstream outfich("sequence.d") ;
64
65 //-----------------------------------------------------
66 // ***** Start of 1st modifiable part ******
67 //-----------------------------------------------------
68
69 double m0_half ;
70 cout <<
71 "Value of the gravitational mass of a single star at infinity [poly. unit] ? " << endl ;
72 cin >> m0_half ;
73 double m0 = 2 * m0_half ;
74
75 outfich << "# M_0 Omega (M_ADM - M_0)/M_0 J/M_0^2" << endl ;
76
77 //-----------------------------------------------------
78 // ***** End of 1st modifiable part ******
79 //-----------------------------------------------------
80
81
82
83 //-------------------------------------------------------
84 // Loop of the files seq.d
85 //-------------------------------------------------------
86
87 char filename[120] ;
88 fichlist.getline(filename, 120) ;
89
90 while( !fichlist.eof() ) {
91
92 cout << filename << endl ;
93 if ( (filename[0] != ' ') && (filename[0] != '#') ) {
94
95 ifstream infich(filename) ;
96 if ( !infich.good() ) {
97 cout << "Problem with opening the file " << filename << " ! " << endl ;
98 abort() ;
99 }
100
101 double ve_m, ve_gb, ve_fus ;
102 double d_km, d_g_km, d_rel, f_hz, m_adm, jj ;
103 double entc1, enerc1, m_b1, r_eq1, a2sa11, a3sa11 ;
104 double entc2, enerc2, m_b2, r_eq2, a2sa12, a3sa12 ;
105 double d_poly, d_g_poly, omega_poly, m_adm_poly, jj_poly,
106 m_b1_poly, m_b2_poly ;
107
108 infich.ignore(1000,'\n') ; // skip first two lines
109 infich.ignore(1000,'\n') ; //
110 infich >> ve_m ;
111 infich >> ve_gb ;
112 infich >> ve_fus ;
113 infich.ignore(1000,'\n') ;
114 infich.ignore(1000,'\n') ;
115 infich >> d_km ;
116 infich >> d_g_km ;
117 infich >> d_rel ;
118 infich >> f_hz ;
119 infich >> m_adm ;
120 infich >> jj ;
121 infich.ignore(1000,'\n') ;
122 infich.ignore(1000,'\n') ;
123 infich >> entc1 ;
124 infich >> enerc1 ;
125 infich >> m_b1 ;
126 infich >> r_eq1 ;
127 infich >> a2sa11 ;
128 infich >> a3sa11 ;
129 infich.ignore(1000,'\n') ;
130 infich.ignore(1000,'\n') ;
131 infich >> entc2 ;
132 infich >> enerc2 ;
133 infich >> m_b2 ;
134 infich >> r_eq2 ;
135 infich >> a2sa12 ;
136 infich >> a3sa12 ;
137 infich.ignore(1000,'\n') ;
138
139 if (infich.peek() == '#') { // There exist a line with
140 // polytropic units
141 infich.ignore(1000,'\n') ;
142 infich >> d_poly ;
143 infich >> d_g_poly ;
144 infich >> omega_poly ;
145 infich >> m_adm_poly ;
146 infich >> jj_poly ;
147 infich >> m_b1_poly ;
148 infich >> m_b2_poly ;
149 }
150 else {
151 d_poly = 0 ;
152 d_g_poly = 0 ;
153 omega_poly = 0 ;
154 m_adm_poly = 0 ;
155 jj_poly = 0 ;
156 m_b1_poly = 0 ;
157 m_b2_poly = 0 ;
158 }
159
160 infich.close() ;
161 // ---------------------------------------------------
162 // End of file reading
163 // ---------------------------------------------------
164
165 cout << "d = " << d_km << " f = " << f_hz << " m_b1 = "
166 << m_b1 << endl ;
167 cout << "d_poly = " << d_poly << " omega_poly = "
168 << omega_poly << " m_adm_poly = " << m_adm_poly << endl ;
169
170
171 //-----------------------------------------------------
172 // ***** Start of 2nd modifiable part ******
173 //-----------------------------------------------------
174
175 // double m0 = 2 * 2.347359 ;
176 // double gm0 = 6.6726E-01 / pow(2.99792458E+8, 3) *
177 // 1.989E+20 * m0 ;
178 // double om1 = 2.* M_PI * f_hz * gm0 ;
179 // double ebind = m_adm / m0 - 1. ;
180
181
182 double om1 = omega_poly * m0 ;
183 double ebind = m_adm_poly / m0 - 1. ;
184 double jj1 = jj_poly / (m0*m0) ;
185
186 outfich.precision(14) ;
187 outfich.setf(ios::scientific) ;
188 outfich.width(20) ;
189 outfich << om1 ; outfich.width(23) ;
190 outfich << ebind ; outfich.width(23) ;
191 outfich << jj1 << endl ;
192
193 //-----------------------------------------------------
194 // ***** End of 2nd modifiable part *****
195 //-----------------------------------------------------
196 }
197
198 fichlist.getline(filename, 120) ; // next file
199
200 }
201
202 outfich.close() ;
203
204 return 0 ;
205 }