fermion_eff.h
Go to the documentation of this file.
1 /*
2  -------------------------------------------------------------------
3 
4  Copyright (C) 2006-2020, 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_EFF_FERMION_H
24 #define O2SCL_EFF_FERMION_H
25 
26 /** \file fermion_eff.h
27  \brief File defining \ref o2scl::fermion_eff
28 */
29 
30 #include <string>
31 #include <iostream>
32 #include <fstream>
33 #include <cmath>
34 
35 #include <boost/numeric/ublas/vector.hpp>
36 #include <boost/numeric/ublas/matrix.hpp>
37 
38 #include <o2scl/constants.h>
39 #include <o2scl/funct.h>
40 #include <o2scl/mm_funct.h>
41 #include <o2scl/root.h>
42 #include <o2scl/mroot.h>
43 #include <o2scl/inte.h>
44 #include <o2scl/root_cern.h>
45 #include <o2scl/misc.h>
46 
47 #include <o2scl/fermion.h>
48 
49 #ifndef DOXYGEN_NO_O2NS
50 namespace o2scl {
51 #endif
52 
53  /** \brief Fermion class from fitting method
54 
55  Based on the fitting method of \ref Johns96 which is an update
56  of the method from \ref Eggleton73 . This method is approximate,
57  but very fast. For a more accurate (but slower) method, use
58  o2scl::fermion_rel_tl.
59 
60  If the temperature is less than or equal to \ref tlimit (which
61  defaults to zero), the zero-temperature expressions
62  from the parent class \ref fermion_zerot_tl are used.
63 
64  Given the chemical potential and the temperature the functions
65  calc_mu() and pair_mu() work by solving the equation (c.f. Eq. 15
66  in \ref Johns96)
67  \f[
68  \psi= 2 \sqrt{1+f/a}+\log\left(\frac{\sqrt{1+f/a}-1}
69  {\sqrt{1+f/a}+1}\right)
70  \f]
71  for \f$ f \f$ given \f$ \psi=(\mu-m)/T \f$.
72  If \f$ f/a<10^{-10} \f$, then the alternative expression
73  \f[
74  \psi= 2 \left[1+f/(2 a)\right]+\log\left\{\frac{f/(2 a)}
75  {\left[1+f/(2 a)\right]}\right\}
76  \f]
77  is used. The pressure, energy density, and entropy, are
78  determined as polynomials in \f$ f \f$ with a
79  set of precomputed coefficients as done in \ref Johns96 .
80 
81  If \f$ \psi \f$ is less than \ref min_psi (which defaults to -4)
82  then the non-dengenerate approximation from \ref
83  fermion_thermo::calc_mu_ndeg() is used. The value of \ref
84  min_psi can be decreased to ensure that the expansion is not
85  used, but values of \f$ \psi \f$ less than about -200 can cause
86  the \ref Johns96 procedure outlined above to fail. Values of
87  \ref min_psi larger than -4 are not useful.
88 
89  When the density and temperature is given instead
90  (calc_density() and pair_density()), then there are two ways to
91  proceed.
92  - Use the density to solve for \f$ f \f$ .
93  - Use the density to solve for the chemical potential.
94 
95  Because the density is a complicated polynomial in \f$ f \f$,
96  the former procedure does not work very well even though it
97  might be less time consuming. In this class, the density is
98  solved for the effective chemical potential instead. The initial
99  guess is just taken from the present value of part::nu .
100 
101  \future Use bracketing to speed up one-dimensional root finding.
102  \future Implement the same method of allowing the user to
103  turn on or off the degenerate and nondegenerate expansions
104  as in \ref o2scl::fermion_rel_tl .
105  */
106  class fermion_eff : public fermion_thermo {
107 
108  protected:
109 
110  /** \brief The function which solves for the chemical potential
111  given the density
112  */
113  double density_fun(double x, fermion &f, double temper);
114 
115  /** \brief The function which solves for the chemical potential
116  given the density (including antiparticles)
117  */
118  double pair_density_fun(double x, fermion &f, double temper);
119 
120  public:
121 
124 
125  /// Create a fermion with mass \c mass and degeneracy \c dof
126  fermion_eff();
127 
128  virtual ~fermion_eff();
129 
130  /** \name Coefficients for finite-temperature approximation
131  */
132  //@{
133  /** \brief Load coefficients
134 
135  The argument \c ctype Should be one of the constants below.
136  */
137  void load_coefficients(int ctype);
138 
139  /// A set of coefficients from Jim Lattimer
140  static const int cf_fermilat3=1;
141  /// The smaller set of coefficients from \ref Johns96
142  static const int cf_fermijel2=2;
143  /// The larger set of coefficients from \ref Johns96
144  static const int cf_fermijel3=3;
145  /** \brief The set of coefficients from \ref Johns96 which retains
146  better thermodynamic consistency
147  */
148  static const int cf_fermijel3cons=4;
149  //@}
150 
151  /** \brief Calculate thermodynamic
152  properties as function of chemical potential
153 
154  If the quantity \f$ (\mu-m)/T \f$ (or \f$ (\nu-m^{*})/T \f$ in
155  the case of interacting particles) is less than -200, then
156  this quietly sets the density, the scalar density, the energy
157  density, the pressure and the entropy to zero and exits.
158  */
159  virtual void calc_mu(fermion &f, double temper);
160 
161  /** \brief Calculate thermodynamic properties as function of
162  density
163 
164  \warning This function needs a guess for the chemical
165  potential, and will fail if that guess is not sufficiently
166  accurate.
167  */
168  virtual int calc_density(fermion &f, double temper);
169 
170  /** \brief Calculate thermodynamic properties with antiparticles
171  as function of chemical potential
172 
173  \warning This function needs a guess for the chemical
174  potential, and will fail if that guess is not sufficiently
175  accurate.
176  */
177  virtual void pair_mu(fermion &f, double temper);
178 
179  /** \brief Calculate thermodynamic properties with antiparticles
180  as function of density
181  */
182  virtual int pair_density(fermion &f, double temper);
183 
184  /** \brief Set the solver for use in calculating \f$ \psi \f$
185  */
186  int set_psi_root(root<> &rp) {
187  psi_root=&rp;
188  return 0;
189  }
190 
191  /** \brief Set the solver for use in calculating the chemical
192  potential from the density
193  */
195  density_root=&rp;
196  return 0;
197  }
198 
199  /** \brief If the temperature is less than \c tlimit then the
200  zero-temperature functions are used (default 0).
201  */
202  double tlimit;
203 
204  /** \brief If true, call the error handler when convergence
205  fails (default true)
206  */
208 
209  /** \brief The default solver for \f$ \psi \f$
210  */
212 
213  /** \brief The default solver for calc_density() and pair_density()
214  */
216 
217  /// Return string denoting type ("fermion_eff")
218  virtual const char *type() { return "fermion_eff"; }
219 
220  /// The minimum value of \f$ \psi \f$ (default -200)
221  double min_psi;
222 
223 #ifndef DOXYGEN_INTERNAL
224 
225  protected:
226 
227  /// The matrix of coefficients
229  /// The parameter \f$ a \f$
230  double parma;
231  /// The array row size
232  int sizem;
233  /// The array column size
234  int sizen;
235 
236  /// The solver for \f$ \psi \f$
238  /// The other solver for calc_density()
240 
241  /// The function which solves for \f$ f \f$ from \f$ \psi \f$.
242  double solve_fun(double x, double psi);
243 
244 #endif
245 
246  };
247 
248 #ifndef DOXYGEN_NO_O2NS
249 }
250 #endif
251 
252 #endif
boost::numeric::ublas::matrix< double >
o2scl::fermion_eff::err_nonconv
bool err_nonconv
If true, call the error handler when convergence fails (default true)
Definition: fermion_eff.h:207
o2scl::fermion_eff::Pmnf
ubmatrix Pmnf
The matrix of coefficients.
Definition: fermion_eff.h:228
o2scl::fermion_eff::set_density_root
int set_density_root(root<> &rp)
Set the solver for use in calculating the chemical potential from the density.
Definition: fermion_eff.h:194
boost::numeric::ublas::vector< double >
o2scl::fermion_eff::density_fun
double density_fun(double x, fermion &f, double temper)
The function which solves for the chemical potential given the density.
o2scl::fermion_eff::solve_fun
double solve_fun(double x, double psi)
The function which solves for from .
o2scl::fermion_eff::tlimit
double tlimit
If the temperature is less than tlimit then the zero-temperature functions are used (default 0).
Definition: fermion_eff.h:202
o2scl::fermion_eff::def_density_root
root_cern def_density_root
The default solver for calc_density() and pair_density()
Definition: fermion_eff.h:215
o2scl::root
o2scl::fermion_eff::cf_fermilat3
static const int cf_fermilat3
A set of coefficients from Jim Lattimer.
Definition: fermion_eff.h:140
o2scl::fermion_eff::cf_fermijel3
static const int cf_fermijel3
The larger set of coefficients from Johns96.
Definition: fermion_eff.h:144
o2scl::fermion_eff::type
virtual const char * type()
Return string denoting type ("fermion_eff")
Definition: fermion_eff.h:218
o2scl::fermion_eff::parma
double parma
The parameter .
Definition: fermion_eff.h:230
o2scl::fermion_eff::psi_root
root * psi_root
The solver for .
Definition: fermion_eff.h:237
o2scl::fermion_eff::calc_density
virtual int calc_density(fermion &f, double temper)
Calculate thermodynamic properties as function of density.
o2scl::fermion_tl< double >
o2scl::fermion_eff::cf_fermijel2
static const int cf_fermijel2
The smaller set of coefficients from Johns96.
Definition: fermion_eff.h:142
o2scl::fermion_eff::pair_density
virtual int pair_density(fermion &f, double temper)
Calculate thermodynamic properties with antiparticles as function of density.
o2scl::fermion_eff::pair_density_fun
double pair_density_fun(double x, fermion &f, double temper)
The function which solves for the chemical potential given the density (including antiparticles)
o2scl::fermion_eff::min_psi
double min_psi
The minimum value of (default -200)
Definition: fermion_eff.h:221
o2scl::fermion_eff::load_coefficients
void load_coefficients(int ctype)
Load coefficients.
o2scl::root_cern
o2scl::fermion_eff::density_root
root * density_root
The other solver for calc_density()
Definition: fermion_eff.h:239
o2scl::fermion_eff::set_psi_root
int set_psi_root(root<> &rp)
Set the solver for use in calculating .
Definition: fermion_eff.h:186
o2scl::fermion_eff::cf_fermijel3cons
static const int cf_fermijel3cons
The set of coefficients from Johns96 which retains better thermodynamic consistency.
Definition: fermion_eff.h:148
o2scl::fermion_eff::calc_mu
virtual void calc_mu(fermion &f, double temper)
Calculate thermodynamic properties as function of chemical potential.
o2scl::fermion_thermo_tl< double >
o2scl::fermion_eff::sizem
int sizem
The array row size.
Definition: fermion_eff.h:232
o2scl::fermion_eff::fermion_eff
fermion_eff()
Create a fermion with mass mass and degeneracy dof.
o2scl::fermion_eff::pair_mu
virtual void pair_mu(fermion &f, double temper)
Calculate thermodynamic properties with antiparticles as function of chemical potential.
o2scl::fermion_eff::sizen
int sizen
The array column size.
Definition: fermion_eff.h:234
o2scl::fermion_eff::def_psi_root
root_cern def_psi_root
The default solver for .
Definition: fermion_eff.h:211
o2scl::fermion_eff
Fermion class from fitting method.
Definition: fermion_eff.h:106

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).