LORENE
boson_star.C
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 
28 
29 /*
30  * $Id: boson_star.C,v 1.5 2016/12/05 16:17:49 j_novak Exp $
31  * $Log: boson_star.C,v $
32  * Revision 1.5 2016/12/05 16:17:49 j_novak
33  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
34  *
35  * Revision 1.4 2014/10/13 08:52:49 j_novak
36  * Lorene classes and functions now belong to the namespace Lorene.
37  *
38  * Revision 1.3 2012/12/03 15:27:30 c_some
39  * Small changes
40  *
41  * Revision 1.2 2012/11/23 15:44:10 c_some
42  * Small changes + method update_ener_mom
43  *
44  * Revision 1.1 2012/11/22 16:04:12 c_some
45  * New class Boson_star
46  *
47  *
48  * $Header: /cvsroot/Lorene/C++/Source/Compobj/boson_star.C,v 1.5 2016/12/05 16:17:49 j_novak Exp $
49  *
50  */
51 
52 
53 // C headers
54 #include <cassert>
55 
56 // Lorene headers
57 #include "boson_star.h"
58 #include "utilitaires.h"
59 
60  //--------------//
61  // Constructors //
62  //--------------//
63 
64 // Standard constructor
65 // --------------------
66 namespace Lorene {
67 Boson_star::Boson_star(Map& mpi, double m, int k) :
68  Star_QI(mpi) ,
69  rphi(mpi),
70  iphi(mpi),
71  omega(0),
72  kkk(k),
73  mmm(m),
74  m2(m*m)
75 {
76  // Pointers of derived quantities initialized to zero :
77  set_der_0x0() ;
78 
79  // Initialization of the scalar field to zero
80  rphi = 0 ;
81  iphi = 0 ;
82 
83 }
84 
85 // Copy constructor
86 // --------------------
88  Star_QI(st),
89  rphi(st.rphi),
90  iphi(st.iphi),
91  omega(st.omega),
92  kkk(st.kkk),
93  mmm(st.mmm),
94  m2(st.m2)
95 {
96  // Pointers of derived quantities initialized to zero :
97  set_der_0x0() ;
98 }
99 
100 
101 // Constructor from a file
102 // -----------------------
103 Boson_star::Boson_star(Map& mpi, FILE* fich) :
104  Star_QI(mpi, fich) ,
105  rphi(mpi, *(mpi.get_mg()), fich) ,
106  iphi(mpi, *(mpi.get_mg()), fich)
107 {
108  // Pointers of derived quantities initialized to zero :
109  set_der_0x0() ;
110 
111  fread_be(&omega, sizeof(double), 1, fich) ;
112  fread_be(&kkk, sizeof(int), 1, fich) ;
113  fread_be(&mmm, sizeof(double), 1, fich) ;
114  m2 = mmm*mmm ;
115 
116 }
117 
118  //------------//
119  // Destructor //
120  //------------//
121 
123 
124  del_deriv() ;
125 
126 }
127 
128 
129  //----------------------------------//
130  // Management of derived quantities //
131  //----------------------------------//
132 
133 void Boson_star::del_deriv() const {
134 
135  Star_QI::del_deriv() ;
136 
138 }
139 
140 
142 
143 }
144 
145  //--------------//
146  // Assignment //
147  //--------------//
148 
149 // Assignment to another Boson_star
150 // --------------------------------
152 
153  // Assignment of quantities common to all the derived classes of Star_QI
154  Star_QI::operator=(st) ;
155 
156  rphi = st.rphi ;
157  iphi = st.iphi ;
158  omega = st.omega ;
159  kkk = st.kkk ;
160  mmm = st.mmm ;
161  m2 = st.m2 ;
162 
163  del_deriv() ; // Deletes all derived quantities
164 }
165 
166  //--------------//
167  // Outputs //
168  //--------------//
169 
170 // Save in a file
171 // --------------
172 void Boson_star::sauve(FILE* fich) const {
173 
174  Star_QI::sauve(fich) ;
175  rphi.sauve(fich) ;
176  iphi.sauve(fich) ;
177  fwrite_be(&omega, sizeof(double), 1, fich) ;
178  fwrite_be(&kkk, sizeof(int), 1, fich) ;
179  fwrite_be(&mmm, sizeof(double), 1, fich) ;
180 
181 }
182 
183 // Printing
184 // --------
185 
186 ostream& Boson_star::operator>>(ostream& ost) const {
187 
188  Star_QI::operator>>(ost) ;
189 
190  ost << endl << "Axisymmetric stationary boson star in quasi-isotropic coordinates (class Boson_star) " << endl ;
191 
192  ost << "Boson mass : " << mmm << endl ; //## which units ?
193 
194  ost << "omega = " << omega << " , k = " << kkk << endl ;
195 
196  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 ;
197 
198  // ost << "Real part of the scalar field : " << rphi << endl ;
199  // ost << "Imaginary part of the scalar field : " << iphi << endl ;
200 
201  //## ost << "ADM mass : " << adm_mass() << endl ;
202  ost << "Gravitational mass : " << mass_g() << endl ;
203  return ost ;
204 
205 }
206 
207 //------------------------
208 // Computational routines
209 //------------------------
210 
211  /* Computes the 3+1 components of the energy-momentum tensor (E, P_i and S_{ij})
212  * from the values of the scalar field and the metric
213  */
215 
216  const Metric_flat& ff = mp.flat_met_spher() ;
217 
218  Scalar mod_phi2 = rphi*rphi + iphi*iphi ;
219  mod_phi2.inc_dzpuis(4) ; // mod_phi2 multiplied by r^4 in the last domain
220 
221  Sym_tensor dphidphi = rphi.derive_cov(ff) * rphi.derive_cov(ff)
222  + iphi.derive_cov(ff) * iphi.derive_cov(ff) ;
223 
224  Scalar tmp = (omega - kkk*nphi)/nn ;
225  Scalar tmp2 = tmp*tmp ;
226  Scalar dphi2 = dphidphi.trace(gamma) ;
227 
228  ener_euler = 0.5*( (tmp2 + m2)*mod_phi2 + dphi2 ) ;
229 
230  mom_euler.set(1) = 0 ; // p^(r) = 0
231  mom_euler.set(2) = 0 ; // p^(theta) = 0
232  mom_euler.set(3) = -kkk*tmp * mod_phi2 ;
233 
234  stress_euler = dphidphi - 0.5*( (m2-tmp2)*mod_phi2 + dphi2 )*gamma.cov() ;
235 }
236 
237 
238 }
void operator=(const Boson_star &)
Assignment to another Boson_star.
Definition: boson_star.C:151
Scalar iphi
Imaginary part of the scalar field Phi.
Definition: boson_star.h:76
Vector mom_euler
Total 3-momentum density in the Eulerian frame.
Definition: compobj.h:150
Lorene prototypes.
Definition: app_hor.h:67
Flat metric for tensor calculation.
Definition: metric.h:261
Tensor field of valence 0 (or component of a tensorial field).
Definition: scalar.h:393
double omega
Coefficient omega in the time dependence of Phi.
Definition: boson_star.h:80
virtual double mass_g() const
Gravitational mass.
Base class for coordinate mappings.
Definition: map.h:688
void update_ener_mom()
Computes the 3+1 components of the energy-momentum tensor (E, P_i and S_{ij}) from the values of the ...
Definition: boson_star.C:214
double mmm
Boson mass.
Definition: boson_star.h:88
double val_grid_point(int l, int k, int j, int i) const
Returns the value of the field at a specified grid point.
Definition: scalar.h:643
Base class for axisymmetric stationary compact stars in Quasi-Isotropic coordinates (under developmen...
Definition: compobj.h:490
double m2
Boson mass squared.
Definition: boson_star.h:92
Scalar nphi
Metric coefficient .
Definition: compobj.h:299
virtual void set_der_0x0() const
Sets to 0x0 all the pointers on derived quantities.
Definition: boson_star.C:141
virtual void sauve(FILE *) const
Save in a file.
Definition: scalar.C:692
Boson_star(Map &mp_i, double m, int k)
Standard constructor.
Definition: boson_star.C:67
virtual void inc_dzpuis(int inc=1)
Increases by inc units the value of dzpuis and changes accordingly the values of the Scalar in the co...
int kkk
Coefficient kkk in the azimuthal dependence of Phi.
Definition: boson_star.h:84
int fwrite_be(const int *aa, int size, int nb, FILE *fich)
Writes integer(s) into a binary file according to the big endian convention.
Definition: fwrite_be.C:73
Scalar rphi
Real part of the scalar field Phi.
Definition: boson_star.h:72
int fread_be(int *aa, int size, int nb, FILE *fich)
Reads integer(s) from a binary file according to the big endian convention.
Definition: fread_be.C:72
virtual const Sym_tensor & cov() const
Read-only access to the covariant representation.
Definition: metric.C:283
Scalar ener_euler
Total energy density E in the Eulerian frame.
Definition: compobj.h:147
virtual void del_deriv() const
Deletes all the derived quantities.
Definition: boson_star.C:133
Class for stationary axisymmetric boson stars (under development).
Definition: boson_star.h:64
Scalar nn
Lapse function N .
Definition: compobj.h:138
Metric gamma
3-metric
Definition: compobj.h:144
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
Definition: boson_star.C:186
Scalar & set(int)
Read/write access to a component.
Definition: vector.C:302
const Vector & derive_cov(const Metric &gam) const
Returns the gradient (1-form = covariant vector) of *this
Definition: scalar_deriv.C:390
virtual void del_deriv() const
Deletes all the derived quantities.
Definition: star_QI.C:225
virtual ~Boson_star()
Destructor.
Definition: boson_star.C:122
const Metric_flat & flat_met_spher() const
Returns the flat metric associated with the spherical coordinates and with components expressed in th...
Definition: map.C:324
void operator=(const Star_QI &)
Assignment to another Star_QI.
Definition: star_QI.C:253
Class intended to describe valence-2 symmetric tensors.
Definition: sym_tensor.h:226
virtual void sauve(FILE *) const
Save in a file.
Definition: boson_star.C:172
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
Definition: star_QI.C:303
Tensor trace(int ind1, int ind2) const
Trace on two different type indices.
Map & mp
Mapping describing the coordinate system (r,theta,phi)
Definition: compobj.h:135
Sym_tensor stress_euler
Stress tensor with respect to the Eulerian observer.
Definition: compobj.h:153
virtual void sauve(FILE *) const
Save in a file.
Definition: star_QI.C:282