sn_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_SN_FERMION_H
00024 #define O2SCL_SN_FERMION_H
00025 
00026 #include <string>
00027 #include <iostream>
00028 #include <fstream>
00029 #include <cmath>
00030 #include <o2scl/constants.h>
00031 #include <o2scl/cern_mroot_root.h>
00032 #include <o2scl/inte.h>
00033 #include <o2scl/deriv_part.h>
00034 #include <o2scl/gsl_inte_qag.h>
00035 #include <o2scl/gsl_inte_qagiu.h>
00036 
00037 #ifndef DOXYGENP
00038 namespace o2scl {
00039 #endif
00040 
00041   /** 
00042       \brief Equation of state for a relativistic fermion
00043 
00044       \note This class does not work with inc_rest_mass=true.
00045 
00046       This implements an equation of state for a relativistic fermion
00047       using direct integration. After subtracting the rest mass from
00048       the chemical potentials, the distribution function is
00049       \f[
00050       \left\{1+\exp[(\sqrt{k^2+m^{* 2}}-m-\nu)/T]\right\}^{-1}
00051       \f]
00052       where \f$ k \f$ is the momentum, \f$ \nu \f$ is the effective
00053       chemical potential, \f$ m \f$ is the rest mass, and \f$ m^{*}
00054       \f$ is the effective mass.  For later use, we define \f$ E^{*} =
00055       \sqrt{k^2 + m^{*2}} \f$ . The degeneracy parameter is
00056       \f[
00057       \psi=(\nu+(m-m^{*}))/T 
00058       \f] 
00059       For \f$ \psi \f$ greater than \ref deg_limit (degenerate
00060       regime), a finite interval integrator is used and for \f$ \psi
00061       \f$ less than \ref deg_limit (non-degenerate regime), an
00062       integrator over the interval from \f$ [0,\infty) \f$ is
00063       used. Typical choices are Gauss-Legendre integration for the
00064       degenerate regime and Gauss-Laguerre integration for the
00065       non-degenerate regime.  The upper limit on the degenerate
00066       integration is given by the solution of
00067       \f[
00068       (\sqrt{k^2+m^{*,2}}-m-\nu)/T=\mathrm{f{l}imit}
00069       \f]
00070       which is
00071       \f[
00072       \sqrt{(m+{\cal L})^2-m^{*2}}
00073       \f]
00074       where \f$ {\cal L}\equiv\mathrm{f{l}imit}\times T+\nu \f$ .
00075 
00076       In the non-degenerate regime, we make the substitution
00077       \f$ u=k/T \f$ to ensure that the variable of integration does not
00078       have units.
00079 
00080       Uncertainties are given in \ref unc.
00081 
00082       \todo This needs to be corrected to calculate \f$ \sqrt{k^2+m^{*
00083       2}}-m \f$ gracefully when \f$ m^{*}\approx m \f$ .
00084       \todo Call error handler if inc_rest_mass is true or update
00085       to properly treat the case when inc_rest_mass is true.
00086       
00087       \b Evaluation \b of \b the \b derivatives
00088 
00089       The relevant
00090       derivatives of the distribution function are
00091       \f[
00092       \frac{\partial f}{\partial T}=
00093       f(1-f)\frac{E^{*}-m-\nu}{T^2}
00094       \f]
00095       \f[
00096       \frac{\partial f}{\partial \nu}=
00097       f(1-f)\frac{1}{T}
00098       \f]
00099       \f[
00100       \frac{\partial f}{\partial k}=
00101       -f(1-f)\frac{k}{E^{*} T}
00102       \f]
00103       \f[
00104       \frac{\partial f}{\partial m^{*}}=
00105       -f(1-f)\frac{m^{*}}{E^{*} T}
00106       \f]
00107 
00108       We also need the derivative of the entropy integrand w.r.t. the 
00109       distribution function, which is
00110       \f[
00111       {\cal S}\equiv f \ln f +(1-f) \ln (1-f) \qquad
00112       \frac{\partial {\cal S}}{\partial f} = \ln 
00113       \left(\frac{f}{1-f}\right) = 
00114       \left(\frac{\nu-E^{*}+m}{T}\right)
00115       \f]
00116       where the entropy density is
00117       \f[
00118       s = - \frac{g}{2 \pi^2} \int_0^{\infty} {\cal S} k^2 d k
00119       \f]
00120 
00121       The derivatives can be integrated directly (\ref method = \ref
00122       direct) or they may be converted to integrals over the
00123       distribution function through an integration by parts (\ref
00124       method = \ref byparts)
00125       \f[
00126       \int_a^b f(k) \frac{d g(k)}{dk} dk = \left.f(k) g(k)\right|_{k=a}^{k=b}
00127       - \int_a^b g(k) \frac{d f(k)}{dk} dk 
00128       \f]
00129       using the distribution function for \f$ f(k) \f$ and 0 and 
00130       \f$ \infty \f$ as the limits, we have
00131       \f[
00132       \frac{g}{2 \pi^2} \int_0^{\infty} \frac{d g(k)}{dk} f dk =
00133       \frac{g}{2 \pi^2} \int_0^{\infty} g(k) f (1-f) \frac{k}{E^{*} T} dk 
00134       \f]
00135       as long as \f$ g(k) \f$ vanishes at \f$ k=0 \f$ .
00136       Rewriting,
00137       \f[
00138       \frac{g}{2 \pi^2} \int_0^{\infty} h(k) f (1-f) dk =
00139       \frac{g}{2 \pi^2} \int_0^{\infty} f \frac{T}{k} 
00140       \left[ h^{\prime} E^{*}-\frac{h E^{*}}{k}+\frac{h k}{E^{*}} \right] dk
00141       \f]
00142       as long as \f$ h(k)/k \f$ vanishes at \f$ k=0 \f$ .
00143 
00144       \b Explicit \b forms
00145 
00146       1) The derivative of the density wrt the chemical potential
00147       \f[
00148       \left(\frac{d n}{d \mu}\right)_T = 
00149       \frac{g}{2 \pi^2} \int_0^{\infty} \frac{k^2}{T} f (1-f) dk
00150       \f]
00151       Using \f$ h(k)=k^2/T \f$ we get
00152       \f[
00153       \left(\frac{d n}{d \mu}\right)_T = 
00154       \frac{g}{2 \pi^2} \int_0^{\infty} 
00155       \left(\frac{k^2+E^{*2}}{E^{*}}\right) f dk
00156       \f]
00157 
00158       2) The derivative of the density wrt the temperature
00159       \f[
00160       \left(\frac{d n}{d T}\right)_{\mu} = 
00161       \frac{g}{2 \pi^2} \int_0^{\infty} \frac{k^2(E^{*}-m-\nu)}{T^2} 
00162       f (1-f) dk
00163       \f]
00164       Using \f$ h(k)=k^2(E^{*}-\nu)/T^2 \f$ we get
00165       \f[
00166       \left(\frac{d n}{d T}\right)_{\mu} = 
00167       \frac{g}{2 \pi^2} \int_0^{\infty} \frac{f}{T} 
00168       \left[2 k^2+E^{*2}-E^{*}\left(\nu+m\right)-
00169       k^2 \left(\frac{\nu+m}{E^{*}}\right)\right] dk
00170       \f]
00171 
00172       3) The derivative of the entropy wrt the chemical potential
00173       \f[
00174       \left(\frac{d s}{d \mu}\right)_T = 
00175       \frac{g}{2 \pi^2} \int_0^{\infty} k^2 f (1-f) 
00176       \frac{(E^{*}-m-\nu)}{T^2} dk
00177       \f]
00178       This verifies the Maxwell relation
00179       \f[
00180       \left(\frac{d s}{d \mu}\right)_T =
00181       \left(\frac{d n}{d T}\right)_{\mu}
00182       \f]
00183 
00184       4) The derivative of the entropy wrt the temperature
00185       \f[
00186       \left(\frac{d s}{d T}\right)_{\mu} = 
00187       \frac{g}{2 \pi^2} \int_0^{\infty} k^2 f (1-f) 
00188       \frac{(E^{*}-m-\nu)^2}{T^3} dk
00189       \f]
00190       Using \f$ h(k)=k^2 (E^{*}-\nu)^2/T^3 \f$ 
00191       \f[
00192       \left(\frac{d s}{d T}\right)_{\mu} = 
00193       \frac{g}{2 \pi^2} \int_0^{\infty} \frac{f(E^{*}-m-\nu)}{E^{*}T^2} 
00194       \left[E^{* 3}+3 E^{*} k^2- (E^{* 2}+k^2)(\nu+m)\right] d k
00195       \f]
00196 
00197       5) The derivative of the density wrt the effective mass
00198       \f[
00199       \left(\frac{d n}{d m^{*}}\right)_{T,\mu} = 
00200       -\frac{g}{2 \pi^2} \int_0^{\infty} 
00201       \frac{k^2 m^{*}}{E^{*} T} f (1-f) dk
00202       \f]
00203       Using \f$ h(k)=-(k^2 m^{*})/(E^{*} T) \f$ we get
00204       \f[
00205       \left(\frac{d n}{d m^{*}}\right)_{T,\mu} = 
00206       -\frac{g}{2 \pi^2} \int_0^{\infty} 
00207       m^{*} f dk
00208       \f]
00209 
00210       The dsdT integration doesn't work well if the system is very
00211       degenerate. When method is byparts, the integral involves a
00212       large cancellation between the regions from \f$ k \in (0,
00213       \mathrm{ulimit/2}) \f$ and \f$ k \in (\mathrm{ulimit/2},
00214       \mathrm{ulimit}) \f$. Switching to method=direct and setting the
00215       lower limit to \f$ \mathrm{llimit} \f$, may help, but recent
00216       testing on this gave negative values for dsdT. For very
00217       degenerate systems, an expansion is probably better than trying
00218       to perform the integration.
00219 
00220       \todo This class will have difficulty with extremely degenerate
00221       or extremely non-degnerate systems.
00222       \todo Create a more intelligent method for dealing with bad 
00223       initial guesses for the chemical potential in calc_density().
00224   */
00225   class sn_fermion : public deriv_fermion {
00226     
00227   public:
00228 
00229     /// Create a fermion with mass \c m and degeneracy \c g
00230     sn_fermion(double m=0.0, double g=0.0);
00231     virtual ~sn_fermion();
00232     
00233     /** \brief The critical degeneracy at which to switch integration 
00234         techniques (default 2.0)
00235     */
00236     double deg_limit;
00237     
00238     /** 
00239         \brief The limit for the Fermi functions (default 20.0)
00240         
00241         sn_fermion will ignore corrections smaller than about
00242         \f$ \exp(-\mathrm{f{l}imit}) \f$ . 
00243     */
00244     double flimit;
00245     
00246     /// Storage for the most recently calculated uncertainties 
00247     deriv_fermion unc;
00248     
00249     /** \name Method of computing derivatives
00250      */
00251     //@{
00252     /// Method (default is \ref byparts)
00253     int method;
00254     /// In the form containing \f$ f(1-f) \f$ .
00255     static const int direct=1;
00256     /// Integrate by parts
00257     static const int byparts=2;
00258     //@}
00259 
00260     /** 
00261         \brief Calculate properties as function of chemical potential
00262     */
00263     virtual int calc_mu(const double temper);
00264 
00265     /** \brief Calculate properties as function of density
00266      */
00267     virtual int calc_density(const double temper);
00268 
00269     /** \brief Calculate properties with antiparticles as function of
00270         chemical potential
00271     */
00272     virtual int pair_mu(const double temper);
00273 
00274     /** \brief Calculate properties with antiparticles as function of
00275         density
00276      */
00277     virtual int pair_density(const double temper);
00278 
00279     /// Calculate effective chemical potential from density
00280     virtual int nu_from_n(const double temper);
00281 
00282     /** 
00283         \brief Set inte objects
00284         
00285         The first integrator is used for non-degenerate integration
00286         and should integrate from 0 to \f$ \infty \f$ (like \ref
00287         gsl_inte_qagiu). The second integrator is for the degenerate
00288         case, and should integrate between two finite values.
00289     */
00290     int set_inte(inte<void *,funct<void *> > &unit, 
00291                         inte<void *,funct<void *> > &udit);
00292 
00293     //    friend class sn_fermion_io_type;
00294     //    friend class aio_tlate<sn_fermion>;
00295 
00296     /** \brief Set the solver for use in calculating the chemical
00297         potential from the density */
00298     int set_density_root(root<void *,funct<void *> > &rp) {
00299       density_root=&rp;
00300       return 0;
00301     }
00302 
00303     /// The default integrator for the non-degenerate regime
00304     gsl_inte_qagiu<void *,funct<void *> > def_nit;
00305 
00306     /// The default integrator for the degenerate regime
00307     gsl_inte_qag<void *,funct<void *> > def_dit;
00308 
00309     /// The default solver for npen_density() and pair_density()
00310     cern_mroot_root<void *,funct<void*> > def_density_root;
00311 
00312     /// Return string denoting type ("sn_fermion")
00313     virtual const char *type() { return "sn_fermion"; };
00314 
00315   protected:
00316 
00317 #ifndef DOXYGENP
00318 
00319     /// The integrator for non-degenerate fermions
00320     inte<void *,funct<void *> > *nit;
00321 
00322     /// The integrator for degenerate fermions
00323     inte<void *,funct<void *> > *dit;
00324 
00325     /// The solver for calc_density() and pair_density()
00326     root<void *,funct<void *> > *density_root;
00327 
00328     /** \name The integrands, as a function of \f$ u=k/T \f$, for 
00329         non-degenerate integrals
00330     */
00331     //@{
00332     double density_fun(double u, void *&pa);
00333     double energy_fun(double u, void *&pa);
00334     double entropy_fun(double u, void *&pa);
00335     double density_T_fun(double k, void *&pa);
00336     double density_mu_fun(double k, void *&pa);
00337     double entropy_T_fun(double k, void *&pa);
00338     double density_ms_fun(double k, void *&pa);
00339     //@}
00340 
00341     /** \name The integrands, as a function of momentum, for the 
00342         degenerate integrals
00343     */
00344     //@{
00345     double deg_density_fun(double u, void *&pa);
00346     double deg_energy_fun(double u, void *&pa);
00347     double deg_entropy_fun(double u, void *&pa);
00348     double deg_density_T_fun(double k, void *&pa);
00349     double deg_density_mu_fun(double k, void *&pa);
00350     double deg_entropy_T_fun(double k, void *&pa);
00351     double deg_density_ms_fun(double k, void *&pa);
00352     //@}
00353 
00354     /** \name The function pointers for the non-degenerate integrals
00355      */
00356     //@{
00357     funct_mfptr_noerr<sn_fermion,void *> *density_fun_f;
00358     funct_mfptr_noerr<sn_fermion,void *> *energy_fun_f;
00359     funct_mfptr_noerr<sn_fermion,void *> *entropy_fun_f;
00360     funct_mfptr_noerr<sn_fermion,void *> *density_mu_fun_f;
00361     funct_mfptr_noerr<sn_fermion,void *> *density_T_fun_f;
00362     funct_mfptr_noerr<sn_fermion,void *> *entropy_T_fun_f;
00363     funct_mfptr_noerr<sn_fermion,void *> *density_ms_fun_f;
00364     //@}
00365 
00366     /** \name The function pointers for the degenerate integrals
00367      */
00368     //@{
00369     funct_mfptr_noerr<sn_fermion,void *> *deg_density_fun_f;
00370     funct_mfptr_noerr<sn_fermion,void *> *deg_energy_fun_f;
00371     funct_mfptr_noerr<sn_fermion,void *> *deg_entropy_fun_f;
00372     funct_mfptr_noerr<sn_fermion,void *> *deg_density_mu_fun_f;
00373     funct_mfptr_noerr<sn_fermion,void *> *deg_density_T_fun_f;
00374     funct_mfptr_noerr<sn_fermion,void *> *deg_entropy_T_fun_f;
00375     funct_mfptr_noerr<sn_fermion,void *> *deg_density_ms_fun_f;
00376     //@}
00377 
00378     /** \brief Solve for the chemical potential from the density 
00379         for calc_density()
00380     */
00381     int solve_fun(double x, double &yy, void *&pa);
00382 
00383     /** \brief Solve for the chemical potential from the density 
00384         for pair_density()
00385     */
00386     int pair_fun(double x, double &yy, void *&pa);
00387 
00388 #endif
00389 
00390   };
00391 
00392   template<> int io_tlate<sn_fermion>::input
00393     (cinput *co, in_file_format *ins, sn_fermion *f);
00394   template<> int io_tlate<sn_fermion>::output
00395     (coutput *co, out_file_format *ins, sn_fermion *f);
00396   template<> const char *io_tlate<sn_fermion>::type();
00397 
00398   typedef io_tlate<sn_fermion> sn_fermion_io_type;
00399 
00400 #ifndef DOXYGENP
00401 }
00402 #endif
00403 
00404 #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