GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpatialRadialProfileDMZhao.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelSpatialRadialProfileDMZhao.cpp - Zhao radial 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 GModelSpatialRadialProfileDMZhao.cpp
23  * @brief Radial DM Einasto profile model class implementation
24  * @author Nathan Kelley-Hoskins
25  */
26 
27 /* __ Includes ___________________________________________________________ */
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 #include "GException.hpp"
32 #include "GTools.hpp"
33 #include "GMath.hpp"
34 #include "GXmlElement.hpp"
37 
38 /* __ Constants __________________________________________________________ */
39 
40 /* __ Globals ____________________________________________________________ */
42 const GModelSpatialRegistry g_radial_disk_registry(&g_radial_disk_seed);
43 
44 /* __ Method name definitions ____________________________________________ */
45 #define G_READ "GModelSpatialRadialProfileDMZhao::read(GXmlElement&)"
46 #define G_WRITE "GModelSpatialRadialProfileDMZhao::write(GXmlElement&)"
47 
48 /* __ Macros _____________________________________________________________ */
49 
50 /* __ Coding definitions _________________________________________________ */
51 
52 /* __ Debug definitions __________________________________________________ */
53 
54 
55 /*==========================================================================
56  = =
57  = Constructors/destructors =
58  = =
59  ==========================================================================*/
60 
61 /***********************************************************************//**
62  * @brief Void constructor
63  *
64  * Constructs empty radial DMZhao profile
65  ***************************************************************************/
68 {
69  // Initialise members
70  init_members();
71 
72  // Return
73  return;
74 }
75 
76 
77 /***********************************************************************//**
78  * @brief XML constructor
79  *
80  * @param[in] xml XML element.
81  *
82  * Constructs radial DMZhao profile model by extracting information from
83  * an XML element. See the read() method for more information about the
84  * expected structure of the XML element.
85  ***************************************************************************/
88 {
89  // Initialise members
90  init_members();
91 
92  // Read information from XML element
93  read(xml);
94 
95  // Return
96  return;
97 }
98 
99 
100 /***********************************************************************//**
101  * @brief Copy constructor
102  *
103  * @param[in] model Radial DMZhao profile model.
104  *
105  * Copies radial DMZhao profile model from another radial profile model.
106  ***************************************************************************/
109 {
110  // Initialise members
111  init_members();
112 
113  // Copy members
114  copy_members(model);
115 
116  // Return
117  return;
118 }
119 
120 
121 /***********************************************************************//**
122  * @brief Destructor
123  *
124  * Destructs radial DMZhao profile model.
125  ***************************************************************************/
127 {
128  // Free members
129  free_members();
130 
131  // Return
132  return;
133 }
134 
135 
136 /*==========================================================================
137  = =
138  = Operators =
139  = =
140  ==========================================================================*/
141 
142 /***********************************************************************//**
143  * @brief Assignment operator
144  *
145  * @param[in] model Radial DMZhao profile model.
146  * @return Radial DMZhao profile model.
147  *
148  * Assigns radial DMZhao profile model.
149  ***************************************************************************/
151 {
152  // Execute only if object is not identical
153  if (this != &model) {
154 
155  // Copy base class members
157 
158  // Free members
159  free_members();
160 
161  // Initialise members
162  init_members();
163 
164  // Copy members
165  copy_members(model);
166 
167  } // endif: object was not identical
168 
169  // Return
170  return *this;
171 }
172 
173 
174 /*==========================================================================
175  = =
176  = Public methods =
177  = =
178  ==========================================================================*/
179 
180 /***********************************************************************//**
181  * @brief Clear radial DMZhao profile model
182  *
183  * Clears radial DMZhao profile model.
184  ***************************************************************************/
186 {
187  // Free class members
188  free_members();
192 
193  // Initialise members
197  init_members();
198 
199  // Return
200  return;
201 }
202 
203 
204 /***********************************************************************//**
205  * @brief Clone radial DMZhao profile model
206  *
207  * @return Pointer to deep copy of radial DMZhao profile model.
208  *
209  * Returns a deep copy of the radial DMZhao profile model.
210  ***************************************************************************/
212 {
213  // Clone radial disk model
214  return new GModelSpatialRadialProfileDMZhao(*this);
215 }
216 
217 /***********************************************************************//**
218  * @brief Return minimum model radius (in radians)
219  *
220  * @return Minimum model radius (in radians).
221  ***************************************************************************/
223 {
224 
225  // update precomputation cache
226  update();
227 
228  // Return value
229  return m_theta_min.value();
230 }
231 
232 
233 /***********************************************************************//**
234  * @brief Return maximum model radius (in radians)
235  *
236  * @return Maximum model radius (in radians).
237  ***************************************************************************/
239 {
240  // Update precomputation cache
241  update();
242 
243  // Initialize maximum theta angle
244  double theta = 0.0;
245 
246  // If Earth is within the significant radius, then theta_max must
247  // contain the entire profile (180deg) ...
249  theta = gammalib::pi;
250  }
251 
252  // ... otherwise, if the halo is far enough away (further than the
253  // significant radius) then we just need to deal with the angles within
254  // the sphere of the significant radius.
255  else {
257  }
258 
259  // Always chose the lesser of ( mass_radius theta, theta_max )
261  if (theta_max < theta) {
262  theta = theta_max;
263  }
264 
265  // Return value
266  return theta;
267 }
268 
269 
270 /***********************************************************************//**
271  * @brief Read model from XML element
272  *
273  * @param[in] xml XML element.
274  *
275  * Reads the DMZhao radial profile model information from an XML element.
276  * The XML element shall have the format
277  *
278  * <spatialModel type="DMZhaoProfile">
279  * <parameter name="RA" scale=.. value=.. min=.. max=.. free=../>
280  * <parameter name="DEC" scale=.. value=.. min=.. max=.. free=../>
281  * <parameter name="ScaleRadius" scale=.. value=.. min=.. max=.. free=../>
282  * <parameter name="ScaleDensity" scale=.. value=.. min=.. max=.. free=../>
283  * <parameter name="HaloDistance" scale=.. value=.. min=.. max=.. free=../>
284  * <parameter name="Alpha" scale=.. value=.. min=.. max=.. free=../>
285  * <parameter name="Beta" scale=.. value=.. min=.. max=.. free=../>
286  * <parameter name="Gamma" scale=.. value=.. min=.. max=.. free=../>
287  * <parameter name="ThetaMin" scale=.. value=.. min=.. max=.. free=../>
288  * <parameter name="ThetaMax" scale=.. value=.. min=.. max=.. free=../>
289  * <parameter name="CoreRadius" scale=.. value=.. min=.. max=.. free=../>
290  * </spatialModel>
291  ***************************************************************************/
293 {
294  // Read halo sky coordinate
296 
297  // Read ScaleRadius parameter
298  const GXmlElement* par1 = gammalib::xml_get_par(G_READ, xml, "ScaleRadius");
299  m_scale_radius.read(*par1);
300 
301  // Read ScaleDensity parameter
302  const GXmlElement* par2 = gammalib::xml_get_par(G_READ, xml, "ScaleDensity");
303  m_scale_density.read(*par2);
304 
305  // Read HaloDistance parameter
306  const GXmlElement* par3 = gammalib::xml_get_par(G_READ, xml, "HaloDistance");
307  m_halo_distance.read(*par3);
308 
309  // Read Alpha parameter
310  const GXmlElement* par4 = gammalib::xml_get_par(G_READ, xml, "Alpha");
311  m_alpha.read(*par4);
312 
313  // Read Beta parameter
314  const GXmlElement* par5 = gammalib::xml_get_par(G_READ, xml, "Beta");
315  m_beta.read(*par5);
316 
317  // Read Gamma parameter
318  const GXmlElement* par6 = gammalib::xml_get_par(G_READ, xml, "Gamma");
319  m_gamma.read(*par6);
320 
321  // Read ThetaMin parameter
322  const GXmlElement* par7 = gammalib::xml_get_par(G_READ, xml, "ThetaMin");
323  m_theta_min.read(*par7);
324 
325  // Read ThetaMax parameter
326  const GXmlElement* par8 = gammalib::xml_get_par(G_READ, xml, "ThetaMax");
327  m_theta_max.read(*par8);
328 
329  // Read CoreRadius parameter
330  const GXmlElement* par9 = gammalib::xml_get_par(G_READ, xml, "CoreRadius");
331  m_core_radius.read(*par9);
332 
333  // Return
334  return;
335 }
336 
337 
338 /***********************************************************************//**
339  * @brief Write model into XML element
340  *
341  * @param[in] xml XML element into which model information is written.
342  *
343  * Writes the DMZhao radial profile model information into an XML element.
344  * The XML element will have the format
345  *
346  * <spatialModel type="DMZhaoProfile">
347  * <parameter name="RA" scale=.. value=.. min=.. max=.. free=../>
348  * <parameter name="DEC" scale=.. value=.. min=.. max=.. free=../>
349  * <parameter name="ScaleRadius" scale=.. value=.. min=.. max=.. free=../>
350  * <parameter name="ScaleDensity" scale=.. value=.. min=.. max=.. free=../>
351  * <parameter name="HaloDistance" scale=.. value=.. min=.. max=.. free=../>
352  * <parameter name="Alpha" scale=.. value=.. min=.. max=.. free=../>
353  * <parameter name="Beta" scale=.. value=.. min=.. max=.. free=../>
354  * <parameter name="Gamma" scale=.. value=.. min=.. max=.. free=../>
355  * <parameter name="ThetaMin" scale=.. value=.. min=.. max=.. free=../>
356  * <parameter name="ThetaMax" scale=.. value=.. min=.. max=.. free=../>
357  * <parameter name="CoreRadius" scale=.. value=.. min=.. max=.. free=../>
358  * </spatialModel>
359  ***************************************************************************/
361 {
362  // Write DMZhao location
364 
365  // Write ScaleRadius parameter
366  GXmlElement* par1 = gammalib::xml_need_par(G_WRITE, xml, "ScaleRadius");
367  m_scale_radius.write(*par1);
368 
369  // Write ScaleDensity parameter
370  GXmlElement* par2 = gammalib::xml_need_par(G_WRITE, xml, "ScaleDensity");
371  m_scale_density.write(*par2);
372 
373  // Write HaloDistance parameter
374  GXmlElement* par3 = gammalib::xml_need_par(G_WRITE, xml, "HaloDistance");
375  m_halo_distance.write(*par3);
376 
377  // Write Alpha parameter
378  GXmlElement* par4 = gammalib::xml_need_par(G_WRITE, xml, "Alpha");
379  m_alpha.write(*par4);
380 
381  // Write Beta parameter
382  GXmlElement* par5 = gammalib::xml_need_par(G_WRITE, xml, "Beta");
383  m_beta.write(*par5);
384 
385  // Write Gamma parameter
386  GXmlElement* par6 = gammalib::xml_need_par(G_WRITE, xml, "Gamma");
387  m_gamma.write(*par6);
388 
389  // Write ThetaMax parameter
390  GXmlElement* par7 = gammalib::xml_need_par(G_WRITE, xml, "ThetaMin");
391  m_theta_min.write(*par7);
392 
393  // Write ThetaMax parameter
394  GXmlElement* par8 = gammalib::xml_need_par(G_WRITE, xml, "ThetaMax");
395  m_theta_max.write(*par8);
396 
397  // Write CoreRadius parameter
398  GXmlElement* par9 = gammalib::xml_need_par(G_WRITE, xml, "CoreRadius");
399  m_core_radius.write(*par9);
400 
401  // Return
402  return;
403 }
404 
405 
406 /***********************************************************************//**
407  * @brief Print information
408  *
409  * @param[in] chatter Chattiness.
410  * @return String containing model information.
411  ***************************************************************************/
412 std::string GModelSpatialRadialProfileDMZhao::print(const GChatter& chatter) const
413 {
414  // Initialise result string
415  std::string result;
416 
417  // Continue only if chatter is not silent
418  if (chatter != SILENT) {
419 
420  // Append header
421  result.append("=== GModelSpatialRadialProfileDMZhao ===");
422 
423  // Append parameters
424  result.append("\n"+gammalib::parformat("Number of parameters"));
425  result.append(gammalib::str(size()));
426  for (int i = 0; i < size(); ++i) {
427  result.append("\n"+m_pars[i]->print(chatter));
428  }
429 
430  } // endif: chatter was not silent
431 
432  // Return result
433  return result;
434 }
435 
436 
437 /*==========================================================================
438  = =
439  = Private methods =
440  = =
441  ==========================================================================*/
442 
443 /***********************************************************************//**
444  * @brief Initialise class members
445  ***************************************************************************/
447 {
448 
449  // Initialise scale radius
451  m_scale_radius.name("ScaleRadius");
452  m_scale_radius.unit("kpc");
453  m_scale_radius.value(21.5); // default to GC scale radius
454  m_scale_radius.min(1.0e-6); // arbitrarily chosen :/
456  m_scale_radius.scale(1.0);
458  m_scale_radius.has_grad(false); // Radial components never have gradients
459 
460  // Initialise scale density
462  m_scale_density.name("ScaleDensity");
463  m_scale_density.unit("GeV/cm^3");
464  m_scale_density.value(0.2); // GeV/cm^3 default to GC scale density
466  m_scale_density.scale(1.0);
468  m_scale_density.has_grad(false); // Radial components never have gradients
469 
470  // Initialise halo distance
472  m_halo_distance.name("HaloDistance");
473  m_halo_distance.unit("kpc");
474  m_halo_distance.value(7.94); // default to GC halo distance
475  m_halo_distance.min(1.0e-6); // arbitrarily chosen
477  m_halo_distance.scale(1.0);
479  m_halo_distance.has_grad(false); // Radial components never have gradients
480 
481  // Initialise alpha
482  m_alpha.clear();
483  m_alpha.name("Alpha");
484  m_alpha.unit("unitless");
485  m_alpha.value(1.0); // default to NFW alpha
486  m_alpha.min(0.01); // arbitrarily chosen
487  m_alpha.max(10.0); // arbitrarily chosen
488  m_alpha.free();
489  m_alpha.scale(1.0);
490  m_alpha.gradient(0.0);
491  m_alpha.has_grad(false); // Radial components never have gradients
492 
493  // Initialise
494  m_beta.clear();
495  m_beta.name("Beta");
496  m_beta.unit("unitless");
497  m_beta.value(3.0); // default to NFW beta
498  m_beta.min(0.01); // arbitrarily chosen
499  m_beta.max(10.0); // arbitrarily chosen
500  m_beta.free();
501  m_beta.scale(1.0);
502  m_beta.gradient(0.0);
503  m_beta.has_grad(false); // Radial components never have gradients
504 
505  // Initialise
506  m_gamma.clear();
507  m_gamma.name("Gamma");
508  m_gamma.unit("unitless");
509  m_gamma.value(1.0); // default to NFW gamma
510  m_gamma.min(0.01); // arbitrarily chosen
511  m_gamma.max(10.0); // arbitrarily chosen
512  m_gamma.free();
513  m_gamma.scale(1.0);
514  m_gamma.gradient(0.0);
515  m_gamma.has_grad(false); // Radial components never have gradients
516 
517  // Initialise theta max
518  m_theta_min.clear();
519  m_theta_min.name("ThetaMin");
520  m_theta_min.unit("degrees");
521  m_theta_min.value(1.0e-6); // can only go from halo center to opposite halo center
522  m_theta_min.min(1.0e-10); // arbitrarily chosen, some halos don't converge at theta=0.0
523  m_theta_min.fix(); // should always be fixed!
524  m_theta_min.scale(1.0);
525  m_theta_min.gradient(0.0);
526  m_theta_min.has_grad(false); // Radial components never have gradients
527 
528  // Initialise theta max
529  m_theta_max.clear();
530  m_theta_max.name("ThetaMax");
531  m_theta_max.unit("degrees");
532  m_theta_max.value(180.0); // can only go from halo center to opposite halo center
533  m_theta_max.min(1.0e-6); // arbitrarily chosen
534  m_theta_max.fix(); // should always be fixed!
535  m_theta_max.scale(1.0);
536  m_theta_max.gradient(0.0);
537  m_theta_max.has_grad(false); // Radial components never have gradients
538 
539  // Initialise core radius
541  m_core_radius.name("CoreRadius");
542  m_core_radius.unit("kpc");
543  m_core_radius.value(10.0);
544  m_core_radius.min(0.0);
545  m_core_radius.fix();
546  m_core_radius.scale(1.0);
547  m_core_radius.gradient(0.0);
548  m_core_radius.has_grad(false);
549 
550  // Set parameter pointer(s)
551  m_pars.push_back(&m_scale_radius);
552  m_pars.push_back(&m_scale_density);
553  m_pars.push_back(&m_halo_distance);
554  m_pars.push_back(&m_alpha);
555  m_pars.push_back(&m_beta);
556  m_pars.push_back(&m_gamma);
557  m_pars.push_back(&m_theta_min);
558  m_pars.push_back(&m_theta_max);
559  m_pars.push_back(&m_core_radius);
560 
561  // Initialize precomputation cache. Note that zero values flag
562  // uninitialised, as a zero radius is not meaningful
563  m_last_scale_radius = 0.0;
564  m_last_scale_density = 0.0;
565  m_mass_radius = 0.0;
567 
568  // Return
569  return;
570 }
571 
572 
573 /***********************************************************************//**
574  * @brief Copy class members
575  *
576  * @param[in] model Radial DMZhao model.
577  *
578  * Copies class members from another radial profile model.
579  ***************************************************************************/
581 {
582  // Copy members. We do not have to push back the members on the parameter
583  // stack as this should have been done by init_members() that was called
584  // before.
588  m_alpha = model.m_alpha;
589  m_beta = model.m_beta;
590  m_gamma = model.m_gamma;
591  m_theta_min = model.m_theta_min;
592  m_theta_max = model.m_theta_max;
594 
595  // copy cache values
600 
601  // Return
602  return;
603 }
604 
605 
606 /***********************************************************************//**
607  * @brief Delete class members
608  ***************************************************************************/
610 {
611  // Return
612  return;
613 }
614 
615 
616 /***********************************************************************//**
617  * @brief Radial profile
618  *
619  * @param[in] theta Angular distance from DMZhao centre (radians).
620  * @return Profile value.
621  ***************************************************************************/
622 double GModelSpatialRadialProfileDMZhao::profile_value(const double& theta) const
623 {
624  // Update precomputation cache
625  update();
626 
627  // Initialize integral value
628  double value = 0.0;
629 
630  // Set up integration limits
631  double los_min = m_halo_distance.value() - m_mass_radius;
632  double los_max = m_halo_distance.value() + m_mass_radius;
633 
634  // Set up integral
637  m_alpha.value(),
638  m_beta.value(),
639  m_gamma.value(),
640  theta,
641  m_core_radius.value());
642  GIntegral integral(&integrand);
643  integral.max_iter(25);
644 
645  // Set up integration boundaries
646  // As there is usually an infinity at the halo center, this splits
647  // the integral at the m_halo_distance.
648  std::vector<double> bounds;
649  bounds.push_back(los_min);
650  bounds.push_back(los_max);
651  bounds.push_back(m_halo_distance.value());
652 
653  // Compute value
654  value = integral.romberg(bounds);
655 
656  // apply scale density squared
657  // TODO: must be multiplied by the particle physics factor
658  value *= m_scale_density_squared;
659 
660  // Return value
661  return value;
662 }
663 
664 
665 /***********************************************************************//**
666  * @brief Kernel for zhao halo density profile squared
667  *
668  * @param[in] los Distance from observer to point in space (meters)
669  * @return Halo density.
670  *
671  * Computes the value of a zhao halo density profile squared,
672  * at distance l from observer, at angle \f[\theta\f] from the halo center,
673  * with a halo posessing a scale radius of \f[r_s\f] :
674  *
675  * \f[
676  * f(\theta, l) = \frac{1}{ g^{\gamma} {\left( g^{\alpha} + 1 \right)}^{ \frac{\beta-\gamma}{\alpha} } }
677  * \f]
678  *
679  * where
680  *
681  * \f[
682  * g = \frac{ \sqrt{l^2+d^2-2ldCos(\theta)} }{r_s}
683  * \f]
684  *
685  * \f[ \beta \f] is the slope of the density at radii much bigger than \f[r_s\f]
686  * \f[ \gamma \f] is the slope of the density profile at radii much smaller than \f[r_s\f]
687  * \f[ \alpha \f] governs how large the transition region is between these two slopes.
688  * larger \f[ \alpha \f] means a smaller transition region.
689  *
690  * This profile is detailed in:
691  * Zhao, 1996
692  * "Analytical models for galactic nuclei"
693  * Monthly Notices of the Royal Astronomical Society, 278, 488-49
694  * http://mnras.oxfordjournals.org/content/278/2/488.short
695  ***************************************************************************/
697 {
698  // Calculate the scale distance g, the ( distance from integration point
699  // to the halo center ) divided by ( the halo scale radius )
700 
701  // First calculate the distance of the integration point from the halo
702  // center via the law of cosines
703  double g = los * los;
705  g -= 2.0 * los * m_halo_distance * std::cos(m_theta);
706  g = std::sqrt(g);
707 
708  // If we have a core radius specified, all halo values inside this core
709  // radius should be the same as at the core radius itself.
710  if (g < m_core_radius) {
711  g = m_core_radius;
712  }
713 
714  // Finish scaling the integration point by the halo's scale radius
715  g /= m_scale_radius ;
716 
717  // apply the zhao profile from the scaled distance to the halo center
718  double f = std::pow(g, m_alpha);
719  f += 1.0;
720  f = std::pow(f, (m_beta-m_gamma)/m_alpha);
721  f *= std::pow(g, m_gamma);
722  f = 1.0 / f;
723 
724  // Squared, for annihilating DM, would just be f if it was decaying DM
725  f = f * f;
726 
727  // Return function value
728  return f;
729 }
730 
731 
732 /***********************************************************************//**
733  * @brief Update precomputation cache
734  *
735  * Computes the m_mass_radius calculation, determining the radius around
736  * the halo that contains 99.99% of the mass. For a Zhao halo profile,
737  * this is just 10.0 * scale_radius .
738  ***************************************************************************/
740 {
741  // Update if scale radius has changed
744 
745  // Store last values
748 
749  // perform precomputations
750  m_mass_radius = 10.0 * scale_radius();
752 
753  }
754 
755  // Return
756  return;
757 }
758 
759 
760 /***********************************************************************//**
761  * @brief Calculate Halo Mass Density
762  *
763  * @param[in] radius Distance from halo center (kpc).
764  * @return Halo mass density.
765  *
766  * Calculates the halo's mass density at a given radial distance from the halo
767  * center.
768  ***************************************************************************/
769 double GModelSpatialRadialProfileDMZhao::mass_density(const double& radius) const
770 {
771  // Initialize halo kernel with stored values. We use theta=0 to effectivly
772  // sample the halo radially
773  halo_kernel_los halo_shape(m_scale_radius.value(),
775  m_alpha.value(),
776  m_beta.value(),
777  m_gamma.value(),
778  0.0,
779  m_core_radius.value());
780 
781  // eval produces a unitless density^2, so we must take its square root
782  double density = std::sqrt(halo_shape.eval(m_halo_distance.value() + radius));
783 
784  // Multiply in the missing scale density
785  density *= m_scale_density.value();
786 
787  return density ;
788 }
789 
790 
791 /***********************************************************************//**
792  * @brief Calculate J-factor
793  *
794  * @param[in] angle from halo center (radians)
795  * @return J-factor
796  *
797  * Calculates the halo's J-factor at an angle from the halo center.
798  ***************************************************************************/
799 double GModelSpatialRadialProfileDMZhao::jfactor(const double& angle) const
800 {
801  // Integration settings
802  double minradian = 0.0;
803  int npoints = 200;
804 
805  // Initialize other variables
806  double jfactor = 0.0;
807  double dr = (angle - minradian) / npoints;
808  double r = 0.0;
809 
810  // Loop over different radii in the profile
811  for (int i = 0; i < npoints; ++i) {
812  r = minradian + (i * dr);
813  jfactor += profile_value(r) * r * dr;
814  }
815 
816  // J-factor = 2 * pi * Int[ profile(r) * r * dr , {r,minradian,angle} ]
817  jfactor *= gammalib::twopi;
818 
819  // Return J-factor
820  return jfactor;
821 }
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.
const std::string & name(void) const
Return parameter name.
GModelPar m_gamma
Power index, slope at &lt;&lt; m_scale_radius.
virtual void read(const GXmlElement &xml)
Read model from XML element.
XML element node class interface definition.
const double pi
Definition: GMath.hpp:35
double gradient(void) const
Return parameter gradient.
int size(void) const
Return number of parameters.
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
Definition: GModelPar.cpp:353
GVector cos(const GVector &vector)
Computes cosine of vector elements.
Definition: GVector.cpp:1100
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:47
double max(void) const
Return parameter maximum boundary.
const GModelSpatialRadialDisk g_radial_disk_seed
virtual void clear(void)
Clear radial DMZhao profile model.
Gammalib tools definition.
GIntegral class interface definition.
Definition: GIntegral.hpp:45
Interface definition for the spatial model registry class.
double min(void) const
Return parameter minimum boundary.
void init_members(void)
Initialise class members.
virtual void write(GXmlElement &xml) const
Write model into XML element.
void init_members(void)
Initialise class members.
const double & scale(void) const
Return parameter scale.
const double deg2rad
Definition: GMath.hpp:43
GVector sqrt(const GVector &vector)
Computes square root of vector elements.
Definition: GVector.cpp:1268
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
void free_members(void)
Delete class members.
void free_members(void)
Delete class members.
void free(void)
Free a parameter.
double mass_density(const double &radius) const
Calculate Halo Mass Density.
std::vector< GModelPar * > m_pars
Parameter pointers.
void fix(void)
Fix a parameter.
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
Definition: GTools.cpp:1513
virtual void read(const GXmlElement &xml)
Read model from XML element.
void clear(void)
Clear parameter.
Spatial model registry class definition.
virtual GModelSpatialRadialProfileDMZhao & operator=(const GModelSpatialRadialProfileDMZhao &model)
Assignment operator.
Dark Matter Zhao profile model class interface definition.
GChatter
Definition: GTypemaps.hpp:33
virtual double profile_value(const double &theta) const
Radial profile.
void copy_members(const GModelSpatialRadialProfileDMZhao &model)
Copy class members.
void init_members(void)
Initialise class members.
void update(void) const
Update precomputation cache.
virtual void write(GXmlElement &xml) const
Write model into XML element.
GModelPar m_scale_density
Scale density of halo profile.
void free_members(void)
Delete class members.
GModelPar m_halo_distance
Distance from earth to halo center.
double jfactor(const double &angle) const
Calculate J-factor.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
Definition: GModelPar.cpp:229
double value(void) const
Return parameter value.
virtual GModelSpatialRadialProfile & operator=(const GModelSpatialRadialProfile &model)
Assignment operator.
double scale_density(void) const
Return scale density.
GVector pow(const GVector &vector, const double &power)
Computes tanh of vector elements.
Definition: GVector.cpp:1332
const std::string & unit(void) const
Return parameter unit.
Exception handler interface definition.
virtual double theta_max(void) const
Return maximum model radius (in radians)
void init_members(void)
Initialise class members.
const double twopi
Definition: GMath.hpp:36
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
Definition: GTools.cpp:1022
GVector atan(const GVector &vector)
Computes arctan of vector elements.
Definition: GVector.cpp:1058
double eval(const double &los)
Kernel for zhao halo density profile squared.
const GXmlElement * xml_get_par(const std::string &origin, const GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
Definition: GTools.cpp:1562
virtual std::string print(const GChatter &chatter=NORMAL) const
Print information.
Mathematical function definitions.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
Definition: GTools.cpp:413