Debian Codegraph @

Codes/BosonStar/bostar.C

raw
1 /*
2 * Code for computing an equilibrium configuration of a rotating boson star
3 *
4 * (see file boson_star.h for documentation).
5 *
6 */
7
8 /*
9 * Copyright (c) 2012 Claire Some, Eric Gourgoulhon
10 *
11 * This file is part of LORENE.
12 *
13 * LORENE is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2
15 * as published by the Free Software Foundation.
16 *
17 * LORENE is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with LORENE; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 */
27
28 char bostar_C[] = "$Header: /cvsroot/Lorene/Codes/BosonStar/bostar.C,v 1.3 2014/10/13 08:53:55 j_novak Exp $" ;
29
30 /*
31 * $Id: bostar.C,v 1.3 2014/10/13 08:53:55 j_novak Exp $
32 * $Log: bostar.C,v $
33 * Revision 1.3 2014/10/13 08:53:55 j_novak
34 * Lorene classes and functions now belong to the namespace Lorene.
35 *
36 * Revision 1.2 2012/12/03 15:28:03 c_some
37 * First call to Boson_star::equilibrium
38 *
39 * Revision 1.1 2012/11/23 15:41:44 c_some
40 * First version
41 *
42 *
43 * $Header: /cvsroot/Lorene/Codes/BosonStar/bostar.C,v 1.3 2014/10/13 08:53:55 j_novak Exp $
44 *
45 */
46
47 // C++ headers
48
49 // C headers
50
51 // Lorene headers
52 #include "boson_star.h"
53 #include "nbr_spx.h"
54
55
56 using namespace Lorene ;
57
58 int main() {
59
60 // Identification of all the subroutines called by the code :
61
62 system("ident bostar > identif.d") ;
63
64 //------------------------------------------------------------------
65 // Parameters of the computation
66 //------------------------------------------------------------------
67
68 int kkk, mer_max, mermax_poisson, graph, nz, nzadapt, nt, np, mer_triax ;
69 double mmm, rphi_c, iphi_c, precis, thres_adapt, relax, relax_poisson, ampli_triax,
70 precis_adapt ;
71
72 ifstream fpar("param.d") ;
73 if ( !fpar.good() ) {
74 cerr << "Problem in opening the file param.d ! " << endl ;
75 abort() ;
76 }
77
78 fpar.ignore(1000,'\n') ; // skip title
79 fpar >> mmm ; fpar.ignore(1000,'\n') ;
80 fpar >> kkk ; fpar.ignore(1000,'\n') ;
81 fpar >> rphi_c ; fpar.ignore(1000,'\n') ;
82 fpar >> iphi_c ; fpar.ignore(1000,'\n') ;
83 fpar.ignore(1000,'\n') ; // skip title
84 fpar >> mer_max ; fpar.ignore(1000,'\n') ;
85 fpar >> precis ; fpar.ignore(1000,'\n') ;
86 fpar >> thres_adapt ; fpar.ignore(1000,'\n') ;
87 fpar >> mer_triax ; fpar.ignore(1000,'\n') ;
88 fpar >> ampli_triax ; fpar.ignore(1000,'\n') ;
89 fpar >> relax ; fpar.ignore(1000,'\n') ;
90 fpar >> mermax_poisson ; fpar.ignore(1000,'\n') ;
91 fpar >> relax_poisson ; fpar.ignore(1000,'\n') ;
92 fpar >> precis_adapt ; fpar.ignore(1000,'\n') ;
93 fpar >> graph ; fpar.ignore(1000,'\n') ;
94 fpar.ignore(1000,'\n') ; // skip title
95 fpar >> nz ; fpar.ignore(1000,'\n') ;
96 fpar >> nzadapt; fpar.ignore(1000,'\n') ;
97 fpar >> nt; fpar.ignore(1000,'\n') ;
98 fpar >> np; fpar.ignore(1000,'\n') ;
99
100 int* nr = new int[nz];
101 int* nt_tab = new int[nz];
102 int* np_tab = new int[nz];
103 double* bornes = new double[nz+1];
104
105 fpar.ignore(1000,'\n'); // skip title
106 for (int l=0; l<nz; l++) {
107 fpar >> nr[l];
108 fpar >> bornes[l]; fpar.ignore(1000,'\n') ;
109 np_tab[l] = np ;
110 nt_tab[l] = nt ;
111 }
112 bornes[nz] = __infinity ;
113
114 fpar.close();
115
116 //-----------------------------------------------------------------------
117 // Construction of the multi-grid and the mapping
118 //-----------------------------------------------------------------------
119
120
121 // Type of r sampling :
122 int* type_r = new int[nz];
123 type_r[0] = RARE ;
124 for (int l=1; l<nz-1; l++) {
125 type_r[l] = FIN ;
126 }
127 type_r[nz-1] = UNSURR ;
128
129 // Type of sampling in theta and phi :
130 int type_t = SYM ;
131 int type_p = SYM ;
132
133 Mg3d mg(nz, nr, type_r, nt_tab, type_t, np_tab, type_p) ;
134
135 Map_et mp(mg, bornes) ;
136
137 // Cleaning
138 // --------
139
140 delete [] nr ;
141 delete [] nt_tab ;
142 delete [] np_tab ;
143 delete [] type_r ;
144 delete [] bornes ;
145
146 //-----------------------------------------------------------------------
147 // Construction of the boson star
148 //-----------------------------------------------------------------------
149
150 Boson_star star(mp, mmm, kkk) ;
151
152 //-----------------------------------------------------------------------
153 // Initialization of Phi
154 //-----------------------------------------------------------------------
155
156 const Coord& r = mp.r ;
157 double ray0 = mp.val_r(0, 1., 0., 0.) ;
158 Scalar rphi0(mp) ;
159 rphi0 = rphi_c * exp(- r*r / (ray0*ray0) ) ;
160 rphi0.std_spectral_base() ; // sets the standard bases for spectral expansions
161
162 Scalar iphi0(mp) ;
163 iphi0 = iphi_c * exp(- r*r / (ray0*ray0) ) ;
164 iphi0.std_spectral_base() ; // sets the standard bases for spectral expansions
165
166 star.set_rphi() = rphi0 ;
167 star.set_iphi() = iphi0 ;
168
169 // Initialization of the energy-momentum tensor
170 star.update_ener_mom() ;
171
172 cout << endl << "Initial star : "
173 << endl << "========== " << endl ;
174 cout << star << endl ;
175
176
177 //-----------------------------------------------------------------------
178 // Computation of the rotating equilibrium
179 //-----------------------------------------------------------------------
180
181 Itbl icontrol(8) ;
182 icontrol.set_etat_qcq() ;
183 icontrol.set(0) = mer_max ;
184 //## icontrol.set(1) = mer_rot ;
185 // icontrol.set(2) = mer_change_omega ;
186 // icontrol.set(3) = mer_fix_omega ;
187 //## icontrol.set(4) = mer_mass ;
188 icontrol.set(5) = mermax_poisson ;
189 icontrol.set(6) = mer_triax ;
190 //## icontrol.set(7) = delta_mer_kep ;
191
192 Tbl control(7) ;
193 control.set_etat_qcq() ;
194 control.set(0) = precis ;
195 //## control.set(1) = omega_ini ;
196 control.set(2) = relax ;
197 control.set(3) = relax_poisson ;
198 //## control.set(4) = thres_adapt ;
199 control.set(5) = ampli_triax ;
200 control.set(6) = precis_adapt ;
201
202 Tbl diff(8) ;
203
204 Tbl phi_limit(1) ;
205 phi_limit.set_etat_qcq() ;
206 phi_limit.set(0) = 1e-3*rphi_c ; // Phi at the stellar "surface"
207
208 star.equilibrium(rphi_c, iphi_c, nzadapt, phi_limit, icontrol, control, diff) ;
209
210
211 cout << endl << "Final star : "
212 << endl << "========== " << endl ;
213 cout << star << endl ;
214
215 }