| 1 |
/* |
| 2 |
* Methods of class Star_rot_Dirac_diff |
| 3 |
* |
| 4 |
* (see file star_rot_dirac_diff.h for documentation). |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
/* |
| 9 |
* Copyright (c) 2005 Motoyuki Saijo |
| 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 star_rot_dirac_diff_C[] = "$Header: /cvsroot/Lorene/C++/Source/Star/star_rot_dirac_diff.C,v 1.4 2014/10/13 08:53:39 j_novak Exp $" ; |
| 29 |
|
| 30 |
/* |
| 31 |
* $Header: /cvsroot/Lorene/C++/Source/Star/star_rot_dirac_diff.C,v 1.4 2014/10/13 08:53:39 j_novak Exp $ |
| 32 |
* |
| 33 |
*/ |
| 34 |
|
| 35 |
|
| 36 |
// C headers |
| 37 |
#include <cmath> |
| 38 |
#include <cassert> |
| 39 |
|
| 40 |
// Lorene headers |
| 41 |
#include "star_rot_dirac_diff.h" |
| 42 |
#include "unites.h" |
| 43 |
#include "utilitaires.h" |
| 44 |
|
| 45 |
|
| 46 |
//--------------// |
| 47 |
// Constructors // |
| 48 |
//--------------// |
| 49 |
|
| 50 |
// Standard constructor |
| 51 |
//------------------------- |
| 52 |
namespace Lorene { |
| 53 |
Star_rot_Dirac_diff::Star_rot_Dirac_diff(Map& mpi, int nzet_i, const Eos& eos_i, |
| 54 |
double (*frot_i)(double, const Tbl&), |
| 55 |
double (*primfrot_i)(double, const Tbl&), |
| 56 |
const Tbl& par_frot_i) |
| 57 |
:Star_rot_Dirac(mpi, nzet_i, eos_i), |
| 58 |
frot(frot_i), |
| 59 |
primfrot(primfrot_i), |
| 60 |
par_frot(par_frot_i), |
| 61 |
omega_field(mpi), |
| 62 |
prim_field(mpi) |
| 63 |
{ |
| 64 |
|
| 65 |
// Initialization to a static state : |
| 66 |
omega_field = 0 ; |
| 67 |
prim_field = 0 ; |
| 68 |
omega_min = 0 ; |
| 69 |
omega_max = 0 ; |
| 70 |
|
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
// Copy constructor |
| 75 |
//----------------- |
| 76 |
Star_rot_Dirac_diff::Star_rot_Dirac_diff(const Star_rot_Dirac_diff& star) |
| 77 |
: Star_rot_Dirac(star), |
| 78 |
frot(star.frot), |
| 79 |
primfrot(star.primfrot), |
| 80 |
par_frot(star.par_frot), |
| 81 |
omega_field(star.omega_field), |
| 82 |
omega_min(star.omega_min), |
| 83 |
omega_max(star.omega_max), |
| 84 |
prim_field(star.prim_field) |
| 85 |
{} |
| 86 |
|
| 87 |
|
| 88 |
//Constructor from a file //## to be more general... |
| 89 |
//------------------------ |
| 90 |
Star_rot_Dirac_diff::Star_rot_Dirac_diff(Map& mpi, const Eos& eos_i, FILE* fich, |
| 91 |
double (*frot_i)(double, const Tbl&), |
| 92 |
double (*primfrot_i)(double, const Tbl&) ) |
| 93 |
: Star_rot_Dirac(mpi, eos_i, fich), |
| 94 |
frot(frot_i), |
| 95 |
primfrot(primfrot_i), |
| 96 |
par_frot(fich), |
| 97 |
omega_field(mpi), |
| 98 |
prim_field(mpi) |
| 99 |
{ |
| 100 |
|
| 101 |
Scalar omega_field_file(mp, *(mp.get_mg()), fich) ; |
| 102 |
omega_field = omega_field_file ; |
| 103 |
fait_prim_field() ; |
| 104 |
|
| 105 |
// omega_min and omega_max are read in the file: |
| 106 |
fread_be(&omega_min, sizeof(double), 1, fich) ; |
| 107 |
fread_be(&omega_max, sizeof(double), 1, fich) ; |
| 108 |
|
| 109 |
} |
| 110 |
|
| 111 |
|
| 112 |
//------------// |
| 113 |
// Destructor // |
| 114 |
//------------// |
| 115 |
|
| 116 |
Star_rot_Dirac_diff::~Star_rot_Dirac_diff(){} |
| 117 |
|
| 118 |
|
| 119 |
//---------------// |
| 120 |
// Assignment // |
| 121 |
//---------------// |
| 122 |
|
| 123 |
// Assignment to another Star_rot_Dirac_diff |
| 124 |
// ------------------------------------ |
| 125 |
|
| 126 |
void Star_rot_Dirac_diff::operator=(const Star_rot_Dirac_diff& star) { |
| 127 |
|
| 128 |
// Assignment of quantities common to all the derived classes of |
| 129 |
// Star_rot_Dirac |
| 130 |
Star_rot_Dirac::operator=(star) ; |
| 131 |
|
| 132 |
// Assignment of proper quantities of class Star_rot_Dirac |
| 133 |
frot = star.frot ; |
| 134 |
primfrot = star.primfrot ; |
| 135 |
par_frot = star.par_frot ; |
| 136 |
omega_field = star.omega_field ; |
| 137 |
prim_field = star.prim_field ; |
| 138 |
omega_min = star.omega_min ; |
| 139 |
omega_max = star.omega_max ; |
| 140 |
|
| 141 |
} |
| 142 |
|
| 143 |
|
| 144 |
//-----------// |
| 145 |
// Outputs // |
| 146 |
//-----------// |
| 147 |
|
| 148 |
// Save in a file |
| 149 |
// -------------- |
| 150 |
|
| 151 |
void Star_rot_Dirac_diff::sauve(FILE* fich) const { |
| 152 |
|
| 153 |
Star::sauve(fich) ; |
| 154 |
|
| 155 |
par_frot.sauve(fich) ; |
| 156 |
|
| 157 |
omega_field.sauve(fich) ; |
| 158 |
|
| 159 |
fwrite_be(&omega_min, sizeof(double), 1, fich) ; |
| 160 |
fwrite_be(&omega_max, sizeof(double), 1, fich) ; |
| 161 |
|
| 162 |
// What else to save? //## to be more general ... |
| 163 |
|
| 164 |
} |
| 165 |
|
| 166 |
|
| 167 |
// Printing |
| 168 |
// --------- |
| 169 |
|
| 170 |
ostream& Star_rot_Dirac_diff::operator>>(ostream& ost) const { |
| 171 |
|
| 172 |
using namespace Unites ; |
| 173 |
|
| 174 |
Star::operator>>(ost) ; |
| 175 |
|
| 176 |
ost << "Differentially rotating star in Dirac gauge" << '\n'; |
| 177 |
|
| 178 |
// Only differentially rotating star for the moment.... |
| 179 |
ost << '\n'; |
| 180 |
ost << "Differentially rotating star" << '\n'; |
| 181 |
ost << "-----------------------" << '\n'; |
| 182 |
|
| 183 |
ost << '\n'<< "Parameters of F(Omega) : " << '\n'; |
| 184 |
ost << par_frot << '\n'; |
| 185 |
|
| 186 |
ost << "Min, Max of Omega/(2pi) : " << omega_min / (2*M_PI) * f_unit |
| 187 |
<< " Hz, " << omega_max / (2*M_PI) * f_unit << " Hz" << '\n'; |
| 188 |
int lsurf = nzet - 1; |
| 189 |
int nt = mp.get_mg()->get_nt(lsurf) ; |
| 190 |
int nr = mp.get_mg()->get_nr(lsurf) ; |
| 191 |
ost << "Central, equatorial value of Omega: " |
| 192 |
<< omega_field.val_grid_point(0, 0, 0, 0) * f_unit |
| 193 |
<< " rad/s, " |
| 194 |
<< omega_field.val_grid_point(nzet-1, 0, nt-1, nr-1) * f_unit |
| 195 |
<< " rad/s" << '\n'; |
| 196 |
|
| 197 |
ost << "Central, equatorial value of Omega/(2 Pi): " |
| 198 |
<< omega_field.val_grid_point(0, 0, 0, 0) * f_unit / (2*M_PI) |
| 199 |
<< " Hz, " |
| 200 |
<< omega_field.val_grid_point(nzet-1, 0, nt-1, nr-1) * |
| 201 |
f_unit / (2*M_PI) |
| 202 |
<< " Hz" << '\n'; |
| 203 |
|
| 204 |
ost << "Error on the virial identity GRV2 : " << '\n'; |
| 205 |
ost << "GRV2 = " << grv2() << '\n'; |
| 206 |
ost << "Error on the virial identity GRV3 : " << '\n'; |
| 207 |
ost << "GRV3 = " << grv3() << '\n'; |
| 208 |
|
| 209 |
ost << "Angular momentum J : " |
| 210 |
<< angu_mom()/( qpig / (4*M_PI) *msol*msol) << " G M_sol^2 / c" |
| 211 |
<< '\n'; |
| 212 |
ost << "c J / (G M^2) : " |
| 213 |
<< angu_mom()/( qpig / (4*M_PI) * pow(mass_g(), 2.) ) << '\n'; |
| 214 |
|
| 215 |
if (omega != 0.) { |
| 216 |
double mom_iner = angu_mom() / omega ; |
| 217 |
double mom_iner_38si = mom_iner * rho_unit * (pow(r_unit, double(5.)) |
| 218 |
/ double(1.e38) ) ; |
| 219 |
ost << "Moment of inertia: " << mom_iner_38si << " 10^38 kg m^2" |
| 220 |
<< '\n'; |
| 221 |
} |
| 222 |
|
| 223 |
ost << "Ratio T/W : " << tsw() << '\n'; |
| 224 |
|
| 225 |
// ost << "Omega_c / e_max^{1/2} : " << get_omega_c() * len_rho << '\n'; |
| 226 |
|
| 227 |
ost << "Circumferential equatorial radius R_circ : " |
| 228 |
<< r_circ()/km << " km" << '\n'; |
| 229 |
ost << "Circumferential polar radius Rp_circ : " |
| 230 |
<< rp_circ()/km << " km" << endl ; |
| 231 |
ost << "Coordinate equatorial radius r_eq : " << ray_eq()/km << " km" |
| 232 |
<< endl ; |
| 233 |
ost << "Flattening r_pole/r_eq : " << aplat() << endl ; |
| 234 |
ost << "Ellipticity sqrt(1-(Rp_circ/R_circ)^2) : " << ellipt() << endl ; |
| 235 |
double compact = qpig/(4.*M_PI) * mass_g() / r_circ() ; |
| 236 |
ost << "Compaction parameter M_g / R_circ : " << compact << '\n'; |
| 237 |
|
| 238 |
|
| 239 |
// More to come here..... |
| 240 |
|
| 241 |
return ost ; |
| 242 |
|
| 243 |
} |
| 244 |
|
| 245 |
|
| 246 |
//-----------------------// |
| 247 |
// Miscellaneous // |
| 248 |
//-----------------------// |
| 249 |
|
| 250 |
double Star_rot_Dirac_diff::funct_omega(double omeg) const { |
| 251 |
|
| 252 |
return frot(omeg, par_frot) ; |
| 253 |
|
| 254 |
} |
| 255 |
|
| 256 |
double Star_rot_Dirac_diff::prim_funct_omega(double omeg) const { |
| 257 |
|
| 258 |
return primfrot(omeg, par_frot) ; |
| 259 |
|
| 260 |
} |
| 261 |
|
| 262 |
double Star_rot_Dirac_diff::get_omega_c() const { |
| 263 |
|
| 264 |
return omega_field.val_grid_point(0, 0, 0, 0) ; |
| 265 |
|
| 266 |
} |
| 267 |
} |