eff_fermion.h

00001 /*
00002   -------------------------------------------------------------------
00003   
00004   Copyright (C) 2006, 2007, 2008, 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/funct.h>
00032 #include <o2scl/mm_funct.h>
00033 #include <o2scl/root.h>
00034 #include <o2scl/mroot.h>
00035 #include <o2scl/inte.h>
00036 #include <o2scl/fermion.h>
00037 #include <o2scl/cern_mroot_root.h>
00038 #include <o2scl/misc.h>
00039 
00040 #ifndef DOXYGENP
00041 namespace o2scl {
00042 #endif
00043 
00044   /** 
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 .
00050 
00051       Given the chemical potential and the temperature (using
00052       calc_mu() and pair_mu()), the function
00053       \f[
00054       \psi= 2 \sqrt{1+f/a}+\log\left(\frac{\sqrt{1+f/a}-1}
00055       {\sqrt{1+f/a}+1}\right)
00056       \f]
00057       is solved for \f$ f \f$ given a value of \f$ \psi=(\mu-m)/T \f$.
00058       If \f$ f/a<10^{-10} \f$, then the alternative expression
00059       \f[
00060       \psi= 2 \left(1+f/(2 a)\right)+\log\left[\frac{f/(2 a)}
00061       {\left(1+f/(2 a)\right)}\right]
00062       \f]
00063       is used. The pressure, energy density, and entropy, are
00064       determined through a set of coefficients.
00065 
00066       When the density and temperature is given instead
00067       (calc_density() and pair_density()), then there are two ways to
00068       proceed.
00069       - We can use the density to solve for \f$ f \f$
00070       - We can use the density to solve for the chemical potential
00071 
00072       Because the density is a complicated polynomial in \f$ f \f$,
00073       the former procedure doesn't work very well even though it might
00074       be less time consuming. The density is solved for the effective
00075       chemical potential instead. The initial guess is just taken from
00076       the present value of part::nu.
00077 
00078       The constructor uses the coefficients from the file \c fermilat3
00079       by default.
00080 
00081       It is important that the \ref inte and \ref root objects are not
00082       safe so that different instances do not use the same instance of
00083       one of a \ref inte or \ref root object simultaneously.
00084 
00085       \todo Use bracketing to speed up one-dimensional root finding
00086   */
00087   class eff_fermion : virtual public fermion {
00088 
00089   public:
00090     
00091     /// Create a fermion with mass \c mass and degeneracy \c dof 
00092     eff_fermion(double mass=0.0, double dof=0.0);
00093     
00094     virtual ~eff_fermion();
00095     
00096     /** \name Load coefficients for finite-temperature approximation
00097 
00098         \c ctype Should be one of the constants below:
00099         cf_fermilat3, cf_fermijel2, cf_fermijel3, or
00100         cf_fermijel3cons. 
00101         
00102     */
00103     //@{
00104     static int load_coefficients(int ix);
00105     static const int cf_fermilat3=1;
00106     static const int cf_fermijel2=2;
00107     static const int cf_fermijel3=3;
00108     static const int cf_fermijel3cons=4;
00109     //@}
00110 
00111   
00112     /** 
00113         \brief Calculate properties as function of chemical potential
00114         
00115         If the quantity \f$ (\mu-m)/T \f$ (or \f$ (\nu-m^{*})/T \f$ in
00116         the case of interacting particles) is less than -200, then
00117         this quietly sets the density, the scalar density, the energy
00118         density, the pressure and the entropy to zero and exits.
00119 
00120         \todo Should see if the function actually works if 
00121         \f$ (\mu-m)/T = -199 \f$ .
00122      */
00123     virtual int calc_mu(const double temper);
00124 
00125     /** \brief Calculate properties as function of density
00126      */
00127     virtual int calc_density(const double temper);
00128 
00129     /** \brief Calculate properties with antiparticles as function of
00130         chemical potential
00131     */
00132     virtual int pair_mu(const double temper);
00133 
00134     /** \brief Calculate properties with antiparticles as function of
00135         density
00136      */
00137     virtual int pair_density(const double temper);
00138 
00139     /** \brief Set the solver for use in calculating \f$ \psi \f$ 
00140      */
00141     int set_psi_root(root<void *, funct<void *> > &rp) {
00142       psi_root=&rp;
00143       return 0;
00144     }
00145 
00146     /** \brief Set the solver for use in calculating the chemical
00147         potential from the density with meth2=true
00148     */
00149     int set_density_root(root<void *, funct<void *> > &rp) {
00150       density_root=&rp;
00151       return 0;
00152     }
00153     
00154     /** \brief If the temperature is less than \c tlimit then the
00155         zero-temperature functions are used (default \f$ 10^{-8}
00156         \mathrm{fm}^{-1} \f$ ).
00157     */
00158     double tlimit;
00159     
00160     /** \brief The default solver for \f$ \psi \f$
00161      */
00162     cern_mroot_root<void *, funct<void *> > def_psi_root;
00163     
00164     /** \brief The default solver for calc_density() and pair_density()
00165      */
00166     cern_mroot_root<void *, funct<void *> > def_density_root;
00167     
00168     /// Return string denoting type ("eff_fermion")
00169     virtual const char *type() { return "eff_fermion"; }
00170 
00171 #ifndef DOXYGEN_INTERNAL
00172 
00173   protected:
00174 
00175     friend class io_tlate<eff_fermion>;
00176 
00177     /// The matrix of coefficients
00178     static double **Pmnf;
00179     /// The parameter \f$ a \f$
00180     static double parma;
00181     /// The array row size
00182     static int sizem;
00183     /// The array column size
00184     static int sizen;
00185     
00186     /// The solver for \f$ \psi \f$
00187     root<void *,funct<void *> > *psi_root;
00188     /// The other solver for calc_density()
00189     root<void *,funct<void *> > *density_root;
00190     
00191     /// The function which solves for \f$ f \f$ from \f$ \psi \f$.
00192     int solve_fun(double x, double &y, void *&pa);
00193     
00194     /// Fix density for calc_density()
00195     int density_fun(double x, double &y, void *&pa);
00196     
00197     /// Fix density for pair_density()
00198     int pair_density_fun(double x, double &y, void *&pa);
00199 
00200 #endif
00201 
00202   };
00203 
00204   template<> int io_tlate<eff_fermion>::input
00205     (cinput *co, in_file_format *ins, eff_fermion *f);
00206   template<> int io_tlate<eff_fermion>::output
00207     (coutput *co, out_file_format *outs, eff_fermion *f);
00208   /*
00209     template<> int io_tlate<eff_fermion>::stat_input
00210     (cinput *co, in_file_format *ins, eff_fermion *f);
00211     template<> int io_tlate<eff_fermion>::stat_output
00212     (coutput *co, out_file_format *outs, eff_fermion *f);
00213     template<> bool io_tlate<eff_fermion>::has_static_data();
00214   */
00215   template<> const char *io_tlate<eff_fermion>::type();
00216   
00217   typedef io_tlate<eff_fermion> eff_fermion_io_type;
00218 
00219 #ifndef DOXYGENP
00220 }
00221 #endif
00222 
00223 #endif

Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.

Project hosting provided by SourceForge.net Logo, O2scl Sourceforge Project Page