Debian Codegraph @

Export/C++/Include/mag_ns.h

raw symbols SCIP
1 /*
2 * Definition of class Mag_NS (magnetized neutron star exportation)
3 *
4 */
5
6 /*
7 * Copyright (c) 2002 Eric Gourgoulhon
8 * Copyright (c) 2009 Jerome Novak
9 *
10 * This file is part of LORENE.
11 *
12 * LORENE is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2
14 * as published by the Free Software Foundation.
15 *
16 * LORENE is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with LORENE; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27 #ifndef __MAG_NS_H_
28 #define __MAG_NS_H_
29
30 /*
31 * $Id: mag_ns.h,v 1.3 2014/10/13 08:54:05 j_novak Exp $
32 * $Log: mag_ns.h,v $
33 * Revision 1.3 2014/10/13 08:54:05 j_novak
34 * Lorene classes and functions now belong to the namespace Lorene.
35 *
36 * Revision 1.2 2014/10/06 15:13:25 j_novak
37 * Modified #include directives to use c++ syntax.
38 *
39 * Revision 1.1 2009/11/19 16:15:21 j_novak
40 * Export class for magnetized neutron stars.
41 *
42 *
43 *
44 * $Header: /cvsroot/Lorene/Export/C++/Include/mag_ns.h,v 1.3 2014/10/13 08:54:05 j_novak Exp $
45 *
46 */
47
48 // Headers C
49 #include <cstdio>
50
51 #include <iostream>
52 #include <fstream>
53 using namespace std ;
54
55 namespace Lorene {
56 /**
57 * Magnetized neutron star configuration on a Cartesian grid.
58 *
59 * A magnetized neutron star is constructed on a Cartesian grid from
60 * data stored in a file resulting from a computation obtained from the
61 * code magstar following the Bocquet et al. (1995) paper.
62 *
63 * Importation of Lorene data is performed by means of the constructor
64 * {\tt Mag\_NS::Mag\_NS(int, const double*, const double*, const double*, const char*)}.
65 * This constructor takes general arrays for the location of the Cartesian coordinates
66 * $(x, y, z)$, i.e. it does not assume that the grid is a uniform one. Note also
67 * that these arrays are 1-D, as well as all the metric fields,
68 * in order to be use with any ordering of the 3-D storage. For the definitions of units,
69 * see the file Lorene/C++/Include/unites.h
70 *
71 * This class is very simple, with all data members being public.
72 * A typical example of use is the following one
73 *
74 * \begin{verbatim}
75 * // Define the Cartesian grid by means of the arrays xg, yg, zg:
76 * for (int i=0; i<nb_points; i++) {
77 * xg[i] = ...
78 * yg[i] = ...
79 * zg[i] = ...
80 * }
81 *
82 * // Read the file containing the spectral data and evaluate
83 * // all the fields on the Cartesian grid :
84 *
85 * Mag_NS star_mag(nb_points, xg, yg, zg, datafile) ;
86 *
87 * // Extract what you need :
88 *
89 * double* gamma_xx = binary_system.g_xx ; // metric coefficient g_xx
90 *
91 * double* shift_x = binary_system.beta_x ; // x comp. of shift vector
92 *
93 * ...
94 *
95 * // Save everything in an ASCII file :
96 *
97 * ofstream file_ini("ini.d") ;
98 * binary_system.save_form(file_ini) ;
99 * file_ini.close() ;
100 *
101 * \end{verbatim}
102 *
103 * @version #$Id: mag_ns.h,v 1.3 2014/10/13 08:54:05 j_novak Exp $#
104 */
105
106 class Mag_NS {
107
108 // Data :
109 // -----
110 public:
111 /// Eos name star
112 char eos_name[100] ;
113
114 /// Adiabatic index of EOS if it is polytropic (0 otherwise)
115 double gamma_poly ;
116
117 /**
118 * Polytropic constant of EOS if it is polytropic (0 otherwise)
119 * [unit: $\rho_{\rm nuc} c^2 / n_{\rm nuc}^\gamma$]
120 */
121 double kappa_poly ;
122
123 /// Rotation frequency [unit: rad/s] (only rigid rotation)
124 double omega ;
125
126 /// Central density [unit: kg m${}^{-3}$]
127 double rho_c ;
128
129 /// Central specific internal energy [unit: c${}^2$]
130 double eps_c ;
131
132 /// Baryon mass [unit: solar mass]
133 double mass_b ;
134
135 /// Gravitational mass [unit: solar mass]
136 double mass_g ;
137
138 /// Coordinate equatorial radius [unit: km]
139 double r_eq ;
140
141 /// Coordinate polar radius [unit: km]
142 double r_p ;
143
144 /// Angular momentum [unit: $G M_{\textrm{sol}}^2/c$]
145 double angu_mom ;
146
147 /// Ratio T/W
148 double T_over_W ;
149
150 /// Magnetic momentum [unit: A m${}^2$]
151 double magn_mom ;
152
153 /// Magnetic field at the pole [unit: $10^9$ T]
154 double b_z_pole ;
155
156 /// Magnetic field at the equator [unit: $10^9$ T]
157 double b_z_eq ;
158
159 /// Total number of grid points
160 int np ;
161
162 /// 1-D array storing the values of coordinate x of the {\tt np} grid points [unit: km]
163 double* xx ;
164
165 /// 1-D array storing the values of coordinate y of the {\tt np} grid points [unit: km]
166 double* yy ;
167
168 /// 1-D array storing the values of coordinate z of the {\tt np} grid points [unit: km]
169 double* zz ;
170
171 /// Lapse function $N$ at the {\tt np} grid points (1-D array)
172 double* nnn ;
173
174 /// Component $\beta^x$ of the shift vector of non rotating coordinates [unit: $c$]
175 double* beta_x ;
176
177 /// Component $\beta^y$ of the shift vector of non rotating coordinates [unit: $c$]
178 double* beta_y ;
179
180 /// Component $\beta^z$ of the shift vector of non rotating coordinates [unit: $c$]
181 double* beta_z ;
182
183 /// Metric coefficient $\gamma_{xx}$ at the grid points (1-D array)
184 double* g_xx ;
185
186 /// Metric coefficient $\gamma_{xy}$ at the grid points (1-D array)
187 double* g_xy ;
188
189 /// Metric coefficient $\gamma_{xz}$ at the grid points (1-D array)
190 double* g_xz ;
191
192 /// Metric coefficient $\gamma_{yy}$ at the grid points (1-D array)
193 double* g_yy ;
194
195 /// Metric coefficient $\gamma_{yz}$ at the grid points (1-D array)
196 double* g_yz ;
197
198 /// Metric coefficient $\gamma_{zz}$ at the grid points (1-D array)
199 double* g_zz ;
200
201 /// Component $K^{xx}$ of the extrinsic curvature at the grid points (1-D array) [unit: c/km]
202 double* k_xx ;
203
204 /// Component $K^{xy}$ of the extrinsic curvature at the grid points (1-D array) [unit: c/km]
205 double* k_xy ;
206
207 /// Component $K^{xz}$ of the extrinsic curvature at the grid points (1-D array) [unit: c/km]
208 double* k_xz ;
209
210 /// Component $K^{yy}$ of the extrinsic curvature at the grid points (1-D array) [unit: c/km]
211 double* k_yy ;
212
213 /// Component $K^{yz}$ of the extrinsic curvature at the grid points (1-D array) [unit: c/km]
214 double* k_yz ;
215
216 /// Component $K^{zz}$ of the extrinsic curvature at the grid points (1-D array) [unit: c/km]
217 double* k_zz ;
218
219 // Magneto-Hydro components
220 //-------------------------
221 /** Baryon density in the fluid frame at the {\tt np} grid points (1-D array)
222 * [unit: ${\rm kg \, m}^{-3}$]
223 */
224 double* nbar ;
225
226 /// Specific internal energy at the {\tt np} grid points (1-D array) [unit: $c^2$]
227 double* ener_spec ;
228
229 /** Component $U^x$ of the fluid 3-velocity with respect to the Eulerian
230 * observer, at the {\tt np} grid points (1-D array) [unit: $c$]
231 */
232 double* u_euler_x ;
233
234 /** Component $U^y$ of the fluid 3-velocity with respect to the Eulerian
235 * observer, at the {\tt np} grid points (1-D array) [unit: $c$]
236 */
237 double* u_euler_y ;
238
239 /** Component $U^z$ of the fluid 3-velocity with respect to the Eulerian
240 * observer, at the {\tt np} grid points (1-D array) [unit: $c$]
241 */
242 double* u_euler_z ;
243
244 /** Component $B^x$ of the magnetic field, at the {\tt np} grid points (1-D array)
245 * [unit: $10^9$ T]
246 */
247 double* bb_x ;
248
249 /** Component $B^y$ of the magnetic field, at the {\tt np} grid points (1-D array)
250 * [unit: $10^9$ T]
251 */
252 double* bb_y ;
253
254 /** Component $B^z$ of the magnetic field, at the {\tt np} grid points (1-D array)
255 * [unit: $10^9$ T]
256 */
257 double* bb_z ;
258
259 /** Component $j^t$ of the 4-current, at the {\tt np} grid points (1-D array)
260 * [unit: A m${}^{-2$}]
261 */
262 double* jj_t ;
263
264 /** Component $j^x$ of the 4-current, at the {\tt np} grid points (1-D array)
265 * [unit: A m${}^{-2$}]
266 */
267 double* jj_x ;
268
269 /** Component $j^y$ of the 4-current, at the {\tt np} grid points (1-D array)
270 * [unit: A m${}^{-2$}]
271 */
272 double* jj_y ;
273
274 /** Component $j^z$ of the 4-current, at the {\tt np} grid points (1-D array)
275 * [unit: A m${}^{-2$}]
276 */
277 double* jj_z ;
278
279 // Constructors - Destructor
280 // -------------------------
281 public:
282 /** Constructor from Lorene spectral data.
283 *
284 * This constructor takes general arrays {\tt xi, yi, zi}
285 * for the location of the Cartesian coordinates
286 * $(x, y, z)$, i.e. it does not assume that the grid is a uniform one.
287 * These arrays are 1-D to deal with any ordering of a 3-D storage.
288 *
289 * @param nbpoints [input] Total number of grid points
290 * @param xi [input] 1-D array (size {\tt nbpoints}) storing the
291 * values of coordinate x of the grid points [unit: km]
292 * @param yi [input] 1-D array (size {\tt nbpoints}) storing the
293 * values of coordinate y of the grid points [unit: km]
294 * @param zi [input] 1-D array (size {\tt nbpoints}) storing the
295 * values of coordinate z of the grid points [unit: km]
296 * @param filename [input] Name of the (binary) file containing the result
297 * of a computation by means of the multi-domain
298 * spectral method.
299 */
300 Mag_NS(int nbpoints, const double* xi, const double* yi,
301 const double* zi, const char* filename) ;
302
303
304 /** Constructor from a binary file
305 * (previously created by {\tt save\_bin})
306 */
307 Mag_NS(FILE* ) ;
308
309 /** Constructor from a formatted file
310 * (previously created by {\tt save\_form})
311 */
312 Mag_NS(ifstream& ) ;
313
314 /// Destructor
315 ~Mag_NS() ;
316
317
318 // Memory management
319 // -----------------
320 private:
321
322 /// Allocate the memory for the arrays g\_ij, k\_ij, etc...
323 void alloc_memory() ;
324
325 // Outputs
326 // -------
327 public:
328 /** Save in a binary file.
329 * This file can be subsenquently read by the evolution code,
330 * or by the constructor {\tt Bin\_NS::Bin\_NS(FILE* )}.
331 */
332 void save_bin(FILE* ) const ;
333
334 /** Save in a formatted file.
335 * This file can be subsenquently read by the evolution code,
336 * or by the constructor {\tt Bin\_NS::Bin\_NS(ifstream\& )}.
337 */
338 void save_form(ofstream& ) const ;
339
340 /// Display
341 friend ostream& operator<<(ostream& , const Mag_NS& ) ;
342
343 };
344
345 }
346 #endif