nucmass_fit.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 NUCMASS_FIT_H
24 #define NUCMASS_FIT_H
25 
26 /** \file nucmass_fit.h
27  \brief File defining \ref o2scl::nucmass_fit
28 */
29 
30 #include <boost/numeric/ublas/vector.hpp>
31 
32 #include <o2scl/constants.h>
33 #include <o2scl/multi_funct.h>
34 #include <o2scl/mmin.h>
35 #include <o2scl/mmin_simp2.h>
36 #include <o2scl/nucmass.h>
37 #include <o2scl/nucmass_ame.h>
38 #include <o2scl/nucdist.h>
39 
40 #ifndef DOXYGEN_NO_O2NS
41 namespace o2scl {
42 #endif
43 
44  /** \brief Fit a nuclear mass formula
45 
46  There is an example of the usage of this class given in
47  \ref ex_nucmass_fit_sect.
48 
49  \future Convert to a real fit with errors and covariance, etc.
50  */
51  class nucmass_fit {
52 
53  public:
54 
58 
59  nucmass_fit();
60 
61  virtual ~nucmass_fit() {};
62 
63  /// \name Fitting method
64  //@{
65  /// Current fitting method
67  /// RMS deviation in mass excess
68  static const int rms_mass_excess=0;
69  /// RMS deviation in binding_energy
70  static const int rms_binding_energy=1;
71  /// Chi-squared for mass excess using specified uncertainties
72  static const int chi_squared_me=2;
73  /// Chi-squared for binding energy using specified uncertainties
74  static const int chi_squared_be=3;
75  //@}
76 
77  /// If true, then only fit doubly-even nuclei (default false)
78  bool even_even;
79 
80  /// Minimum proton number to fit (default 8)
81  int minZ;
82 
83  /// Minimum neutron number to fit (default 8)
84  int minN;
85 
86  /// Fit the nuclear mass formula
87  virtual void fit(nucmass_fit_base &n, double &res);
88 
89  /** \brief Evaluate quality without fitting
90  */
91  virtual void eval(nucmass &n, double &res);
92 
93  /** \brief The default minimizer
94 
95  The value of def_mmin::ntrial is automatically multiplied by
96  10 in the constructor because the minimization frequently
97  requires more trials than the default.
98  */
100 
101  /// Change the minimizer for use in the fit
102  void set_mmin(mmin_base<> &umm) {
103  mm=&umm;
104  return;
105  }
106 
107  /** \brief Select the experimental nuclei to fit
108  */
109  std::vector<nucleus> dist;
110 
111  /** \brief Set the fit uncertainties (in MeV)
112  */
113  template<class vec_t> void set_uncerts(vec_t &u) {
114  size_t nv=u.size();
115  set_uncerts(nv,u);
116  return;
117  }
118 
119  /** \brief Set the fit uncertainties (in MeV) from the first \c nv
120  elements of \c u
121  */
122  template<class vec_t> void set_uncerts(size_t nv, vec_t &u) {
123  if (nv==0) {
124  O2SCL_ERR2("Tried to give zero uncertainties in nucmass_fit::",
125  "set_uncerts().",exc_efailed);
126  }
127  if (uncs.size()>0) uncs.clear();
128  uncs.resize(nv);
129  vector_copy(nv,u,uncs);
130  return;
131  }
132 
133  /** \brief Evaluate isospin dependence of fit quality
134 
135  \todo More documentation and compute uncertainty
136  */
137  void eval_isospin_beta(nucmass &n, ubvector_int &n_qual,
138  ubvector &qual, int max_iso=20);
139 
140  /** \brief Evaluate isospin dependence of fit quality
141  */
142  void eval_isospin(nucmass &n, ubvector_int &n_qual,
143  ubvector &qual, int min_iso=-8, int max_iso=60);
144 
145  /** \brief The function to minimize
146  */
147  virtual double min_fun(size_t nv, const ubvector &x);
148 
149  protected:
150 
151 #ifndef DOXYGEN_NO_O2NS
152 
153  /// Uncertainties
155 
156  /// The pointer to the minimizer
158 
159  /** \brief The nuclear mass formula to fit to
160 
161  This pointer is set by fit() and eval().
162  */
164 
165 #endif
166 
167  };
168 
169 #ifndef DOXYGEN_NO_O2NS
170 }
171 #endif
172 
173 #endif
o2scl::mmin_simp2
boost::numeric::ublas::vector
exc_efailed
exc_efailed
o2scl::nucmass_fit::rms_mass_excess
static const int rms_mass_excess
RMS deviation in mass excess.
Definition: nucmass_fit.h:68
O2SCL_ERR2
#define O2SCL_ERR2(d, d2, n)
o2scl::nucmass_fit::minN
int minN
Minimum neutron number to fit (default 8)
Definition: nucmass_fit.h:84
o2scl::nucmass_fit::eval_isospin_beta
void eval_isospin_beta(nucmass &n, ubvector_int &n_qual, ubvector &qual, int max_iso=20)
Evaluate isospin dependence of fit quality.
vector_copy
void vector_copy(const vec_t &src, vec2_t &dest)
o2scl::nucmass_fit::chi_squared_be
static const int chi_squared_be
Chi-squared for binding energy using specified uncertainties.
Definition: nucmass_fit.h:74
o2scl::nucmass_fit::eval
virtual void eval(nucmass &n, double &res)
Evaluate quality without fitting.
o2scl::nucmass_fit::even_even
bool even_even
If true, then only fit doubly-even nuclei (default false)
Definition: nucmass_fit.h:78
o2scl::nucmass_fit::def_mmin
mmin_simp2 def_mmin
The default minimizer.
Definition: nucmass_fit.h:99
o2scl::nucmass_fit::dist
std::vector< nucleus > dist
Select the experimental nuclei to fit.
Definition: nucmass_fit.h:109
o2scl::nucmass_fit::nmf
nucmass_fit_base * nmf
The nuclear mass formula to fit to.
Definition: nucmass_fit.h:163
o2scl::nucmass_fit
Fit a nuclear mass formula.
Definition: nucmass_fit.h:51
o2scl::nucmass_fit::chi_squared_me
static const int chi_squared_me
Chi-squared for mass excess using specified uncertainties.
Definition: nucmass_fit.h:72
o2scl::nucmass_fit_base
Fittable mass formula [abstract base].
Definition: nucmass.h:375
o2scl::nucmass_fit::minZ
int minZ
Minimum proton number to fit (default 8)
Definition: nucmass_fit.h:81
o2scl::nucmass_fit::uncs
ubvector uncs
Uncertainties.
Definition: nucmass_fit.h:154
o2scl::nucmass_fit::set_uncerts
void set_uncerts(vec_t &u)
Set the fit uncertainties (in MeV)
Definition: nucmass_fit.h:113
o2scl::nucmass_fit::set_mmin
void set_mmin(mmin_base<> &umm)
Change the minimizer for use in the fit.
Definition: nucmass_fit.h:102
o2scl::nucmass_fit::mm
mmin_base * mm
The pointer to the minimizer.
Definition: nucmass_fit.h:157
o2scl::nucmass_fit::set_uncerts
void set_uncerts(size_t nv, vec_t &u)
Set the fit uncertainties (in MeV) from the first nv elements of u.
Definition: nucmass_fit.h:122
o2scl::nucmass_fit::min_fun
virtual double min_fun(size_t nv, const ubvector &x)
The function to minimize.
o2scl::nucmass
Nuclear mass formula base [abstract base].
Definition: nucmass.h:206
o2scl::mmin_base
o2scl::nucmass_fit::fit_method
int fit_method
Current fitting method.
Definition: nucmass_fit.h:66
o2scl::nucmass_fit::rms_binding_energy
static const int rms_binding_energy
RMS deviation in binding_energy.
Definition: nucmass_fit.h:70
o2scl::nucmass_fit::eval_isospin
void eval_isospin(nucmass &n, ubvector_int &n_qual, ubvector &qual, int min_iso=-8, int max_iso=60)
Evaluate isospin dependence of fit quality.
o2scl::nucmass_fit::fit
virtual void fit(nucmass_fit_base &n, double &res)
Fit the nuclear mass formula.

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