Debian Codegraph @

C++/Source/Compobj/boson_star.C

raw
1 /*
2 * Methods of the class Boson_star
3 *
4 * (see file boson_star.h for documentation).
5 */
6
7 /*
8 * Copyright (c) 2012 Claire Some, Eric Gourgoulhon
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 char boson_star_C[] = "$Header: /cvsroot/Lorene/C++/Source/Compobj/boson_star.C,v 1.4 2014/10/13 08:52:49 j_novak Exp $" ;
28
29 /*
30 * $Id: boson_star.C,v 1.4 2014/10/13 08:52:49 j_novak Exp $
31 * $Log: boson_star.C,v $
32 * Revision 1.4 2014/10/13 08:52:49 j_novak
33 * Lorene classes and functions now belong to the namespace Lorene.
34 *
35 * Revision 1.3 2012/12/03 15:27:30 c_some
36 * Small changes
37 *
38 * Revision 1.2 2012/11/23 15:44:10 c_some
39 * Small changes + method update_ener_mom
40 *
41 * Revision 1.1 2012/11/22 16:04:12 c_some
42 * New class Boson_star
43 *
44 *
45 * $Header: /cvsroot/Lorene/C++/Source/Compobj/boson_star.C,v 1.4 2014/10/13 08:52:49 j_novak Exp $
46 *
47 */
48
49
50 // C headers
51 #include <cassert>
52
53 // Lorene headers
54 #include "boson_star.h"
55 #include "utilitaires.h"
56
57 //--------------//
58 // Constructors //
59 //--------------//
60
61 // Standard constructor
62 // --------------------
63 namespace Lorene {
64 Boson_star::Boson_star(Map& mpi, double m, int k) :
65 Star_QI(mpi) ,
66 rphi(mpi),
67 iphi(mpi),
68 omega(0),
69 kkk(k),
70 mmm(m),
71 m2(m*m)
72 {
73 // Pointers of derived quantities initialized to zero :
74 set_der_0x0() ;
75
76 // Initialization of the scalar field to zero
77 rphi = 0 ;
78 iphi = 0 ;
79
80 }
81
82 // Copy constructor
83 // --------------------
84 Boson_star::Boson_star(const Boson_star& st) :
85 Star_QI(st),
86 rphi(st.rphi),
87 iphi(st.iphi),
88 omega(st.omega),
89 kkk(st.kkk),
90 mmm(st.mmm),
91 m2(st.m2)
92 {
93 // Pointers of derived quantities initialized to zero :
94 set_der_0x0() ;
95 }
96
97
98 // Constructor from a file
99 // -----------------------
100 Boson_star::Boson_star(Map& mpi, FILE* fich) :
101 Star_QI(mpi, fich) ,
102 rphi(mpi, *(mpi.get_mg()), fich) ,
103 iphi(mpi, *(mpi.get_mg()), fich)
104 {
105 // Pointers of derived quantities initialized to zero :
106 set_der_0x0() ;
107
108 fread_be(&omega, sizeof(double), 1, fich) ;
109 fread_be(&kkk, sizeof(int), 1, fich) ;
110 fread_be(&mmm, sizeof(double), 1, fich) ;
111 m2 = mmm*mmm ;
112
113 }
114
115 //------------//
116 // Destructor //
117 //------------//
118
119 Boson_star::~Boson_star(){
120
121 del_deriv() ;
122
123 }
124
125
126 //----------------------------------//
127 // Management of derived quantities //
128 //----------------------------------//
129
130 void Boson_star::del_deriv() const {
131
132 Star_QI::del_deriv() ;
133
134 Boson_star::set_der_0x0() ;
135 }
136
137
138 void Boson_star::set_der_0x0() const {
139
140 }
141
142 //--------------//
143 // Assignment //
144 //--------------//
145
146 // Assignment to another Boson_star
147 // --------------------------------
148 void Boson_star::operator=(const Boson_star& st) {
149
150 // Assignment of quantities common to all the derived classes of Star_QI
151 Star_QI::operator=(st) ;
152
153 rphi = st.rphi ;
154 iphi = st.iphi ;
155 omega = st.omega ;
156 kkk = st.kkk ;
157 mmm = st.mmm ;
158 m2 = st.m2 ;
159
160 del_deriv() ; // Deletes all derived quantities
161 }
162
163 //--------------//
164 // Outputs //
165 //--------------//
166
167 // Save in a file
168 // --------------
169 void Boson_star::sauve(FILE* fich) const {
170
171 Star_QI::sauve(fich) ;
172 rphi.sauve(fich) ;
173 iphi.sauve(fich) ;
174 fwrite_be(&omega, sizeof(double), 1, fich) ;
175 fwrite_be(&kkk, sizeof(int), 1, fich) ;
176 fwrite_be(&mmm, sizeof(double), 1, fich) ;
177
178 }
179
180 // Printing
181 // --------
182
183 ostream& Boson_star::operator>>(ostream& ost) const {
184
185 Star_QI::operator>>(ost) ;
186
187 ost << endl << "Axisymmetric stationary boson star in quasi-isotropic coordinates (class Boson_star) " << endl ;
188
189 ost << "Boson mass : " << mmm << endl ; //## which units ?
190
191 ost << "omega = " << omega << " , k = " << kkk << endl ;
192
193 ost << "Central value of the scalar field : " << rphi.val_grid_point(0,0,0,0) << " + i " << iphi.val_grid_point(0,0,0,0)<< endl ;
194
195 // ost << "Real part of the scalar field : " << rphi << endl ;
196 // ost << "Imaginary part of the scalar field : " << iphi << endl ;
197
198 //## ost << "ADM mass : " << adm_mass() << endl ;
199 ost << "Gravitational mass : " << mass_g() << endl ;
200 return ost ;
201
202 }
203
204 //------------------------
205 // Computational routines
206 //------------------------
207
208 /* Computes the 3+1 components of the energy-momentum tensor (E, P_i and S_{ij})
209 * from the values of the scalar field and the metric
210 */
211 void Boson_star::update_ener_mom() {
212
213 const Metric_flat& ff = mp.flat_met_spher() ;
214
215 Scalar mod_phi2 = rphi*rphi + iphi*iphi ;
216 mod_phi2.inc_dzpuis(4) ; // mod_phi2 multiplied by r^4 in the last domain
217
218 Sym_tensor dphidphi = rphi.derive_cov(ff) * rphi.derive_cov(ff)
219 + iphi.derive_cov(ff) * iphi.derive_cov(ff) ;
220
221 Scalar tmp = (omega - kkk*nphi)/nn ;
222 Scalar tmp2 = tmp*tmp ;
223 Scalar dphi2 = dphidphi.trace(gamma) ;
224
225 ener_euler = 0.5*( (tmp2 + m2)*mod_phi2 + dphi2 ) ;
226
227 mom_euler.set(1) = 0 ; // p^(r) = 0
228 mom_euler.set(2) = 0 ; // p^(theta) = 0
229 mom_euler.set(3) = -kkk*tmp * mod_phi2 ;
230
231 stress_euler = dphidphi - 0.5*( (m2-tmp2)*mod_phi2 + dphi2 )*gamma.cov() ;
232 }
233
234
235 }