part.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_PART_H
24 #define O2SCL_PART_H
25 
26 #include <string>
27 #include <iostream>
28 #include <cmath>
29 #include <o2scl/constants.h>
30 #include <o2scl/inte.h>
31 #include <o2scl/funct.h>
32 #include <o2scl/mroot.h>
33 
34 /** \file part.h
35  \brief File defining \ref o2scl::thermo and \ref o2scl::part
36 */
37 
38 #ifndef DOXYGEN_NO_O2NS
39 namespace o2scl {
40 #endif
41 
42  /** \brief A class holding some useful thermodynamical variables (energy
43  density, pressure, entropy density)
44  */
45  class thermo {
46 
47  public:
48 
49  /// pressure
50  double pr;
51  /// energy density
52  double ed;
53  /// entropy density
54  double en;
55 
56  /// Return string denoting type ("thermo")
57  const char *type() { return "thermo"; }
58 
59  // Default constructor
60  thermo() {
61  }
62 
63  /// Copy constructor
64  thermo(const thermo &t) {
65  ed=t.ed;
66  pr=t.pr;
67  en=t.en;
68  }
69 
70  /// Copy construction with operator=()
71  thermo &operator=(const thermo &t) {
72  if (this!=&t) {
73  ed=t.ed;
74  pr=t.pr;
75  en=t.en;
76  }
77  return *this;
78  }
79 
80  };
81 
82  /** \brief Addition operator
83  */
84  extern thermo operator+(const thermo &left, const thermo &right);
85 
86  /** \brief Subtraction operator
87  */
88  extern thermo operator-(const thermo &left, const thermo &right);
89 
90  /** \brief Particle base class
91  */
92  class part {
93 
94  public:
95 
96  /// Degeneracy (e.g. spin and color if applicable)
97  double g;
98  /// Mass
99  double m;
100  /// Number density
101  double n;
102  /// Energy density
103  double ed;
104  /// Pressure
105  double pr;
106  /// Chemical potential
107  double mu;
108  /// Entropy density
109  double en;
110  /// Effective mass (Dirac unless otherwise specified)
111  double ms;
112  /// Effective chemical potential
113  double nu;
114  /** \brief If true, include the mass in the energy
115  density and chemical potential (default true)
116  */
118  /// True if the particle is non-interacting (default true)
120 
121  /// Copy constructor
122  part(const part &p) {
123  g=p.g;
124  m=p.m;
125  ms=p.ms;
126  n=p.n;
127  ed=p.ed;
128  pr=p.pr;
129  mu=p.mu;
130  en=p.en;
131  nu=p.nu;
132  inc_rest_mass=p.inc_rest_mass;
133  non_interacting=p.non_interacting;
134  }
135 
136  /// Copy construction with operator=()
137  part &operator=(const part &p) {
138  if (this!=&p) {
139  g=p.g;
140  m=p.m;
141  ms=p.ms;
142  n=p.n;
143  ed=p.ed;
144  pr=p.pr;
145  mu=p.mu;
146  en=p.en;
147  nu=p.nu;
148  inc_rest_mass=p.inc_rest_mass;
149  non_interacting=p.non_interacting;
150  }
151  return *this;
152  }
153 
154  /// Make a particle of mass \c mass and degeneracy \c dof.
155  part(double mass=0.0, double dof=0.0);
156 
157  virtual ~part();
158 
159  /// Set the mass \c mass and degeneracy \c dof.
160  virtual void init(double mass, double dof);
161 
162  /** \brief Make \c ap an anti-particle with the same mass
163  and degeneracy
164 
165  This sets the \ref m, \ref g, \ref ms, \ref inc_rest_mass
166  and \ref non_interacting fields of \c ap equal to that
167  of the current object. If \ref inc_rest_mass is true,
168  then it sets
169  \f[
170  \mu_{\mathrm{anti}} = - \mu
171  \qquad\mathrm{and}\qquad
172  \nu_{\mathrm{anti}} = - \nu
173  \f]
174  and if \ref inc_rest_mass is false, it sets
175  \f[
176  \mu_{\mathrm{anti}} = - \mu - 2 m
177  \qquad\mathrm{and}\qquad
178  \nu_{\mathrm{anti}} = - \nu - 2 m
179  \f]
180  */
181  virtual void anti(part &ap);
182 
183  /// Return string denoting type ("part")
184  virtual const char *type() { return "part"; }
185 
186  };
187 
188  /** \brief Addition operator
189  */
190  extern thermo operator+(const thermo &left, const part &right);
191 
192  /** \brief Subtraction operator
193  */
194  extern thermo operator-(const thermo &left, const part &right);
195 
196 #ifndef DOXYGEN_NO_O2NS
197 }
198 #endif
199 
200 #endif
double pr
pressure
Definition: part.h:50
thermo operator+(const thermo &left, const thermo &right)
Addition operator.
part(const part &p)
Copy constructor.
Definition: part.h:122
part & operator=(const part &p)
Copy construction with operator=()
Definition: part.h:137
thermo operator-(const thermo &left, const thermo &right)
Subtraction operator.
double nu
Effective chemical potential.
Definition: part.h:113
virtual const char * type()
Return string denoting type ("part")
Definition: part.h:184
double n
Number density.
Definition: part.h:101
thermo & operator=(const thermo &t)
Copy construction with operator=()
Definition: part.h:71
thermo(const thermo &t)
Copy constructor.
Definition: part.h:64
double en
Entropy density.
Definition: part.h:109
double ed
energy density
Definition: part.h:52
double m
Mass.
Definition: part.h:99
Particle base class.
Definition: part.h:92
double mu
Chemical potential.
Definition: part.h:107
double pr
Pressure.
Definition: part.h:105
double ms
Effective mass (Dirac unless otherwise specified)
Definition: part.h:111
double en
entropy density
Definition: part.h:54
A class holding some useful thermodynamical variables (energy density, pressure, entropy density) ...
Definition: part.h:45
double ed
Energy density.
Definition: part.h:103
const char * type()
Return string denoting type ("thermo")
Definition: part.h:57
bool non_interacting
True if the particle is non-interacting (default true)
Definition: part.h:119
bool inc_rest_mass
If true, include the mass in the energy density and chemical potential (default true) ...
Definition: part.h:117
double g
Degeneracy (e.g. spin and color if applicable)
Definition: part.h:97

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