Particles and Nuclei Sub-Library: Version 0.910
eff_fermion.h
00001 /*
00002   -------------------------------------------------------------------
00003   
00004   Copyright (C) 2006-2012, Andrew W. Steiner
00005   
00006   This file is part of O2scl.
00007   
00008   O2scl is free software; you can redistribute it and/or modify
00009   it under the terms of the GNU General Public License as published by
00010   the Free Software Foundation; either version 3 of the License, or
00011   (at your option) any later version.
00012   
00013   O2scl is distributed in the hope that it will be useful,
00014   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016   GNU General Public License for more details.
00017   
00018   You should have received a copy of the GNU General Public License
00019   along with O2scl. If not, see <http://www.gnu.org/licenses/>.
00020 
00021   -------------------------------------------------------------------
00022 */
00023 #ifndef O2SCL_EFF_FERMION_H
00024 #define O2SCL_EFF_FERMION_H
00025 
00026 #include <string>
00027 #include <iostream>
00028 #include <fstream>
00029 #include <cmath>
00030 #include <o2scl/constants.h>
00031 #include <o2scl/umatrix_tlate.h>
00032 #include <o2scl/funct.h>
00033 #include <o2scl/mm_funct.h>
00034 #include <o2scl/root.h>
00035 #include <o2scl/mroot.h>
00036 #include <o2scl/inte.h>
00037 #include <o2scl/cern_mroot_root.h>
00038 #include <o2scl/misc.h>
00039 
00040 #include <o2scl/fermion.h>
00041 
00042 #ifndef DOXYGENP
00043 namespace o2scl {
00044 #endif
00045 
00046   /** \brief Fermion class from fitting method
00047       
00048       Based on the fitting method of \ref Johns96 which is an update
00049       of the method from \ref Eggleton73 . This method is approximate,
00050       but very fast. For a more accurate (but slower) method, use
00051       rel_fermion.
00052       
00053       Given the chemical potential and the temperature the functions
00054       calc_mu() and pair_mu() work by solving the equation (c.f. Eq. 15
00055       in \ref Johns96)
00056       \f[
00057       \psi= 2 \sqrt{1+f/a}+\log\left(\frac{\sqrt{1+f/a}-1}
00058       {\sqrt{1+f/a}+1}\right)
00059       \f]
00060       for \f$ f \f$ given \f$ \psi=(\mu-m)/T \f$.
00061       If \f$ f/a<10^{-10} \f$, then the alternative expression
00062       \f[
00063       \psi= 2 \left(1+f/(2 a)\right)+\log\left[\frac{f/(2 a)}
00064       {\left(1+f/(2 a)\right)}\right]
00065       \f]
00066       is used. The pressure, energy density, and entropy, are
00067       determined as polynomials in \f$ f \f$ with a
00068       set of precomputed coefficients as done in \ref Johns96 .
00069 
00070       If \f$ \psi \f$ is too small (less than about -200), the 
00071       above procedure fails. To handle this, this class
00072       uses the \classical result if \f$ \psi \f$ < \ref min_psi,
00073       where \ref min_psi defaults to -200.
00074 
00075       When the density and temperature is given instead
00076       (calc_density() and pair_density()), then there are two ways to
00077       proceed.
00078       - Use the density to solve for \f$ f \f$ .
00079       - Use the density to solve for the chemical potential.
00080 
00081       Because the density is a complicated polynomial in \f$ f \f$,
00082       the former procedure does not work very well even though it
00083       might be less time consuming. In this class, the density is
00084       solved for the effective chemical potential instead. The initial
00085       guess is just taken from the present value of part::nu .
00086 
00087       \note It is important to note that the coefficients are
00088       static and apply to all objects of type \ref eff_fermion.
00089 
00090       \note The coefficients are stored in static data, and there is
00091       a small possibility of a memory leak in a multithreaded program
00092       if more than one instance of \ref eff_fermion tries to initialize
00093       these coefficients in the constructor. This can easily be 
00094       avoided by ensuring that the static coefficients are initialized
00095       by a single thread beforehand. 
00096 
00097       \todo There's still def_err_hnd.set_mode(0) in the testing code,
00098       probably because the solver has a hard time for extreme values.
00099 
00100       \future Use bracketing to speed up one-dimensional root finding.
00101   */
00102   class eff_fermion : public fermion_eval_thermo {
00103 
00104   public:
00105     
00106     /// Create a fermion with mass \c mass and degeneracy \c dof 
00107     eff_fermion();
00108     
00109     virtual ~eff_fermion();
00110     
00111     /** \name Coefficients for finite-temperature approximation
00112      */
00113     //@{
00114     /** \brief Load coefficients
00115         
00116         The argument \c ctype Should be one of the constants below.
00117     */
00118     void load_coefficients(int ctype);
00119 
00120     /// A set of coefficients from Jim Lattimer 
00121     static const int cf_fermilat3=1;
00122     /// The smaller set of coefficients from \ref Johns96
00123     static const int cf_fermijel2=2;
00124     /// The larger set of coefficients from \ref Johns96
00125     static const int cf_fermijel3=3;
00126     /** \brief The set of coefficients from \ref Johns96 which retains 
00127         better thermodynamic consistency
00128     */
00129     static const int cf_fermijel3cons=4;
00130     //@}
00131 
00132     /** \brief Calculate thermodynamic 
00133         properties as function of chemical potential
00134         
00135         If the quantity \f$ (\mu-m)/T \f$ (or \f$ (\nu-m^{*})/T \f$ in
00136         the case of interacting particles) is less than -200, then
00137         this quietly sets the density, the scalar density, the energy
00138         density, the pressure and the entropy to zero and exits.
00139 
00140         \todo Should see if the function actually works if 
00141         \f$ (\mu-m)/T = -199 \f$ .
00142     */
00143     virtual void calc_mu(fermion &f, double temper);
00144 
00145     /** \brief Calculate thermodynamic properties as function of
00146         density
00147 
00148         \warning This function needs a guess for the chemical
00149         potential, and will fail if that guess is not sufficiently
00150         accurate.
00151     */
00152     virtual void calc_density(fermion &f, double temper);
00153 
00154     /** \brief Calculate thermodynamic properties with antiparticles
00155         as function of chemical potential
00156 
00157         \warning This function needs a guess for the chemical
00158         potential, and will fail if that guess is not sufficiently
00159         accurate.
00160     */
00161     virtual void pair_mu(fermion &f, double temper);
00162 
00163     /** \brief Calculate thermodynamic properties with antiparticles
00164         as function of density
00165     */
00166     virtual void pair_density(fermion &f, double temper);
00167 
00168     /** \brief Set the solver for use in calculating \f$ \psi \f$ 
00169      */
00170     int set_psi_root(root<funct> &rp) {
00171       psi_root=&rp;
00172       return 0;
00173     }
00174 
00175     /** \brief Set the solver for use in calculating the chemical
00176         potential from the density
00177     */
00178     int set_density_root(root<funct> &rp) {
00179       density_root=&rp;
00180       return 0;
00181     }
00182     
00183     /** \brief If the temperature is less than \c tlimit then the
00184         zero-temperature functions are used (default 0).
00185     */
00186     double tlimit;
00187     
00188     /** \brief The default solver for \f$ \psi \f$
00189      */
00190     cern_mroot_root<funct> def_psi_root;
00191     
00192     /** \brief The default solver for calc_density() and pair_density()
00193      */
00194     cern_mroot_root<funct> def_density_root;
00195     
00196     /// Return string denoting type ("eff_fermion")
00197     virtual const char *type() { return "eff_fermion"; }
00198 
00199     /// The minimum value of \f$ \psi \f$ (default -200)
00200     double min_psi;
00201 
00202 #ifndef DOXYGEN_INTERNAL
00203 
00204   protected:
00205 
00206     /// The matrix of coefficients
00207     umatrix Pmnf;
00208     /// The parameter \f$ a \f$
00209     double parma;
00210     /// The array row size
00211     int sizem;
00212     /// The array column size
00213     int sizen;
00214     
00215     /// The solver for \f$ \psi \f$
00216     root<funct> *psi_root;
00217     /// The other solver for calc_density()
00218     root<funct> *density_root;
00219     
00220     /// The function which solves for \f$ f \f$ from \f$ \psi \f$.
00221     double solve_fun(double x, double &psi);
00222     
00223     /** \brief Define the function which solves for the chemical 
00224         potential given the density [protected subclass of \ref 
00225         eff_fermion]
00226     */
00227     class density_fun : public funct {
00228 
00229     protected:
00230 
00231       eff_fermion &ef_;
00232       fermion &f_;
00233       double T_;
00234 
00235     public:
00236 
00237       density_fun(eff_fermion &ef, fermion &f, double T);
00238       
00239       /// Fix density for \ref eff_fermion::calc_density()
00240       double operator()(double x);
00241 
00242     };
00243 
00244     /** \brief Define the function which solves for the chemical 
00245         potential given the density of particles and antiparticles
00246         [protected subclass of \ref eff_fermion]
00247     */
00248     class pair_density_fun : public funct {
00249 
00250     protected:
00251 
00252       eff_fermion &ef_;
00253       fermion &f_;
00254       double T_;
00255 
00256     public:
00257 
00258       pair_density_fun(eff_fermion &ef, fermion &f, double T);
00259       
00260       /// Fix density for \ref eff_fermion::pair_density()
00261       double operator()(double x);
00262 
00263     };
00264     
00265 #endif
00266 
00267   };
00268 
00269 #ifndef DOXYGENP
00270 }
00271 #endif
00272 
00273 #endif
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Friends

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).

Get Object-oriented Scientific Computing
Lib at SourceForge.net. Fast, secure and Free Open Source software
downloads.