star_rot_dirac_diff.C
/*
* Methods of class Star_rot_Dirac_diff
*
* (see file star_rot_dirac_diff.h for documentation).
*
*/
/*
* Copyright (c) 2005 Motoyuki Saijo
*
* 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 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 $" ;
/*
* $Header: /cvsroot/Lorene/C++/Source/Star/star_rot_dirac_diff.C,v 1.4 2014/10/13 08:53:39 j_novak Exp $
*
*/
// C headers
#include <cmath>
#include <cassert>
// Lorene headers
#include "star_rot_dirac_diff.h"
#include "unites.h"
#include "utilitaires.h"
//--------------//
// Constructors //
//--------------//
// Standard constructor
//-------------------------
namespace Lorene {
Star_rot_Dirac_diff::Star_rot_Dirac_diff(Map& mpi, int nzet_i, const Eos& eos_i,
double (*frot_i)(double, const Tbl&),
double (*primfrot_i)(double, const Tbl&),
const Tbl& par_frot_i)
:Star_rot_Dirac(mpi, nzet_i, eos_i),
frot(frot_i),
primfrot(primfrot_i),
par_frot(par_frot_i),
omega_field(mpi),
prim_field(mpi)
{
// Initialization to a static state :
omega_field = 0 ;
prim_field = 0 ;
omega_min = 0 ;
omega_max = 0 ;
}
// Copy constructor
//-----------------
Star_rot_Dirac_diff::Star_rot_Dirac_diff(const Star_rot_Dirac_diff& star)
: Star_rot_Dirac(star),
frot(star.frot),
primfrot(star.primfrot),
par_frot(star.par_frot),
omega_field(star.omega_field),
omega_min(star.omega_min),
omega_max(star.omega_max),
prim_field(star.prim_field)
{}
//Constructor from a file //## to be more general...
//------------------------
Star_rot_Dirac_diff::Star_rot_Dirac_diff(Map& mpi, const Eos& eos_i, FILE* fich,
double (*frot_i)(double, const Tbl&),
double (*primfrot_i)(double, const Tbl&) )
: Star_rot_Dirac(mpi, eos_i, fich),
frot(frot_i),
primfrot(primfrot_i),
par_frot(fich),
omega_field(mpi),
prim_field(mpi)
{
Scalar omega_field_file(mp, *(mp.get_mg()), fich) ;
omega_field = omega_field_file ;
fait_prim_field() ;
// omega_min and omega_max are read in the file:
fread_be(&omega_min, sizeof(double), 1, fich) ;
fread_be(&omega_max, sizeof(double), 1, fich) ;
}
//------------//
// Destructor //
//------------//
Star_rot_Dirac_diff::~Star_rot_Dirac_diff(){}
//---------------//
// Assignment //
//---------------//
// Assignment to another Star_rot_Dirac_diff
// ------------------------------------
void Star_rot_Dirac_diff::operator=(const Star_rot_Dirac_diff& star) {
// Assignment of quantities common to all the derived classes of
// Star_rot_Dirac
Star_rot_Dirac::operator=(star) ;
// Assignment of proper quantities of class Star_rot_Dirac
frot = star.frot ;
primfrot = star.primfrot ;
par_frot = star.par_frot ;
omega_field = star.omega_field ;
prim_field = star.prim_field ;
omega_min = star.omega_min ;
omega_max = star.omega_max ;
}
//-----------//
// Outputs //
//-----------//
// Save in a file
// --------------
void Star_rot_Dirac_diff::sauve(FILE* fich) const {
Star::sauve(fich) ;
par_frot.sauve(fich) ;
omega_field.sauve(fich) ;
fwrite_be(&omega_min, sizeof(double), 1, fich) ;
fwrite_be(&omega_max, sizeof(double), 1, fich) ;
// What else to save? //## to be more general ...
}
// Printing
// ---------
ostream& Star_rot_Dirac_diff::operator>>(ostream& ost) const {
using namespace Unites ;
Star::operator>>(ost) ;
ost << "Differentially rotating star in Dirac gauge" << '\n';
// Only differentially rotating star for the moment....
ost << '\n';
ost << "Differentially rotating star" << '\n';
ost << "-----------------------" << '\n';
ost << '\n'<< "Parameters of F(Omega) : " << '\n';
ost << par_frot << '\n';
ost << "Min, Max of Omega/(2pi) : " << omega_min / (2*M_PI) * f_unit
<< " Hz, " << omega_max / (2*M_PI) * f_unit << " Hz" << '\n';
int lsurf = nzet - 1;
int nt = mp.get_mg()->get_nt(lsurf) ;
int nr = mp.get_mg()->get_nr(lsurf) ;
ost << "Central, equatorial value of Omega: "
<< omega_field.val_grid_point(0, 0, 0, 0) * f_unit
<< " rad/s, "
<< omega_field.val_grid_point(nzet-1, 0, nt-1, nr-1) * f_unit
<< " rad/s" << '\n';
ost << "Central, equatorial value of Omega/(2 Pi): "
<< omega_field.val_grid_point(0, 0, 0, 0) * f_unit / (2*M_PI)
<< " Hz, "
<< omega_field.val_grid_point(nzet-1, 0, nt-1, nr-1) *
f_unit / (2*M_PI)
<< " Hz" << '\n';
ost << "Error on the virial identity GRV2 : " << '\n';
ost << "GRV2 = " << grv2() << '\n';
ost << "Error on the virial identity GRV3 : " << '\n';
ost << "GRV3 = " << grv3() << '\n';
ost << "Angular momentum J : "
<< angu_mom()/( qpig / (4*M_PI) *msol*msol) << " G M_sol^2 / c"
<< '\n';
ost << "c J / (G M^2) : "
<< angu_mom()/( qpig / (4*M_PI) * pow(mass_g(), 2.) ) << '\n';
if (omega != 0.) {
double mom_iner = angu_mom() / omega ;
double mom_iner_38si = mom_iner * rho_unit * (pow(r_unit, double(5.))
/ double(1.e38) ) ;
ost << "Moment of inertia: " << mom_iner_38si << " 10^38 kg m^2"
<< '\n';
}
ost << "Ratio T/W : " << tsw() << '\n';
// ost << "Omega_c / e_max^{1/2} : " << get_omega_c() * len_rho << '\n';
ost << "Circumferential equatorial radius R_circ : "
<< r_circ()/km << " km" << '\n';
ost << "Circumferential polar radius Rp_circ : "
<< rp_circ()/km << " km" << endl ;
ost << "Coordinate equatorial radius r_eq : " << ray_eq()/km << " km"
<< endl ;
ost << "Flattening r_pole/r_eq : " << aplat() << endl ;
ost << "Ellipticity sqrt(1-(Rp_circ/R_circ)^2) : " << ellipt() << endl ;
double compact = qpig/(4.*M_PI) * mass_g() / r_circ() ;
ost << "Compaction parameter M_g / R_circ : " << compact << '\n';
// More to come here.....
return ost ;
}
//-----------------------//
// Miscellaneous //
//-----------------------//
double Star_rot_Dirac_diff::funct_omega(double omeg) const {
return frot(omeg, par_frot) ;
}
double Star_rot_Dirac_diff::prim_funct_omega(double omeg) const {
return primfrot(omeg, par_frot) ;
}
double Star_rot_Dirac_diff::get_omega_c() const {
return omega_field.val_grid_point(0, 0, 0, 0) ;
}
}
Lorene::Eos
Equation of state base class.
Definition eos.h:190
Lorene::Scalar
Tensor field of valence 0 (or component of a tensorial field).
Definition scalar.h:387
Lorene::Star_rot_Dirac_diff::~Star_rot_Dirac_diff
virtual ~Star_rot_Dirac_diff()
Destructor.
Definition star_rot_dirac_diff.C:116
Lorene::Star_rot_Dirac_diff::omega_field
Scalar omega_field
Field .
Definition star_rot_dirac_diff.h:84
Lorene::Star_rot_Dirac_diff::operator>>
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
Definition star_rot_dirac_diff.C:170
Lorene::Star_rot_Dirac_diff::funct_omega
double funct_omega(double omeg) const
Evaluates , where F is the function defining the rotation profile.
Definition star_rot_dirac_diff.C:250
Lorene::Star_rot_Dirac_diff::sauve
virtual void sauve(FILE *) const
Save in a file.
Definition star_rot_dirac_diff.C:151
Lorene::Star_rot_Dirac_diff::prim_funct_omega
double prim_funct_omega(double omeg) const
Evaluates the primitive of , where F is the function defining the rotation profile.
Definition star_rot_dirac_diff.C:256
Lorene::Star_rot_Dirac_diff::Star_rot_Dirac_diff
Star_rot_Dirac_diff(Map &mp_i, int nzet_i, const Eos &eos_i, double(*frot_i)(double, const Tbl &), double(*primfrot_i)(double, const Tbl &), const Tbl &par_frot_i)
Standard constructor.
Definition star_rot_dirac_diff.C:53
Lorene::Star_rot_Dirac_diff::fait_prim_field
void fait_prim_field()
Computes the member prim_field from omega_field .
Definition strot_dirac_diff_faitomeg.C:176
Lorene::Star_rot_Dirac_diff::frot
double(* frot)(double, const Tbl &)
Function defining the rotation profile.
Definition star_rot_dirac_diff.h:64
Lorene::Star_rot_Dirac_diff::omega_min
double omega_min
Minimum value of .
Definition star_rot_dirac_diff.h:86
Lorene::Star_rot_Dirac_diff::get_omega_c
virtual double get_omega_c() const
Returns the central value of the rotation angular velocity ([f_unit] ).
Definition star_rot_dirac_diff.C:262
Lorene::Star_rot_Dirac_diff::primfrot
double(* primfrot)(double, const Tbl &)
Primitive of the function , which vanishes at the stellar center.
Definition star_rot_dirac_diff.h:72
Lorene::Star_rot_Dirac_diff::prim_field
Scalar prim_field
Field .
Definition star_rot_dirac_diff.h:90
Lorene::Star_rot_Dirac_diff::tsw
virtual double tsw() const
Ratio T/W.
Definition strot_dirac_diff_global.C:48
Lorene::Star_rot_Dirac_diff::par_frot
Tbl par_frot
Parameters of the function .
Definition star_rot_dirac_diff.h:81
Lorene::Star_rot_Dirac_diff::operator=
void operator=(const Star_rot_Dirac_diff &)
Assignment to another Star_rot_Dirac_diff.
Definition star_rot_dirac_diff.C:126
Lorene::Star_rot_Dirac_diff::omega_max
double omega_max
Maximum value of .
Definition star_rot_dirac_diff.h:87
Lorene::Star_rot_Dirac::mass_g
virtual double mass_g() const
Gravitational mass.
Definition strot_dirac_global.C:117
Lorene::Star_rot_Dirac::ellipt
virtual double ellipt() const
Ellipticity e.
Definition strot_dirac_global.C:428
Lorene::Star_rot_Dirac::grv3
virtual double grv3() const
Error on the virial identity GRV3.
Definition strot_dirac_global.C:273
Lorene::Star_rot_Dirac::Star_rot_Dirac
Star_rot_Dirac(Map &mp_i, int nzet_i, const Eos &eos_i, int filter=0)
Standard constructor.
Definition star_rot_dirac.C:93
Lorene::Star_rot_Dirac::angu_mom
virtual double angu_mom() const
Angular momentum.
Definition strot_dirac_global.C:143
Lorene::Star_rot_Dirac::r_circ
virtual double r_circ() const
Circumferential equatorial radius.
Definition strot_dirac_global.C:331
Lorene::Star_rot_Dirac::omega
double omega
Rotation angular velocity ([f_unit] ).
Definition star_rot_dirac.h:59
Lorene::Star_rot_Dirac::rp_circ
virtual double rp_circ() const
Circumferential polar radius.
Definition strot_dirac_global.C:357
Lorene::Star_rot_Dirac::aplat
virtual double aplat() const
Flattening r_pole/r_eq.
Definition strot_dirac_global.C:418
Lorene::Star_rot_Dirac::operator=
void operator=(const Star_rot_Dirac &)
Assignment to another Star_rot_Dirac.
Definition star_rot_dirac.C:266
Lorene::Star_rot_Dirac::grv2
virtual double grv2() const
Error on the virial identity GRV2.
Definition strot_dirac_global.C:204
Lorene::Star::operator>>
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
Definition star.C:417
Lorene::Star::ray_eq
double ray_eq() const
Coordinate radius at , [r_unit].
Definition star_global.C:108
Lorene::Star::sauve
virtual void sauve(FILE *) const
Save in a file.
Definition star.C:397
Lorene::Star::mp
Map & mp
Mapping associated with the star.
Definition star.h:180
Lorene::Star::nzet
int nzet
Number of domains of *mp occupied by the star.
Definition star.h:183
Lorene::Tbl
Basic array class.
Definition tbl.h:161
Lorene::pow
Cmp pow(const Cmp &, int)
Power .
Definition cmp_math.C:348
Lorene::fread_be
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:69
Lorene::fwrite_be
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:70
Lorene
Lorene prototypes.
Definition app_hor.h:64
Lorene::Map
Map(const Mg3d &)
Constructor from a multi-domain 3D grid.
Definition map.C:139
Unites
Standard units of space, time and mass.