fermion_eff.h
Go to the documentation of this file.
1 /*
2  -------------------------------------------------------------------
3 
4  Copyright (C) 2006-2017, 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  fermion_rel.
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 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_eval_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  \todo Fix higher densities in fermion_eff_ts.cpp.
102 
103  \future Use bracketing to speed up one-dimensional root finding.
104  */
106 
107  protected:
108 
109  /** \brief The function which solves for the chemical potential
110  given the density
111  */
112  double density_fun(double x, fermion &f, double temper);
113 
114  /** \brief The function which solves for the chemical potential
115  given the density (including antiparticles)
116  */
117  double pair_density_fun(double x, fermion &f, double temper);
118 
119  public:
120 
123 
124  /// Create a fermion with mass \c mass and degeneracy \c dof
125  fermion_eff();
126 
127  virtual ~fermion_eff();
128 
129  /** \name Coefficients for finite-temperature approximation
130  */
131  //@{
132  /** \brief Load coefficients
133 
134  The argument \c ctype Should be one of the constants below.
135  */
136  void load_coefficients(int ctype);
137 
138  /// A set of coefficients from Jim Lattimer
139  static const int cf_fermilat3=1;
140  /// The smaller set of coefficients from \ref Johns96
141  static const int cf_fermijel2=2;
142  /// The larger set of coefficients from \ref Johns96
143  static const int cf_fermijel3=3;
144  /** \brief The set of coefficients from \ref Johns96 which retains
145  better thermodynamic consistency
146  */
147  static const int cf_fermijel3cons=4;
148  //@}
149 
150  /** \brief Calculate thermodynamic
151  properties as function of chemical potential
152 
153  If the quantity \f$ (\mu-m)/T \f$ (or \f$ (\nu-m^{*})/T \f$ in
154  the case of interacting particles) is less than -200, then
155  this quietly sets the density, the scalar density, the energy
156  density, the pressure and the entropy to zero and exits.
157 
158  \todo Should see if the function actually works if
159  \f$ (\mu-m)/T = -199 \f$ .
160  */
161  virtual void calc_mu(fermion &f, double temper);
162 
163  /** \brief Calculate thermodynamic properties as function of
164  density
165 
166  \warning This function needs a guess for the chemical
167  potential, and will fail if that guess is not sufficiently
168  accurate.
169  */
170  virtual int calc_density(fermion &f, double temper);
171 
172  /** \brief Calculate thermodynamic properties with antiparticles
173  as function of chemical potential
174 
175  \warning This function needs a guess for the chemical
176  potential, and will fail if that guess is not sufficiently
177  accurate.
178  */
179  virtual void pair_mu(fermion &f, double temper);
180 
181  /** \brief Calculate thermodynamic properties with antiparticles
182  as function of density
183  */
184  virtual int pair_density(fermion &f, double temper);
185 
186  /** \brief Set the solver for use in calculating \f$ \psi \f$
187  */
188  int set_psi_root(root<> &rp) {
189  psi_root=&rp;
190  return 0;
191  }
192 
193  /** \brief Set the solver for use in calculating the chemical
194  potential from the density
195  */
197  density_root=&rp;
198  return 0;
199  }
200 
201  /** \brief If the temperature is less than \c tlimit then the
202  zero-temperature functions are used (default 0).
203  */
204  double tlimit;
205 
206  /** \brief If true, call the error handler when convergence
207  fails (default true)
208  */
210 
211  /** \brief The default solver for \f$ \psi \f$
212  */
214 
215  /** \brief The default solver for calc_density() and pair_density()
216  */
218 
219  /// Return string denoting type ("fermion_eff")
220  virtual const char *type() { return "fermion_eff"; }
221 
222  /// The minimum value of \f$ \psi \f$ (default -200)
223  double min_psi;
224 
225 #ifndef DOXYGEN_INTERNAL
226 
227  protected:
228 
229  /// The matrix of coefficients
230  ubmatrix Pmnf;
231  /// The parameter \f$ a \f$
232  double parma;
233  /// The array row size
234  int sizem;
235  /// The array column size
236  int sizen;
237 
238  /// The solver for \f$ \psi \f$
240  /// The other solver for calc_density()
242 
243  /// The function which solves for \f$ f \f$ from \f$ \psi \f$.
244  double solve_fun(double x, double &psi);
245 
246 #endif
247 
248  };
249 
250 #ifndef DOXYGEN_NO_O2NS
251 }
252 #endif
253 
254 #endif
double tlimit
If the temperature is less than tlimit then the zero-temperature functions are used (default 0)...
Definition: fermion_eff.h:204
double parma
The parameter .
Definition: fermion_eff.h:232
bool err_nonconv
If true, call the error handler when convergence fails (default true)
Definition: fermion_eff.h:209
static const int cf_fermijel2
The smaller set of coefficients from Johns96.
Definition: fermion_eff.h:141
double solve_fun(double x, double &psi)
The function which solves for from .
double density_fun(double x, fermion &f, double temper)
The function which solves for the chemical potential given the density.
Fermion class.
Definition: fermion.h:52
static const int cf_fermilat3
A set of coefficients from Jim Lattimer.
Definition: fermion_eff.h:139
fermion_eff()
Create a fermion with mass mass and degeneracy dof.
Fermion with finite-temperature thermodynamics [abstract base].
Definition: fermion.h:199
double min_psi
The minimum value of (default -200)
Definition: fermion_eff.h:223
int sizem
The array row size.
Definition: fermion_eff.h:234
virtual int calc_density(fermion &f, double temper)
Calculate thermodynamic properties as function of density.
virtual int pair_density(fermion &f, double temper)
Calculate thermodynamic properties with antiparticles as function of density.
static const int cf_fermijel3cons
The set of coefficients from Johns96 which retains better thermodynamic consistency.
Definition: fermion_eff.h:147
virtual void calc_mu(fermion &f, double temper)
Calculate thermodynamic properties as function of chemical potential.
ubmatrix Pmnf
The matrix of coefficients.
Definition: fermion_eff.h:230
double pair_density_fun(double x, fermion &f, double temper)
The function which solves for the chemical potential given the density (including antiparticles) ...
void load_coefficients(int ctype)
Load coefficients.
Fermion class from fitting method.
Definition: fermion_eff.h:105
static const int cf_fermijel3
The larger set of coefficients from Johns96.
Definition: fermion_eff.h:143
root_cern def_density_root
The default solver for calc_density() and pair_density()
Definition: fermion_eff.h:217
root_cern def_psi_root
The default solver for .
Definition: fermion_eff.h:213
virtual void pair_mu(fermion &f, double temper)
Calculate thermodynamic properties with antiparticles as function of chemical potential.
virtual const char * type()
Return string denoting type ("fermion_eff")
Definition: fermion_eff.h:220
root * psi_root
The solver for .
Definition: fermion_eff.h:239
int set_psi_root(root<> &rp)
Set the solver for use in calculating .
Definition: fermion_eff.h:188
int set_density_root(root<> &rp)
Set the solver for use in calculating the chemical potential from the density.
Definition: fermion_eff.h:196
int sizen
The array column size.
Definition: fermion_eff.h:236
root * density_root
The other solver for calc_density()
Definition: fermion_eff.h:241

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