nucmass_densmat.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 NUCMASS_DENSMAT_H
24 #define NUCMASS_DENSMAT_H
25 
26 #include <boost/numeric/ublas/vector.hpp>
27 
28 #include <o2scl/classical.h>
29 #include <o2scl/fermion_rel.h>
30 #include <o2scl/fermion_deriv_rel.h>
31 #include <o2scl/boson_rel.h>
32 
33 #include <o2scl/nucmass_frdm.h>
34 #include <o2scl/nucmass_ame.h>
35 #include <o2scl/nucdist.h>
36 #include <o2scl/hdf_nucmass_io.h>
37 
38 /** \file nucmass_densmat.h
39  \brief File defining \ref o2scl::dense_matter and
40  \ref o2scl::nucmass_densmat
41 */
42 
43 #ifndef DOXYGEN_NO_O2NS
44 namespace o2scl {
45 #endif
46 
47  /** \brief A container for the properties of dense matter at a
48  specified baryon density, electron fraction and temperature
49 
50  This class is experimental.
51 
52  By default, the rest mass is not included in the neutron, or the
53  proton. It is, however, included in the electron. Note that the
54  values of \ref nB and \ref Ye need not always correspond exactly
55  to the values returned by \ref baryon_density() and \ref
56  electron_fraction(). This design enables this object to refer to
57  the composition while some algorithm is matching to a fixed
58  baryon density and electron fraction. Note also that the
59  chemical potentials in \ref eta_n, \ref eta_p, and \ref eta_nuc may
60  contain corrections from heterogeneous matter which are not
61  typically included in the values in \ref o2scl::part::mu which
62  only contain the homogeneous parts.
63 
64  */
65  class dense_matter {
66 
67  public:
68 
70 
71  /// Temperature (in \f$ \mathrm{fm}^{-1} \f$)
72  double T;
73  /// Baryon number density (in \f$ \mathrm{fm}^{-3} \f$)
74  double nB;
75  /// Electron fraction
76  double Ye;
77 
78  /// Neutrons
80  /// Protons
82  /// Electrons
84  /// Muons
86  /// Photons
88  /// Distribution of nuclei
89  std::vector<o2scl::nucleus> dist;
90 
91  /// Neutron chemical potential
92  double eta_n;
93  /// Proton chemical potential
94  double eta_p;
95 
96  /// Nuclear chemical potentials
97  ubvector eta_nuc;
98 
99  /// Total thermodynamic quantities
101 
102  /// Thermodynamic quantities for dripped particles
104 
105  /** \brief Constructor
106 
107  This constructor automatically sets the neutron, proton, and
108  electron masses.
109  */
110  dense_matter();
111 
112  /// Copy constructor
114  n=dm.n;
115  p=dm.p;
116  e=dm.e;
117  mu=dm.mu;
118  photon=dm.photon;
119 
120  drip_th=dm.drip_th;
121  th=dm.th;
122 
123  for (size_t i=0;i<dm.dist.size();i++) {
124  dist.push_back(dm.dist[i]);
125  }
126 
127  eta_n=dm.eta_n;
128  eta_p=dm.eta_p;
129  eta_nuc=dm.eta_nuc;
130 
131  T=dm.T;
132  nB=dm.nB;
133  Ye=dm.Ye;
134  }
135 
136  /// Copy constructor with operator=()
138 
139  if (this!=&dm) {
140  n=dm.n;
141  p=dm.p;
142  e=dm.e;
143  mu=dm.mu;
144  photon=dm.photon;
145 
146  drip_th=dm.drip_th;
147  th=dm.th;
148 
149  for (size_t i=0;i<dm.dist.size();i++) {
150  dist.push_back(dm.dist[i]);
151  }
152 
153  eta_n=dm.eta_n;
154  eta_p=dm.eta_p;
155  eta_nuc=dm.eta_nuc;
156 
157  T=dm.T;
158  nB=dm.nB;
159  Ye=dm.Ye;
160  }
161 
162  return *this;
163  }
164 
165  void output(std::ostream &out, int verbose=1);
166 
167  /** \brief Compute an average inter-ionic spacing
168 
169  This function returns
170  \f[
171  \left<a\right> \equiv \left(\frac{4 \pi}{3}\sum_i n_i
172  \right)^{-1/3} \, .
173  \f]
174  */
175  double average_a();
176 
177  /** \brief Compute the number-averaged mass number
178 
179  This function returns
180  \f$ \left<A\right> \equiv \sum_i n_i A_i / \sum_i n_i \f$ .
181  */
182  double average_A();
183 
184  /** \brief Compute total density of neutrons
185  */
186  double nn_tot();
187 
188  /** \brief Compute total density of protons
189  */
190  double np_tot();
191 
192  /** \brief Compute the number-averaged neutron number
193 
194  This function returns
195  \f$ \left<N\right> \equiv \sum_i n_i N_i / \sum_i n_i \f$ .
196  */
197  double average_N();
198 
199  /** \brief Compute the number-averaged proton number
200 
201  This function returns
202  \f$ \left<Z\right> \equiv \sum_i n_i Z_i / \sum_i n_i \f$ .
203  */
204  double average_Z();
205 
206  /** \brief Compute the impurity parameter
207 
208  This function returns the impurity parameter,
209  \f[
210  \left<Q\right> \equiv \left[\sum_i n_i \left(Z_i-\left<Z\right>
211  \right)^2 \right]
212  \left(\sum_i n_i\right)^{-1}
213  \f]
214  */
215  double impurity();
216 
217  /** \brief Compute the baryon density in nuclei
218 
219  This function returns \f$ \sum_i n_i A_i \f$ .
220  */
221  double baryon_density_nuclei();
222 
223  /** \brief Compute the total baryon density
224 
225  This function returns \f$ n_n + n_p + \sum_i n_i A_i \f$ .
226  */
227  double baryon_density();
228 
229  /** \brief Compute the electron fraction
230 
231  This function returns
232  \f[
233  \frac{1}{n_B} \left(n_p + \sum_i Z_i n_i \right)
234  \f]
235  where \f$ n_B \f$ is the value returned by \ref baryon_density() .
236  */
237  double electron_fraction();
238 
239  /** \brief Return true if nucleus (Z,N) is in the distribution and
240  store it's index in \c index
241 
242  This function performs a simple brute-force search.
243  */
244  bool nuc_in_dist(int Z, int N, size_t &index);
245 
246  /** \brief Remove nuclei from the distribution which have
247  a small density
248 
249  This function removes all nuclei which have densities
250  smaller than \c factor times the value returned
251  by \ref baryon_density_nuclei() .
252  */
253  void prune_distribution(double factor);
254 
255  /** \brief Copy densities from those stored in another
256  \ref dense_matter object
257 
258  This function sets all nuclear densities to zero and then, for
259  each nucleus in the distribution, looks for the same nucleus
260  in \c dm2. If the nucleus is found in \c dm2, its density is
261  copied over, otherwise its density is left at zero. This is a
262  brute-force algorithm of order \f$ {\cal O}(N_1 N_2) \f$ where
263  \f$ N_1 \f$ is the number of nuclei in the distribution and
264  \f$ N_2 \f$ is the number of nuclei in \c dm2.
265  */
267 
268  };
269 
270  /** \brief A nuclear mass formula for dense matter
271 
272  This class is experimental.
273 
274  The default set of nuclear masses is from the AME 2012
275  mass evaluation and is automatically loaded in the
276  constructor.
277 
278  \future If this isn't going to be in a child of \ref nucmass,
279  then maybe we can simplify \ref binding_energy_densmat_derivs()
280  to just <tt>binding_energy()</tt>.
281 
282  */
284 
285  protected:
286 
287  /** \brief Pointer to the nuclear mass formula
288  */
290 
291  public:
292 
293  /// Return the type, \c "nucmass_densmat".
294  virtual const char *type() { return "nucmass_densmat"; }
295 
296  nucmass_densmat();
297 
298  /// Set base nuclear masses
299  void set_mass(nucmass &nm);
300 
301  /** \brief Test the derivatives for
302  \ref binding_energy_densmat_derivs()
303  */
304  virtual void test_derivatives(double eps, double &t1, double &t2,
305  double &t3, double &t4);
306 
307  /** \brief Compute the binding energy of a nucleus in dense matter
308  and derivatives
309 
310  This function computes the binding energy of a nucleus in a
311  sea of protons, neutrons, and negative charges (usually
312  electrons) at a fixed temperature, relative to homogeneous
313  nucleonic matter with the same number densities of protons,
314  neutrons, and negative charges. The proton number Z and
315  neutron number N should also be counted relative to
316  homogeneous nucleonic matter, not relative to the vacuum.
317 
318  As in \ref o2scl::nucmass::binding_energy_d(), the binding
319  energy returned in \c E has units of MeV. All densities are
320  expected to be in \f$ \mathrm{fm}^{-3} \f$, and the
321  temperature should be in MeV.
322 
323  \future Extend to negative N and Z?
324  */
325  virtual void binding_energy_densmat_derivs
326  (double Z, double N, double npout, double nnout,
327  double nneg, double T, double &E, double &dEdnp, double &dEdnn,
328  double &dEdnneg, double &dEdT);
329 
330  /** \brief Compute the binding energy of a nucleus in dense matter
331  without the derivatives
332  */
333  virtual void binding_energy_densmat
334  (double Z, double N, double npout, double nnout,
335  double nneg, double T, double &E);
336 
337  };
338 
339 #ifndef DOXYGEN_NO_O2NS
340 }
341 #endif
342 
343 #endif
344 
o2scl::fermion mu
Muons.
double np_tot()
Compute total density of protons.
double baryon_density()
Compute the total baryon density.
dense_matter()
Constructor.
o2scl::fermion n
Neutrons.
Nuclear mass formula base [abstract base].
Definition: nucmass.h:201
std::vector< o2scl::nucleus > dist
Distribution of nuclei.
o2scl::boson photon
Photons.
Fermion class.
Definition: fermion.h:52
void copy_densities_from(dense_matter &dm2)
Copy densities from those stored in another dense_matter object.
dense_matter(const dense_matter &dm)
Copy constructor.
double impurity()
Compute the impurity parameter.
double average_A()
Compute the number-averaged mass number.
double eta_p
Proton chemical potential.
double eta_n
Neutron chemical potential.
void prune_distribution(double factor)
Remove nuclei from the distribution which have a small density.
o2scl::thermo th
Total thermodynamic quantities.
double Ye
Electron fraction.
double T
Temperature (in )
double nn_tot()
Compute total density of neutrons.
o2scl::fermion e
Electrons.
double baryon_density_nuclei()
Compute the baryon density in nuclei.
nucmass * massp
Pointer to the nuclear mass formula.
double electron_fraction()
Compute the electron fraction.
o2scl::thermo drip_th
Thermodynamic quantities for dripped particles.
A nuclear mass formula for dense matter.
double average_a()
Compute an average inter-ionic spacing.
double average_N()
Compute the number-averaged neutron number.
dense_matter & operator=(const dense_matter &dm)
Copy constructor with operator=()
o2scl::fermion p
Protons.
A container for the properties of dense matter at a specified baryon density, electron fraction and t...
double nB
Baryon number density (in )
virtual const char * type()
Return the type, "nucmass_densmat".
bool nuc_in_dist(int Z, int N, size_t &index)
Return true if nucleus (Z,N) is in the distribution and store it&#39;s index in index.
ubvector eta_nuc
Nuclear chemical potentials.
A class holding some useful thermodynamical variables (energy density, pressure, entropy density) ...
Definition: part.h:45
Boson class.
Definition: boson.h:46
double average_Z()
Compute the number-averaged proton number.

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