From deaf5e66fedcd3c5035056a93b12dbb6319fc7e5 Mon Sep 17 00:00:00 2001 From: knodlseder <> Date: Wed, 27 Jul 2011 20:59:29 +0000 Subject: [PATCH] add eflux() method --- include/GModelSpectral.hpp | 17 +++++++++++++---- include/GModelSpectralConst.hpp | 17 +++++++++++++---- include/GModelSpectralExpPlaw.hpp | 17 +++++++++++++---- include/GModelSpectralFunc.hpp | 17 +++++++++++++---- include/GModelSpectralPlaw.hpp | 17 +++++++++++++---- include/GModelSpectralPlaw2.hpp | 17 +++++++++++++---- pyext/GModelSpectral.i | 17 +++++++++++++---- pyext/GModelSpectralConst.i | 17 +++++++++++++---- pyext/GModelSpectralExpPlaw.i | 17 +++++++++++++---- pyext/GModelSpectralFunc.i | 17 +++++++++++++---- pyext/GModelSpectralPlaw.i | 17 +++++++++++++---- pyext/GModelSpectralPlaw2.i | 17 +++++++++++++---- src/model/GModelSpectralConst.cpp | 30 +++++++++++++++++++++++++++++- src/model/GModelSpectralPlaw.cpp | 37 ++++++++++++++++++++++++++++++++++++- 14 files changed, 221 insertions(+), 50 deletions(-) diff --git a/include/GModelSpectral.hpp b/include/GModelSpectral.hpp index a32319d..844e7ba 100644 --- a/include/GModelSpectral.hpp +++ b/include/GModelSpectral.hpp @@ -4,10 +4,18 @@ * copyright (C) 2009-2011 by Jurgen Knodlseder * * ----------------------------------------------------------------------- * * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -64,6 +72,7 @@ public: virtual double eval(const GEnergy& srcEng) const = 0; virtual double eval_gradients(const GEnergy& srcEng) const = 0; virtual double flux(const GEnergy& emin, const GEnergy& emax) const = 0; + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const = 0; virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const = 0; virtual void read(const GXmlElement& xml) = 0; virtual void write(GXmlElement& xml) const = 0; diff --git a/include/GModelSpectralConst.hpp b/include/GModelSpectralConst.hpp index 3dc0a3b..acba2c4 100644 --- a/include/GModelSpectralConst.hpp +++ b/include/GModelSpectralConst.hpp @@ -4,10 +4,18 @@ * copyright (C) 2009-2011 by Jurgen Knodlseder * * ----------------------------------------------------------------------- * * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -57,6 +65,7 @@ public: virtual double eval(const GEnergy& srcEng) const; virtual double eval_gradients(const GEnergy& srcEng) const; virtual double flux(const GEnergy& emin, const GEnergy& emax) const; + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const; virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const; virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; diff --git a/include/GModelSpectralExpPlaw.hpp b/include/GModelSpectralExpPlaw.hpp index 32d187f..3056eda 100644 --- a/include/GModelSpectralExpPlaw.hpp +++ b/include/GModelSpectralExpPlaw.hpp @@ -4,10 +4,18 @@ * copyright (C) 2010-2011 by Jurgen Knodlseder * * ----------------------------------------------------------------------- * * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -61,6 +69,7 @@ public: virtual double eval(const GEnergy& srcEng) const; virtual double eval_gradients(const GEnergy& srcEng) const; virtual double flux(const GEnergy& emin, const GEnergy& emax) const; + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const; virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const; virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; diff --git a/include/GModelSpectralFunc.hpp b/include/GModelSpectralFunc.hpp index b71f7f4..9ed47db 100644 --- a/include/GModelSpectralFunc.hpp +++ b/include/GModelSpectralFunc.hpp @@ -4,10 +4,18 @@ * copyright (C) 2010-2011 by Jurgen Knodlseder * * ----------------------------------------------------------------------- * * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -60,6 +68,7 @@ public: virtual double eval(const GEnergy& srcEng) const; virtual double eval_gradients(const GEnergy& srcEng) const; virtual double flux(const GEnergy& emin, const GEnergy& emax) const; + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const; virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const; virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; diff --git a/include/GModelSpectralPlaw.hpp b/include/GModelSpectralPlaw.hpp index ed60bd8..807e07e 100644 --- a/include/GModelSpectralPlaw.hpp +++ b/include/GModelSpectralPlaw.hpp @@ -4,10 +4,18 @@ * copyright (C) 2009-2011 by Jurgen Knodlseder * * ----------------------------------------------------------------------- * * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -60,6 +68,7 @@ public: virtual double eval(const GEnergy& srcEng) const; virtual double eval_gradients(const GEnergy& srcEng) const; virtual double flux(const GEnergy& emin, const GEnergy& emax) const; + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const; virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const; virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; diff --git a/include/GModelSpectralPlaw2.hpp b/include/GModelSpectralPlaw2.hpp index 7c570a0..b388853 100644 --- a/include/GModelSpectralPlaw2.hpp +++ b/include/GModelSpectralPlaw2.hpp @@ -4,10 +4,18 @@ * copyright (C) 2011 by Jurgen Knodlseder * * ----------------------------------------------------------------------- * * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -64,6 +72,7 @@ public: virtual double eval(const GEnergy& srcEng) const; virtual double eval_gradients(const GEnergy& srcEng) const; virtual double flux(const GEnergy& emin, const GEnergy& emax) const; + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const; virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const; virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; diff --git a/pyext/GModelSpectral.i b/pyext/GModelSpectral.i index f3f0757..dce5bdc 100644 --- a/pyext/GModelSpectral.i +++ b/pyext/GModelSpectral.i @@ -4,10 +4,18 @@ * copyright (C) 2009-2011 by Jurgen Knodlseder * * ----------------------------------------------------------------------- * * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -41,6 +49,7 @@ public: virtual double eval(const GEnergy& srcEng) const = 0; virtual double eval_gradients(const GEnergy& srcEng) const = 0; virtual double flux(const GEnergy& emin, const GEnergy& emax) const = 0; + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const = 0; virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const = 0; virtual void read(const GXmlElement& xml) = 0; virtual void write(GXmlElement& xml) const = 0; diff --git a/pyext/GModelSpectralConst.i b/pyext/GModelSpectralConst.i index 5cbf258..fda4752 100644 --- a/pyext/GModelSpectralConst.i +++ b/pyext/GModelSpectralConst.i @@ -4,10 +4,18 @@ * copyright (C) 2011 by Jurgen Knodlseder * * ----------------------------------------------------------------------- * * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -42,6 +50,7 @@ public: virtual double eval(const GEnergy& srcEng) const; virtual double eval_gradients(const GEnergy& srcEng) const; virtual double flux(const GEnergy& emin, const GEnergy& emax) const; + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const; virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const; virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; diff --git a/pyext/GModelSpectralExpPlaw.i b/pyext/GModelSpectralExpPlaw.i index 89fa01f..a529700 100644 --- a/pyext/GModelSpectralExpPlaw.i +++ b/pyext/GModelSpectralExpPlaw.i @@ -4,10 +4,18 @@ * copyright (C) 2009-2011 by Jurgen Knodlseder * * ----------------------------------------------------------------------- * * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -44,6 +52,7 @@ public: virtual double eval(const GEnergy& srcEng) const; virtual double eval_gradients(const GEnergy& srcEng) const; virtual double flux(const GEnergy& emin, const GEnergy& emax) const; + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const; virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const; virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; diff --git a/pyext/GModelSpectralFunc.i b/pyext/GModelSpectralFunc.i index 86d4973..2f94d41 100644 --- a/pyext/GModelSpectralFunc.i +++ b/pyext/GModelSpectralFunc.i @@ -4,10 +4,18 @@ * copyright (C) 2011 by Jurgen Knodlseder * * ----------------------------------------------------------------------- * * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -43,6 +51,7 @@ public: virtual double eval(const GEnergy& srcEng) const; virtual double eval_gradients(const GEnergy& srcEng) const; virtual double flux(const GEnergy& emin, const GEnergy& emax) const; + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const; virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const; virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; diff --git a/pyext/GModelSpectralPlaw.i b/pyext/GModelSpectralPlaw.i index 348e6ba..595117f 100644 --- a/pyext/GModelSpectralPlaw.i +++ b/pyext/GModelSpectralPlaw.i @@ -4,10 +4,18 @@ * copyright (C) 2009-2011 by Jurgen Knodlseder * * ----------------------------------------------------------------------- * * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -43,6 +51,7 @@ public: virtual double eval(const GEnergy& srcEng) const; virtual double eval_gradients(const GEnergy& srcEng) const; virtual double flux(const GEnergy& emin, const GEnergy& emax) const; + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const; virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const; virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; diff --git a/pyext/GModelSpectralPlaw2.i b/pyext/GModelSpectralPlaw2.i index f21b594..35c5806 100644 --- a/pyext/GModelSpectralPlaw2.i +++ b/pyext/GModelSpectralPlaw2.i @@ -4,10 +4,18 @@ * copyright (C) 2011 by Jurgen Knodlseder * * ----------------------------------------------------------------------- * * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -43,6 +51,7 @@ public: virtual double eval(const GEnergy& srcEng) const; virtual double eval_gradients(const GEnergy& srcEng) const; virtual double flux(const GEnergy& emin, const GEnergy& emax) const; + virtual double eflux(const GEnergy& emin, const GEnergy& emax) const; virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, GRan& ran) const; virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; diff --git a/src/model/GModelSpectralConst.cpp b/src/model/GModelSpectralConst.cpp index ec59c06..6138724 100644 --- a/src/model/GModelSpectralConst.cpp +++ b/src/model/GModelSpectralConst.cpp @@ -246,7 +246,7 @@ double GModelSpectralConst::eval_gradients(const GEnergy& srcEng) const /***********************************************************************//** - * @brief Returns model flux between [emin, emax] (units: ph/cm2/s) + * @brief Returns model photon flux between [emin, emax] (units: ph/cm2/s) * * @param[in] emin Minimum photon energy. * @param[in] emax Maximum photon energy. @@ -257,6 +257,7 @@ double GModelSpectralConst::eval_gradients(const GEnergy& srcEng) const * \f$E_{\rm min}\f$ and \f$E_{\rm max}\f$ are the minimum and maximum * energy, respectively, and * \f$I(E)\f$ is the spectral model (units: ph/cm2/s/MeV). + * The integration is done analytically. ***************************************************************************/ double GModelSpectralConst::flux(const GEnergy& emin, const GEnergy& emax) const { @@ -269,6 +270,33 @@ double GModelSpectralConst::flux(const GEnergy& emin, const GEnergy& emax) const /***********************************************************************//** + * @brief Returns model energy flux between [emin, emax] (units: erg/cm2/s) + * + * @param[in] emin Minimum photon energy. + * @param[in] emax Maximum photon energy. + * + * Computes + * \f[\int_{E_{\rm min}}^{E_{\rm max}} I(E) E dE\f] + * where + * \f$E_{\rm min}\f$ and \f$E_{\rm max}\f$ are the minimum and maximum + * energy, respectively, and + * \f$I(E)\f$ is the spectral model (units: ph/cm2/s/MeV). + * The integration is done analytically. + ***************************************************************************/ +double GModelSpectralConst::eflux(const GEnergy& emin, const GEnergy& emax) const +{ + // Compute flux for a constant model + double flux = norm() * 0.5 * (emax.MeV()*emax.MeV() - emin.MeV()*emin.MeV()); + + // Convert from MeV/cm2/s to erg/cm2/s + flux *= MeV2erg; + + // Return + return flux; +} + + +/***********************************************************************//** * @brief Returns MC energy between [emin, emax] * * @param[in] emin Minimum photon energy. diff --git a/src/model/GModelSpectralPlaw.cpp b/src/model/GModelSpectralPlaw.cpp index 3a21484..4637c36 100644 --- a/src/model/GModelSpectralPlaw.cpp +++ b/src/model/GModelSpectralPlaw.cpp @@ -326,7 +326,7 @@ double GModelSpectralPlaw::eval_gradients(const GEnergy& srcEng) const /***********************************************************************//** - * @brief Returns model flux between [emin, emax] (units: ph/cm2/s) + * @brief Returns model photon flux between [emin, emax] (units: ph/cm2/s) * * @param[in] emin Minimum photon energy. * @param[in] emax Maximum photon energy. @@ -337,6 +337,7 @@ double GModelSpectralPlaw::eval_gradients(const GEnergy& srcEng) const * \f$E_{\rm min}\f$ and \f$E_{\rm max}\f$ are the minimum and maximum * energy, respectively, and * \f$I(E)\f$ is the spectral model (units: ph/cm2/s/MeV). + * The integration is done analytically. ***************************************************************************/ double GModelSpectralPlaw::flux(const GEnergy& emin, const GEnergy& emax) const { @@ -356,6 +357,40 @@ double GModelSpectralPlaw::flux(const GEnergy& emin, const GEnergy& emax) const /***********************************************************************//** + * @brief Returns model energy flux between [emin, emax] (units: erg/cm2/s) + * + * @param[in] emin Minimum photon energy. + * @param[in] emax Maximum photon energy. + * + * Computes + * \f[\int_{E_{\rm min}}^{E_{\rm max}} I(E) E dE\f] + * where + * \f$E_{\rm min}\f$ and \f$E_{\rm max}\f$ are the minimum and maximum + * energy, respectively, and + * \f$I(E)\f$ is the spectral model (units: ph/cm2/s/MeV). + * The integration is done analytically. + ***************************************************************************/ +double GModelSpectralPlaw::eflux(const GEnergy& emin, const GEnergy& emax) const +{ + // Compute flux + double flux = norm() * pow(pivot(), -index()); + if (index() != -2.0) { + double exponent = index() + 2.0; + flux *= (std::pow(emax.MeV(), exponent)-std::pow(emin.MeV(), exponent)) / + exponent; + } + else + flux *= (std::log(emax.MeV()) - std::log(emin.MeV())); + + // Convert from MeV/cm2/s to erg/cm2/s + flux *= MeV2erg; + + // Return flux + return flux; +} + + +/***********************************************************************//** * @brief Returns Monte Carlo energy between [emin, emax] * * @param[in] emin Minimum photon energy. -- libgit2 0.21.4