All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
fermion_rel.h
Go to the documentation of this file.
1 /*
2  -------------------------------------------------------------------
3 
4  Copyright (C) 2006-2014, Andrew W. Steiner
5 
6  This file is part of O2scl.
7 
8  O2scl is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12 
13  O2scl is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with O2scl. If not, see <http://www.gnu.org/licenses/>.
20 
21  -------------------------------------------------------------------
22 */
23 #ifndef O2SCL_REL_FERMION_H
24 #define O2SCL_REL_FERMION_H
25 
26 /** \file fermion_rel.h
27  \brief File defining \ref o2scl::fermion_rel
28 */
29 
30 #include <string>
31 #include <iostream>
32 #include <fstream>
33 #include <cmath>
34 #include <o2scl/constants.h>
35 #include <o2scl/mroot.h>
36 #include <o2scl/inte.h>
37 #include <o2scl/root_cern.h>
38 #include <o2scl/inte_qagiu_gsl.h>
39 #include <o2scl/inte_qag_gsl.h>
40 #include <o2scl/fermion_eff.h>
41 #include <o2scl/shared_ptr.h>
42 
43 #ifndef DOXYGEN_NO_O2NS
44 namespace o2scl {
45 #endif
46 
47  /** \brief Equation of state for a relativistic fermion
48 
49  This class computes the thermodynamics of a relativistic fermion
50  either as a function of the density or the chemical potential.
51  It employs direct integration, using two different integrators
52  for the degenerate and non-degenerate regimes. The default
53  integrators are inte_qag_gsl (for degenerate fermions) and
54  inte_qagiu_gsl (for non-degenerate fermions). For the functions
55  calc_mu() and calc_density(), if the temperature argument is
56  less than or equal to zero, the functions \ref
57  fermion_zerot::calc_mu_zerot() and \ref
58  fermion_zerot::calc_density_zerot() will be used to compute the
59  result.
60 
61  \hline
62  <b>Degeneracy parameter:</b>
63 
64  Define the degeneracy parameter
65  \f[
66  \psi=(\nu-m^{*})/T
67  \f]
68  where \f$ \nu \f$ is the effective chemical potential (including
69  the rest mass) and \f$
70  m^{*} \f$ is the effective mass. For \f$ \psi \f$ smaller than
71  \ref min_psi, the non-degenerate expansion in \ref
72  fermion_eval_thermo::calc_mu_ndeg() is attempted first. If that
73  fails, then integration is used. For \f$ \psi \f$ greater than
74  \ref deg_limit (degenerate regime), a finite interval integrator
75  is used and for \f$ \psi \f$ less than \ref deg_limit
76  (non-degenerate regime), an integrator over the interval from
77  \f$ [0,\infty) \f$ is used. In the case where \ref
78  part::inc_rest_mass is false, the degeneracy parameter is
79  \f[
80  \psi=(\nu+m-m^{*})/T
81  \f]
82 
83  <b>Integration limits:</b>
84 
85  The upper limit on the degenerate integration is given by
86  \f[
87  \mathrm{upper~limit} = \sqrt{{\cal L}^2-m^{*,2}}
88  \f]
89  where \f$ {\cal L}\equiv u T+\nu \f$ and \f$ u \f$ is \ref
90  fermion_rel::upper_limit_fac . In the case where \ref
91  part::inc_rest_mass is false, the result is
92  \f[
93  \mathrm{upper~limit} = \sqrt{(m+{\cal L})^2-m^{*2}}
94  \f]
95 
96  The entropy is only significant at the Fermi surface, thus
97  in the degenerate case, the lower limit of the entropy
98  integral can be given be determined by the value of \f$ k \f$
99  which solves
100  \f[
101  - u = \frac{\sqrt{k^2+m^{* 2}}-\nu}{T}
102  \f]
103  The solution is
104  \f[
105  \mathrm{lower~limit} = \sqrt{(-u T+{\nu})^2-m^{*,2}}
106  \f]
107  but this solution is only valid if \f$ (m^{*}-\nu)/T < -u \f$.
108  In the case where part::inc_rest_mass is false, the result is
109  \f[
110  \mathrm{lower~limit} = \sqrt{(-u T + m +\nu)^2-m^{*,2}}
111  \f]
112  which is valid if \f$ (m^{*}-\nu - m)/T < -u \f$.
113 
114  <b>Entropy integrand:</b>
115 
116  In the degenerate regime, the entropy integrand
117  \f[
118  - k^2 \left[ f \log f + \left(1-f\right) \log
119  \left(1-f \right) \right]
120  \f]
121  where \f$ f \f$ is the fermionic distribution function can lose
122  precision when \f$ (E^{*} - \nu)/T \f$ is negative and
123  sufficiently large in absolute magnitude. Thus when \f$ (E^{*} -
124  \nu)/T < S \f$ where \f$ S \f$ is stored in \ref deg_entropy_fac
125  (default is -30), the integrand is written as
126  \f[
127  -k^2 \left( E/T-\nu/T \right) e^{E/T-\nu/T} \, .
128  \f]
129  If \f$ (E - \nu)/T < S \f$ is less than -1 times \ref exp_limit
130  (e.g. less than -200), then the entropy integrand is assumed
131  to be zero.
132 
133  <b>Non-degenerate integrands:</b>
134 
135  \comment
136  It's not at all clear that this dimensionless form is more
137  accurate than other potential alternatives. On the other hand,
138  it seems that the uncertainties in the integrations are larger
139  than the errors made by the integrand at present.
140  \endcomment
141  The integrands in the non-degenerate regime are written
142  in a dimensionless form, by defining \f$ u \f$ with
143  the relation
144  \f$ p = \sqrt{\left(T u + m^{*}\right)^2-m^{* 2}} \f$,
145  \f$ y \equiv \nu/ T \f$, and
146  \f$ \mathrm{mx} \equiv m^{*}/T \f$.
147  The density integrand is
148  \f[
149  \left(\mathrm{mx}+u\right) \sqrt{u^2+2 (\mathrm{mx}) u}
150  \left(\frac{e^{y}}{e^{\mathrm{mx}+u}+e^{y}}\right) \, ,
151  \f]
152  the energy integrand is
153  \f[
154  \left(\mathrm{mx}+u\right)^2 \sqrt{u^2+2 (\mathrm{mx}) u}
155  \left(\frac{e^{y}}{e^{\mathrm{mx}+u}+e^{y}}\right) \, ,
156  \f]
157  and the entropy integrand is
158  \f[
159  \left(\mathrm{mx}+u\right) \sqrt{u^2+2 (\mathrm{mx}) u}
160  \left(t_1+t_2\right) \, ,
161  \f]
162  where
163  \f{eqnarray*}
164  t_1 &=& \log \left(1+e^{y-\mathrm{mx}-u}\right)/
165  \left(1+e^{y-\mathrm{mx}-u}\right) \nonumber \\
166  t_2 &=& \log \left(1+e^{\mathrm{mx}+u-y}\right)/
167  \left(1+e^{\mathrm{mx}+u-y}\right) \, .
168  \f}
169 
170  \hline
171  <b>Accuracy:</b>
172 
173  The default settings for for this class give an accuracy of at
174  least 1 part in \f$ 10^6 \f$ (and frequently better than this).
175 
176  When the integrators provide numerical uncertainties, these
177  uncertainties are stored in \ref unc. In the case of
178  calc_density() and pair_density(), the uncertainty from the
179  numerical accuracy of the solver is not included. (There is also
180  a relatively small inaccuracy due to the mathematical evaluation
181  of the integrands which is not included in \ref unc.)
182 
183  One can improve the accuracy to within 1 part in \f$ 10^{10} \f$
184  using
185  \code
186  fermion_rel rf(1.0,2.0);
187  rf.upper_limit_fac=40.0;
188  rf.dit->tol_abs=1.0e-13;
189  rf.dit->tol_rel=1.0e-13;
190  rf.nit->tol_abs=1.0e-13;
191  rf.nit->tol_rel=1.0e-13;
192  rf.density_root->tol_rel=1.0e-10;
193  \endcode
194  which decreases the both the relative and absolute tolerances
195  for both the degenerate and non-degenerate integrators and
196  improves the accuracy of the solver which determines the
197  chemical potential from the density. Of course if these
198  tolerances are too small, the calculation may fail.
199 
200  \hline
201  <b>Todos:</b>
202 
203  \future The expressions which appear in in the integrand
204  functions density_fun(), etc. could likely be improved,
205  especially in the case where \ref o2scl::part::inc_rest_mass is
206  <tt>false</tt>. There should not be a need to check if
207  <tt>ret</tt> is finite.
208 
209  \future It appears this class doesn't compute the uncertainty in
210  the chemical potential or density with calc_density(). This
211  could be fixed.
212 
213  \future I'd like to change the lower limit on the entropy
214  integration, but the value in the code at the moment (stored
215  in <tt>ll</tt>) makes bm_part2.cpp worse.
216 
217  \future The function pair_mu() should set the antiparticle
218  integrators as done in fermion_deriv_rel.
219  */
221 
222  public:
223 
224  /// \name Numerical parameters
225  //@{
226  /** \brief If true, call the error handler when convergence
227  fails (default true)
228  */
230 
231  /** \brief The smallest value of \f$ (\mu-m)/T \f$ for which
232  integration is used
233  */
234  double min_psi;
235 
236  /** \brief The critical degeneracy at which to switch integration
237  techniques (default 2)
238  */
239  double deg_limit;
240 
241  /** \brief The limit for exponentials to ensure integrals are finite
242  (default 200)
243  */
244  double exp_limit;
245 
246  /// The factor for the degenerate upper limits (default 20)
248 
249  /// A factor for the degenerate entropy integration (default 30)
251  //@}
252 
253  /// Storage for the uncertainty
255 
256  /// Create a fermion with mass \c m and degeneracy \c g
257  fermion_rel();
258 
259  virtual ~fermion_rel();
260 
261  /** \brief Calculate properties as function of chemical potential
262  */
263  virtual void calc_mu(fermion &f, double temper);
264 
265  /** \brief Calculate properties as function of density
266 
267  This function uses the current value of \c nu (or \c mu if the
268  particle is non interacting) for an initial guess to solve for
269  the chemical potential. If this guess is too small, then this
270  function may fail.
271  */
272  virtual int calc_density(fermion &f, double temper);
273 
274  /** \brief Calculate properties with antiparticles as function of
275  chemical potential
276  */
277  virtual void pair_mu(fermion &f, double temper);
278 
279  /** \brief Calculate properties with antiparticles as function of
280  density
281  */
282  virtual int pair_density(fermion &f, double temper);
283 
284  /** \brief Calculate effective chemical potential from density
285 
286  \future This function might be improved by generating a
287  bracket for a bracketing solver, rather than \ref
288  o2scl::root_cern which is the default for \ref
289  o2scl::fermion_rel::density_root.
290  */
291  virtual int nu_from_n(fermion &f, double temper);
292 
293  /// The non-degenerate integrator
295 
296  /// The degenerate integrator
298 
299  /// The solver for calc_density()
301 
302  /// Return string denoting type ("fermion_rel")
303  virtual const char *type() { return "fermion_rel"; }
304 
305  protected:
306 
307 #ifndef DOXYGEN_INTERNAL
308 
309  /// The integrand for the density for non-degenerate fermions
310  double density_fun(double u, fermion &f, double T);
311 
312  /// The integrand for the energy density for non-degenerate fermions
313  double energy_fun(double u, fermion &f, double T);
314 
315  /// The integrand for the entropy density for non-degenerate fermions
316  double entropy_fun(double u, fermion &f, double T);
317 
318  /// The integrand for the density for degenerate fermions
319  double deg_density_fun(double u, fermion &f, double T);
320 
321  /// The integrand for the energy density for degenerate fermions
322  double deg_energy_fun(double u, fermion &f, double T);
323 
324  /// The integrand for the entropy density for degenerate fermions
325  double deg_entropy_fun(double u, fermion &f, double T);
326 
327  /// Solve for the chemical potential given the density
328  double solve_fun(double x, fermion &f, double T);
329 
330  /// Solve for the chemical potential given the density with antiparticles
331  double pair_fun(double x, fermion &f, double T);
332 
333 #endif
334 
335  };
336 
337 #ifndef DOXYGEN_NO_O2NS
338 }
339 #endif
340 
341 #endif
double upper_limit_fac
The factor for the degenerate upper limits (default 20)
Definition: fermion_rel.h:247
bool err_nonconv
If true, call the error handler when convergence fails (default true)
Definition: fermion_rel.h:229
double deg_entropy_fac
A factor for the degenerate entropy integration (default 30)
Definition: fermion_rel.h:250
double exp_limit
The limit for exponentials to ensure integrals are finite (default 200)
Definition: fermion_rel.h:244
double min_psi
The smallest value of for which integration is used.
Definition: fermion_rel.h:234
Fermion class.
Definition: fermion.h:52
virtual void pair_mu(fermion &f, double temper)
Calculate properties with antiparticles as function of chemical potential.
Fermion with finite-temperature thermodynamics [abstract base].
Definition: fermion.h:162
virtual const char * type()
Return string denoting type ("fermion_rel")
Definition: fermion_rel.h:303
o2_shared_ptr< inte<> >::type dit
The degenerate integrator.
Definition: fermion_rel.h:297
o2_shared_ptr< root<> >::type density_root
The solver for calc_density()
Definition: fermion_rel.h:300
double entropy_fun(double u, fermion &f, double T)
The integrand for the entropy density for non-degenerate fermions.
fermion unc
Storage for the uncertainty.
Definition: fermion_rel.h:254
double deg_limit
The critical degeneracy at which to switch integration techniques (default 2)
Definition: fermion_rel.h:239
Equation of state for a relativistic fermion.
Definition: fermion_rel.h:220
virtual int nu_from_n(fermion &f, double temper)
Calculate effective chemical potential from density.
double deg_density_fun(double u, fermion &f, double T)
The integrand for the density for degenerate fermions.
double solve_fun(double x, fermion &f, double T)
Solve for the chemical potential given the density.
double deg_entropy_fun(double u, fermion &f, double T)
The integrand for the entropy density for degenerate fermions.
double energy_fun(double u, fermion &f, double T)
The integrand for the energy density for non-degenerate fermions.
virtual int calc_density(fermion &f, double temper)
Calculate properties as function of density.
double pair_fun(double x, fermion &f, double T)
Solve for the chemical potential given the density with antiparticles.
fermion_rel()
Create a fermion with mass m and degeneracy g.
virtual void calc_mu(fermion &f, double temper)
Calculate properties as function of chemical potential.
double deg_energy_fun(double u, fermion &f, double T)
The integrand for the energy density for degenerate fermions.
virtual int pair_density(fermion &f, double temper)
Calculate properties with antiparticles as function of density.
double density_fun(double u, fermion &f, double T)
The integrand for the density for non-degenerate fermions.
o2_shared_ptr< inte<> >::type nit
The non-degenerate integrator.
Definition: fermion_rel.h:294

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).
Hosted at Get Object-oriented Scientific Computing
Lib at SourceForge.net. Fast, secure and Free Open Source software
downloads..