Particles and Nuclei Sub-Library: Version 0.910
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_FERMION_H
00024 #define O2SCL_FERMION_H
00025 
00026 #include <string>
00027 #include <iostream>
00028 #include <fstream>
00029 #include <cmath>
00030 
00031 // For gsl_sf_fermi_dirac_int()
00032 #include <gsl/gsl_specfunc.h>
00033 
00034 #include <o2scl/constants.h>
00035 #include <o2scl/funct.h>
00036 #include <o2scl/root.h>
00037 #include <o2scl/cern_mroot_root.h>
00038 #include <o2scl/part.h>
00039 
00040 #ifndef DOXYGENP
00041 namespace o2scl {
00042 #endif
00043 
00044   /** \brief Fermion class
00045 
00046       This class adds two member data variables, \ref kf and \ref
00047       del, for the Fermi momentum and the gap, respectively.
00048   */
00049   class fermion : public part {
00050 
00051   public:
00052 
00053     /// Fermi momentum
00054     double kf;
00055     /// Gap
00056     double del;
00057 
00058     /// Create a fermion with mass \c mass and degeneracy \c dof.
00059     fermion(double mass=0, double dof=0);
00060 
00061     virtual ~fermion() {
00062     }
00063 
00064     /// Return string denoting type ("fermion")
00065     virtual const char *type() { return "fermion"; }
00066 
00067   };
00068 
00069   /** \brief
00070 
00071       This is a base class for the computation of fermionic statistics
00072       at zero temperature. The more general case of finite temperature
00073       is taken care of by \ref fermion_eval_thermo objects. The primary
00074       functions are calc_mu_zerot() and calc_density_zerot() which
00075       compute all the thermodynamic quantities as a function of the
00076       chemical potential, or the density, respectively.
00077       
00078       \future Use hypot() and other more accurate functions for the
00079       analytic expressions for the zero temperature integrals. [Progress
00080       has been made, but there are probably other functions which may
00081       break down for small but finite masses and temperatures]
00082   */
00083   class fermion_zerot {
00084 
00085   public:
00086 
00087     fermion_zerot() {
00088     };
00089 
00090     virtual ~fermion_zerot() {
00091     }
00092 
00093     /// \name Zero-temperature fermions 
00094     //@{
00095     /** \brief Calculate the Fermi momentum from the density
00096         
00097         Uses the relation \f$ k_F = ( 6 \pi^2 n /g )^{1/3} \f$
00098     */
00099     void kf_from_density(fermion &f); 
00100 
00101     /** \brief Energy density at T=0 from \ref fermion::kf and \ref part::ms
00102 
00103         Calculates the integral 
00104         \f[
00105         \varepsilon = \frac{g}{2 \pi^2} \int_0^{k_F} k^2 
00106         \sqrt{k^2+m^{* 2}} d k
00107         \f]
00108     */
00109     void energy_density_zerot(fermion &f); 
00110 
00111     /** \brief Pressure at T=0 from \ref fermion::kf and \ref part::ms
00112 
00113         Calculates the integral 
00114         \f[
00115         P=\frac{g}{6 \pi^2} \int_0^{k_F} \frac{k^4}{\sqrt{k^2+m^{* 2}}} d k
00116         \f]
00117     */
00118     void pressure_zerot(fermion &f); 
00119 
00120     /** \brief Zero temperature fermions from \ref part::nu and \ref part::ms
00121         
00122         This function always returns \c gsl_success.
00123     */
00124     virtual void calc_mu_zerot(fermion &f);
00125 
00126     /** \brief Zero temperature fermions from \ref part::n and \ref part::ms
00127 
00128         This function always returns \c gsl_success.
00129     */
00130     virtual void calc_density_zerot(fermion &f);
00131     //@}
00132 
00133   };
00134   
00135   /** \brief Fermion with finite-temperature thermodynamics
00136       [abstract base]
00137 
00138       This is an abstract base for the computation of
00139       finite-temperature fermionic statistics. Different children
00140       (e.g. \ref eff_fermion and \ref rel_fermion) use different
00141       techniques to computing the momentum integrations.
00142 
00143       Because massless fermions at finite temperature are much
00144       simpler, there are separate member functions included in this
00145       class to handle them. The functions massless_calc_density() and
00146       massless_calc_mu() compute the thermodynamics of massless
00147       fermions at finite temperature given the density or the chemical
00148       potentials. The functions massless_pair_density() and
00149       massless_pair_mu() perform the same task, but automatically
00150       include antiparticles.
00151 
00152       The function massless_calc_density() uses a \ref root object to
00153       solve for the chemical potential as a function of the density.
00154       The default is an object of type cern_mroot_root. The function
00155       massless_pair_density() does not need to use the \ref root
00156       object because of the simplification afforded by the inclusion
00157       of antiparticles.
00158 
00159       \future Create a Chebyshev approximation for inverting the 
00160       the Fermi functions for massless_calc_density() functions?
00161       
00162       \htmlonly
00163       This Mathematica notebook contains the derivations of related
00164       series expansions and some algebra for the massless_pair()
00165       functions.
00166       <a href="../extras/fermion.nb">
00167       fermion.nb</a>, and
00168       <a href="../extras/fermion.pdf">
00169       fermion.pdf</a>.
00170       \endhtmlonly
00171       \latexonly
00172       This Mathematica notebook contains the derivations of related
00173       series expansions and some algebra for the massless\_pair()
00174       functions.
00175       \begin{verbatim}
00176       doc/o2scl/extras/fermion.nb
00177       doc/o2scl/extras/fermion.pdf
00178       \end{verbatim}
00179       \endlatexonly
00180   */
00181   class fermion_eval_thermo : public fermion_zerot {
00182 
00183   public:
00184 
00185     fermion_eval_thermo();
00186 
00187     virtual ~fermion_eval_thermo() {
00188     }
00189 
00190     /** \brief Calculate properties as function of chemical potential
00191      */
00192     virtual void calc_mu(fermion &f, double temper)=0;
00193 
00194     /** \brief Calculate properties as function of density
00195      */
00196     virtual void calc_density(fermion &f, double temper)=0;
00197 
00198     /** \brief Calculate properties with antiparticles as function of
00199         chemical potential
00200     */
00201     virtual void pair_mu(fermion &f, double temper)=0;
00202 
00203     /** \brief Calculate properties with antiparticles as function of
00204         density
00205     */
00206     virtual void pair_density(fermion &f, double temper)=0;
00207 
00208     /// \name Massless fermions
00209     //@{
00210     /// Finite temperature massless fermions
00211     virtual void massless_calc_mu(fermion &f, double temper);
00212 
00213     /// Finite temperature massless fermions
00214     virtual void massless_calc_density(fermion &f, double temper);
00215 
00216     /** \brief Finite temperature massless fermions and antifermions 
00217      */
00218     virtual void massless_pair_mu(fermion &f, double temper);
00219 
00220     /** \brief Finite temperature massless fermions and antifermions 
00221 
00222         In the cases \f$ n^3 >> T \f$ and \f$ T >> n^3 \f$ ,
00223         expansions are used instead of the exact formulas to avoid
00224         loss of precision.
00225 
00226         In particular, using the parameter
00227         \f[
00228         \alpha = \frac{g^2 \pi^2 T^6}{243 n^2}
00229         \f]
00230         and defining the expression
00231         \f[
00232         \mathrm{cbt} = \alpha^{-1/6} \left( -1 + \sqrt{1+\alpha}\right)^{1/3}
00233         \f]
00234         we can write the chemical potential as
00235         \f[
00236         \mu = \frac{\pi T}{\sqrt{3}} \left(\frac{1}{\mathrm{cbt}} -
00237         \mathrm{cbt} \right)
00238         \f]
00239         
00240         These expressions, however, do not work well when \f$ \alpha
00241         \f$ is very large or very small, so series expansions are
00242         used whenever \f$ \alpha > 10^{4} \f$ or 
00243         \f$ \alpha < 3 \times 10^{-4} \f$. For small \f$ \alpha \f$, 
00244         \f[
00245         \left(\frac{1}{\mathrm{cbt}} -
00246         \mathrm{cbt} \right) \approx
00247         \frac{2^{1/3}}{\alpha^{1/6}} - 
00248         \frac{\alpha^{1/6}}{2^{1/3}} +
00249         \frac{\alpha^{5/6}}{6~2^{2/3}} +
00250         \frac{\alpha^{7/6}}{12~2^{1/3}} -
00251         \frac{\alpha^{11/6}}{18~2^{2/3}} -
00252         \frac{5 \alpha^{13/6}}{144~2^{1/3}} +
00253         \frac{77 \alpha^{17/6}}{2592~2^{2/3}}
00254         \f]
00255         and for large \f$ \alpha \f$, 
00256         \f[
00257         \left(\frac{1}{\mathrm{cbt}} -
00258         \mathrm{cbt} \right) \approx
00259         \frac{2}{3} \sqrt{\frac{1}{\alpha}} - 
00260         \frac{8}{81} \left(\frac{1}{\alpha}\right)^{3/2} +
00261         \frac{32}{729} \left(\frac{1}{\alpha}\right)^{5/2}
00262         \f]
00263 
00264         This approach works to within about 1 \part in \f$ 10^{12} \f$,
00265         and is tested in <tt>fermion_ts.cpp</tt>.
00266         
00267         \future This could be improved by including more terms
00268         in the expansions.
00269     */
00270     virtual void massless_pair_density(fermion &f, double temper);
00271     //@}
00272     
00273     /** \brief Set the solver for use in massless_calc_density() */ 
00274     void set_massless_root(root<funct> &rp) {
00275       massless_root=&rp;
00276       return;
00277     }
00278 
00279     /** \brief The default solver for massless_calc_density()
00280         
00281         We default to a solver of type cern_mroot_root here since we
00282         don't have a bracket or a derivative.
00283     */
00284     cern_mroot_root<funct> def_massless_root;
00285 
00286     /// Return string denoting type ("fermion_eval_thermo")
00287     virtual const char *type() { return "fermion_eval_thermo"; }
00288 
00289     /** \brief Test the thermodynamics of calc_density() and 
00290         calc_mu()
00291 
00292         This compares the approximation to the exact results over a
00293         grid with \f$ T = \left\{10^{-2},1,10^{2}\right\} \f$, \f$
00294         \log_{10} (m/T) = \left\{ -3,-2,-1,0,1,2,3\right\} \f$, and
00295         \f$ \log_{10} \psi = \left\{ -3,-2,-1,0,1\right\} \f$, where
00296         \f$ \psi \equiv \left(\mu-m\right)/T \f$ using
00297         calc_density() and calc_mu(), with both inc_rest_mass
00298         taking both values <tt>true</tt> and <tt>false</tt>.
00299 
00300         The <tt>verbose</tt> parameter controls the amount of
00301         output, and \c fname is the filename for the file
00302         <tt>fermion_cal.dat</tt>.
00303 
00304         \future Also calibrate massless fermions?
00305         \future Convert into separate class?
00306     */
00307     virtual double calibrate(fermion &f, int verbose=0, std::string fname="");
00308 
00309 #ifndef DOXYGENP
00310 
00311   protected:
00312     
00313     /// A pointer to the solver for massless fermions
00314     root<funct> *massless_root;
00315     
00316     /// The function to solve for massless fermions
00317     class massless_fun : public funct {
00318       
00319     protected:
00320       
00321       fermion &f_;
00322       double temper_;
00323       
00324     public:
00325       
00326     massless_fun(fermion &f, double temper) : f_(f), temper_(temper) {
00327       }
00328       
00329       /** \brief Solve for the density for 
00330           \ref fermion_eval_thermo::massless_calc_density()
00331       */
00332       double operator()(double x);
00333 
00334     };
00335 
00336 #endif
00337     
00338   };
00339 
00340 #ifndef DOXYGENP
00341 }
00342 #endif
00343 
00344 #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.