All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
fermion.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_FERMION_H
24 #define O2SCL_FERMION_H
25 
26 /** \file fermion.h
27  \brief File defining \ref o2scl::fermion
28 */
29 #include <string>
30 #include <iostream>
31 #include <fstream>
32 #include <cmath>
33 
34 // For gsl_sf_fermi_dirac_int()
35 #include <gsl/gsl_specfunc.h>
36 
37 #include <o2scl/constants.h>
38 #include <o2scl/funct.h>
39 #include <o2scl/root.h>
40 #include <o2scl/root_cern.h>
41 #include <o2scl/part.h>
42 
43 #ifndef DOXYGEN_NO_O2NS
44 namespace o2scl {
45 #endif
46 
47  /** \brief Fermion class
48 
49  This class adds two member data variables, \ref kf and \ref
50  del, for the Fermi momentum and the gap, respectively.
51  */
52  class fermion : public part {
53 
54  public:
55 
56  /// Fermi momentum
57  double kf;
58  /// Gap
59  double del;
60 
61  /// Create a fermion with mass \c mass and degeneracy \c dof.
62  fermion(double mass=0, double dof=0);
63 
64  virtual ~fermion() {
65  }
66 
67  /// Return string denoting type ("fermion")
68  virtual const char *type() { return "fermion"; }
69 
70  };
71 
72  /** \brief Fermion properties at zero temperature
73 
74  This is a base class for the computation of fermionic statistics
75  at zero temperature. The more general case of finite temperature
76  is taken care of by \ref fermion_eval_thermo objects. The
77  primary functions are calc_mu_zerot() and calc_density_zerot()
78  which compute all the thermodynamic quantities as a function of
79  the chemical potential, or the density, respectively.
80 
81  \future Use hypot() and other more accurate functions for the
82  analytic expressions for the zero temperature integrals. [Progress
83  has been made, but there are probably other functions which may
84  break down for small but finite masses and temperatures]
85  */
86  class fermion_zerot {
87 
88  public:
89 
90  fermion_zerot() {
91  };
92 
93  virtual ~fermion_zerot() {
94  }
95 
96  /// \name Zero-temperature fermions
97  //@{
98  /** \brief Calculate the Fermi momentum from the density
99 
100  Uses the relation \f$ k_F = ( 6 \pi^2 n /g )^{1/3} \f$
101  */
102  void kf_from_density(fermion &f);
103 
104  /** \brief Energy density at T=0 from \ref fermion::kf and \ref part::ms
105 
106  Calculates the integral
107  \f[
108  \varepsilon = \frac{g}{2 \pi^2} \int_0^{k_F} k^2
109  \sqrt{k^2+m^{* 2}} d k
110  \f]
111  */
112  void energy_density_zerot(fermion &f);
113 
114  /** \brief Pressure at T=0 from \ref fermion::kf and \ref part::ms
115 
116  Calculates the integral
117  \f[
118  P=\frac{g}{6 \pi^2} \int_0^{k_F} \frac{k^4}{\sqrt{k^2+m^{* 2}}} d k
119  \f]
120  */
121  void pressure_zerot(fermion &f);
122 
123  /** \brief Zero temperature fermions from \ref part::mu or
124  \ref part::nu and \ref part::ms
125  */
126  virtual void calc_mu_zerot(fermion &f);
127 
128  /** \brief Zero temperature fermions from \ref part::n and \ref part::ms
129  */
130  virtual void calc_density_zerot(fermion &f);
131  //@}
132 
133  };
134 
135  /** \brief Fermion with finite-temperature thermodynamics
136  [abstract base]
137 
138  This is an abstract base for the computation of
139  finite-temperature fermionic statistics. Different children
140  (e.g. \ref fermion_eff and \ref fermion_rel) use different
141  techniques to computing the momentum integrations.
142 
143  Because massless fermions at finite temperature are much
144  simpler, there are separate member functions included in this
145  class to handle them. The functions massless_calc_density() and
146  massless_calc_mu() compute the thermodynamics of massless
147  fermions at finite temperature given the density or the chemical
148  potentials. The functions massless_pair_density() and
149  massless_pair_mu() perform the same task, but automatically
150  include antiparticles.
151 
152  The function massless_calc_density() uses a \ref root object to
153  solve for the chemical potential as a function of the density.
154  The default is an object of type root_cern. The function
155  massless_pair_density() does not need to use the \ref root
156  object because of the simplification afforded by the inclusion
157  of antiparticles.
158 
159  \future Create a Chebyshev approximation for inverting the
160  the Fermi functions for massless_calc_density() functions?
161  */
163 
164  public:
165 
167 
168  virtual ~fermion_eval_thermo() {
169  }
170 
171  /** \brief Non-degenerate expansion for fermions
172 
173  Attempts to evaulate thermodynamics of a non-degenerate
174  fermion. If the result is accurate to within the requested
175  precision, this function returns <tt>true</tt>, and otherwise
176  this function returns <tt>false</tt> and the values in stored
177  in the <tt>pr</tt>, <tt>n</tt>, <tt>en</tt>, and <tt>ed</tt>
178  field are meaningless.
179 
180  If \f$ \mu \f$ is negative and sufficiently far from zero,
181  then the thermodynamic quantities are smaller than the smallest
182  representable double-precision number. In this case,
183  this function will return <tt>true</tt> and report all
184  quantities as zero.
185 
186  Defining \f$ \psi \equiv (\mu-m)/T \f$, \f$ t \equiv T/m \f$,
187  and \f$ d \equiv g~m^4/(2 \pi^2) \f$ the pressure
188  in the non-degenerate limit (\f$ \psi \rightarrow - \infty \f$)
189  is (\ref Johns96)
190  \f[
191  P = d \sum_{n=1}^{\infty} P_n
192  \f]
193  where
194  \f[
195  P_n \equiv \left(-1\right)^{n+1} \left(\frac{t^2}{n^2}\right)
196  e^{n \left(\psi+1/t\right)} K_2 \left( \frac{n}{t} \right)
197  \f]
198  The density is then
199  \f[
200  n = d \sum_{n=1}^{\infty} \frac{n P_n}{T}
201  \f]
202  and the entropy density is
203  \f[
204  s = \frac{d}{m} \sum_{n=1}^{\infty} \left\{ \frac{2 P_n}{t}
205  -\frac{n P_n}{t^2}+
206  \frac{\left(-1\right)^{n+1}}{2 n}
207  e^{n \left(\psi+1/t\right)} \left[ K_1 \left( \frac{n}{t}
208  \right)+K_3 \left( \frac{n}{t} \right) \right]
209  \right\}
210  \f]
211 
212  This function is accurate over a wide range of conditions
213  when \f$ \psi < -4 \f$.
214 
215  The ratio of the nth term to the first term in the pressure
216  series is
217  \f[
218  R_n \equiv \frac{P_{n}}{P_{1}} = \frac{(-1)^{n+1}
219  e^{(n-1)(\psi+1/t)} K_2(n/t) }{n^2 K_2(1/t)}
220  \f]
221  This function currently uses 20 terms in the series and
222  immediately returns <tt>false</tt> if \f$ |R_{20}| \f$
223  is greater than <tt>prec</tt>
224 
225  In the nondegenerate and nonrelativistic (\f$ t \rightarrow 0
226  \f$) limit, the argument to the Bessel functions and the
227  exponential becomes too large. In this case, it's better to
228  use the expansions, e.g. for \f$ x \equiv n/t \rightarrow
229  \infty \f$,
230  \f[
231  \sqrt{\frac{2 x}{\pi}} e^{x} K_2(x) \approx
232  1 + \frac{3}{8 x} - \frac{15}{128 x^2} + ...
233  \f]
234  The current code currently goes up to \f$ x^{-12} \f$ in the
235  expansion, which is enough for the default precision of \f$
236  10^{-18} \f$ since \f$ (20/700)^{12} \sim 10^{-19} \f$.
237  */
238  virtual bool calc_mu_ndeg(fermion &f, double temper,
239  double prec=1.0e-18);
240 
241  /** \brief Degenerate expansion for fermions
242 
243  Attempts to evaulate thermodynamics of a degenerate fermion.
244  If the result is accurate to within the requested precision,
245  this function returns <tt>true</tt>, and otherwise this
246  function returns <tt>false</tt> and the values in stored in
247  the <tt>pr</tt>, <tt>n</tt>, <tt>en</tt>, and <tt>ed</tt>
248  field are meaningless.
249 
250  The pressure, density, and energy density, should be accurate
251  to the requested precision, but the first term in the series
252  expansion for the entropy is zero, so the entropy is one order
253  lower in accuracy.
254 
255  \future Make a function like this for dndm, dsdT, etc.
256  for fermion_deriv .
257  */
258  virtual bool calc_mu_deg(fermion &f, double temper,
259  double prec=1.0e-18);
260 
261  /** \brief Calculate properties as function of chemical potential
262  */
263  virtual void calc_mu(fermion &f, double temper)=0;
264 
265  /** \brief Calculate properties as function of density
266 
267  \note This function returns an integer value, in contrast to
268  \ref calc_mu(), because of the potential for non-convergence.
269  */
270  virtual int calc_density(fermion &f, double temper)=0;
271 
272  /** \brief Calculate properties with antiparticles as function of
273  chemical potential
274  */
275  virtual void pair_mu(fermion &f, double temper)=0;
276 
277  /** \brief Calculate properties with antiparticles as function of
278  density
279 
280  \note This function returns an integer value, in contrast to
281  \ref pair_mu(), because of the potential for non-convergence.
282  */
283  virtual int pair_density(fermion &f, double temper)=0;
284 
285  /// \name Massless fermions
286  //@{
287  /// Finite temperature massless fermions
288  virtual void massless_calc_mu(fermion &f, double temper);
289 
290  /// Finite temperature massless fermions
291  virtual void massless_calc_density(fermion &f, double temper);
292 
293  /** \brief Finite temperature massless fermions and antifermions
294  */
295  virtual void massless_pair_mu(fermion &f, double temper);
296 
297  /** \brief Finite temperature massless fermions and antifermions
298 
299  In the cases \f$ n^3 \gg T \f$ and \f$ T \gg n^3 \f$ ,
300  expansions are used instead of the exact formulas to avoid
301  loss of precision.
302 
303  In particular, using the parameter
304  \f[
305  \alpha = \frac{g^2 \pi^2 T^6}{243 n^2}
306  \f]
307  and defining the expression
308  \f[
309  \mathrm{cbt} = \alpha^{-1/6} \left( -1 + \sqrt{1+\alpha}\right)^{1/3}
310  \f]
311  we can write the chemical potential as
312  \f[
313  \mu = \frac{\pi T}{\sqrt{3}} \left(\frac{1}{\mathrm{cbt}} -
314  \mathrm{cbt} \right)
315  \f]
316 
317  These expressions, however, do not work well when \f$ \alpha
318  \f$ is very large or very small, so series expansions are
319  used whenever \f$ \alpha > 10^{4} \f$ or
320  \f$ \alpha < 3 \times 10^{-4} \f$. For small \f$ \alpha \f$,
321  \f[
322  \left(\frac{1}{\mathrm{cbt}} -
323  \mathrm{cbt} \right) \approx
324  \frac{2^{1/3}}{\alpha^{1/6}} -
325  \frac{\alpha^{1/6}}{2^{1/3}} +
326  \frac{\alpha^{5/6}}{6{\cdot}2^{2/3}} +
327  \frac{\alpha^{7/6}}{12{\cdot}2^{1/3}} -
328  \frac{\alpha^{11/6}}{18{\cdot}2^{2/3}} -
329  \frac{5 \alpha^{13/6}}{144{\cdot}2^{1/3}} +
330  \frac{77 \alpha^{17/6}}{2592{\cdot}2^{2/3}}
331  \f]
332  and for large \f$ \alpha \f$,
333  \f[
334  \left(\frac{1}{\mathrm{cbt}} -
335  \mathrm{cbt} \right) \approx
336  \frac{2}{3} \sqrt{\frac{1}{\alpha}} -
337  \frac{8}{81} \left(\frac{1}{\alpha}\right)^{3/2} +
338  \frac{32}{729} \left(\frac{1}{\alpha}\right)^{5/2}
339  \f]
340 
341  This approach works to within about 1 \part in \f$ 10^{12} \f$,
342  and is tested in <tt>fermion_ts.cpp</tt>.
343 
344  \future This could be improved by including more terms
345  in the expansions.
346  */
347  virtual void massless_pair_density(fermion &f, double temper);
348  //@}
349 
350  /** \brief Set the solver for use in massless_calc_density() */
352  massless_root=&rp;
353  return;
354  }
355 
356  /** \brief The default solver for massless_calc_density()
357 
358  We default to a solver of type root_cern here since we
359  don't have a bracket or a derivative.
360  */
362 
363  /// Return string denoting type ("fermion_eval_thermo")
364  virtual const char *type() { return "fermion_eval_thermo"; }
365 
366  /** \brief Test the thermodynamics of calc_density() and
367  calc_mu()
368 
369  This compares the approximation to the exact results over a
370  grid with \f$ T = \left\{10^{-2},1,10^{2}\right\} \f$, \f$
371  \log_{10} (m/T) = \left\{ -3,-2,-1,0,1,2,3\right\} \f$, and
372  \f$ \log_{10} \psi = \left\{ -3,-2,-1,0,1\right\} \f$, where
373  \f$ \psi \equiv \left(\mu-m\right)/T \f$ using
374  calc_density() and calc_mu(), with both inc_rest_mass
375  taking both values <tt>true</tt> and <tt>false</tt>.
376 
377  The <tt>verbose</tt> parameter controls the amount of
378  output, and \c fname is the filename for the file
379  <tt>fermion_cal.o2</tt>.
380 
381  \future Also calibrate massless fermions?
382  \future Convert into separate class?
383  */
384  virtual double calibrate(fermion &f, int verbose=0, std::string fname="");
385 
386 #ifndef DOXYGEN_NO_O2NS
387 
388  protected:
389 
390  /// A pointer to the solver for massless fermions
392 
393  /// Desc
394  double massless_solve_fun(double x, fermion &f, double temper);
395 
396 #endif
397 
398  };
399 
400 #ifndef DOXYGEN_NO_O2NS
401 }
402 #endif
403 
404 #endif
virtual void massless_calc_mu(fermion &f, double temper)
Finite temperature massless fermions.
Fermion properties at zero temperature.
Definition: fermion.h:86
virtual double calibrate(fermion &f, int verbose=0, std::string fname="")
Test the thermodynamics of calc_density() and calc_mu()
virtual void calc_density_zerot(fermion &f)
Zero temperature fermions from part::n and part::ms.
virtual void massless_pair_density(fermion &f, double temper)
Finite temperature massless fermions and antifermions.
virtual void calc_mu_zerot(fermion &f)
Zero temperature fermions from part::mu or part::nu and part::ms.
root_cern def_massless_root
The default solver for massless_calc_density()
Definition: fermion.h:361
void kf_from_density(fermion &f)
Calculate the Fermi momentum from the density.
double massless_solve_fun(double x, fermion &f, double temper)
Desc.
Fermion class.
Definition: fermion.h:52
virtual void massless_calc_density(fermion &f, double temper)
Finite temperature massless fermions.
virtual bool calc_mu_ndeg(fermion &f, double temper, double prec=1.0e-18)
Non-degenerate expansion for fermions.
fermion(double mass=0, double dof=0)
Create a fermion with mass mass and degeneracy dof.
Fermion with finite-temperature thermodynamics [abstract base].
Definition: fermion.h:162
virtual int calc_density(fermion &f, double temper)=0
Calculate properties as function of density.
virtual const char * type()
Return string denoting type ("fermion_eval_thermo")
Definition: fermion.h:364
root * massless_root
A pointer to the solver for massless fermions.
Definition: fermion.h:391
void pressure_zerot(fermion &f)
Pressure at T=0 from fermion::kf and part::ms.
double del
Gap.
Definition: fermion.h:59
Particle base class.
Definition: part.h:71
virtual void massless_pair_mu(fermion &f, double temper)
Finite temperature massless fermions and antifermions.
virtual bool calc_mu_deg(fermion &f, double temper, double prec=1.0e-18)
Degenerate expansion for fermions.
double kf
Fermi momentum.
Definition: fermion.h:57
virtual void calc_mu(fermion &f, double temper)=0
Calculate properties as function of chemical potential.
virtual int pair_density(fermion &f, double temper)=0
Calculate properties with antiparticles as function of density.
void energy_density_zerot(fermion &f)
Energy density at T=0 from fermion::kf and part::ms.
virtual void pair_mu(fermion &f, double temper)=0
Calculate properties with antiparticles as function of chemical potential.
void set_massless_root(root<> &rp)
Set the solver for use in massless_calc_density()
Definition: fermion.h:351
virtual const char * type()
Return string denoting type ("fermion")
Definition: fermion.h:68

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..