GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpatialRadialProfileDMZhao.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelSpatialRadialProfileDMZhao.hpp - DM Zhao profile class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2016-2020 by Nathan Kelley-Hoskins *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 /**
22  * @file GModelSpatialRadialProfileDMZhao.hpp
23  * @brief Dark Matter Zhao profile model class interface definition
24  * @author Nathan Kelley-Hoskins
25  */
26 
27 #ifndef GMODELSPATIALRADIALPROFILEDMZHAO_HPP
28 #define GMODELSPATIALRADIALPROFILEDMZHAO_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
33 #include "GModelPar.hpp"
34 #include "GFunction.hpp"
35 #include "GIntegral.hpp"
36 
37 /* __ Forward declaration ________________________________________________ */
38 class GXmlElement;
39 
40 
41 /**************************************************************************
42  * @class GModelSpatialRadialProfileDMZhao
43  *
44  * @brief Radial Dark Matter Zhao profile source model class
45  *
46  * This class implements the spatial component of the factorised source
47  * model for a radial Dark Matter profile, using an Zhao density halo.
48  ***************************************************************************/
50 
51 public:
52  // Constructors and destructors
54  explicit GModelSpatialRadialProfileDMZhao(const GXmlElement& xml);
57 
58  // Operators
60 
61  // Implemented pure virtual base class methods
62  virtual void clear(void);
63  virtual GModelSpatialRadialProfileDMZhao* clone(void) const;
64  virtual std::string classname(void) const;
65  virtual double theta_min(void) const;
66  virtual double theta_max(void) const;
67  virtual void read(const GXmlElement& xml);
68  virtual void write(GXmlElement& xml) const;
69  virtual std::string print(const GChatter& chatter = NORMAL) const;
70 
71  // Other methods
72  double scale_radius(void) const;
73  void scale_radius(const double& scale_radius);
74  double scale_density(void) const;
75  void scale_density(const double& scale_density);
76  double halo_distance(void) const;
77  void halo_distance(const double& halo_distance);
78  double alpha(void) const;
79  void alpha(const double& alpha);
80  double beta(void) const;
81  void beta(const double& beta);
82  double gamma(void) const;
83  void gamma(const double& gamma);
84  double mass_density(const double& radius) const;
85  double jfactor(const double& angle) const;
86 
87 protected:
88  // Protected methods
89  void init_members(void);
91  void free_members(void);
92  void update(void) const;
93  virtual double profile_value(const double& theta) const;
94 
95  // Integration kernel for line-of-sight integral
96  class halo_kernel_los : public GFunction {
97  public :
98  halo_kernel_los(const double& scale_radius,
99  const double& halo_distance,
100  const double& alpha,
101  const double& beta,
102  const double& gamma,
103  const double& theta,
104  const double& core_radius) :
105  m_scale_radius(scale_radius),
106  m_halo_distance(halo_distance),
107  m_alpha(alpha),
108  m_beta(beta),
109  m_gamma(gamma),
110  m_theta(theta),
111  m_core_radius(core_radius) {}
112  double eval(const double& los);
113  protected :
116  double m_alpha;
117  double m_beta;
118  double m_gamma;
119  double m_theta;
121  } ;
122 
123  // Protected members
124  GModelPar m_theta_min; //!< Minimum theta angle
125  GModelPar m_theta_max; //!< Maximum theta angle
126  GModelPar m_scale_radius; //!< Scale radius of halo profile
127  GModelPar m_scale_density; //!< Scale density of halo profile
128  GModelPar m_halo_distance; //!< Distance from earth to halo center
129  GModelPar m_alpha; //!< Power index, inverse transition region width
130  GModelPar m_beta; //!< Power index, slope at >> m_scale_radius
131  GModelPar m_gamma; //!< Power index, slope at << m_scale_radius
132  GModelPar m_core_radius; //!< Core radius
133 
134  // Protected cached members
135  mutable double m_last_scale_radius;
136  mutable double m_last_scale_density;
137  mutable double m_mass_radius;
138  mutable double m_scale_density_squared;
139 };
140 
141 
142 /***********************************************************************//**
143  * @brief Return class name
144  *
145  * @return String containing the class name ("GModelSpatialRadialProfileDMZhao").
146  ***************************************************************************/
147 inline
149 {
150  return ("GModelSpatialRadialProfileDMZhao");
151 }
152 
153 
154 /***********************************************************************//**
155  * @brief Return scale radius
156  *
157  * @return Scale radius (kpc).
158  *
159  * Returns the scale radius of the halo profile in kpc.
160  ***************************************************************************/
161 inline
163 {
164  return (m_scale_radius.value());
165 }
166 
167 
168 /***********************************************************************//**
169  * @brief Set scale radius
170  *
171  * @param[in] radius Scale radius (kpc).
172  *
173  * Sets the scale radius of the halo profile in kpc.
174  ***************************************************************************/
175 inline
177 {
178  m_scale_radius.value(radius);
179  return;
180 }
181 
182 
183 /***********************************************************************//**
184  * @brief Return scale density
185  *
186  * @return Scale density (GeV/cm^3).
187  *
188  * Returns the scale density (mass/volume density at the scale radius) of
189  * the halo profile in GeV/cm^3.
190  ***************************************************************************/
191 inline
193 {
194  return (m_scale_density.value());
195 }
196 
197 
198 /***********************************************************************//**
199  * @brief Set scale density
200  *
201  * @param[in] density Scale density (GeV/cm^3).
202  *
203  * Sets the scale density (mass/volume density at the scale radius) of the
204  * halo profile in GeV/cm^3.
205  ***************************************************************************/
206 inline
208 {
209  m_scale_density.value(density);
210  return;
211 }
212 
213 
214 /***********************************************************************//**
215  * @brief Return halo distance
216  *
217  * @return Halo distance (kpc).
218  *
219  * Returns the distance to the halo center in kpc.
220  ***************************************************************************/
221 inline
223 {
224  return (m_halo_distance.value());
225 }
226 
227 
228 /***********************************************************************//**
229  * @brief Set halo distance
230  *
231  * @param[in] distance Halo distance (kpc).
232  *
233  * Sets the distance between the observer and the halo center in kpc.
234  ***************************************************************************/
235 inline
237 {
238  m_halo_distance.value(distance);
239  return;
240 }
241 
242 
243 /***********************************************************************//**
244  * @brief Return Zhao alpha power index
245  *
246  * @return alpha (unitless).
247  *
248  * Returns the alpha power index in the Zhao halo density function
249  ***************************************************************************/
250 inline
252 {
253  return (m_alpha.value());
254 }
255 
256 
257 /***********************************************************************//**
258  * @brief Set Zhao alpha power index
259  *
260  * @param[in] alpha (unitless).
261  *
262  * Sets the Zhao profile alpha power index.
263  ***************************************************************************/
264 inline
266 {
267  m_alpha.value(alpha);
268  return;
269 }
270 
271 
272 /***********************************************************************//**
273  * @brief Return Zhao beta power index
274  *
275  * @return beta (unitless).
276  *
277  * Returns the beta power index in the Zhao halo density function
278  ***************************************************************************/
279 inline
281 {
282  return (m_beta.value());
283 }
284 
285 
286 /***********************************************************************//**
287  * @brief Set Zhao beta power index
288  *
289  * @param[in] beta (unitless).
290  *
291  * Sets the Zhao profile beta power index.
292  ***************************************************************************/
293 inline
295 {
296  m_beta.value(beta);
297  return;
298 }
299 
300 
301 /***********************************************************************//**
302  * @brief Return Zhao gamma power index
303  *
304  * @return gamma (unitless).
305  *
306  * Returns the gamma power index in the Zhao halo density function
307  ***************************************************************************/
308 inline
310 {
311  return (m_gamma.value());
312 }
313 
314 
315 /***********************************************************************//**
316  * @brief Set Zhao gamma power index
317  *
318  * @param[in] gamma (unitless).
319  *
320  * Sets the Zhao profile gamma power index.
321  ***************************************************************************/
322 inline
324 {
325  m_gamma.value(gamma);
326  return;
327 }
328 
329 #endif /* GMODELSPATIALRADIALPROFILEDMZHAO_HPP */
virtual double theta_min(void) const
Return minimum model radius (in radians)
double scale_radius(void) const
Return scale radius.
GModelPar m_alpha
Power index, inverse transition region width.
GModelPar m_beta
Power index, slope at &gt;&gt; m_scale_radius.
GModelPar m_gamma
Power index, slope at &lt;&lt; m_scale_radius.
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual GModelSpatialRadialProfileDMZhao * clone(void) const
Clone radial DMZhao profile model.
GModelPar m_scale_radius
Scale radius of halo profile.
XML element node class.
Definition: GXmlElement.hpp:48
virtual void clear(void)
Clear radial DMZhao profile model.
double gamma(void) const
Return Zhao gamma power index.
Radial profile model class interface definition.
double halo_distance(void) const
Return halo distance.
virtual void write(GXmlElement &xml) const
Write model into XML element.
Model parameter class interface definition.
Model parameter class.
Definition: GModelPar.hpp:87
double beta(void) const
Return Zhao beta power index.
Single parameter function abstract base class definition.
double mass_density(const double &radius) const
Calculate Halo Mass Density.
halo_kernel_los(const double &scale_radius, const double &halo_distance, const double &alpha, const double &beta, const double &gamma, const double &theta, const double &core_radius)
virtual GModelSpatialRadialProfileDMZhao & operator=(const GModelSpatialRadialProfileDMZhao &model)
Assignment operator.
GChatter
Definition: GTypemaps.hpp:33
double angle(const GVector &a, const GVector &b)
Computes angle between vectors.
Definition: GVector.cpp:974
virtual double profile_value(const double &theta) const
Radial profile.
double alpha(void) const
Return Zhao alpha power index.
void copy_members(const GModelSpatialRadialProfileDMZhao &model)
Copy class members.
void init_members(void)
Initialise class members.
void update(void) const
Update precomputation cache.
GModelPar m_scale_density
Scale density of halo profile.
virtual std::string classname(void) const
Return class name.
GModelPar m_halo_distance
Distance from earth to halo center.
double jfactor(const double &angle) const
Calculate J-factor.
double value(void) const
Return parameter value.
Single parameter function abstract base class.
Definition: GFunction.hpp:44
double scale_density(void) const
Return scale density.
virtual double theta_max(void) const
Return maximum model radius (in radians)
Integration class interface definition.
double eval(const double &los)
Kernel for zhao halo density profile squared.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print information.