00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2006, 2007, Andrew W. Steiner 00005 00006 This file is part of O2scl. 00007 00008 O2scl is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 O2scl is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with O2scl. If not, see <http://www.gnu.org/licenses/>. 00020 00021 ------------------------------------------------------------------- 00022 */ 00023 #ifndef O2SCL_PART_H 00024 #define O2SCL_PART_H 00025 00026 #include <string> 00027 #include <iostream> 00028 #include <cmath> 00029 #include <o2scl/constants.h> 00030 #include <o2scl/inte.h> 00031 #include <o2scl/collection.h> 00032 #include <o2scl/funct.h> 00033 #include <o2scl/mroot.h> 00034 00035 /** \file part.h 00036 \brief File for definitions for \ref thermo and \ref part 00037 */ 00038 00039 #ifndef DOXYGENP 00040 namespace o2scl { 00041 #endif 00042 00043 /** \brief A class for the thermodynamical variables (energy 00044 density, pressure, entropy density) 00045 */ 00046 class thermo { 00047 00048 public: 00049 00050 /// pressure 00051 double pr; 00052 /// energy density 00053 double ed; 00054 /// entropy density 00055 double en; 00056 00057 /// Return string denoting type ("thermo") 00058 const char *type() { return "thermo"; } 00059 00060 }; 00061 00062 /** \brief Addition operator 00063 */ 00064 extern thermo operator+(const thermo &left, const thermo &right); 00065 00066 /** \brief Subtraction operator 00067 */ 00068 extern thermo operator-(const thermo &left, const thermo &right); 00069 00070 template<> int io_tlate<thermo>::input 00071 (cinput *co, in_file_format *ins, thermo *t); 00072 template<> int io_tlate<thermo>::output 00073 (coutput *co, out_file_format *outs, thermo *t); 00074 template<> const char *io_tlate<thermo>::type(); 00075 00076 /** 00077 \brief Particle base class 00078 00079 Calculate the properties of particles from their chemical 00080 potential (calc_mu() and pair_mu()) or from the density 00081 (calc_density() and pair_density()). 00082 00083 When non-interacting is false, the thermodynamic integrals need 00084 both a value of "mu" and "nu". "nu" is an effective chemical 00085 potential which appears in the argument of the exponential of 00086 the Fermi-function. 00087 00088 Keep in mind, that the pair functions use anti(), which assumes 00089 that nu -> -nu and mu -> -mu for the anti-particles, which might 00090 not be true for interacting particles. When non-interacting is 00091 true, then "ms" is set equal to "m", and "nu" is set equal to 00092 "mu", everywhere. 00093 00094 The "density" functions use the value of nu (or mu when 00095 non_interacting is true) for an initial guess. Zero is very 00096 likely a bad guess, but these functions will not warn you about 00097 this. 00098 00099 */ 00100 class part { 00101 00102 public: 00103 00104 /// degeneracy 00105 double g; 00106 /// mass 00107 double m; 00108 /// density 00109 double n; 00110 /// energy density 00111 double ed; 00112 /// pressure 00113 double pr; 00114 /// chemical potential 00115 double mu; 00116 /// entropy 00117 double en; 00118 /// effective mass (Dirac unless otherwise specified) 00119 double ms; 00120 /// effective chemical potential 00121 double nu; 00122 /// derivative of energy with respect to effective mass 00123 bool inc_rest_mass; 00124 /** \brief When this is true, \ref nu and \ref ms are set equal 00125 to \ref mu and \ref m by \ref calc_mu(), etc.. (default true) 00126 */ 00127 bool non_interacting; 00128 /// The name usually defaults to the class name. 00129 std::string name; 00130 00131 /// make a particle of mass \c m and degeneracy \c g. 00132 part(double m=0.0, double g=0.0); 00133 virtual ~part(); 00134 00135 /// Set the mass \c m and degeneracy \c g. 00136 virtual int init(double m, double g); 00137 00138 /** 00139 \brief Calculate properties as function of chemical potential 00140 */ 00141 virtual int calc_mu(const double temper); 00142 00143 /** \brief Calculate properties as function of density 00144 */ 00145 virtual int calc_density(const double temper); 00146 00147 /** \brief Calculate properties with antiparticles as function of 00148 chemical potential 00149 */ 00150 virtual int pair_mu(const double temper); 00151 00152 /** \brief Calculate properties with antiparticles as function of 00153 density 00154 */ 00155 virtual int pair_density(const double temper); 00156 00157 /// Make an anti-particle 00158 virtual int anti(part &ax); 00159 00160 /// Return string denoting type ("part") 00161 virtual const char *type() { return "part"; } 00162 00163 friend class io_tlate<part>; 00164 00165 }; 00166 00167 /** \brief Addition operator 00168 */ 00169 extern thermo operator+(const thermo &left, const part &right); 00170 00171 /** \brief Subtraction operator 00172 */ 00173 extern thermo operator-(const thermo &left, const part &right); 00174 00175 template<> int io_tlate<part>::input 00176 (cinput *co, in_file_format *ins, part *p); 00177 template<> int io_tlate<part>::output 00178 (coutput *co, out_file_format *outs, part *p); 00179 template<> const char *io_tlate<part>::type(); 00180 00181 //--------------------------------------------- 00182 00183 typedef io_tlate<thermo> thermo_io_type; 00184 typedef io_tlate<part> part_io_type; 00185 00186 #ifndef DOXYGENP 00187 } 00188 #endif 00189 00190 #endif