Debian Codegraph @

Codes/Rot_star/examrot.C

raw
1 /*
2 * Copyright (c) 1999-2001 Eric Gourgoulhon
3 *
4 * This file is part of LORENE.
5 *
6 * LORENE is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * LORENE is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with LORENE; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21
22 char examrot_C[] = "$Header: /cvsroot/Lorene/Codes/Rot_star/examrot.C,v 1.5 2014/10/13 08:53:58 j_novak Exp $" ;
23
24 /*
25 * $Id: examrot.C,v 1.5 2014/10/13 08:53:58 j_novak Exp $
26 * $Log: examrot.C,v $
27 * Revision 1.5 2014/10/13 08:53:58 j_novak
28 * Lorene classes and functions now belong to the namespace Lorene.
29 *
30 * Revision 1.4 2014/10/06 15:09:45 j_novak
31 * Modified #include directives to use c++ syntax.
32 *
33 * Revision 1.3 2004/03/25 12:35:43 j_novak
34 * now using namespace Unites
35 *
36 * Revision 1.2 2003/01/09 11:07:50 j_novak
37 * headcpp.h is now compliant with C++ norm.
38 * The include files have been ordered, as well as the local_settings_linux
39 *
40 * Revision 1.1.1.1 2001/11/20 15:19:31 e_gourgoulhon
41 * LORENE
42 *
43 * Revision 1.3 2001/10/16 14:54:00 eric
44 * get_omega() --> get_omega_c().
45 *
46 * Revision 1.2 2001/10/10 13:58:30 eric
47 * Modif Joachim: traitement des legendes graphiques
48 *
49 * Revision 1.1 2000/11/24 13:29:48 eric
50 * Initial revision
51 *
52 *
53 * $Header: /cvsroot/Lorene/Codes/Rot_star/examrot.C,v 1.5 2014/10/13 08:53:58 j_novak Exp $
54 *
55 */
56
57 // headers C
58 #include <cstdlib>
59 #include <cstring>
60 #include <cmath>
61
62 // headers Lorene
63 #include "etoile.h"
64 #include "eos.h"
65 #include "utilitaires.h"
66 #include "graphique.h"
67 #include "unites.h"
68
69 namespace Lorene {
70
71 // Local prototype (for drawings only)
72 Cmp raccord_c1(const Cmp& uu, int l1) ;
73
74 }
75 //******************************************************************************
76
77 using namespace Lorene ;
78
79 int main(int argc, char** argv){
80
81 using namespace Unites ;
82
83 if (argc < 2) {
84 cout <<
85 "examrot : the name of a file containing a stellar configuration"
86 << endl << " must be given in argument !" << endl ;
87 abort() ;
88 }
89
90 char* nomresu = argv[1] ;
91 cout << "Name of the file to be read : " << nomresu << endl ;
92
93 cout << endl <<
94 "Do you want to draw the boundaries of the various domains (y/n) ? [y]"
95 << endl ;
96 char rep ;
97 cin.get(rep) ;
98 bool draw_bound = !(rep == 'n') ;
99
100
101 FILE* fich = fopen(nomresu, "r") ; // open binary file in readonly
102
103 Mg3d mg(fich) ;
104 Map_et mp(mg, fich) ;
105
106 Eos* peos = Eos::eos_from_file(fich) ;
107
108 Etoile_rot star(mp, *peos, fich) ;
109
110 fclose(fich) ;
111
112 star.update_metric() ;
113 star.equation_of_state() ;
114 star.hydro_euler() ;
115
116
117 cout.precision(10) ;
118 cout << star << endl ;
119
120
121 // Formula (150) of Shapiro & Zane (1998) --> tsw1
122 double tcin = 0.5 * star.get_omega_c() * star.angu_mom() ;
123 double tsw1 = tcin / ( tcin + star.mass_b() - star.mass_g() ) ;
124
125 cout << "tsw, tsw1 : " << star.tsw() << " " << tsw1 << endl ;
126
127
128 // Print of the enthalpy field
129 cout << "Enthalpy : " << endl ;
130 cout << star.get_ent() << endl ;
131 arrete() ;
132
133 // Print of the energy density field
134 cout << "Proper energy density : " << endl ;
135 cout << star.get_ener() << endl ;
136 arrete() ;
137
138
139 int nzet = star.get_nzet() ;
140
141 // Drawing of the mapping
142 // ----------------------
143
144 for (int l=0; l<nzet; l++) {
145 des_map_et(mp, l) ;
146 }
147
148 // 2-D drawings
149 // ------------
150
151 char title[80] ;
152 char bslash[2] = {92, '\0'} ; // 92 is the ASCII code for backslash
153
154 // Cmp defining the surface of the star (via the enthalpy field)
155 Cmp surf = star.get_ent()() ;
156 Cmp surf_ext(mp) ;
157 surf_ext = - 0.2 * surf(0, 0, 0, 0) ;
158 surf_ext.annule(0, star.get_nzet()-1) ;
159 surf.annule(star.get_nzet(), mg.get_nzone()-1) ;
160 surf = surf + surf_ext ;
161 surf = raccord_c1(surf, star.get_nzet()) ;
162
163 double zoom = 1.2 ;
164
165 // Only the surface and possible transitions]
166 cout << "Value of the enthalpy defining the transition ?" << endl ;
167 double ent_trans ;
168 cin >> ent_trans ;
169 Cmp transit = star.get_ent()() - ent_trans ;
170
171 // ... surface of the star
172 int newgraph = 1 ; // opens the device
173 double ray = zoom * star.ray_eq() ;
174 des_surface_y(surf, 0., "?", newgraph, -ray, ray, -ray, ray,
175 "x [km]", "z [km]") ;
176
177 // ... transition surface
178 newgraph = 2 ; // closes the device at the end of the plot
179 des_surface_y(transit, 0., "?", newgraph, -ray, ray, -ray, ray,
180 "x [km]", "z [km]") ;
181
182
183 // Various fields
184 des_coupe_y(star.get_ent()(), 0., nzet, "Enthalpy", &surf, zoom,
185 draw_bound) ;
186
187 if (mg.get_np(0) > 1) {
188 des_coupe_z(star.get_ent()(), 0., nzet, "Enthalpy (equatorial plane)",
189 &surf, zoom, draw_bound) ;
190 }
191
192 char partit[] = {92, 'g', 'n', '\0'} ;
193 strcpy(title, "Gravitational potential ") ;
194 strcat(title, partit) ;
195 strcat(title," ") ;
196
197 des_coupe_y(star.get_logn()(), 0., nzet, title, &surf, zoom,
198 draw_bound) ;
199
200
201 strcpy(title, "Azimuthal shift N") ;
202 strcat(title, bslash) ;
203 strcat(title, "u") ;
204 strcat(title, bslash) ;
205 strcat(title, "gf") ;
206 des_coupe_y(star.get_nphi()(), 0., nzet, title, &surf, zoom,
207 draw_bound) ;
208
209 strcpy(title, "Metric potential ") ;
210 strcat(title, bslash) ;
211 strcat(title, "gz") ;
212 des_coupe_y(star.get_dzeta()(), 0., nzet, title, &surf, zoom,
213 draw_bound) ;
214
215 strcpy(title, "Metric potential (NB-1) r sin") ;
216 strcat(title, bslash) ;
217 strcat(title, "gh") ;
218 des_coupe_y(star.get_tggg()(), 0., nzet, title, &surf, zoom,
219 draw_bound) ;
220
221
222 char debtit[] = {'A', 92, 'u', '2', 92, 'd', ' ', 'K', 92, 'u', '\0'} ;
223 strcpy(title, debtit) ;
224 strcat(title, "ij") ;
225 strcat(title, bslash) ;
226 strcat(title, "d K") ;
227 strcat(title, bslash) ;
228 strcat(title, "dij") ;
229 strcat(title, bslash) ;
230 strcat(title, "u") ;
231
232 des_coupe_y(star.get_ak_car()(), 0., nzet, title, &surf, zoom,
233 draw_bound) ;
234
235 // 1-D plots
236 // ---------
237
238 // Energy density
239 double r_min = 0 ; // plot starts at center
240 double r_max = star.ray_eq() ;
241 double theta = M_PI / 2 ;
242 double phi = 0 ;
243 des_profile(star.get_ener()(), r_min, r_max, theta, phi,
244 "Proper energy density [rho_nuc]") ;
245
246 // Outputs in file for Xmgr, Gnuplot, ...
247
248 ofstream fdata("profiles.d") ;
249 fdata << "# r [km] e(theta=pi/2) e(theta=0)" << endl ;
250
251 r_min = 0 ;
252 r_max = star.ray_eq() ;
253 int npt = 200 ;
254
255 for (int i=0; i<npt; i++) {
256
257 double r = r_min + double(i) * (r_max -r_min) / double(npt-1) ;
258
259 theta = M_PI / 2. ;
260 double uu1 = star.get_ener()().val_point(r,theta,phi) ;
261
262 theta = 0 ;
263 double uu2 = star.get_ener()().val_point(r,theta,phi) ;
264
265 fdata << r / km << " " << uu1 << " " << uu2 ;
266
267
268 fdata << endl ;
269 }
270
271 fdata.close() ;
272
273
274
275 // Cleaning
276 // --------
277
278 delete peos ;
279
280 exit(EXIT_SUCCESS) ;
281
282 return EXIT_SUCCESS ;
283
284 }