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