rel_fermion.h

00001 /*
00002   -------------------------------------------------------------------
00003   
00004   Copyright (C) 2006, 2007, 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_REL_FERMION_H
00024 #define O2SCL_REL_FERMION_H
00025 
00026 #include <string>
00027 #include <iostream>
00028 #include <fstream>
00029 #include <cmath>
00030 #include <o2scl/constants.h>
00031 #include <o2scl/mroot.h>
00032 #include <o2scl/inte.h>
00033 #include <o2scl/fermion.h>
00034 #include <o2scl/cern_mroot_root.h>
00035 #include <o2scl/gsl_inte_qagiu.h>
00036 #include <o2scl/gsl_inte_qag.h>
00037 
00038 #ifndef DOXYGENP
00039 namespace o2scl {
00040 #endif
00041 
00042   /** 
00043       \brief Equation of state for a relativistic fermion
00044 
00045       This implements an equation of state for a relativistic fermion
00046       using direct integration. Define the degeneracy parameter 
00047       \f[
00048       \psi=(\nu-m^{*})/T 
00049       \f] 
00050       where \f$ \nu \f$ is the effective chemical potential and \f$
00051       m^{*} \f$ is the effective mass. For \f$ \psi \f$ greater than
00052       \ref deg_limit (degenerate regime), a finite interval integrator
00053       is used and for \f$ \psi \f$ less than \ref deg_limit
00054       (non-degenerate regime), an integrator over the interval from
00055       \f$ [0,\infty) \f$ is used. Typical choices are Gauss-Legendre
00056       integration for the degenerate regime and Gauss-Laguerre
00057       integration for the non-degenerate regime. The upper limit on
00058       the degenerate integration is given by
00059       \f[
00060       \sqrt{(20 T+{\nu})^2-m^{*,2}}
00061       \f]
00062       
00063       The default integrators are gsl_inte_qag and gsl_inte_qagiu.
00064       
00065       \note This does not work with inc_rest_mass=false
00066       
00067   */
00068   class rel_fermion : public fermion {
00069 
00070   public:
00071 
00072     /// The critical degeneracy at which to switch integration techniques
00073     double deg_limit;
00074 
00075     /// Storage for the uncertainty
00076     fermion unc;
00077 
00078     /** \brief If true, use the present value of the chemical potential as
00079         a guess for the new chemical potential
00080     */
00081     bool guess_from_nu;
00082     
00083     /// Create a fermion with mass \c m and degeneracy \c g
00084     rel_fermion(double m=0.0, double g=0.0);
00085     virtual ~rel_fermion();
00086     
00087     /** 
00088         \brief Calculate properties as function of chemical potential
00089     */
00090     virtual int calc_mu(const double temper);
00091 
00092     /** \brief Calculate properties as function of density
00093      */
00094     virtual int calc_density(const double temper);
00095 
00096     /** \brief Calculate properties with antiparticles as function of
00097         chemical potential
00098     */
00099     virtual int pair_mu(const double temper);
00100 
00101     /** \brief Calculate properties with antiparticles as function of
00102         density
00103      */
00104     virtual int pair_density(const double temper);
00105 
00106     /// Calculate effective chemical potential from density
00107     virtual int nu_from_n(const double temper);
00108     
00109     /// Set integrators
00110     int set_inte(inte<void *,funct<void *> > &non_it, 
00111                  inte<void *,funct<void *> > &deg_it);
00112     
00113     /** \brief Set the solver for use in calculating the chemical
00114         potential from the density */
00115     int set_density_root(root<void *,funct<void *> > &rp) {
00116       density_root=&rp;
00117       return 0;
00118     }
00119     
00120     /// The default solver for calc_density().
00121     cern_mroot_root<void *,funct<void *> > def_density_root;
00122 
00123     /// The default integrator for degenerate fermions
00124     gsl_inte_qag<void *,funct<void *> > def_dit;
00125 
00126     /// The default integrator for non-degenerate fermions
00127     gsl_inte_qagiu<void *,funct<void *> > def_nit;
00128 
00129     /// Return string denoting type ("rel_fermion")
00130     virtual const char *type() { return "rel_fermion"; }
00131 
00132   protected:
00133     
00134 #ifndef DOXYGEN_INTERNAL
00135     
00136     friend class io_tlate<rel_fermion>;
00137 
00138     /// The non-degenerate integrator
00139     inte<void *,funct<void *> > *nit;
00140     /// The degenerate integrator
00141     inte<void *,funct<void *> > *dit;
00142     /// The solver for calc_density()
00143     root<void *,funct<void *> > *density_root;
00144 
00145     /// The integrand for the density for non-degenerate fermions
00146     double density_fun(double u, void *&pa);
00147 
00148     /// The integrand for the energy density for non-degenerate fermions
00149     double energy_fun(double u, void *&pa);
00150 
00151     /// The integrand for the entropy density for non-degenerate fermions
00152     double entropy_fun(double u, void *&pa);
00153 
00154     /// The integrand for the density for degenerate fermions
00155     double deg_density_fun(double u, void *&pa);
00156 
00157     /// The integrand for the energy density for degenerate fermions
00158     double deg_energy_fun(double u, void *&pa);
00159 
00160     /// The integrand for the entropy density for degenerate fermions
00161     double deg_entropy_fun(double u, void *&pa);
00162 
00163     /// Solve for the chemical potential given the density
00164     int solve_fun(double x, double &yy, void *&pa);
00165     int pair_fun(double x, double &yy, void *&pa);
00166     
00167 #endif
00168 
00169   };
00170 
00171   template<> int io_tlate<rel_fermion>::input
00172     (cinput *co, in_file_format *ins, rel_fermion *f);
00173   template<> int io_tlate<rel_fermion>::output
00174     (coutput *co, out_file_format *outs, rel_fermion *f);
00175   template<> const char *io_tlate<rel_fermion>::type();
00176   template<> int io_tlate<rel_fermion>::stat_input
00177     (cinput *co, in_file_format *ins, rel_fermion *f);
00178   template<> int io_tlate<rel_fermion>::stat_output
00179     (coutput *co, out_file_format *outs, rel_fermion *f);
00180 
00181   typedef io_tlate<rel_fermion> rel_fermion_io_type;
00182 
00183 #ifndef DOXYGENP
00184 }
00185 #endif
00186 
00187 #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