GammaLib  2.1.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-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 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 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 mass_density(const double& radius) const;
81  double jfactor(const double& angle) const;
82 
83 protected:
84  // Protected methods
85  void init_members(void);
87  void free_members(void);
88  virtual double profile_value(const double& theta) const;
89  void update(void) const;
90 
91  // Integration kernel for line-of-sight integral
92  class halo_kernel_los : public GFunction {
93  public :
94  halo_kernel_los(const double& scale_radius,
95  const double& halo_distance,
96  const double& alpha,
97  const double& theta,
98  const double& core_radius ) :
99  m_scale_radius(scale_radius),
100  m_halo_distance(halo_distance),
101  m_alpha(alpha),
102  m_theta(theta),
103  m_core_radius(core_radius) {}
104  double eval(const double& los);
105  protected :
108  double m_alpha;
109  double m_theta;
111  };
112 
113  // Protected members
114  GModelPar m_theta_min; //!< Minimum theta angle
115  GModelPar m_theta_max; //!< Maximum theta angle
116  GModelPar m_scale_radius; //!< Scale radius of halo profile
117  GModelPar m_scale_density; //!< Scale density of halo profile
118  GModelPar m_halo_distance; //!< Distance from earth to halo center
119  GModelPar m_alpha; //!< Einasto spatial power index
120  GModelPar m_core_radius; //!< Core radius
121 
122  // Cached members used for pre-computation
123  mutable double m_last_scale_radius;
124  mutable double m_last_scale_density;
125  mutable double m_mass_radius;
126  mutable double m_scale_density_squared;
127 };
128 
129 
130 /***********************************************************************//**
131  * @brief Return class name
132  *
133  * @return String containing the class name ("GModelSpatialRadialProfileDMEinasto").
134  ***************************************************************************/
135 inline
137 {
138  return ("GModelSpatialRadialProfileDMEinasto");
139 }
140 
141 
142 /***********************************************************************//**
143  * @brief Return scale radius
144  *
145  * @return scale radius (kpc).
146  *
147  * Returns the scale radius of the halo profile in kpc.
148  ***************************************************************************/
149 inline
151 {
152  return (m_scale_radius.value());
153 }
154 
155 
156 /***********************************************************************//**
157  * @brief Set scale radius
158  *
159  * @param[in] radius Scale radius (kpc).
160  *
161  * Sets the scale radius of the halo profile in kpc.
162  ***************************************************************************/
163 inline
165 {
166  m_scale_radius.value(radius);
167  return;
168 }
169 
170 
171 /***********************************************************************//**
172  * @brief Return scale density
173  *
174  * @return Scale density (GeV/cm^3).
175  *
176  * Returns the scale radius of the halo profile in kpc.
177  ***************************************************************************/
178 inline
180 {
181  return (m_scale_density.value());
182 }
183 
184 
185 /***********************************************************************//**
186  * @brief Set scale density
187  *
188  * @param[in] density Scale density (GeV/cm^3).
189  *
190  * Sets the scale density (mass/volume density at the scale radius) of
191  * the halo profile in GeV/cm^3.
192  ***************************************************************************/
193 inline
195 {
196  m_scale_density.value(density);
197  return;
198 }
199 
200 
201 /***********************************************************************//**
202  * @brief Return halo distance
203  *
204  * @return Halo distance (kpc).
205  *
206  * Returns the distance to the halo center in kpc.
207  ***************************************************************************/
208 inline
210 {
211  return (m_halo_distance.value());
212 }
213 
214 
215 /***********************************************************************//**
216  * @brief Set halo distance
217  *
218  * @param[in] distance Halo distance (kpc).
219  *
220  * Sets the distance between the observer and the halo center in kpc.
221  ***************************************************************************/
222 inline
224 {
225  m_halo_distance.value(distance);
226  return;
227 }
228 
229 
230 /***********************************************************************//**
231  * @brief Return Einasto alpha power index
232  *
233  * @return Einasto profile power index alpha (unitless).
234  *
235  * Returns the alpha power index in the Einasto halo density function.
236  ***************************************************************************/
237 inline
239 {
240  return (m_alpha.value());
241 }
242 
243 
244 /***********************************************************************//**
245  * @brief Set Einasto profile power index
246  *
247  * @param[in] alpha Einasto profile power index (unitless).
248  *
249  * Sets the Einasto profile power index, should be positive.
250  ***************************************************************************/
251 inline
253 {
254  m_alpha.value(alpha);
255  return;
256 }
257 
258 #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:48
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 angle(const GVector &a, const GVector &b)
Computes angle between vectors.
Definition: GVector.cpp:974
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 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.