GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpatialRadialProfileDMEinasto.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelSpatialRadialProfileDMEinasto.hpp - DM Einasto profile class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2016-2017 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 GModelSpatialRadialProfileDMEinasto.hpp
23  * @brief Dark Matter Einasto profile model class interface definition
24  * @author Nathan Kelley-Hoskins
25  */
26 
27 #ifndef GMODELSPATIALRADIALPROFILEDMEINASTO_HPP
28 #define GMODELSPATIALRADIALPROFILEDMEINASTO_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 GModelSpatialRadialProfileDMEinasto
43  *
44  * @brief Radial Dark Matter Einasto 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 Einasto density halo.
48  ***************************************************************************/
50 
51 public:
52  // Constructors and destructors
57 
58  // Operators
60 
61  // Implemented pure virtual base class methods
62  virtual void clear(void);
63  virtual GModelSpatialRadialProfileDMEinasto* clone(void) const;
64  virtual std::string classname(void) const;
65  virtual std::string type(void) const;
66  virtual double theta_min(void) const;
67  virtual double theta_max(void) const;
68  virtual void read(const GXmlElement& xml);
69  virtual void write(GXmlElement& xml) const;
70  virtual std::string print(const GChatter& chatter = NORMAL) const;
71 
72  // Other methods
73  double scale_radius(void) const;
74  void scale_radius(const double& scale_radius);
75  double scale_density(void) const;
76  void scale_density(const double& scale_density);
77  double halo_distance(void) const;
78  void halo_distance(const double& halo_distance);
79  double alpha(void) const;
80  void alpha(const double& alpha);
81  double mass_density(const double& radius) const;
82  double jfactor(const double& angle) const;
83 
84 protected:
85  // Protected methods
86  void init_members(void);
88  void free_members(void);
89  virtual double profile_value(const double& theta) const;
90  void update(void) const;
91 
92  // Integration kernel for line-of-sight integral
93  class halo_kernel_los : public GFunction {
94  public :
95  halo_kernel_los(const double& scale_radius,
96  const double& halo_distance,
97  const double& alpha,
98  const double& theta,
99  const double& core_radius ) :
100  m_scale_radius(scale_radius),
101  m_halo_distance(halo_distance),
102  m_alpha(alpha),
103  m_theta(theta),
104  m_core_radius(core_radius) {}
105  double eval(const double& los);
106  protected :
109  double m_alpha;
110  double m_theta;
112  };
113 
114  // Protected members
115  GModelPar m_theta_min; //!< Minimum theta angle
116  GModelPar m_theta_max; //!< Maximum theta angle
117  GModelPar m_scale_radius; //!< Scale radius of halo profile
118  GModelPar m_scale_density; //!< Scale density of halo profile
119  GModelPar m_halo_distance; //!< Distance from earth to halo center
120  GModelPar m_alpha; //!< Einasto spatial power index
121  GModelPar m_core_radius; //!< Core radius
122 
123  // Cached members used for pre-computation
124  mutable double m_last_scale_radius;
125  mutable double m_last_scale_density;
126  mutable double m_mass_radius;
127  mutable double m_scale_density_squared;
128 };
129 
130 
131 /***********************************************************************//**
132  * @brief Return class name
133  *
134  * @return String containing the class name ("GModelSpatialRadialProfileDMEinasto").
135  ***************************************************************************/
136 inline
138 {
139  return ("GModelSpatialRadialProfileDMEinasto");
140 }
141 
142 
143 /***********************************************************************//**
144  * @brief Return model type
145  *
146  * @return "DMEinastoProfile".
147  *
148  * Returns the type of the radial profile model.
149  ***************************************************************************/
150 inline
152 {
153  return "DMEinastoProfile";
154 }
155 
156 /***********************************************************************//**
157  * @brief Return scale radius
158  *
159  * @return scale radius (kpc).
160  *
161  * Returns the scale radius of the halo profile in kpc.
162  ***************************************************************************/
163 inline
165 {
166  return (m_scale_radius.value());
167 }
168 
169 /***********************************************************************//**
170  * @brief Set scale radius
171  *
172  * @param[in] radius Scale radius (kpc).
173  *
174  * Sets the scale radius of the halo profile in kpc.
175  ***************************************************************************/
176 inline
178 {
179  m_scale_radius.value(radius);
180  return;
181 }
182 
183 /***********************************************************************//**
184  * @brief Return scale density
185  *
186  * @return Scale density (GeV/cm^3).
187  *
188  * Returns the scale radius of the halo profile in kpc.
189  ***************************************************************************/
190 inline
192 {
193  return (m_scale_density.value());
194 }
195 
196 /***********************************************************************//**
197  * @brief Set scale density
198  *
199  * @param[in] density Scale density (GeV/cm^3).
200  *
201  * Sets the scale density (mass/volume density at the scale radius) of
202  * the halo profile in GeV/cm^3.
203  ***************************************************************************/
204 inline
206 {
207  m_scale_density.value(density);
208  return;
209 }
210 
211 /***********************************************************************//**
212  * @brief Return halo distance
213  *
214  * @return Halo distance (kpc).
215  *
216  * Returns the distance to the halo center in kpc.
217  ***************************************************************************/
218 inline
220 {
221  return (m_halo_distance.value());
222 }
223 
224 /***********************************************************************//**
225  * @brief Set halo distance
226  *
227  * @param[in] distance Halo distance (kpc).
228  *
229  * Sets the distance between the observer and the halo center in kpc.
230  ***************************************************************************/
231 inline
233 {
234  m_halo_distance.value(distance);
235  return;
236 }
237 
238 /***********************************************************************//**
239  * @brief Return Einasto alpha power index
240  *
241  * @return Einasto profile power index alpha (unitless).
242  *
243  * Returns the alpha power index in the Einasto halo density function.
244  ***************************************************************************/
245 inline
247 {
248  return (m_alpha.value());
249 }
250 
251 /***********************************************************************//**
252  * @brief Set Einasto profile power index
253  *
254  * @param[in] alpha Einasto profile power index (unitless).
255  *
256  * Sets the Einasto profile power index, should be positive.
257  ***************************************************************************/
258 inline
260 {
261  m_alpha.value(alpha);
262  return;
263 }
264 
265 #endif /* GMODELSPATIALRADIALPROFILEDMEINASTO_HPP */
GModelPar m_scale_density
Scale density of halo profile.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print information.
virtual double profile_value(const double &theta) const
Radial profile.
XML element node class.
Definition: GXmlElement.hpp:47
GModelPar m_alpha
Einasto spatial power index.
double scale_density(void) const
Return scale density.
virtual double theta_max(void) const
Return maximum model radius (in radians)
Radial profile model class interface definition.
GModelPar m_halo_distance
Distance from earth to halo center.
halo_kernel_los(const double &scale_radius, const double &halo_distance, const double &alpha, const double &theta, const double &core_radius)
Model parameter class interface definition.
Model parameter class.
Definition: GModelPar.hpp:87
virtual GModelSpatialRadialProfileDMEinasto * clone(void) const
Clone radial DMEinasto profile model.
Single parameter function abstract base class definition.
virtual double theta_min(void) const
Return minimum model radius (in radians)
GModelPar m_scale_radius
Scale radius of halo profile.
virtual void write(GXmlElement &xml) const
Write model into XML element.
double jfactor(const double &angle) const
Calculate J-factor.
GChatter
Definition: GTypemaps.hpp:33
double mass_density(const double &radius) const
Calculate halo mass density.
double alpha(void) const
Return Einasto alpha power index.
virtual void read(const GXmlElement &xml)
Read model from XML element.
void copy_members(const GModelSpatialRadialProfileDMEinasto &model)
Copy class members.
double scale_radius(void) const
Return scale radius.
double value(void) const
Return parameter value.
Single parameter function abstract base class.
Definition: GFunction.hpp:44
virtual void clear(void)
Clear radial DMEinasto profile model.
virtual GModelSpatialRadialProfileDMEinasto & operator=(const GModelSpatialRadialProfileDMEinasto &model)
Assignment operator.
virtual std::string type(void) const
Return model type.
virtual std::string classname(void) const
Return class name.
void update(void) const
Update precomputation cache.
double halo_distance(void) const
Return halo distance.
Integration class interface definition.
double eval(const double &los)
Kernel for halo density profile squared.