boson_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_BOSON_EFF_H
24 #define O2SCL_BOSON_EFF_H
25 
26 /** \file boson_eff.h
27  \brief File defining \ref o2scl::boson_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/mroot_hybrids.h>
46 
47 #include <o2scl/boson.h>
48 
49 #ifndef DOXYGEN_NO_O2NS
50 namespace o2scl {
51 #endif
52 
53  /** \brief Boson 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  \ref o2scl::boson_rel.
59 
60  Given the chemical potential and the temperature the functions
61  \ref calc_mu() and \ref pair_mu() work by solving the equation
62  (c.f. Eq. 26 in \ref Johns96)
63  \f[
64  \psi = \frac{h}{(h+\sqrt{a})} - \ln \left(
65  \frac{h+\sqrt{a}}{\sqrt{a}}\right)
66  \f]
67  for \f$ h \f$ given \f$ \psi=(\mu-m)/T \f$. The pressure, energy
68  density, and entropy, are determined as polynomials in \f$ h \f$
69  with a set of precomputed coefficients as done in \ref Johns96 .
70 
71  When the density and temperature is given instead (\ref
72  calc_density() and \ref pair_density()), then there are two ways
73  to proceed:
74  - use the density to solve for \f$ f \f$ , or
75  - use the density to solve for the chemical potential.
76 
77  Because the density is a complicated polynomial in \f$ f \f$,
78  the former procedure does not work very well (the polynomial
79  produces spurious solutions) even though it might be less time
80  consuming. In this class, the density is solved for the
81  effective chemical potential instead. The initial guess is just
82  taken from the present value of part::mu or, if
83  part::non_interacting is false, from part::nu .
84  */
85  class boson_eff : public boson_thermo {
86 
87  public:
88 
91 
92  /// Create a boson with mass \c m and degeneracy \c g
93  boson_eff();
94 
95  virtual ~boson_eff();
96 
97  /** \brief Load coefficients for finite-temperature approximation
98 
99  Presently acceptable values of \c fn are:
100  \c bosejel21, \c bosejel22, \c bosejel34, and
101  \c bosejel34cons from \ref Johns96.
102  */
103  int load_coefficients(int ctype);
104  /// A set of coefficients from \ref Johns96
105  static const int cf_bosejel21=2;
106  /// A set of coefficients from \ref Johns96
107  static const int cf_bosejel22=3;
108  /// A set of coefficients from \ref Johns96 (default)
109  static const int cf_bosejel34=4;
110  /** \brief The set of coefficients from \ref Johns96 which retains
111  better thermodynamic consistency
112  */
113  static const int cf_bosejel34cons=5;
114 
115  /** \brief Calculate thermodynamic
116  properties as function of chemical potential
117  */
118  virtual void calc_mu(boson &b, double temper);
119 
120  /** \brief Calculate thermodynamic
121  properties as function of density
122  */
123  virtual void calc_density(boson &b, double temper);
124 
125  /** \brief Calculate thermodynamic properties with antiparticles
126  as function of chemical potential
127  */
128  virtual void pair_mu(boson &b, double temper);
129 
130  /** \brief Calculate thermodynamic properties with antiparticles
131  as function of density
132  */
133  virtual void pair_density(boson &b, double temper);
134 
135  /** \brief Set the solver for use in calculating \f$ \psi \f$
136  */
137  void set_psi_root(root<> &rp) {
138  psi_root=&rp;
139  return;
140  }
141 
142  /** \brief Set the solver for use in calculating the chemical
143  potential from the density
144  */
146  density_mroot=&rp;
147  return;
148  }
149 
150  /** \brief The default solver for calc_density() and pair_density()
151  */
153 
154  /** \brief The default solver for \f$ \psi \f$
155  */
157 
158  /// Return string denoting type ("boson_eff")
159  virtual const char *type() { return "boson_eff"; }
160 
161 #ifndef DOXYGEN_INTERNAL
162 
163  protected:
164 
165  /// The coefficients
167  /// The number of coefficient rows
168  int sizem;
169  /// The number of coefficient columns
170  int sizen;
171  /// The parameter, \f$ a \f$
172  double parma;
173  /// Temporary storage
174  double fix_density;
175 
176  /// The solver for calc_density()
178 
179  /// The solver to compute \f$ h \f$ from \f$ \psi \f$.
181 
182  /// The function which solves for \f$ h \f$ from \f$ \psi \f$.
183  double solve_fun(double x, double psi);
184 
185  /// Fix density for \ref calc_density()
186  int density_fun(size_t nv, const ubvector &x, ubvector &y,
187  boson &b, double T);
188 
189  /// Fix density for \ref pair_density()
190  int pair_density_fun(size_t nv, const ubvector &x, ubvector &y,
191  boson &b, double T);
192 
193 #endif
194  };
195 
196 #ifndef DOXYGEN_NO_O2NS
197 }
198 #endif
199 
200 #endif
boost::numeric::ublas::matrix
o2scl::boson_eff::load_coefficients
int load_coefficients(int ctype)
Load coefficients for finite-temperature approximation.
o2scl::boson_eff::pair_mu
virtual void pair_mu(boson &b, double temper)
Calculate thermodynamic properties with antiparticles as function of chemical potential.
boost::numeric::ublas::vector< double >
o2scl::boson_eff::pair_density_fun
int pair_density_fun(size_t nv, const ubvector &x, ubvector &y, boson &b, double T)
Fix density for pair_density()
o2scl::boson_eff::cf_bosejel34
static const int cf_bosejel34
A set of coefficients from Johns96 (default)
Definition: boson_eff.h:109
o2scl::boson
Boson class.
Definition: boson.h:46
o2scl::boson_eff::psi_root
root * psi_root
The solver to compute from .
Definition: boson_eff.h:180
o2scl::boson_eff::cf_bosejel22
static const int cf_bosejel22
A set of coefficients from Johns96.
Definition: boson_eff.h:107
o2scl::boson_eff::boson_eff
boson_eff()
Create a boson with mass m and degeneracy g.
o2scl::boson_eff::sizen
int sizen
The number of coefficient columns.
Definition: boson_eff.h:170
o2scl::boson_eff::calc_density
virtual void calc_density(boson &b, double temper)
Calculate thermodynamic properties as function of density.
o2scl::root
o2scl::boson_eff::solve_fun
double solve_fun(double x, double psi)
The function which solves for from .
o2scl::boson_eff::def_psi_root
root_cern def_psi_root
The default solver for .
Definition: boson_eff.h:156
o2scl::boson_eff::set_density_mroot
void set_density_mroot(mroot<> &rp)
Set the solver for use in calculating the chemical potential from the density.
Definition: boson_eff.h:145
o2scl::boson_eff::type
virtual const char * type()
Return string denoting type ("boson_eff")
Definition: boson_eff.h:159
o2scl::boson_thermo
Compute the thermodynamic properties of a boson [abstract base].
Definition: boson.h:75
o2scl::boson_eff::sizem
int sizem
The number of coefficient rows.
Definition: boson_eff.h:168
o2scl::boson_eff::Pmnb
ubmatrix Pmnb
The coefficients.
Definition: boson_eff.h:166
o2scl::boson_eff::parma
double parma
The parameter, .
Definition: boson_eff.h:172
o2scl::mroot_hybrids
o2scl::boson_eff::calc_mu
virtual void calc_mu(boson &b, double temper)
Calculate thermodynamic properties as function of chemical potential.
o2scl::boson_eff::def_density_mroot
mroot_hybrids def_density_mroot
The default solver for calc_density() and pair_density()
Definition: boson_eff.h:152
o2scl::boson_eff::pair_density
virtual void pair_density(boson &b, double temper)
Calculate thermodynamic properties with antiparticles as function of density.
o2scl::boson_eff::density_fun
int density_fun(size_t nv, const ubvector &x, ubvector &y, boson &b, double T)
Fix density for calc_density()
o2scl::mroot
o2scl::root_cern
o2scl::boson_eff::cf_bosejel34cons
static const int cf_bosejel34cons
The set of coefficients from Johns96 which retains better thermodynamic consistency.
Definition: boson_eff.h:113
o2scl::boson_eff
Boson class from fitting method.
Definition: boson_eff.h:85
o2scl::boson_eff::density_mroot
mroot * density_mroot
The solver for calc_density()
Definition: boson_eff.h:177
o2scl::boson_eff::cf_bosejel21
static const int cf_bosejel21
A set of coefficients from Johns96.
Definition: boson_eff.h:105
o2scl::boson_eff::set_psi_root
void set_psi_root(root<> &rp)
Set the solver for use in calculating .
Definition: boson_eff.h:137
o2scl::boson_eff::fix_density
double fix_density
Temporary storage.
Definition: boson_eff.h:174

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