boson_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_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::nu .
83 
84  \todo Improve documentation
85  */
86  class boson_eff {
87 
88  public:
89 
92 
93  /// Create a boson with mass \c m and degeneracy \c g
94  boson_eff();
95 
96  virtual ~boson_eff();
97 
98  /** \brief Load coefficients for finite-temperature approximation
99 
100  Presently acceptable values of \c fn are:
101  \c bosejel21, \c bosejel22, \c bosejel34, and
102  \c bosejel34cons from \ref Johns96.
103  */
104  int load_coefficients(int ctype);
105  /// A set of coefficients from \ref Johns96
106  static const int cf_bosejel21=2;
107  /// A set of coefficients from \ref Johns96
108  static const int cf_bosejel22=3;
109  /// A set of coefficients from \ref Johns96 (default)
110  static const int cf_bosejel34=4;
111  /** \brief The set of coefficients from \ref Johns96 which retains
112  better thermodynamic consistency
113  */
114  static const int cf_bosejel34cons=5;
115 
116  /** \brief Calculate thermodynamic
117  properties as function of chemical potential
118  */
119  virtual void calc_mu(boson &b, double temper);
120 
121  /** \brief Calculate thermodynamic
122  properties as function of density
123  */
124  virtual void calc_density(boson &b, double temper);
125 
126  /** \brief Calculate thermodynamic properties with antiparticles
127  as function of chemical potential
128  */
129  virtual void pair_mu(boson &b, double temper);
130 
131  /** \brief Calculate thermodynamic properties with antiparticles
132  as function of density
133  */
134  virtual void pair_density(boson &b, double temper);
135 
136  /** \brief Set the solver for use in calculating \f$ \psi \f$
137  */
138  void set_psi_root(root<> &rp) {
139  psi_root=&rp;
140  return;
141  }
142 
143  /** \brief Set the solver for use in calculating the chemical
144  potential from the density
145  */
147  density_mroot=&rp;
148  return;
149  }
150 
151  /** \brief The default solver for calc_density() and pair_density()
152  */
154 
155  /** \brief The default solver for \f$ \psi \f$
156  */
158 
159  /// Return string denoting type ("boson_eff")
160  virtual const char *type() { return "boson_eff"; }
161 
162 #ifndef DOXYGEN_INTERNAL
163 
164  protected:
165 
166  /// The coefficients
167  ubmatrix Pmnb;
168  /// The number of coefficient rows
169  int sizem;
170  /// The number of coefficient columns
171  int sizen;
172  /// The parameter, \f$ a \f$
173  double parma;
174  /// Temporary storage
175  double fix_density;
176 
177  /// The solver for calc_density()
179 
180  /// The solver to compute \f$ h \f$ from \f$ \psi \f$.
182 
183  /// The function which solves for \f$ h \f$ from \f$ \psi \f$.
184  double solve_fun(double x, double &psi);
185 
186  /// Fix density for \ref calc_density()
187  int density_fun(size_t nv, const ubvector &x, ubvector &y,
188  boson &b, double T);
189 
190  /// Fix density for \ref pair_density()
191  int pair_density_fun(size_t nv, const ubvector &x, ubvector &y,
192  boson &b, double T);
193 
194 #endif
195  };
196 
197 #ifndef DOXYGEN_NO_O2NS
198 }
199 #endif
200 
201 #endif
void set_density_mroot(mroot<> &rp)
Set the solver for use in calculating the chemical potential from the density.
Definition: boson_eff.h:146
root_cern def_psi_root
The default solver for .
Definition: boson_eff.h:157
void set_psi_root(root<> &rp)
Set the solver for use in calculating .
Definition: boson_eff.h:138
boson_eff()
Create a boson with mass m and degeneracy g.
mroot * density_mroot
The solver for calc_density()
Definition: boson_eff.h:178
static const int cf_bosejel21
A set of coefficients from Johns96.
Definition: boson_eff.h:106
double parma
The parameter, .
Definition: boson_eff.h:173
virtual void pair_mu(boson &b, double temper)
Calculate thermodynamic properties with antiparticles as function of chemical potential.
int pair_density_fun(size_t nv, const ubvector &x, ubvector &y, boson &b, double T)
Fix density for pair_density()
static const int cf_bosejel34cons
The set of coefficients from Johns96 which retains better thermodynamic consistency.
Definition: boson_eff.h:114
double solve_fun(double x, double &psi)
The function which solves for from .
int load_coefficients(int ctype)
Load coefficients for finite-temperature approximation.
virtual void calc_mu(boson &b, double temper)
Calculate thermodynamic properties as function of chemical potential.
int sizem
The number of coefficient rows.
Definition: boson_eff.h:169
ubmatrix Pmnb
The coefficients.
Definition: boson_eff.h:167
mroot_hybrids def_density_mroot
The default solver for calc_density() and pair_density()
Definition: boson_eff.h:153
root * psi_root
The solver to compute from .
Definition: boson_eff.h:181
int density_fun(size_t nv, const ubvector &x, ubvector &y, boson &b, double T)
Fix density for calc_density()
double fix_density
Temporary storage.
Definition: boson_eff.h:175
virtual void pair_density(boson &b, double temper)
Calculate thermodynamic properties with antiparticles as function of density.
virtual void calc_density(boson &b, double temper)
Calculate thermodynamic properties as function of density.
static const int cf_bosejel34
A set of coefficients from Johns96 (default)
Definition: boson_eff.h:110
Boson class from fitting method.
Definition: boson_eff.h:86
static const int cf_bosejel22
A set of coefficients from Johns96.
Definition: boson_eff.h:108
Boson class.
Definition: boson.h:46
virtual const char * type()
Return string denoting type ("boson_eff")
Definition: boson_eff.h:160
int sizen
The number of coefficient columns.
Definition: boson_eff.h:171

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