| 1 | /* |
| 2 | * Definition of Lorene class Star_rot_dirac_diff |
| 3 | * |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * Copyright (c) 2005 Motoyuki Saijo |
| 8 | * |
| 9 | * This file is part of LORENE. |
| 10 | * |
| 11 | * LORENE is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 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 | #ifndef __STAR_ROT_DIRAC_DIFF_H_ |
| 29 | #define __STAR_ROT_DIRAC_DIFF_H_ |
| 30 | |
| 31 | /* |
| 32 | * |
| 33 | * $Header: /cvsroot/Lorene/C++/Include/star_rot_dirac_diff.h,v 1.2 2014/10/13 08:52:36 j_novak Exp $ |
| 34 | * |
| 35 | */ |
| 36 | |
| 37 | // Headers Lorene |
| 38 | #include "star_rot_dirac.h" |
| 39 | |
| 40 | namespace Lorene { |
| 41 | |
| 42 | /** |
| 43 | * Class for relativistic differentially rotating stars in Dirac gauge and |
| 44 | * maximal slicing. (*** Under development ***) \ingroup (star) |
| 45 | * |
| 46 | * |
| 47 | */ |
| 48 | |
| 49 | class Star_rot_Dirac_diff : public Star_rot_Dirac { |
| 50 | |
| 51 | // Data : |
| 52 | // ----- |
| 53 | protected: |
| 54 | /** Function \f$F(\Omega)\f$ defining the rotation profile. |
| 55 | * This function is linked to the components of the fluid 4-velocity |
| 56 | * by |
| 57 | * \f[ |
| 58 | * F(\Omega) = u^t u_\varphi \ . |
| 59 | * \f] |
| 60 | * The first argument of \c frot must be \f$\Omega\f$; the second |
| 61 | * argument contains the parameters, the first of which being |
| 62 | * necessarily the central value of \f$\Omega\f$. |
| 63 | */ |
| 64 | double (*frot)(double, const Tbl&) ; |
| 65 | |
| 66 | /** Primitive of the function \f$F(\Omega)\f$, which vanishes at the |
| 67 | * stellar center. |
| 68 | * The first argument of \c primfrot must be \f$\Omega\f$; the second |
| 69 | * argument contains the parameters, the first of which being |
| 70 | * necessarily the central value of \f$\Omega\f$. |
| 71 | */ |
| 72 | double (*primfrot)(double, const Tbl&) ; |
| 73 | |
| 74 | /** Parameters of the function \f$F(\Omega)\f$. |
| 75 | * |
| 76 | * To be used as the second argument of functions \c frot |
| 77 | * and \c primfrot . |
| 78 | * The parameter \c par_frot(0) must always be the central angular |
| 79 | * velocity. |
| 80 | */ |
| 81 | Tbl par_frot ; |
| 82 | |
| 83 | /// Field \f$\Omega(r,\theta)\f$ |
| 84 | Scalar omega_field ; |
| 85 | |
| 86 | double omega_min ; ///< Minimum value of \f$\Omega\f$ |
| 87 | double omega_max ; ///< Maximum value of \f$\Omega\f$ |
| 88 | |
| 89 | /// Field \f$\int_{\Omega_{\rm c}}^\Omega F(\Omega') \, d\Omega' \f$ |
| 90 | Scalar prim_field ; |
| 91 | |
| 92 | // Constructors - Destructor |
| 93 | // ------------------------- |
| 94 | public: |
| 95 | /** Standard constructor. |
| 96 | * |
| 97 | * @param mp_i Mapping on which the star will be defined |
| 98 | * @param nzet_i Number of domains occupied by the star |
| 99 | * @param relat should be \c true for a relativistic |
| 100 | * star, \c false for a Newtonian one |
| 101 | * @param eos_i Equation of state of the stellar matter |
| 102 | * @param frot_i Function \f$F(\Omega)\f$ defining the rotation profile. |
| 103 | * @param primfrot_i Primitive of \f$F(\Omega)\f$ which vanishes at the |
| 104 | * stellar center |
| 105 | * @param par_frot_i Parameters of functions \c frot_i |
| 106 | * and \c primfrot_i , |
| 107 | * \c par_frot_i(0) being the central value of |
| 108 | * \f$\Omega\f$. |
| 109 | */ |
| 110 | Star_rot_Dirac_diff(Map& mp_i, int nzet_i, const Eos& eos_i, |
| 111 | double (*frot_i)(double, const Tbl&), |
| 112 | double (*primfrot_i)(double, const Tbl&), |
| 113 | const Tbl& par_frot_i) ; |
| 114 | |
| 115 | Star_rot_Dirac_diff(const Star_rot_Dirac_diff& ) ; ///< Copy constructor |
| 116 | |
| 117 | /** Constructor from a file (see \c sauve(FILE*) ). |
| 118 | * |
| 119 | * @param mp_i Mapping on which the star will be defined |
| 120 | * @param eos_i Equation of state of the stellar matter |
| 121 | * @param fich input file (must have been created by the function |
| 122 | * \c sauve ) |
| 123 | * @param frot_i Function \f$F(\Omega)\f$ defining the rotation profile. |
| 124 | * @param primfrot_i Primitive of \f$F(\Omega)\f$ which vanishes at the |
| 125 | * stellar center |
| 126 | */ |
| 127 | Star_rot_Dirac_diff(Map& mp_i, const Eos& eos_i, FILE* fich, |
| 128 | double (*frot_i)(double, const Tbl&), |
| 129 | double (*primfrot_i)(double, const Tbl&) ) ; |
| 130 | |
| 131 | virtual ~Star_rot_Dirac_diff() ; ///< Destructor |
| 132 | |
| 133 | |
| 134 | // Memory management |
| 135 | // ----------------- |
| 136 | |
| 137 | // Everything is inherited from Star_rot_dirac |
| 138 | |
| 139 | // Mutators / assignment |
| 140 | // --------------------- |
| 141 | public: |
| 142 | /// Assignment to another \c Star_rot_Dirac_diff |
| 143 | void operator=(const Star_rot_Dirac_diff& ) ; |
| 144 | |
| 145 | // Accessors |
| 146 | // --------- |
| 147 | public: |
| 148 | /// Returns the angular velocity field \f$\Omega\f$ |
| 149 | const Scalar& get_omega_field() const {return omega_field;} ; |
| 150 | |
| 151 | /** Returns the central value of the rotation angular velocity |
| 152 | * (\c [f_unit] ) |
| 153 | */ |
| 154 | virtual double get_omega_c() const ; |
| 155 | |
| 156 | |
| 157 | // Outputs |
| 158 | // ------- |
| 159 | public: |
| 160 | virtual void sauve(FILE *) const ; ///< Save in a file |
| 161 | |
| 162 | /* /// Display in polytropic units */ |
| 163 | /* virtual void display_poly(ostream& ) const ; */ |
| 164 | |
| 165 | /// Display |
| 166 | friend ostream& operator<<(ostream& , const Star& ) ; |
| 167 | |
| 168 | |
| 169 | protected: |
| 170 | /// Operator >> (virtual function called by the operator <<). |
| 171 | virtual ostream& operator>>(ostream& ) const ; |
| 172 | |
| 173 | |
| 174 | // Computational routines |
| 175 | // ---------------------- |
| 176 | public: |
| 177 | |
| 178 | virtual double tsw() const ; ///< Ratio T/W |
| 179 | |
| 180 | /** Computes the hydrodynamical quantities relative to the Eulerian |
| 181 | * observer from those in the fluid frame. |
| 182 | * |
| 183 | * The calculation is performed starting from the quantities |
| 184 | * \c omega_field , \c ent , \c ener , \c press , |
| 185 | * and \c a_car , |
| 186 | * which are supposed to be up to date. |
| 187 | * From these, the following fields are updated: |
| 188 | * \c gam_euler , \c u_euler , \c ener_euler , \c s_euler . |
| 189 | * |
| 190 | */ |
| 191 | virtual void hydro_euler() ; |
| 192 | |
| 193 | /** Computes \f$\Omega(r,\theta)\f$ (member \c omega_field ). |
| 194 | * |
| 195 | * The computation amounts to solving the equation |
| 196 | * \f[ |
| 197 | * F(\Omega) - {\gamma_{\varphi \varphi} (\beta^\varphi + \Omega) |
| 198 | * \over N^2 - \gamma_{\varphi \varphi}(\beta^\varphi + \Omega)^2} = 0 |
| 199 | * \f] |
| 200 | * for \f$\Omega\f$. |
| 201 | * |
| 202 | * @param omeg_min [input] Lower bound of the interval for |
| 203 | * searching omega |
| 204 | * @param omeg_max [input] Higher bound of the interval for |
| 205 | * searching omega |
| 206 | * @param precis [input] Required precision in the determination of |
| 207 | * the zero by the secant method |
| 208 | * @param nitermax [input] Maximum number of iterations in the secant |
| 209 | * method to compute the zero. |
| 210 | */ |
| 211 | void fait_omega_field(double omeg_min, double omeg_max, |
| 212 | double precis, int nitermax) ; |
| 213 | |
| 214 | /// Computes the member \c prim_field from \c omega_field . |
| 215 | void fait_prim_field() ; |
| 216 | |
| 217 | /** Evaluates \f$F(\Omega)\f$, where \e F is the function |
| 218 | * defining the rotation profile. |
| 219 | * This function is linked to the components of the fluid 4-velocity |
| 220 | * by |
| 221 | * \f[ |
| 222 | * F(\Omega) = u^t u_\varphi \ . |
| 223 | * \f] |
| 224 | * |
| 225 | * \c funct_omega calls \c frot with the parameters |
| 226 | * \c par_frot . |
| 227 | * |
| 228 | * @param omeg [input] value of \f$\Omega\f$ |
| 229 | * @return value of \f$F(\Omega)\f$ |
| 230 | * |
| 231 | */ |
| 232 | double funct_omega(double omeg) const ; |
| 233 | |
| 234 | /** Evaluates the primitive of \f$F(\Omega)\f$, where \e F is the function |
| 235 | * defining the rotation profile. |
| 236 | * |
| 237 | * @param omeg [input] value of \f$\Omega\f$ |
| 238 | * @return value of |
| 239 | * \f$\int_{\Omega_{\rm c}}^\Omega F(\Omega') \, d\Omega' \f$ |
| 240 | * |
| 241 | */ |
| 242 | double prim_funct_omega(double omeg) const ; |
| 243 | |
| 244 | /** Computes an equilibrium configuration. |
| 245 | * |
| 246 | * @param ent_c [input] Central enthalpy |
| 247 | * @param omega0 [input] Requested central angular velocity |
| 248 | * (if \c fact_omega=1. ) |
| 249 | * @param fact_omega [input] 1.01 = search for the Keplerian frequency, |
| 250 | * 1. = otherwise. |
| 251 | * @param nzadapt [input] Number of (inner) domains where the mapping |
| 252 | * adaptation to an iso-enthalpy surface |
| 253 | * should be performed |
| 254 | * @param ent_limit [input] 1-D \c Tbl of dimension \c nzet which |
| 255 | * defines the enthalpy at the outer boundary |
| 256 | * of each domain |
| 257 | * @param icontrol [input] Set of integer parameters (stored as a |
| 258 | * 1-D \c Itbl of size 8) to control the |
| 259 | * iteration: |
| 260 | * \li \c icontrol(0) = mer_max : maximum number of steps |
| 261 | * \li \c icontrol(1) = mer_rot : step at which the rotation is |
| 262 | * switched on |
| 263 | * \li \c icontrol(2) = mer_change_omega : step at which the rotation |
| 264 | * velocity is changed to reach the final one |
| 265 | * \li \c icontrol(3) = mer_fix_omega : step at which the final |
| 266 | * rotation velocity must have been reached |
| 267 | * \li \c icontrol(4) = mer_mass : the absolute value of |
| 268 | * \c mer_mass is the step from which the |
| 269 | * baryon mass is forced to converge, |
| 270 | * by varying the central enthalpy |
| 271 | * (\c mer_mass > 0 ) or the angular |
| 272 | * velocity (\c mer_mass < 0 ) |
| 273 | * \li \c icontrol(5) = mermax_poisson : maximum number of steps in |
| 274 | * \c Map_et::poisson |
| 275 | * \li \c icontrol(6) = mer_triax : step at which the 3-D |
| 276 | * perturbation is switched on |
| 277 | * \li \c icontrol(7) = delta_mer_kep : number of steps |
| 278 | * after \c mer_fix_omega when \c omega |
| 279 | * starts to be increased by \c fact_omega |
| 280 | * to search for the Keplerian velocity |
| 281 | * |
| 282 | * @param control [input] Set of parameters (stored as a |
| 283 | * 1-D \c Tbl of size 7) to control the |
| 284 | * iteration: |
| 285 | * \li \c control(0) = precis : threshold on the enthalpy relative |
| 286 | * change for ending the computation |
| 287 | * \li \c control(1) = omega_ini : initial central angular velocity, |
| 288 | * switched on only if \c mer_rot < 0 , |
| 289 | * otherwise 0 is used |
| 290 | * \li \c control(2) = relax : relaxation factor in the main |
| 291 | * iteration |
| 292 | * \li \c control(3) = relax_poisson : relaxation factor in |
| 293 | * \c Map_et::poisson |
| 294 | * \li \c control(4) = thres_adapt : threshold on dH/dr for |
| 295 | * freezing the adaptation of the mapping |
| 296 | * \li \c control(5) = ampli_triax : relative amplitude of |
| 297 | * the 3-D perturbation |
| 298 | * \li \c control(6) = precis_adapt : precision for |
| 299 | * \c Map_et::adapt |
| 300 | * |
| 301 | * @param mbar_wanted [input] Requested baryon mass (effective only |
| 302 | * if \c mer_mass > mer_max ) |
| 303 | * @param aexp_mass [input] Exponent for the increase factor of the |
| 304 | * central enthalpy to converge to the |
| 305 | * requested baryon mass |
| 306 | * @param diff [output] 1-D \c Tbl of size 7 for the storage of |
| 307 | * some error indicators : |
| 308 | * \li \c diff(0) : Relative change in the enthalpy field |
| 309 | * between two successive steps |
| 310 | * \li \c diff(1) : Relative error in the resolution of the |
| 311 | * Poisson equation for \c nuf |
| 312 | * \li \c diff(2) : Relative error in the resolution of the |
| 313 | * Poisson equation for \c nuq |
| 314 | * \li \c diff(3) : Relative error in the resolution of the |
| 315 | * Poisson equation for \c dzeta |
| 316 | * \li \c diff(4) : Relative error in the resolution of the |
| 317 | * Poisson equation for \c tggg |
| 318 | * \li \c diff(5) : Relative error in the resolution of the |
| 319 | * equation for \c shift (x comp.) |
| 320 | * \li \c diff(6) : Relative error in the resolution of the |
| 321 | * equation for \c shift (y comp.) |
| 322 | */ |
| 323 | virtual void equilibrium(double ent_c, double omega0, double fact_omega, |
| 324 | int nzadapt, const Tbl& ent_limit, |
| 325 | const Itbl& icontrol, const Tbl& control, |
| 326 | double mbar_wanted, double aexp_mass, |
| 327 | Tbl& diff) ; |
| 328 | |
| 329 | }; |
| 330 | |
| 331 | } |
| 332 | #endif |