File: boson_star.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 (235 lines) | stat: -rw-r--r-- 5,946 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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
/*
 *  Methods of the class Boson_star
 *
 *    (see file boson_star.h for documentation).
 */

/*
 *   Copyright (c) 2012 Claire Some, 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 boson_star_C[] = "$Header: /cvsroot/Lorene/C++/Source/Compobj/boson_star.C,v 1.4 2014/10/13 08:52:49 j_novak Exp $" ;

/*
 * $Id: boson_star.C,v 1.4 2014/10/13 08:52:49 j_novak Exp $
 * $Log: boson_star.C,v $
 * Revision 1.4  2014/10/13 08:52:49  j_novak
 * Lorene classes and functions now belong to the namespace Lorene.
 *
 * Revision 1.3  2012/12/03 15:27:30  c_some
 * Small changes
 *
 * Revision 1.2  2012/11/23 15:44:10  c_some
 * Small changes + method update_ener_mom
 *
 * Revision 1.1  2012/11/22 16:04:12  c_some
 * New class Boson_star
 *
 *
 * $Header: /cvsroot/Lorene/C++/Source/Compobj/boson_star.C,v 1.4 2014/10/13 08:52:49 j_novak Exp $
 *
 */


// C headers
#include <cassert>

// Lorene headers
#include "boson_star.h"
#include "utilitaires.h"

                   //--------------//
                   // Constructors //
                   //--------------//

// Standard constructor
// --------------------
namespace Lorene {
Boson_star::Boson_star(Map& mpi, double m, int k) :
			 Star_QI(mpi) ,
			 rphi(mpi), 
			 iphi(mpi),
			 omega(0),
			 kkk(k),
			 mmm(m),
			 m2(m*m) 	 
{
    // Pointers of derived quantities initialized to zero : 
    set_der_0x0() ;

    // Initialization of the scalar field to zero
    rphi = 0 ;   
    iphi = 0 ;   
    
}

// Copy constructor
// --------------------
Boson_star::Boson_star(const Boson_star& st) :
			 Star_QI(st), 
			 rphi(st.rphi), 
			 iphi(st.iphi),
			 omega(st.omega),
			 kkk(st.kkk),		 
			 mmm(st.mmm),
			 m2(st.m2)		 
{
    // Pointers of derived quantities initialized to zero : 
    set_der_0x0() ;
}


// Constructor from a file
// -----------------------
Boson_star::Boson_star(Map& mpi, FILE* fich) :
			 Star_QI(mpi, fich) , 
			 rphi(mpi, *(mpi.get_mg()), fich) ,
			 iphi(mpi, *(mpi.get_mg()), fich)
{
    // Pointers of derived quantities initialized to zero : 
    set_der_0x0() ;
    
    fread_be(&omega, sizeof(double), 1, fich) ;		
    fread_be(&kkk, sizeof(int), 1, fich) ;		
    fread_be(&mmm, sizeof(double), 1, fich) ;	
    m2 = mmm*mmm ;	
        
}

			    //------------//
			    // Destructor //
			    //------------//

Boson_star::~Boson_star(){

    del_deriv() ; 

}


			//----------------------------------//
			// Management of derived quantities //
			//----------------------------------//

void Boson_star::del_deriv() const {

    Star_QI::del_deriv() ; 

    Boson_star::set_der_0x0() ; 
}			    


void Boson_star::set_der_0x0() const {
 	 
}			    

			    //--------------//
			    //  Assignment  //
			    //--------------//

// Assignment to another Boson_star
// --------------------------------
void Boson_star::operator=(const Boson_star& st) {

    // Assignment of quantities common to all the derived classes of Star_QI
    Star_QI::operator=(st) ;	    
    
    rphi = st.rphi ; 
    iphi = st.iphi ; 
    omega = st.omega ; 
    kkk = st.kkk ; 
   	mmm = st.mmm ; 
   	m2 = st.m2 ; 

    del_deriv() ;  // Deletes all derived quantities
}	

			    //--------------//
			    //	  Outputs   //
			    //--------------//

// Save in a file
// --------------
void Boson_star::sauve(FILE* fich) const {

	Star_QI::sauve(fich) ; 
    rphi.sauve(fich) ; 
    iphi.sauve(fich) ; 
    fwrite_be(&omega, sizeof(double), 1, fich) ;		
    fwrite_be(&kkk, sizeof(int), 1, fich) ;		
    fwrite_be(&mmm, sizeof(double), 1, fich) ;		

}

// Printing
// --------

ostream& Boson_star::operator>>(ostream& ost) const {
   
    Star_QI::operator>>(ost) ; 
    
    ost << endl << "Axisymmetric stationary boson star in quasi-isotropic coordinates (class Boson_star) " << endl ;
    
    ost << "Boson mass : " << mmm << endl ; //## which units ? 
    
    ost << "omega = " << omega << " ,   k = " << kkk << endl ; 
    
    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 ;  

    // ost << "Real part of the scalar field : " << rphi << endl ; 
    // ost << "Imaginary part of the scalar field : " << iphi << endl ; 
    
    //## ost << "ADM mass : " << adm_mass() << endl ; 	
    ost << "Gravitational mass : " << mass_g() << endl ; 	
    return ost ; 
      
}

//------------------------
// Computational routines
//------------------------

	/* Computes the 3+1 components of the energy-momentum tensor (E, P_i and S_{ij})
	 *  from the values of the scalar field and the metric 
	 */
void Boson_star::update_ener_mom() {

	const Metric_flat& ff = mp.flat_met_spher() ;
	
	Scalar mod_phi2 = rphi*rphi + iphi*iphi ; 
	mod_phi2.inc_dzpuis(4) ; // mod_phi2 multiplied by r^4 in the last domain
	
	Sym_tensor dphidphi = rphi.derive_cov(ff) * rphi.derive_cov(ff) 
							+ iphi.derive_cov(ff) * iphi.derive_cov(ff) ;
	
	Scalar tmp = (omega - kkk*nphi)/nn  ;
	Scalar tmp2 = tmp*tmp ; 
	Scalar dphi2 = dphidphi.trace(gamma) ;

    ener_euler = 0.5*( (tmp2 + m2)*mod_phi2 + dphi2 ) ;
    
	mom_euler.set(1) = 0 ;   // p^(r) = 0
	mom_euler.set(2) = 0 ;   // p^(theta) = 0
	mom_euler.set(3) = -kkk*tmp * mod_phi2 ;

	stress_euler = dphidphi - 0.5*( (m2-tmp2)*mod_phi2 + dphi2 )*gamma.cov() ;
}


}