File: prepare_seq.C

package info (click to toggle)
lorene 0.0.0~cvs20161116%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 26,472 kB
  • sloc: cpp: 212,946; fortran: 21,645; makefile: 1,750; sh: 4
file content (213 lines) | stat: -rw-r--r-- 6,332 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/*
 *  Prepare a file describing a sequence from a list of resformat.d files
 *  
 */

/*
 *   Copyright (c) 2003  Eric Gourgoulhon
 *
 *   This file is part of LORENE.
 *
 *   LORENE is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License version 2
 *   as published by the Free Software Foundation.
 *
 *   LORENE is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with LORENE; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

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 $" ;

/*
 * $Id: prepare_seq.C,v 1.4 2014/10/13 08:53:55 j_novak Exp $
 * $Log: prepare_seq.C,v $
 * Revision 1.4  2014/10/13 08:53:55  j_novak
 * Lorene classes and functions now belong to the namespace Lorene.
 *
 * Revision 1.3  2014/10/06 15:09:41  j_novak
 * Modified #include directives to use c++ syntax.
 *
 * Revision 1.2  2005/09/13 19:47:28  f_limousin
 * Reintroduction of the resolution of the equations in cartesian coordinates.
 *
 * Revision 1.1  2004/09/16 12:15:01  f_limousin
 * *** empty log message ***
 *
 * Revision 1.1  2003/09/16 09:15:33  e_gourgoulhon
 * First version.
 *
 *
 *
 * $Header: /cvsroot/Lorene/Codes/Binary_star/prepare_seq.C,v 1.4 2014/10/13 08:53:55 j_novak Exp $
 *
 */

// C headers
#include <cmath>
#include <cstdlib>
#include "unites.h"
#include "headcpp.h"

#define maxval(a,b) a < b ? b : a
#define minval(a,b) a > b ? b : a

using namespace Lorene ;

int main() {

    using namespace Unites ;

    // For the display :
    char display_bold[]="x[1m" ; display_bold[0] = 27 ;
    char display_normal[] = "x[0m" ; display_normal[0] = 27 ;

	ifstream fichlist("list_prepare_seq.d") ; 
	if ( !fichlist.good() ) {
		cout << "Problem with opening the file list_prepare_seq.d ! " << endl ;
		abort() ;
	}

	ofstream outfich("sequence.d") ; 

	//-----------------------------------------------------
	//  ***** Start of 1st modifiable part ******
	//-----------------------------------------------------

	double m0_half ;
	cout << 
	"Gravitational mass of a single star at r->oo [in sollar mass units]? " << endl ;
	cin >> m0_half ; 
	double m0 = 2 * m0_half ;
	
	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 ; 
	
	//-----------------------------------------------------
	//  ***** End of 1st modifiable part ******
	//-----------------------------------------------------

	//-------------------------------------------------------
	//  Loop of the files seq.d
	//-------------------------------------------------------
	
	char filename[120] ; 
	fichlist.getline(filename, 120) ; 

	while( !fichlist.eof() ) {

		cout << filename << endl ; 
		if ( (filename[0] != ' ') && (filename[0] != '#') ) {

			ifstream infich(filename) ;
			if ( !infich.good() ) {
		    	cout << "Problem with opening the file " << filename << " ! " << endl ;
		    	abort() ;
			}
	
			double ve_m ;
			double d_km, d_g_km, d_rel, f_hz, m_adm, m_adm_vol ;
			double m_kom, m_kom_vol, jj ; 
			double entc1, enerc1, m_b1, r_eq1, a2sa11, a3sa11 ; 
			double entc2, enerc2, m_b2, r_eq2, a2sa12, a3sa12 ; 
	
			infich.ignore(1000,'\n') ; // skip first two lines
			infich.ignore(1000,'\n') ; //
			infich >> ve_m ;
			infich.ignore(1000,'\n') ;  
			infich.ignore(1000,'\n') ;  
			infich >> d_km ; 
			infich >> d_g_km ;
			infich >> d_rel ;
			infich >>  f_hz ;
			infich >>  m_adm ;
			infich >>  m_adm_vol ;
			infich >>  m_kom ;
			infich >>  m_kom_vol ;
			infich >>  jj ;
			infich.ignore(1000,'\n') ;
			infich.ignore(1000,'\n') ;
			infich >> entc1 ;
			infich >>  enerc1 ;
			infich >>  m_b1 ;
			infich >>  r_eq1 ;
			infich >>  a2sa11 ;
			infich >>  a3sa11 ; 
			infich.ignore(1000,'\n') ;
			infich.ignore(1000,'\n') ;
			infich >> entc2 ;
			infich >>  enerc2 ;
			infich >>  m_b2 ;
			infich >>  r_eq2 ;
			infich >>  a2sa12 ;
			infich >>  a3sa12 ; 
			infich.ignore(1000,'\n') ;

			infich.close() ; 
			// ---------------------------------------------------
			//  End of file reading
			// ---------------------------------------------------

			    cout.precision(8);
			cout << "d = " << d_km << display_bold 
                             << " f_gw = " << 2*f_hz
                             << " m_adm = " << m_adm
                             << " m_b1 = " << m_b1 
                             << display_normal << " j = " << jj ; 
			    cout.precision(8) ;             
			    
			//-----------------------------------------------------
			//  ***** Start of 2nd modifiable part ******
			//-----------------------------------------------------

/* 			// double m0 = 2 * 2.347359 ; 
			// double gm0 = 6.6726E-01 / pow(2.99792458E+8, 3) *
			// 			1.989E+20 * m0 ;
			// double om1 = 2.* M_PI * f_hz * gm0 ; 
			// double ebind = m_adm / m0 - 1. ;

                                                

			double om1 = omega_poly * m0 ; 
			double ebind = m_adm_poly / m0 - 1. ;
			double jj1 = jj_poly / (m0*m0) ; 
*/
			    
			    double kappa = 0.0332 ;
			    double gamma = 2. ;

			double om1 = f_hz * 2 * M_PI ; 
			double jj1 = jj / (m0*m0) ; 
//                      dM=m_adm-Mg(f=0)+4.056e-4*x^(2/3)
			outfich.setf(ios::scientific) ; 
                        outfich.precision(4) ; 
			outfich << d_km  << " ";
			outfich.precision(12) ;  
                        outfich << f_hz  << " "; 
                        outfich << (m_adm_vol - m0)  << " "; 
			outfich << om1/f_unit*m0*msol*ggrav  << " "; 
			outfich << m_b1  << " ";
                        outfich.precision(5) ;  
			outfich << ve_m << " "; 
			outfich << a2sa11 << " "; 
			outfich << a3sa11 << " "; 
			outfich << jj1  << endl ; 

			//-----------------------------------------------------
			//  ***** End of 2nd modifiable part ***** 
			//-----------------------------------------------------
		}

		fichlist.getline(filename, 120) ; 	// next file

	}
	
	outfich.close() ; 
		
	return 0 ; 
}