From 7f1311157078fffa78210517fd2b070885e54fa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?JulienD=C3=B6rner?= Date: Thu, 26 Oct 2023 10:59:08 +0200 Subject: [PATCH 1/5] remove DINT --- CMakeLists.txt | 11 - include/CRPropa.h | 1 - include/crpropa/PhotonPropagation.h | 53 -- libs/dint/CMakeLists.txt | 32 - libs/dint/include/dint/DintEMCascade.h | 200 ----- libs/dint/include/dint/advance.h | 167 ---- libs/dint/include/dint/background.h | 64 -- libs/dint/include/dint/binfread.h | 24 - libs/dint/include/dint/check.h | 10 - libs/dint/include/dint/const.h | 58 -- libs/dint/include/dint/cvector.h | 30 - libs/dint/include/dint/decay.h | 10 - libs/dint/include/dint/deriv.h | 100 --- libs/dint/include/dint/error.h | 9 - libs/dint/include/dint/final.h | 15 - libs/dint/include/dint/fold.h | 153 ---- libs/dint/include/dint/frag.h | 17 - libs/dint/include/dint/gauleg.h | 7 - libs/dint/include/dint/inject.h | 12 - libs/dint/include/dint/io_util.h | 8 - libs/dint/include/dint/load.h | 81 -- libs/dint/include/dint/math_util.h | 9 - libs/dint/include/dint/prepare.h | 48 -- libs/dint/include/dint/prop_second.h | 91 -- libs/dint/include/dint/rate.h | 102 --- libs/dint/include/dint/spectrum.h | 55 -- libs/dint/include/dint/sync.h | 22 - libs/dint/include/dint/utilities.h | 10 - libs/dint/include/dint/vector.h | 31 - libs/dint/src/DintEMCascade.cpp | 363 -------- libs/dint/src/advance.cpp | 845 ------------------ libs/dint/src/background.cpp | 529 ------------ libs/dint/src/binfread.cpp | 64 -- libs/dint/src/check.cpp | 27 - libs/dint/src/cvector.cpp | 36 - libs/dint/src/decay.cpp | 150 ---- libs/dint/src/deriv.cpp | 477 ----------- libs/dint/src/error.cpp | 9 - libs/dint/src/final.cpp | 71 -- libs/dint/src/fold.cpp | 826 ------------------ libs/dint/src/frag.cpp | 582 ------------- libs/dint/src/gauleg.cpp | 534 ------------ libs/dint/src/inject.cpp | 55 -- libs/dint/src/io_util.cpp | 15 - libs/dint/src/load.cpp | 330 -------- libs/dint/src/math_util.cpp | 34 - libs/dint/src/prepare.cpp | 409 --------- libs/dint/src/prop_second.cpp | 1081 ------------------------ libs/dint/src/rate.cpp | 909 -------------------- libs/dint/src/spectrum.cpp | 212 ----- libs/dint/src/sync.cpp | 128 --- libs/dint/src/vector.cpp | 224 ----- python/2_headers.i | 2 - src/PhotonPropagation.cpp | 504 ----------- src/module/EMCascade.cpp | 184 ---- test/testDINT.cpp | 97 --- test/testSimulationExecution.py | 5 +- 57 files changed, 4 insertions(+), 10128 deletions(-) delete mode 100644 include/crpropa/PhotonPropagation.h delete mode 100644 libs/dint/CMakeLists.txt delete mode 100644 libs/dint/include/dint/DintEMCascade.h delete mode 100644 libs/dint/include/dint/advance.h delete mode 100644 libs/dint/include/dint/background.h delete mode 100644 libs/dint/include/dint/binfread.h delete mode 100644 libs/dint/include/dint/check.h delete mode 100644 libs/dint/include/dint/const.h delete mode 100644 libs/dint/include/dint/cvector.h delete mode 100644 libs/dint/include/dint/decay.h delete mode 100644 libs/dint/include/dint/deriv.h delete mode 100644 libs/dint/include/dint/error.h delete mode 100644 libs/dint/include/dint/final.h delete mode 100644 libs/dint/include/dint/fold.h delete mode 100644 libs/dint/include/dint/frag.h delete mode 100644 libs/dint/include/dint/gauleg.h delete mode 100644 libs/dint/include/dint/inject.h delete mode 100644 libs/dint/include/dint/io_util.h delete mode 100644 libs/dint/include/dint/load.h delete mode 100644 libs/dint/include/dint/math_util.h delete mode 100644 libs/dint/include/dint/prepare.h delete mode 100644 libs/dint/include/dint/prop_second.h delete mode 100644 libs/dint/include/dint/rate.h delete mode 100644 libs/dint/include/dint/spectrum.h delete mode 100644 libs/dint/include/dint/sync.h delete mode 100644 libs/dint/include/dint/utilities.h delete mode 100644 libs/dint/include/dint/vector.h delete mode 100644 libs/dint/src/DintEMCascade.cpp delete mode 100644 libs/dint/src/advance.cpp delete mode 100644 libs/dint/src/background.cpp delete mode 100644 libs/dint/src/binfread.cpp delete mode 100644 libs/dint/src/check.cpp delete mode 100644 libs/dint/src/cvector.cpp delete mode 100644 libs/dint/src/decay.cpp delete mode 100644 libs/dint/src/deriv.cpp delete mode 100644 libs/dint/src/error.cpp delete mode 100644 libs/dint/src/final.cpp delete mode 100644 libs/dint/src/fold.cpp delete mode 100644 libs/dint/src/frag.cpp delete mode 100644 libs/dint/src/gauleg.cpp delete mode 100644 libs/dint/src/inject.cpp delete mode 100644 libs/dint/src/io_util.cpp delete mode 100644 libs/dint/src/load.cpp delete mode 100644 libs/dint/src/math_util.cpp delete mode 100644 libs/dint/src/prepare.cpp delete mode 100644 libs/dint/src/prop_second.cpp delete mode 100644 libs/dint/src/rate.cpp delete mode 100644 libs/dint/src/spectrum.cpp delete mode 100644 libs/dint/src/sync.cpp delete mode 100644 libs/dint/src/vector.cpp delete mode 100644 src/PhotonPropagation.cpp delete mode 100644 src/module/EMCascade.cpp delete mode 100644 test/testDINT.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index f66953c2d..68cfd4016 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,11 +164,6 @@ add_subdirectory(libs/sophia) list(APPEND CRPROPA_EXTRA_LIBRARIES sophia gfortran) list(APPEND CRPROPA_EXTRA_INCLUDES libs/sophia) -# DINT (provided) -add_subdirectory(libs/dint) -list(APPEND CRPROPA_EXTRA_LIBRARIES dint) -list(APPEND CRPROPA_EXTRA_INCLUDES libs/dint/include) - # EleCa (provided) add_subdirectory(libs/EleCa) list(APPEND CRPROPA_EXTRA_LIBRARIES eleca) @@ -381,7 +376,6 @@ add_library(crpropa SHARED src/ParticleMass.cpp src/ParticleState.cpp src/PhotonBackground.cpp - src/PhotonPropagation.cpp src/ProgressBar.cpp src/Random.cpp src/Source.cpp @@ -392,7 +386,6 @@ add_library(crpropa SHARED src/module/BreakCondition.cpp src/module/CandidateSplitting.cpp src/module/DiffusionSDE.cpp - src/module/EMCascade.cpp src/module/EMDoublePairProduction.cpp src/module/EMInverseComptonScattering.cpp src/module/EMPairProduction.cpp @@ -625,10 +618,6 @@ if(ENABLE_TESTING) target_link_libraries(testDensity crpropa gtest gtest_main pthread ${COVERAGE_LIBS}) add_test(testDensity testDensity) - add_executable(testDINT test/testDINT.cpp) - target_link_libraries(testDINT crpropa gtest gtest_main pthread ${COVERAGE_LIBS}) - add_test(testDINT testDINT) - add_executable(testPropagation test/testPropagation.cpp) target_link_libraries(testPropagation crpropa gtest gtest_main pthread ${COVERAGE_LIBS}) add_test(testPropagation testPropagation) diff --git a/include/CRPropa.h b/include/CRPropa.h index 05743bde1..6544a8129 100644 --- a/include/CRPropa.h +++ b/include/CRPropa.h @@ -31,7 +31,6 @@ #include "crpropa/module/BreakCondition.h" #include "crpropa/module/CandidateSplitting.h" #include "crpropa/module/DiffusionSDE.h" -#include "crpropa/module/EMCascade.h" #include "crpropa/module/EMDoublePairProduction.h" #include "crpropa/module/EMInverseComptonScattering.h" #include "crpropa/module/EMPairProduction.h" diff --git a/include/crpropa/PhotonPropagation.h b/include/crpropa/PhotonPropagation.h deleted file mode 100644 index a5097e1e4..000000000 --- a/include/crpropa/PhotonPropagation.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef CRPROPA_PHOTON_PROPAGATION_H -#define CRPROPA_PHOTON_PROPAGATION_H - -#include -#include - -/** - @file - @brief Calculation of the electromagnetic cascade outside of CRPropa's module list - */ - -namespace crpropa { - -/** - Propagate photons, electrons and positrons using the EleCa code. - The propagation is stopped when the particles reach the observer or their energy drops below the threshold energy. - */ -void ElecaPropagation( - const std::string &inputfile, //!< input in PhotonOutput1D format - const std::string &outputfile, //!< output in PhotonOutput1D format - bool showProgress = true, //!< show a progress bar - double lowerEnergyThreshold = 0.8010882435, //!< threshold energy [J], default = 5 EeV - double magneticFieldStrength = 1E-13, //!< magnetic field strength [T], default = 1 nG - const std::string &background = "ALL" //!< photon background string - ); - -/** - Calculate the electromagnetic cascade with DINT - */ -void DintPropagation( - const std::string &inputfile, //!< input in PhotonOutput1D format - const std::string &outputfile, //!< output spectrum (photons, electrons, positrons) - int IRFlag = 4, //!< EBL background 0: high, 1: low, 2: Primack, 4: Stecker'06 - int RadioFlag = 4, //!< radio background 0: high, 1: medium, 2: obs, 3: none, 4: Protheroe'96 - double magneticFieldStrength = 1E-13, //!< magnetic field strength [T], default = 1 nG - double aCutcascade_Magfield = 0 //!< a-parameter, see CRPropa 2 paper - ); - -/** - Propagate photons using EleCa for energies above the crossover energy and DINT below - */ -void DintElecaPropagation( - const std::string &inputfile, //!< input in PhotonOutput1D format - const std::string &outputfile, //!< output spectrum (photons, electrons, positrons) - bool showProgress = true, //!< show a progress bar - double crossOverEnergy = 0.08010882435, //!< crossover energy [J] between EleCa and DINT, default = 0.5 EeV - double magneticFieldStrength = 1E-13, //!< magnetic field strength [T], default = 1 nG - double aCutcascade_Magfield = 0 //!< a-parameter, see CRPropa 2 paper - ); - -} // namespace crpropa - -#endif // CRPROPA_PHOTON_PROPAGATION_H diff --git a/libs/dint/CMakeLists.txt b/libs/dint/CMakeLists.txt deleted file mode 100644 index fa1b9bb78..000000000 --- a/libs/dint/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 2.6) - -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) - -add_library(dint STATIC - src/advance.cpp - src/background.cpp - src/binfread.cpp - src/check.cpp - src/cvector.cpp - src/decay.cpp - src/deriv.cpp - src/error.cpp - src/final.cpp - src/fold.cpp - src/frag.cpp - src/gauleg.cpp - src/inject.cpp - src/io_util.cpp - src/load.cpp - src/math_util.cpp - src/prepare.cpp - src/prop_second.cpp - src/rate.cpp - src/spectrum.cpp - src/sync.cpp - src/vector.cpp - src/DintEMCascade.cpp -) - -SET_TARGET_PROPERTIES(dint PROPERTIES COMPILE_FLAGS -fPIC) - diff --git a/libs/dint/include/dint/DintEMCascade.h b/libs/dint/include/dint/DintEMCascade.h deleted file mode 100644 index 3e9e9cd18..000000000 --- a/libs/dint/include/dint/DintEMCascade.h +++ /dev/null @@ -1,200 +0,0 @@ -#ifndef DINT_EMCASCADE_H -#define DINT_EMCASCADE_H - -#include "dint/rate.h" -#include "dint/const.h" -#include "dint/spectrum.h" -#include "dint/cvector.h" -#include "dint/load.h" -#include "dint/prepare.h" -#include "dint/sync.h" -#include "dint/inject.h" -#include "dint/background.h" -#include "dint/fold.h" -#include "dint/advance.h" -#include "dint/final.h" -#include "dint/utilities.h" - - -// DintEMCascade. -// Class based on the original DINT prop_second function, intended as starting -// point to create a simplified EM cascade calculation based on transport -// equations to replace DINT completely in a future release of CRPropa. -class DintEMCascade { - private: - //-------- Declaration of main variables -------- - //---- Interaction table coefficients ---- - RawTotalRate ICSTotalRate; - RawTotalRate PPTotalRate; - RawTotalRate TPPTotalRate; - RawTotalRate DPPRate; - - RawTotalRate PPPProtonLossRate; - RawTotalRate PPPNeutronLossRate; - RawTotalRate NPPTotalRate; - // total (interaction) rates before being folded into the background - - RawDiffRate ICSPhotonRate; - RawDiffRate ICSScatRate; - RawDiffRate PPDiffRate; - RawDiffRate TPPDiffRate; - - RawDiffRate PPPProtonScatRate; - RawDiffRate PPPProtonNeutronRate; - RawDiffRate PPPNeutronProtonRate; - RawDiffRate PPPProtonPhotonRate; - RawDiffRate PPPProtonElectronRate; - RawDiffRate PPPProtonPositronRate; - RawDiffRate PPPNeutronElectronRate; - RawDiffRate NPPDiffRate; - RawDiffRate PPPProtonElectronNeutrinoRate; - RawDiffRate PPPProtonAntiElectronNeutrinoRate; - RawDiffRate PPPProtonMuonNeutrinoRate; - RawDiffRate PPPProtonAntiMuonNeutrinoRate; - RawDiffRate PPPNeutronAntiElectronNeutrinoRate; - RawDiffRate PPPNeutronMuonNeutrinoRate; - RawDiffRate PPPNeutronAntiMuonNeutrinoRate; - // differential rates before being folded into the background - - TotalRate neutronDecayRate; - DiffRate neutronDecayElectronRate; - DiffRate neutronDecayProtonRate; - - TotalRate NNElNeutTotalRate; - TotalRate NNMuonNeutTotalRate; - TotalRate NNTauNeutTotalRate; - // These total rates are net rates; i.e. scattered flux into same bin is subtracted - DiffRate NNElNeutScatRate; - DiffRate NNElNeutMuonNeutRate; - DiffRate NNElNeutTauNeutRate; - DiffRate NNElNeutElectronRate; - DiffRate NNElNeutPhotonRate; - DiffRate NNElNeutProtonRate; - DiffRate NNMuonNeutScatRate; - DiffRate NNMuonNeutElNeutRate; - DiffRate NNMuonNeutTauNeutRate; - DiffRate NNMuonNeutElectronRate; - DiffRate NNMuonNeutPhotonRate; - DiffRate NNMuonNeutProtonRate; - DiffRate NNTauNeutScatRate; - DiffRate NNTauNeutElNeutRate; - DiffRate NNTauNeutMuonNeutRate; - DiffRate NNTauNeutElectronRate; - DiffRate NNTauNeutPhotonRate; - DiffRate NNTauNeutProtonRate; - // rates from neutrino-neutrino interaction - DiffRate syncRate; - - // Energy Bins - dCVector deltaG; // dg used in continuous energy loss calculation - - dCVector bgEnergy; - dCVector bgEnergyWidth; - dCVector bgPhotonDensity; - - Spectrum Q_0; // standard injection function - Spectrum spectrumNew; - Spectrum derivative; - - //---- interaction rates folded with photon background ---- - TotalRate leptonTotalRate; - TotalRate photonTotalRate; - TotalRate protonTotalRate; - TotalRate neutronTotalRate; - - DiffRate leptonScatRate; - DiffRate leptonExchRate; - DiffRate leptonPhotonRate; - DiffRate photonLeptonRate; - - DiffRate protonScatRate; - DiffRate protonNeutronRate; - DiffRate neutronProtonRate; - DiffRate protonPhotonRate; - DiffRate protonElectronRate; - DiffRate protonPositronRate; - DiffRate neutronElectronRate; - DiffRate neutronPositronRate; - DiffRate protonElectronNeutrinoRate; - DiffRate protonAntiElectronNeutrinoRate; - DiffRate protonMuonNeutrinoRate; - DiffRate protonAntiMuonNeutrinoRate; - DiffRate neutronAntiElectronNeutrinoRate; - DiffRate neutronMuonNeutrinoRate; - DiffRate neutronAntiMuonNeutrinoRate; - - TotalRate elNeutTotalRate; - TotalRate muonNeutTotalRate; - TotalRate tauNeutTotalRate; - - DiffRate elNeutElectronRate; - DiffRate elNeutPhotonRate; - DiffRate muonNeutElectronRate; - DiffRate muonNeutPhotonRate; - DiffRate tauNeutElectronRate; - DiffRate tauNeutPhotonRate; - // rates from neutrino-neutrino interaction - - dCVector synchrotronLoss; // sgdot - dCVector otherLoss; // tgdot - dCVector continuousLoss; // gdot - - dCVector pEnergy; - dCVector pEnergyWidth; - - dCVector RedshiftArray ; - dCVector DistanceArray ; - - // switches - const int synchrotronSwitch; - const int sourceTypeSwitch; - const int tauNeutrinoMassSwitch; - const int ICSSwitch; - const int PPSwitch; - const int TPPSwitch; - const int DPPSwitch; - const int PPPSwitch; - const int NPPSwitch; - const int neutronDecaySwitch; - const int nucleonToSecondarySwitch; - const int neutrinoNeutrinoSwitch; - - const int aIRFlag; - const int aRadioFlag; - - const double aZmax_IR; - - const double aH0; - const double aOmegaM; - const double aOmegaLambda; - - dCVector pB_field; - string aDirTables; - -public: - DintEMCascade( - int _aIRFlag, //!< EBL background 0: high, 1: low, 2: Primack, 4: Stecker'06 - int _aRadioFlag, //!< radio background 0: high, 1: medium, 2: obs, 3: none, 4: Protheroe'96 - string _aDirTables, //!< DINT data path - double B = 1E-9, //!< magnetic field strength [G], default = 1 nG - double _aH0 = H_0, //!< Hubble parameter in [km/s/Mpc] - double _aOmegaM = OMEGA_M, //!< omegaM parameter - double _aOmegaLambda = OMEGA_LAMBDA //!< omegaL parameter - ); - - ~DintEMCascade(); - - void propagate( - const double start_distance, // -#include "dint/spectrum.h" -#include "dint/rate.h" -#include "dint/cvector.h" -#include "dint/const.h" -#include "dint/deriv.h" -#include "dint/error.h" - -const double EPSILON = 1.e-18; - -void ComputeRedshifts(const int sourceTypeSwitch, const double leftRedshift, - double* pDeltaRedshift, double* pRightRedshift, - double* pCentralRedshift, int* pLastIndex); -void AdvanceNucleonStep(const int sourceTypeSwitch, - const int PPPSwitch, const int NPPSwitch, - const int neutronDecaySwitch, - const int neutrinoNeutrinoSwitch, - const double smallDistanceStep, - const double evolutionFactor, - const double convergeParameter, - const double bkgFactor, - const Spectrum* pQ_0, - const DiffRate* elNeutProtonRate, - const DiffRate* muonNeutProtonRate, - const DiffRate* tauNeutProtonRate, - const TotalRate* protonTotalRate, - const TotalRate* neutronTotalRate, - const TotalRate* neutronDecayRate, - const DiffRate* protonScatRate, - const DiffRate* protonNeutronRate, - const DiffRate* neutronProtonRate, - const DiffRate* neutronDecayProtonRate, - const dCVector* protonContinuousLoss, - const dCVector* deltaG, const Spectrum* pSpectrum, - Spectrum* pSpectrumNew); -void AdvanceNeutrinoStep(const int sourceTypeSwitch, - const int neutrinoNeutrinoSwitch, - const int PPPSwitch, const int neutronDecaySwitch, - const int nucleonToSecondarySwitch, - const double smallDistanceStep, - const double evolutionFactor, - const double convergeParameter, - const double bkgFactor, - const Spectrum* pQ_0, - const DiffRate* protonMuonNeutrinoRate, - const DiffRate* neutronAntiMuonNeutrinoRate, - const DiffRate* protonAntiMuonNeutrinoRate, - const DiffRate* neutronMuonNeutrinoRate, - const DiffRate* protonElectronNeutrinoRate, - const DiffRate* neutronAntiElectronNeutrinoRate, - const DiffRate* protonAntiElectronNeutrinoRate, - const DiffRate* neutronDecayElectronRate, - const TotalRate* elNeutTotalRate, - const TotalRate* muonNeutTotalRate, - const TotalRate* tauNeutTotalRate, - const DiffRate* elNeutScatRate, - const DiffRate* elNeutMuonNeutRate, - const DiffRate* elNeutTauNeutRate, - const DiffRate* muonNeutElNeutRate, - const DiffRate* muonNeutScatRate, - const DiffRate* muonNeutTauNeutRate, - const DiffRate* tauNeutElNeutRate, - const DiffRate* tauNeutMuonNeutRate, - const DiffRate* tauNeutScatRate, - const Spectrum* pSpectrum, Spectrum* pSpectrumNew); -void AdvanceNucNeutStep(const int sourceTypeSwitch, - const int PPPSwitch, const int NPPSwitch, - const int neutronDecaySwitch, - const int nucleonToSecondarySwitch, - const int neutrinoNeutrinoSwitch, - const double smallDistanceStep, - const double evolutionFactor, - const double convergeParameter, - const double bkgFactor, - const Spectrum* pQ_0, - const DiffRate* elNeutProtonRate, - const DiffRate* muonNeutProtonRate, - const DiffRate* tauNeutProtonRate, - const TotalRate* protonTotalRate, - const TotalRate* neutronTotalRate, - const TotalRate* neutronDecayRate, - const DiffRate* protonScatRate, - const DiffRate* protonNeutronRate, - const DiffRate* neutronProtonRate, - const DiffRate* neutronDecayProtonRate, - const DiffRate* protonMuonNeutrinoRate, - const DiffRate* neutronAntiMuonNeutrinoRate, - const DiffRate* protonAntiMuonNeutrinoRate, - const DiffRate* neutronMuonNeutrinoRate, - const DiffRate* protonElectronNeutrinoRate, - const DiffRate* neutronAntiElectronNeutrinoRate, - const DiffRate* protonAntiElectronNeutrinoRate, - const DiffRate* neutronDecayElectronRate, - const TotalRate* elNeutTotalRate, - const TotalRate* muonNeutTotalRate, - const TotalRate* tauNeutTotalRate, - const DiffRate* elNeutScatRate, - const DiffRate* elNeutMuonNeutRate, - const DiffRate* elNeutTauNeutRate, - const DiffRate* muonNeutElNeutRate, - const DiffRate* muonNeutScatRate, - const DiffRate* muonNeutTauNeutRate, - const DiffRate* tauNeutElNeutRate, - const DiffRate* tauNeutMuonNeutRate, - const DiffRate* tauNeutScatRate, - const dCVector* protonContinuousLoss, - const dCVector* deltaG, const Spectrum* pSpectrum, - Spectrum* pSpectrumNew); -void AdvanceEMStep(const int sourceTypeSwitch, const int PPSwitch, - const int ICSSwitch, const int TPPSwitch, - const int DPPSwitch, const int synchrotronSwitch, - const int PPPSwitch, const int NPPSwitch, - const int neutronDecaySwitch, - const int nucleonToSecondarySwitch, - const int neutrinoNeutrinoSwitch, - const double smallDistanceStep, - const double evolutionFactor, - const double convergeParameter, const double bkgFactor, - const Spectrum* pQ_0, - const DiffRate* photonLeptonRate, - const DiffRate* protonElectronRate, - const DiffRate* neutronPositronRate, - const DiffRate* protonPositronRate, - const DiffRate* neutronElectronRate, - const DiffRate* neutronDecayElectronRate, - const DiffRate* elNeutElectronRate, - const DiffRate* muonNeutElectronRate, - const DiffRate* tauNeutElectronRate, - const DiffRate* protonPhotonRate, - const DiffRate* elNeutPhotonRate, - const DiffRate* muonNeutPhotonRate, - const DiffRate* tauNeutPhotonRate, - const TotalRate* leptonTotalRate, - const DiffRate* leptonScatRate, - const DiffRate* leptonExchRate, - const dCVector* continuousLoss, const dCVector* deltaG, - const TotalRate* photonTotalRate, - const DiffRate* leptonPhotonRate, - const DiffRate* syncRate, const Spectrum* pSpectrum, - Spectrum* pSpectrumNew); -void RedshiftDown(const int lastIndex, const double redshiftRatio, - const dCVector* pEnergy, Spectrum* pSpectrum, - Spectrum* pSpectrumNew); -void RedshiftBinsDown(const int lastIndex, const double evolutionFactor, - const dCVector* pEnergy, double* pSpectrum, - double* pSpectrumNew); -void GetExternalFlux(const int sourceTypeSwitch, const double evolutionFactor, - const PARTICLE particle, const Spectrum* pQ_0, - Spectrum* pInfluxExt); -void ImplicitEquation(const double smallDistanceStep, - const PARTICLE particle, const Spectrum* pInflux, - const Spectrum* pInflux0, const Spectrum* pInfluxExt, - const Spectrum* pOutflux, const Spectrum* pSpectrum, - Spectrum* pSpectrumNew); -void ExplicitEquation(const double smallDistanceStep, - const PARTICLE particle, const Spectrum* pInflux, - const Spectrum* pInflux0, const Spectrum* pInfluxExt, - const Spectrum* pOutflux, const Spectrum* pSpectrum, - const Spectrum* pSpectrumNew); -void ComputeChange(const Spectrum* pSpectrumTemp, - const Spectrum* pSpectrumNew, - const PARTICLE particle, double* pChangeMax); - -#endif diff --git a/libs/dint/include/dint/background.h b/libs/dint/include/dint/background.h deleted file mode 100644 index 06ba5eae4..000000000 --- a/libs/dint/include/dint/background.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef DINT__BACKGROUND_H -#define DINT__BACKGROUND_H - -#include -#include -#include -#include -#include -#include -#include - -#include "dint/cvector.h" -#include "dint/error.h" -#include "dint/utilities.h" -#include "dint/const.h" -#include "dint/gauleg.h" - -#define GAULEG_POINTS 31 // number of gaussian quadrature points for integration - -using namespace std; - -void LoadPhotonBackground(const double redshift, - dCVector* pBgEnergy, dCVector* pBgEnergyWidth, - dCVector* pBgPhotonDensity, const int aIRFlag, - const double aZmax_IR, const int aRadioFlag, - const double aH0, const double aOmegaM, const double aOmegaLambda); -void LoadCMB(const double redshift, const dCVector* pBgEnergy, - const dCVector* pBgEnergyWidth, dCVector* pBgPhotonDensity); -void LoadIR(const double redshift, const dCVector* pBgEnergy, - const dCVector* pBgEnergyWidth, dCVector* pBgPhotonDensity, - const int aIRFlag, const double aZmax_IR); -double IR2(const double redshift, const double BgEnergy); -double HighIR(const double zTarget, const double zObserve, - const double energy0, const double deltaO, - const double deltaD); -double LowIR(const double zTarget, const double zObserve, - const double energy0, const double deltaO, - const double deltaD); -double OpticalIR(const double energy); -double DustIR(const double energy); -void LoadRadio(const double redshift, const dCVector* pBgEnergy, - const dCVector* pBgEnergyWidth, dCVector* pBgPhotonDensity, - const int aRadioFlag, const double aH0, const double aOmegaM, - const double aOmegaLambda); -double HighRadio(const double zTarget, const double zObserve, - const double energy0, const double aH0, - const double aOmegaM, const double aOmegaLambda); -double MedRadio(const double zTarget, const double zObserve, - const double energy0, const double aH0, const double aOmegaM, - const double aOmegaLambda); -double ObsRadio(const double zTarget, const double zObserve, - const double energy0, const double aH0, - const double aOmegaM, const double aOmegaLambda); -double ElecaRadio(const double zTarget, const double zObserve, - const double energy0, const double aH0, - const double aOmegaM, const double aOmegaLambda); - -/* -// Routine added by Gunter (July 2005) : -void DumpBgSpectrum(const dCVector* pBgEnergy, const dCVector* pBgEnergyWidth, - const dCVector* pBgPhotonDensity, const char* filename); -*/ - -#endif diff --git a/libs/dint/include/dint/binfread.h b/libs/dint/include/dint/binfread.h deleted file mode 100644 index da5f8b8ce..000000000 --- a/libs/dint/include/dint/binfread.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef DINT__BINFREAD_H -#define DINT__BINFREAD_H - -// T. Beau 2005 - -// Allow to deal with big / little endian machines. -// Data have been written on a Intel Machine... - -#include -#include -#include - -#if HAVE_ARPA_INET_H -#include -#endif - -#if HAVE_NETINET_IN_H -#include -#endif - -size_t binfread(void *, size_t, size_t, FILE *); - -#endif - diff --git a/libs/dint/include/dint/check.h b/libs/dint/include/dint/check.h deleted file mode 100644 index b7550b614..000000000 --- a/libs/dint/include/dint/check.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef DINT__CHECK_H -#define DINT__CHECK_H - -#include "dint/cvector.h" - -void CheckIndex(const int lowerLimit, const int upperLimit, const int i, - const char* functionName); -void DumpArray(const dCVector* pVector); - -#endif diff --git a/libs/dint/include/dint/const.h b/libs/dint/include/dint/const.h deleted file mode 100644 index d43c7630d..000000000 --- a/libs/dint/include/dint/const.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef DINT__CONST_H -#define DINT__CONST_H - - -#define ELECTRON_MASS 5.110e5 -#define DISTANCE_UNIT 3.0856e18 -#define VOLUME_UNIT 6.652448e-25*3.0856e18 -#define PI 3.141592 -#define C 3.e10 -#define H_0 71. -// Added July 2005 : cosmological parameters -#define OMEGA_M 0.3// NOW THEY ARE NOT defined like this, but taken as input parameters. -#define OMEGA_LAMBDA 0.7 // if not specified as parameters, take these values - -// CHANGE (Guenter; 7/20/1998) -#define DMAX 1.e6 -#define CLUSTER_DISTANCE 100. -#define CLUSTER_FACTOR 1. -#define SOURCE_CLUSTER_DISTANCE 0.1 -#define SOURCE_CLUSTER_FACTOR 1. - -#define NUM_IP_ELEMENTS 1309125 -#define NUM_IS_ELEMENTS 571200 -#define NUM_PP_ELEMENTS 558050 -#define NUM_TPP_ELEMENTS 548250 -// photopion production -#define NUM_PPP_PROTON_SCAT_ELEMENTS 111541 -#define NUM_PPP_PROTON_NEUTRON_ELEMENTS 111541 -#define NUM_PPP_PROTON_PHOTON_ELEMENTS 20000 -#define NUM_PPP_PROTON_ELECTRON_ELEMENTS 20000 -#define NUM_PPP_PROTON_POSITRON_ELEMENTS 20000 -// nucleon pair production -#define NUM_NPP_ELEMENTS 20000 -// neutrino production from PPP -#define NUM_PPP_PROTON_ANTI_ELECTRON_NEUTRINO_ELEMENTS 20000 -#define NUM_PPP_PROTON_MUON_NEUTRINO_ELEMENTS 20000 -#define NUM_PPP_PROTON_ANTI_MUON_NEUTRINO_ELEMENTS 20000 - -// Parameters used in the code -// Warning : those cannot be changed unless various parts of CRPropa are also changed! -#define BINS_PER_DECADE 10 // number of bins per decade -#define MIN_ENERGY_EXP 7 // minimum spectrum energy = 10 MeV -#define MAX_ENERGY_EXP (MIN_ENERGY_EXP + 17) // maximum spectrum energy - -#define BG_MIN_ENERGY_EXP (-8 - MIN_ENERGY_EXP + 7) -#define BG_MAX_ENERGY_EXP (2 - MIN_ENERGY_EXP + 7) -#define EM_MIN_ENERGY_EXP (MIN_ENERGY_EXP) -#define NUC_MIN_ENERGY_EXP (14 + MIN_ENERGY_EXP - 7) -#define NEUT_MIN_ENERGY_EXP (17 + MIN_ENERGY_EXP - 7) -#define NUM_MAIN_BINS ((MAX_ENERGY_EXP - MIN_ENERGY_EXP)*BINS_PER_DECADE) -#define NUM_BG_BINS ((BG_MAX_ENERGY_EXP - BG_MIN_ENERGY_EXP)*BINS_PER_DECADE) - -#define EM_NUM_MAIN_BINS ((MAX_ENERGY_EXP - EM_MIN_ENERGY_EXP)*BINS_PER_DECADE) -#define NUC_NUM_MAIN_BINS ((MAX_ENERGY_EXP - NUC_MIN_ENERGY_EXP)*BINS_PER_DECADE) -#define NEUT_NUM_MAIN_BINS ((MAX_ENERGY_EXP - NEUT_MIN_ENERGY_EXP)*BINS_PER_DECADE) - - -#endif diff --git a/libs/dint/include/dint/cvector.h b/libs/dint/include/dint/cvector.h deleted file mode 100644 index ce9c5e9a1..000000000 --- a/libs/dint/include/dint/cvector.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef DINT__CVECTOR_H -#define DINT__CVECTOR_H - -#include "dint/vector.h" -#include - -// these are variants of structs defined in vector.h; they have dimensional -// info built-in, and they are initialized when assigned memory -typedef struct -{ - int dimension; - dVector vector; -} dCVector; - -typedef struct -{ - int dimension1; - int dimension2; - iMatrix matrix; -} iCMatrix; - -void New_dCVector(dCVector* pVector, const int n); -void Delete_dCVector(dCVector* pVector); -void Initialize_dCVector(dCVector* pVector); - -void New_iCMatrix(iCMatrix* pMatrix, const int n1, const int n2); -void Delete_iCMatrix(iCMatrix* pMatrix); -void Initialize_iCMatrix(iCMatrix* pMatrix); - -#endif diff --git a/libs/dint/include/dint/decay.h b/libs/dint/include/dint/decay.h deleted file mode 100644 index 78351824b..000000000 --- a/libs/dint/include/dint/decay.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef DINT__DECAY_H -#define DINT__DECAY_H - -double PionToPhoton(const int iPhoton, const int iPion); -double PionToLepton(const double leptonEnergy, const double pionEnergy); -double PionToElectronNeutrino(const double neutrinoEnergy, - const double pionEnergy); -double PionToMuonNeutrino(const int iNeutrino, const int iPion); - -#endif diff --git a/libs/dint/include/dint/deriv.h b/libs/dint/include/dint/deriv.h deleted file mode 100644 index 2055d7f28..000000000 --- a/libs/dint/include/dint/deriv.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef DINT__DERIV_H -#define DINT__DERIV_H - -#include "dint/rate.h" -#include "dint/spectrum.h" -#include "dint/cvector.h" - - -void GetLeptonInfluxFromPhotons(const DiffRate* photonLeptonRate, - const Spectrum* pSpectrumNew, - Spectrum* pInflux); -void GetLeptonFluxFromLeptons(const TotalRate* leptonTotalRate, - const DiffRate* leptonScatRate, - const DiffRate* leptonExchRate, - const dCVector* continuousLoss, - const dCVector* deltaG, - const Spectrum* pSpectrumNew, Spectrum* pInflux, - Spectrum* pOutflux); -void GetPhotonInfluxFromLeptons(const DiffRate* leptonPhotonRate, - const int synchrotronSwitch, - const DiffRate* syncRate, - const Spectrum* pSpectrumNew, - Spectrum* pInflux); -void GetPhotonFluxFromPhotons(const TotalRate* photonTotalRate, - Spectrum* pOutflux); -void GetLeptonInfluxFromNucleons(const int neutronDecaySwitch, - const DiffRate* protonElectronRate, - const DiffRate* neutronPositronRate, - const DiffRate* protonPositronRate, - const DiffRate* neutronElectronRate, - const DiffRate* neutronDecayElectronRate, - const Spectrum* pSpectrumNew, - Spectrum* pInflux); -void GetPhotonInfluxFromNucleons(const DiffRate* protonPhotonRate, - const Spectrum* pSpectrumNew, - Spectrum* pInflux); -void GetLeptonInfluxFromNeutrinos(const double bkgFactor, - const DiffRate* elNeutElectronRate, - const DiffRate* muonNeutElectronRate, - const DiffRate* tauNeutElectronRate, - const Spectrum* pSpectrumNew, - Spectrum* pInflux0); -void GetPhotonInfluxFromNeutrinos(const double bkgFactor, - const DiffRate* elNeutPhotonRate, - const DiffRate* muonNeutPhotonRate, - const DiffRate* tauNeutPhotonRate, - const Spectrum* pSpectrumNew, - Spectrum* pInflux0); -void GetNucleonFluxFromNucleons(const int neutronDecaySwitch, - const TotalRate* protonTotalRate, - const TotalRate* neutronTotalRate, - const TotalRate* neutronDecayRate, - const DiffRate* protonScatRate, - const DiffRate* neutronProtonRate, - const DiffRate* protonNeutronRate, - const DiffRate* neutronDecayProtonRate, - const dCVector* protonContinuousLoss, - const dCVector* deltaG, - const Spectrum* pSpectrumNew, - Spectrum* pInflux, Spectrum* pOutflux); -void GetNeutrinoInfluxFromNucleons(const int neutronDecaySwitch, - const DiffRate* protonMuonNeutrinoRate, - const DiffRate* neutronAntiMuonNeutrinoRate, - const DiffRate* neutronMuonNeutrinoRate, - const DiffRate* protonAntiMuonNeutrinoRate, - const DiffRate* protonElectronNeutrinoRate, - const DiffRate* neutronAntiElectronNeutrinoRate, - const DiffRate* protonAntiElectronNeutrinoRate, - const DiffRate* neutronDecayElectronRate, - const Spectrum* pSpectrumNew, - Spectrum* pInflux0); -void GetNucleonInfluxFromNeutrinos(const double bkgFactor, - const DiffRate* elNeutProtonRate, - const DiffRate* muonNeutProtonRate, - const DiffRate* tauNeutProtonRate, - const Spectrum* pSpectrumNew, - Spectrum* pInflux0); -void GetNeutrinoFluxFromNeutrinos(const double bkgFactor, - const TotalRate* elNeutTotalRate, - const TotalRate* muonNeutTotalRate, - const TotalRate* tauNeutTotalRate, - const DiffRate* elNeutScatRate, - const DiffRate* elNeutMuonNeutRate, - const DiffRate* elNeutTauNeutRate, - const DiffRate* muonNeutElNeutRate, - const DiffRate* muonNeutScatRate, - const DiffRate* muonNeutTauNeutRate, - const DiffRate* tauNeutElNeutRate, - const DiffRate* tauNeutMuonNeutRate, - const DiffRate* tauNeutScatRate, - const Spectrum* pSpectrumNew, - Spectrum* pInflux, Spectrum* pOutflux); - -void ComputeOutflux(const double bkgFactor, const TotalRate* pRate, - const PARTICLE parent, Spectrum* pOutflux); -void ComputeInflux(const double bkgFactor, const DiffRate* pRate, - const PARTICLE parent, const PARTICLE daughter, - const Spectrum* pSpectrum, Spectrum* pInflux); - -#endif diff --git a/libs/dint/include/dint/error.h b/libs/dint/include/dint/error.h deleted file mode 100644 index f619c0bcf..000000000 --- a/libs/dint/include/dint/error.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef DINT__ERROR_H -#define DINT__ERROR_H - -typedef enum {NO_ERROR = 0, ARRAY_ERROR = 1, IO_ERROR = 2, PROGRAM_ERROR = 3} -ErrorCode; - -void Error(const char* errorMessage, const ErrorCode errorCode); - -#endif diff --git a/libs/dint/include/dint/final.h b/libs/dint/include/dint/final.h deleted file mode 100644 index 95245f5b9..000000000 --- a/libs/dint/include/dint/final.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef DINT__FINAL_H -#define DINT__FINAL_H - -#include "dint/spectrum.h" -#include "dint/cvector.h" - -void CheckEnergy(const int sourceTypeSwitch, const double brightPhaseExp, - const double startingRedshift, - const double rightRedshift, const Spectrum* pSpectrum, - const dCVector* pEnergy, const double initialTotalEnergy); -void FinalPrintOutToTheScreen(const double distance, - const double startingRedshift, - const double propagatingDistance); - -#endif diff --git a/libs/dint/include/dint/fold.h b/libs/dint/include/dint/fold.h deleted file mode 100644 index 883134abc..000000000 --- a/libs/dint/include/dint/fold.h +++ /dev/null @@ -1,153 +0,0 @@ -#ifndef DINT__FOLD_H -#define DINT__FOLD_H - -#include "dint/rate.h" -#include "dint/cvector.h" - -void InitializeLeptonCoefficients(TotalRate* leptonTotalRate, - DiffRate* leptonScatRate, - DiffRate* leptonExchRate, - DiffRate* leptonPhotonRate); -void InitializePhotonCoefficients(TotalRate* photonTotalRate, - DiffRate* photonLeptonRate); -void InitializeNucleonCoefficients(TotalRate* protonTotalRate, - TotalRate* neutronTotalRate, - DiffRate* protonScatRate, - DiffRate* protonNeutronRate, - DiffRate* neutronProtonRate, - DiffRate* protonPhotonRate, - DiffRate* protonElectronRate, - DiffRate* protonPositronRate, - DiffRate* neutronElectronRate, - DiffRate* neutronPositronRate, - DiffRate* protonElectronNeutrinoRate, - DiffRate* protonAntiElectronNeutrinoRate, - DiffRate* protonMuonNeutrinoRate, - DiffRate* protonAntiMuonNeutrinoRate, - DiffRate* neutronAntiElectronNeutrinoRate, - DiffRate* neutronMuonNeutrinoRate, - DiffRate* neutronAntiMuonNeutrinoRate); -void InitializeNeutrinoCoefficients(TotalRate* elNeutTotalRate, - TotalRate* muonNeutTotalRate, - TotalRate* tauNeutTotalRate, - DiffRate* elNeutScatRate, - DiffRate* elNeutMuonNeutRate, - DiffRate* elNeutTauNeutRate, - DiffRate* elNeutElectronRate, - DiffRate* elNeutPhotonRate, - DiffRate* elNeutProtonRate, - DiffRate* muonNeutElNeutRate, - DiffRate* muonNeutScatRate, - DiffRate* muonNeutTauNeutRate, - DiffRate* muonNeutElectronRate, - DiffRate* muonNeutPhotonRate, - DiffRate* muonNeutProtonRate, - DiffRate* tauNeutElNeutRate, - DiffRate* tauNeutMuonNeutRate, - DiffRate* tauNeutScatRate, - DiffRate* tauNeutElectronRate, - DiffRate* tauNeutPhotonRate, - DiffRate* tauNeutProtonRate); -void FoldTotalRate(const dCVector* pBgPhotonDensity, - const RawTotalRate* pRawTotalRate, TotalRate* pTotalRate); -void FoldDiffRate(const dCVector* pBgPhotonDensity, - const RawDiffRate* pRawDiffRate, - DiffRate* pDiffRate, const int scatSwitch, ...); -void FoldICS(const dCVector* pBgPhotonDensity, - const RawTotalRate* ICSTotalRate, - const RawDiffRate* ICSPhotonRate, const RawDiffRate* ICSScatRate, - TotalRate* leptonTotalRate, DiffRate* leptonPhotonRate, - DiffRate* leptonScatRate); -void FoldTPP(const dCVector* pBgPhotonDensity, const dCVector* pEnergy, - const RawTotalRate* TPPTotalRate, const RawDiffRate* TPPDiffRate, - TotalRate* leptonTotalRate, DiffRate* leptonScatRate, - DiffRate* leptonExchRate, dCVector* otherLoss); -void FoldPP(const dCVector* pBgPhotonDensity, const RawTotalRate* PPTotalRate, - const RawDiffRate* PPDiffRate, TotalRate* photonTotalRate, - DiffRate* photonLeptonRate); -void FoldDPP(const dCVector* pBgPhotonDensity, const RawTotalRate* DPPRate, - TotalRate* photonTotalRate, DiffRate* photonLeptonRate); -void FoldPPPNucleon(const dCVector* pBgPhotonDensity, - const RawTotalRate* PPPProtonLossRate, - const RawTotalRate* PPPNeutronLossRate, - const RawDiffRate* PPPProtonScatRate, - const RawDiffRate* PPPProtonNeutronRate, - const RawDiffRate* PPPNeutronProtonRate, - TotalRate* protonTotalRate, TotalRate* neutronTotalRate, - DiffRate* protonScatRate, DiffRate* protonNeutronRate, - DiffRate* neutronProtonRate); -void FoldPPPSecondary(const dCVector* pBgPhotonDensity, - const RawDiffRate* PPPProtonPhotonRate, - const RawDiffRate* PPPProtonElectronRate, - const RawDiffRate* PPPProtonPositronRate, - const RawDiffRate* PPPNeutronElectronRate, - const RawDiffRate* PPPProtonElectronNeutrinoRate, - const RawDiffRate* PPPProtonAntiElectronNeutrinoRate, - const RawDiffRate* PPPProtonMuonNeutrinoRate, - const RawDiffRate* PPPProtonAntiMuonNeutrinoRate, - const RawDiffRate* PPPNeutronAntiElectronNeutrinoRate, - const RawDiffRate* PPPNeutronMuonNeutrinoRate, - const RawDiffRate* PPPNeutronAntiMuonNeutrinoRate, - DiffRate* protonPhotonRate, - DiffRate* protonElectronRate, - DiffRate* protonPositronRate, - DiffRate* neutronElectronRate, - DiffRate* neutronPositronRate, - DiffRate* protonElectronNeutrinoRate, - DiffRate* protonAntiElectronNeutrinoRate, - DiffRate* protonMuonNeutrinoRate, - DiffRate* protonAntiMuonNeutrinoRate, - DiffRate* neutronAntiElectronNeutrinoRate, - DiffRate* neutronMuonNeutrinoRate, - DiffRate* neutronAntiMuonNeutrinoRate); -void FoldNPPNucleon(const dCVector* pBgPhotonDensity, const dCVector* pEnergy, - const RawTotalRate* NPPTotalRate, - dCVector* protonContinuousLoss); -void FoldNPPSecondary(const dCVector* pBgPhotonDensity, - const RawDiffRate* NPPDiffRate, - DiffRate* protonPositronRate, - DiffRate* protonElectronRate); - -void MapNeutTotalRate(const double redshift, const int lastIndex, - const int tauNeutrinoMassSwitch, - const TotalRate* NNTotalRate, - TotalRate* totalRate); -void MapNeutDiffRate(const double redshift, const int lastIndex, - const int tauNeutrinoMassSwitch, - const DiffRate* NNDiffRate, - DiffRate* diffRate); -void MapNeutRates(const double redshift, const int lastIndex, - const int tauNeutrinoMassSwitch, - const TotalRate* NNElNeutTotalRate, - const TotalRate* NNMuonNeutTotalRate, - const TotalRate* NNTauNeutTotalRate, - const DiffRate* NNElNeutScatRate, - const DiffRate* NNElNeutMuonNeutRate, - const DiffRate* NNElNeutTauNeutRate, - const DiffRate* NNElNeutElectronRate, - const DiffRate* NNElNeutPhotonRate, - const DiffRate* NNElNeutProtonRate, - const DiffRate* NNMuonNeutElNeutRate, - const DiffRate* NNMuonNeutScatRate, - const DiffRate* NNMuonNeutTauNeutRate, - const DiffRate* NNMuonNeutElectronRate, - const DiffRate* NNMuonNeutPhotonRate, - const DiffRate* NNMuonNeutProtonRate, - const DiffRate* NNTauNeutElNeutRate, - const DiffRate* NNTauNeutMuonNeutRate, - const DiffRate* NNTauNeutScatRate, - const DiffRate* NNTauNeutElectronRate, - const DiffRate* NNTauNeutPhotonRate, - const DiffRate* NNTauNeutProtonRate, - TotalRate* elNeutTotalRate, TotalRate* muonNeutTotalRate, - TotalRate* tauNeutTotalRate, DiffRate* elNeutScatRate, - DiffRate* elNeutMuonNeutRate, DiffRate* elNeutTauNeutRate, - DiffRate* elNeutElectronRate, DiffRate* elNeutPhotonRate, - DiffRate* elNeutProtonRate, DiffRate* muonNeutElNeutRate, - DiffRate* muonNeutScatRate, DiffRate* muonNeutTauNeutRate, - DiffRate* muonNeutElectronRate, DiffRate* muonNeutPhotonRate, - DiffRate* muonNeutProtonRate, DiffRate* tauNeutElNeutRate, - DiffRate* tauNeutMuonNeutRate, DiffRate* tauNeutScatRate, - DiffRate* tauNeutElectronRate, DiffRate* tauNeutPhotonRate, - DiffRate* tauNeutProtonRate); -#endif diff --git a/libs/dint/include/dint/frag.h b/libs/dint/include/dint/frag.h deleted file mode 100644 index 3dc172932..000000000 --- a/libs/dint/include/dint/frag.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef DINT__FRAG_H -#define DINT__FRAG_H - -double OldFrag(const double x); -double HillFrag(const double x); -double TestFrag(const double x); -double MLLA_25(const double x); -double MLLA_24(const double x); -double MLLA_23(const double x); -double MLLA_22(const double x); -double Susy_MLLA_25(const double x); -double Susy_MLLA_24(const double x); -double Susy_MLLA_23(const double x); -double Susy_MLLA_22(const double x); -double TDFolded(const double x); - -#endif diff --git a/libs/dint/include/dint/gauleg.h b/libs/dint/include/dint/gauleg.h deleted file mode 100644 index 9915e2492..000000000 --- a/libs/dint/include/dint/gauleg.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef DINT__GAULEG_H -#define DINT__GAULEG_H - -void Gauleg(const double x1, const double x2, double x[], double w[], - const int n); - -#endif diff --git a/libs/dint/include/dint/inject.h b/libs/dint/include/dint/inject.h deleted file mode 100644 index 9b521c166..000000000 --- a/libs/dint/include/dint/inject.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef DINT__INJECT_H -#define DINT__INJECT_H - -#include "dint/cvector.h" -#include "dint/spectrum.h" - -void SetInjectionSpectrum(const PARTICLE part, const double InjEnergy, - const double HInjEnergy, const double deltaE_hadron, - const dCVector* pEnergy, - const dCVector* pEnergyWidth, Spectrum* pQ_0); - -#endif diff --git a/libs/dint/include/dint/io_util.h b/libs/dint/include/dint/io_util.h deleted file mode 100644 index 31df6e4cb..000000000 --- a/libs/dint/include/dint/io_util.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef DINT__IO_UTIL_H -#define DINT__IO_UTIL_H - -#include - -FILE* SafeFOpen(const char* filename, const char* mode); - -#endif diff --git a/libs/dint/include/dint/load.h b/libs/dint/include/dint/load.h deleted file mode 100644 index 88bfa4e49..000000000 --- a/libs/dint/include/dint/load.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef DINT__LOAD_H -#define DINT__LOAD_H - -#include "dint/rate.h" -#include "dint/utilities.h" -#include "dint/const.h" - -#include -#include -#include -#include -#include - -#include "binfread.h" - -using namespace std; - -void LoadICSTables(RawTotalRate* ICSTotalRate, RawDiffRate* ICSPhotonRate, - RawDiffRate* ICSScatRate, const int num_main_bins, - string aDirTables); -void LoadPPTables(RawTotalRate* PPTotalRate, RawDiffRate* PPDiffRate, - const int num_main_bins, - string aDirTables); -void LoadTPPTables(RawTotalRate* TPPTotalRate, RawDiffRate* TPPDiffRate, - const int num_main_bins, string aDirTables); -void LoadDPPTables(RawTotalRate* DPPRate, const int num_main_bins, - string aDirTables); -void LoadPPPNucleonTables(RawTotalRate* PPPProtonLossRate, - RawTotalRate* PPPNeutronLossRate, - RawDiffRate* PPPProtonScatRate, - RawDiffRate* PPPProtonNeutronRate, - RawDiffRate* PPPNeutronProtonRate, - const int num_main_bins, string aDirTables); -void LoadPPPEMTables(RawDiffRate* PPPProtonPhotonRate, - RawDiffRate* PPPProtonElectronRate, - RawDiffRate* PPPProtonPositronRate, - RawDiffRate* PPPNeutronElectronRate, - const int num_main_bins, string aDirTables); -void LoadNPPNucleonTables(RawTotalRate* NPPTotalRate, const int num_main_bins, - string aDirTables); -void LoadNPPSecondaryTables(RawDiffRate* NPPDiffRate, const int num_main_bins, - string aDirTables); -void LoadPPPNeutrinoTables(RawDiffRate* PPPProtonElectronNeutrinoRate, - RawDiffRate* PPPProtonAntiElectronNeutrinoRate, - RawDiffRate* PPPProtonMuonNeutrinoRate, - RawDiffRate* PPPProtonAntiMuonNeutrinoRate, - RawDiffRate* PPPNeutronAntiElectronNeutrinoRate, - RawDiffRate* PPPNeutronMuonNeutrinoRate, - RawDiffRate* PPPNeutronAntiMuonNeutrinoRate, - const int num_main_bins, string aDirTables); -void LoadNeutronDecayNucleonTables(TotalRate* neutronDecayRate, - DiffRate* neutronDecayProtonRate, - const int num_main_bins, string aDirTables); -void LoadNeutronDecaySecondaryTables(DiffRate* neutronDecayElectronRate, - const int num_main_bins, - string aDirTables); -void LoadNeutrinoTables(const int tauNeutrinoMassSwitch, - TotalRate* NNElNeutTotalRate, - TotalRate* NNMuonNeutTotalRate, - TotalRate* NNTauNeutTotalRate, - DiffRate* NNElNeutScatRate, - DiffRate* NNElNeutMuonNeutRate, - DiffRate* NNElNeutTauNeutRate, - DiffRate* NNElNeutElectronRate, - DiffRate* NNElNeutPhotonRate, - DiffRate* NNElNeutProtonRate, - DiffRate* NNMuonNeutScatRate, - DiffRate* NNMuonNeutElNeutRate, - DiffRate* NNMuonNeutTauNeutRate, - DiffRate* NNMuonNeutElectronRate, - DiffRate* NNMuonNeutPhotonRate, - DiffRate* NNMuonNeutProtonRate, - DiffRate* NNTauNeutScatRate, - DiffRate* NNTauNeutElNeutRate, - DiffRate* NNTauNeutMuonNeutRate, - DiffRate* NNTauNeutElectronRate, - DiffRate* NNTauNeutPhotonRate, - DiffRate* NNTauNeutProtonRate, - const int num_main_bins, string aDirTables); - -#endif diff --git a/libs/dint/include/dint/math_util.h b/libs/dint/include/dint/math_util.h deleted file mode 100644 index 436b201a3..000000000 --- a/libs/dint/include/dint/math_util.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef DINT__MATH_UTIL_H -#define DINT__MATH_UTIL_H - -double DMax(const double double1, const double double2); -double DMin(const double double1, const double double2); -int IMax(const int integer1, const int integer2); -int IMin(const int integer1, const int integer2); - -#endif diff --git a/libs/dint/include/dint/prepare.h b/libs/dint/include/dint/prepare.h deleted file mode 100644 index 55b0e7a8b..000000000 --- a/libs/dint/include/dint/prepare.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef DINT__PREPARE_H -#define DINT__PREPARE_H - -#include -#include "dint/spectrum.h" -#include "dint/cvector.h" - -void SetEnergyBins(const int min_energy_exp, dCVector* pEnergy, - dCVector* pEnergyWidth); -void SetDeltaG(const dCVector* pEnergy, dCVector* pDeltaG); -void GetModeOfInput(FILE* input, int* pInputMethodSwitch); -void BasicParameterInput(FILE* input, const int argc, int* pMinEnergyExp, - int* pNumSmallSteps, - double* pConvergeParameter, - double* pStartingRedshift, - double* pStartingDistanceInMpc); -void InteractionParameterInput(FILE* input, const int argc, - int* pSynchrotronSwitch, double* pB_0, - int* pTauNeutrinoMassSwitch, int* pICSSwitch, - int* pPPSwitch, int* pTPPSwitch, - int* pDPPSwitch, int* pPPPSwitch, - int* pNPPSwitch, int* pNeutronDecaySwitch, - int* pNucleonToSecondarySwitch, - int* pNeutrinoNeutrinoSwitch); -void ModelParameterInput(FILE* input, const int argc, - int* pSourceTypeSwitch, double* pMinDistance, - double* pBrightPhaseExp, int* pModelTypeSwitch); -/* CHANGE (Guenter; 7/20/1998): BrightPhaseExp added */ -void PrepareSpectra(const int sourceTypeSwitch, const Spectrum* pQ_0, - Spectrum* pSpectrum, Spectrum* pSpectrumNew, - Spectrum* pDerivative); -void ComputeTotalInitialContent(const dCVector* pEnergy, const Spectrum* pQ_0, - double* initialPhotonEnergy, - double* initialLeptonEnergy, - double* initialNucleonEnergy, - double* initialNeutrinoEnergy, - double* initialTotalEnergy, - double* initialPhotonNumber, - double* initialLeptonNumber, - double* initialNucleonNumber, - double* initialNeutrinoNumber, - double* initialTotalNumber); -void ComputeContinuousEnergyLoss(const int synchrotronSwitch, - const dCVector* synchrotronLoss, - const dCVector* otherLoss, - dCVector* continuousLoss); - -#endif diff --git a/libs/dint/include/dint/prop_second.h b/libs/dint/include/dint/prop_second.h deleted file mode 100644 index bad37bebf..000000000 --- a/libs/dint/include/dint/prop_second.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef DINT__PROPSECOND_H -#define DINT__PROPSECOND_H - -#include -#include -#include "dint/rate.h" -#include "dint/const.h" -#include "dint/spectrum.h" -#include "dint/cvector.h" -#include "dint/load.h" -#include "dint/prepare.h" -#include "dint/sync.h" -#include "dint/inject.h" -#include "dint/background.h" -#include "dint/fold.h" -#include "dint/advance.h" -#include "dint/final.h" -#include "dint/utilities.h" -#include -#include -#include -#include -#include - -/*-------------------------------------------------------------------------- - prop_second - Main routine for the dint package - E. Armengaud - Jan 2006 ---------------------------------------------------------------------------*/ - -/* - Arguments : - - dist_observer : light travel distance in Mpc - pB_field : in Gauss - pEnergy, pEnergyWidth : in ELECTRON_MASS*eV - apInjectionSpectrum : INPUT mean number of particles per energy bin - pSpectrum : OUTPUT mean number of particles per energy bin - aDirTables : directory for cascade tables - Photon background flags : - aIRFlag = 0 (High IR), 1 (Low IR) or 2 (Primack IR) - aZmax_IR = max redshift of the infrared background - aRadioFlag = 0 (High Radio), 1 (Low Radio), 2 (Obs Radio) or 3 (Null Radio) - Cosmological parameters : H0, Omega_M/Lambda. The unit of H0 is km/s/Mpc - aCutcascade_Magfield : flag to "cut" of the e+/- cascade by the magnetic deflections. -*/ - -/*-------------------------------------------------------------------------- - The routine prop_second, used in CRPropa, propagates an electromagnetic cascade - in the extragalactic medium over a given light travel distance. - - Propagation takes place in redshift space. The energy unit used in dint is m_e (~511 keV). - The distance unit is in cm. - The magnetic field perpendicular to the trajectory must be specified. It can be - inhomogeneous, allowing to take into account probable B field concentrations inside the - clusters. 3 models of homogeneous cosmic IR background and 3 models of cosmic radio - background are implemented. - - The redshift evolution of radio background is consistent with its model (see background.cpp). - The redshift evolution of IR background is the same as for CMB until aZmax_IR. - - The input spectrum must have the same format as the output : - The output is a spectrum, computed for 170 values of energy ranging from 10^7 to 10^24 eV. - - If the aCutcascade_Magfield flag is set : at each step, we define a critical energy E_c - based on the comparison between Larmor, synchrotron and ICS time scales. - Only the electrons with r_Larmor > aCutcascade_Magfield) * min(t_synchrotron,t_ICS) are kept: - this mimics the loss of the cascade due to the deflections (useful for the study of a "point" - source; allows to test roughly the effect of B fields on the 1D approximation for the cascade). ---------------------------------------------------------------------------*/ - -void prop_second(const double dist_observer, - //const double InjEnergy, - //const PARTICLE part, - //const double HInjEnergy, const double deltaE_hadron, - const dCVector* pB_field, - const dCVector* pEnergy, - const dCVector* pEnergyWidth, - Spectrum* apInjectionSpectrum, - Spectrum* pSpectrum, string aDirTables, - const int aIRFlag, const double aZmax_IR, const int aRadioFlag, - const double aH0, const double aOmegaM, const double aOmegaLambda, - const double aCutcascade_Magfield); - -void BuildRedshiftTable(double aH0, double aOmegaM, double aOmegaLambda, - dCVector* pRedshiftArray, dCVector* pDistanceArray); - -double getRedshift(dCVector RedshiftArray, dCVector DistanceArray, double distance) ; -double getDistance(dCVector RedshiftArray, dCVector DistanceArray, double redshift) ; - -#endif diff --git a/libs/dint/include/dint/rate.h b/libs/dint/include/dint/rate.h deleted file mode 100644 index fb3c47f10..000000000 --- a/libs/dint/include/dint/rate.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef DINT__RATE_H -#define DINT__RATE_H - -#include "dint/vector.h" -#include "dint/binfread.h" - -typedef struct -{ - int mainDimension; - int bgDimension; - // int mainDimension2; /* number of daughter bins */ - int numberOfElements; - i3Tensor bound; - dVector diffRate; -} RawDiffRate; -/* although RawDiffRate is really a 3-dimensional matrix, I "serialize" - the matrix to tighten up the memory: instead of using the full - 3-dimensional matrix with lots of zeros, I replace it by a serialized - 1-dimensional array with non-zero elements and with appropriate lower - and upper bounds (bound) */ - -typedef struct -{ - int mainDimension; - int bgDimension; - dMatrix totalRate; -} RawTotalRate; - -typedef struct -{ - int mainDimension; - iMatrix bound; - dMatrix diffRate; -} DiffRate; - -typedef struct -{ - int mainDimension; - dVector totalRate; -} TotalRate; -/* NOTE: all rates are initialized when assigned memory. All bounds are - properly invalidated. */ - - -void NewRawTotalRate(RawTotalRate* pRate, const int num_main_bins, - const int num_bg_bins); -void DeleteRawTotalRate(RawTotalRate* pRate); -void InitializeRawTotalRate(RawTotalRate* pRate); -void CopyRawTotalRate(RawTotalRate* pLRate, const RawTotalRate* pRRate); -void ClipRawTotalRate(RawTotalRate* pRate, const int newSize); -void EnlargeRawTotalRate(RawTotalRate* pRate, const int newSize); -void ModifyRawTotalRate(RawTotalRate* pRate, const int newSize); -void ReadRawTotalRate(RawTotalRate* pRate, const char* filename); - - -void NewRawDiffRate(RawDiffRate* pRate, const int num_main_bins, - const int num_bg_bins, const int num_elements); -void DeleteRawDiffRate(RawDiffRate* pRate); -void InitializeRawDiffRate(RawDiffRate* pRate); -void CheckRawDiffRate(RawDiffRate* pRate); -#ifdef DEBUG -double RawDiffRateElement(const RawDiffRate* pRate, const int i, const int j, - const int k); -/* although this is a very good and safe way of getting the element - it is a very expensive call: it is recommended only for checking */ -#endif -void CopyRawDiffRate(RawDiffRate* pLRate, const RawDiffRate* pRRate); -void CopyRawDiffRateBound(RawDiffRate* pLRate, const RawDiffRate* pRRate); -void ClipRawDiffRate(RawDiffRate* pRate, const int newSize); -void EnlargeRawDiffRate(RawDiffRate* pRate, const int newSize); -void ModifyRawDiffRate(RawDiffRate* pRate, const int newSize); -void ReadRawDiffRate(RawDiffRate* pRate, const char* filename); - - -void NewTotalRate(TotalRate* pRate, const int num_main_bins); -void DeleteTotalRate(TotalRate* pRate); -void InitializeTotalRate(TotalRate* pRate); -void CopyTotalRate(TotalRate* pLRate, const TotalRate* pRRate); -void ClipTotalRate(TotalRate* pRate, const int newSize); -void EnlargeTotalRate(TotalRate* pRate, const int newSize); -void ModifyTotalRate(TotalRate* pRate, const int newSize); -void ReadTotalRate(TotalRate* pRate, const char* filename); - - -void NewDiffRate(DiffRate* pRate, const int num_main_bins); -void DeleteDiffRate(DiffRate* pRate); -void InitializeDiffRate(DiffRate* pRate); -void CopyDiffRate(DiffRate* pLRate, const DiffRate* pRRate); -void ClipDiffRate(DiffRate* pRate, const int newSize); -void EnlargeDiffRate(DiffRate* pRate, const int newSize); -void ModifyDiffRate(DiffRate* pRate, const int newSize); -void ReadDiffRate(DiffRate* pRate, const char* filename); -void CopyDiffRateBound(DiffRate* pLRate, const DiffRate* pRRate); -void SetStandardDiffRateBound(DiffRate* pRate); -/* sets DiffRate bound to 0 <= k <= i */ -void InvalidateDiffRateBound(DiffRate* pRate); - -#endif -/* Copy*Rate: perform real deep copies; i.e. they reformat the dimensions - according to the size of the rate being copied. - Copy*DiffRateBound: copy bounds without altering size. -*/ diff --git a/libs/dint/include/dint/spectrum.h b/libs/dint/include/dint/spectrum.h deleted file mode 100644 index e99ca7c46..000000000 --- a/libs/dint/include/dint/spectrum.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef DINT__SPECTRUM_H -#define DINT__SPECTRUM_H - -#include "dint/vector.h" -#include "dint/cvector.h" - -#define NUM_SPECIES 11 - -typedef enum PARTICLE { - PHOTON = 0, - ELECTRON = 1, - POSITRON = 2, - PROTON = 3, - NEUTRON = 4, - ELECTRON_NEUTRINO = 5, - ANTI_ELECTRON_NEUTRINO = 6, - MUON_NEUTRINO = 7, - ANTI_MUON_NEUTRINO = 8, - TAU_NEUTRINO = 9, - ANTI_TAU_NEUTRINO = 10, - NOTHING = 11 -} PARTICLE; -// NOTHING type added by Gunter (2005) for secondary from pair production - -/* Spectrum is a struct that corresponds to the total spectrum. It - has all particle spectra in it. Since particle data is more or less - fixed and independent, we do not specify the number of particle species. */ -typedef struct Spectrum { - int numberOfMainBins; - dMatrix spectrum; -} Spectrum; - -void NewSpectrum(Spectrum* pSpectrum, const int num_bins); -void DeleteSpectrum(Spectrum* pSpectrum); -void InitializeSpectrum(Spectrum* pSpectrum); -void InitializeEMSpectrum(Spectrum* pSpectrum); -void InitializeNucleonSpectrum(Spectrum* pSpectrum); -void InitializeNeutrinoSpectrum(Spectrum* pSpectrum); -void AddSpectrum(Spectrum* a, const Spectrum* b); -void SetSpectrum(Spectrum* pSpectrum1, const Spectrum* pSpectrum2); -void SetEMSpectrum(Spectrum* pSpectrum1, const Spectrum* pSpectrum2); -void SetNucleonSpectrum(Spectrum* pSpectrum1, const Spectrum* pSpectrum2); -void SetNeutrinoSpectrum(Spectrum* pSpectrum1, const Spectrum* pSpectrum2); -double GetNumber(const Spectrum* pSpectrum); -double GetEMNumber(const Spectrum* pSpectrum); -double GetNucleonNumber(const Spectrum* pSpectrum); -double GetNeutrinoNumber(const Spectrum* pSpectrum); -double GetEnergy(const Spectrum* pSpectrum, const dCVector* pEnergy); -double GetEMEnergy(const Spectrum* pSpectrum, const dCVector* pEnergy); -double GetNucleonEnergy(const Spectrum* pSpectrum, const dCVector* pEnergy); -double GetNeutrinoEnergy(const Spectrum* pSpectrum, const dCVector* pEnergy); -void DumpSpectrum(const dCVector* pEnergy, const dCVector* pEnergyWidth, - const Spectrum* pSpectrum, const char* filename); - -#endif diff --git a/libs/dint/include/dint/sync.h b/libs/dint/include/dint/sync.h deleted file mode 100644 index 043f68f36..000000000 --- a/libs/dint/include/dint/sync.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef DINT__SYNC_H -#define DINT__SYNC_H - -#include "dint/rate.h" -#include "dint/cvector.h" -#include -#include -#include "dint/utilities.h" -#include "dint/const.h" -#include -#include -#include -#include -using namespace std; - -void LoadSyncTable(dCVector* syncTable, string aDirTables); -void InitializeSynchrotron(const double B_0, const dCVector* pEnergy, - const dCVector* pEnergyWidth, - dCVector* synchrotronLoss, DiffRate* syncRate, - string aDirTables); - -#endif diff --git a/libs/dint/include/dint/utilities.h b/libs/dint/include/dint/utilities.h deleted file mode 100644 index fc30d0c4c..000000000 --- a/libs/dint/include/dint/utilities.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef DINT__UTILITIES_H -#define DINT__UTILITIES_H - -#include "dint/error.h" -#include "dint/io_util.h" -#include "dint/math_util.h" - -#include "dint/check.h" - -#endif diff --git a/libs/dint/include/dint/vector.h b/libs/dint/include/dint/vector.h deleted file mode 100644 index efa6098f5..000000000 --- a/libs/dint/include/dint/vector.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef DINT__VECTOR_H -#define DINT__VECTOR_H - -/* Vectors, matrices, and tensors defined here are very simple, dynamic - objects. They do not provide any bound checking nor has extra data - structure, but have very little overhead because of that. For structs - that have dimensional data built-in, see "cvector.h". -*/ - -typedef double* dVector; -typedef int* iVector; -typedef double** dMatrix; -typedef int** iMatrix; -typedef double*** d3Tensor; -typedef int*** i3Tensor; - - -dVector New_dVector(const int n); -iVector New_iVector(const int n); -dMatrix New_dMatrix(const int n1, const int n2); -iMatrix New_iMatrix(const int n1, const int n2); -d3Tensor New_d3Tensor(const int n1, const int n2, const int n3); -i3Tensor New_i3Tensor(const int n1, const int n2, const int n3); -void Delete_dVector(dVector vector); -void Delete_iVector(iVector vector); -void Delete_dMatrix(dMatrix matrix); -void Delete_iMatrix(iMatrix matrix); -void Delete_d3Tensor(d3Tensor tensor); -void Delete_i3Tensor(i3Tensor tensor); - -#endif diff --git a/libs/dint/src/DintEMCascade.cpp b/libs/dint/src/DintEMCascade.cpp deleted file mode 100644 index bee94c9bc..000000000 --- a/libs/dint/src/DintEMCascade.cpp +++ /dev/null @@ -1,363 +0,0 @@ -#include "dint/prop_second.h" -#include "dint/DintEMCascade.h" - -#include -#include -#include - - -DintEMCascade::DintEMCascade(int _aIRFlag, int _aRadioFlag, string _aDirTables, - double B, double _aH0, double _aOmegaM, double - _aOmegaLambda) : synchrotronSwitch(1), sourceTypeSwitch(0), - tauNeutrinoMassSwitch(1), ICSSwitch(1), PPSwitch(1), TPPSwitch(1), - DPPSwitch(1), PPPSwitch(0), NPPSwitch(0), neutronDecaySwitch(0), - nucleonToSecondarySwitch(0), neutrinoNeutrinoSwitch(0), aIRFlag(_aIRFlag), - aRadioFlag(_aRadioFlag), aH0(_aH0), aOmegaM(_aOmegaM), - aOmegaLambda(_aOmegaLambda), aZmax_IR(5.), aDirTables(_aDirTables) -{ - BuildRedshiftTable(aH0, aOmegaM, aOmegaLambda, &RedshiftArray, &DistanceArray) ; - - // Initialize the bField - New_dCVector(&pB_field, 1); - for (size_t i = 0; i < 1; i++) - pB_field.vector[i] = B; // B in gauss - - //-------- Set up energy bins -------- - New_dCVector(&deltaG, NUM_MAIN_BINS); - New_dCVector(&bgEnergy, NUM_BG_BINS); - New_dCVector(&bgEnergyWidth, NUM_BG_BINS); - New_dCVector(&bgPhotonDensity, NUM_BG_BINS); - - New_dCVector(&pEnergy, NUM_MAIN_BINS); - New_dCVector(&pEnergyWidth, NUM_MAIN_BINS); - SetEnergyBins(MIN_ENERGY_EXP, &pEnergy, &pEnergyWidth); - - // set energy bins - SetDeltaG(&pEnergy, &deltaG); - - SetEnergyBins(BG_MIN_ENERGY_EXP, &bgEnergy, &bgEnergyWidth); - - NewSpectrum(&Q_0, NUM_MAIN_BINS); - NewSpectrum(&spectrumNew, NUM_MAIN_BINS); - NewSpectrum(&derivative, NUM_MAIN_BINS); - - New_dCVector(&synchrotronLoss, NUM_MAIN_BINS); - New_dCVector(&otherLoss, NUM_MAIN_BINS); - New_dCVector(&continuousLoss, NUM_MAIN_BINS); - - if (ICSSwitch == 1) { - NewRawTotalRate(&ICSTotalRate, EM_NUM_MAIN_BINS, NUM_BG_BINS); - NewRawDiffRate(&ICSPhotonRate, EM_NUM_MAIN_BINS, NUM_BG_BINS, - NUM_IP_ELEMENTS); - NewRawDiffRate(&ICSScatRate, EM_NUM_MAIN_BINS, NUM_BG_BINS, - NUM_IS_ELEMENTS); - } - - if (PPSwitch == 1) { - NewRawTotalRate(&PPTotalRate, EM_NUM_MAIN_BINS, NUM_BG_BINS); - NewRawDiffRate(&PPDiffRate, EM_NUM_MAIN_BINS, NUM_BG_BINS, - NUM_PP_ELEMENTS); - } - - if (TPPSwitch == 1) { - NewRawTotalRate(&TPPTotalRate, EM_NUM_MAIN_BINS, NUM_BG_BINS); - NewRawDiffRate(&TPPDiffRate, EM_NUM_MAIN_BINS, NUM_BG_BINS, - NUM_TPP_ELEMENTS); - } - - if (DPPSwitch == 1) - NewRawTotalRate(&DPPRate, EM_NUM_MAIN_BINS, NUM_BG_BINS); - - //---- read in coefficient tables; clipping is done here if necessary ---- - if (ICSSwitch == 1) - LoadICSTables(&ICSTotalRate, &ICSPhotonRate, &ICSScatRate, - NUM_MAIN_BINS, aDirTables); - if (PPSwitch == 1) - LoadPPTables(&PPTotalRate, &PPDiffRate, NUM_MAIN_BINS, aDirTables); - if (TPPSwitch == 1) - LoadTPPTables(&TPPTotalRate, &TPPDiffRate, NUM_MAIN_BINS, aDirTables); - if (DPPSwitch == 1) - LoadDPPTables(&DPPRate, NUM_MAIN_BINS, aDirTables); - - NewTotalRate(&leptonTotalRate, NUM_MAIN_BINS); - NewTotalRate(&photonTotalRate, NUM_MAIN_BINS); - - NewTotalRate(&protonTotalRate, NUM_MAIN_BINS); - NewTotalRate(&neutronTotalRate, NUM_MAIN_BINS); - - NewDiffRate(&leptonScatRate, NUM_MAIN_BINS); - NewDiffRate(&leptonExchRate, NUM_MAIN_BINS); - NewDiffRate(&leptonPhotonRate, NUM_MAIN_BINS); - NewDiffRate(&photonLeptonRate, NUM_MAIN_BINS); - - NewDiffRate(&protonScatRate, NUM_MAIN_BINS); - NewDiffRate(&protonNeutronRate, NUM_MAIN_BINS); - NewDiffRate(&neutronProtonRate, NUM_MAIN_BINS); - NewDiffRate(&protonPhotonRate, NUM_MAIN_BINS); - NewDiffRate(&protonElectronRate, NUM_MAIN_BINS); - NewDiffRate(&protonPositronRate, NUM_MAIN_BINS); - NewDiffRate(&neutronElectronRate, NUM_MAIN_BINS); - NewDiffRate(&neutronPositronRate, NUM_MAIN_BINS); - NewDiffRate(&protonElectronNeutrinoRate, NUM_MAIN_BINS); - NewDiffRate(&protonAntiElectronNeutrinoRate, NUM_MAIN_BINS); - NewDiffRate(&protonMuonNeutrinoRate, NUM_MAIN_BINS); - NewDiffRate(&protonAntiMuonNeutrinoRate, NUM_MAIN_BINS); - NewDiffRate(&neutronAntiElectronNeutrinoRate, NUM_MAIN_BINS); - NewDiffRate(&neutronMuonNeutrinoRate, NUM_MAIN_BINS); - NewDiffRate(&neutronAntiMuonNeutrinoRate, NUM_MAIN_BINS); - - NewTotalRate(&elNeutTotalRate, NUM_MAIN_BINS); - NewTotalRate(&muonNeutTotalRate, NUM_MAIN_BINS); - NewTotalRate(&tauNeutTotalRate, NUM_MAIN_BINS); - - NewDiffRate(&elNeutElectronRate, NUM_MAIN_BINS); - NewDiffRate(&elNeutPhotonRate, NUM_MAIN_BINS); - NewDiffRate(&muonNeutElectronRate, NUM_MAIN_BINS); - NewDiffRate(&muonNeutPhotonRate, NUM_MAIN_BINS); - NewDiffRate(&tauNeutElectronRate, NUM_MAIN_BINS); - NewDiffRate(&tauNeutPhotonRate, NUM_MAIN_BINS); -} - -DintEMCascade::~DintEMCascade() -{ - DeleteDiffRate(&leptonScatRate); - DeleteDiffRate(&leptonExchRate); - DeleteDiffRate(&leptonPhotonRate); - DeleteDiffRate(&photonLeptonRate); - DeleteDiffRate(&protonScatRate); - DeleteDiffRate(&protonNeutronRate); - DeleteDiffRate(&neutronProtonRate); - DeleteDiffRate(&protonPhotonRate); - DeleteDiffRate(&protonElectronRate); - DeleteDiffRate(&protonPositronRate); - DeleteDiffRate(&neutronElectronRate); - DeleteDiffRate(&neutronPositronRate); - DeleteDiffRate(&protonElectronNeutrinoRate); - DeleteDiffRate(&protonAntiElectronNeutrinoRate); - DeleteDiffRate(&protonMuonNeutrinoRate); - DeleteDiffRate(&protonAntiMuonNeutrinoRate); - DeleteDiffRate(&neutronAntiElectronNeutrinoRate); - DeleteDiffRate(&neutronMuonNeutrinoRate); - DeleteDiffRate(&neutronAntiMuonNeutrinoRate); - - DeleteDiffRate(&elNeutElectronRate); - DeleteDiffRate(&elNeutPhotonRate); - DeleteDiffRate(&muonNeutElectronRate); - DeleteDiffRate(&muonNeutPhotonRate); - DeleteDiffRate(&tauNeutElectronRate); - DeleteDiffRate(&tauNeutPhotonRate); - - DeleteTotalRate(&leptonTotalRate); - DeleteTotalRate(&photonTotalRate); - DeleteTotalRate(&protonTotalRate); - DeleteTotalRate(&neutronTotalRate); - DeleteTotalRate(&elNeutTotalRate); - DeleteTotalRate(&muonNeutTotalRate); - DeleteTotalRate(&tauNeutTotalRate); - - if (ICSSwitch == 1) { - DeleteRawDiffRate(&ICSPhotonRate); - DeleteRawDiffRate(&ICSScatRate); - DeleteRawTotalRate(&ICSTotalRate); - } - if (PPSwitch == 1) { - DeleteRawDiffRate(&PPDiffRate); - DeleteRawTotalRate(&PPTotalRate); - } - if (TPPSwitch == 1) { - DeleteRawDiffRate(&TPPDiffRate); - DeleteRawTotalRate(&TPPTotalRate); - } - if (DPPSwitch == 1) - DeleteRawTotalRate(&DPPRate); - - DeleteSpectrum(&Q_0); - DeleteSpectrum(&spectrumNew); - DeleteSpectrum(&derivative); - - Delete_dCVector(&synchrotronLoss); - Delete_dCVector(&continuousLoss); - Delete_dCVector(&otherLoss); - - Delete_dCVector(&deltaG); - Delete_dCVector(&bgEnergy); - Delete_dCVector(&bgEnergyWidth); - Delete_dCVector(&bgPhotonDensity); - - Delete_dCVector(&RedshiftArray) ; - Delete_dCVector(&DistanceArray) ; - - Delete_dCVector(&pEnergy); - Delete_dCVector(&pEnergyWidth); -} - - -void DintEMCascade::propagate(const double start_distance, - const double stop_distance, Spectrum* apInjectionSpectrum, - Spectrum* pSpectrum, const double aCutcascade_Magfield) { - - double convergeParameter = 1.e-8; - - // -------- Redshift Estimation --------------- - double startingRedshift = getRedshift(RedshiftArray, DistanceArray, start_distance) ; - double stopRedshift = getRedshift(RedshiftArray, DistanceArray, stop_distance) ; - - double minDistance = 0.; - double brightPhaseExp = 0.; - - //---- Initialize distance ---- - - SetSpectrum(&Q_0, apInjectionSpectrum) ; - PrepareSpectra(sourceTypeSwitch, &Q_0, pSpectrum, &spectrumNew, &derivative); - - //--------- START of actual computation -------- - //---- initialize indices and parameters ---- - double leftRedshift = startingRedshift; - double deltaRedshift = 1. - (pEnergy.vector)[2]/(pEnergy.vector)[3]; - int lastIndex = 0; - double propagatingDistance = 0.; - double distance = 0.; // distance variable: dist in FORTRAN - - //-------- This is where propagation takes place -------- - do { - double rightRedshift, centralRedshift; - // this firstIndex & lastIndex pair is used to bin redshift finer - // near the end of propagation (z close to 0) - ComputeRedshifts(sourceTypeSwitch, leftRedshift, &deltaRedshift, - &rightRedshift, ¢ralRedshift, &lastIndex); - // limit the distance step to the stop redshift - if (rightRedshift < stopRedshift) - rightRedshift = stopRedshift; - - //---- compute various distance parameters ---- - double redshiftRatio = (1. + rightRedshift)/(1. + leftRedshift); - - // (cosmological parameters added July 2005) - double leftDistance = getDistance(RedshiftArray,DistanceArray,leftRedshift) ; - double rightDistance = getDistance(RedshiftArray,DistanceArray,rightRedshift) ; - double distanceStep = leftDistance - rightDistance ; - distance += distanceStep; - - int numSmallSteps = (int)(ceil(distanceStep/DISTANCE_UNIT/DMAX)); - double smallDistanceStep = distanceStep/DISTANCE_UNIT/numSmallSteps; - double x = 0.; - - //---- compute the photon background at given redshift ---- - LoadPhotonBackground(centralRedshift, &bgEnergy, &bgEnergyWidth, - &bgPhotonDensity, aIRFlag, aZmax_IR, aRadioFlag, - aH0, aOmegaM, aOmegaLambda); - - //---- initialize rates ---- - InitializeLeptonCoefficients(&leptonTotalRate, &leptonScatRate, - &leptonExchRate, &leptonPhotonRate); - InitializePhotonCoefficients(&photonTotalRate, &photonLeptonRate); - - Initialize_dCVector(&continuousLoss); - - Initialize_dCVector(&otherLoss); - - //---- fold interaction rates w/ photon background ---- - if (ICSSwitch == 1) - FoldICS(&bgPhotonDensity, &ICSTotalRate, &ICSPhotonRate, - &ICSScatRate, &leptonTotalRate, &leptonPhotonRate, - &leptonScatRate); - if (TPPSwitch == 1) - FoldTPP(&bgPhotonDensity, &pEnergy, &TPPTotalRate, &TPPDiffRate, - &leptonTotalRate, &leptonScatRate, &leptonExchRate, - &otherLoss); - if (PPSwitch == 1) - FoldPP(&bgPhotonDensity, &PPTotalRate, &PPDiffRate, - &photonTotalRate, &photonLeptonRate); - if (DPPSwitch == 1) - FoldDPP(&bgPhotonDensity, &DPPRate, &photonTotalRate, - &photonLeptonRate); - - //---- main iteration (convergence) block ---- - - for (int loopCounter = 0; loopCounter < numSmallSteps; loopCounter++) - { - double B_loc = 0; - if (synchrotronSwitch == 1) - { - NewDiffRate(&syncRate, NUM_MAIN_BINS); - int B_bins = pB_field.dimension; - int B_bin = (int)((double)(B_bins)*(propagatingDistance+x)/1.e6/ - start_distance); - B_loc=(pB_field.vector)[B_bin]; - InitializeSynchrotron(B_loc, &pEnergy, &pEnergyWidth, - &synchrotronLoss, &syncRate, - aDirTables); - } - //---- compute continuous energy loss for electrons ---- - ComputeContinuousEnergyLoss(synchrotronSwitch, &synchrotronLoss, - &otherLoss, &continuousLoss); - - // used for source evolution, disabled here - double bkgFactor = 1.; - double evolutionFactor = 0; - - AdvanceEMStep(sourceTypeSwitch, PPSwitch, ICSSwitch, - TPPSwitch, DPPSwitch, synchrotronSwitch, PPPSwitch, - NPPSwitch, neutronDecaySwitch, nucleonToSecondarySwitch, - neutrinoNeutrinoSwitch, smallDistanceStep, evolutionFactor, - convergeParameter, bkgFactor, &Q_0, &photonLeptonRate, - &protonElectronRate, &neutronPositronRate, - &protonPositronRate, &neutronElectronRate, - &neutronDecayElectronRate, &elNeutElectronRate, - &muonNeutElectronRate, &tauNeutElectronRate, - &protonPhotonRate, &elNeutPhotonRate, &muonNeutPhotonRate, - &tauNeutPhotonRate, &leptonTotalRate, &leptonScatRate, - &leptonExchRate, &continuousLoss, &deltaG, &photonTotalRate, - &leptonPhotonRate, &syncRate, pSpectrum, &spectrumNew); - - SetEMSpectrum(pSpectrum, &spectrumNew); - // update spectrum - - if (aCutcascade_Magfield != 0 && B_loc != 0 ) - { - // Estimate the effect of B field on the 1D approximation (added E.A. June 2006) - bool lEcFlag = 0 ; - int lIndex = 0; - - double a_ics = (3.-log10(4.))/4. ; - double b_ics = pow(10.,8.-7.*a_ics) ; - while (!lEcFlag) - { - double lEnergy = (pEnergy.vector)[lIndex] ; - // Time scales are computed in parsec - double t_sync = 3.84e6/(lEnergy*B_loc*B_loc*ELECTRON_MASS) ; - double t_larmor = (1.1e-21)*ELECTRON_MASS*lEnergy/(B_loc*aCutcascade_Magfield) ; - double t_ics; - if (lEnergy <= 1.e15/ELECTRON_MASS) { - t_ics = 4.e2*1.e15/(ELECTRON_MASS*lEnergy) ; - } else if (lEnergy <= 1.e18/ELECTRON_MASS) { - t_ics = 4.e2*lEnergy*ELECTRON_MASS/1.e15 ; - } else if (lEnergy <= 1.e22/ELECTRON_MASS) { - t_ics = b_ics*pow(lEnergy*ELECTRON_MASS/1.e15,a_ics) ; - } else t_ics = 1.e8*lEnergy*ELECTRON_MASS/1.e22 ; - if (t_larmor >= t_sync || t_larmor >= t_ics) lEcFlag = 1 ; - // defines the "critical" energy : the e+/- spectrum is set to 0 for Espectrum)[ELECTRON][lIndex]=0 ; - (pSpectrum->spectrum)[POSITRON][lIndex]=0 ; - lIndex++ ; - } - } - - if (synchrotronSwitch == 1) // synchrotron == true (on) - DeleteDiffRate(&syncRate); - - x += smallDistanceStep; - } // for loopCounter < numSmallSteps - - propagatingDistance += x; // increment distance - - //---- redshift bins down ---- - // Force redshiftdown to use more accurate method, see issue #174 - RedshiftDown(-1, redshiftRatio, &pEnergy, pSpectrum, &spectrumNew); - - //---- prepare for new step ---- - leftRedshift = rightRedshift; - } while ((lastIndex != 1) && (leftRedshift > stopRedshift)); - -} - diff --git a/libs/dint/src/advance.cpp b/libs/dint/src/advance.cpp deleted file mode 100644 index fdecf1248..000000000 --- a/libs/dint/src/advance.cpp +++ /dev/null @@ -1,845 +0,0 @@ - -#include "dint/advance.h" - -#ifdef DEBUG -void PrintEnergy(const dCVector* pArray, const dCVector* pEnergy) -{ - double temp = 0.; - int i; - - if (pArray->dimension != pEnergy->dimension) - { - Error("PrintEnergy: inconsistent dimensions", PROGRAM_ERROR); - } - - for (i = 0; i < pEnergy->dimension; i++) - { - temp += (pArray->vector)[i]*(pEnergy->vector)[i]; - } - - printf("%15.6E\n", temp); -} -#endif - -void ComputeRedshifts(const int sourceTypeSwitch, const double leftRedshift, - double* pDeltaRedshift, double* pRightRedshift, - double* pCentralRedshift, int* pLastIndex) { - double clusterRedshift,localRedshift,minRedshift,maxRedshift; - - clusterRedshift = pow(1.-1.5e5*H_0/C*CLUSTER_DISTANCE,-2./3.)-1.; - localRedshift = pow(1.-1.5e5*H_0/C*SOURCE_CLUSTER_DISTANCE,-2./3.)-1.; - maxRedshift = localRedshift; - minRedshift = maxRedshift; - if (clusterRedshift > maxRedshift) - maxRedshift = clusterRedshift; - else - minRedshift = clusterRedshift; - if (sourceTypeSwitch == 0) - minRedshift = maxRedshift; - - if ((*pLastIndex == 0) && (leftRedshift < 0.6)) { - *pDeltaRedshift /= 2.; - *pLastIndex = 3; - } - *pRightRedshift = leftRedshift - (1. + leftRedshift)*(*pDeltaRedshift); - if (*pRightRedshift < 0.) { - *pRightRedshift = 0.; - *pLastIndex = 1; - } - *pCentralRedshift = (leftRedshift + *pRightRedshift)/2.; - if ((*pLastIndex == 1) && (*pCentralRedshift > maxRedshift)) { - *pRightRedshift = maxRedshift; - *pCentralRedshift = (leftRedshift + *pRightRedshift)/2.; - *pLastIndex = 2; - } - - if ((*pLastIndex == 1) && (*pCentralRedshift > minRedshift)) { - *pRightRedshift = minRedshift; - *pCentralRedshift = (leftRedshift + *pRightRedshift)/2.; - *pLastIndex = 2; - } - -} - -void AdvanceNucleonStep(const int sourceTypeSwitch, - const int PPPSwitch, const int NPPSwitch, - const int neutronDecaySwitch, - const int neutrinoNeutrinoSwitch, - const double smallDistanceStep, - const double evolutionFactor, - const double convergeParameter, - const double bkgFactor, - const Spectrum* pQ_0, - const DiffRate* elNeutProtonRate, - const DiffRate* muonNeutProtonRate, - const DiffRate* tauNeutProtonRate, - const TotalRate* protonTotalRate, - const TotalRate* neutronTotalRate, - const TotalRate* neutronDecayRate, - const DiffRate* protonScatRate, - const DiffRate* protonNeutronRate, - const DiffRate* neutronProtonRate, - const DiffRate* neutronDecayProtonRate, - const dCVector* protonContinuousLoss, - const dCVector* deltaG, const Spectrum* pSpectrum, - Spectrum* pSpectrumNew) { - Spectrum spectrumTemp; - Spectrum influx; - Spectrum influx0; - Spectrum influxExt; - Spectrum outflux; - int num_main_bins; - double changeMax; - - num_main_bins = pSpectrum->numberOfMainBins; - - NewSpectrum(&spectrumTemp, num_main_bins); - NewSpectrum(&influx, num_main_bins); - NewSpectrum(&influx0, num_main_bins); - NewSpectrum(&influxExt, num_main_bins); - NewSpectrum(&outflux, num_main_bins); - - GetExternalFlux(sourceTypeSwitch, evolutionFactor, PROTON, pQ_0, - &influxExt); - GetExternalFlux(sourceTypeSwitch, evolutionFactor, NEUTRON, pQ_0, - &influxExt); - - if (neutrinoNeutrinoSwitch == 1) - GetNucleonInfluxFromNeutrinos(bkgFactor, elNeutProtonRate, - muonNeutProtonRate, tauNeutProtonRate, - pSpectrumNew, &influx0); - - do { - SetNucleonSpectrum(&spectrumTemp, pSpectrumNew); - - InitializeSpectrum(&influx); - InitializeSpectrum(&outflux); - - if ((PPPSwitch == 1) || (NPPSwitch == 1) || - (neutronDecaySwitch == 1)) { - // call all the processes that produce nucleons from nucleons - GetNucleonFluxFromNucleons(neutronDecaySwitch, protonTotalRate, - neutronTotalRate, neutronDecayRate, protonScatRate, - neutronProtonRate, protonNeutronRate, - neutronDecayProtonRate, protonContinuousLoss, - deltaG, pSpectrumNew, &influx, &outflux); - } - - ImplicitEquation(smallDistanceStep, PROTON, &influx, &influx0, - &influxExt, &outflux, pSpectrum, pSpectrumNew); - ImplicitEquation(smallDistanceStep, NEUTRON, &influx, &influx0, - &influxExt, &outflux, pSpectrum, pSpectrumNew); - - changeMax = 0.; - ComputeChange(&spectrumTemp, pSpectrumNew, PROTON, &changeMax); - ComputeChange(&spectrumTemp, pSpectrumNew, NEUTRON, &changeMax); - } while (changeMax > convergeParameter); - - DeleteSpectrum(&spectrumTemp); - DeleteSpectrum(&influx); - DeleteSpectrum(&influx0); - DeleteSpectrum(&influxExt); - DeleteSpectrum(&outflux); -} - - -void AdvanceNeutrinoStep(const int sourceTypeSwitch, - const int neutrinoNeutrinoSwitch, - const int PPPSwitch, - const int neutronDecaySwitch, - const int nucleonToSecondarySwitch, - const double smallDistanceStep, - const double evolutionFactor, - const double convergeParameter, - const double bkgFactor, - const Spectrum* pQ_0, - const DiffRate* protonMuonNeutrinoRate, - const DiffRate* neutronAntiMuonNeutrinoRate, - const DiffRate* protonAntiMuonNeutrinoRate, - const DiffRate* neutronMuonNeutrinoRate, - const DiffRate* protonElectronNeutrinoRate, - const DiffRate* neutronAntiElectronNeutrinoRate, - const DiffRate* protonAntiElectronNeutrinoRate, - const DiffRate* neutronDecayElectronRate, - const TotalRate* elNeutTotalRate, - const TotalRate* muonNeutTotalRate, - const TotalRate* tauNeutTotalRate, - const DiffRate* elNeutScatRate, - const DiffRate* elNeutMuonNeutRate, - const DiffRate* elNeutTauNeutRate, - const DiffRate* muonNeutElNeutRate, - const DiffRate* muonNeutScatRate, - const DiffRate* muonNeutTauNeutRate, - const DiffRate* tauNeutElNeutRate, - const DiffRate* tauNeutMuonNeutRate, - const DiffRate* tauNeutScatRate, - const Spectrum* pSpectrum, Spectrum* pSpectrumNew) { - double changeMax; - int num_main_bins; - Spectrum spectrumTemp; - Spectrum influx; - Spectrum influx0; - Spectrum influxExt; - Spectrum outflux; - - num_main_bins = pSpectrum->numberOfMainBins; - - NewSpectrum(&spectrumTemp, num_main_bins); - NewSpectrum(&influx, num_main_bins); - NewSpectrum(&influx0, num_main_bins); - NewSpectrum(&influxExt, num_main_bins); - NewSpectrum(&outflux, num_main_bins); - - // SetNeutrinoSpectrum(spectrumNew, spectrum); - - GetExternalFlux(sourceTypeSwitch, evolutionFactor, MUON_NEUTRINO, pQ_0, - &influxExt); - GetExternalFlux(sourceTypeSwitch, evolutionFactor, ANTI_MUON_NEUTRINO, - pQ_0, &influxExt); - GetExternalFlux(sourceTypeSwitch, evolutionFactor, ELECTRON_NEUTRINO, pQ_0, - &influxExt); - GetExternalFlux(sourceTypeSwitch, evolutionFactor, ANTI_ELECTRON_NEUTRINO, - pQ_0, &influxExt); - GetExternalFlux(sourceTypeSwitch, evolutionFactor, TAU_NEUTRINO, pQ_0, - &influxExt); - GetExternalFlux(sourceTypeSwitch, evolutionFactor, ANTI_TAU_NEUTRINO, pQ_0, - &influxExt); - - InitializeSpectrum(&influx0); - /* this is not really necessary but will keep it for redundancy */ - - /* neutrino influx from nucleons */ - if (nucleonToSecondarySwitch == 1) - { - if ((PPPSwitch == 1) || (neutronDecaySwitch == 1)) - { - GetNeutrinoInfluxFromNucleons(neutronDecaySwitch, - protonMuonNeutrinoRate, neutronAntiMuonNeutrinoRate, - neutronMuonNeutrinoRate, protonAntiMuonNeutrinoRate, - protonElectronNeutrinoRate, neutronAntiElectronNeutrinoRate, - protonAntiElectronNeutrinoRate, neutronDecayElectronRate, - pSpectrumNew, &influx0); - } - } - - do { - SetNeutrinoSpectrum(&spectrumTemp, pSpectrumNew); - - InitializeSpectrum(&influx); - InitializeSpectrum(&outflux); - - /* call processes that produce neutrinos from neutrinos */ - if (neutrinoNeutrinoSwitch == 1) - { - GetNeutrinoFluxFromNeutrinos(bkgFactor, elNeutTotalRate, - muonNeutTotalRate, - tauNeutTotalRate, elNeutScatRate, elNeutMuonNeutRate, - elNeutTauNeutRate, muonNeutElNeutRate, muonNeutScatRate, - muonNeutTauNeutRate, tauNeutElNeutRate, tauNeutMuonNeutRate, - tauNeutScatRate, pSpectrumNew, &influx, &outflux); - } - - ImplicitEquation(smallDistanceStep, MUON_NEUTRINO, &influx, - &influx0, &influxExt, &outflux, pSpectrum, pSpectrumNew); - ImplicitEquation(smallDistanceStep, ANTI_MUON_NEUTRINO, &influx, - &influx0, &influxExt, &outflux, pSpectrum, pSpectrumNew); - ImplicitEquation(smallDistanceStep, ELECTRON_NEUTRINO, &influx, - &influx0, &influxExt, &outflux, pSpectrum, pSpectrumNew); - ImplicitEquation(smallDistanceStep, ANTI_ELECTRON_NEUTRINO, &influx, - &influx0, &influxExt, &outflux, pSpectrum, pSpectrumNew); - ImplicitEquation(smallDistanceStep, TAU_NEUTRINO, &influx, - &influx0, &influxExt, &outflux, pSpectrum, pSpectrumNew); - ImplicitEquation(smallDistanceStep, ANTI_TAU_NEUTRINO, &influx, - &influx0, &influxExt, &outflux, pSpectrum, pSpectrumNew); - - changeMax = 0.; - ComputeChange(&spectrumTemp, pSpectrumNew, ELECTRON_NEUTRINO, - &changeMax); - ComputeChange(&spectrumTemp, pSpectrumNew, ANTI_ELECTRON_NEUTRINO, - &changeMax); - ComputeChange(&spectrumTemp, pSpectrumNew, MUON_NEUTRINO, - &changeMax); - ComputeChange(&spectrumTemp, pSpectrumNew, ANTI_MUON_NEUTRINO, - &changeMax); - ComputeChange(&spectrumTemp, pSpectrumNew, TAU_NEUTRINO, - &changeMax); - ComputeChange(&spectrumTemp, pSpectrumNew, ANTI_TAU_NEUTRINO, - &changeMax); - } while (changeMax > convergeParameter); - - DeleteSpectrum(&spectrumTemp); - DeleteSpectrum(&influx); - DeleteSpectrum(&influx0); - DeleteSpectrum(&influxExt); - DeleteSpectrum(&outflux); -} - -void AdvanceNucNeutStep(const int sourceTypeSwitch, - const int PPPSwitch, const int NPPSwitch, - const int neutronDecaySwitch, - const int nucleonToSecondarySwitch, - const int neutrinoNeutrinoSwitch, - const double smallDistanceStep, - const double evolutionFactor, - const double convergeParameter, - const double bkgFactor, - const Spectrum* pQ_0, - const DiffRate* elNeutProtonRate, - const DiffRate* muonNeutProtonRate, - const DiffRate* tauNeutProtonRate, - const TotalRate* protonTotalRate, - const TotalRate* neutronTotalRate, - const TotalRate* neutronDecayRate, - const DiffRate* protonScatRate, - const DiffRate* protonNeutronRate, - const DiffRate* neutronProtonRate, - const DiffRate* neutronDecayProtonRate, - const DiffRate* protonMuonNeutrinoRate, - const DiffRate* neutronAntiMuonNeutrinoRate, - const DiffRate* protonAntiMuonNeutrinoRate, - const DiffRate* neutronMuonNeutrinoRate, - const DiffRate* protonElectronNeutrinoRate, - const DiffRate* neutronAntiElectronNeutrinoRate, - const DiffRate* protonAntiElectronNeutrinoRate, - const DiffRate* neutronDecayElectronRate, - const TotalRate* elNeutTotalRate, - const TotalRate* muonNeutTotalRate, - const TotalRate* tauNeutTotalRate, - const DiffRate* elNeutScatRate, - const DiffRate* elNeutMuonNeutRate, - const DiffRate* elNeutTauNeutRate, - const DiffRate* muonNeutElNeutRate, - const DiffRate* muonNeutScatRate, - const DiffRate* muonNeutTauNeutRate, - const DiffRate* tauNeutElNeutRate, - const DiffRate* tauNeutMuonNeutRate, - const DiffRate* tauNeutScatRate, - const dCVector* protonContinuousLoss, - const dCVector* deltaG, const Spectrum* pSpectrum, - Spectrum* pSpectrumNew) -{ - Spectrum spectrumGlobalTemp; - /* temporary spectrum used in swapping spectra */ - double changeGlobal; - int num_main_bins; - - num_main_bins = pSpectrum->numberOfMainBins; - - NewSpectrum(&spectrumGlobalTemp, num_main_bins); - - do { - SetNucleonSpectrum(&spectrumGlobalTemp, pSpectrumNew); - SetNeutrinoSpectrum(&spectrumGlobalTemp, pSpectrumNew); - - - AdvanceNucleonStep(sourceTypeSwitch, PPPSwitch, NPPSwitch, - neutronDecaySwitch, neutrinoNeutrinoSwitch, smallDistanceStep, - evolutionFactor, convergeParameter, bkgFactor, pQ_0, - elNeutProtonRate, muonNeutProtonRate, tauNeutProtonRate, - protonTotalRate, neutronTotalRate, neutronDecayRate, - protonScatRate, protonNeutronRate, neutronProtonRate, - neutronDecayProtonRate, protonContinuousLoss, deltaG, pSpectrum, - pSpectrumNew); - - AdvanceNeutrinoStep(sourceTypeSwitch, neutrinoNeutrinoSwitch, - PPPSwitch, neutronDecaySwitch, nucleonToSecondarySwitch, - smallDistanceStep, evolutionFactor, convergeParameter, bkgFactor, - pQ_0, protonMuonNeutrinoRate, neutronAntiMuonNeutrinoRate, - protonAntiMuonNeutrinoRate, neutronMuonNeutrinoRate, - protonElectronNeutrinoRate, neutronAntiElectronNeutrinoRate, - protonAntiElectronNeutrinoRate, neutronDecayElectronRate, - elNeutTotalRate, muonNeutTotalRate, tauNeutTotalRate, - elNeutScatRate, elNeutMuonNeutRate, elNeutTauNeutRate, - muonNeutElNeutRate, muonNeutScatRate, muonNeutTauNeutRate, - tauNeutElNeutRate, tauNeutMuonNeutRate, tauNeutScatRate, - pSpectrum, pSpectrumNew); - - /*global convergence */ - changeGlobal = 0.; - ComputeChange(&spectrumGlobalTemp, pSpectrumNew, PROTON, - &changeGlobal); - ComputeChange(&spectrumGlobalTemp, pSpectrumNew, NEUTRON, - &changeGlobal); - ComputeChange(&spectrumGlobalTemp, pSpectrumNew, ELECTRON_NEUTRINO, - &changeGlobal); - ComputeChange(&spectrumGlobalTemp, pSpectrumNew, - ANTI_ELECTRON_NEUTRINO, &changeGlobal); - ComputeChange(&spectrumGlobalTemp, pSpectrumNew, MUON_NEUTRINO, - &changeGlobal); - ComputeChange(&spectrumGlobalTemp, pSpectrumNew, ANTI_MUON_NEUTRINO, - &changeGlobal); - ComputeChange(&spectrumGlobalTemp, pSpectrumNew, TAU_NEUTRINO, - &changeGlobal); - ComputeChange(&spectrumGlobalTemp, pSpectrumNew, ANTI_TAU_NEUTRINO, - &changeGlobal); - } while (changeGlobal > convergeParameter); - - - DeleteSpectrum(&spectrumGlobalTemp); -} - - -void AdvanceEMStep(const int sourceTypeSwitch, const int PPSwitch, - const int ICSSwitch, const int TPPSwitch, - const int DPPSwitch, const int synchrotronSwitch, - const int PPPSwitch, const int NPPSwitch, - const int neutronDecaySwitch, - const int nucleonToSecondarySwitch, - const int neutrinoNeutrinoSwitch, - const double smallDistanceStep, - const double evolutionFactor, - const double convergeParameter, const double bkgFactor, - const Spectrum* pQ_0, - const DiffRate* photonLeptonRate, - const DiffRate* protonElectronRate, - const DiffRate* neutronPositronRate, - const DiffRate* protonPositronRate, - const DiffRate* neutronElectronRate, - const DiffRate* neutronDecayElectronRate, - const DiffRate* elNeutElectronRate, - const DiffRate* muonNeutElectronRate, - const DiffRate* tauNeutElectronRate, - const DiffRate* protonPhotonRate, - const DiffRate* elNeutPhotonRate, - const DiffRate* muonNeutPhotonRate, - const DiffRate* tauNeutPhotonRate, - const TotalRate* leptonTotalRate, - const DiffRate* leptonScatRate, - const DiffRate* leptonExchRate, - const dCVector* continuousLoss, const dCVector* deltaG, - const TotalRate* photonTotalRate, - const DiffRate* leptonPhotonRate, - const DiffRate* syncRate, const Spectrum* pSpectrum, - Spectrum* pSpectrumNew) -{ - int i; - Spectrum spectrumTemp; - Spectrum spectrumGlobalTemp; - /* temporary spectra used in swapping spectra */ - Spectrum influx; - Spectrum influx0; - Spectrum influxExt; - Spectrum outflux; - double changeMax; - /* maximum difference by advance: diff in FORTRAN */ - double changeGlobal; - int num_main_bins; - - num_main_bins = pSpectrum->numberOfMainBins; - - NewSpectrum(&spectrumTemp, num_main_bins); - NewSpectrum(&spectrumGlobalTemp, num_main_bins); - NewSpectrum(&influx, num_main_bins); - NewSpectrum(&influx0, num_main_bins); - NewSpectrum(&influxExt, num_main_bins); - NewSpectrum(&outflux, num_main_bins); - - do { - SetEMSpectrum(&spectrumGlobalTemp, pSpectrumNew); - - // for (i = 0; i < NUM_MAIN_BINS; i++) - // spectrumOld[PHOTON][i] = spectrumNew[PHOTON][i]; - /* I don't think I need it here... */ - - /*---- Converge e+/- first ----*/ - InitializeSpectrum(&influxExt); - - /* external injection */ - GetExternalFlux(sourceTypeSwitch, evolutionFactor, ELECTRON, pQ_0, - &influxExt); - GetExternalFlux(sourceTypeSwitch, evolutionFactor, POSITRON, pQ_0, - &influxExt); - - - InitializeSpectrum(&influx0); - - /* influx from pair production/double pair production */ - if ((PPSwitch == 1) || (DPPSwitch == 1)) - { - GetLeptonInfluxFromPhotons(photonLeptonRate, pSpectrumNew, - &influx0); - } - - /* influx from nucleons */ - if (nucleonToSecondarySwitch == 1) /* secondary tables included */ - { - if ((PPPSwitch == 1) || (NPPSwitch == 1) || - (neutronDecaySwitch == 1)) - { - GetLeptonInfluxFromNucleons(neutronDecaySwitch, - protonElectronRate, neutronPositronRate, - protonPositronRate, neutronElectronRate, - neutronDecayElectronRate, pSpectrumNew, &influx0); - } - } - - /* influx from neutrinos */ - if (neutrinoNeutrinoSwitch == 1) - { - GetLeptonInfluxFromNeutrinos(bkgFactor, elNeutElectronRate, - muonNeutElectronRate, tauNeutElectronRate, pSpectrumNew, - &influx0); - } - - do { - for (i = 0; i < num_main_bins; i++) - { - spectrumTemp.spectrum[ELECTRON][i] = - (pSpectrumNew->spectrum)[ELECTRON][i]; - spectrumTemp.spectrum[POSITRON][i] = - (pSpectrumNew->spectrum)[POSITRON][i]; - } - - InitializeSpectrum(&influx); - InitializeSpectrum(&outflux); - - /* influx & outflux from inverse Compton scattering/synchrotron - radiation */ - if ((ICSSwitch == 1) || (TPPSwitch == 1) || - (synchrotronSwitch == 1)) - { - GetLeptonFluxFromLeptons(leptonTotalRate, leptonScatRate, - leptonExchRate, continuousLoss, deltaG, pSpectrumNew, - &influx, &outflux); - } - - ImplicitEquation(smallDistanceStep, ELECTRON, &influx, &influx0, - &influxExt, &outflux, pSpectrum, pSpectrumNew); - ImplicitEquation(smallDistanceStep, POSITRON, &influx, &influx0, - &influxExt, &outflux, pSpectrum, pSpectrumNew); - /* main difference equation part */ - - changeMax = 0.; - ComputeChange(&spectrumTemp, pSpectrumNew, ELECTRON, &changeMax); - ComputeChange(&spectrumTemp, pSpectrumNew, POSITRON, &changeMax); - } while (changeMax > convergeParameter); - - - /*---- Converge photons ----*/ - /* external influx */ - InitializeSpectrum(&influxExt); - - GetExternalFlux(sourceTypeSwitch, evolutionFactor, PHOTON, pQ_0, - &influxExt); - - InitializeSpectrum(&influx0); - - /* influx from electrons (ICS/synchrotron) */ - if ((ICSSwitch == 1) || (synchrotronSwitch == 1)) - { - GetPhotonInfluxFromLeptons(leptonPhotonRate, synchrotronSwitch, - syncRate, pSpectrumNew, &influx0); - } - - /* influx from nucleons */ - if ((nucleonToSecondarySwitch == 1) && (PPPSwitch == 1)) - { - GetPhotonInfluxFromNucleons(protonPhotonRate, pSpectrumNew, - &influx0); - } - if (neutrinoNeutrinoSwitch == 1) - { - GetPhotonInfluxFromNeutrinos(bkgFactor, elNeutPhotonRate, - muonNeutPhotonRate, tauNeutPhotonRate, pSpectrumNew, &influx0); - } - - do { - for (i = 0; i < num_main_bins; i++) - { - spectrumTemp.spectrum[PHOTON][i] = - (pSpectrumNew->spectrum)[PHOTON][i]; - } - - /* loss (and zero gain) by PP/DPP */ - InitializeSpectrum(&outflux); - if ((PPSwitch == 1) || (DPPSwitch == 1)) - { - GetPhotonFluxFromPhotons(photonTotalRate, &outflux); - } - - ImplicitEquation(smallDistanceStep, PHOTON, &influx, &influx0, - &influxExt, &outflux, pSpectrum, pSpectrumNew); - /* main difference equation */ - - changeMax = 0.; /* reset it for photons */ - ComputeChange(&spectrumTemp, pSpectrumNew, PHOTON, &changeMax); - } while (changeMax > convergeParameter); - - /*global convergence */ - changeGlobal = 0.; - ComputeChange(&spectrumGlobalTemp, pSpectrumNew, ELECTRON, - &changeGlobal); - ComputeChange(&spectrumGlobalTemp, pSpectrumNew, POSITRON, - &changeGlobal); - ComputeChange(&spectrumGlobalTemp, pSpectrumNew, PHOTON, - &changeGlobal); - } while (changeGlobal > convergeParameter); - - DeleteSpectrum(&spectrumTemp); - DeleteSpectrum(&spectrumGlobalTemp); - DeleteSpectrum(&influx); - DeleteSpectrum(&influx0); - DeleteSpectrum(&influxExt); - DeleteSpectrum(&outflux); -} - - -void RedshiftDown(const int lastIndex, const double redshiftRatio, - const dCVector* pEnergy, Spectrum* pSpectrum, - Spectrum* pSpectrumNew) -{ - int i; - - if (pEnergy->dimension != pSpectrum->numberOfMainBins) - { - Error("RedshiftDown: inconsistent dimensions", PROGRAM_ERROR); - } - for (i = 0; i < NUM_SPECIES; i++) - { - RedshiftBinsDown(lastIndex, redshiftRatio, pEnergy, - pSpectrum->spectrum[i], pSpectrumNew->spectrum[i]); - } -} - - -void RedshiftBinsDown(const int lastIndex, const double redshiftRatio, - const dCVector* pEnergy, double* pSpectrum, - double* pSpectrumNew) -/* redshift particle distributions at the end of a big dx */ -{ - int i; - int num_main_bins; - double averaging_factor; - - averaging_factor = (pow(10., 1./2./BINS_PER_DECADE) + - pow(10., -1./2./BINS_PER_DECADE))/2.; - - num_main_bins = pEnergy->dimension; - - if (lastIndex == 0) /* normal steps far from end */ - { - for (i = 0; i < num_main_bins-1; i++) - { - pSpectrum[i] = pSpectrum[i+1]*redshiftRatio* - redshiftRatio*redshiftRatio; - } - pSpectrum[num_main_bins-1] = 0.; - } - else - /* if it's close to z = 0, need some fine tuning because redshift - steps are taken more finely */ - { - // double spectrumTemp[NUM_MAIN_BINS]; - dCVector spectrumTemp; - double energyTemp; - double inflow; - int iMod; - int iMod2; - double tempFraction; - double tempExponent; - - New_dCVector(&spectrumTemp, num_main_bins); - - for (i = 0; i < num_main_bins; i++) - { - energyTemp = (pEnergy->vector)[i]/redshiftRatio; - if (energyTemp > (pEnergy->vector)[num_main_bins-1]/ - averaging_factor*pow(10., 1./2./BINS_PER_DECADE)) - { - inflow = 0.; - } - else - { - iMod = (int)(BINS_PER_DECADE*(log10(energyTemp*ELECTRON_MASS) - - MAX_ENERGY_EXP) + (num_main_bins + 0.5)); -#ifdef DEBUG - CheckIndex(0, num_main_bins, iMod, "RedshiftBinsDown"); -#endif - if ((pEnergy->vector)[iMod] > energyTemp) - { - iMod--; - } - if (iMod < 0) - { - Error("RedshiftBinsDown: iMod became negative.", - PROGRAM_ERROR); /* get the hell out of here! */ - } - iMod2 = iMod + 1; - if (iMod2 >= num_main_bins) - { - inflow = pSpectrum[num_main_bins-1]; - } - else if ((pSpectrum[iMod] < 1.e-40) || - (pSpectrum[iMod2] < 1.e-40)) - { -#ifdef DEBUG - CheckIndex(0, num_main_bins, iMod2, "RedshiftBinsDown"); -#endif - tempFraction = (energyTemp - (pEnergy->vector)[iMod])/ - ((pEnergy->vector)[iMod2] - (pEnergy->vector)[iMod]); - if (tempFraction < 0.) - { - tempFraction = 0.; - } - inflow = pSpectrum[iMod]*(1. - tempFraction) + - pSpectrum[iMod2]*tempFraction; - } - else - { - tempExponent = log(energyTemp/(pEnergy->vector)[iMod])/ - log((pEnergy->vector)[iMod2]/(pEnergy->vector)[iMod]); - inflow = pSpectrum[iMod]*pow(pSpectrum[iMod2]/ - pSpectrum[iMod], tempExponent); - } - } - spectrumTemp.vector[i] = inflow*redshiftRatio*redshiftRatio* - redshiftRatio; - } - -#ifdef DEBUG - if (spectrumTemp.vector[num_main_bins-1] > pSpectrum[num_main_bins-1]) - printf("Auch!!!\n"); -#endif - - for (i = 0; i < num_main_bins; i++) - { - if (spectrumTemp.vector[i] < 0.) - { - Error("RedshiftBinsDown: spectrumTemp negative.", - PROGRAM_ERROR); - } - pSpectrum[i] = spectrumTemp.vector[i]; - pSpectrumNew[i] = pSpectrum[i]; - } - Delete_dCVector(&spectrumTemp); - } -} - - -void GetExternalFlux(const int sourceTypeSwitch, const double evolutionFactor, - const PARTICLE particle, const Spectrum* pQ_0, - Spectrum* pInfluxExt) -{ - int i; - - if (pQ_0->numberOfMainBins != pInfluxExt->numberOfMainBins) - { - Error("GetExternalFlux: inconsistent dimensions", PROGRAM_ERROR); - } - - for (i = 0; i < pQ_0->numberOfMainBins; i++) - { - if (sourceTypeSwitch == 0) /* single source */ - { - (pInfluxExt->spectrum)[particle][i] = 0.; - } - else - { - (pInfluxExt->spectrum)[particle][i] = - (pQ_0->spectrum)[particle][i]*evolutionFactor; - } - } -} - -void ImplicitEquation(const double smallDistanceStep, - const PARTICLE particle, const Spectrum* pInflux, - const Spectrum* pInflux0, const Spectrum* pInfluxExt, - const Spectrum* pOutflux, const Spectrum* pSpectrum, - Spectrum* pSpectrumNew) -{ - /* influx: influx from the same KIND of species (e-: e+/-, p: p/n, etc.) - influx0: influx from other species - influxExt: external influx - NOTE: there is no fundamental distinction between influx and influx0 */ - int i; - int num_main_bins; - - num_main_bins = pSpectrum->numberOfMainBins; - - if ((pInflux->numberOfMainBins != num_main_bins) || - (pInflux0->numberOfMainBins != num_main_bins) || - (pInfluxExt->numberOfMainBins != num_main_bins) || - (pOutflux->numberOfMainBins != num_main_bins) || - (pSpectrumNew->numberOfMainBins != num_main_bins)) - { - Error("ImplicitEquation: inconsistent dimensions", PROGRAM_ERROR); - } - - for (i = 0; i < num_main_bins; i++) - { - (pSpectrumNew->spectrum)[particle][i] = - ((pInflux->spectrum)[particle][i] + - (pInflux0->spectrum)[particle][i] + - (pInfluxExt->spectrum)[particle][i] + - (pSpectrum->spectrum)[particle][i]/smallDistanceStep)/ - ((pOutflux->spectrum)[particle][i] + 1./smallDistanceStep); - /* main difference equation */ - - if ((pSpectrumNew->spectrum)[particle][i] < 0.) - { - (pSpectrumNew->spectrum)[particle][i] = 0.; - } - /* reset if it passes below zero */ - } -} - -void ExplicitEquation(const double smallDistanceStep, - const PARTICLE particle, const Spectrum* pInflux, - const Spectrum* pInflux0, const Spectrum* pInfluxExt, - const Spectrum* pOutflux, const Spectrum* pSpectrum, - const Spectrum* pSpectrumNew) -{ - int i; - int num_main_bins; - - num_main_bins = pSpectrum->numberOfMainBins; - - if ((pInflux->numberOfMainBins != num_main_bins) || - (pInflux0->numberOfMainBins != num_main_bins) || - (pInfluxExt->numberOfMainBins != num_main_bins) || - (pOutflux->numberOfMainBins != num_main_bins) || - (pSpectrumNew->numberOfMainBins != num_main_bins)) - { - Error("ImplicitEquation: inconsistent dimensions", PROGRAM_ERROR); - } - - for (i = 0; i < num_main_bins; i++) - { - (pSpectrumNew->spectrum)[particle][i] = - (pSpectrum->spectrum)[particle][i] + smallDistanceStep* - ((pInflux->spectrum)[particle][i] + - (pInflux0->spectrum)[particle][i] + - (pInfluxExt->spectrum)[particle][i] - - (pSpectrum->spectrum)[particle][i]* - (pOutflux->spectrum)[particle][i]); - - if ((pSpectrumNew->spectrum)[particle][i] < 0.) - { - (pSpectrumNew->spectrum)[particle][i] = 0.; - } - } -} - -void ComputeChange(const Spectrum* pSpectrumTemp, - const Spectrum* pSpectrumNew, - const PARTICLE particle, double* pChangeMax) -{ - double change; - int i; - - if (pSpectrumTemp->numberOfMainBins != pSpectrumNew->numberOfMainBins) - { - Error("ComputeChange: inconsistent dimensions", PROGRAM_ERROR); - } - - for (i = 0; i < pSpectrumNew->numberOfMainBins; i++) - { - change = fabs((pSpectrumNew->spectrum)[particle][i] - - (pSpectrumTemp->spectrum)[particle][i])/ - (fabs((pSpectrumTemp->spectrum)[particle][i]) + EPSILON); - if (change > *pChangeMax) - { - *pChangeMax = change; - } - } -} diff --git a/libs/dint/src/background.cpp b/libs/dint/src/background.cpp deleted file mode 100644 index 86e68a032..000000000 --- a/libs/dint/src/background.cpp +++ /dev/null @@ -1,529 +0,0 @@ - -#include "dint/background.h" -#include - -// integer pow implementation as template that is evaluated at compile time -template -inline double pow_integer(double base) -{ - return pow_integer<(exponent >> 1)>(base*base) * (((exponent & 1) > 0) ? base : 1); -} - -template <> -inline double pow_integer<0>(double base) -{ - return 1; -} - - - -void LoadPhotonBackground(const double redshift, - dCVector* pBgEnergy, dCVector* pBgEnergyWidth, - dCVector* pBgPhotonDensity, - const int aIRFlag, const double aZmax_IR, const int aRadioFlag, - const double aH0, const double aOmegaM, const double aOmegaLambda) { - if ((pBgEnergy->dimension != pBgEnergyWidth->dimension) || - (pBgEnergyWidth->dimension != pBgPhotonDensity->dimension)) - Error("LoadPhotonBackground: inconsistent dimensions", PROGRAM_ERROR); - - LoadCMB(redshift, pBgEnergy, pBgEnergyWidth, pBgPhotonDensity); - LoadIR(redshift, pBgEnergy, pBgEnergyWidth, pBgPhotonDensity, aIRFlag, aZmax_IR); - LoadRadio(redshift, pBgEnergy, pBgEnergyWidth, pBgPhotonDensity, aRadioFlag, - aH0, aOmegaM, aOmegaLambda); - - for (int i=0; idimension; i++) - (pBgPhotonDensity->vector)[i] *= VOLUME_UNIT; // normalization - -#ifdef PRINT_PHOTON_BACKGROUND // Output the density and exit (July 2005) - cout << "z=" << redshift << endl; - for (int i=0; idimension; i++) - cout << (pBgEnergy->vector)[i] << " " << (pBgPhotonDensity->vector)[i] << endl; - exit(-1) ; -#endif - -} - - -void LoadCMB(const double redshift, const dCVector* pBgEnergy, - const dCVector* pBgEnergyWidth, dCVector* pBgPhotonDensity) { - double numberDensity = 0.; // to test CMB was computed correctly - const double PRESENT_TEMPERATURE = 2.73; // present CMB temperature (K) - double exponent; - double tempNumber; - double temperature; - - temperature = 1.6863e-10*PRESENT_TEMPERATURE*(1. + redshift); - //temperature at redshift (K) - - for (int i=0; idimension; i++) { - exponent = (pBgEnergy->vector)[i]/temperature; - if (exponent < 550.) { - tempNumber = (pBgEnergy->vector)[i]*(pBgEnergy->vector)[i]/ - (exp(exponent) - 1.); // thermal distribution - } else tempNumber = 0.; - (pBgPhotonDensity->vector)[i] = tempNumber* - (pBgEnergyWidth->vector)[i]*1.75586e30; - numberDensity += (pBgPhotonDensity->vector)[i]; - } - -#ifdef TEST_CMB - printf("Computed CMB number density: %g\n", numberDensity); - numberDensity = 20.2417*PRESENT_TEMPERATURE*PRESENT_TEMPERATURE* - PRESENT_TEMPERATURE*(1. + redshift)*(1. + redshift)* - (1. + redshift); - printf("Predicted CMB number density: %g\n", numberDensity); -#endif - -} - - -double CIOBR(double eps) { - // parametrization for infrared/optical by - // Hopkins, A. M. & Beacom, J. F. 2006, ApJ, 651, 142 - // See Model D Finke et al, arXiv:0905.1115v2 - const double eps_ph_sup_ciob = 9.9; // [eV] - const double eps_ph_inf_ciob = 2e-3; // [eV] - - double tmp = 0; - - if (eps > eps_ph_inf_ciob && eps < eps_ph_sup_ciob) { - double x = log(eps); - tmp = -5.32524895349885 - 0.0741140642891119 * x - - 0.252586527659431 * pow_integer<2>(x) - + 0.234971297531891 * pow_integer<3>(x) - - 0.217014471117521 * pow_integer<4>(x) - - 0.364936722063572 * pow_integer<5>(x) - + 0.0880702191711222 * pow_integer<6>(x) - + 0.221947767409286 * pow_integer<7>(x) - + 0.0445499623085708 * pow_integer<8>(x) - - 0.0517435600939147 * pow_integer<9>(x) - - 0.0295646851279071 * pow_integer<10>(x) - - 0.00011943632049331 * pow_integer<11>(x) - + 0.00461621589174355 * pow_integer<12>(x) - + 0.00150906100702171 * pow_integer<13>(x) - + 1.91459088023263e-05 * pow_integer<14>(x) - - 0.000110272619218937 * pow_integer<15>(x) - - 3.45221358079085e-05 * pow_integer<16>(x) - - 5.42000122025042e-06 * pow_integer<17>(x) - - 4.90862622314226e-07 * pow_integer<18>(x) - - 2.45145316799091e-08 * pow_integer<19>(x) - - 5.25792204884819e-10 * pow_integer<20>(x); - tmp = 0.4 * (double) exp(tmp) / eps / eps; - } else { - tmp = 0; - } - - if (std::isnan(tmp)) - tmp = 0; - - return tmp; -} - -double CIB_Evolution_Fast(double z) { - // Function for the CIB fast evolution. - // Stecker, Malkan, Scully (2006) arXiv:astro-ph/0510449v4 - - double tmp = 0; - double m = 4.; - double z_flat = 1.; - - if (z <= z_flat) - tmp = pow(1. + z, m); - if (z_flat < z && z < 6) - tmp = pow(1. + z_flat, m); - if (z > 6) - tmp = 0; - - return tmp; -} - -double CIOB_Evolution(double z) { - return CIB_Evolution_Fast(z); -} - -double ElecaIOBR(double E, double z) -{ - double eps = E * ELECTRON_MASS; - return CIOBR(eps) * CIOB_Evolution(z) * ELECTRON_MASS; -} - - -void LoadIR(const double redshift, const dCVector* pBgEnergy, - const dCVector* pBgEnergyWidth, dCVector* pBgPhotonDensity, - const int aIRFlag, const double aZmax_IR) { - - double IRStartRedshift = aZmax_IR ; // Primack CDM - // const double IRStartRedshift = 4.3; // Primack CHDM - // parameters from Franceschini, Yoshi, and Takahara burst of both components - const double deltaO = 7.; - const double deltaD = 7.; - double (*IRFunction)(const double zTarget, const double zObserve, - const double energy0, const double deltaO, - const double deltaD); - if (aIRFlag == 0) IRFunction = HighIR ; - else if (aIRFlag == 1) IRFunction = LowIR ; - else if (aIRFlag == 2) IRFunction = NULL ; - else if (aIRFlag == 4) IRFunction = NULL; - else Error("LoadIR : Uncorrect IR flag",IO_ERROR) ; - - // eleca IR model - if (aIRFlag == 4) - { - for (int i=0; idimension; i++) - { - - (pBgPhotonDensity->vector)[i] += ElecaIOBR((pBgEnergy->vector)[i], redshift)*(pBgEnergyWidth->vector)[i]; - } - - } - else if (redshift <= IRStartRedshift) - { - double z[GAULEG_POINTS]; - double w[GAULEG_POINTS]; - double observeRedshift; - for (int i=0; idimension; i++) - { - if (aIRFlag == 2) { - (pBgPhotonDensity->vector)[i] += - IR2(redshift,(pBgEnergy->vector)[i])*(pBgEnergyWidth->vector)[i]*ELECTRON_MASS; - } else { - double temp = 0; - Gauleg(redshift, IRStartRedshift, z, w, GAULEG_POINTS); //find integration points - observeRedshift = redshift; - for (int j=0; jvector)[i], deltaO, deltaD)*w[j]; - } - (pBgPhotonDensity->vector)[i] += temp*(pBgEnergyWidth->vector)[i]; - } - } - } - -} - - -double IR2(const double redshift, const double BgEnergy) { - - // Primack et al. (1999) CIB parameters - - const double flux_conversion = 2.9979e10/4./PI*1.602e-19*1.e9*1.e4; - // xData is log10(wavelength/micrometers) - // yData is log10(\nu I_\nu/[nW m^-2 sr^-1]) - - // Redshift effect : we assume the following evolution of photon number density : - // n(e,z) = (1+z)**2 * n_0(e/(1+z)) - // It's the same as for CMB (pysically no injection of photons) and therefore the total - // number density evolves as (1+z)**3 - - // Changed to Kneiske Background for consistency with CRPropa interactions, JK - // Kneiske et al. Astron.\ Astrophys.\ {\bf 413} (2004) 807 - const double xData[15] = {-1.00000, -0.750000, -0.500000, -0.250000, 0.00000, 0.250000, 0.500000, 0.750000, - 1.00000, 1.25000, 1.50000, 1.75000, 2.00000, 2.25000, 2.50000}; - const double yData[15] = { -0.214401, 0.349313, 0.720354, 0.890389, 1.16042, 1.24692, 1.06525, 0.668659, 0.536312, 0.595859, 0.457456, - 0.623521, 1.20208, 1.33657, 1.04461}; - -// const double xData[15] = {-1., -0.75, -0.5, -0.25, 0., 0.25, 0.5, -// 0.75, 1., 1.25, 1.5, 1.75, 2., 2.25, 2.5}; -// const double yData[15] = {0.8, 1.1, 1.15, 1.2, 1.3, 1.2, 1.05, 0.7, -// 0.4, 0.3, 0.5, 0.8, 1.1, 1.3, 1.}; - - double result; - double lLocalEnergy = BgEnergy / (1.+redshift) ; // Redshift effect - double x = C/(lLocalEnergy*ELECTRON_MASS*2.42e14)*1.e4; // convert energy into microns - if (x > 500. || log10(x) <= xData[0]) { - result = 0.; - } else if (log10(x) >= xData[14]) { - result = (yData[14] - yData[13])/(xData[14] - xData[13])* - (log10(x) - xData[13]) + yData[13]; - result = pow(10., result); - } else { - int index = 1; - while (xData[index] < log10(x)) index++; - result = (yData[index] - yData[index-1])/ - (xData[index] - xData[index-1])*(log10(x) - xData[index-1]) + - yData[index-1]; - result = pow(10., result); - } - result *= pow(1.+redshift,2.)/pow(lLocalEnergy*ELECTRON_MASS, 2.)/ - flux_conversion; // Redshift effect - - return result; -} - - -double HighIR(const double zTarget, const double zObserve, - const double energy0, const double deltaO, - const double deltaD) { - const double normalization = 2./125.*1.e-5; - // high norm: this is the only difference from LowIR - - double coefficient = 1./pow(1. + zTarget, 4.5)/H_0*4.*PI* - (1. + zObserve)*(1. + zObserve); - double energyTarget = energy0*(1. + zTarget)/(1. + zObserve); - - double function = OpticalIR(energyTarget)*pow(1. + zTarget, deltaO)/30. + - DustIR(energyTarget)/300.*pow(1. + zTarget, deltaD)/2.; - // for no evolution for both (i.e. initial burst) - - return (normalization*coefficient*function) ; -} - - -double LowIR(const double zTarget, const double zObserve, - const double energy0, const double deltaO, - const double deltaD) { - const double normalization = 0.4/125.*1.e-5; - // low norm: this is the only difference from HighIR - - double coefficient = 1./pow(1. + zTarget, 4.5)/H_0*4.*PI* - (1. + zObserve)*(1. + zObserve); - double energyTarget = energy0*(1. + zTarget)/(1. + zObserve); - - double function = OpticalIR(energyTarget)*pow(1. + zTarget, deltaO)/30. + - DustIR(energyTarget)/300.*pow(1. + zTarget, deltaD)/2.; - // for no evolution for both (i.e. initial burst) - - return (normalization*coefficient*function) ; -} - - -double OpticalIR(const double energy) { - const double xData[9] = {-1.0402, -0.9, -0.7, -0.63, -0.4, -0.1, 0.1, 0.6, - 1.}; - const double yData[9] = {-30., -1.45, -1.65, -1.74, -0.33, 0.1, 0.2, -0.6, - -2.6}; - double result; - double x = C/(energy*ELECTRON_MASS*2.42e14)*1.e4; // convert energy into microns - // cut off far IR excess completely - - if (x > 100. || log10(x) <= xData[0]) { - result = 0.; - } else if (log10(x) >= xData[8]) { - result = (yData[8] - yData[7])/(xData[8] - xData[7])* - (log10(x) - xData[7]) + yData[7]; - result = pow(10., result)/energy/energy; - } else { - int index = 1 ; - while (xData[index] < log10(x)) index++; - result = (yData[index] - yData[index-1])/ - (xData[index] - xData[index-1])*(log10(x) - xData[index-1]) + - yData[index-1]; - result = pow(10., result)/energy/energy; - } - - return result; -} - - -double DustIR(const double energy) { - const double xData[6] = {-0.18, 0.54, 1.06, 1.4, 1.8, 2.9}; - const double yData[6] = {-3.0, 0.77, 0.6, 1.37, 1.5, -3.0}; - double result; - double x = C/(energy*ELECTRON_MASS*2.42e14)*1.e4; - - if (log10(x) <= xData[0]) result = 0.; - else if (log10(x) >= xData[5]) { - result = (yData[5] - yData[4])/(xData[5] - xData[4])* - (log10(x) - xData[4]) + yData[4]; - result = pow(10., result)/energy/energy; - } else { - int index = 1 ; - while (xData[index] < log10(x)) index++; - result = (yData[index] - yData[index-1])/ - (xData[index] - xData[index-1])*(log10(x) - xData[index-1]) + - yData[index-1]; - result = pow(10., result)/energy/energy; - } - - return result; -} - - -// Universal Radio Background from Protheroe, Bierman 1996. -double URB(double eps) { - const double eps_ph_inf_urb = 4.1e-12; // [eV] - const double eps_ph_inf_cmb = 0.825e-6; // [eV] - const double eps_ph_sup_urb = 4E-5; //4e-5; // [eV] - if (eps < eps_ph_inf_urb || eps > eps_ph_sup_urb) - return 0; - - const double h_Planck = 4.135667e-15; // [eV s]// - const double C_speed = 299792458; // [m/s] speed of light - const double eV2J = 1.602176487e-19; // from eV to J - - double v = eps / h_Planck; - double x = log10(v / 1e9); - - double p0 = -2.23791e+01; - double p1 = -2.59696e-01; - double p2 = 3.51067e-01; - double p3 = -6.80104e-02; - double p4 = 5.82003e-01; - double p5 = -2.00075e+00; - double p6 = -1.35259e+00; - double p7 = -7.12112e-01; //xbreak - - double intensity = 0; - if (x > p7) - intensity = p0 + p1 * x + p3 * x * x * x / (exp(p4 * x) - 1) + p6 + p5 * x; - else - intensity = p0 + p1 * x + p2 * x * x - + p3 * x * x * x / (exp(p4 * x) - 1); - intensity = pow(10, intensity); - double n_eps = 0; - n_eps = 4 * M_PI / (h_Planck * C_speed) * (intensity / eps); - return n_eps / eV2J / 1.0e6; -} -double URB_Evolution(double z) { - //from Protheroe - Bierman astro-ph:9605119 - if (z < 0.8) - return pow_integer<4>(1. + z); - return pow_integer<4>(1 + 0.8); // z>= z0 -} - -/// Provide Radio Background from Eleca for Dint -double ElecaRadio(const double zTarget, const double zObserve, - const double energy0, const double aH0, - const double aOmegaM, const double aOmegaLambda) { - - // Convert DINT unit to eps - const double eps = energy0 * ELECTRON_MASS; - return URB(eps) * URB_Evolution(zTarget) * ELECTRON_MASS; -} - - -void LoadRadio(const double redshift, const dCVector* pBgEnergy, - const dCVector* pBgEnergyWidth, dCVector* pBgPhotonDensity, - const int aRadioFlag, const double aH0, const double aOmegaM, - const double aOmegaLambda) { - const double radioStartRedshift = 5.; - // although the source distribution does not vanish at high redshift, - // one might as well cut it off effectively - // (5 is 6 sigma away from peak) - double (*RadioFunction)(const double zObserve, const double zTarget, - const double energy0, const double H, - const double OM, const double OL); - const double B = 2.58734e-28; - if (aRadioFlag == 4) - { - for (int i=0; idimension; i++) { - (pBgPhotonDensity->vector)[i] += - ElecaRadio(redshift, redshift, - (pBgEnergy->vector)[i], aH0, aOmegaM, aOmegaLambda) * (pBgEnergyWidth->vector)[i]; - } - } - else if (aRadioFlag != 3) { - // aRadioFlag == 3 : Null radio, so do nothing - if (aRadioFlag == 0) { - RadioFunction = HighRadio ; - } else if (aRadioFlag == 1) { - RadioFunction = MedRadio ; - } else if (aRadioFlag == 2) { - RadioFunction = ObsRadio ; - } else Error("LoadRadio : Uncorrect Radio flag",IO_ERROR) ; - - if (redshift <= radioStartRedshift ) { - double z[GAULEG_POINTS]; - double w[GAULEG_POINTS]; - double cutoffFactor; // cutoffFactor removed from function - - for (int i=0; idimension; i++) { - double temp = 0 ; - Gauleg(redshift, radioStartRedshift, z, w, GAULEG_POINTS); - double observeRedshift = redshift; - for (int j=0; jvector)[i], aH0, aOmegaM, aOmegaLambda)*w[j]; - } - if (RadioFunction == ObsRadio) - cutoffFactor = exp(-B/(pBgEnergy->vector)[i]/ (pBgEnergy->vector)[i]); - // this is a cutoff of the spectrum due to ISM absorption - else cutoffFactor = 1.; - (pBgPhotonDensity->vector)[i] += cutoffFactor*temp * (pBgEnergyWidth->vector)[i]; - } - } - } -} - - -double HighRadio(const double zTarget, const double zObserve, - const double energy0, const double aH0, - const double aOmegaM, const double aOmegaLambda) { - double B0 = 25.26*log(10.); - double B1 = 1.18*log(10.); - double B2 = 0.28*log(10.); - double H_z,coefficient,function,energyTarget; - - H_z = aH0*sqrt(aOmegaM*pow(1.+zTarget,3.)+aOmegaLambda); - energyTarget = energy0*(1. + zTarget)/(1. + zObserve); - coefficient = 4.*PI/H_z*DISTANCE_UNIT*1.e6/1.e5*4.2458e-56* - pow(1. + zObserve, 2.)/(1.40576e-28 + 1.81075e-45/energyTarget + - 6.38227e-8*pow(energyTarget, 1.3) + pow(energyTarget, 1.8)); - function = exp(B0 + B1*zTarget - B2*zTarget*zTarget); - - return (1.e0*coefficient*function); -} - - -double MedRadio(const double zTarget, const double zObserve, - const double energy0, const double aH0, - const double aOmegaM, const double aOmegaLambda) { - - return (HighRadio(zTarget,zObserve,energy0,aH0,aOmegaM,aOmegaLambda)/pow(10.,0.7)); -} - - -double ObsRadio(const double zTarget, const double zObserve, - const double energy0, const double aH0, - const double aOmegaM, const double aOmegaLambda) { - double B0 = 25.26*log(10.); - double B1 = 1.18*log(10.); - double B2 = 0.28*log(10.); - double H_z,coefficient,function,energyTarget; - - H_z = aH0*sqrt(aOmegaM*pow(1.+zTarget,3.)+aOmegaLambda); - energyTarget = energy0*(1. + zTarget)/(1. + zObserve); - coefficient = 4.*PI/H_z*DISTANCE_UNIT*1.e6/1.e5*4.2458e-56* - pow(1. + zObserve, 2.)*pow(energyTarget, -1.8); - function = exp(B0 + B1*zTarget - B2*zTarget*zTarget); - - return (coefficient*function); -} - - - - -/* -// Routine to "dump" the spectrum. -// Not needed -void DumpBgSpectrum(const dCVector* pBgEnergy, const dCVector* pBgEnergyWidth, - const dCVector* pBgPhotonDensity, const char* filename) -{ - int i; - int j; - FILE* dumpFile; - char f1[80] = "datafiles/"; - - if ((pBgEnergy->dimension != pBgEnergyWidth->dimension) || - (pBgEnergyWidth->dimension != pBgPhotonDensity->dimension)) - { - Error("DumpBgSpectrum: inconsistent dimensions", PROGRAM_ERROR); - } - - strncat(f1, filename, 79 - strlen(filename)); - dumpFile = SafeFOpen(f1, "w"); -// this is to send the dump file to a different directory (datafiles) -// by Guenter (7/20/1998) - - for (i = 0; i < pBgEnergy->dimension; i++) - { - fprintf(dumpFile, "%15.4E %15.4E\n", - ELECTRON_MASS*(pBgEnergy->vector)[i], - (pBgPhotonDensity->vector)[i]/ELECTRON_MASS/ - (pBgEnergyWidth->vector)[i]/VOLUME_UNIT); -// proper unit conversion for energy - } - fclose(dumpFile); -} -*/ diff --git a/libs/dint/src/binfread.cpp b/libs/dint/src/binfread.cpp deleted file mode 100644 index 1cd926f7f..000000000 --- a/libs/dint/src/binfread.cpp +++ /dev/null @@ -1,64 +0,0 @@ - -#include "dint/binfread.h" - -#include - -static int ToSwap() { - static int ToSwap = -1 ; - if ( ToSwap != -1 ) goto endToSwap ; - else { - if ( ntohs(1234) != ntohs(1234) ) ToSwap = 1; - else ToSwap = 0; - } - -endToSwap: - //cerr << "ToSwap = " << ToSwap << endl; - return ToSwap ; -} - -static int16_t Swap2(int16_t a) { - return ( ((a >> 8)&0xff) | ((a << 8)&0xff00) ) ; -} - -static int32_t Swap4(int32_t a) { - return ( ((a >> 24)&0xff) | ((a >> 8 )&0xff00 ) | - ((a << 8 )&0xff0000 ) | ((a << 24)&0xff000000) ) ; -} - -static int64_t Swap8(int64_t a) { - return ( ((a >> 56)&0xff) | ((a >> 40 )&0xff00 ) | - ((a >> 24)&0xff0000) | ((a >> 8 )&0xff000000) | - ((a << 8 )&(((int64_t)(0xff))<<32)) | - ((a << 24)&(((int64_t)(0xff))<<40)) | - ((a << 40)&(((int64_t)(0xff))<<48)) | - ((a << 56)&(((int64_t)(0xff))<<56)) ) ; -} - -size_t binfread(void *ptr, size_t size, size_t nmemb, FILE *stream) { - size_t i; - size_t s = fread(ptr, size, nmemb, stream); - - if ( ToSwap() && size>1 ) { - if ( size == 2 ) { - int16_t *temp = (int16_t*)ptr; - for ( i=0; i -#include -#include "dint/error.h" -#include "dint/cvector.h" -#include "dint/const.h" - - -void DumpArray(const dCVector* pVector) -{ - int i; - for (i = 0; i < pVector->dimension; i++) - { - printf("%15.6E\n", pVector->vector[i]*ELECTRON_MASS); - } -} - -void CheckIndex(const int lowerLimit, const int upperLimit, const int i, - const char* functionName) -{ - if (i < lowerLimit || i >= upperLimit) - { - printf("%s: index out of bounds!!!\n", functionName); - printf("Should have satisfied %i <= %i < %i.\n", lowerLimit, i, - upperLimit); - exit (ARRAY_ERROR); - } -} diff --git a/libs/dint/src/cvector.cpp b/libs/dint/src/cvector.cpp deleted file mode 100644 index 9bf664ef2..000000000 --- a/libs/dint/src/cvector.cpp +++ /dev/null @@ -1,36 +0,0 @@ - -#include "dint/cvector.h" - -void New_dCVector(dCVector* pVector, const int n) { - pVector->dimension = n; - pVector->vector = New_dVector(n); - - Initialize_dCVector(pVector); -} - -void Delete_dCVector(dCVector* pVector) { - Delete_dVector(pVector->vector); -} - -void Initialize_dCVector(dCVector* pVector) { - for (int i = 0; idimension; i++) pVector->vector[i] = 0.; -} - - -void New_iCMatrix(iCMatrix* pMatrix, const int n1, const int n2) { - pMatrix->dimension1 = n1; - pMatrix->dimension2 = n2; - pMatrix->matrix = New_iMatrix(n1, n2); - - Initialize_iCMatrix(pMatrix); -} - -void Delete_iCMatrix(iCMatrix* pMatrix) { - Delete_iMatrix(pMatrix->matrix); -} - -void Initialize_iCMatrix(iCMatrix* pMatrix) { - for (int i=0; idimension1; i++) { - for (int j=0; jdimension2; j++) pMatrix->matrix[i][j] = 0; - } -} diff --git a/libs/dint/src/decay.cpp b/libs/dint/src/decay.cpp deleted file mode 100644 index 3eb5c275b..000000000 --- a/libs/dint/src/decay.cpp +++ /dev/null @@ -1,150 +0,0 @@ -#include -#include "dint/const.h" -#include "dint/utilities.h" - - -/* NOTE: note that these functions use MIN_ENERGY_EXP, etc. instead of - NUC_MIN_ENERGY_EXP, etc. Thus these functions are tied with the main - routine only. */ -double PionToPhoton(const int iPhoton, const int iPion) -{ - double piEnergyRight; - double piEnergyLeft; - double deltaPiE; - double result; - - piEnergyRight = pow(10., MIN_ENERGY_EXP + (iPion+0.5)/BINS_PER_DECADE)/ - ELECTRON_MASS; - piEnergyLeft = pow(10., MIN_ENERGY_EXP + (iPion-0.5)/BINS_PER_DECADE)/ - ELECTRON_MASS; - deltaPiE = piEnergyRight - piEnergyLeft; - - if (iPhoton < iPion) - result = 2./deltaPiE/BINS_PER_DECADE*log(10.); - else if (iPhoton == iPion) - { - result = 2.*(1./deltaPiE - piEnergyLeft/deltaPiE/deltaPiE/ - BINS_PER_DECADE*log(10.)); - } - else - result = 0.; - - if (result < 0.) - Error("PionToPhoton: decay spectrum negative.", PROGRAM_ERROR); - - return result; -} - - -double PionToLepton(const double leptonEnergy, const double pionEnergy) -{ - const double r = (1.056595e8/1.39567e8)*(1.056595e8/1.39567e8); - const double A0 = 0.94486e0; - const double A2 = -2.7892e0; - const double A3 = 1.2397e0; - const double B0 = -2.4126e0; - const double B0p = -2.8951e0; - const double B2 = 4.3426e0; - const double B3 = -1.9300e0; - - double ratio; - double result; - - ratio = leptonEnergy/pionEnergy; - if (leptonEnergy < r*pionEnergy) - { - result = 1./(1.0 - r)/pionEnergy*(A0 + A2*ratio*ratio + A3*ratio* - ratio*ratio); - } - else - { - result = 1./(1.0 - r)/pionEnergy*(B0 + B0p*log(ratio) + - B2*ratio*ratio + B3*ratio*ratio*ratio); - } - if (result < 0.) - result = 0.; - - return result; -} - -double PionToElectronNeutrino(const double neutrinoEnergy, - const double pionEnergy) -{ - const double r = (1.056595e8/1.39567e8)*(1.056595e8/1.39567e8); - const double C0 = 1.1053e0; - const double C2 = -4.46883e0; - const double C3 = 3.71887e0; - const double D0 = 13.846e0; - const double D0p = 5.37053e0; - const double D1 = -28.1116e0; - const double D2 = 20.0558e0; - const double D3 = -5.7902e0; - - double ratio; - double result; - - ratio = neutrinoEnergy/pionEnergy; - if (neutrinoEnergy < r*pionEnergy) - { - result = 1./(1. - r)/pionEnergy*(C0 + C2*ratio*ratio + C3*ratio*ratio - *ratio); - } - else - { - result = 1./(1. - r)/pionEnergy*(D0 + D0p*log(ratio) + D1*ratio + - D2*ratio*ratio + D3*ratio*ratio*ratio); - } - if (result < 0.) - result = 0.; - - return result; -} - -double PionToMuonNeutrino(const int iNeutrino, const int iPion) -{ - const double r = (1.056595e8/1.39567e8)*(1.056595e8/1.39567e8); - - double neutEnergyLeft; - double neutEnergyRight; - double piEnergyLeft; - double piEnergyRight; - double deltaNeutE; - double deltaPiE; - double result; - - neutEnergyRight = pow(10., MIN_ENERGY_EXP + (iNeutrino+0.5)/ - BINS_PER_DECADE)/ELECTRON_MASS; - neutEnergyLeft = pow(10., MIN_ENERGY_EXP + (iNeutrino-0.5)/ - BINS_PER_DECADE)/ELECTRON_MASS; - deltaNeutE = neutEnergyRight - neutEnergyLeft; - - piEnergyRight = pow(10., MIN_ENERGY_EXP + (iPion+0.5)/BINS_PER_DECADE)/ - ELECTRON_MASS; - piEnergyLeft = pow(10., MIN_ENERGY_EXP + (iPion-0.5)/BINS_PER_DECADE)/ - ELECTRON_MASS; - deltaPiE = piEnergyRight - piEnergyLeft; - - if (neutEnergyRight < piEnergyLeft*(1.-r)) - result = log(piEnergyRight/piEnergyLeft)/(1. - r)/deltaPiE; - else if (neutEnergyLeft < piEnergyLeft*(1.-r)) - { - result = (deltaNeutE/(1. - r)*log(piEnergyRight*(1. - r)/ - neutEnergyRight) + neutEnergyRight/(1. - r) - piEnergyLeft - - neutEnergyLeft/(1. - r)*log(neutEnergyRight/(piEnergyLeft* - (1. - r))))/deltaPiE/deltaNeutE; - } - else if ((neutEnergyLeft < piEnergyRight*(1.-r)) && - (neutEnergyRight > piEnergyRight*(1.-r))) - { - result = (piEnergyRight - neutEnergyLeft/(1. - r) - neutEnergyLeft/ - (1. - r)*log(piEnergyRight*(1. - r)/neutEnergyLeft))/deltaPiE/ - deltaNeutE; - } - else - result = 0.; - - if (result < 0.) - result = 0.; - - return result; -} diff --git a/libs/dint/src/deriv.cpp b/libs/dint/src/deriv.cpp deleted file mode 100644 index 07976f216..000000000 --- a/libs/dint/src/deriv.cpp +++ /dev/null @@ -1,477 +0,0 @@ -#include "dint/deriv.h" -#include "dint/rate.h" -#include "dint/spectrum.h" -#include "dint/error.h" -#include "dint/check.h" -#include "dint/cvector.h" - - -void GetLeptonInfluxFromPhotons(const DiffRate* photonLeptonRate, - const Spectrum* pSpectrumNew, - Spectrum* pInflux0) -{ - ComputeInflux(1., photonLeptonRate, PHOTON, ELECTRON, pSpectrumNew, - pInflux0); - ComputeInflux(1., photonLeptonRate, PHOTON, POSITRON, pSpectrumNew, - pInflux0); -} - -void GetLeptonInfluxFromNucleons(const int neutronDecaySwitch, - const DiffRate* protonElectronRate, - const DiffRate* neutronPositronRate, - const DiffRate* protonPositronRate, - const DiffRate* neutronElectronRate, - const DiffRate* neutronDecayElectronRate, - const Spectrum* pSpectrumNew, - Spectrum* pInflux0) -{ - /* lepton influx from nucleons */ - ComputeInflux(1., protonElectronRate, PROTON, ELECTRON, pSpectrumNew, - pInflux0); - ComputeInflux(1., neutronPositronRate, NEUTRON, POSITRON, pSpectrumNew, - pInflux0); - ComputeInflux(1., protonPositronRate, PROTON, POSITRON, pSpectrumNew, - pInflux0); - ComputeInflux(1., neutronElectronRate, NEUTRON, ELECTRON, pSpectrumNew, - pInflux0); - if (neutronDecaySwitch == 1) - { - ComputeInflux(1., neutronDecayElectronRate, NEUTRON, ELECTRON, - pSpectrumNew, pInflux0); - } -} - -void GetLeptonInfluxFromNeutrinos(const double bkgFactor, - const DiffRate* elNeutElectronRate, - const DiffRate* muonNeutElectronRate, - const DiffRate* tauNeutElectronRate, - const Spectrum* pSpectrumNew, - Spectrum* pInflux0) -{ - ComputeInflux(bkgFactor, elNeutElectronRate, ELECTRON_NEUTRINO, ELECTRON, - pSpectrumNew, pInflux0); - ComputeInflux(bkgFactor, elNeutElectronRate, ANTI_ELECTRON_NEUTRINO, - ELECTRON, pSpectrumNew, pInflux0); - ComputeInflux(bkgFactor, elNeutElectronRate, ELECTRON_NEUTRINO, POSITRON, - pSpectrumNew, pInflux0); - ComputeInflux(bkgFactor, elNeutElectronRate, ANTI_ELECTRON_NEUTRINO, - POSITRON, pSpectrumNew, pInflux0); - ComputeInflux(bkgFactor, muonNeutElectronRate, MUON_NEUTRINO, ELECTRON, - pSpectrumNew, pInflux0); - ComputeInflux(bkgFactor, muonNeutElectronRate, ANTI_MUON_NEUTRINO, - ELECTRON, pSpectrumNew, pInflux0); - ComputeInflux(bkgFactor, muonNeutElectronRate, MUON_NEUTRINO, POSITRON, - pSpectrumNew, pInflux0); - ComputeInflux(bkgFactor, muonNeutElectronRate, ANTI_MUON_NEUTRINO, - POSITRON, pSpectrumNew, pInflux0); - ComputeInflux(bkgFactor, tauNeutElectronRate, TAU_NEUTRINO, ELECTRON, - pSpectrumNew, pInflux0); - ComputeInflux(bkgFactor, tauNeutElectronRate, ANTI_TAU_NEUTRINO, ELECTRON, - pSpectrumNew, pInflux0); - ComputeInflux(bkgFactor, tauNeutElectronRate, TAU_NEUTRINO, POSITRON, - pSpectrumNew, pInflux0); - ComputeInflux(bkgFactor, tauNeutElectronRate, ANTI_TAU_NEUTRINO, POSITRON, - pSpectrumNew, pInflux0); -} - -void GetLeptonFluxFromLeptons(const TotalRate* leptonTotalRate, - const DiffRate* leptonScatRate, - const DiffRate* leptonExchRate, - const dCVector* continuousLoss, - const dCVector* deltaG, - const Spectrum* pSpectrumNew, Spectrum* pInflux, - Spectrum* pOutflux) -{ - int i; - int num_main_bins; - - num_main_bins = pOutflux->numberOfMainBins; - if ((continuousLoss->dimension != num_main_bins) || - (deltaG->dimension != num_main_bins)) - { - Error("GetLeptonFluxFromLeptons: inconsistent dimensions", - PROGRAM_ERROR); - } - - /* ICS & TPP (differential) */ - ComputeOutflux(1., leptonTotalRate, ELECTRON, pOutflux); - ComputeOutflux(1., leptonTotalRate, POSITRON, pOutflux); - /* outflux */ - - ComputeInflux(1., leptonScatRate, ELECTRON, ELECTRON, pSpectrumNew, - pInflux); - ComputeInflux(1., leptonScatRate, POSITRON, POSITRON, pSpectrumNew, - pInflux); - ComputeInflux(1., leptonExchRate, ELECTRON, POSITRON, pSpectrumNew, - pInflux); - ComputeInflux(1., leptonExchRate, POSITRON, ELECTRON, pSpectrumNew, - pInflux); - /* this is for TPP */ - - /* continuous energy loss (synchrotron & TPP) */ - for (i = 0; i < num_main_bins; i++) - { - double fraction; - - fraction = (continuousLoss->vector)[i]/(deltaG->vector)[i]; - (pOutflux->spectrum)[ELECTRON][i] += -fraction; - (pOutflux->spectrum)[POSITRON][i] += -fraction; - if (i != num_main_bins - 1) - { - (pInflux->spectrum)[ELECTRON][i] += - -(continuousLoss->vector)[i+1]/(deltaG->vector)[i+1]* - (pSpectrumNew->spectrum)[ELECTRON][i+1]; - (pInflux->spectrum)[POSITRON][i] += - -(continuousLoss->vector)[i+1]/(deltaG->vector)[i+1]* - (pSpectrumNew->spectrum)[POSITRON][i+1]; - } - } -} - - -void GetPhotonInfluxFromLeptons(const DiffRate* leptonPhotonRate, - const int synchrotronSwitch, - const DiffRate* syncRate, - const Spectrum* pSpectrumNew, - Spectrum* pInflux0) -{ - int i; - int num_main_bins; - - num_main_bins = pInflux0->numberOfMainBins; - if (synchrotronSwitch == 1) - { - if (syncRate->mainDimension != num_main_bins) - { - Error("GetPhotonInfluxFromLeptons: inconsistent dimensions", - PROGRAM_ERROR); - } - } - - ComputeInflux(1., leptonPhotonRate, ELECTRON, PHOTON, pSpectrumNew, - pInflux0); - ComputeInflux(1., leptonPhotonRate, POSITRON, PHOTON, pSpectrumNew, - pInflux0); - /* influx from ICS */ - - /* influx from synchrotron */ - if (synchrotronSwitch == 1) - { - for (i = 0; i < num_main_bins; i++) - { - if (((syncRate->bound)[i][0] != num_main_bins - 1) || - (syncRate->bound)[i][1] != 0) - { - int j; - - for (j = (syncRate->bound)[i][0]; j <= (syncRate->bound)[i][1]; - j++) - { - (pInflux0->spectrum)[PHOTON][j] += - (syncRate->diffRate)[i][j]* - ((pSpectrumNew->spectrum)[ELECTRON][i] + - (pSpectrumNew->spectrum)[POSITRON][i]); - } - } - } - } -} - -void GetPhotonInfluxFromNucleons(const DiffRate* protonPhotonRate, - const Spectrum* pSpectrumNew, - Spectrum* pInflux0) -{ - ComputeInflux(1., protonPhotonRate, PROTON, PHOTON, pSpectrumNew, - pInflux0); - ComputeInflux(1., protonPhotonRate, NEUTRON, PHOTON, pSpectrumNew, - pInflux0); -} - -void GetPhotonInfluxFromNeutrinos(const double bkgFactor, - const DiffRate* elNeutPhotonRate, - const DiffRate* muonNeutPhotonRate, - const DiffRate* tauNeutPhotonRate, - const Spectrum* pSpectrumNew, - Spectrum* pInflux0) -{ - ComputeInflux(bkgFactor, elNeutPhotonRate, ELECTRON_NEUTRINO, PHOTON, - pSpectrumNew, pInflux0); - ComputeInflux(bkgFactor, elNeutPhotonRate, ANTI_ELECTRON_NEUTRINO, PHOTON, - pSpectrumNew, pInflux0); - ComputeInflux(bkgFactor, muonNeutPhotonRate, MUON_NEUTRINO, PHOTON, - pSpectrumNew, pInflux0); - ComputeInflux(bkgFactor, muonNeutPhotonRate, ANTI_MUON_NEUTRINO, PHOTON, - pSpectrumNew, pInflux0); - ComputeInflux(bkgFactor, tauNeutPhotonRate, TAU_NEUTRINO, PHOTON, - pSpectrumNew, pInflux0); - ComputeInflux(bkgFactor, tauNeutPhotonRate, ANTI_TAU_NEUTRINO, PHOTON, - pSpectrumNew, pInflux0); -} - - -void GetPhotonFluxFromPhotons(const TotalRate* photonTotalRate, - Spectrum* pOutflux) -{ - ComputeOutflux(1., photonTotalRate, PHOTON, pOutflux); -} - -void GetNucleonFluxFromNucleons(const int neutronDecaySwitch, - const TotalRate* protonTotalRate, - const TotalRate* neutronTotalRate, - const TotalRate* neutronDecayRate, - const DiffRate* protonScatRate, - const DiffRate* neutronProtonRate, - const DiffRate* protonNeutronRate, - const DiffRate* neutronDecayProtonRate, - const dCVector* protonContinuousLoss, - const dCVector* deltaG, - const Spectrum* pSpectrumNew, - Spectrum* pInflux, Spectrum* pOutflux) -{ - int i; - int num_main_bins; - - num_main_bins = pInflux->numberOfMainBins; - if ((protonContinuousLoss->dimension != num_main_bins) || - (deltaG->dimension != num_main_bins)) - { - Error("GetNucleonFluxFromNucleons: inconsistent dimensions", - PROGRAM_ERROR); - } - - ComputeOutflux(1., protonTotalRate, PROTON, pOutflux); - ComputeOutflux(1., neutronTotalRate, NEUTRON, pOutflux); - if (neutronDecaySwitch == 1) - { - ComputeOutflux(1., neutronDecayRate, NEUTRON, pOutflux); - } - /* compute outflux */ - - ComputeInflux(1., protonScatRate, PROTON, PROTON, pSpectrumNew, pInflux); - ComputeInflux(1., neutronProtonRate, NEUTRON, PROTON, pSpectrumNew, - pInflux); - ComputeInflux(1., protonScatRate, NEUTRON, NEUTRON, pSpectrumNew, pInflux); - ComputeInflux(1., protonNeutronRate, PROTON, NEUTRON, pSpectrumNew, - pInflux); - /* compute influx by PPP */ - - if (neutronDecaySwitch == 1) - { - /*ComputeInflux(1., neutronDecayProtonRate, NEUTRON, PROTON, pSpectrumNew, - pInflux);*/ - - for (i = 0; i < neutronDecayRate->mainDimension; i++) - { - pInflux->spectrum[PROTON][i] += (neutronDecayRate->totalRate[i])* - (pSpectrumNew->spectrum)[NEUTRON][i]; - } - - } - /* add proton influx by neutron decay */ - - for (i = 0; i < num_main_bins; i++) - { - double fraction; - - fraction = (protonContinuousLoss->vector)[i]/(deltaG->vector)[i]; - (pOutflux->spectrum)[PROTON][i] += -fraction; - if (i != num_main_bins - 1) - { - (pInflux->spectrum)[PROTON][i] += -fraction* - (pSpectrumNew->spectrum)[PROTON][i+1]; - } - } -} - -void GetNeutrinoInfluxFromNucleons(const int neutronDecaySwitch, - const DiffRate* protonMuonNeutrinoRate, - const DiffRate* neutronAntiMuonNeutrinoRate, - const DiffRate* neutronMuonNeutrinoRate, - const DiffRate* protonAntiMuonNeutrinoRate, - const DiffRate* protonElectronNeutrinoRate, - const DiffRate* neutronAntiElectronNeutrinoRate, - const DiffRate* protonAntiElectronNeutrinoRate, - const DiffRate* neutronDecayElectronRate, - const Spectrum* pSpectrumNew, - Spectrum* pInflux0) -{ - ComputeInflux(1., protonMuonNeutrinoRate, PROTON, MUON_NEUTRINO, - pSpectrumNew, pInflux0); - ComputeInflux(1., neutronAntiMuonNeutrinoRate, NEUTRON, - ANTI_MUON_NEUTRINO, pSpectrumNew, pInflux0); - ComputeInflux(1., protonAntiMuonNeutrinoRate, PROTON, ANTI_MUON_NEUTRINO, - pSpectrumNew, pInflux0); - ComputeInflux(1., neutronMuonNeutrinoRate, NEUTRON, MUON_NEUTRINO, - pSpectrumNew, pInflux0); - ComputeInflux(1., protonElectronNeutrinoRate, PROTON, ELECTRON_NEUTRINO, - pSpectrumNew, pInflux0); - ComputeInflux(1., neutronAntiElectronNeutrinoRate, NEUTRON, - ANTI_ELECTRON_NEUTRINO, pSpectrumNew, pInflux0); - ComputeInflux(1., protonAntiElectronNeutrinoRate, PROTON, - ANTI_ELECTRON_NEUTRINO, pSpectrumNew, pInflux0); - ComputeInflux(1., protonAntiElectronNeutrinoRate, NEUTRON, - ELECTRON_NEUTRINO, pSpectrumNew, pInflux0); - - if (neutronDecaySwitch == 1) - { - ComputeInflux(1., neutronDecayElectronRate, NEUTRON, - ANTI_ELECTRON_NEUTRINO, pSpectrumNew, pInflux0); - } -} - -void GetNucleonInfluxFromNeutrinos(const double bkgFactor, - const DiffRate* elNeutProtonRate, - const DiffRate* muonNeutProtonRate, - const DiffRate* tauNeutProtonRate, - const Spectrum* pSpectrumNew, - Spectrum* pInflux0) -{ - ComputeInflux(bkgFactor, elNeutProtonRate, ELECTRON_NEUTRINO, PROTON, - pSpectrumNew, pInflux0); - ComputeInflux(bkgFactor, elNeutProtonRate, ANTI_ELECTRON_NEUTRINO, PROTON, - pSpectrumNew, pInflux0); - ComputeInflux(bkgFactor, muonNeutProtonRate, MUON_NEUTRINO, PROTON, - pSpectrumNew, pInflux0); - ComputeInflux(bkgFactor, muonNeutProtonRate, ANTI_MUON_NEUTRINO, PROTON, - pSpectrumNew, pInflux0); - ComputeInflux(bkgFactor, tauNeutProtonRate, TAU_NEUTRINO, PROTON, - pSpectrumNew, pInflux0); - ComputeInflux(bkgFactor, tauNeutProtonRate, ANTI_TAU_NEUTRINO, PROTON, - pSpectrumNew, pInflux0); - - /* neutron is unchanged: this has to be replaced after proton-antiproton - symmetry is solved */ -} - -void GetNeutrinoFluxFromNeutrinos(const double bkgFactor, - const TotalRate* elNeutTotalRate, - const TotalRate* muonNeutTotalRate, - const TotalRate* tauNeutTotalRate, - const DiffRate* elNeutScatRate, - const DiffRate* elNeutMuonNeutRate, - const DiffRate* elNeutTauNeutRate, - const DiffRate* muonNeutElNeutRate, - const DiffRate* muonNeutScatRate, - const DiffRate* muonNeutTauNeutRate, - const DiffRate* tauNeutElNeutRate, - const DiffRate* tauNeutMuonNeutRate, - const DiffRate* tauNeutScatRate, - const Spectrum* pSpectrumNew, - Spectrum* pInflux, Spectrum* pOutflux) -{ - int i; - int k; - int num_main_bins; - - num_main_bins = pInflux->numberOfMainBins; - - ComputeOutflux(bkgFactor, elNeutTotalRate, ELECTRON_NEUTRINO, pOutflux); - ComputeOutflux(bkgFactor, elNeutTotalRate, ANTI_ELECTRON_NEUTRINO, - pOutflux); - ComputeOutflux(bkgFactor, muonNeutTotalRate, MUON_NEUTRINO, pOutflux); - ComputeOutflux(bkgFactor, muonNeutTotalRate, ANTI_MUON_NEUTRINO, pOutflux); - ComputeOutflux(bkgFactor, tauNeutTotalRate, TAU_NEUTRINO, pOutflux); - ComputeOutflux(bkgFactor, tauNeutTotalRate, ANTI_TAU_NEUTRINO, pOutflux); - - - ComputeInflux(bkgFactor, elNeutScatRate, ELECTRON_NEUTRINO, - ELECTRON_NEUTRINO, pSpectrumNew, pInflux); - ComputeInflux(bkgFactor, elNeutScatRate, ANTI_ELECTRON_NEUTRINO, - ELECTRON_NEUTRINO, pSpectrumNew, pInflux); - ComputeInflux(bkgFactor, muonNeutElNeutRate, MUON_NEUTRINO, - ELECTRON_NEUTRINO, pSpectrumNew, pInflux); - ComputeInflux(bkgFactor, muonNeutElNeutRate, ANTI_MUON_NEUTRINO, - ELECTRON_NEUTRINO, pSpectrumNew, pInflux); - ComputeInflux(bkgFactor, tauNeutElNeutRate, TAU_NEUTRINO, - ELECTRON_NEUTRINO, pSpectrumNew, pInflux); - ComputeInflux(bkgFactor, tauNeutElNeutRate, ANTI_TAU_NEUTRINO, - ELECTRON_NEUTRINO, pSpectrumNew, pInflux); - - ComputeInflux(bkgFactor, elNeutMuonNeutRate, ELECTRON_NEUTRINO, - MUON_NEUTRINO, pSpectrumNew, pInflux); - ComputeInflux(bkgFactor, elNeutMuonNeutRate, ANTI_ELECTRON_NEUTRINO, - MUON_NEUTRINO, pSpectrumNew, pInflux); - ComputeInflux(bkgFactor, muonNeutScatRate, MUON_NEUTRINO, MUON_NEUTRINO, - pSpectrumNew, pInflux); - ComputeInflux(bkgFactor, muonNeutScatRate, ANTI_MUON_NEUTRINO, - MUON_NEUTRINO, pSpectrumNew, pInflux); - ComputeInflux(bkgFactor, tauNeutMuonNeutRate, TAU_NEUTRINO, MUON_NEUTRINO, - pSpectrumNew, pInflux); - ComputeInflux(bkgFactor, tauNeutMuonNeutRate, ANTI_TAU_NEUTRINO, - MUON_NEUTRINO, pSpectrumNew, pInflux); - - ComputeInflux(bkgFactor, elNeutTauNeutRate, ELECTRON_NEUTRINO, - TAU_NEUTRINO, pSpectrumNew, pInflux); - ComputeInflux(bkgFactor, elNeutTauNeutRate, ANTI_ELECTRON_NEUTRINO, - TAU_NEUTRINO, pSpectrumNew, pInflux); - ComputeInflux(bkgFactor, muonNeutTauNeutRate, MUON_NEUTRINO, TAU_NEUTRINO, - pSpectrumNew, pInflux); - ComputeInflux(bkgFactor, muonNeutTauNeutRate, ANTI_MUON_NEUTRINO, - TAU_NEUTRINO, pSpectrumNew, pInflux); - ComputeInflux(bkgFactor, tauNeutScatRate, TAU_NEUTRINO, TAU_NEUTRINO, - pSpectrumNew, pInflux); - ComputeInflux(bkgFactor, tauNeutScatRate, ANTI_TAU_NEUTRINO, TAU_NEUTRINO, - pSpectrumNew, pInflux); - - /* ??? */ - for (i = 0; i < num_main_bins; i++) - { - for (k = 0; k <= i; k++) - { - (pInflux->spectrum)[ANTI_ELECTRON_NEUTRINO][k] = - (pInflux->spectrum)[ELECTRON_NEUTRINO][k]; - (pInflux->spectrum)[ANTI_MUON_NEUTRINO][k] = - (pInflux->spectrum)[MUON_NEUTRINO][k]; - (pInflux->spectrum)[ANTI_TAU_NEUTRINO][k] = - (pInflux->spectrum)[TAU_NEUTRINO][k]; - } - } -} - -void ComputeOutflux(const double bkgFactor, const TotalRate* pRate, - const PARTICLE parent, Spectrum* pOutflux) -{ - int i; - - if (pRate->mainDimension != pOutflux->numberOfMainBins) - { - Error("ComputeOutflux: inconsistent dimension", PROGRAM_ERROR); - } - - for (i = 0; i < pRate->mainDimension; i++) - { - pOutflux->spectrum[parent][i] += bkgFactor*(pRate->totalRate[i]); - } -} - -void ComputeInflux(const double bkgFactor, const DiffRate* pRate, - const PARTICLE parent, const PARTICLE daughter, - const Spectrum* pSpectrum, Spectrum* pInflux) -{ - int i; - int k; - - if ((pRate->mainDimension != pSpectrum->numberOfMainBins) || - (pSpectrum->numberOfMainBins != pInflux->numberOfMainBins)) - { - Error("ComputeInflux: inconsistent dimensions", PROGRAM_ERROR); - } - - for (i = 0; i < pRate->mainDimension; i++) - { - if ((pRate->bound[i][0] != pRate->mainDimension - 1) || - (pRate->bound[i][1] != 0)) - /* bound is valid */ - { - for (k = pRate->bound[i][0]; k <= pRate->bound[i][1]; k++) - { -#ifdef DEBUG - CheckIndex(0, i+1, k, "ComputeInflux"); -#endif - pInflux->spectrum[daughter][k] += bkgFactor* - (pRate->diffRate)[i][k]* - (pSpectrum->spectrum)[parent][i]; - } - } - } -} diff --git a/libs/dint/src/error.cpp b/libs/dint/src/error.cpp deleted file mode 100644 index 90dfb063f..000000000 --- a/libs/dint/src/error.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include -#include "dint/error.h" - -void Error(const char* errorMessage, const ErrorCode errorCode) -{ - printf("%s\n", errorMessage); - exit (errorCode); -} diff --git a/libs/dint/src/final.cpp b/libs/dint/src/final.cpp deleted file mode 100644 index e50887e76..000000000 --- a/libs/dint/src/final.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include -#include -#include "dint/spectrum.h" -#include "dint/const.h" - -void CheckEnergy(const int sourceTypeSwitch, const double brightPhaseExp, - const double startingRedshift, - const double rightRedshift, const Spectrum* pSpectrum, - const dCVector* pEnergy, const double initialTotalEnergy) -{ - int i; - double tempFraction; - double photonNumber = 0.; - double leptonNumber = 0.; - double nucleonNumber = 0.; - double neutrinoNumber = 0.; - double totalNumber = 0.; - double photonEnergy = 0.; - double leptonEnergy = 0.; - double nucleonEnergy = 0.; - double neutrinoEnergy = 0.; - double totalEnergy = 0.; - double energyRedshiftFactor; - - tempFraction = (1. + startingRedshift)/(1. + rightRedshift); - for (i = 0; i < pEnergy->dimension; i++) - { - photonNumber += (pSpectrum->spectrum)[PHOTON][i]; - photonEnergy += (pSpectrum->spectrum)[PHOTON][i]*(pEnergy->vector)[i]; - leptonNumber += (pSpectrum->spectrum)[ELECTRON][i] + - (pSpectrum->spectrum)[POSITRON][i]; - leptonEnergy += (pEnergy->vector)[i]* - ((pSpectrum->spectrum)[ELECTRON][i] + - (pSpectrum->spectrum)[POSITRON][i]); - } - - nucleonNumber = GetNucleonNumber(pSpectrum); - nucleonEnergy = GetNucleonEnergy(pSpectrum, pEnergy); - neutrinoNumber = GetNeutrinoNumber(pSpectrum); - neutrinoEnergy = GetNeutrinoEnergy(pSpectrum, pEnergy); - totalNumber = photonNumber + leptonNumber + nucleonNumber + neutrinoNumber; - totalEnergy = photonEnergy + leptonEnergy + nucleonEnergy + neutrinoEnergy; - - if (sourceTypeSwitch == 0) /* single source */ - energyRedshiftFactor = 1./pow(tempFraction, 4); - else - { - energyRedshiftFactor = C/H_0*1.e6/1.e5*pow(1. + startingRedshift, - -1.5)/pow(tempFraction,1.5+brightPhaseExp)/(brightPhaseExp-2.5)* - (pow(tempFraction,brightPhaseExp-2.5) - 1.); - } - - // printf(" Total energy = %15.6E (arbitrary units)\n", totalEnergy); - // printf(" (total energy)/(injected energy) = %g\n", - // totalEnergy/initialTotalEnergy/energyRedshiftFactor); -} - - -void FinalPrintOutToTheScreen(const double distance, - const double startingRedshift, - const double propagatingDistance) -{ - double analyticalDistance; - - printf("\n\nTotal distance was %g Mpc ", - distance/DISTANCE_UNIT/1.e6); - analyticalDistance = 2./3.*C*1.e-5/H_0*(1. - - pow(1. + startingRedshift, -3./2.)); - printf("vs. real distance %g Mpc.\n", analyticalDistance); - printf("And total x was %g pc\n", propagatingDistance); -} diff --git a/libs/dint/src/fold.cpp b/libs/dint/src/fold.cpp deleted file mode 100644 index 7fb4dfd9c..000000000 --- a/libs/dint/src/fold.cpp +++ /dev/null @@ -1,826 +0,0 @@ -#include -#include -#include "dint/rate.h" -#include "dint/const.h" -#include "dint/cvector.h" -#include "dint/check.h" -#include "dint/utilities.h" - - -void InitializeLeptonCoefficients(TotalRate* leptonTotalRate, - DiffRate* leptonScatRate, - DiffRate* leptonExchRate, - DiffRate* leptonPhotonRate) -{ - InitializeTotalRate(leptonTotalRate); - InitializeDiffRate(leptonScatRate); - InitializeDiffRate(leptonExchRate); - InitializeDiffRate(leptonPhotonRate); -} - - -void InitializePhotonCoefficients(TotalRate* photonTotalRate, - DiffRate* photonLeptonRate) -{ - InitializeTotalRate(photonTotalRate); - InitializeDiffRate(photonLeptonRate); -} - -void InitializeNucleonCoefficients(TotalRate* protonTotalRate, - TotalRate* neutronTotalRate, - DiffRate* protonScatRate, - DiffRate* protonNeutronRate, - DiffRate* neutronProtonRate, - DiffRate* protonPhotonRate, - DiffRate* protonElectronRate, - DiffRate* protonPositronRate, - DiffRate* neutronElectronRate, - DiffRate* neutronPositronRate, - DiffRate* protonElectronNeutrinoRate, - DiffRate* protonAntiElectronNeutrinoRate, - DiffRate* protonMuonNeutrinoRate, - DiffRate* protonAntiMuonNeutrinoRate, - DiffRate* neutronAntiElectronNeutrinoRate, - DiffRate* neutronMuonNeutrinoRate, - DiffRate* neutronAntiMuonNeutrinoRate) -{ - InitializeTotalRate(protonTotalRate); - InitializeTotalRate(neutronTotalRate); - - InitializeDiffRate(protonScatRate); - InitializeDiffRate(protonNeutronRate); - InitializeDiffRate(neutronProtonRate); - InitializeDiffRate(protonPhotonRate); - InitializeDiffRate(protonElectronRate); - InitializeDiffRate(protonPositronRate); - InitializeDiffRate(neutronElectronRate); - InitializeDiffRate(neutronPositronRate); - InitializeDiffRate(protonElectronNeutrinoRate); - InitializeDiffRate(protonAntiElectronNeutrinoRate); - InitializeDiffRate(protonMuonNeutrinoRate); - InitializeDiffRate(protonAntiMuonNeutrinoRate); - InitializeDiffRate(neutronAntiElectronNeutrinoRate); - InitializeDiffRate(neutronMuonNeutrinoRate); - InitializeDiffRate(neutronAntiMuonNeutrinoRate); -} - -void InitializeNeutrinoCoefficients(TotalRate* elNeutTotalRate, - TotalRate* muonNeutTotalRate, - TotalRate* tauNeutTotalRate, - DiffRate* elNeutScatRate, - DiffRate* elNeutMuonNeutRate, - DiffRate* elNeutTauNeutRate, - DiffRate* elNeutElectronRate, - DiffRate* elNeutPhotonRate, - DiffRate* elNeutProtonRate, - DiffRate* muonNeutElNeutRate, - DiffRate* muonNeutScatRate, - DiffRate* muonNeutTauNeutRate, - DiffRate* muonNeutElectronRate, - DiffRate* muonNeutPhotonRate, - DiffRate* muonNeutProtonRate, - DiffRate* tauNeutElNeutRate, - DiffRate* tauNeutMuonNeutRate, - DiffRate* tauNeutScatRate, - DiffRate* tauNeutElectronRate, - DiffRate* tauNeutPhotonRate, - DiffRate* tauNeutProtonRate) -{ - InitializeTotalRate(elNeutTotalRate); - InitializeTotalRate(muonNeutTotalRate); - InitializeTotalRate(tauNeutTotalRate); - - InitializeDiffRate(elNeutScatRate); - InitializeDiffRate(elNeutMuonNeutRate); - InitializeDiffRate(elNeutTauNeutRate); - InitializeDiffRate(elNeutElectronRate); - InitializeDiffRate(elNeutPhotonRate); - InitializeDiffRate(elNeutProtonRate); - InitializeDiffRate(muonNeutElNeutRate); - InitializeDiffRate(muonNeutScatRate); - InitializeDiffRate(muonNeutTauNeutRate); - InitializeDiffRate(muonNeutElectronRate); - InitializeDiffRate(muonNeutPhotonRate); - InitializeDiffRate(muonNeutProtonRate); - InitializeDiffRate(tauNeutElNeutRate); - InitializeDiffRate(tauNeutMuonNeutRate); - InitializeDiffRate(tauNeutScatRate); - InitializeDiffRate(tauNeutElectronRate); - InitializeDiffRate(tauNeutPhotonRate); - InitializeDiffRate(tauNeutProtonRate); -} - - -void FoldTotalRate(const dCVector* pBgPhotonDensity, - const RawTotalRate* pRawTotalRate, TotalRate* pTotalRate) -{ - int i; - int j; - - if ((pBgPhotonDensity->dimension != pRawTotalRate->bgDimension) || - (pRawTotalRate->mainDimension != pTotalRate->mainDimension)) - { - Error("FoldTotalRate: inconsistent dimensions", PROGRAM_ERROR); - } - - for (i = 0; i < pRawTotalRate->mainDimension; i++) - { - for (j = 0; j < pRawTotalRate->bgDimension; j++) - { - (pTotalRate->totalRate)[i] += (pBgPhotonDensity->vector)[j]* - (pRawTotalRate->totalRate)[i][j]; - } - } -} - -void FoldDiffRate(const dCVector* pBgPhotonDensity, - const RawDiffRate* pRawDiffRate, - DiffRate* pDiffRate, const int scatSwitch, ...) -{ - int i; - int j; - int k; - int offset = 0; - int jLower; - int jUpper; - int num_main_bins; - int num_bg_bins; - - num_main_bins = pRawDiffRate->mainDimension; - num_bg_bins = pRawDiffRate->bgDimension; - - if ((pBgPhotonDensity->dimension != num_bg_bins) || - (num_main_bins != pDiffRate->mainDimension)) - { - Error("FoldDiffRate: inconsistent dimensions", PROGRAM_ERROR); - } - - if (scatSwitch != 0) - /* scattering type: adjustment of total rate(s) needed */ - { - va_list pArg; -// TotalRate* totalRateArray[scatSwitch]; - TotalRate* totalRateArray[3]; - - va_start(pArg, scatSwitch); - for (i = 0; i < scatSwitch; i++) - totalRateArray[i] = va_arg(pArg, TotalRate*); - /* Let totalRateArray[i] point to the totalRate* we will modify; we do - not need to update the arguments later - (i.e. va_arg(...) = totalRateArray[i];) because the actual values - they point to have been properly updated */ - - for (i = 0; i < num_main_bins; i++) - { - jLower = num_main_bins - 1; - jUpper = 0; - for (j = 0; j < num_bg_bins; j++) - { - if (pRawDiffRate->bound[i][j][0] != -1) - /* above threshold */ - { - offset += -(pRawDiffRate->bound)[i][j][0]; - jLower = IMin(jLower, (pRawDiffRate->bound)[i][j][0]); - jUpper = IMax(jUpper, (pRawDiffRate->bound)[i][j][1]); - for (k = (pRawDiffRate->bound)[i][j][0]; - k <= (pRawDiffRate->bound)[i][j][1]; k++) - { -#ifdef DEBUG - CheckIndex(0, i+1, k, "FoldDiffRate"); - CheckIndex(0, pRawDiffRate->numberOfElements, k+offset, - "FoldDiffRate"); -#endif - (pDiffRate->diffRate)[i][k] += - (pBgPhotonDensity->vector)[j]* - (pRawDiffRate->diffRate)[k+offset]; - } - /* these lines take care of the appropriate subtractions - made in the main implicit formula */ - if ((pRawDiffRate->bound)[i][j][1] == i) - /* if (((pRawDiffRate->bound)[i][j][0] <= i) && - ((pRawDiffRate->bound)[i][j][1] >= i)) */ - { - int l; - - for (l = 0; l < scatSwitch; l++) - { - (totalRateArray[l]->totalRate)[i] += - -(pRawDiffRate->diffRate)[i+offset]* - (pBgPhotonDensity->vector)[j]; - } - (pDiffRate->diffRate)[i][i] += - -(pRawDiffRate->diffRate)[i+offset]* - (pBgPhotonDensity->vector)[j]; - } - offset += (pRawDiffRate->bound)[i][j][1] + 1; - /* reset the offset index */ - } - } - (pDiffRate->bound)[i][0] = IMin((pDiffRate->bound)[i][0], jLower); - (pDiffRate->bound)[i][1] = IMax((pDiffRate->bound)[i][1], jUpper); - } - va_end(pArg); - } - else - { - for (i = 0; i < num_main_bins; i++) - { - jLower = num_main_bins - 1; - jUpper = 0; - for (j = 0; j < num_bg_bins; j++) - { - if (pRawDiffRate->bound[i][j][0] != -1) - /* if no threshold or above threshold */ - { - offset += -(pRawDiffRate->bound)[i][j][0]; - jLower = IMin(jLower, (pRawDiffRate->bound)[i][j][0]); - jUpper = IMax(jUpper, (pRawDiffRate->bound)[i][j][1]); - for (k = (pRawDiffRate->bound)[i][j][0]; - k <= (pRawDiffRate->bound)[i][j][1]; k++) - { -#ifdef DEBUG - CheckIndex(0, i+1, k, "FoldDiffRate"); - CheckIndex(0, pRawDiffRate->numberOfElements, k+offset, - "FoldDiffRate"); -#endif - (pDiffRate->diffRate)[i][k] += - (pBgPhotonDensity->vector)[j]* - (pRawDiffRate->diffRate)[k+offset]; - } - offset += (pRawDiffRate->bound)[i][j][1] + 1; - /* reset the offset index */ - } - } - (pDiffRate->bound)[i][0] = IMin((pDiffRate->bound)[i][0], jLower); - (pDiffRate->bound)[i][1] = IMax((pDiffRate->bound)[i][1], jUpper); - } - } -} - - -void FoldICS(const dCVector* pBgPhotonDensity, - const RawTotalRate* ICSTotalRate, - const RawDiffRate* ICSPhotonRate, const RawDiffRate* ICSScatRate, - TotalRate* leptonTotalRate, DiffRate* leptonPhotonRate, - DiffRate* leptonScatRate) -{ - FoldTotalRate(pBgPhotonDensity, ICSTotalRate, leptonTotalRate); - FoldDiffRate(pBgPhotonDensity, ICSScatRate, leptonScatRate, 1, - leptonTotalRate); - FoldDiffRate(pBgPhotonDensity, ICSPhotonRate, leptonPhotonRate, 0); -} - - -void FoldTPP(const dCVector* pBgPhotonDensity, const dCVector* pEnergy, - const RawTotalRate* TPPTotalRate, const RawDiffRate* TPPDiffRate, - TotalRate* leptonTotalRate, DiffRate* leptonScatRate, - DiffRate* leptonExchRate, dCVector* otherLoss) -{ - int i; - int j; - - if ((pEnergy->dimension != TPPTotalRate->mainDimension) || - (TPPTotalRate->bgDimension != pBgPhotonDensity->dimension) || - (otherLoss->dimension != pEnergy->dimension)) - { - Error("FoldTPP: inconsistent dimensions", PROGRAM_ERROR); - } - - /* add TPP total rates in continuous energy loss */ - for (i = 0; i < TPPTotalRate->mainDimension; i++) - { - (otherLoss->vector)[i] = 0.; - for (j = 0; j < TPPTotalRate->bgDimension; j++) - { - (otherLoss->vector)[i] += -(pEnergy->vector)[i]* - (pBgPhotonDensity->vector)[j]* - (TPPTotalRate->totalRate)[i][j]; - } - } - - FoldDiffRate(pBgPhotonDensity, TPPDiffRate, leptonScatRate, 1, - leptonTotalRate); - FoldDiffRate(pBgPhotonDensity, TPPDiffRate, leptonExchRate, 0); -} - - -void FoldPP(const dCVector* pBgPhotonDensity, const RawTotalRate* PPTotalRate, - const RawDiffRate* PPDiffRate, TotalRate* photonTotalRate, - DiffRate* photonLeptonRate) -{ - FoldTotalRate(pBgPhotonDensity, PPTotalRate, photonTotalRate); - FoldDiffRate(pBgPhotonDensity, PPDiffRate, photonLeptonRate, 0); -} - - -void FoldDPP(const dCVector* pBgPhotonDensity, const RawTotalRate* DPPRate, - TotalRate* photonTotalRate, DiffRate* photonLeptonRate) -/* I adopt a simple model where one pair of e-/e+ gets all the energy - equally (1/2); see PRD paper */ -{ - int i; - int j; - int jLower; - int jUpper; - int num_main_bins; - int num_bg_bins; - - double averaging_factor; - int offset; - double ratio; - - - num_main_bins = DPPRate->mainDimension; - num_bg_bins = DPPRate->bgDimension; - - if ((pBgPhotonDensity->dimension != num_bg_bins) || - (photonTotalRate->mainDimension != num_main_bins) || - (photonLeptonRate->mainDimension != num_main_bins)) - { - Error("FoldDPP: inconsistent dimensions", PROGRAM_ERROR); - } - - averaging_factor = (pow(10., 1./2./BINS_PER_DECADE) + - pow(10., -1./2./BINS_PER_DECADE))/2.; - /* although this could be supplied through arguments, I provide a local - version to keep the modality */ - offset = -(int)(BINS_PER_DECADE*log10(averaging_factor/2.) + 0.5); - ratio = offset/BINS_PER_DECADE - log10(2.); - - for (i = 0; i < num_main_bins; i++) - { - jLower = photonLeptonRate->bound[i][0]; - jUpper = photonLeptonRate->bound[i][1]; - for (j = 0; j < num_bg_bins; j++) - { - (photonTotalRate->totalRate)[i] += (pBgPhotonDensity->vector)[j]* - (DPPRate->totalRate)[i][j]; - if ((DPPRate->totalRate)[i][j] > 0.) - { - /* this is supplanted by the new implementation... - (photonLeptonRate->diffRate)[i][i-6] += - (pBgPhotonDensity->vector)[j]* - (DPPRate->totalRate)[i][j]*(1. - alpha); - (photonLeptonRate->diffRate)[i][i-7] += - (pBgPhotonDensity->vector)[j]* - (DPPRate->totalRate)[i][j]*alpha; - jLower = IMin((photonLeptonRate->bound)[i][0], i-7); - jUpper = IMax((photonLeptonRate->bound)[i][1], i-6); - */ - if (ratio < 1.) - { - if (i-offset >= 0) - { -#ifdef DEBUG - CheckIndex(0, num_main_bins, i-offset, "FoldDPP"); -#endif - (photonLeptonRate->diffRate)[i][i-offset] += - (pBgPhotonDensity->vector)[j]* - (DPPRate->totalRate)[i][j]*ratio; - - jLower = IMin(jLower, i-offset); - jUpper = IMax(jUpper, i-offset); - } - if (i-offset-1 >= 0) - { -#ifdef DEBUG - CheckIndex(0, num_main_bins, i-offset-1, "FoldDPP"); -#endif - (photonLeptonRate->diffRate)[i][i-offset-1] += - (pBgPhotonDensity->vector)[j]* - (DPPRate->totalRate)[i][j]*(1. - ratio); - - jLower = IMin(jLower, i-offset-1); - } - } - else - { - if (i-offset >= 0) - { -#ifdef DEBUG - CheckIndex(0, num_main_bins, i-offset, "FoldDPP"); -#endif - (photonLeptonRate->diffRate)[i][i-offset] += - (pBgPhotonDensity->vector)[j]* - (DPPRate->totalRate)[i][j]*(2. - ratio); - - jLower = IMin(jLower, i-offset); - jUpper = IMax(jUpper, i-offset); - } - if (i-offset+1 >= 0) - { -#ifdef DEBUG - CheckIndex(0, num_main_bins, i-offset+1, "FoldDPP"); -#endif - (photonLeptonRate->diffRate)[i][i-offset+1] += - (pBgPhotonDensity->vector)[j]* - (DPPRate->totalRate)[i][j]*(ratio - 1.); - - jUpper = IMax(jUpper, i-offset+1); - } - } - } - } - (photonLeptonRate->bound)[i][0] = jLower; - (photonLeptonRate->bound)[i][1] = jUpper; - /* update bounds */ - } -} - - -void FoldPPPNucleon(const dCVector* pBgPhotonDensity, - const RawTotalRate* PPPProtonLossRate, - const RawTotalRate* PPPNeutronLossRate, - const RawDiffRate* PPPProtonScatRate, - const RawDiffRate* PPPProtonNeutronRate, - const RawDiffRate* PPPNeutronProtonRate, - TotalRate* protonTotalRate, TotalRate* neutronTotalRate, - DiffRate* protonScatRate, DiffRate* protonNeutronRate, - DiffRate* neutronProtonRate) -{ - FoldTotalRate(pBgPhotonDensity, PPPProtonLossRate, protonTotalRate); - FoldTotalRate(pBgPhotonDensity, PPPNeutronLossRate, neutronTotalRate); - - /*---- nucleon -> nucleon from PPP ----*/ - FoldDiffRate(pBgPhotonDensity, PPPProtonScatRate, protonScatRate, - 2, protonTotalRate, neutronTotalRate); - FoldDiffRate(pBgPhotonDensity, PPPProtonNeutronRate, protonNeutronRate, - 0); - FoldDiffRate(pBgPhotonDensity, PPPNeutronProtonRate, neutronProtonRate, - 0); -} - - -void FoldPPPSecondary(const dCVector* pBgPhotonDensity, - const RawDiffRate* PPPProtonPhotonRate, - const RawDiffRate* PPPProtonElectronRate, - const RawDiffRate* PPPProtonPositronRate, - const RawDiffRate* PPPNeutronElectronRate, - const RawDiffRate* PPPProtonElectronNeutrinoRate, - const RawDiffRate* PPPProtonAntiElectronNeutrinoRate, - const RawDiffRate* PPPProtonMuonNeutrinoRate, - const RawDiffRate* PPPProtonAntiMuonNeutrinoRate, - const RawDiffRate* PPPNeutronAntiElectronNeutrinoRate, - const RawDiffRate* PPPNeutronMuonNeutrinoRate, - const RawDiffRate* PPPNeutronAntiMuonNeutrinoRate, - DiffRate* protonPhotonRate, - DiffRate* protonElectronRate, - DiffRate* protonPositronRate, - DiffRate* neutronElectronRate, - DiffRate* neutronPositronRate, - DiffRate* protonElectronNeutrinoRate, - DiffRate* protonAntiElectronNeutrinoRate, - DiffRate* protonMuonNeutrinoRate, - DiffRate* protonAntiMuonNeutrinoRate, - DiffRate* neutronAntiElectronNeutrinoRate, - DiffRate* neutronMuonNeutrinoRate, - DiffRate* neutronAntiMuonNeutrinoRate) -{ - /*---- nucleon -> EM species (gamma, e+/-) from PPP ----*/ - FoldDiffRate(pBgPhotonDensity, PPPProtonPhotonRate, protonPhotonRate, - 0); - FoldDiffRate(pBgPhotonDensity, PPPProtonPositronRate, protonPositronRate, - 0); - FoldDiffRate(pBgPhotonDensity, PPPNeutronElectronRate, - neutronElectronRate, 0); - FoldDiffRate(pBgPhotonDensity, PPPProtonElectronRate, protonElectronRate, - 0); - FoldDiffRate(pBgPhotonDensity, PPPProtonElectronRate, neutronPositronRate, - 0); - - /*---- nucleons -> neutrinos from PPP ----*/ - FoldDiffRate(pBgPhotonDensity, PPPProtonMuonNeutrinoRate, - protonMuonNeutrinoRate, 0); - FoldDiffRate(pBgPhotonDensity, PPPNeutronAntiMuonNeutrinoRate, - neutronAntiMuonNeutrinoRate, 0); - FoldDiffRate(pBgPhotonDensity, PPPProtonAntiMuonNeutrinoRate, - protonAntiMuonNeutrinoRate, 0); - FoldDiffRate(pBgPhotonDensity, PPPNeutronMuonNeutrinoRate, - neutronMuonNeutrinoRate, 0); - FoldDiffRate(pBgPhotonDensity, PPPProtonElectronNeutrinoRate, - protonElectronNeutrinoRate, 0); - FoldDiffRate(pBgPhotonDensity, PPPNeutronAntiElectronNeutrinoRate, - neutronAntiElectronNeutrinoRate, 0); - FoldDiffRate(pBgPhotonDensity, PPPProtonAntiElectronNeutrinoRate, - protonAntiElectronNeutrinoRate, 0); -} - -void FoldNPPNucleon(const dCVector* pBgPhotonDensity, const dCVector* pEnergy, - const RawTotalRate* NPPTotalRate, - dCVector* protonContinuousLoss) -{ - int i; - int j; - int num_main_bins; - int num_bg_bins; - - num_main_bins = pEnergy->dimension; - num_bg_bins = pBgPhotonDensity->dimension; - - if ((NPPTotalRate->mainDimension != num_main_bins) || - (NPPTotalRate->bgDimension != num_bg_bins) || - (protonContinuousLoss->dimension != num_main_bins)) - { - Error("FoldNPP: inconsistent dimensions", PROGRAM_ERROR); - } - - /*---- continuous energy loss ----*/ - for (i = 0; i < num_main_bins; i++) - { - (protonContinuousLoss->vector)[i] = 0.; - /* this is very important! */ - for (j = 0; j < num_bg_bins; j++) - { - (protonContinuousLoss->vector)[i] += -(pEnergy->vector)[i]* - (pBgPhotonDensity->vector)[j]* - (NPPTotalRate->totalRate)[i][j]; - } - } -} - -void FoldNPPSecondary(const dCVector* pBgPhotonDensity, - const RawDiffRate* NPPDiffRate, - DiffRate* protonPositronRate, - DiffRate* protonElectronRate) -{ - FoldDiffRate(pBgPhotonDensity, NPPDiffRate, protonPositronRate, 0); - FoldDiffRate(pBgPhotonDensity, NPPDiffRate, protonElectronRate, 0); -} - - -void MapNeutTotalRate(const double redshift, const int lastIndex, - const int tauNeutrinoMassSwitch, - const TotalRate* NNTotalRate, TotalRate* pRate) -/* This is for m_nu = 0 */ -{ - double redshiftFactor; - int i; - int offset; - int iNew; - int num_main_bins; - - num_main_bins = pRate->mainDimension; - - if (NNTotalRate->mainDimension != pRate->mainDimension) - { - Error("ManNeutTotalRate: inconsistent dimensions", PROGRAM_ERROR); - } - redshiftFactor = (1. + redshift)*(1. + redshift)*(1. + redshift); - - if (tauNeutrinoMassSwitch == 2) /* massless case */ - { - if (lastIndex == 0) /* away from z = 0 (simple sliding applies) */ - { - offset = (int)(BINS_PER_DECADE*log10(1. + redshift)); - for (i = 0; i < num_main_bins; i++) - { - iNew = i + offset; - /* map to the right index */ - if (iNew >= num_main_bins) - iNew = num_main_bins - 1; - /* if the index is beyond range, simply set it to maximum - (unsatisfactory?) */ -#ifdef DEBUG - CheckIndex(0, num_main_bins, iNew, "MapNeutTotalRate"); -#endif - (pRate->totalRate)[i] = redshiftFactor* - (NNTotalRate->totalRate)[iNew]; - } - } - else - { - double fraction; - - fraction = BINS_PER_DECADE*log10(1. + redshift); - offset = (int)fraction; - for (i = 0; i < num_main_bins; i++) - { - iNew = i + offset; - if (iNew < num_main_bins - 1) - { -#ifdef DEBUG - CheckIndex(0, num_main_bins, iNew, "MapNeutTotalRate"); -#endif - (pRate->totalRate)[i] = redshiftFactor* - ((NNTotalRate->totalRate)[iNew]* - (1. - fraction) + (NNTotalRate->totalRate)[iNew+1]* - fraction); - } - else - { - (pRate->totalRate)[i] = redshiftFactor* - (NNTotalRate->totalRate)[num_main_bins-1]; - } - } - } - } - else /* massive neutrinos */ - { - for (i = 0; i < num_main_bins; i++) - { - (pRate->totalRate)[i] = redshiftFactor* - (NNTotalRate->totalRate)[i]; - } - } -} - -void MapNeutDiffRate(const double redshift, const int lastIndex, - const int tauNeutrinoMassSwitch, - const DiffRate* NNDiffRate, DiffRate* pRate) -{ - int i; - int j; - int offset; - int iNew; - int jNew; - double redshiftFactor; - int num_main_bins; - - num_main_bins = pRate->mainDimension; - - if (NNDiffRate->mainDimension != pRate->mainDimension) - { - Error("ManNeutDiffRate: inconsistent dimensions", PROGRAM_ERROR); - } - - redshiftFactor = (1. + redshift)*(1. + redshift)*(1. + redshift); - - if (tauNeutrinoMassSwitch == 2) /* massless case */ - { - if (lastIndex == 0) /* away from z = 0 (simple sliding applies) */ - { - offset = (int)(BINS_PER_DECADE*log10(1. + redshift)); - for (i = 0; i < num_main_bins; i++) - { - iNew = i + offset; - /* map to the right index */ - if (iNew >= num_main_bins) - iNew = num_main_bins - 1; - /* if the index is beyond range, simply set it to maximum - (unsatisfactory?) */ - for (j = 0; j < num_main_bins; j++) - { - jNew = j + offset; - if (jNew >= num_main_bins) - jNew = num_main_bins - 1; - -#ifdef DEBUG - CheckIndex(0, num_main_bins, iNew, "MapNeutDiffRate"); - CheckIndex(0, num_main_bins, jNew, "MapNeutDiffRate"); -#endif - (pRate->diffRate)[i][j] = redshiftFactor* - (NNDiffRate->diffRate)[iNew][jNew]; - } - } - } - else - { - double fraction; - - fraction = BINS_PER_DECADE*log10(1. + redshift); - offset = (int)fraction; - for (i = 0; i < num_main_bins; i++) - { - iNew = i + offset; - for (j = 0; j < num_main_bins; j++) - { - jNew = j + offset; - if (iNew < num_main_bins - 1) - { -#ifdef DEBUG - CheckIndex(0, num_main_bins, iNew, "MapNeutDiffRate"); - CheckIndex(0, num_main_bins, jNew, "MapNeutDiffRate"); - CheckIndex(0, num_main_bins, iNew+1, - "MapNeutDiffRate"); - CheckIndex(0, num_main_bins, jNew+1, - "MapNeutDiffRate"); -#endif - (pRate->diffRate)[i][j] = redshiftFactor* - ((NNDiffRate->diffRate)[iNew][jNew]* - (1. - fraction)*(1. - fraction) + - ((NNDiffRate->diffRate)[iNew+1][jNew] + - (NNDiffRate->diffRate)[iNew][jNew+1])*fraction* - (1. - fraction) + - (NNDiffRate->diffRate)[iNew+1][jNew+1]*fraction* - fraction); - } - else if (jNew < num_main_bins - 1) - { -#ifdef DEBUG - CheckIndex(0, num_main_bins, jNew, "MapNeutDiffRate"); - CheckIndex(0, num_main_bins, jNew+1, - "MapNeutDiffRate"); -#endif - (pRate->diffRate)[i][j] = redshiftFactor* - ((NNDiffRate->diffRate)[num_main_bins-1][jNew]* - (1. - fraction) + - (NNDiffRate->diffRate)[num_main_bins-1][jNew+1]* - fraction); - } - else - { - (pRate->diffRate)[i][j] = redshiftFactor* - (NNDiffRate->diffRate)[num_main_bins-1][num_main_bins-1]; - } - } - } - } - } - else /* massive neutrino: simply multiply by redshift factor */ - { - for (i = 0; i < num_main_bins; i++) - { - for (j = 0; j < num_main_bins; j++) - { - (pRate->diffRate)[i][j] = redshiftFactor* - (NNDiffRate->diffRate)[i][j]; - } - } - } - - /* take care of bounds: simply make it standard (0 <= k <= i) */ - for (i = 0; i < pRate->mainDimension; i++) - { - pRate->bound[i][0] = 0; - pRate->bound[i][1] = i; - } -} - -void MapNeutRates(const double redshift, const int lastIndex, - const int tauNeutrinoMassSwitch, - const TotalRate* NNElNeutTotalRate, - const TotalRate* NNMuonNeutTotalRate, - const TotalRate* NNTauNeutTotalRate, - const DiffRate* NNElNeutScatRate, - const DiffRate* NNElNeutMuonNeutRate, - const DiffRate* NNElNeutTauNeutRate, - const DiffRate* NNElNeutElectronRate, - const DiffRate* NNElNeutPhotonRate, - const DiffRate* NNElNeutProtonRate, - const DiffRate* NNMuonNeutElNeutRate, - const DiffRate* NNMuonNeutScatRate, - const DiffRate* NNMuonNeutTauNeutRate, - const DiffRate* NNMuonNeutElectronRate, - const DiffRate* NNMuonNeutPhotonRate, - const DiffRate* NNMuonNeutProtonRate, - const DiffRate* NNTauNeutElNeutRate, - const DiffRate* NNTauNeutMuonNeutRate, - const DiffRate* NNTauNeutScatRate, - const DiffRate* NNTauNeutElectronRate, - const DiffRate* NNTauNeutPhotonRate, - const DiffRate* NNTauNeutProtonRate, - TotalRate* elNeutTotalRate, TotalRate* muonNeutTotalRate, - TotalRate* tauNeutTotalRate, DiffRate* elNeutScatRate, - DiffRate* elNeutMuonNeutRate, DiffRate* elNeutTauNeutRate, - DiffRate* elNeutElectronRate, DiffRate* elNeutPhotonRate, - DiffRate* elNeutProtonRate, DiffRate* muonNeutElNeutRate, - DiffRate* muonNeutScatRate, DiffRate* muonNeutTauNeutRate, - DiffRate* muonNeutElectronRate, DiffRate* muonNeutPhotonRate, - DiffRate* muonNeutProtonRate, DiffRate* tauNeutElNeutRate, - DiffRate* tauNeutMuonNeutRate, DiffRate* tauNeutScatRate, - DiffRate* tauNeutElectronRate, DiffRate* tauNeutPhotonRate, - DiffRate* tauNeutProtonRate) -{ - MapNeutTotalRate(redshift, lastIndex, tauNeutrinoMassSwitch, - NNElNeutTotalRate, elNeutTotalRate); - MapNeutTotalRate(redshift, lastIndex, tauNeutrinoMassSwitch, - NNMuonNeutTotalRate, muonNeutTotalRate); - MapNeutTotalRate(redshift, lastIndex, tauNeutrinoMassSwitch, - NNTauNeutTotalRate, tauNeutTotalRate); - MapNeutDiffRate(redshift, lastIndex, tauNeutrinoMassSwitch, - NNElNeutScatRate, elNeutScatRate); - MapNeutDiffRate(redshift, lastIndex, tauNeutrinoMassSwitch, - NNElNeutMuonNeutRate, elNeutMuonNeutRate); - MapNeutDiffRate(redshift, lastIndex, tauNeutrinoMassSwitch, - NNElNeutTauNeutRate, elNeutTauNeutRate); - MapNeutDiffRate(redshift, lastIndex, tauNeutrinoMassSwitch, - NNElNeutElectronRate, elNeutElectronRate); - MapNeutDiffRate(redshift, lastIndex, tauNeutrinoMassSwitch, - NNElNeutPhotonRate, elNeutPhotonRate); - MapNeutDiffRate(redshift, lastIndex, tauNeutrinoMassSwitch, - NNElNeutProtonRate, elNeutProtonRate); - MapNeutDiffRate(redshift, lastIndex, tauNeutrinoMassSwitch, - NNMuonNeutElNeutRate, muonNeutElNeutRate); - MapNeutDiffRate(redshift, lastIndex, tauNeutrinoMassSwitch, - NNMuonNeutScatRate, muonNeutScatRate); - MapNeutDiffRate(redshift, lastIndex, tauNeutrinoMassSwitch, - NNMuonNeutTauNeutRate, muonNeutTauNeutRate); - MapNeutDiffRate(redshift, lastIndex, tauNeutrinoMassSwitch, - NNMuonNeutElectronRate, muonNeutElectronRate); - MapNeutDiffRate(redshift, lastIndex, tauNeutrinoMassSwitch, - NNMuonNeutPhotonRate, muonNeutPhotonRate); - MapNeutDiffRate(redshift, lastIndex, tauNeutrinoMassSwitch, - NNMuonNeutProtonRate, muonNeutProtonRate); - MapNeutDiffRate(redshift, lastIndex, tauNeutrinoMassSwitch, - NNTauNeutElNeutRate, tauNeutElNeutRate); - MapNeutDiffRate(redshift, lastIndex, tauNeutrinoMassSwitch, - NNTauNeutMuonNeutRate, tauNeutMuonNeutRate); - MapNeutDiffRate(redshift, lastIndex, tauNeutrinoMassSwitch, - NNTauNeutScatRate, tauNeutScatRate); - MapNeutDiffRate(redshift, lastIndex, tauNeutrinoMassSwitch, - NNTauNeutElectronRate, tauNeutElectronRate); - MapNeutDiffRate(redshift, lastIndex, tauNeutrinoMassSwitch, - NNTauNeutPhotonRate, tauNeutPhotonRate); - MapNeutDiffRate(redshift, lastIndex, tauNeutrinoMassSwitch, - NNTauNeutProtonRate, tauNeutProtonRate); -} diff --git a/libs/dint/src/frag.cpp b/libs/dint/src/frag.cpp deleted file mode 100644 index ba2394cf1..000000000 --- a/libs/dint/src/frag.cpp +++ /dev/null @@ -1,582 +0,0 @@ -#include -#include -#include "dint/utilities.h" - -double OldFrag(const double x) -{ - double result; - - if ((x > 1.) || (x < 0.)) - Error("OldFrag: invalid x in FragFunction.", PROGRAM_ERROR); - - result = 15./16.*pow(x, -1.5)*(1. - x)*(1. - x); - return result; -} - -double HillFrag(const double x) -{ - double result; - - if ((x > 1.) || (x < 0.)) - Error("HillFrag: invalid x in FragFunction.", PROGRAM_ERROR); - - result = 0.08*exp(2.6*pow(log(1./x),0.5))*pow(1.-x,2.)/ - (x*pow(log(1./x),0.5)); - return result; -} - -double TestFrag(const double x) -{ - double result,dum; - - if ((x > 1.) || (x < 0.)) - Error("TestFrag: invalid x in FragFunction.", PROGRAM_ERROR); - - dum=log(1.e16*x); - result=pow(10.,16.40245282549585 + (0.972599977555579 + - (-0.437688709005956 + (0.07127838644906224 + - (-0.0096795444540692 + - (0.001074648803851362 + - (-0.0001017698959101458 + - (8.29188862155849e-6 + - (-6.028775483570168e-7 + - (3.722893226065044e-8 - - 5.328241092075332e-9* - (-14.27185163534489 + - 0.4342944819032517*dum))* - (-12.58946076125045 + - 0.4342944819032517*dum))* - (-10.90706988715602 + - 0.4342944819032517*dum))* - (-9.22467901306159 + - 0.4342944819032517*dum))* - (-7.542288138967164 + 0.4342944819032517*dum)) - *(-5.859897264872732 + 0.4342944819032517*dum))* - (-4.1775063907783 + 0.4342944819032517*dum))* - (-2.495115516683869 + 0.4342944819032517*dum))* - (-0.812724642589438 + 0.4342944819032517*dum))* - (0.869666231504994 + 0.4342944819032517*dum)); - - return result; -} - -double MLLA_25(const double x) -{ - double result,dum; - - if ((x > 1.) || (x < 0.)) - Error("MLLA_25: invalid x in FragFunction.", PROGRAM_ERROR); - - dum=log(5.e15*x); - result=pow(2.,15.40458956729789 + (0.985611314574832 + - (-0.4486531617591206 + (0.07437713380769515 + - (-0.01028351361441756 + - (0.001162396465975171 + - (-0.0001120792654142042 + - (9.29759848042302e-6 + - (-6.883087600199417e-7 + - (4.326958021115784e-8 - - 6.309347416082323e-9* - (-14.0009246392473 + - 0.4342944819032517*dum))* - (-12.34863676471927 + - 0.4342944819032517*dum))* - (-10.69634889019124 + - 0.4342944819032517*dum))* - (-9.04406101566321 + - 0.4342944819032517*dum))* - (-7.391773141135174 + - 0.4342944819032517*dum))* - (-5.73948526660714 + 0.4342944819032517*dum))* - (-4.087197392079107 + 0.4342944819032517*dum))* - (-2.434909517551073 + 0.4342944819032517*dum))* - (-0.78262164302304 + 0.4342944819032517*dum))* - (0.869666231504994 + 0.4342944819032517*dum))* - pow(5.,16.40458956729789 + (0.985611314574832 + - (-0.4486531617591206 + (0.07437713380769515 + - (-0.01028351361441756 + - (0.001162396465975171 + - (-0.0001120792654142042 + - (9.29759848042302e-6 + - (-6.883087600199417e-7 + - (4.326958021115784e-8 - - 6.309347416082323e-9* - (-14.0009246392473 + - 0.4342944819032517*dum))* - (-12.34863676471927 + - 0.4342944819032517*dum))* - (-10.69634889019124 + - 0.4342944819032517*dum))* - (-9.04406101566321 + - 0.4342944819032517*dum))* - (-7.391773141135174 + - 0.4342944819032517*dum))* - (-5.73948526660714 + 0.4342944819032517*dum))* - (-4.087197392079107 + 0.4342944819032517*dum))* - (-2.434909517551073 + 0.4342944819032517*dum))* - (-0.78262164302304 + 0.4342944819032517*dum))* - (0.869666231504994 + 0.4342944819032517*dum)); - - return result; -} - -double MLLA_24(const double x) -{ - double result,dum; - - if ((x > 1.) || (x < 0.)) - Error("MLLA_24: invalid x in FragFunction.", PROGRAM_ERROR); - - dum=log(5.e14*x); - result=pow(2.,14.41151551291054 + (1.031272826827779 + - (-0.4887554084149168 + (0.0861742231419955 + - (-0.01267862267956894 + - (0.001524972879202349 + - (-0.0001564836567815242 + - (0.00001381420881469393 + - (-1.088524574431424e-6 + - (7.278270707633613e-8 - - 1.131740588420111e-8* - (-13.1009246392473 + - 0.4342944819032517*dum))* - (-11.54863676471927 + - 0.4342944819032517*dum))* - (-9.99634889019124 + - 0.4342944819032517*dum))* - (-8.44406101566321 + - 0.4342944819032517*dum))* - (-6.891773141135172 + - 0.4342944819032517*dum))* - (-5.339485266607138 + 0.4342944819032517*dum))* - (-3.787197392079105 + 0.4342944819032517*dum))* - (-2.234909517551072 + 0.4342944819032517*dum))* - (-0.6826216430230394 + 0.4342944819032517*dum))* - (0.869666231504994 + 0.4342944819032517*dum))* - pow(5.,15.41151551291054 + (1.031272826827779 + - (-0.4887554084149168 + (0.0861742231419955 + - (-0.01267862267956894 + - (0.001524972879202349 + - (-0.0001564836567815242 + - (0.00001381420881469393 + - (-1.088524574431424e-6 + - (7.278270707633613e-8 - - 1.131740588420111e-8* - (-13.1009246392473 + - 0.4342944819032517*dum))* - (-11.54863676471927 + - 0.4342944819032517*dum))* - (-9.99634889019124 + - 0.4342944819032517*dum))* - (-8.44406101566321 + - 0.4342944819032517*dum))* - (-6.891773141135172 + - 0.4342944819032517*dum))* - (-5.339485266607138 + 0.4342944819032517*dum))* - (-3.787197392079105 + 0.4342944819032517*dum))* - (-2.234909517551072 + 0.4342944819032517*dum))* - (-0.6826216430230394 + 0.4342944819032517*dum))* - (0.869666231504994 + 0.4342944819032517*dum)); - - return result; -} - -double MLLA_23(const double x) -{ - double result,dum; - - if ((x > 1.) || (x < 0.)) - Error("MLLA_23: invalid x in FragFunction.", PROGRAM_ERROR); - - dum=log(5.e13*x); - result=pow(2.,13.41903621081451 + (1.080543174351792 + - (-0.5353344158025766 + (0.1007918200125547 + - (-0.01584522550357778 + - (0.00203634282994057 + - (-0.0002232988627851284 + - (0.00002106422871935973 + - (-1.774021976209115e-6 + - (1.26678984354972e-7 - - 2.109673764365339e-8* - (-12.2009246392473 + - 0.4342944819032517*dum))* - (-10.74863676471927 + - 0.4342944819032517*dum))* - (-9.29634889019124 + - 0.4342944819032517*dum))* - (-7.844061015663205 + - 0.4342944819032517*dum))* - (-6.391773141135174 + - 0.4342944819032517*dum))* - (-4.93948526660714 + 0.4342944819032517*dum))* - (-3.487197392079106 + 0.4342944819032517*dum))* - (-2.034909517551073 + 0.4342944819032517*dum))* - (-0.5826216430230398 + 0.4342944819032517*dum))* - (0.869666231504994 + 0.4342944819032517*dum))* - pow(5.,14.4190362108145 + (1.080543174351792 + - (-0.5353344158025766 + (0.1007918200125547 + - (-0.01584522550357778 + - (0.00203634282994057 + - (-0.0002232988627851284 + - (0.00002106422871935973 + - (-1.774021976209115e-6 + - (1.26678984354972e-7 - - 2.109673764365339e-8* - (-12.2009246392473 + - 0.4342944819032517*dum))* - (-10.74863676471927 + - 0.4342944819032517*dum))* - (-9.29634889019124 + - 0.4342944819032517*dum))* - (-7.844061015663205 + - 0.4342944819032517*dum))* - (-6.391773141135174 + - 0.4342944819032517*dum))* - (-4.93948526660714 + 0.4342944819032517*dum))* - (-3.487197392079106 + 0.4342944819032517*dum))* - (-2.034909517551073 + 0.4342944819032517*dum))* - (-0.5826216430230398 + 0.4342944819032517*dum))* - (0.869666231504994 + 0.4342944819032517*dum)); - - return result; -} - -double MLLA_22(const double x) -{ - double result,dum; - - if ((x > 1.) || (x < 0.)) - Error("MLLA_22: invalid x in FragFunction.", PROGRAM_ERROR); - - dum=log(5.e12*x); - result=pow(2.,12.42700515451375 + (1.13410597810389 + - (-0.5900360565767645 + (0.1191811135998055 + - (-0.02011422129768237 + - (0.002774985316661523 + - (-0.000326719986276957 + - (0.00003308906432045379 + - (-2.992669826664713e-6 + - (2.292869774886544e-7 - - 4.109421051511541e-8* - (-11.3009246392473 + - 0.4342944819032517*dum))* - (-9.94863676471927 + - 0.4342944819032517*dum))* - (-8.59634889019124 + - 0.4342944819032517*dum))* - (-7.244061015663207 + - 0.4342944819032517*dum))* - (-5.891773141135173 + - 0.4342944819032517*dum))* - (-4.539485266607139 + 0.4342944819032517*dum))* - (-3.187197392079106 + 0.4342944819032517*dum))* - (-1.834909517551073 + 0.4342944819032517*dum))* - (-0.4826216430230396 + 0.4342944819032517*dum))* - (0.869666231504994 + 0.4342944819032517*dum))* - pow(5.,13.42700515451375 + (1.13410597810389 + - (-0.5900360565767645 + (0.1191811135998055 + - (-0.02011422129768237 + - (0.002774985316661523 + - (-0.000326719986276957 + - (0.00003308906432045379 + - (-2.992669826664713e-6 + - (2.292869774886544e-7 - - 4.109421051511541e-8* - (-11.3009246392473 + - 0.4342944819032517*dum))* - (-9.94863676471927 + - 0.4342944819032517*dum))* - (-8.59634889019124 + - 0.4342944819032517*dum))* - (-7.244061015663207 + - 0.4342944819032517*dum))* - (-5.891773141135173 + - 0.4342944819032517*dum))* - (-4.539485266607139 + 0.4342944819032517*dum))* - (-3.187197392079106 + 0.4342944819032517*dum))* - (-1.834909517551073 + 0.4342944819032517*dum))* - (-0.4826216430230396 + 0.4342944819032517*dum))* - (0.869666231504994 + 0.4342944819032517*dum)); - - return result; -} - -double Susy_MLLA_25(const double x) -{ - double result,dum; - - if ((x > 1.) || (x < 0.)) - Error("SUSY_MLLA_25: invalid x in FragFunction.", PROGRAM_ERROR); - - dum=log(5.e15*x); - result=pow(2.,17.80939867175655 + (0.2839116910462308 + - (-0.2356852044900653 + (0.02811959068440033 + - (-0.003372920093046873 + - (0.0003286208445235064 + - (-0.00002939777800753709 + - (2.158754018629821e-6 + - (-1.695451594928554e-7 + - 1.096396916569957e-9* - (-12.9950665059705 + - 0.4342944819032517*dum))* - (-11.3649635064041 + - 0.4342944819032517*dum))* - (-9.73486050683771 + - 0.4342944819032517*dum))* - (-8.10475750727131 + - 0.4342944819032517*dum))* - (-6.474654507704915 + 0.4342944819032517*dum))* - (-4.844551508138517 + 0.4342944819032517*dum))* - (-3.214448508572119 + 0.4342944819032517*dum))* - (-1.584345509005722 + 0.4342944819032517*dum))* - (0.04575749056067511 + 0.4342944819032517*dum))* - pow(5.,18.80939867175655 + (0.2839116910462308 + - (-0.2356852044900653 + (0.02811959068440033 + - (-0.003372920093046873 + - (0.0003286208445235064 + - (-0.00002939777800753709 + - (2.158754018629821e-6 + - (-1.695451594928554e-7 + - 1.096396916569957e-9* - (-12.9950665059705 + - 0.4342944819032517*dum))* - (-11.3649635064041 + - 0.4342944819032517*dum))* - (-9.73486050683771 + - 0.4342944819032517*dum))* - (-8.10475750727131 + 0.4342944819032517*dum))* - (-6.474654507704915 + 0.4342944819032517*dum))* - (-4.844551508138517 + 0.4342944819032517*dum))* - (-3.214448508572119 + 0.4342944819032517*dum))* - (-1.584345509005722 + 0.4342944819032517*dum))* - (0.04575749056067511 + 0.4342944819032517*dum)); - - return result; -} - -double Susy_MLLA_24(const double x) -{ - double result,dum; - - if ((x > 1.) || (x < 0.)) - Error("SUSY_MLLA_24: invalid x in FragFunction.", PROGRAM_ERROR); - - dum=log(5.e14*x); - result=pow(2.,16.77113060518843 + (0.2757875825414864 + - (-0.2492517918211629 + (0.03115785196336573 + - (-0.003960507732763939 + - (0.0004075768109015362 + - (-0.00003875082087547734 + - (3.001698672664923e-6 + - (-2.54680759800193e-7 - - 6.061017668092866e-10* - (-12.1950665059705 + - 0.4342944819032517*dum))* - (-10.6649635064041 + - 0.4342944819032517*dum))* - (-9.13486050683771 + - 0.4342944819032517*dum))* - (-7.604757507271312 + - 0.4342944819032517*dum))* - (-6.074654507704915 + 0.4342944819032517*dum))* - (-4.544551508138517 + 0.4342944819032517*dum))* - (-3.01444850857212 + 0.4342944819032517*dum))* - (-1.484345509005722 + 0.4342944819032517*dum))* - (0.04575749056067511 + 0.4342944819032517*dum))* - pow(5.,17.77113060518843 + (0.2757875825414864 + - (-0.2492517918211629 + (0.03115785196336573 + - (-0.003960507732763939 + - (0.0004075768109015362 + - (-0.00003875082087547734 + - (3.001698672664923e-6 + - (-2.54680759800193e-7 - - 6.061017668092866e-10* - (-12.1950665059705 + - 0.4342944819032517*dum))* - (-10.6649635064041 + - 0.4342944819032517*dum))* - (-9.13486050683771 + - 0.4342944819032517*dum))* - (-7.604757507271312 + - 0.4342944819032517*dum))* - (-6.074654507704915 + 0.4342944819032517*dum))* - (-4.544551508138517 + 0.4342944819032517*dum))* - (-3.01444850857212 + 0.4342944819032517*dum))* - (-1.484345509005722 + 0.4342944819032517*dum))* - (0.04575749056067511 + 0.4342944819032517*dum)); - - return result; -} - -double Susy_MLLA_23(const double x) -{ - double result,dum; - - if ((x > 1.) || (x < 0.)) - Error("SUSY_MLLA_23: invalid x in FragFunction.", PROGRAM_ERROR); - - dum=log(5.e13*x); - result=pow(2.,15.72966406841544 + (0.2650394265463622 + - (-0.2643461911608049 + (0.03469445588689251 + - (-0.004691489477251425 + - (0.0005115097120944895 + - (-0.00005190898995160702 + - (4.25132297772461e-6 + - (-3.930251977808645e-7 - - 6.036368834076273e-9* - (-11.3950665059705 + - 0.4342944819032517*dum))* - (-9.96496350640411 + - 0.4342944819032517*dum))* - (-8.53486050683771 + - 0.4342944819032517*dum))* - (-7.104757507271313 + - 0.4342944819032517*dum))* - (-5.674654507704915 + 0.4342944819032517*dum))* - (-4.244551508138518 + 0.4342944819032517*dum))* - (-2.81444850857212 + 0.4342944819032517*dum))* - (-1.384345509005722 + 0.4342944819032517*dum))* - (0.04575749056067511 + 0.4342944819032517*dum))* - pow(5.,16.72966406841544 + (0.2650394265463622 + - (-0.2643461911608049 + (0.03469445588689251 + - (-0.004691489477251425 + - (0.0005115097120944895 + - (-0.00005190898995160702 + - (4.25132297772461e-6 + - (-3.930251977808645e-7 - - 6.036368834076273e-9* - (-11.3950665059705 + - 0.4342944819032517*dum))* - (-9.96496350640411 + - 0.4342944819032517*dum))* - (-8.53486050683771 + - 0.4342944819032517*dum))* - (-7.104757507271313 + - 0.4342944819032517*dum))* - (-5.674654507704915 + 0.4342944819032517*dum))* - (-4.244551508138518 + 0.4342944819032517*dum))* - (-2.81444850857212 + 0.4342944819032517*dum))* - (-1.384345509005722 + 0.4342944819032517*dum))* - (0.04575749056067511 + 0.4342944819032517*dum)); - - return result; -} - -double Susy_MLLA_22(const double x) -{ - double result,dum; - - if ((x > 1.) || (x < 0.)) - Error("SUSY_MLLA_22: invalid x in FragFunction.", PROGRAM_ERROR); - - dum=log(5.e12*x); - result=pow(2.,14.684456999313 + (0.2510136065483903 + - (-0.2812473861506196 + (0.03884100532808183 + - (-0.005612423127059197 + - (0.0006504629731684842 + - (-0.00007081237970893412 + - (6.145415483685166e-6 + - (-6.258855246298706e-7 - - 2.175481457118431e-8* - (-10.5950665059705 + - 0.4342944819032517*dum))* - (-9.26496350640411 + - 0.4342944819032517*dum))* - (-7.934860506837712 + - 0.4342944819032517*dum))* - (-6.604757507271314 + - 0.4342944819032517*dum))* - (-5.274654507704916 + 0.4342944819032517*dum))* - (-3.944551508138518 + 0.4342944819032517*dum))* - (-2.61444850857212 + 0.4342944819032517*dum))* - (-1.284345509005722 + 0.4342944819032517*dum))* - (0.04575749056067511 + 0.4342944819032517*dum))* - pow(5.,15.68445699931301 + (0.2510136065483903 + - (-0.2812473861506196 + (0.03884100532808183 + - (-0.005612423127059197 + - (0.0006504629731684842 + - (-0.00007081237970893412 + - (6.145415483685166e-6 + - (-6.258855246298706e-7 - - 2.175481457118431e-8* - (-10.5950665059705 + - 0.4342944819032517*dum))* - (-9.26496350640411 + - 0.4342944819032517*dum))* - (-7.934860506837712 + - 0.4342944819032517*dum))* - (-6.604757507271314 + - 0.4342944819032517*dum))* - (-5.274654507704916 + 0.4342944819032517*dum))* - (-3.944551508138518 + 0.4342944819032517*dum))* - (-2.61444850857212 + 0.4342944819032517*dum))* - (-1.284345509005722 + 0.4342944819032517*dum))* - (0.04575749056067511 + 0.4342944819032517*dum)); - - return result; -} - -double TDFolded(const double x) -{ - double result,dum; - - if ((x > 1.) || (x < 0.)) - Error("TDFolded: invalid x in FragFunction.", PROGRAM_ERROR); - - dum=log(1.e16*x); - result=pow(10.,16.40245282549585 + (2.006465566761043 + - (-1.2290432682737338 + (0.4053297476358819 + - (-0.10906672734507838 + - (0.02423162048512474 + - (-0.004566321632592419 + - (0.0007455136443033367 + - (-0.00010727374780647999 + - (0.000013791254716212407 + - (-1.6018349553861322e-6 + - (1.6963430526506736e-7 + - (-1.6505676370801003e-8 + - (1.4852680477947195e-9 + - (-1.2429947252576973e-10 + - (9.721275964488186e-12 + - (-7.135988486015182e-13 + - (4.933475574027309e-14 + - (-3.2288896623602718e-15 + - (1.9690047616867213e-16 - - 2.6034108179793842e-17* - (-15.113047072392108 + - 0.43429448190325176*dum))* - (-14.271851635344891 + - 0.43429448190325176*dum))* - (-13.430656198297674 + - 0.43429448190325176*dum))* - (-12.589460761250459 + - 0.43429448190325176*dum))* - (-11.748265324203246 + - 0.43429448190325176*dum))* - (-10.907069887156027 + - 0.43429448190325176*dum))* - (-10.065874450108813 + - 0.43429448190325176*dum))* - (-9.224679013061595 + - 0.43429448190325176*dum))* - (-8.383483576014381 + - 0.43429448190325176*dum))* - (-7.542288138967164 + - 0.43429448190325176*dum))* - (-6.701092701919949 + - 0.43429448190325176*dum))* - (-5.859897264872733 + - 0.43429448190325176*dum))* - (-5.018701827825517 + - 0.43429448190325176*dum))* - (-4.1775063907783005 + - 0.43429448190325176*dum))* - (-3.3363109537310853 + - 0.43429448190325176*dum))* - (-2.4951155166838697 + 0.43429448190325176*dum))* - (-1.6539200796366536 + 0.43429448190325176*dum))* - (-0.812724642589438 + 0.43429448190325176*dum))* - (0.028470794457777927 + 0.43429448190325176*dum))* - (0.8696662315049937 + 0.43429448190325176*dum)); - - return result; -} diff --git a/libs/dint/src/gauleg.cpp b/libs/dint/src/gauleg.cpp deleted file mode 100644 index df634964c..000000000 --- a/libs/dint/src/gauleg.cpp +++ /dev/null @@ -1,534 +0,0 @@ -//////////////////////////////////////////////////////////////////////// -// Gauss Legendre Integration -// -// Based on an implementation from John Burkardt -// http://people.sc.fsu.edu/~jburkardt/cpp_src/legendre_rule_fast/legendre_rule_fast.html -// -// Licensing: -// This code is distributed under the GNU LGPL license. - - -#include -#include - - -void legendre_compute_glr ( int n, double x[], double w[] ); -void legendre_compute_glr0 ( int n, double *p, double *pp ); -void legendre_compute_glr1 ( int n, double *roots, double *ders ); -void legendre_compute_glr2 ( double p, int n, double *roots, double *ders ); - -double ts_mult ( double *u, double h, int n ) - -//****************************************************************************80 -// -// Purpose: -// -// TS_MULT evaluates a polynomial. -// -// Licensing: -// -// This code is distributed under the GNU LGPL license. -// -// Modified: -// -// 17 May 2013 -// -// Author: -// -// Original C++ version by Nick Hale. -// This C++ version by John Burkardt. -// -// Parameters: -// -// Input, double U[N+1], the polynomial coefficients. -// U[0] is ignored. -// -// Input, double H, the polynomial argument. -// -// Input, int N, the number of terms to compute. -// -// Output, double TS_MULT, the value of the polynomial. -// -{ - double hk; - int k; - double ts; - - ts = 0.0; - hk = 1.0; - for ( k = 1; k<= n; k++ ) - { - ts = ts + u[k] * hk; - hk = hk * h; - } - return ts; -} - -double rk2_leg ( double t1, double t2, double x, int n ) - -//****************************************************************************80 -// -// Purpose: -// -// RK2_LEG advances the value of X(T) using a Runge-Kutta method. -// -// Licensing: -// -// This code is distributed under the GNU LGPL license. -// -// Modified: -// -// 22 October 2009 -// -// Author: -// -// Original C++ version by Nick Hale. -// This C++ version by John Burkardt. -// -// Parameters: -// -// Input, double T1, T2, the range of the integration interval. -// -// Input, double X, the value of X at T1. -// -// Input, int N, the number of steps to take. -// -// Output, double RK2_LEG, the value of X at T2. -// -{ - double f; - double h; - int j; - double k1; - double k2; - int m = 10; - double snn1; - double t; - - h = ( t2 - t1 ) / ( double ) m; - snn1 = sqrt ( ( double ) ( n * ( n + 1 ) ) ); - t = t1; - - for ( j = 0; j < m; j++ ) - { - f = ( 1.0 - x ) * ( 1.0 + x ); - k1 = - h * f / ( snn1 * sqrt ( f ) - 0.5 * x * sin ( 2.0 * t ) ); - x = x + k1; - - t = t + h; - - f = ( 1.0 - x ) * ( 1.0 + x ); - k2 = - h * f / ( snn1 * sqrt ( f ) - 0.5 * x * sin ( 2.0 * t ) ); - x = x + 0.5 * ( k2 - k1 ); - } - return x; -} -//****************************************************************************80 - - - -void legendre_compute_glr ( int n, double x[], double w[] ) - -//****************************************************************************80 -// -// Purpose: -// -// LEGENDRE_COMPUTE_GLR: Legendre quadrature by the Glaser-Liu-Rokhlin method. -// -// Licensing: -// -// This code is distributed under the GNU LGPL license. -// -// Modified: -// -// 20 October 2009 -// -// Author: -// -// Original C++ version by Nick Hale. -// This C++ version by John Burkardt. -// -// Reference: -// -// Andreas Glaser, Xiangtao Liu, Vladimir Rokhlin, -// A fast algorithm for the calculation of the roots of special functions, -// SIAM Journal on Scientific Computing, -// Volume 29, Number 4, pages 1420-1438, 2007. -// -// Parameters: -// -// Input, int N, the order. -// -// Output, double X[N], the abscissas. -// -// Output, double W[N], the weights. -// -{ - int i; - double p; - double pp; - double w_sum; -// -// Get the value and derivative of the N-th Legendre polynomial at 0. -// - legendre_compute_glr0 ( n, &p, &pp ); -// -// If N is odd, then zero is a root. -// - if ( n % 2 == 1 ) - { - x[(n-1)/2] = p; - w[(n-1)/2] = pp; - } -// -// If N is even, we have to call a function to find the first root. -// - else - { - legendre_compute_glr2 ( p, n, &x[n/2], &w[n/2] ); - } -// -// Get the complete set of roots and derivatives. -// - legendre_compute_glr1 ( n, x, w ); -// -// Compute the W. -// - for ( i = 0; i < n; i++ ) - { - w[i] = 2.0 / ( 1.0 - x[i] ) / ( 1.0 + x[i] ) / w[i] / w[i]; - } - w_sum = 0.0; - for ( i = 0; i < n; i++ ) - { - w_sum = w_sum + w[i]; - } - for ( i = 0; i < n; i++ ) - { - w[i] = 2.0 * w[i] / w_sum; - } - return; -} -//****************************************************************************80 - -void legendre_compute_glr0 ( int n, double *p, double *pp ) - -//****************************************************************************80 -// -// Purpose: -// -// LEGENDRE_COMPUTE_GLR0 gets a starting value for the fast algorithm. -// -// Licensing: -// -// This code is distributed under the GNU LGPL license. -// -// Modified: -// -// 19 October 2009 -// -// Author: -// -// Original C++ version by Nick Hale. -// This C++ version by John Burkardt. -// -// Reference: -// -// Andreas Glaser, Xiangtao Liu, Vladimir Rokhlin, -// A fast algorithm for the calculation of the roots of special functions, -// SIAM Journal on Scientific Computing, -// Volume 29, Number 4, pages 1420-1438, 2007. -// -// Parameters: -// -// Input, int N, the order of the Legendre polynomial. -// -// Output, double *P, *PP, the value of the N-th Legendre polynomial -// and its derivative at 0. -// -{ - double dk; - int k; - double pm1; - double pm2; - double ppm1; - double ppm2; - - pm2 = 0.0; - pm1 = 1.0; - ppm2 = 0.0; - ppm1 = 0.0; - - for ( k = 0; k < n; k++) - { - dk = ( double ) k; - *p = - dk * pm2 / ( dk + 1.0 ); - *pp = ( ( 2.0 * dk + 1.0 ) * pm1 - dk * ppm2 ) / ( dk + 1.0 ); - pm2 = pm1; - pm1 = *p; - ppm2 = ppm1; - ppm1 = *pp; - } - return; -} -//****************************************************************************80 - -void legendre_compute_glr1 ( int n, double *x, double *w ) - -//****************************************************************************80 -// -// Purpose: -// -// LEGENDRE_COMPUTE_GLR1 gets the complete set of Legendre points and weights. -// -// Discussion: -// -// This routine requires that a starting estimate be provided for one -// root and its derivative. This information will be stored in entry -// (N+1)/2 if N is odd, or N/2 if N is even, of X and W. -// -// Licensing: -// -// This code is distributed under the GNU LGPL license. -// -// Modified: -// -// 19 October 2009 -// -// Author: -// -// Original C++ version by Nick Hale. -// This C++ version by John Burkardt. -// -// Reference: -// -// Andreas Glaser, Xiangtao Liu, Vladimir Rokhlin, -// A fast algorithm for the calculation of the roots of special functions, -// SIAM Journal on Scientific Computing, -// Volume 29, Number 4, pages 1420-1438, 2007. -// -// Parameters: -// -// Input, int N, the order of the Legendre polynomial. -// -// Input/output, double X[N]. On input, a starting value -// has been set in one entry. On output, the roots of the Legendre -// polynomial. -// -// Input/output, double W[N]. On input, a starting value -// has been set in one entry. On output, the derivatives of the Legendre -// polynomial at the zeros. -// -// Local Parameters: -// -// Local, int M, the number of terms in the Taylor expansion. -// -{ - double dk; - double dn; - double h; - int j; - int k; - int l; - int m = 30; - int n2; - static double pi = 3.141592653589793; - int s; - double *u; - double *up; - double xp; - - if ( n % 2 == 1 ) - { - n2 = ( n - 1 ) / 2 - 1; - s = 1; - } - else - { - n2 = n / 2 - 1; - s = 0; - } - - u = new double[m+2]; - up = new double[m+1]; - - dn = ( double ) n; - - for ( j = n2 + 1; j < n - 1; j++ ) - { - xp = x[j]; - - h = rk2_leg ( pi/2.0, -pi/2.0, xp, n ) - xp; - - u[0] = 0.0; - u[1] = 0.0; - u[2] = w[j]; - - up[0] = 0.0; - up[1] = u[2]; - - for ( k = 0; k <= m - 2; k++ ) - { - dk = ( double ) k; - - u[k+3] = - ( - 2.0 * xp * ( dk + 1.0 ) * u[k+2] - + ( dk * ( dk + 1.0 ) - dn * ( dn + 1.0 ) ) * u[k+1] / ( dk + 1.0 ) - ) / ( 1.0 - xp ) / ( 1.0 + xp ) / ( dk + 2.0 ); - - up[k+2] = ( dk + 2.0 ) * u[k+3]; - } - - for ( l = 0; l < 5; l++ ) - { - h = h - ts_mult ( u, h, m ) / ts_mult ( up, h, m-1 ); - } - - x[j+1] = xp + h; - w[j+1] = ts_mult ( up, h, m - 1 ); - } - - for ( k = 0; k <= n2 + s; k++ ) - { - x[k] = - x[n-1-k]; - w[k] = w[n-1-k]; - } - - delete[] u; - delete[] up; - - return; -} -//****************************************************************************80 - -void legendre_compute_glr2 ( double pn0, int n, double *x1, double *d1 ) - -//****************************************************************************80 -// -// Purpose: -// -// LEGENDRE_COMPUTE_GLR2 finds the first real root. -// -// Discussion: -// -// This function is only called if N is even. -// -// Licensing: -// -// This code is distributed under the GNU LGPL license. -// -// Modified: -// -// 19 October 2009 -// -// Author: -// -// Original C++ version by Nick Hale. -// This C++ version by John Burkardt. -// -// Reference: -// -// Andreas Glaser, Xiangtao Liu, Vladimir Rokhlin, -// A fast algorithm for the calculation of the roots of special functions, -// SIAM Journal on Scientific Computing, -// Volume 29, Number 4, pages 1420-1438, 2007. -// -// Parameters: -// -// Input, double PN0, the value of the N-th Legendre polynomial -// at 0. -// -// Input, int N, the order of the Legendre polynomial. -// -// Output, double *X1, the first real root. -// -// Output, double *D1, the derivative at X1. -// -// Local Parameters: -// -// Local, int M, the number of terms in the Taylor expansion. -// -{ - double dk; - double dn; - int k; - int l; - int m = 30; - static double pi = 3.141592653589793; - double t; - double *u; - double *up; - - t = 0.0; - *x1 = rk2_leg ( t, -pi/2.0, 0.0, n ); - - u = new double[m+2]; - up = new double[m+1]; - - dn = ( double ) n; -// -// U[0] and UP[0] are never used. -// U[M+1] is set, but not used, and UP[M] is set and not used. -// What gives? -// - u[0] = 0.0; - u[1] = pn0; - - up[0] = 0.0; - - for ( k = 0; k <= m - 2; k = k + 2 ) - { - dk = ( double ) k; - - u[k+2] = 0.0; - u[k+3] = ( dk * ( dk + 1.0 ) - dn * ( dn + 1.0 ) ) * u[k+1] - / (dk + 1.0) / (dk + 2.0 ); - - up[k+1] = 0.0; - up[k+2] = ( dk + 2.0 ) * u[k+3]; - } - - for ( l = 0; l < 5; l++ ) - { - *x1 = *x1 - ts_mult ( u, *x1, m ) / ts_mult ( up, *x1, m-1 ); - } - *d1 = ts_mult ( up, *x1, m-1 ); - - delete[] u; - delete[] up; - - return; -} - - - - -void Gauleg(const double x1, const double x2, double x[], double w[], - const int n) -{ - - static std::map __legendreAbcissa; - static std::map __legendreWeights; - - if (__legendreAbcissa.find(n) == __legendreAbcissa.end()) - { - __legendreAbcissa[n] = new double[n]; - __legendreWeights[n] = new double[n]; - legendre_compute_glr ( n, __legendreAbcissa[n], __legendreWeights[n]); - } - - - - for ( int i = 0; i < n; i++ ) - { - x[i] = ( ( x1 + x2 ) + ( x2 - x1 ) * __legendreAbcissa[n][i] ) / 2.0; - } - for ( int i = 0; i < n; i++ ) - { - w[i] = ( x2 - x1 ) * __legendreWeights[n][i] / 2.0; - } - return; - -} - diff --git a/libs/dint/src/inject.cpp b/libs/dint/src/inject.cpp deleted file mode 100644 index 7e6a4236d..000000000 --- a/libs/dint/src/inject.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include -#include "dint/cvector.h" -#include "dint/spectrum.h" -#include "dint/const.h" -#include "dint/frag.h" -#include "dint/decay.h" -#include "dint/utilities.h" -#include "dint/inject.h" - -// E.Armengaud - Dec 2005 -// This routine is not used anymore : -// the injection spectrum must now be computed within CRPropa. - -void SetInjectionSpectrum(const PARTICLE part, const double InjEnergy, - const double HInjEnergy, const double deltaE_hadron, - const dCVector* pEnergy, - const dCVector* pEnergyWidth, Spectrum* pQ_0) { - int num_main_bins, maxBin, i; - double criticalEnergy; - - InitializeSpectrum(pQ_0); - num_main_bins = pEnergy->dimension; - - if ((pEnergyWidth->dimension != num_main_bins) || - (pQ_0->numberOfMainBins != num_main_bins)) - Error("PhotonMonoInjection: inconsistent dimensions", PROGRAM_ERROR); - - if (part != NOTHING) { - criticalEnergy = InjEnergy/ELECTRON_MASS; - maxBin = (int)((log10(criticalEnergy*ELECTRON_MASS) - - MAX_ENERGY_EXP)*BINS_PER_DECADE + num_main_bins); - (pQ_0->spectrum)[part][maxBin] = 1.; - - } else { - // In this case, we model the injection spectrum created by pair production - // with a power law of index -7/4 - if (deltaE_hadron == 0.e0) Error("DeltaE_Hadron = 0 !", PROGRAM_ERROR); - double sum=0.; - criticalEnergy = HInjEnergy/ELECTRON_MASS; - for (i = 0; i < num_main_bins; i++) { - if (pEnergy->vector[i] < criticalEnergy) { - (pQ_0->spectrum)[ELECTRON][i] = pow(pEnergy->vector[i],-7./4.)* - (pEnergyWidth->vector)[i]; - sum += (pQ_0->spectrum)[ELECTRON][i]*(pEnergy->vector)[i]; - } - } - sum *= ELECTRON_MASS; - sum = deltaE_hadron/sum/2.; - for (i = 0; i < num_main_bins; i++) { - (pQ_0->spectrum)[ELECTRON][i] *= sum; - (pQ_0->spectrum)[POSITRON][i] = (pQ_0->spectrum)[ELECTRON][i]; - } - - } -} diff --git a/libs/dint/src/io_util.cpp b/libs/dint/src/io_util.cpp deleted file mode 100644 index 7798cf3ae..000000000 --- a/libs/dint/src/io_util.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include "dint/error.h" - -FILE* SafeFOpen(const char* filename, const char* mode) -{ - FILE* file; - if ((file = fopen(filename, mode)) == NULL) - { - printf("SafeFOpen: cannot open %s\n", filename); - exit (IO_ERROR); - } - - return file; -} diff --git a/libs/dint/src/load.cpp b/libs/dint/src/load.cpp deleted file mode 100644 index 6dc1f569c..000000000 --- a/libs/dint/src/load.cpp +++ /dev/null @@ -1,330 +0,0 @@ - -#include "dint/load.h" - -// Modified Apr 2005 : aDirTable argument - -void LoadICSTables(RawTotalRate* ICSTotalRate, RawDiffRate* ICSPhotonRate, - RawDiffRate* ICSScatRate, const int num_main_bins, - string aDirTables) -{ - ReadRawTotalRate(ICSTotalRate, (aDirTables+"/ICSLoss.dat").c_str()); - ModifyRawTotalRate(ICSTotalRate, num_main_bins); - - ReadRawDiffRate(ICSPhotonRate, (aDirTables+"/ICSLP.dat").c_str()); - ModifyRawDiffRate(ICSPhotonRate, num_main_bins); - - ReadRawDiffRate(ICSScatRate, (aDirTables+"/ICSLS.dat").c_str()); - ModifyRawDiffRate(ICSScatRate, num_main_bins); -} - - -void LoadPPTables(RawTotalRate* PPTotalRate, RawDiffRate* PPDiffRate, - const int num_main_bins, string aDirTables) -{ - ReadRawTotalRate(PPTotalRate, (aDirTables+"/PPLoss.dat").c_str()); - ModifyRawTotalRate(PPTotalRate, num_main_bins); - - ReadRawDiffRate(PPDiffRate, (aDirTables+"/PPPL.dat").c_str()); - ModifyRawDiffRate(PPDiffRate, num_main_bins); -} - - -void LoadTPPTables(RawTotalRate* TPPTotalRate, RawDiffRate* TPPDiffRate, - const int num_main_bins, string aDirTables) -{ - ReadRawTotalRate(TPPTotalRate, (aDirTables+"/TPPLoss.dat").c_str()); - ModifyRawTotalRate(TPPTotalRate, num_main_bins); - - ReadRawDiffRate(TPPDiffRate, (aDirTables+"/TPPDiff.dat").c_str()); - ModifyRawDiffRate(TPPDiffRate, num_main_bins); -} - -void LoadDPPTables(RawTotalRate* DPPRate, const int num_main_bins, - string aDirTables) -{ - ReadRawTotalRate(DPPRate, (aDirTables+"/DPP.dat").c_str()); - ModifyRawTotalRate(DPPRate, num_main_bins); -} - -void LoadPPPNucleonTables(RawTotalRate* PPPProtonLossRate, - RawTotalRate* PPPNeutronLossRate, - RawDiffRate* PPPProtonScatRate, - RawDiffRate* PPPProtonNeutronRate, - RawDiffRate* PPPNeutronProtonRate, - const int num_main_bins, - string aDirTables) -{ - FILE* PPPLoss; - - PPPLoss = SafeFOpen((aDirTables+"/PPPLoss.dat").c_str(), "r"); - binfread(PPPProtonLossRate->totalRate[0], sizeof(double), - (PPPProtonLossRate->mainDimension)*(PPPProtonLossRate->bgDimension), - PPPLoss); - binfread(PPPNeutronLossRate->totalRate[0], sizeof(double), - (PPPNeutronLossRate->mainDimension)*(PPPNeutronLossRate->bgDimension), - PPPLoss); - fclose(PPPLoss); - ModifyRawTotalRate(PPPProtonLossRate, num_main_bins); - ModifyRawTotalRate(PPPNeutronLossRate, num_main_bins); - /* this is treated a little differently because the file contains both - tables */ - - - ReadRawDiffRate(PPPProtonScatRate, (aDirTables+"/PPPPrS.dat").c_str()); - ModifyRawDiffRate(PPPProtonScatRate, num_main_bins); - - ReadRawDiffRate(PPPProtonNeutronRate, (aDirTables+"/PPPPrN.dat").c_str()); - ModifyRawDiffRate(PPPProtonNeutronRate, num_main_bins); - - ReadRawDiffRate(PPPNeutronProtonRate, (aDirTables+"/PPPNPr.dat").c_str()); - ModifyRawDiffRate(PPPNeutronProtonRate, num_main_bins); -} - - -void LoadPPPEMTables(RawDiffRate* PPPProtonPhotonRate, - RawDiffRate* PPPProtonElectronRate, - RawDiffRate* PPPProtonPositronRate, - RawDiffRate* PPPNeutronElectronRate, - const int num_main_bins, - string aDirTables) -{ - FILE* PPPNE; - - ReadRawDiffRate(PPPProtonPhotonRate, (aDirTables+"/PPPPrPh.dat").c_str()); - ModifyRawDiffRate(PPPProtonPhotonRate, num_main_bins); - - ReadRawDiffRate(PPPProtonElectronRate, (aDirTables+"/PPPPrE.dat").c_str()); - ModifyRawDiffRate(PPPProtonElectronRate, num_main_bins); - - ReadRawDiffRate(PPPProtonPositronRate, (aDirTables+"/PPPPrPos.dat").c_str()); - - PPPNE = SafeFOpen((aDirTables+"/PPPNE.dat").c_str(), "r"); - if (PPPNeutronElectronRate->numberOfElements != - PPPProtonPositronRate->numberOfElements) - { - Error("LoadPPPTables: inconsistent dimensions", PROGRAM_ERROR); - } - binfread(PPPNeutronElectronRate->diffRate, sizeof(double), - PPPProtonPositronRate->numberOfElements, PPPNE); - fclose(PPPNE); - CopyRawDiffRate(PPPNeutronElectronRate, PPPProtonPositronRate); - ModifyRawDiffRate(PPPProtonPositronRate, num_main_bins); - ModifyRawDiffRate(PPPNeutronElectronRate, num_main_bins); -} - - -void LoadNPPNucleonTables(RawTotalRate* NPPTotalRate, const int num_main_bins, - string aDirTables) -{ - ReadRawTotalRate(NPPTotalRate, (aDirTables+"/NPPLoss.dat").c_str()); - ModifyRawTotalRate(NPPTotalRate, num_main_bins); -} - -void LoadNPPSecondaryTables(RawDiffRate* NPPDiffRate, const int num_main_bins, - string aDirTables) -{ - ReadRawDiffRate(NPPDiffRate, (aDirTables+"/NPPDiff.dat").c_str()); - ModifyRawDiffRate(NPPDiffRate, num_main_bins); -} - -void LoadPPPNeutrinoTables(RawDiffRate* PPPProtonElectronNeutrinoRate, - RawDiffRate* PPPProtonAntiElectronNeutrinoRate, - RawDiffRate* PPPProtonMuonNeutrinoRate, - RawDiffRate* PPPProtonAntiMuonNeutrinoRate, - RawDiffRate* PPPNeutronAntiElectronNeutrinoRate, - RawDiffRate* PPPNeutronMuonNeutrinoRate, - RawDiffRate* PPPNeutronAntiMuonNeutrinoRate, - const int num_main_bins, string aDirTables) -{ - FILE* PPPPrEN; - FILE* PPPNAEN; - FILE* PPPNMN; - FILE* PPPNAMN; - - - /* these 4 rates share the same bound */ - ReadRawDiffRate(PPPProtonAntiMuonNeutrinoRate, (aDirTables+"/PPPPrAMN.dat").c_str()); - - if (PPPProtonElectronNeutrinoRate->numberOfElements != - PPPProtonAntiMuonNeutrinoRate->numberOfElements) - { - Error("LoadPPPTables: inconsistent dimensions", PROGRAM_ERROR); - } - PPPPrEN = SafeFOpen((aDirTables+"/PPPPrEN.dat").c_str(), "r"); - binfread(PPPProtonElectronNeutrinoRate->diffRate, sizeof(double), - PPPProtonAntiMuonNeutrinoRate->numberOfElements, PPPPrEN); - fclose(PPPPrEN); - CopyRawDiffRateBound(PPPProtonElectronNeutrinoRate, - PPPProtonAntiMuonNeutrinoRate); - - if (PPPNeutronAntiElectronNeutrinoRate->numberOfElements != - PPPProtonAntiMuonNeutrinoRate->numberOfElements) - { - Error("LoadPPPTables: inconsistent dimensions", PROGRAM_ERROR); - } - PPPNAEN = SafeFOpen((aDirTables+"/PPPNAEN.dat").c_str(), "r"); - binfread(PPPNeutronAntiElectronNeutrinoRate->diffRate, sizeof(double), - PPPProtonAntiMuonNeutrinoRate->numberOfElements, PPPNAEN); - fclose(PPPNAEN); - CopyRawDiffRateBound(PPPNeutronAntiElectronNeutrinoRate, - PPPProtonAntiMuonNeutrinoRate); - - if (PPPNeutronMuonNeutrinoRate->numberOfElements != - PPPProtonAntiMuonNeutrinoRate->numberOfElements) - { - Error("LoadPPPTables: inconsistent dimensions", PROGRAM_ERROR); - } - PPPNMN = SafeFOpen((aDirTables+"/PPPNMN.dat").c_str(), "r"); - binfread(PPPNeutronMuonNeutrinoRate->diffRate, sizeof(double), - PPPProtonAntiMuonNeutrinoRate->numberOfElements, PPPNMN); - fclose(PPPNMN); - CopyRawDiffRateBound(PPPNeutronMuonNeutrinoRate, - PPPProtonAntiMuonNeutrinoRate); - - ModifyRawDiffRate(PPPProtonAntiMuonNeutrinoRate, num_main_bins); - ModifyRawDiffRate(PPPProtonElectronNeutrinoRate, num_main_bins); - ModifyRawDiffRate(PPPNeutronAntiElectronNeutrinoRate, num_main_bins); - ModifyRawDiffRate(PPPNeutronMuonNeutrinoRate, num_main_bins); - - - - ReadRawDiffRate(PPPProtonAntiElectronNeutrinoRate, - (aDirTables+"/PPPPrAEN.dat").c_str()); - ModifyRawDiffRate(PPPProtonAntiElectronNeutrinoRate, num_main_bins); - - /* these 2 share bound */ - ReadRawDiffRate(PPPProtonMuonNeutrinoRate, (aDirTables+"/PPPPrMN.dat").c_str()); - - if (PPPNeutronAntiMuonNeutrinoRate->numberOfElements != - PPPProtonMuonNeutrinoRate->numberOfElements) - { - Error("LoadPPPTables: inconsistent dimensions", PROGRAM_ERROR); - } - PPPNAMN = SafeFOpen((aDirTables+"/PPPNAMN.dat").c_str(), "r"); - binfread(PPPNeutronAntiMuonNeutrinoRate->diffRate, sizeof(double), - PPPProtonMuonNeutrinoRate->numberOfElements, PPPNAMN); - fclose(PPPNAMN); - CopyRawDiffRateBound(PPPNeutronAntiMuonNeutrinoRate, - PPPProtonMuonNeutrinoRate); - - ModifyRawDiffRate(PPPProtonMuonNeutrinoRate, num_main_bins); - ModifyRawDiffRate(PPPNeutronAntiMuonNeutrinoRate, num_main_bins); -} - -void LoadNeutronDecayNucleonTables(TotalRate* neutronDecayRate, - DiffRate* neutronDecayProtonRate, - const int num_main_bins, - string aDirTables) -{ - ReadTotalRate(neutronDecayRate, (aDirTables+"/neutronDecayLoss.dat").c_str()); - ModifyTotalRate(neutronDecayRate, num_main_bins); - - ReadDiffRate(neutronDecayProtonRate, (aDirTables+"/neutronDecayProton.dat").c_str()); - ModifyDiffRate(neutronDecayProtonRate, num_main_bins); -} - -void LoadNeutronDecaySecondaryTables(DiffRate* neutronDecayElectronRate, - const int num_main_bins, - string aDirTables) -{ - ReadDiffRate(neutronDecayElectronRate, (aDirTables+"/neutronDecayElectron.dat").c_str()); - ModifyDiffRate(neutronDecayElectronRate, num_main_bins); -} - -void LoadNeutrinoTables(const int tauNeutrinoMassSwitch, - TotalRate* NNElNeutTotalRate, - TotalRate* NNMuonNeutTotalRate, - TotalRate* NNTauNeutTotalRate, - DiffRate* NNElNeutScatRate, - DiffRate* NNElNeutMuonNeutRate, - DiffRate* NNElNeutTauNeutRate, - DiffRate* NNElNeutElectronRate, - DiffRate* NNElNeutPhotonRate, - DiffRate* NNElNeutProtonRate, - DiffRate* NNMuonNeutScatRate, - DiffRate* NNMuonNeutElNeutRate, - DiffRate* NNMuonNeutTauNeutRate, - DiffRate* NNMuonNeutElectronRate, - DiffRate* NNMuonNeutPhotonRate, - DiffRate* NNMuonNeutProtonRate, - DiffRate* NNTauNeutScatRate, - DiffRate* NNTauNeutElNeutRate, - DiffRate* NNTauNeutMuonNeutRate, - DiffRate* NNTauNeutElectronRate, - DiffRate* NNTauNeutPhotonRate, - DiffRate* NNTauNeutProtonRate, - const int num_main_bins, - string aDirTables) -{ - if (tauNeutrinoMassSwitch == 0) - { - ReadTotalRate(NNElNeutTotalRate, (aDirTables+"/ENT_0.dat").c_str()); - ReadTotalRate(NNMuonNeutTotalRate, (aDirTables+"/MNT_0.dat").c_str()); - ReadTotalRate(NNTauNeutTotalRate, (aDirTables+"/TNT_0.dat").c_str()); - - ReadDiffRate(NNElNeutScatRate, (aDirTables+"/ENS_0.dat").c_str()); - ReadDiffRate(NNElNeutMuonNeutRate, (aDirTables+"/ENMN_0.dat").c_str()); - ReadDiffRate(NNElNeutTauNeutRate, (aDirTables+"/ENTN_0.dat").c_str()); - ReadDiffRate(NNElNeutElectronRate, (aDirTables+"/ENE_0.dat").c_str()); - ReadDiffRate(NNElNeutPhotonRate, (aDirTables+"/ENPh_0.dat").c_str()); - ReadDiffRate(NNElNeutProtonRate, (aDirTables+"/ENPr_0.dat").c_str()); - ReadDiffRate(NNMuonNeutElNeutRate, (aDirTables+"/MNEN_0.dat").c_str()); - ReadDiffRate(NNMuonNeutScatRate, (aDirTables+"/MNS_0.dat").c_str()); - ReadDiffRate(NNMuonNeutTauNeutRate, (aDirTables+"/MNTN_0.dat").c_str()); - ReadDiffRate(NNMuonNeutElectronRate, (aDirTables+"/MNE_0.dat").c_str()); - ReadDiffRate(NNMuonNeutPhotonRate, (aDirTables+"/MNPh_0.dat").c_str()); - ReadDiffRate(NNMuonNeutProtonRate, (aDirTables+"/MNPr_0.dat").c_str()); - ReadDiffRate(NNTauNeutElNeutRate, (aDirTables+"/TNEN_0.dat").c_str()); - ReadDiffRate(NNTauNeutMuonNeutRate, (aDirTables+"/TNMN_0.dat").c_str()); - ReadDiffRate(NNTauNeutScatRate, (aDirTables+"/TNS_0.dat").c_str()); - ReadDiffRate(NNTauNeutElectronRate, (aDirTables+"/TNE_0.dat").c_str()); - ReadDiffRate(NNTauNeutPhotonRate, (aDirTables+"/TNPh_0.dat").c_str()); - ReadDiffRate(NNTauNeutProtonRate, (aDirTables+"/TNPr_0.dat").c_str()); - } - else - { - ReadTotalRate(NNElNeutTotalRate, (aDirTables+"/ENT_10.dat").c_str()); - ReadTotalRate(NNMuonNeutTotalRate, (aDirTables+"/MNT_10.dat").c_str()); - ReadTotalRate(NNTauNeutTotalRate, (aDirTables+"/TNT_10.dat").c_str()); - ReadDiffRate(NNElNeutScatRate, (aDirTables+"/ENS_10.dat").c_str()); - ReadDiffRate(NNElNeutMuonNeutRate, (aDirTables+"/ENMN_10.dat").c_str()); - ReadDiffRate(NNElNeutTauNeutRate, (aDirTables+"/ENTN_10.dat").c_str()); - ReadDiffRate(NNElNeutElectronRate, (aDirTables+"/ENE_10.dat").c_str()); - ReadDiffRate(NNElNeutPhotonRate, (aDirTables+"/ENPh_10.dat").c_str()); - ReadDiffRate(NNElNeutProtonRate, (aDirTables+"/ENPr_10.dat").c_str()); - ReadDiffRate(NNMuonNeutElNeutRate, (aDirTables+"/MNEN_10.dat").c_str()); - ReadDiffRate(NNMuonNeutScatRate, (aDirTables+"/MNS_10.dat").c_str()); - ReadDiffRate(NNMuonNeutTauNeutRate, (aDirTables+"/MNTN_10.dat").c_str()); - ReadDiffRate(NNMuonNeutElectronRate, (aDirTables+"/MNE_10.dat").c_str()); - ReadDiffRate(NNMuonNeutPhotonRate, (aDirTables+"/MNPh_10.dat").c_str()); - ReadDiffRate(NNMuonNeutProtonRate, (aDirTables+"/MNPr_10.dat").c_str()); - ReadDiffRate(NNTauNeutElNeutRate, (aDirTables+"/TNEN_10.dat").c_str()); - ReadDiffRate(NNTauNeutMuonNeutRate, (aDirTables+"/TNMN_10.dat").c_str()); - ReadDiffRate(NNTauNeutScatRate, (aDirTables+"/TNS_10.dat").c_str()); - ReadDiffRate(NNTauNeutElectronRate, (aDirTables+"/TNE_10.dat").c_str()); - ReadDiffRate(NNTauNeutPhotonRate, (aDirTables+"/TNPh_10.dat").c_str()); - ReadDiffRate(NNTauNeutProtonRate, (aDirTables+"/TNPr_10.dat").c_str()); - } - - ModifyTotalRate(NNElNeutTotalRate, num_main_bins); - ModifyTotalRate(NNMuonNeutTotalRate, num_main_bins); - ModifyTotalRate(NNTauNeutTotalRate, num_main_bins); - ModifyDiffRate(NNElNeutScatRate, num_main_bins); - ModifyDiffRate(NNElNeutMuonNeutRate, num_main_bins); - ModifyDiffRate(NNElNeutTauNeutRate, num_main_bins); - ModifyDiffRate(NNElNeutElectronRate, num_main_bins); - ModifyDiffRate(NNElNeutPhotonRate, num_main_bins); - ModifyDiffRate(NNElNeutProtonRate, num_main_bins); - ModifyDiffRate(NNMuonNeutElNeutRate, num_main_bins); - ModifyDiffRate(NNMuonNeutScatRate, num_main_bins); - ModifyDiffRate(NNMuonNeutTauNeutRate, num_main_bins); - ModifyDiffRate(NNMuonNeutElectronRate, num_main_bins); - ModifyDiffRate(NNMuonNeutPhotonRate, num_main_bins); - ModifyDiffRate(NNMuonNeutProtonRate, num_main_bins); - ModifyDiffRate(NNTauNeutElNeutRate, num_main_bins); - ModifyDiffRate(NNTauNeutMuonNeutRate, num_main_bins); - ModifyDiffRate(NNTauNeutScatRate, num_main_bins); - ModifyDiffRate(NNTauNeutElectronRate, num_main_bins); - ModifyDiffRate(NNTauNeutPhotonRate, num_main_bins); - ModifyDiffRate(NNTauNeutProtonRate, num_main_bins); -} diff --git a/libs/dint/src/math_util.cpp b/libs/dint/src/math_util.cpp deleted file mode 100644 index 545cf262e..000000000 --- a/libs/dint/src/math_util.cpp +++ /dev/null @@ -1,34 +0,0 @@ -double DMax(const double double1, const double double2) -{ - if (double1 >= double2) - return double1; - else - return double2; -} - - -double DMin(const double double1, const double double2) -{ - if (double1 <= double2) - return double1; - else - return double2; -} - - -int IMax(const int integer1, const int integer2) -{ - if (integer1 >= integer2) - return integer1; - else - return integer2; -} - - -int IMin(const int integer1, const int integer2) -{ - if (integer1 <= integer2) - return integer1; - else - return integer2; -} diff --git a/libs/dint/src/prepare.cpp b/libs/dint/src/prepare.cpp deleted file mode 100644 index 50936eef9..000000000 --- a/libs/dint/src/prepare.cpp +++ /dev/null @@ -1,409 +0,0 @@ - -#include -#include -#include -#include -#include "dint/const.h" -#include "dint/cvector.h" -#include "dint/utilities.h" -#include "dint/spectrum.h" -#include "dint/frag.h" -#include "dint/decay.h" - - -void SetEnergyBins(const int min_energy_exp, dCVector* pEnergy, - dCVector* pEnergyWidth) -{ - int i; - double exponent; - double temp; - int num_bins; - double averaging_factor; - double binning_factor; - - num_bins = pEnergy->dimension; - averaging_factor = (pow(10., 1./2./BINS_PER_DECADE) + - pow(10., -1./2./BINS_PER_DECADE))/2.; - binning_factor = pow(10., 1./2./BINS_PER_DECADE) - - pow(10., -1./2./BINS_PER_DECADE); - - if (num_bins != pEnergyWidth->dimension) - { - Error("SetEnergyBins: inconsistent dimensions", PROGRAM_ERROR); - } - - for (i = 0; i < num_bins; i++) - { - exponent = (double)min_energy_exp + (double)i/BINS_PER_DECADE; - temp = pow(10., exponent)/ELECTRON_MASS; - (pEnergy->vector)[i] = temp*averaging_factor; - (pEnergyWidth->vector)[i] = temp*binning_factor; - } -} - -void SetDeltaG(const dCVector* pEnergy, dCVector* pDeltaG) -{ - int i; - int num_main_bins; - - num_main_bins = pEnergy->dimension; - - if (pDeltaG->dimension != num_main_bins) - { - Error("SetDeltaG: inconsistent dimensions", PROGRAM_ERROR); - } - - for (i = 0; i < num_main_bins - 1; i++) - { - (pDeltaG->vector)[i] = (pEnergy->vector)[i+1] - (pEnergy->vector)[i]; - } - (pDeltaG->vector)[num_main_bins-1] = (pEnergy->vector)[num_main_bins-1]* - pow(10., 1./BINS_PER_DECADE); -} - -/* NOTE: this function is not used any more... */ -void GetModeOfInput(FILE* input, int* pInputMethodSwitch) -{ - /* give a choice between manually entering the data and reading it - from a data file */ - printf(" -----------------< Enter Model Parameters >"); - printf("-----------------\n\n"); - printf("1. Read from a file (1)/Manually enter parameters (0): "); - scanf("%i", pInputMethodSwitch); - - if (*pInputMethodSwitch == 1) - /* From data file */ - { - char fileName[20]; - - /* get the name of the file */ - printf("2. Name of parameter file: "); - scanf("%s", fileName); - input = SafeFOpen(fileName, "r"); - } -} - -void BasicParameterInput(FILE* input, const int argc, int* pMinEnergyExp, - int* pNumSmallSteps, - double* pConvergeParameter, - double* pStartingRedshift, - double* pStartingDistanceInMpc) -{ - if (argc == 3) - /* From data file */ - { - printf("\n[Parameters read from the file]\n"); - /* read in parameters */ - fscanf(input, "%i", pMinEnergyExp); - printf("1. Minimum energy: 10^%i eV\n", *pMinEnergyExp); - fscanf(input, "%i", pNumSmallSteps); - printf("2. Number of small steps: %i\n", *pNumSmallSteps); - fscanf(input, "%lf", pConvergeParameter); - printf("3. Delta (convergence parameter): %12.3E\n", - *pConvergeParameter); - fscanf(input, "%lf", pStartingRedshift); - if (*pStartingRedshift != 0.) - { - printf("4. Maximal redshift: %10.3f\n", *pStartingRedshift); - } - fscanf(input, "%lf", pStartingDistanceInMpc); - if (*pStartingDistanceInMpc >= 2.*C/3./H_0*1.e-5) - { - Error("BasicParameterInput: distance larger than horizon", - PROGRAM_ERROR); - } - if (*pStartingDistanceInMpc != 0.) - { - printf("4. Maximal distance (Mpc): %10.3f\n", - *pStartingDistanceInMpc); - } - } - else if (argc == 2) - /* Enter manually */ - { - printf("1. Minimum energy exponent (e.g. 10^8 eV: 8): "); - scanf("%i", pMinEnergyExp); - printf("2. Number of small steps (suggestion: 6): "); - scanf("%i", pNumSmallSteps); - printf("3. Delta (convergence parameter) (suggestion: 1.e-6): "); - scanf("%lf", pConvergeParameter); - printf("4. Maximal redshift "); - printf("(enter 0 if you will type in distance): "); - scanf("%lf", pStartingRedshift); - printf("5. Maximal distance in Mpc "); - printf("(enter 0 if you typed in redshift): "); - scanf("%lf", pStartingDistanceInMpc); - if (*pStartingDistanceInMpc >= 2.*C/3./H_0*1.e-5) - { - Error("BasicParameterInput: distance larger than horizon", - PROGRAM_ERROR); - } - } - - if (*pStartingDistanceInMpc == 0.) - { - *pStartingDistanceInMpc = 2.*C/3./H_0/1.e5*(1. - - pow(1. + *pStartingRedshift, -3./2.)); - printf("\n"); - printf("Maximal distance (Mpc): %12.6f\n", *pStartingDistanceInMpc); - } - if (*pStartingRedshift == 0.) - { - *pStartingRedshift = - pow(1. - 3.*H_0*1.e5*(*pStartingDistanceInMpc)/2./C, -2./3.) - 1.; - printf("\n"); - printf("Maximal redshift: %12.6f\n", *pStartingRedshift); - } -} - -void InteractionParameterInput(FILE* input, const int argc, - int* pSynchrotronSwitch, double* pB_0, - int* pTauNeutrinoMassSwitch, int* pICSSwitch, - int* pPPSwitch, int* pTPPSwitch, - int* pDPPSwitch, int* pPPPSwitch, - int* pNPPSwitch, int* pNeutronDecaySwitch, - int* pNucleonToSecondarySwitch, - int* pNeutrinoNeutrinoSwitch) -{ - if (argc == 3) - /* From data file */ - { - fscanf(input, "%i", pSynchrotronSwitch); - fscanf(input, "%lf", pB_0); - if (*pSynchrotronSwitch == 1) - { - printf("5. Synchrotron loss on -> B_0: %12.3E\n", *pB_0); - } - else - { - *pB_0 = 0; - printf("5. Synchrotron loss off\n"); - } - fscanf(input, "%i", pTauNeutrinoMassSwitch); - if (*pTauNeutrinoMassSwitch == 0) - printf("6. m_tau = m_e = m_nu = 1 eV\n"); - else - printf("6. m_tau = m_nu = 1 eV, m_e = 0.1 eV\n"); - - /* read in interaction switches */ - printf("\n7. "); - fscanf(input, "%i", pICSSwitch); - if (*pICSSwitch != 0) - printf("ICS on... "); - fscanf(input, "%i", pPPSwitch); - if (*pPPSwitch != 0) - printf("PP on... "); - fscanf(input, "%i", pTPPSwitch); - if (*pTPPSwitch != 0) - printf("TPP on... "); - fscanf(input, "%i", pDPPSwitch); - if (*pDPPSwitch != 0) - printf("DPP on... "); - fscanf(input, "%i", pPPPSwitch); - if (*pPPPSwitch != 0) - printf("Photopion production on... "); - fscanf(input, "%i", pNPPSwitch); - if (*pNPPSwitch != 0) - printf("Proton pair production on... "); - fscanf(input, "%i", pNeutronDecaySwitch); - if (*pNeutronDecaySwitch != 0) - printf("Neutron decay on... "); - fscanf(input, "%i", pNucleonToSecondarySwitch); - if (*pNucleonToSecondarySwitch != 0) - printf("Nucleon secondary tables included... "); - fscanf(input, "%i", pNeutrinoNeutrinoSwitch); - if (*pNeutrinoNeutrinoSwitch != 0) - printf("Neutrino-neutrino interaction on... "); - printf("\n"); - } - else if (argc == 2) - /* Enter manually */ - { - printf("6. Synchrotron on/off? (on = 1, off = 0) "); - scanf("%i", pSynchrotronSwitch); - if (*pSynchrotronSwitch == 1) - { - printf(" 6-1. Magnetic field (G): "); - scanf("%lf", pB_0); - } - else - { - *pB_0 = 0; - } - - printf("7. Neutrino mass (0: equally massive (1 eV), 1: tau = nu = 1, e = 0.1 eV): "); - scanf("%i", pTauNeutrinoMassSwitch); - - // printf("\n\nNow turning to individual interactions...\n"); - printf("\n"); - printf("8-1. Inverse Compton scattering (ICS) on? (on = 1, off = 0) "); - scanf("%i", pICSSwitch); - printf("8-2. Pair production (PP) on? "); - scanf("%i", pPPSwitch); - printf("8-3. Triplet pair production (TPP) on? "); - scanf("%i", pTPPSwitch); - printf("8-4. Double pair production (DPP) on? "); - scanf("%i", pDPPSwitch); - printf("8-5. Photopion production on? "); - scanf("%i", pPPPSwitch); - printf("8-6. Proton pair production on? "); - scanf("%i", pNPPSwitch); - printf("8-7. Neutron decay on? "); - scanf("%i", pNeutronDecaySwitch); - printf("8-8. Nucleon secondary tables included? "); - scanf("%i", pNucleonToSecondarySwitch); - printf("8-9. Neutrino-neutrino interaction on? "); - scanf("%i", pNeutrinoNeutrinoSwitch); - } - - /* quick check whether secondary table switch is consistent */ - if (*pNucleonToSecondarySwitch == 1) - { - if ((*pPPPSwitch == 0) && (*pNPPSwitch == 0) && - (*pNeutronDecaySwitch == 0)) - { - printf("WARNING: secondary table on when all interactions off?\n"); - } - } -} - -void ModelParameterInput(FILE* input, const int argc, - int* pSourceTypeSwitch, double* pMinDistance, - double* pBrightPhaseExp, int* pModelTypeSwitch) -{ - if (argc == 3) - /* From data file */ - { - fscanf(input, "%i", pSourceTypeSwitch); - fscanf(input, "%lf", pMinDistance); - fscanf(input, "%lf", pBrightPhaseExp); - if (*pSourceTypeSwitch == 1) - { - printf("8. Source type: diffuse\n"); - printf("8-1. Minimal distance: %12.6f\n", *pMinDistance); - printf("8-2. Bright phase exponent: %12.6f\n", *pBrightPhaseExp); - } - else - printf("8. Source type: single\n"); - - fscanf(input, "%i", pModelTypeSwitch); - if (*pModelTypeSwitch == 0) - printf("9. Injection model: photon monoenergetic injection\n"); - else if (*pModelTypeSwitch == 1) - printf("9. Injection model: electron monoenergetic injection\n"); - else if (*pModelTypeSwitch == 2) - printf("9. Injection model: positron monoenergetic injection\n"); - } - else if (argc == 2) - /* Enter manually */ - { - printf("9. Single source or diffuse sources? "); - printf("(single = 0, diffuse = 1) "); - scanf("%i", pSourceTypeSwitch); - *pMinDistance = 0.; - *pBrightPhaseExp = 1.5; - if (*pSourceTypeSwitch == 1) - { - printf("9-1. Minimal distance: "); - scanf("%lf", pMinDistance); - printf("9-2. Bright phase exponent: "); - scanf("%lf", pBrightPhaseExp); - } - printf("10. Injection model\n"); - printf("(photon = 0, electron = 1,\n"); - printf(" positron = 2; monoenergetic injection ? "); - scanf("%i", pModelTypeSwitch); - } - - printf("\n\nParameter input complete.\n"); -} - -void PrepareSpectra(const int sourceTypeSwitch, const Spectrum* pQ_0, - Spectrum* pSpectrum, Spectrum* pSpectrumNew, - Spectrum* pDerivative) -{ - if (pSpectrumNew->numberOfMainBins != pDerivative->numberOfMainBins) - { - Error("PrepareSpectra: inconsistent dimensions", PROGRAM_ERROR); - } - - // InitializeSpectrum(spectrumOld); - if (sourceTypeSwitch == 0) /* single source */ - SetSpectrum(pSpectrum, pQ_0); - else /* diffuse sources */ - InitializeSpectrum(pSpectrum); - - SetSpectrum(pSpectrumNew, pSpectrum); - InitializeSpectrum(pDerivative); -} - - -void ComputeTotalInitialContent(const dCVector* pEnergy, const Spectrum* pQ_0, - double* initialPhotonEnergy, - double* initialLeptonEnergy, - double* initialNucleonEnergy, - double* initialNeutrinoEnergy, - double* initialTotalEnergy, - double* initialPhotonNumber, - double* initialLeptonNumber, - double* initialNucleonNumber, - double* initialNeutrinoNumber, - double* initialTotalNumber) -{ - int i; - - *initialPhotonEnergy = 0; - *initialLeptonEnergy = 0.; - *initialNucleonEnergy = 0.; - *initialNeutrinoEnergy = 0.; - *initialTotalEnergy = 0.; - *initialPhotonNumber = 0; - *initialLeptonNumber = 0.; - *initialNucleonNumber = 0.; - *initialNeutrinoNumber = 0.; - *initialTotalNumber = 0.; - - for (i = 0; i < pEnergy->dimension; i++) - { - *initialPhotonEnergy += (pQ_0->spectrum)[PHOTON][i]* - (pEnergy->vector)[i]; - *initialPhotonNumber += (pQ_0->spectrum)[PHOTON][i]; - *initialLeptonEnergy += ((pQ_0->spectrum)[ELECTRON][i] + - (pQ_0->spectrum)[POSITRON][i])*(pEnergy->vector)[i]; - *initialLeptonNumber += (pQ_0->spectrum)[ELECTRON][i] + - (pQ_0->spectrum)[POSITRON][i]; - } - *initialNucleonEnergy += GetNucleonEnergy(pQ_0, pEnergy); - *initialNucleonNumber += GetNucleonNumber(pQ_0); - *initialNeutrinoEnergy += GetNeutrinoEnergy(pQ_0, pEnergy); - *initialNeutrinoNumber += GetNeutrinoNumber(pQ_0); - *initialTotalEnergy = *initialPhotonEnergy + *initialLeptonEnergy + - *initialNucleonEnergy + *initialNeutrinoEnergy; - *initialTotalNumber = *initialPhotonNumber + *initialLeptonNumber + - *initialNucleonNumber + *initialNeutrinoNumber; -} - - -void ComputeContinuousEnergyLoss(const int synchrotronSwitch, - const dCVector* synchrotronLoss, - const dCVector* otherLoss, - dCVector* continuousLoss) -{ - int i; - - if ((synchrotronLoss->dimension != otherLoss->dimension) || - (otherLoss->dimension != continuousLoss->dimension)) - { - Error("ComputeContinuousEnergyLoss: inconsistent dimensions", - PROGRAM_ERROR); - } - - for (i = 0; i < continuousLoss->dimension; i++) - { - (continuousLoss->vector)[i] = (otherLoss->vector)[i]; - if (synchrotronSwitch == 1) /* synchrotron on */ - { - (continuousLoss->vector)[i] += (synchrotronLoss->vector)[i]; - } - } -} diff --git a/libs/dint/src/prop_second.cpp b/libs/dint/src/prop_second.cpp deleted file mode 100644 index 5f71f6909..000000000 --- a/libs/dint/src/prop_second.cpp +++ /dev/null @@ -1,1081 +0,0 @@ - -#include "dint/prop_second.h" - -#ifdef DEBUG -void DumpEnergy(const Spectrum* pSpectrum, const dCVector* pEnergy) { - printf("Initial energy: %15.6E\n", GetEnergy(pSpectrum, pEnergy)); - printf("Nucleon fraction: %15.6E\n", - GetNucleonEnergy(pSpectrum, pEnergy)/GetEnergy(pSpectrum, pEnergy)); - printf("electromagnetic fraction: %15.6E\n", - GetEMEnergy(pSpectrum, pEnergy)/GetEnergy(pSpectrum, pEnergy)); -} -#endif - -//-------------------------------------------------------------------------- -// Prop_second : see the file prop_second.h for explanations -//-------------------------------------------------------------------------- - -// Switches to read 1) the folded interaction rates : total pair production and -// total energy losses by photons; 2) the photon background density -//#define EXTRACT_PAIR_PROD_RATE -//#define EXTRACT_PHOTON_TOTAL_RATE -//#define PRINT_PHOTON_BACKGROUND -//#define EXTRACT_LEPTON_RATE - -// Parameters of the redshift table (used for distance-redshift conversion) -#define NBINS_REDSHIFTTABLE 1000 -#define ZMIN_REDSHIFTTABLE 0.0001 -#define ZMAX_REDSHIFTTABLE 100 - -void prop_second(const double dist_observer, - //const double InjEnergy, - //const PARTICLE part, - //const double HInjEnergy, const double deltaE_hadron, - const dCVector* pB_field, - const dCVector* pEnergy, - const dCVector* pEnergyWidth, - Spectrum* apInjectionSpectrum, - Spectrum* pSpectrum, - string aDirTables, - const int aIRFlag, const double aZmax_IR, const int aRadioFlag, - const double aH0 = H_0, const double aOmegaM = OMEGA_M, - const double aOmegaLambda = OMEGA_LAMBDA, - const double aCutcascade_Magfield = 0) { -clock_t start = clock(); - //-------- Declaration of main variables -------- - //---- Interaction table coefficients ---- - RawTotalRate ICSTotalRate; - RawTotalRate PPTotalRate; - RawTotalRate TPPTotalRate; - RawTotalRate DPPRate; - - RawTotalRate PPPProtonLossRate; - RawTotalRate PPPNeutronLossRate; - RawTotalRate NPPTotalRate; - // total (interaction) rates before being folded into the background - - RawDiffRate ICSPhotonRate; - RawDiffRate ICSScatRate; - RawDiffRate PPDiffRate; - RawDiffRate TPPDiffRate; - - RawDiffRate PPPProtonScatRate; - RawDiffRate PPPProtonNeutronRate; - RawDiffRate PPPNeutronProtonRate; - RawDiffRate PPPProtonPhotonRate; - RawDiffRate PPPProtonElectronRate; - RawDiffRate PPPProtonPositronRate; - RawDiffRate PPPNeutronElectronRate; - RawDiffRate NPPDiffRate; - RawDiffRate PPPProtonElectronNeutrinoRate; - RawDiffRate PPPProtonAntiElectronNeutrinoRate; - RawDiffRate PPPProtonMuonNeutrinoRate; - RawDiffRate PPPProtonAntiMuonNeutrinoRate; - RawDiffRate PPPNeutronAntiElectronNeutrinoRate; - RawDiffRate PPPNeutronMuonNeutrinoRate; - RawDiffRate PPPNeutronAntiMuonNeutrinoRate; - // differential rates before being folded into the background - - TotalRate neutronDecayRate; - DiffRate neutronDecayElectronRate; - DiffRate neutronDecayProtonRate; - - TotalRate NNElNeutTotalRate; - TotalRate NNMuonNeutTotalRate; - TotalRate NNTauNeutTotalRate; - // These total rates are net rates; i.e. scattered flux into same bin is subtracted - DiffRate NNElNeutScatRate; - DiffRate NNElNeutMuonNeutRate; - DiffRate NNElNeutTauNeutRate; - DiffRate NNElNeutElectronRate; - DiffRate NNElNeutPhotonRate; - DiffRate NNElNeutProtonRate; - DiffRate NNMuonNeutScatRate; - DiffRate NNMuonNeutElNeutRate; - DiffRate NNMuonNeutTauNeutRate; - DiffRate NNMuonNeutElectronRate; - DiffRate NNMuonNeutPhotonRate; - DiffRate NNMuonNeutProtonRate; - DiffRate NNTauNeutScatRate; - DiffRate NNTauNeutElNeutRate; - DiffRate NNTauNeutMuonNeutRate; - DiffRate NNTauNeutElectronRate; - DiffRate NNTauNeutPhotonRate; - DiffRate NNTauNeutProtonRate; - // rates from neutrino-neutrino interaction - - - //---- Main parameter variables ---- - int B_bin, B_bins; // bin numbers for B-field array - - dCVector deltaG; // dg used in continuous energy loss calculation - - dCVector bgEnergy; - dCVector bgEnergyWidth; - dCVector bgPhotonDensity; - - double distance; // main distance variable (cm) - - int numSmallSteps; // number of small steps in one redshift step - double convergeParameter; // redshift increment - - int synchrotronSwitch; - double B_loc; // local strength of extragalactic magnetic field (gauss) - DiffRate syncRate; - - int sourceTypeSwitch; // source type: single (0) or diffuse (1) - double brightPhaseExp; // bright phase exponent - double startingRedshift; // zsource in FORTRAN - double minDistance; // minimal distance to sources - double bkgFactor; // local background enhancement factor - double totalEnergyInput; // einj0 in FORTRAN - - Spectrum Q_0; // standard injection function - Spectrum spectrumNew; - Spectrum derivative; - - double initialPhotonEnergy; // totpe in FORTRAN - double initialLeptonEnergy; // totee - double initialNucleonEnergy; - double initialNeutrinoEnergy; - double initialTotalEnergy; // tote - double initialPhotonNumber; // totpn - double initialLeptonNumber; // toten - double initialNucleonNumber; - double initialNeutrinoNumber; - double initialTotalNumber; // totn - - int iterationCounter; // niter in FORTRAN - int firstIndex; // ifirst - double leftRedshift; // zi - double deltaRedshift; //zdelt - int lastIndex; // ilast - double propagatingDistance; - // totalx: total propagating distance (pc) - double rightRedshift; // zf - double centralRedshift; // zt - double redshiftRatio; // erat - // double tempCoefficient; // coeff - double distanceStep; // tzdist*tdz (cm) - double rightDistance; // d1 (Mpc) - double leftDistance; // d2 (Mpc) - double evolutionFactor,evolutionFactor1; // zfact - double smallDistanceStep; // dx (pc) - double x; // x (pc) - - // Energy below which the 1D approximation is not a priori correct : - bool lEcFlag ; - int lIndex ; - double lEnergy, t_sync, t_larmor, t_ics = 0 ; - double a_ics = (3.-log10(4.))/4. ; - double b_ics = pow(10.,8.-7.*a_ics) ; - // (used if the flag aCutcascade_Magfield is set) - - // FILE* input; - int tauNeutrinoMassSwitch; - - // interaction switches - int ICSSwitch; - int PPSwitch; - int TPPSwitch; - int DPPSwitch; - - int PPPSwitch; - int NPPSwitch; - int neutronDecaySwitch; - int nucleonToSecondarySwitch; - - int neutrinoNeutrinoSwitch; - - //---- interaction rates folded with photon background ---- - TotalRate leptonTotalRate; - TotalRate photonTotalRate; - TotalRate protonTotalRate; - TotalRate neutronTotalRate; - - DiffRate leptonScatRate; - DiffRate leptonExchRate; - DiffRate leptonPhotonRate; - DiffRate photonLeptonRate; - - DiffRate protonScatRate; - DiffRate protonNeutronRate; - DiffRate neutronProtonRate; - DiffRate protonPhotonRate; - DiffRate protonElectronRate; - DiffRate protonPositronRate; - DiffRate neutronElectronRate; - DiffRate neutronPositronRate; - DiffRate protonElectronNeutrinoRate; - DiffRate protonAntiElectronNeutrinoRate; - DiffRate protonMuonNeutrinoRate; - DiffRate protonAntiMuonNeutrinoRate; - DiffRate neutronAntiElectronNeutrinoRate; - DiffRate neutronMuonNeutrinoRate; - DiffRate neutronAntiMuonNeutrinoRate; - - TotalRate elNeutTotalRate; - TotalRate muonNeutTotalRate; - TotalRate tauNeutTotalRate; - - DiffRate elNeutScatRate; - DiffRate elNeutMuonNeutRate; - DiffRate elNeutTauNeutRate; - DiffRate elNeutElectronRate; - DiffRate elNeutPhotonRate; - DiffRate elNeutProtonRate; - DiffRate muonNeutScatRate; - DiffRate muonNeutElNeutRate; - DiffRate muonNeutTauNeutRate; - DiffRate muonNeutElectronRate; - DiffRate muonNeutPhotonRate; - DiffRate muonNeutProtonRate; - DiffRate tauNeutScatRate; - DiffRate tauNeutElNeutRate; - DiffRate tauNeutMuonNeutRate; - DiffRate tauNeutElectronRate; - DiffRate tauNeutPhotonRate; - DiffRate tauNeutProtonRate; - // rates from neutrino-neutrino interaction - - dCVector synchrotronLoss; // sgdot - dCVector otherLoss; // tgdot - dCVector continuousLoss; // gdot - dCVector protonContinuousLoss; // pgdot - - int loopCounter; - //-------- End of variable declaration -------- - - // numSmallSteps = 100; - convergeParameter = 1.e-8; - - // -------- Redshift Estimation --------------- - // startingRedshift = pow(1. - 3.*H_0*1.e5*dist_observer/2./C, -2./3.) - 1.; - // This was the old analytic redshift computation. - dCVector RedshiftArray ; - dCVector DistanceArray ; - BuildRedshiftTable(aH0, aOmegaM, aOmegaLambda, &RedshiftArray, &DistanceArray) ; - startingRedshift = getRedshift(RedshiftArray, DistanceArray, dist_observer) ; - // printf("distance/Mpc: %15.6E\n", dist_observer); - // printf("particle type: %d\n", part); - // printf("injection energy/eV: %15.6E\n", InjEnergy); - - B_bins = pB_field->dimension; - - synchrotronSwitch = 1; - tauNeutrinoMassSwitch = 1; - ICSSwitch = 1; - PPSwitch = 1; - TPPSwitch = 1; - DPPSwitch = 1; - // PPPSwitch = 1; - PPPSwitch = 0; - NPPSwitch = 0; - // synchrotronSwitch = 0; - // tauNeutrinoMassSwitch = 0; - // ICSSwitch = 0; - // PPSwitch = 0; - // TPPSwitch = 0; - // DPPSwitch = 0; - // PPPSwitch = 1; - PPPSwitch = 0; - NPPSwitch = 0; - // printf("DINT modified!!\n"); -#ifdef EXTRACT_PAIR_PROD_RATE - NPPSwitch = 1; // (allows to compute new pair prod rate) -#endif - - // neutronDecaySwitch = 1; - neutronDecaySwitch = 0; - nucleonToSecondarySwitch = 0; - neutrinoNeutrinoSwitch = 1; - sourceTypeSwitch = 0; - minDistance = 0.; - brightPhaseExp = 0.; - - //-------- Set up energy bins -------- - New_dCVector(&deltaG, NUM_MAIN_BINS); - New_dCVector(&bgEnergy, NUM_BG_BINS); - New_dCVector(&bgEnergyWidth, NUM_BG_BINS); - New_dCVector(&bgPhotonDensity, NUM_BG_BINS); - - // set energy bins - SetDeltaG(pEnergy, &deltaG); - - SetEnergyBins(BG_MIN_ENERGY_EXP, &bgEnergy, &bgEnergyWidth); - - NewSpectrum(&Q_0, NUM_MAIN_BINS); - NewSpectrum(&spectrumNew, NUM_MAIN_BINS); - NewSpectrum(&derivative, NUM_MAIN_BINS); - - New_dCVector(&synchrotronLoss, NUM_MAIN_BINS); - New_dCVector(&otherLoss, NUM_MAIN_BINS); - New_dCVector(&continuousLoss, NUM_MAIN_BINS); - New_dCVector(&protonContinuousLoss, NUM_MAIN_BINS); - - - //---- Select injection model ---- - // SetInjectionSpectrum(part, InjEnergy, HInjEnergy, deltaE_hadron, - // pEnergy, pEnergyWidth, &Q_0); - // SetInjectionSpectrum(part, pEnergy, pEnergyWidth, &Q_0, InjEnergy); - - SetSpectrum(&Q_0, apInjectionSpectrum) ; - // No call anymore to SetInjectionSpectrum, which is not useful anymore. - totalEnergyInput = GetEnergy(&Q_0, pEnergy); -#ifdef DEBUG - DumpEnergy(&Q_0, pEnergy); -#endif - - //-------- Create arrays -------- - // NOTE: I first make them table size; they will be "clipped" after reading in tables - if (ICSSwitch == 1) { - NewRawTotalRate(&ICSTotalRate, EM_NUM_MAIN_BINS, NUM_BG_BINS); - NewRawDiffRate(&ICSPhotonRate, EM_NUM_MAIN_BINS, NUM_BG_BINS, - NUM_IP_ELEMENTS); - NewRawDiffRate(&ICSScatRate, EM_NUM_MAIN_BINS, NUM_BG_BINS, - NUM_IS_ELEMENTS); - } - - if (PPSwitch == 1) { - NewRawTotalRate(&PPTotalRate, EM_NUM_MAIN_BINS, NUM_BG_BINS); - NewRawDiffRate(&PPDiffRate, EM_NUM_MAIN_BINS, NUM_BG_BINS, - NUM_PP_ELEMENTS); - } - - if (TPPSwitch == 1) { - NewRawTotalRate(&TPPTotalRate, EM_NUM_MAIN_BINS, NUM_BG_BINS); - NewRawDiffRate(&TPPDiffRate, EM_NUM_MAIN_BINS, NUM_BG_BINS, - NUM_TPP_ELEMENTS); - } - - if (DPPSwitch == 1) - NewRawTotalRate(&DPPRate, EM_NUM_MAIN_BINS, NUM_BG_BINS); - - if (PPPSwitch == 1) { - NewRawTotalRate(&PPPProtonLossRate, NUC_NUM_MAIN_BINS, NUM_BG_BINS); - NewRawTotalRate(&PPPNeutronLossRate, NUC_NUM_MAIN_BINS, NUM_BG_BINS); - - NewRawDiffRate(&PPPProtonScatRate, NUC_NUM_MAIN_BINS, NUM_BG_BINS, - NUM_PPP_PROTON_SCAT_ELEMENTS); - NewRawDiffRate(&PPPProtonNeutronRate, NUC_NUM_MAIN_BINS, NUM_BG_BINS, - NUM_PPP_PROTON_NEUTRON_ELEMENTS); - NewRawDiffRate(&PPPNeutronProtonRate, NUC_NUM_MAIN_BINS, NUM_BG_BINS, - NUM_PPP_PROTON_NEUTRON_ELEMENTS); - - if (nucleonToSecondarySwitch == 1) { - NewRawDiffRate(&PPPProtonPhotonRate, NUC_NUM_MAIN_BINS, - NUM_BG_BINS, NUM_PPP_PROTON_PHOTON_ELEMENTS); - NewRawDiffRate(&PPPProtonElectronRate, NUC_NUM_MAIN_BINS, - NUM_BG_BINS, NUM_PPP_PROTON_ELECTRON_ELEMENTS); - NewRawDiffRate(&PPPProtonPositronRate, NUC_NUM_MAIN_BINS, - NUM_BG_BINS, NUM_PPP_PROTON_POSITRON_ELEMENTS); - NewRawDiffRate(&PPPNeutronElectronRate, NUC_NUM_MAIN_BINS, - NUM_BG_BINS, NUM_PPP_PROTON_POSITRON_ELEMENTS); - NewRawDiffRate(&PPPProtonElectronNeutrinoRate, NUC_NUM_MAIN_BINS, - NUM_BG_BINS, NUM_PPP_PROTON_ANTI_MUON_NEUTRINO_ELEMENTS); - NewRawDiffRate(&PPPProtonAntiElectronNeutrinoRate, - NUC_NUM_MAIN_BINS, NUM_BG_BINS, - NUM_PPP_PROTON_ANTI_ELECTRON_NEUTRINO_ELEMENTS); - NewRawDiffRate(&PPPProtonMuonNeutrinoRate, NUC_NUM_MAIN_BINS, - NUM_BG_BINS, NUM_PPP_PROTON_MUON_NEUTRINO_ELEMENTS); - NewRawDiffRate(&PPPProtonAntiMuonNeutrinoRate, NUC_NUM_MAIN_BINS, - NUM_BG_BINS, NUM_PPP_PROTON_ANTI_MUON_NEUTRINO_ELEMENTS); - NewRawDiffRate(&PPPNeutronAntiElectronNeutrinoRate, - NUC_NUM_MAIN_BINS, NUM_BG_BINS, - NUM_PPP_PROTON_ANTI_MUON_NEUTRINO_ELEMENTS); - NewRawDiffRate(&PPPNeutronMuonNeutrinoRate, NUC_NUM_MAIN_BINS, - NUM_BG_BINS, NUM_PPP_PROTON_ANTI_MUON_NEUTRINO_ELEMENTS); - NewRawDiffRate(&PPPNeutronAntiMuonNeutrinoRate, NUC_NUM_MAIN_BINS, - NUM_BG_BINS, NUM_PPP_PROTON_MUON_NEUTRINO_ELEMENTS); - } - } - - if (NPPSwitch == 1) { - NewRawTotalRate(&NPPTotalRate, NUC_NUM_MAIN_BINS, NUM_BG_BINS); - - if (nucleonToSecondarySwitch == 1) - NewRawDiffRate(&NPPDiffRate, NUC_NUM_MAIN_BINS, NUM_BG_BINS, - NUM_NPP_ELEMENTS); - } - - // neutron decay does not fit the general category because it is not - // really an interaction (with background) - if (neutronDecaySwitch == 1) { - NewTotalRate(&neutronDecayRate, NUC_NUM_MAIN_BINS); - NewDiffRate(&neutronDecayProtonRate, NUC_NUM_MAIN_BINS); - - if (nucleonToSecondarySwitch == 1) - NewDiffRate(&neutronDecayElectronRate, NUC_NUM_MAIN_BINS); - } - - // neutrino-neutrino rates are already folded w/ neutrino background - if (neutrinoNeutrinoSwitch == 1) { - NewTotalRate(&NNElNeutTotalRate, NEUT_NUM_MAIN_BINS); - NewTotalRate(&NNMuonNeutTotalRate, NEUT_NUM_MAIN_BINS); - NewTotalRate(&NNTauNeutTotalRate, NEUT_NUM_MAIN_BINS); - - NewDiffRate(&NNElNeutScatRate, NEUT_NUM_MAIN_BINS); - NewDiffRate(&NNElNeutMuonNeutRate, NEUT_NUM_MAIN_BINS); - NewDiffRate(&NNElNeutTauNeutRate, NEUT_NUM_MAIN_BINS); - NewDiffRate(&NNElNeutElectronRate, NEUT_NUM_MAIN_BINS); - NewDiffRate(&NNElNeutPhotonRate, NEUT_NUM_MAIN_BINS); - NewDiffRate(&NNElNeutProtonRate, NEUT_NUM_MAIN_BINS); - NewDiffRate(&NNMuonNeutScatRate, NEUT_NUM_MAIN_BINS); - NewDiffRate(&NNMuonNeutElNeutRate, NEUT_NUM_MAIN_BINS); - NewDiffRate(&NNMuonNeutTauNeutRate, NEUT_NUM_MAIN_BINS); - NewDiffRate(&NNMuonNeutElectronRate, NEUT_NUM_MAIN_BINS); - NewDiffRate(&NNMuonNeutPhotonRate, NEUT_NUM_MAIN_BINS); - NewDiffRate(&NNMuonNeutProtonRate, NEUT_NUM_MAIN_BINS); - NewDiffRate(&NNTauNeutScatRate, NEUT_NUM_MAIN_BINS); - NewDiffRate(&NNTauNeutElNeutRate, NEUT_NUM_MAIN_BINS); - NewDiffRate(&NNTauNeutMuonNeutRate, NEUT_NUM_MAIN_BINS); - NewDiffRate(&NNTauNeutElectronRate, NEUT_NUM_MAIN_BINS); - NewDiffRate(&NNTauNeutPhotonRate, NEUT_NUM_MAIN_BINS); - NewDiffRate(&NNTauNeutProtonRate, NEUT_NUM_MAIN_BINS); - } - - //---- read in coefficient tables; clipping is done here if necessary ---- - if (ICSSwitch == 1) - LoadICSTables(&ICSTotalRate, &ICSPhotonRate, &ICSScatRate, - NUM_MAIN_BINS, aDirTables); - if (PPSwitch == 1) - LoadPPTables(&PPTotalRate, &PPDiffRate, NUM_MAIN_BINS, aDirTables); - if (TPPSwitch == 1) - LoadTPPTables(&TPPTotalRate, &TPPDiffRate, NUM_MAIN_BINS, aDirTables); - if (DPPSwitch == 1) - LoadDPPTables(&DPPRate, NUM_MAIN_BINS, aDirTables); - if (PPPSwitch == 1) { - LoadPPPNucleonTables(&PPPProtonLossRate, &PPPNeutronLossRate, - &PPPProtonScatRate, &PPPProtonNeutronRate, &PPPNeutronProtonRate, - NUM_MAIN_BINS, aDirTables); - - if (nucleonToSecondarySwitch == 1) { - LoadPPPEMTables(&PPPProtonPhotonRate, &PPPProtonElectronRate, - &PPPProtonPositronRate, &PPPNeutronElectronRate, - NUM_MAIN_BINS, aDirTables); - LoadPPPNeutrinoTables(&PPPProtonElectronNeutrinoRate, - &PPPProtonAntiElectronNeutrinoRate, &PPPProtonMuonNeutrinoRate, - &PPPProtonAntiMuonNeutrinoRate, - &PPPNeutronAntiElectronNeutrinoRate, - &PPPNeutronMuonNeutrinoRate, &PPPNeutronAntiMuonNeutrinoRate, - NUM_MAIN_BINS, aDirTables); - } - } - if (NPPSwitch == 1) { - LoadNPPNucleonTables(&NPPTotalRate, NUM_MAIN_BINS, aDirTables); - - if (nucleonToSecondarySwitch == 1) - LoadNPPSecondaryTables(&NPPDiffRate, NUM_MAIN_BINS, aDirTables); - } - - if (neutronDecaySwitch == 1) { - LoadNeutronDecayNucleonTables(&neutronDecayRate, - &neutronDecayProtonRate, NUM_MAIN_BINS, aDirTables); - - if (nucleonToSecondarySwitch == 1) - LoadNeutronDecaySecondaryTables(&neutronDecayElectronRate, - NUM_MAIN_BINS, aDirTables); - } - - if (neutrinoNeutrinoSwitch == 1) - LoadNeutrinoTables(tauNeutrinoMassSwitch, &NNElNeutTotalRate, - &NNMuonNeutTotalRate, &NNTauNeutTotalRate, &NNElNeutScatRate, - &NNElNeutMuonNeutRate, &NNElNeutTauNeutRate, - &NNElNeutElectronRate, &NNElNeutPhotonRate, &NNElNeutProtonRate, - &NNMuonNeutScatRate, &NNMuonNeutElNeutRate, - &NNMuonNeutTauNeutRate, &NNMuonNeutElectronRate, - &NNMuonNeutPhotonRate, &NNMuonNeutProtonRate, &NNTauNeutScatRate, - &NNTauNeutElNeutRate, &NNTauNeutMuonNeutRate, - &NNTauNeutElectronRate, &NNTauNeutPhotonRate, - &NNTauNeutProtonRate, NUM_MAIN_BINS, aDirTables); - -#ifdef DEBUG - printf("Starting computations...\n\n"); -#endif - -clock_t start_comp = clock(); - - //---- Initialize distance ---- - distance = 0.; // distance variable: dist in FORTRAN - - PrepareSpectra(sourceTypeSwitch, &Q_0, pSpectrum, &spectrumNew, - &derivative); - // NOTE: suspect derivative is never used??? - - // if (sourceTypeSwitch == 0) // single source - // DumpSpectrum(pEnergy, pEnergyWidth, &Q_0, "InitialSpectrumDump.dat"); - - ComputeTotalInitialContent(pEnergy, &Q_0, &initialPhotonEnergy, - &initialLeptonEnergy, &initialNucleonEnergy, - &initialNeutrinoEnergy, &initialTotalEnergy, - &initialPhotonNumber, &initialLeptonNumber, - &initialNucleonNumber, &initialNeutrinoNumber, - &initialTotalNumber); - - //--------- START of actual computation -------- - //---- initialize indices and parameters ---- - iterationCounter = 1; - firstIndex = 0; - leftRedshift = startingRedshift; - deltaRedshift = 1. - (pEnergy->vector)[2]/(pEnergy->vector)[3]; - lastIndex = 0; - propagatingDistance = 0.; - - - NewTotalRate(&leptonTotalRate, NUM_MAIN_BINS); - NewTotalRate(&photonTotalRate, NUM_MAIN_BINS); - - NewTotalRate(&protonTotalRate, NUM_MAIN_BINS); - NewTotalRate(&neutronTotalRate, NUM_MAIN_BINS); - - - NewDiffRate(&leptonScatRate, NUM_MAIN_BINS); - NewDiffRate(&leptonExchRate, NUM_MAIN_BINS); - NewDiffRate(&leptonPhotonRate, NUM_MAIN_BINS); - NewDiffRate(&photonLeptonRate, NUM_MAIN_BINS); - - NewDiffRate(&protonScatRate, NUM_MAIN_BINS); - NewDiffRate(&protonNeutronRate, NUM_MAIN_BINS); - NewDiffRate(&neutronProtonRate, NUM_MAIN_BINS); - NewDiffRate(&protonPhotonRate, NUM_MAIN_BINS); - NewDiffRate(&protonElectronRate, NUM_MAIN_BINS); - NewDiffRate(&protonPositronRate, NUM_MAIN_BINS); - NewDiffRate(&neutronElectronRate, NUM_MAIN_BINS); - NewDiffRate(&neutronPositronRate, NUM_MAIN_BINS); - NewDiffRate(&protonElectronNeutrinoRate, NUM_MAIN_BINS); - NewDiffRate(&protonAntiElectronNeutrinoRate, NUM_MAIN_BINS); - NewDiffRate(&protonMuonNeutrinoRate, NUM_MAIN_BINS); - NewDiffRate(&protonAntiMuonNeutrinoRate, NUM_MAIN_BINS); - NewDiffRate(&neutronAntiElectronNeutrinoRate, NUM_MAIN_BINS); - NewDiffRate(&neutronMuonNeutrinoRate, NUM_MAIN_BINS); - NewDiffRate(&neutronAntiMuonNeutrinoRate, NUM_MAIN_BINS); - - - NewTotalRate(&elNeutTotalRate, NUM_MAIN_BINS); - NewTotalRate(&muonNeutTotalRate, NUM_MAIN_BINS); - NewTotalRate(&tauNeutTotalRate, NUM_MAIN_BINS); - - NewDiffRate(&elNeutScatRate, NUM_MAIN_BINS); - NewDiffRate(&elNeutMuonNeutRate, NUM_MAIN_BINS); - NewDiffRate(&elNeutTauNeutRate, NUM_MAIN_BINS); - NewDiffRate(&elNeutElectronRate, NUM_MAIN_BINS); - NewDiffRate(&elNeutPhotonRate, NUM_MAIN_BINS); - NewDiffRate(&elNeutProtonRate, NUM_MAIN_BINS); - NewDiffRate(&muonNeutElNeutRate, NUM_MAIN_BINS); - NewDiffRate(&muonNeutScatRate, NUM_MAIN_BINS); - NewDiffRate(&muonNeutTauNeutRate, NUM_MAIN_BINS); - NewDiffRate(&muonNeutElectronRate, NUM_MAIN_BINS); - NewDiffRate(&muonNeutPhotonRate, NUM_MAIN_BINS); - NewDiffRate(&muonNeutProtonRate, NUM_MAIN_BINS); - NewDiffRate(&tauNeutElNeutRate, NUM_MAIN_BINS); - NewDiffRate(&tauNeutMuonNeutRate, NUM_MAIN_BINS); - NewDiffRate(&tauNeutScatRate, NUM_MAIN_BINS); - NewDiffRate(&tauNeutElectronRate, NUM_MAIN_BINS); - NewDiffRate(&tauNeutPhotonRate, NUM_MAIN_BINS); - NewDiffRate(&tauNeutProtonRate, NUM_MAIN_BINS); - /* I created all folded rates because I didn't want to pass all the - switches to the subsequent functions, and these allocations are - not so expensive anyway */ - - //-------- This is where propagation takes place -------- - do { - - // this firstIndex & lastIndex pair is used to bin redshift finer - // near the end of propagation (z close to 0) - ComputeRedshifts(sourceTypeSwitch, leftRedshift, &deltaRedshift, - &rightRedshift, ¢ralRedshift, &lastIndex); - - //---- compute various distance parameters ---- - redshiftRatio = (1. + rightRedshift)/(1. + leftRedshift); - // tempCoefficient = pow(OMEGA_M*pow(1. + centralRedshift,3.)+ - // OMEGA_LAMBDA, -1./2.)/(1.+centralRedshift); - // tempCoefficient = pow(1. + centralRedshift, -5./2.); - // distanceStep = (leftRedshift - rightRedshift)*tempCoefficient*C/ - // (H_0*1.e5/1.e6/DISTANCE_UNIT); - - // (cosmological parameters added July 2005) - leftDistance = getDistance(RedshiftArray,DistanceArray,leftRedshift) ; - rightDistance = getDistance(RedshiftArray,DistanceArray,rightRedshift) ; - distanceStep = leftDistance - rightDistance ; - distance += distanceStep; - // rightDistance = distance - distanceStep/2.; - // leftDistance = distance + distanceStep/2.; - // rightDistance = 2./3.*C/1.e5/H_0*(1. - pow(1. + rightRedshift, -1.5)); - // leftDistance = 2./3.*C/1.e5/H_0*(1. - pow(1. + leftRedshift, -1.5)); - - evolutionFactor1 = pow((1. + centralRedshift)/(1. + startingRedshift), - brightPhaseExp+3.); // redshift evolution - numSmallSteps = (int)(ceil(distanceStep/DISTANCE_UNIT/DMAX)); - smallDistanceStep = distanceStep/DISTANCE_UNIT/numSmallSteps; - x = 0.; - // printf("small stepsize: %15.6E\n", smallDistanceStep); - - //---- compute the photon background at given redshift ---- - LoadPhotonBackground(centralRedshift, &bgEnergy, &bgEnergyWidth, - &bgPhotonDensity, aIRFlag, aZmax_IR, aRadioFlag, - aH0, aOmegaM, aOmegaLambda); - - // if (rightRedshift < 1.e-5) - // DumpBgSpectrum(&bgEnergy, &bgEnergyWidth, &bgPhotonDensity,"~/"); - - //---- initialize rates ---- - InitializeLeptonCoefficients(&leptonTotalRate, &leptonScatRate, - &leptonExchRate, &leptonPhotonRate); - InitializePhotonCoefficients(&photonTotalRate, &photonLeptonRate); - InitializeNucleonCoefficients(&protonTotalRate, &neutronTotalRate, - &protonScatRate, &protonNeutronRate, - &neutronProtonRate, &protonPhotonRate, - &protonElectronRate, &protonPositronRate, - &neutronElectronRate, &neutronPositronRate, - &protonElectronNeutrinoRate, - &protonAntiElectronNeutrinoRate, - &protonMuonNeutrinoRate, &protonAntiMuonNeutrinoRate, - &neutronAntiElectronNeutrinoRate, &neutronMuonNeutrinoRate, - &neutronAntiMuonNeutrinoRate); - InitializeNeutrinoCoefficients(&elNeutTotalRate, &muonNeutTotalRate, - &tauNeutTotalRate, &elNeutScatRate, &elNeutMuonNeutRate, - &elNeutTauNeutRate, &elNeutElectronRate, - &elNeutPhotonRate, &elNeutProtonRate, - &muonNeutElNeutRate, &muonNeutScatRate, - &muonNeutTauNeutRate, &muonNeutElectronRate, - &muonNeutPhotonRate, &muonNeutProtonRate, - &tauNeutElNeutRate, &tauNeutMuonNeutRate, - &tauNeutScatRate, &tauNeutElectronRate, - &tauNeutPhotonRate, &tauNeutProtonRate); - - Initialize_dCVector(&continuousLoss); - - Initialize_dCVector(&otherLoss); - Initialize_dCVector(&protonContinuousLoss); - - //---- fold interaction rates w/ photon background ---- - if (ICSSwitch == 1) - FoldICS(&bgPhotonDensity, &ICSTotalRate, &ICSPhotonRate, - &ICSScatRate, &leptonTotalRate, &leptonPhotonRate, - &leptonScatRate); - if (TPPSwitch == 1) - FoldTPP(&bgPhotonDensity, pEnergy, &TPPTotalRate, &TPPDiffRate, - &leptonTotalRate, &leptonScatRate, &leptonExchRate, - &otherLoss); - if (PPSwitch == 1) - FoldPP(&bgPhotonDensity, &PPTotalRate, &PPDiffRate, - &photonTotalRate, &photonLeptonRate); - if (DPPSwitch == 1) - FoldDPP(&bgPhotonDensity, &DPPRate, &photonTotalRate, - &photonLeptonRate); - if (PPPSwitch == 1) { - FoldPPPNucleon(&bgPhotonDensity, &PPPProtonLossRate, - &PPPNeutronLossRate, &PPPProtonScatRate, &PPPProtonNeutronRate, - &PPPNeutronProtonRate, &protonTotalRate, &neutronTotalRate, - &protonScatRate, &protonNeutronRate, &neutronProtonRate); - - if (nucleonToSecondarySwitch == 1) - FoldPPPSecondary(&bgPhotonDensity, &PPPProtonPhotonRate, - &PPPProtonElectronRate, &PPPProtonPositronRate, - &PPPNeutronElectronRate, &PPPProtonElectronNeutrinoRate, - &PPPProtonAntiElectronNeutrinoRate, - &PPPProtonMuonNeutrinoRate, &PPPProtonAntiMuonNeutrinoRate, - &PPPNeutronAntiElectronNeutrinoRate, - &PPPNeutronMuonNeutrinoRate, - &PPPNeutronAntiMuonNeutrinoRate, &protonPhotonRate, - &protonElectronRate, &protonPositronRate, - &neutronElectronRate, &neutronPositronRate, - &protonElectronNeutrinoRate, - &protonAntiElectronNeutrinoRate, - &protonMuonNeutrinoRate, &protonAntiMuonNeutrinoRate, - &neutronAntiElectronNeutrinoRate, &neutronMuonNeutrinoRate, - &neutronAntiMuonNeutrinoRate); - } - - -#ifdef EXTRACT_PHOTON_TOTAL_RATE - // Add - E.A. Dec. 2005 - // Extract photon total energy loss rate - for (int i=0; idimension; i++) cout << (pEnergy->vector)[i] << " " - << (photonTotalRate.totalRate)[i] - << endl; - exit(0) ; -#endif -#ifdef EXTRACT_LEPTON_RATE - for (int i=0; idimension; i++) cout << (pEnergy->vector)[i] << " " - << (leptonTotalRate.totalRate)[i] - << endl; - exit(0) ; -#endif - - if (NPPSwitch == 1) { - - FoldNPPNucleon(&bgPhotonDensity, pEnergy, &NPPTotalRate, - &protonContinuousLoss); - -#ifdef EXTRACT_PAIR_PROD_RATE - // Slight add - E.A. July 2005 . - // To extract the pair production tables of protons on photon backgrounds. - // (need to switch NPPSwitch!) - for (int i=0; idimension; i++) cout << (pEnergy->vector)[i] << " " - << (protonContinuousLoss.vector)[i] - << endl; - exit(0) ; -#endif - - if (nucleonToSecondarySwitch == 1) - FoldNPPSecondary(&bgPhotonDensity, &NPPDiffRate, - &protonPositronRate, &protonElectronRate); - } - - if (neutrinoNeutrinoSwitch == 1) - MapNeutRates(centralRedshift, lastIndex, tauNeutrinoMassSwitch, - &NNElNeutTotalRate, &NNMuonNeutTotalRate, &NNTauNeutTotalRate, - &NNElNeutScatRate, &NNElNeutMuonNeutRate, - &NNElNeutTauNeutRate, &NNElNeutElectronRate, - &NNElNeutPhotonRate, &NNElNeutProtonRate, - &NNMuonNeutElNeutRate, &NNMuonNeutScatRate, - &NNMuonNeutTauNeutRate, &NNMuonNeutElectronRate, - &NNMuonNeutPhotonRate, &NNMuonNeutProtonRate, - &NNTauNeutElNeutRate, &NNTauNeutMuonNeutRate, - &NNTauNeutScatRate, &NNTauNeutElectronRate, - &NNTauNeutPhotonRate, &NNTauNeutProtonRate, &elNeutTotalRate, - &muonNeutTotalRate, &tauNeutTotalRate, &elNeutScatRate, - &elNeutMuonNeutRate, &elNeutTauNeutRate, &elNeutElectronRate, - &elNeutPhotonRate, &elNeutProtonRate, &muonNeutElNeutRate, - &muonNeutScatRate, &muonNeutTauNeutRate, &muonNeutElectronRate, - &muonNeutPhotonRate, &muonNeutProtonRate, &tauNeutElNeutRate, - &tauNeutMuonNeutRate, &tauNeutScatRate, &tauNeutElectronRate, - &tauNeutPhotonRate, &tauNeutProtonRate); - - //---- main iteration (convergence) block ---- - - for (loopCounter = 0; loopCounter < numSmallSteps; loopCounter++) { - - if (synchrotronSwitch == 1) { // synchrotron == true (on) - - NewDiffRate(&syncRate, NUM_MAIN_BINS); - - B_bin = (int)((double)(B_bins)*(propagatingDistance+x)/1.e6/ - dist_observer); - B_loc=(pB_field->vector)[B_bin]; - InitializeSynchrotron(B_loc, pEnergy, pEnergyWidth, - &synchrotronLoss, &syncRate, - aDirTables); - } - //---- compute continuous energy loss for electrons ---- - ComputeContinuousEnergyLoss(synchrotronSwitch, &synchrotronLoss, - &otherLoss, &continuousLoss); - - evolutionFactor = evolutionFactor1; - if ((leftDistance - x/1.e6) < minDistance) - evolutionFactor = 0.; - if ((leftDistance - x/1.e6) < SOURCE_CLUSTER_DISTANCE) - evolutionFactor = SOURCE_CLUSTER_FACTOR*evolutionFactor1; - if ((leftDistance - x/1.e6) < CLUSTER_DISTANCE) - bkgFactor = CLUSTER_FACTOR; - else - bkgFactor = 1.; - - AdvanceNucNeutStep(sourceTypeSwitch, PPPSwitch, NPPSwitch, - neutronDecaySwitch, nucleonToSecondarySwitch, - neutrinoNeutrinoSwitch, smallDistanceStep, - evolutionFactor, convergeParameter, bkgFactor, &Q_0, - &elNeutProtonRate, - &muonNeutProtonRate, &tauNeutProtonRate, &protonTotalRate, - &neutronTotalRate, &neutronDecayRate, &protonScatRate, - &protonNeutronRate, &neutronProtonRate, - &neutronDecayProtonRate, &protonMuonNeutrinoRate, - &neutronAntiMuonNeutrinoRate, &protonAntiMuonNeutrinoRate, - &neutronMuonNeutrinoRate, &protonElectronNeutrinoRate, - &neutronAntiElectronNeutrinoRate, - &protonAntiElectronNeutrinoRate, &neutronDecayElectronRate, - &elNeutTotalRate, &muonNeutTotalRate, &tauNeutTotalRate, - &elNeutScatRate, &elNeutMuonNeutRate, &elNeutTauNeutRate, - &muonNeutElNeutRate, &muonNeutScatRate, &muonNeutTauNeutRate, - &tauNeutElNeutRate, &tauNeutMuonNeutRate, &tauNeutScatRate, - &protonContinuousLoss, &deltaG, pSpectrum, &spectrumNew); - - SetNucleonSpectrum(pSpectrum, &spectrumNew); - SetNeutrinoSpectrum(pSpectrum, &spectrumNew); - - AdvanceEMStep(sourceTypeSwitch, PPSwitch, ICSSwitch, - TPPSwitch, DPPSwitch, synchrotronSwitch, PPPSwitch, - NPPSwitch, neutronDecaySwitch, nucleonToSecondarySwitch, - neutrinoNeutrinoSwitch, smallDistanceStep, evolutionFactor, - convergeParameter, bkgFactor, &Q_0, &photonLeptonRate, - &protonElectronRate, &neutronPositronRate, - &protonPositronRate, &neutronElectronRate, - &neutronDecayElectronRate, &elNeutElectronRate, - &muonNeutElectronRate, &tauNeutElectronRate, - &protonPhotonRate, &elNeutPhotonRate, &muonNeutPhotonRate, - &tauNeutPhotonRate, &leptonTotalRate, &leptonScatRate, - &leptonExchRate, &continuousLoss, &deltaG, &photonTotalRate, - &leptonPhotonRate, &syncRate, pSpectrum, &spectrumNew); - - SetEMSpectrum(pSpectrum, &spectrumNew); - // update spectrum - - if (aCutcascade_Magfield != 0 && B_loc != 0 ) { - // Estimate the effect of B field on the 1D approximation (added E.A. June 2006) - lEcFlag = 0 ; - lIndex = 0; - while (!lEcFlag) { - lEnergy = (pEnergy->vector)[lIndex] ; - // Time scales are computed in parsec - t_sync = 3.84e6/(lEnergy*B_loc*B_loc*ELECTRON_MASS) ; - t_larmor = (1.1e-21)*ELECTRON_MASS*lEnergy/(B_loc*aCutcascade_Magfield) ; - if (lEnergy <= 1.e15/ELECTRON_MASS) { - t_ics = 4.e2*1.e15/(ELECTRON_MASS*lEnergy) ; - } else if (lEnergy <= 1.e18/ELECTRON_MASS) { - t_ics = 4.e2*lEnergy*ELECTRON_MASS/1.e15 ; - } else if (lEnergy <= 1.e22/ELECTRON_MASS) { - t_ics = b_ics*pow(lEnergy*ELECTRON_MASS/1.e15,a_ics) ; - } else t_ics = 1.e8*lEnergy*ELECTRON_MASS/1.e22 ; - if (t_larmor >= t_sync || t_larmor >= t_ics) lEcFlag = 1 ; - // defines the "critical" energy : the e+/- spectrum is set to 0 for Espectrum)[ELECTRON][lIndex]=0 ; - (pSpectrum->spectrum)[POSITRON][lIndex]=0 ; - lIndex++ ; - } - } - - if (synchrotronSwitch == 1) // synchrotron == true (on) - DeleteDiffRate(&syncRate); - - x += smallDistanceStep; - iterationCounter++; - } - - - propagatingDistance += x; // increment distance - - //---- redshift bins down ---- - RedshiftDown(lastIndex, redshiftRatio, pEnergy, pSpectrum, - &spectrumNew); - - // printf("\nz = %g -> %g", leftRedshift, rightRedshift); - // printf("; d/Mpc = %g -> %g:\n", leftDistance, rightDistance); - // printf("%g, %g:\n", propagatingDistance, distance); - CheckEnergy(sourceTypeSwitch, brightPhaseExp, startingRedshift, - rightRedshift, pSpectrum, pEnergy, initialTotalEnergy); - - //---- prepare for new step ---- - leftRedshift = rightRedshift; - } while (lastIndex != 1); - -clock_t end_comp = clock(); - - //---- I am done with the rates ---- - DeleteDiffRate(&leptonScatRate); - DeleteDiffRate(&leptonExchRate); - DeleteDiffRate(&leptonPhotonRate); - DeleteDiffRate(&photonLeptonRate); - DeleteDiffRate(&protonScatRate); - DeleteDiffRate(&protonNeutronRate); - DeleteDiffRate(&neutronProtonRate); - DeleteDiffRate(&protonPhotonRate); - DeleteDiffRate(&protonElectronRate); - DeleteDiffRate(&protonPositronRate); - DeleteDiffRate(&neutronElectronRate); - DeleteDiffRate(&neutronPositronRate); - DeleteDiffRate(&protonElectronNeutrinoRate); - DeleteDiffRate(&protonAntiElectronNeutrinoRate); - DeleteDiffRate(&protonMuonNeutrinoRate); - DeleteDiffRate(&protonAntiMuonNeutrinoRate); - DeleteDiffRate(&neutronAntiElectronNeutrinoRate); - DeleteDiffRate(&neutronMuonNeutrinoRate); - DeleteDiffRate(&neutronAntiMuonNeutrinoRate); - - DeleteDiffRate(&elNeutScatRate); - DeleteDiffRate(&elNeutMuonNeutRate); - DeleteDiffRate(&elNeutTauNeutRate); - DeleteDiffRate(&elNeutElectronRate); - DeleteDiffRate(&elNeutPhotonRate); - DeleteDiffRate(&elNeutProtonRate); - DeleteDiffRate(&muonNeutElNeutRate); - DeleteDiffRate(&muonNeutScatRate); - DeleteDiffRate(&muonNeutTauNeutRate); - DeleteDiffRate(&muonNeutElectronRate); - DeleteDiffRate(&muonNeutPhotonRate); - DeleteDiffRate(&muonNeutProtonRate); - DeleteDiffRate(&tauNeutElNeutRate); - DeleteDiffRate(&tauNeutMuonNeutRate); - DeleteDiffRate(&tauNeutScatRate); - DeleteDiffRate(&tauNeutElectronRate); - DeleteDiffRate(&tauNeutPhotonRate); - DeleteDiffRate(&tauNeutProtonRate); - - DeleteTotalRate(&leptonTotalRate); - DeleteTotalRate(&photonTotalRate); - DeleteTotalRate(&protonTotalRate); - DeleteTotalRate(&neutronTotalRate); - DeleteTotalRate(&elNeutTotalRate); - DeleteTotalRate(&muonNeutTotalRate); - DeleteTotalRate(&tauNeutTotalRate); - - - if (ICSSwitch == 1) { - DeleteRawDiffRate(&ICSPhotonRate); - DeleteRawDiffRate(&ICSScatRate); - DeleteRawTotalRate(&ICSTotalRate); - } - if (PPSwitch == 1) { - DeleteRawDiffRate(&PPDiffRate); - DeleteRawTotalRate(&PPTotalRate); - } - if (TPPSwitch == 1) { - DeleteRawDiffRate(&TPPDiffRate); - DeleteRawTotalRate(&TPPTotalRate); - } - if (PPPSwitch == 1) { - DeleteRawDiffRate(&PPPProtonScatRate); - DeleteRawDiffRate(&PPPProtonNeutronRate); - DeleteRawDiffRate(&PPPNeutronProtonRate); - - DeleteRawTotalRate(&PPPProtonLossRate); - DeleteRawTotalRate(&PPPNeutronLossRate); - - if (nucleonToSecondarySwitch == 1) { - DeleteRawDiffRate(&PPPProtonPhotonRate); - DeleteRawDiffRate(&PPPProtonElectronRate); - DeleteRawDiffRate(&PPPProtonPositronRate); - DeleteRawDiffRate(&PPPNeutronElectronRate); - DeleteRawDiffRate(&PPPProtonElectronNeutrinoRate); - DeleteRawDiffRate(&PPPProtonAntiElectronNeutrinoRate); - DeleteRawDiffRate(&PPPProtonMuonNeutrinoRate); - DeleteRawDiffRate(&PPPProtonAntiMuonNeutrinoRate); - DeleteRawDiffRate(&PPPNeutronAntiElectronNeutrinoRate); - DeleteRawDiffRate(&PPPNeutronMuonNeutrinoRate); - DeleteRawDiffRate(&PPPNeutronAntiMuonNeutrinoRate); - } - } - if (NPPSwitch == 1) { - if (nucleonToSecondarySwitch == 1) - DeleteRawDiffRate(&NPPDiffRate); - DeleteRawTotalRate(&NPPTotalRate); - } - if (DPPSwitch == 1) - DeleteRawTotalRate(&DPPRate); - - if (neutronDecaySwitch == 1) { - if (nucleonToSecondarySwitch == 1) - DeleteDiffRate(&neutronDecayElectronRate); - DeleteDiffRate(&neutronDecayProtonRate); - DeleteTotalRate(&neutronDecayRate); - } - - - if (neutrinoNeutrinoSwitch == 1) { - DeleteDiffRate(&NNElNeutScatRate); - DeleteDiffRate(&NNElNeutMuonNeutRate); - DeleteDiffRate(&NNElNeutTauNeutRate); - DeleteDiffRate(&NNElNeutElectronRate); - DeleteDiffRate(&NNElNeutPhotonRate); - DeleteDiffRate(&NNElNeutProtonRate); - DeleteDiffRate(&NNMuonNeutElNeutRate); - DeleteDiffRate(&NNMuonNeutScatRate); - DeleteDiffRate(&NNMuonNeutTauNeutRate); - DeleteDiffRate(&NNMuonNeutElectronRate); - DeleteDiffRate(&NNMuonNeutPhotonRate); - DeleteDiffRate(&NNMuonNeutProtonRate); - DeleteDiffRate(&NNTauNeutElNeutRate); - DeleteDiffRate(&NNTauNeutMuonNeutRate); - DeleteDiffRate(&NNTauNeutScatRate); - DeleteDiffRate(&NNTauNeutElectronRate); - DeleteDiffRate(&NNTauNeutPhotonRate); - DeleteDiffRate(&NNTauNeutProtonRate); - - DeleteTotalRate(&NNElNeutTotalRate); - DeleteTotalRate(&NNMuonNeutTotalRate); - DeleteTotalRate(&NNTauNeutTotalRate); - } - - // FinalPrintOutToTheScreen(distance, startingRedshift, propagatingDistance); - - DeleteSpectrum(&Q_0); - DeleteSpectrum(&spectrumNew); - DeleteSpectrum(&derivative); - - Delete_dCVector(&synchrotronLoss); - Delete_dCVector(&continuousLoss); - Delete_dCVector(&otherLoss); - Delete_dCVector(&protonContinuousLoss); - - Delete_dCVector(&deltaG); - Delete_dCVector(&bgEnergy); - Delete_dCVector(&bgEnergyWidth); - Delete_dCVector(&bgPhotonDensity); - - Delete_dCVector(&RedshiftArray) ; - Delete_dCVector(&DistanceArray) ; -clock_t end = clock(); - -clock_t total = end -start; -clock_t comp = end_comp -start_comp; - -#ifdef DEBUG -printf("Dint Comptime: %f\n", float(comp)/float(total)); -#endif -} - -void BuildRedshiftTable(double aH0, double aOmegaM, double aOmegaLambda, - dCVector* pRedshiftArray, dCVector* pDistanceArray) { - - // Routine added Jan 2006 - E.A. - - // aH0 in km/s/Mpc - // C is in cm/s, distances in Mpc - int lNbBins = NBINS_REDSHIFTTABLE ; - double lZmin = ZMIN_REDSHIFTTABLE ; - double lZmax = ZMAX_REDSHIFTTABLE ; - New_dCVector(pRedshiftArray, lNbBins) ; - New_dCVector(pDistanceArray, lNbBins) ; - - pRedshiftArray->vector[0] = 0 ; - for (int i=0; i < lNbBins - 1; i++) { - double kk = i/(lNbBins-2.) ; - pRedshiftArray->vector[i+1] = lZmin*pow(lZmax/lZmin,kk) ; - } - dCVector lpEvolutionFactor ; - New_dCVector(&lpEvolutionFactor, lNbBins) ; - lpEvolutionFactor.vector[0] = 1 ; - pDistanceArray->vector[0] = 0 ; - for (int i=1; i < lNbBins; i++) { - double lZ = pRedshiftArray->vector[i] ; - lpEvolutionFactor.vector[i] = 1./((1.+lZ)*sqrt(aOmegaLambda+aOmegaM*pow(1.+lZ,3))) ; - pDistanceArray->vector[i] = pDistanceArray->vector[i-1]+ - (lZ-pRedshiftArray->vector[i-1])*0.5* - (lpEvolutionFactor.vector[i-1]+lpEvolutionFactor.vector[i])*C/(aH0*1.e5) ; - } - Delete_dCVector(&lpEvolutionFactor) ; - -} - -double getRedshift(dCVector RedshiftArray, dCVector DistanceArray, double distance) { - - // Routine added Jan 2006 - E.A. - - unsigned int i0 = 0 ; - while (DistanceArray.vector[i0+1] <= distance) i0 += 1 ; - double lRedshift = RedshiftArray.vector[i0] + (RedshiftArray.vector[i0+1]-RedshiftArray.vector[i0]) - *(distance-DistanceArray.vector[i0]) - /(DistanceArray.vector[i0+1]-DistanceArray.vector[i0]) ; - if ( distance <= 0 ) lRedshift = 0 ; - - return lRedshift ; -} - -double getDistance(dCVector RedshiftArray, dCVector DistanceArray, double redshift) { - - // Routine added Jan 2006 - E.A. - - unsigned int i0 = 0 ; - while (RedshiftArray.vector[i0+1] <= redshift) i0 += 1 ; - double lDistance = DistanceArray.vector[i0] + (DistanceArray.vector[i0+1]-DistanceArray.vector[i0]) - *(redshift-RedshiftArray.vector[i0]) - /(RedshiftArray.vector[i0+1]-RedshiftArray.vector[i0]) ; - if ( redshift <= 0 ) lDistance = 0 ; - - // At that level lDistance is in Mpc --> we convert it into cm. - lDistance *= 1.e6 ; // in pc - lDistance *= DISTANCE_UNIT ; // in cm - - return lDistance ; -} - diff --git a/libs/dint/src/rate.cpp b/libs/dint/src/rate.cpp deleted file mode 100644 index c62e781db..000000000 --- a/libs/dint/src/rate.cpp +++ /dev/null @@ -1,909 +0,0 @@ -#include -#include "dint/rate.h" -#include "dint/vector.h" -#include "dint/utilities.h" - - -/* this is actually the class constructor for RawTotalRate */ -void NewRawTotalRate(RawTotalRate* pRate, const int num_main_bins, - const int num_bg_bins) -{ - pRate->mainDimension = num_main_bins; - pRate->bgDimension = num_bg_bins; - pRate->totalRate = New_dMatrix(num_main_bins, num_bg_bins); - - InitializeRawTotalRate(pRate); -} - -void DeleteRawTotalRate(RawTotalRate* pRate) -{ - Delete_dMatrix(pRate->totalRate); -} - -void InitializeRawTotalRate(RawTotalRate* pRate) -{ - int i; - int j; - - for (i = 0; i < pRate->mainDimension; i++) - { - for (j = 0; j < pRate->bgDimension; j++) - { - pRate->totalRate[i][j] = 0.; - } - } -} - -void CopyRawTotalRate(RawTotalRate* pLRate, const RawTotalRate* pRRate) -{ - int i; - int j; - - pLRate->mainDimension = pRRate->mainDimension; - pLRate->bgDimension = pRRate->bgDimension; - - Delete_dMatrix(pLRate->totalRate); - - pLRate->totalRate = New_dMatrix(pRRate->mainDimension, - pRRate->bgDimension); - - for (i = 0; i < pRRate->mainDimension; i++) - { - for (j = 0; j < pRRate->bgDimension; j++) - { - pLRate->totalRate[i][j] = pRRate->totalRate[i][j]; - } - } - /* deep copy */ -} - -void ClipRawTotalRate(RawTotalRate* pRate, const int newSize) -{ - int i; - int j; - int clip; - RawTotalRate tempRate; - - printf("Clipping RawTotalRate. From %5i... ", pRate->mainDimension); - /* let user know */ - - clip = pRate->mainDimension - newSize; - NewRawTotalRate(&tempRate, newSize, pRate->bgDimension); - - for (i = 0; i < newSize; i++) - { - int iOld = i + clip; - for (j = 0; j < pRate->bgDimension; j++) - { -#ifdef DEBUG - CheckIndex(0, pRate->mainDimension, iOld, "ClipRawTotalRate"); -#endif - tempRate.totalRate[i][j] = pRate->totalRate[iOld][j]; - } - } - - CopyRawTotalRate(pRate, &tempRate); - DeleteRawTotalRate(&tempRate); - - printf("to %5i.\n", pRate->mainDimension); -} - -void EnlargeRawTotalRate(RawTotalRate* pRate, const int newSize) -{ - int i; - int j; - RawTotalRate tempRate; - int numAddedCells; - - - numAddedCells = newSize - pRate->mainDimension; - NewRawTotalRate(&tempRate, newSize, pRate->bgDimension); - - for (i = 0; i < newSize; i++) - { - int iOld = i - numAddedCells; - for (j = 0; j < pRate->bgDimension; j++) - { - if (iOld >= 0) /* range where original matrix is */ - { -#ifdef DEBUG - CheckIndex(0, pRate->mainDimension, iOld, - "EnlargeRawTotalRate"); -#endif - tempRate.totalRate[i][j] = pRate->totalRate[iOld][j]; - } - else /* enlarged area is filled with 0 for convenience */ - { - tempRate.totalRate[i][j] = 0.; - } - } - } - - CopyRawTotalRate(pRate, &tempRate); - DeleteRawTotalRate(&tempRate); -} - -void ModifyRawTotalRate(RawTotalRate* pRate, const int newSize) -{ - if (pRate->mainDimension > newSize) - { - ClipRawTotalRate(pRate, newSize); - } - else if (pRate->mainDimension < newSize) - { - EnlargeRawTotalRate(pRate, newSize); - } - else - { - /* do nothing */ - } -} - -void ReadRawTotalRate(RawTotalRate* pRate, const char* filename) -{ - FILE* file; - - file = SafeFOpen(filename, "r"); - binfread((pRate->totalRate)[0], sizeof(double), (pRate->mainDimension)* - (pRate->bgDimension), file); - fclose(file); -} - - - -/* this is actually the class constructor for RawDiffRate */ -void NewRawDiffRate(RawDiffRate* pRate, const int num_main_bins, - const int num_bg_bins, const int num_elements) -{ - pRate->mainDimension = num_main_bins; - pRate->bgDimension = num_bg_bins; - pRate->numberOfElements = num_elements; - pRate->bound = New_i3Tensor(num_main_bins, num_bg_bins, 2); - pRate->diffRate = New_dVector(num_elements); - - InitializeRawDiffRate(pRate); -} - -void DeleteRawDiffRate(RawDiffRate* pRate) -{ - Delete_dVector(pRate->diffRate); - Delete_i3Tensor(pRate->bound); -} - -void InitializeRawDiffRate(RawDiffRate* pRate) -{ - int i; - int j; - - for (i = 0; i < pRate->mainDimension; i++) - { - for (j = 0; j < pRate->bgDimension; j++) - { - pRate->bound[i][j][0] = -1; - pRate->bound[i][j][1] = -1; - } - } - /* note how the bounds are invalidated */ - - for (i = 0; i < pRate->numberOfElements; i++) - { - pRate->diffRate[i] = 0.; - } -} - -void CheckRawDiffRate(RawDiffRate* pRate) -{ - int i; - int j; - int counter; - - for (counter = 0, i = 0; i < pRate->mainDimension; i++) - { - for (j = 0; j < pRate->bgDimension; j++) - { - if (pRate->bound[i][j][0] != -1) - { - counter += pRate->bound[i][j][1] - pRate->bound[i][j][0] + 1; - } - } - } - - if (counter != pRate->numberOfElements) - { - Error("CheckRawDiffRate: inconsistent rate", PROGRAM_ERROR); - } -} - -#ifdef DEBUG -double RawDiffRateElement(const RawDiffRate* pRate, const int i, const int j, - const int k) -{ - int n; - int p; - int offset; - - - if ((i < 0) || (j < 0) || (i >= pRate->mainDimension) || - (j >= pRate->bgDimension)) - { - printf("i: %3i, j: %3i\n", i, j); - Error("RawDiffRateElement: i or j out of bounds", PROGRAM_ERROR); - } - if ((pRate->bound)[i][j][0] == -1) /* out of range */ - { - printf("i: %3i, j: %3i\n", i, j); - Error("RawDiffRateElement: i or j out of range", PROGRAM_ERROR); - } - else - { - if ((k < (pRate->bound)[i][j][0]) || (k > (pRate->bound)[i][j][1])) - { - printf("i, j, k: %3i %3i %3i\n", k); - Error("RawDiffRateElement: k out of range", PROGRAM_ERROR); - } - } - - offset = 0; - for (n = 0; n < i; n++) - { - for (p = 0; p < pRate->bgDimension; p++) - { - if ((pRate->bound)[n][p][0] != -1) - { - offset += ((pRate->bound)[n][p][1] - (pRate->bound)[n][p][0] + - 1); - } - } - } - for (p = 0; p < j; p++) - { - offset += ((pRate->bound)[i][p][1] - (pRate->bound)[i][p][0] + 1); - } - offset += -(pRate->bound)[i][j][0] + k; - if (offset >= pRate->numberOfElements || offset < 0) - { - printf("offset: %7i, number of elements: %7i\n", offset, - pRate->numberOfElements); - Error("RawDiffRateElement: main index out of range", PROGRAM_ERROR); - } - - return (pRate->diffRate)[offset]; -} -#endif - -void CopyRawDiffRate(RawDiffRate* pLRate, const RawDiffRate* pRRate) -{ - int i; - int j; - - pLRate->mainDimension = pRRate->mainDimension; - pLRate->bgDimension = pRRate->bgDimension; - pLRate->numberOfElements = pRRate->numberOfElements; - - Delete_dVector(pLRate->diffRate); - Delete_i3Tensor(pLRate->bound); - - pLRate->bound = New_i3Tensor(pRRate->mainDimension, pRRate->bgDimension, - 2); - pLRate->diffRate = New_dVector(pRRate->numberOfElements); - - for (i = 0; i < pRRate->mainDimension; i++) - { - for (j = 0; j < pRRate->bgDimension; j++) - { - pLRate->bound[i][j][0] = pRRate->bound[i][j][0]; - pLRate->bound[i][j][1] = pRRate->bound[i][j][1]; - } - } - for (i = 0; i < pRRate->numberOfElements; i++) - { - pLRate->diffRate[i] = pRRate->diffRate[i]; - } -} - -void CopyRawDiffRateBound(RawDiffRate* pLRate, const RawDiffRate* pRRate) -{ - int i; - int j; - - if ((pLRate->mainDimension != pRRate->mainDimension) || - (pLRate->bgDimension != pRRate->bgDimension) || - (pLRate->numberOfElements != pRRate->numberOfElements)) - { - Error("CopyRawDiffRateBound: inconsistent dimensions", PROGRAM_ERROR); - } - - for (i = 0; i < pLRate->mainDimension; i++) - { - for (j = 0; j < pLRate->bgDimension; j++) - { - pLRate->bound[i][j][0] = pRRate->bound[i][j][0]; - pLRate->bound[i][j][1] = pRRate->bound[i][j][1]; - } - } -} - -void ClipRawDiffRate(RawDiffRate* pRate, const int newSize) -{ - int clip; - int newNumberOfElements; - RawDiffRate tempRate; - int i; - int j; - int k; - int counter; - int newCounter; - - - printf("Clipping RawDiffRate. From %8i... ", pRate->numberOfElements); - - clip = pRate->mainDimension - newSize; - - for (newNumberOfElements = 0, i = clip; i < pRate->mainDimension; i++) - { - for (j = 0; j < pRate->bgDimension; j++) - { - if ((pRate->bound[i][j][0] != -1) && - (pRate->bound[i][j][1] >= clip)) - /* not empty AND within range */ - { - int newLowerBound; - newLowerBound = IMax(pRate->bound[i][j][0], clip); - /* new lower bound cannot be smaller than the lower clip */ - newNumberOfElements += pRate->bound[i][j][1] - - newLowerBound + 1; - } - } - } - /* determine new number of elements */ - - NewRawDiffRate(&tempRate, newSize, pRate->bgDimension, - newNumberOfElements); - - for (i = 0; i < newSize; i++) - { - int iOld = i + clip; /* (old) index for old rate */ - for (j = 0; j < pRate->bgDimension; j++) - { -#ifdef DEBUG - CheckIndex(0, pRate->mainDimension, iOld, "ClipRawDiffRate"); -#endif - if ((pRate->bound[iOld][j][0] != -1) && - (pRate->bound[iOld][j][1] >= clip)) - { - tempRate.bound[i][j][0] = - IMax(pRate->bound[iOld][j][0], clip) - clip; - tempRate.bound[i][j][1] = - pRate->bound[iOld][j][1] - clip; - } - else - { - tempRate.bound[i][j][0] = -1; - tempRate.bound[i][j][1] = -1; - } - } - } - /* set the bounds */ - - /* fast-forward the index */ - for (counter = 0, newCounter = 0, i = 0; i < pRate->mainDimension; i++) - { - int iNew = i - clip; /* (new) index for new rate */ - for (j = 0; j < pRate->bgDimension; j++) - { - if (pRate->bound[i][j][0] != -1) - { - for (k = pRate->bound[i][j][0]; - k <= pRate->bound[i][j][1]; k++, counter++) - { - int kNew = k - clip; /* (new) k index */ - -#ifdef DEBUG - CheckIndex(0, pRate->numberOfElements, counter, - "ClipRawDiffRate"); -#endif - /* i must be within clips */ - if (i >= clip) - { - /* its own bound must not be empty && - k must be within range: - comparison w/ upper bound is not necessary - because it is automatically satisfied */ -#ifdef DEBUG - CheckIndex(0, tempRate.mainDimension, iNew, - "ClipRawDiffRate"); -#endif - if ((tempRate.bound[iNew][j][0] != -1) && - (kNew >= tempRate.bound[iNew][j][0])) - { -#ifdef DEBUG - CheckIndex(0, tempRate.numberOfElements, - newCounter, "ClipRawDiffRate"); -#endif - tempRate.diffRate[newCounter] = - pRate->diffRate[counter]; - newCounter++; - } - } - } - } - } - } - if ((counter != pRate->numberOfElements) || - (newCounter != tempRate.numberOfElements)) - { - Error("ClipRawDiffRate: counting does not match", PROGRAM_ERROR); - } - /* redundant checking, but comes cheap so why not */ - - CopyRawDiffRate(pRate, &tempRate); - /* this is where real copy takes place */ - DeleteRawDiffRate(&tempRate); - - printf("to %8i.\n", pRate->numberOfElements); -} - -void EnlargeRawDiffRate(RawDiffRate* pRate, const int newSize) -{ - int i; - int j; - int numAddedCells; - RawDiffRate tempRate; - - numAddedCells = newSize - pRate->mainDimension; - - NewRawDiffRate(&tempRate, newSize, pRate->bgDimension, - pRate->numberOfElements); - - for (i = 0; i < newSize; i++) - { - int iOld = i - numAddedCells; - for (j = 0; j < pRate->bgDimension; j++) - { - if (iOld >= 0) /* area where the original tensor is */ - { - if (pRate->bound[iOld][j][0] != -1) - { -#ifdef DEBUG - CheckIndex(0, pRate->mainDimension, iOld, - "EnlargeRawDiffRate"); -#endif - tempRate.bound[i][j][0] = pRate->bound[iOld][j][0] + - numAddedCells; - tempRate.bound[i][j][1] = pRate->bound[iOld][j][1] + - numAddedCells; - } - else - { - tempRate.bound[i][j][0] = -1; - tempRate.bound[i][j][1] = -1; - } - } - else /* outside the original tensor */ - { - tempRate.bound[i][j][0] = -1; - tempRate.bound[i][j][1] = -1; - } - } - } - - for (i = 0; i < pRate->numberOfElements; i++) - { - tempRate.diffRate[i] = pRate->diffRate[i]; - /* the rate itself does not change */ - } - - CopyRawDiffRate(pRate, &tempRate); - DeleteRawDiffRate(&tempRate); -} - -void ModifyRawDiffRate(RawDiffRate* pRate, const int newSize) -{ - if (pRate->mainDimension > newSize) - { - ClipRawDiffRate(pRate, newSize); - } - else if (pRate->mainDimension < newSize) - { - EnlargeRawDiffRate(pRate, newSize); - } - else - { - /* do nothing */ - } -} - -void ReadRawDiffRate(RawDiffRate* pRate, const char* filename) -{ - FILE* file; - - file = SafeFOpen(filename, "r"); - binfread((pRate->bound)[0][0], sizeof(int), (pRate->mainDimension)* - (pRate->bgDimension)*2, file); - binfread(pRate->diffRate, sizeof(double), pRate->numberOfElements, file); - fclose(file); - - CheckRawDiffRate(pRate); -} - - - -void NewTotalRate(TotalRate* pRate, const int num_main_bins) -{ - pRate->mainDimension = num_main_bins; - pRate->totalRate = New_dVector(num_main_bins); - - InitializeTotalRate(pRate); -} - -void DeleteTotalRate(TotalRate* pRate) -{ - Delete_dVector(pRate->totalRate); -} - -void InitializeTotalRate(TotalRate* pRate) -{ - int i; - - for (i = 0; i < pRate->mainDimension; i++) - { - pRate->totalRate[i] = 0.; - } -} - -void CopyTotalRate(TotalRate* pLRate, const TotalRate* pRRate) -{ - int i; - - pLRate->mainDimension = pRRate->mainDimension; - - Delete_dVector(pLRate->totalRate); - pLRate->totalRate = New_dVector(pRRate->mainDimension); - - for (i = 0; i < pRRate->mainDimension; i++) - { - pLRate->totalRate[i] = pRRate->totalRate[i]; - } -} - -void ClipTotalRate(TotalRate* pRate, const int newSize) -{ - int i; - int clip; - TotalRate tempRate; - - - printf("Clipping TotalRate. From %5i... ", pRate->mainDimension); - /* let user know */ - - clip = pRate->mainDimension - newSize; - NewTotalRate(&tempRate, newSize); - - for (i = 0; i < newSize; i++) - { - int iOld = i + clip; -#ifdef DEBUG - CheckIndex(0, pRate->mainDimension, iOld, "ClipTotalRate"); -#endif - tempRate.totalRate[i] = pRate->totalRate[iOld]; - } - - CopyTotalRate(pRate, &tempRate); - DeleteTotalRate(&tempRate); - - printf("to %5i.\n", pRate->mainDimension); -} - -void EnlargeTotalRate(TotalRate* pRate, const int newSize) -{ - int i; - int numAddedCells; - TotalRate tempRate; - - numAddedCells = newSize - pRate->mainDimension; - - NewTotalRate(&tempRate, newSize); - - for (i = 0; i < newSize; i++) - { - int iOld = i - numAddedCells; - if (iOld >= 0) - { -#ifdef DEBUG - CheckIndex(0, pRate->mainDimension, iOld, "EnlargeTotalRate"); -#endif - tempRate.totalRate[i] = pRate->totalRate[iOld]; - } - else - { - tempRate.totalRate[i] = 0.; - } - } - - CopyTotalRate(pRate, &tempRate); - DeleteTotalRate(&tempRate); -} - -void ModifyTotalRate(TotalRate* pRate, const int newSize) -{ - if (pRate->mainDimension > newSize) - { - ClipTotalRate(pRate, newSize); - } - else if (pRate->mainDimension < newSize) - { - EnlargeTotalRate(pRate, newSize); - } - else - { - /* do nothing */ - } -} - -void ReadTotalRate(TotalRate* pRate, const char* filename) -{ - FILE* file; - - file = SafeFOpen(filename, "r"); - binfread(pRate->totalRate, sizeof(double), (pRate->mainDimension), file); - fclose(file); -} - - - -void NewDiffRate(DiffRate* pRate, const int num_main_bins) -{ - pRate->mainDimension = num_main_bins; - pRate->bound = New_iMatrix(num_main_bins, 2); - pRate->diffRate = New_dMatrix(num_main_bins, num_main_bins); - - InitializeDiffRate(pRate); -} - - -void DeleteDiffRate(DiffRate* pRate) -{ - Delete_dMatrix(pRate->diffRate); - Delete_iMatrix(pRate->bound); -} - - -void InitializeDiffRate(DiffRate* pRate) -{ - int i; - int j; - - for (i = 0; i < pRate->mainDimension; i++) - { - pRate->bound[i][0] = pRate->mainDimension - 1; - pRate->bound[i][1] = 0; - /* note that the invalidation here is different from RawDiffRate */ - for (j = 0; j < pRate->mainDimension; j++) - { - pRate->diffRate[i][j] = 0.; - } - } -} - -void CopyDiffRate(DiffRate* pLRate, const DiffRate* pRRate) -{ - int i; - int j; - - pLRate->mainDimension = pRRate->mainDimension; - - Delete_dMatrix(pLRate->diffRate); - Delete_iMatrix(pLRate->bound); - - pLRate->bound = New_iMatrix(pRRate->mainDimension, 2); - pLRate->diffRate = New_dMatrix(pRRate->mainDimension, - pRRate->mainDimension); - - for (i = 0; i < pRRate->mainDimension; i++) - { - pLRate->bound[i][0] = pRRate->bound[i][0]; - pLRate->bound[i][1] = pRRate->bound[i][1]; - for (j = 0; j < pRRate->mainDimension; j++) - { - pLRate->diffRate[i][j] = pRRate->diffRate[i][j]; - } - } -} - -void CopyDiffRateBound(DiffRate* pLRate, const DiffRate* pRRate) -{ - int i; - - if (pLRate->mainDimension != pRRate->mainDimension) - { - Error("CopyDiffRateBound: inconsistent dimensions", PROGRAM_ERROR); - } - - for (i = 0; i < pLRate->mainDimension; i++) - { - pLRate->bound[i][0] = pRRate->bound[i][0]; - pLRate->bound[i][1] = pRRate->bound[i][1]; - } -} - -void SetStandardDiffRateBound(DiffRate* pRate) -{ - int i; - - InvalidateDiffRateBound(pRate); - - for (i = 0; i < pRate->mainDimension; i++) - { - if ((pRate->bound[i][0] != pRate->mainDimension - 1) || - (pRate->bound[i][1] != 0)) - { - pRate->bound[i][0] = 0; - pRate->bound[i][1] = i; - } - } -} - -void ClipDiffRate(DiffRate* pRate, const int newSize) -{ - int clip; - DiffRate tempRate; - int i; - int j; - - printf("Clipping DiffRate. From %5i... ", pRate->mainDimension); - - clip = pRate->mainDimension - newSize; - - NewDiffRate(&tempRate, newSize); - - for (i = 0; i < newSize; i++) - { - int iOld = i + clip; /* (old) index for old rate */ - -#ifdef DEBUG - CheckIndex(0, pRate->mainDimension, iOld, "ClipDiffRate"); -#endif - if ((pRate->bound[iOld][0] != pRate->mainDimension - 1) || - (pRate->bound[iOld][1] != 0)) - /* bound is valid */ - { - if (pRate->bound[iOld][1] >= clip) - { - tempRate.bound[i][0] = IMax(pRate->bound[iOld][0], clip) - - clip; - tempRate.bound[i][1] = pRate->bound[iOld][1] - clip; - } - else - { - tempRate.bound[i][0] = newSize - 1; - tempRate.bound[i][1] = 0; - } - } - else /* bound is invalid to begin with */ - { - tempRate.bound[i][0] = newSize - 1; - tempRate.bound[i][1] = 0; - } - - for (j = 0; j < newSize; j++) - { - int jOld = j + clip; /* (old) j-index */ - -#ifdef DEBUG - CheckIndex(0, pRate->mainDimension, jOld, "ClipDiffRate"); -#endif - tempRate.diffRate[i][j] = pRate->diffRate[iOld][jOld]; - } - } - - CopyDiffRate(pRate, &tempRate); - DeleteDiffRate(&tempRate); - - printf("to %5i.\n", pRate->mainDimension); -} - -void EnlargeDiffRate(DiffRate* pRate, const int newSize) -{ - int i; - int j; - int numAddedCells; - DiffRate tempRate; - - numAddedCells = newSize - pRate->mainDimension; - - NewDiffRate(&tempRate, newSize); - - for (i = 0; i < newSize; i++) - { - int iOld = i - numAddedCells; - if (iOld >= 0) - { -#ifdef DEBUG - CheckIndex(0, pRate->mainDimension, iOld, "EnlargeDiffRate"); -#endif - if ((pRate->bound[iOld][0] != pRate->mainDimension - 1) || - (pRate->bound[iOld][1] != 0)) - /* old bound is valid */ - { - tempRate.bound[i][0] = pRate->bound[iOld][0] + numAddedCells; - tempRate.bound[i][1] = pRate->bound[iOld][1] + numAddedCells; - } - else /* old bound is invalild */ - { - tempRate.bound[i][0] = newSize - 1; - tempRate.bound[i][1] = 0; - } - } - else - { - tempRate.bound[i][0] = newSize - 1; - tempRate.bound[i][1] = 0; - } - - for (j = 0; j < newSize; j++) - { - int jOld = j - numAddedCells; - if (iOld >= 0 && jOld >= 0) - { -#ifdef DEBUG - CheckIndex(0, pRate->mainDimension, jOld, "EnlargeDiffRate"); -#endif - tempRate.diffRate[i][j] = pRate->diffRate[iOld][jOld]; - } - else - { - tempRate.diffRate[i][j] = 0.; - } - } - } - - CopyDiffRate(pRate, &tempRate); - DeleteDiffRate(&tempRate); -} - -void ModifyDiffRate(DiffRate* pRate, const int newSize) -{ - if (pRate->mainDimension > newSize) - { - ClipDiffRate(pRate, newSize); - } - else if (pRate->mainDimension < newSize) - { - EnlargeDiffRate(pRate, newSize); - } - else - { - /* do nothing */ - } -} - -void ReadDiffRate(DiffRate* pRate, const char* filename) -{ - FILE* file; - - file = SafeFOpen(filename, "r"); - binfread((pRate->bound)[0], sizeof(int), (pRate->mainDimension)*2, file); - binfread((pRate->diffRate)[0], sizeof(double), (pRate->mainDimension)* - (pRate->mainDimension), file); - fclose(file); - - InvalidateDiffRateBound(pRate); - /* make sure invalid bounds are properly invalidated */ -} - -void InvalidateDiffRateBound(DiffRate* pRate) -{ - int i; - - for (i = 0; i < pRate->mainDimension; i++) - { - if ((pRate->bound[i][0] == -1) || ((pRate->bound[i][0] == - pRate->mainDimension - 1) && (pRate->bound[i][0] == 0))) - /* picks up invalid bound data however they are formatted */ - { - pRate->bound[i][0] = pRate->mainDimension - 1; - pRate->bound[i][1] = 0; - } - } -} - diff --git a/libs/dint/src/spectrum.cpp b/libs/dint/src/spectrum.cpp deleted file mode 100644 index b01801762..000000000 --- a/libs/dint/src/spectrum.cpp +++ /dev/null @@ -1,212 +0,0 @@ -#include -#include -#include "dint/spectrum.h" -#include "dint/vector.h" -#include "dint/cvector.h" -#include "dint/const.h" -#include "dint/utilities.h" - - -void NewSpectrum(Spectrum* pSpectrum, const int num_bins) { - pSpectrum->numberOfMainBins = num_bins; - pSpectrum->spectrum = New_dMatrix(NUM_SPECIES, num_bins); - - InitializeSpectrum(pSpectrum); // always initialize! -} - -void DeleteSpectrum(Spectrum* pSpectrum) { - Delete_dMatrix(pSpectrum->spectrum); -} - -void InitializeSpectrum(Spectrum* pSpectrum) { - for (int i=0; inumberOfMainBins; j++) - pSpectrum->spectrum[i][j] = 0.; - } -} - -void InitializeEMSpectrum(Spectrum* pSpectrum) { - for (int i=0; i<3; i++) { - for (int j=0; jnumberOfMainBins; j++) - pSpectrum->spectrum[i][j] = 0.; - } -} - -void InitializeNucleonSpectrum(Spectrum* pSpectrum) { - for (int i=3; i<5; i++) { - for (int j=0; jnumberOfMainBins; j++) - pSpectrum->spectrum[i][j] = 0.; - } -} - -void InitializeNeutrinoSpectrum(Spectrum* pSpectrum) { - for (int i=5; inumberOfMainBins; j++) - pSpectrum->spectrum[i][j] = 0.; - } -} - -void AddSpectrum(Spectrum *a, const Spectrum *b) { - for (int i = 0; i < NUM_SPECIES; i++) { - for (int j = 0; j < a->numberOfMainBins; j++) - a->spectrum[i][j] += b->spectrum[i][j]; - } -} - -void SetSpectrum(Spectrum* pSpectrum1, const Spectrum* pSpectrum2) { - if (pSpectrum1->numberOfMainBins != pSpectrum2->numberOfMainBins) - Error("SetSpectrum: inconsistent dimensions", PROGRAM_ERROR); - - for (int i=0; inumberOfMainBins; j++) - pSpectrum1->spectrum[i][j] = pSpectrum2->spectrum[i][j]; - } -} - -void SetEMSpectrum(Spectrum* pSpectrum1, const Spectrum* pSpectrum2) { - if (pSpectrum1->numberOfMainBins != pSpectrum2->numberOfMainBins) - Error("SetEMSpectrum: inconsistent dimension", PROGRAM_ERROR); - - for (int i=0; i<3; i++) { - for (int j=0; jnumberOfMainBins; j++) - pSpectrum1->spectrum[i][j] = pSpectrum2->spectrum[i][j]; - } -} - -void SetNucleonSpectrum(Spectrum* pSpectrum1, const Spectrum* pSpectrum2) { - if (pSpectrum1->numberOfMainBins != pSpectrum2->numberOfMainBins) - Error("SetSpectrum: inconsistent dimension", PROGRAM_ERROR); - - for (int i=3; i<5; i++) { - for (int j=0; jnumberOfMainBins; j++) - pSpectrum1->spectrum[i][j] = pSpectrum2->spectrum[i][j]; - } -} - -void SetNeutrinoSpectrum(Spectrum* pSpectrum1, const Spectrum* pSpectrum2) { - if (pSpectrum1->numberOfMainBins != pSpectrum2->numberOfMainBins) - Error("SetSpectrum: inconsistent dimension", PROGRAM_ERROR); - - for (int i=5; inumberOfMainBins; j++) - pSpectrum1->spectrum[i][j] = pSpectrum2->spectrum[i][j]; - } -} - -double GetNumber(const Spectrum* pSpectrum) { - double number = 0.; - - for (int i=0; inumberOfMainBins; j++) - number += pSpectrum->spectrum[i][j]; - } - return number; -} - -double GetEMNumber(const Spectrum* pSpectrum) { - double number = 0.; - - for (int i=0; i<3; i++) { - for (int j=0; jnumberOfMainBins; j++) - number += pSpectrum->spectrum[i][j]; - } - return number; -} - -double GetNucleonNumber(const Spectrum* pSpectrum) { - double number = 0.; - - for (int i=3; i<5; i++) { - for (int j=0; jnumberOfMainBins; j++) - number += pSpectrum->spectrum[i][j]; - } - return number; -} - -double GetNeutrinoNumber(const Spectrum* pSpectrum) { - double number = 0.; - - for (int i=5; inumberOfMainBins; j++) - number += pSpectrum->spectrum[i][j]; - } - return number; -} - -double GetEnergy(const Spectrum* pSpectrum, const dCVector* pEnergy) { - double totalEnergy = 0.; - - if (pSpectrum->numberOfMainBins != pEnergy->dimension) - Error("GetEnergy: inconsistent dimensions", PROGRAM_ERROR); - - for (int i=0; inumberOfMainBins; j++) - totalEnergy += (pSpectrum->spectrum)[i][j]*(pEnergy->vector)[j]; - } - return totalEnergy; -} - -double GetEMEnergy(const Spectrum* pSpectrum, const dCVector* pEnergy) { - double totalEnergy = 0.; - - if (pSpectrum->numberOfMainBins != pEnergy->dimension) - Error("GetEnergy: inconsistent dimensions", PROGRAM_ERROR); - - for (int i=0; i<3; i++) { - for (int j=0; jnumberOfMainBins; j++) - totalEnergy += (pSpectrum->spectrum)[i][j]*(pEnergy->vector)[j]; - } - return totalEnergy; -} - -double GetNucleonEnergy(const Spectrum* pSpectrum, const dCVector* pEnergy) { - double totalEnergy = 0.; - - if (pSpectrum->numberOfMainBins != pEnergy->dimension) - Error("GetEnergy: inconsistent dimensions", PROGRAM_ERROR); - - for (int i=3; i<5; i++) { - for (int j=0; jnumberOfMainBins; j++) - totalEnergy += (pSpectrum->spectrum)[i][j]*(pEnergy->vector)[j]; - } - return totalEnergy; -} - -double GetNeutrinoEnergy(const Spectrum* pSpectrum, const dCVector* pEnergy) { - double totalEnergy = 0.; - - if (pSpectrum->numberOfMainBins != pEnergy->dimension) - Error("GetEnergy: inconsistent dimensions", PROGRAM_ERROR); - - for (int i=5; inumberOfMainBins; j++) - totalEnergy += (pSpectrum->spectrum)[i][j]*(pEnergy->vector)[j]; - } - return totalEnergy; -} - -void DumpSpectrum(const dCVector* pEnergy, const dCVector* pEnergyWidth, - const Spectrum* pSpectrum, const char* filename) { - FILE* dumpFile; - char f1[80] = "datafiles/"; - - if ((pEnergy->dimension != pEnergyWidth->dimension) || - (pEnergyWidth->dimension != pSpectrum->numberOfMainBins)) - Error("DumpSpectrum: inconsistent dimensions", PROGRAM_ERROR); - - strncat(f1, filename, 79 - strlen(filename)); - dumpFile = SafeFOpen(f1, "w"); - // this is to send the dump file to a different directory (datafiles) - // by Guenter (7/20/1998) - - for (int i=0; inumberOfMainBins; j++) { - fprintf(dumpFile, "%15.4E %15.4E\n", - ELECTRON_MASS*(pEnergy->vector)[j], - (pSpectrum->spectrum)[i][j]/(pEnergyWidth->vector)[j]* - (pEnergy->vector)[j]*(pEnergy->vector)[j]); - // proper unit conversion for energy - } - } - fclose(dumpFile); -} diff --git a/libs/dint/src/sync.cpp b/libs/dint/src/sync.cpp deleted file mode 100644 index 72a74699b..000000000 --- a/libs/dint/src/sync.cpp +++ /dev/null @@ -1,128 +0,0 @@ - -#include "dint/sync.h" - -void LoadSyncTable(dCVector* syncTable, string aDirTables) -{ - FILE* syncData; - double temporary; - int i; - - syncData = SafeFOpen((aDirTables+"/syncTable.dat").c_str(), "r"); - for (i = 0; i < syncTable->dimension; i++) { - fscanf(syncData, "%lf %lf", &temporary, &((syncTable->vector)[i])); - } - fclose(syncData) ; // added June 2005 - E.A. - -} - - -void InitializeSynchrotron(const double B_0, const dCVector* pEnergy, - const dCVector* pEnergyWidth, - dCVector* synchrotronLoss, DiffRate* syncRate, - string aDirTables) -/* this function calculates the synchrotron loss rate for the electron - and the synchrotron radiation spectrum for photons - The radom direction of the magnetic field requires me to do an - average over the pitch angle, and it results in an extra factor of - 2/3, and slightly modifies the functional form of F(x) from the - purely perpendicular case */ -/* The above comment is from the stand alone version. Compared to this version the constants seem to be fixed to correct for a perpendicular field as input. JK, 2011*/ -{ - const int SYNC_TABLE_SIZE = 161; - int i; - double offset; /* parameter to compute bounds correctly */ - dCVector syncTable; - double x0; - - double ECrit; - double EMin; - double EMax; - int jMin; - int jMax; - int j; - double xx; - double function; - int iTable; - double eLower; - double eUpper; - int num_main_bins; - - num_main_bins = pEnergy->dimension; - - if ((num_main_bins != pEnergyWidth->dimension) || - (num_main_bins != syncRate->mainDimension) || - (num_main_bins != synchrotronLoss->dimension)) - { - Error("InitializeSynchrotron: inconsistent dimensions", PROGRAM_ERROR); - } - - New_dCVector(&syncTable, SYNC_TABLE_SIZE); - - /* read in table */ - - LoadSyncTable(&syncTable, aDirTables); - - /* calculate the rates */ - offset = BINS_PER_DECADE*(log10(ELECTRON_MASS) - MAX_ENERGY_EXP) + - num_main_bins + 0.5; - x0 = B_0*5.86667629e-4*DISTANCE_UNIT; - /* x0: eB/m_e in inverse pc */ - - for (i = 0; i < num_main_bins; i++) - { - /* electron loss rate */ - (synchrotronLoss->vector)[i] = -B_0*B_0*(pEnergy->vector)[i]* - (pEnergy->vector)[i]*2.*4.86037e4*VOLUME_UNIT; - - /* calculate the radiation spectrum */ - ECrit = 3./2.*B_0/4.414034e13*(pEnergy->vector)[i]* - (pEnergy->vector)[i]; - /* ECrit: critical energy in electron mass */ - - EMin = 2./3./((pEnergy->vector)[i]*(pEnergy->vector)[i]* - (pEnergy->vector)[i])*ECrit; - EMax = 5.*ECrit; - /* EMin/EMax: useful range for x (in electron mass) */ - - /* set up the range for photons -> determine bounds */ - jMin = IMax((int)(BINS_PER_DECADE*log10(EMin) + offset), 0); - jMax = IMin((int)(BINS_PER_DECADE*log10(EMax) + offset), - num_main_bins - 1); - if (jMax >= 0) /* normal case */ - { - (syncRate->bound)[i][0] = jMin; - (syncRate->bound)[i][1] = jMax; - - for (j = (syncRate->bound)[i][0]; - j <= (syncRate->bound)[i][1]; j++) - { - xx = (pEnergy->vector)[j]/ECrit; - - if (log10(xx) < -7.) - { - function = pow(xx, 1./3.)*2.1809736; - /* use an approximation for x below 10^-7 */ - } - else - { - /* compute F(x) at given photon energy by linear - extrapolation in logarithm */ - iTable = (int)(log10(xx)*20. + 140); - eLower = (double)(iTable - 140)/20.; - eUpper = (double)(iTable - 139)/20.; - /* numbers 140, 139, and 20 are properties of table */ - function = exp(log(syncTable.vector[iTable]) + (log10(xx) - - eLower)/(eUpper - eLower)* - (log(syncTable.vector[iTable+1]) - - log(syncTable.vector[iTable]))); - } - (syncRate->diffRate)[i][j] = 2.756644477e-1/137.036*x0* - function/(pEnergy->vector)[j]*(pEnergyWidth->vector)[j]; - /* 2.7566...: sqtr(3)/(2pi), 1/137: e^2, x0: eB/m_e */ - } - } - } - - Delete_dCVector(&syncTable) ; - -} diff --git a/libs/dint/src/vector.cpp b/libs/dint/src/vector.cpp deleted file mode 100644 index 58e9700d4..000000000 --- a/libs/dint/src/vector.cpp +++ /dev/null @@ -1,224 +0,0 @@ - -#include -#include - -#include "dint/vector.h" -#include "dint/error.h" - - -dVector New_dVector(const int n) -{ - dVector vector; - - vector = (double*)malloc((size_t)(n*sizeof(double))); - if (vector == NULL) - { - Error("New_dVector: allocation failure", ARRAY_ERROR); - } - - return vector; -} - -iVector New_iVector(const int n) -{ - iVector vector; - - vector = (int*)malloc((size_t)(n*sizeof(int))); - if (vector == NULL) - { - Error("New_iVector: allocation failure", ARRAY_ERROR); - } - - return vector; -} - - -dMatrix New_dMatrix(const int n1, const int n2) -{ - int i; - dMatrix matrix; - - matrix = (double**)malloc((size_t)(n1*sizeof(double*))); - if (matrix == NULL) - { - Error("New_dMatrix: allocation failure level 1", ARRAY_ERROR); - } - - matrix[0] = (double*)malloc((size_t)(n1*n2*sizeof(double))); - if (matrix[0] == NULL) - { - Error("New_dMatrix: allocation failure level 2", ARRAY_ERROR); - } - - for (i = 1; i < n1; i++) - { - matrix[i] = matrix[i-1] + n2; - } - - return matrix; -} - - -iMatrix New_iMatrix(const int n1, const int n2) -{ - int i; - iMatrix matrix; - - matrix = (int**)malloc((size_t)(n1*sizeof(int*))); - if (matrix == NULL) - { - Error("New_iMatrix: allocation failure level 1", ARRAY_ERROR); - } - - matrix[0] = (int*)malloc((size_t)(n1*n2*sizeof(int))); - if (matrix[0] == NULL) - { - Error("New_iMatrix: allocation failure level 2", ARRAY_ERROR); - } - - for (i = 1; i < n1; i++) - { - matrix[i] = matrix[i-1] + n2; - } - - return matrix; -} - - -d3Tensor New_d3Tensor(const int n1, const int n2, const int n3) -{ - int i; - int j; - d3Tensor tensor; - - tensor = (double***)malloc((size_t)(n1*sizeof(double**))); - if (tensor == NULL) - { - Error("d3Tensor: allocation failure level 1", ARRAY_ERROR); - } - - tensor[0] = (double**)malloc((size_t)(n1*n2*sizeof(double*))); - if (tensor[0] == NULL) - { - Error("d3Tensor: allocation failure level 2", ARRAY_ERROR); - } - - tensor[0][0] = (double*)malloc((size_t)(n1*n2*n3*sizeof(double))); - if (tensor[0][0] == NULL) - { - Error("d3Tensor: allocation failure level 3", ARRAY_ERROR); - } - - for (j = 1; j < n2; j++) - { - tensor[0][j] = tensor[0][j-1] + n3; - } - for (i = 1; i < n1; i++) - { - tensor[i] = tensor[i-1] + n2; - tensor[i][0] = tensor[i-1][0] + n2*n3; - for (j = 1; j < n2; j++) - { - tensor[i][j] = tensor[i][j-1] + n3; - } - } - - return tensor; -} - - -i3Tensor New_i3Tensor(const int n1, const int n2, const int n3) -{ - int i; - int j; - i3Tensor tensor; - - tensor = (int***)malloc((size_t)(n1*sizeof(int**))); - if (tensor == NULL) - { - Error("New_i3Tensor: allocation failure level 1", ARRAY_ERROR); - } - - tensor[0] = (int**)malloc((size_t)(n1*n2*sizeof(int*))); - if (tensor[0] == NULL) - { - Error("New_i3Tensor: allocation failure level 2", ARRAY_ERROR); - } - - tensor[0][0] = (int*)malloc((size_t)(n1*n2*n3*sizeof(int))); - if (tensor[0][0] == NULL) - { - Error("New_i3Tensor: allocation failure level 3", ARRAY_ERROR); - } - - - for (j = 1; j < n2; j++) - { - tensor[0][j] = tensor[0][j-1] + n3; - } - for (i = 1; i < n1; i++) - { - tensor[i] = tensor[i-1] + n2; - tensor[i][0] = tensor[i-1][0] + n2*n3; - for (j = 1; j < n2; j++) - { - tensor[i][j] = tensor[i][j-1] + n3; - } - } - - return tensor; -} - - -void Delete_dVector(dVector vector) -{ - free(vector); - vector = NULL; -} - - -void Delete_iVector(iVector vector) -{ - free(vector); - vector = NULL; -} - - -void Delete_dMatrix(dMatrix matrix) -{ - free(matrix[0]); - matrix[0] = NULL; - free(matrix); - matrix = NULL; -} - - -void Delete_iMatrix(iMatrix matrix) -{ - free(matrix[0]); - matrix[0] = NULL; - free(matrix); - matrix = NULL; -} - - -void Delete_d3Tensor(d3Tensor tensor) -{ - free(tensor[0][0]); - tensor[0][0] = NULL; - free(tensor[0]); - tensor[0] = NULL; - free(tensor); - tensor = NULL; -} - - -void Delete_i3Tensor(i3Tensor tensor) -{ - free(tensor[0][0]); - tensor[0][0] = NULL; - free(tensor[0]); - tensor[0] = NULL; - free(tensor); - tensor = NULL; -} diff --git a/python/2_headers.i b/python/2_headers.i index dc659e03b..5c0674bc4 100644 --- a/python/2_headers.i +++ b/python/2_headers.i @@ -172,7 +172,6 @@ using namespace crpropa; // for usage of namespace in header files, necessary %include "crpropa/Units.h" %include "crpropa/Common.h" %include "crpropa/Cosmology.h" -%include "crpropa/PhotonPropagation.h" %template(RandomSeed) std::vector; %template(RandomSeedThreads) std::vector< std::vector >; %include "crpropa/Random.h" @@ -548,7 +547,6 @@ using namespace crpropa; // for usage of namespace in header files, necessary %include "crpropa/module/HDF5Output.h" %include "crpropa/module/OutputShell.h" -%include "crpropa/module/EMCascade.h" %include "crpropa/module/PhotonEleCa.h" %include "crpropa/module/PhotonOutput1D.h" %include "crpropa/module/NuclearDecay.h" diff --git a/src/PhotonPropagation.cpp b/src/PhotonPropagation.cpp deleted file mode 100644 index b7d7ea06c..000000000 --- a/src/PhotonPropagation.cpp +++ /dev/null @@ -1,504 +0,0 @@ -#include "crpropa/PhotonPropagation.h" -#include "crpropa/Common.h" -#include "crpropa/Units.h" -#include "crpropa/Cosmology.h" -#include "crpropa/ProgressBar.h" - -#include "EleCa/Propagation.h" -#include "EleCa/Particle.h" -#include "EleCa/Common.h" - -#include "dint/prop_second.h" -#include "dint/DintEMCascade.h" -#include "kiss/string.h" -#include "kiss/logger.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace crpropa { - -void ElecaPropagation( - const std::string &inputfile, - const std::string &outputfile, - bool showProgress, - double lowerEnergyThreshold, - double magneticFieldStrength, - const std::string &background) { - - KISS_LOG_WARNING << "EleCa propagation is deprecated and is no longer supported. Please use the EM* (EMPairProduction, EMInverseComptonScattering, ...) modules instead.\n"; - - std::ifstream infile(inputfile.c_str()); - std::streampos startPosition = infile.tellg(); - - infile.seekg(0, std::ios::end); - std::streampos endPosition = infile.tellg(); - infile.seekg(startPosition); - - - ProgressBar progressbar(endPosition); - if (showProgress) { - progressbar.start("Run ElecaPropagation"); - } - - if (!infile.good()) - throw std::runtime_error( - "ElecaPropagation: could not open file " + inputfile); - - bool PhotonOutput1D; - std::string line; - std::getline(infile, line); - if (line == "#ID E D pID pE iID iE iD") { - PhotonOutput1D = true; - } else if (line == "# D ID E ID0 E0 ID1 E1 X1") { - PhotonOutput1D = false; - } else { - throw std::runtime_error("ElecaPropagation: Wrong header of input file. Use PhotonOutput1D or Event1D with additional columns enabled."); - } - - eleca::setSeed(); - eleca::Propagation propagation; - propagation.SetEthr(lowerEnergyThreshold / eV ); - propagation.ReadTables(getDataPath("EleCa/eleca.dat")); - propagation.InitBkgArray(background); - - propagation.SetB(magneticFieldStrength / gauss); - - std::ofstream output(outputfile.c_str()); - output << "# ID\tE\tiID\tiE\tgeneration\n"; - output << "# ID Id of particle (photon, electron, positron)\n"; - output << "# E Energy [EeV]\n"; - output << "# iID Id of source particle\n"; - output << "# iE Energy [EeV] of source particle\n"; - output << "# Generation number of interactions during propagation before particle is created\n"; - - while (infile.good()) { - if (infile.peek() != '#') { - double D, E, E0, E1, X1; - int ID, ID0, ID1; - if (PhotonOutput1D) { - infile >> ID >> E >> X1 >> ID1 >> E1 >> ID0 >> E0 >> D; - } else { - infile >> D >> ID >> E >> ID0 >> E0 >> ID1 >> E1 >> X1; - } - if (showProgress) { - progressbar.setPosition(infile.tellg()); - } - - if (infile) { - - double z = eleca::Mpc2z(X1); - eleca::Particle p0(ID, E * 1e18, z); - - std::vector ParticleAtMatrix; - std::vector ParticleAtGround; - ParticleAtMatrix.push_back(p0); - - while (ParticleAtMatrix.size() > 0) { - - eleca::Particle p1 = ParticleAtMatrix.back(); - ParticleAtMatrix.pop_back(); - - if (p1.IsGood()) { - propagation.Propagate(p1, ParticleAtMatrix, - ParticleAtGround); - } - } - - for (int i = 0; i < ParticleAtGround.size(); ++i) { - eleca::Particle &p = ParticleAtGround[i]; - if (p.GetType() != 22) - continue; - char buffer[256]; - size_t bufferPos = 0; - bufferPos += std::sprintf(buffer + bufferPos, "%i\t", p.GetType()); - bufferPos += std::sprintf(buffer + bufferPos, "%.4E\t", p.GetEnergy() / 1E18 ); - bufferPos += std::sprintf(buffer + bufferPos, "%i\t", ID0); - bufferPos += std::sprintf(buffer + bufferPos, "%.4E\t", E0 ); - bufferPos += std::sprintf(buffer + bufferPos, "%i", p.Generation()); - bufferPos += std::sprintf(buffer + bufferPos, "\n"); - - output.write(buffer, bufferPos); - } - } - } - - infile.ignore(std::numeric_limits::max(), '\n'); - } - infile.close(); - output.close(); -} - -typedef struct _Secondary { - double D, E, E0, E1, X1; - int ID, ID0, ID1; -} _Secondary; - -bool _SecondarySortPredicate(const _Secondary& s1, const _Secondary& s2) { - return s1.X1 < s2.X1; -} - -void FillInSpectrum(Spectrum *a, const _Secondary &s) { - double logE = log10(s.E) + 18; // log10(E/eV) - int iBin = floor((logE - MIN_ENERGY_EXP) / 0.1); // bin number from 0 - NUM_MAIN_BINS-1 - if (iBin >= NUM_MAIN_BINS) { - std::cout << "DintPropagation: Energy too high " << logE << std::endl; - return; - } - if (iBin < 0) { - std::cout << "DintPropagation: Energy too low " << logE << std::endl; - return; - } - if (s.ID == 22) - a->spectrum[PHOTON][iBin] += 1.; - else if (s.ID == 11) - a->spectrum[ELECTRON][iBin] += 1.; - else if (s.ID == -11) - a->spectrum[POSITRON][iBin] += 1.; - else - std::cout << "DintPropagation: Unhandled particle ID " << s.ID << std::endl; -} - -void DintPropagation( - const std::string &inputfile, - const std::string &outputfile, - int IRBFlag, - int RadioFlag, - double magneticFieldStrength, - double aCutcascade_Magfield) { - - KISS_LOG_WARNING << "DINT propagation is deprecated and is no longer supported. Please use the EM* (EMPairProduction, EMInverseComptonScattering, ...) modules instead.\n"; - - // initialize the energy grids for DINT - dCVector energyGrid, energyWidth; - New_dCVector(&energyGrid, NUM_MAIN_BINS); - New_dCVector(&energyWidth, NUM_MAIN_BINS); - SetEnergyBins(MIN_ENERGY_EXP, &energyGrid, &energyWidth); - - std::ofstream outfile(outputfile.c_str()); - if (!outfile.good()) - throw std::runtime_error( - "DintPropagation: could not open file " + outputfile); - - std::ifstream infile(inputfile.c_str()); - if (!infile.good()) - throw std::runtime_error( - "DintPropagation: could not open file " + inputfile); - - bool PhotonOutput1D; - std::string line; - std::getline(infile, line); - if (line == "#ID E D pID pE iID iE iD") { - PhotonOutput1D = true; - } else if (line == "# D ID E ID0 E0 ID1 E1 X1") { - PhotonOutput1D = false; - } else { - throw std::runtime_error("DintPropagation: Wrong header of input file. Use PhotonOutput1D or Event1D with additional columns enabled."); - } - - // initialize the spectrum - Spectrum finalSpectrum; - NewSpectrum(&finalSpectrum, NUM_MAIN_BINS); - InitializeSpectrum(&finalSpectrum); - - std::string dataPath = getDataPath("dint"); - double B = magneticFieldStrength / gauss; - double h = H0() * Mpc / 1000; - DintEMCascade dint(IRBFlag, RadioFlag, dataPath, B, h, omegaM(), omegaL()); - - const size_t nBuffer = 7.5E7; // maximum number of simultaneously processed particles, keep memory requirement < 1GB - const double dMargin = 0.1; // distance bin width in [Mpc] - - while (infile.good()) { - // read up to nBuffer secondaries from input file - std::vector<_Secondary> secondaries; - secondaries.reserve(nBuffer); - while (infile.good() && (secondaries.size() < nBuffer)) { - if (infile.peek() != '#') { - _Secondary s; - if (PhotonOutput1D) { - infile >> s.ID >> s.E >> s.X1 >> s.ID1 >> s.E1 >> s.ID0 >> s.E0 >> s.D; - } else { - infile >> s.D >> s.ID >> s.E >> s.ID0 >> s.E0 >> s.ID1 >> s.E1 >> s.X1; - } - s.X1 = comoving2LightTravelDistance(s.X1 * Mpc) / Mpc; // DintEMCascade expects light travel distance - if (infile) - secondaries.push_back(s); - } - infile.ignore(std::numeric_limits::max(), '\n'); - } - - if (secondaries.empty()) - break; // all secondaries processed, nothing left to do - - // sort by distance - std::sort(secondaries.begin(), secondaries.end(), - _SecondarySortPredicate); - - Spectrum inputSpectrum, outputSpectrum; - NewSpectrum(&inputSpectrum, NUM_MAIN_BINS); - NewSpectrum(&outputSpectrum, NUM_MAIN_BINS); - InitializeSpectrum(&inputSpectrum); - - // process secondaries - while ((secondaries.size() > 0 ) && (secondaries.back().X1 > 0)) { - double Dmax = secondaries.back().X1; // upper bound of distance bin - double Dmin = max(Dmax - dMargin, 0.); // lower bound of distance bin - - // add all secondaries within the current distance bin - while ((secondaries.size() > 0) && (secondaries.back().X1 > Dmin)) { - FillInSpectrum(&inputSpectrum, secondaries.back()); - secondaries.pop_back(); - } - - // propagate to next closest particle or to D=0 - double D = 0; - if (secondaries.size() > 0) - D = secondaries.back().X1; - - // propagate distance step and make the output the new input spectrum - InitializeSpectrum(&outputSpectrum); - dint.propagate(Dmax, D, &inputSpectrum, &outputSpectrum, aCutcascade_Magfield); - SetSpectrum(&inputSpectrum, &outputSpectrum); - } - - // add remaining secondaries at D=0 to output spectrum - while (secondaries.size() > 0) { - FillInSpectrum(&inputSpectrum, secondaries.back()); - secondaries.pop_back(); - } - - AddSpectrum(&finalSpectrum, &inputSpectrum); - DeleteSpectrum(&outputSpectrum); - DeleteSpectrum(&inputSpectrum); - } - - // output - outfile << "# logE photons electrons positrons\n"; - outfile << "# - logE: energy bin center \n"; - outfile << "# - photons, electrons, positrons: total flux weights\n"; - for (int j = 0; j < finalSpectrum.numberOfMainBins; j++) { - double logEc = MIN_ENERGY_EXP + 0.05 + j * 1. / BINS_PER_DECADE; - outfile << std::setw(5) << logEc; - for (int i = 0; i < 3; i++) { - outfile << std::setw(13) << finalSpectrum.spectrum[i][j]; - } - outfile << "\n"; - } - outfile.close(); - - DeleteSpectrum(&finalSpectrum); - Delete_dCVector(&energyGrid); - Delete_dCVector(&energyWidth); -} - - - -bool _ParticlesAtGroundSortPredicate(const eleca::Particle& p1, const eleca::Particle& p2) { - return p1.Getz() < p2.Getz(); -} - -void DintElecaPropagation( - const std::string &inputfile, - const std::string &outputfile, - bool showProgress, - double crossOverEnergy, - double magneticFieldStrength, - double aCutcascade_Magfield) { - - KISS_LOG_WARNING << "EleCa+DINT propagation is deprecated and is no longer supported. Please use the EM* (EMPairProduction, EMInverseComptonScattering, ...) modules instead.\n"; - - //////////////////////////////////////////////////////////////////////// - //Initialize EleCa - std::ifstream infile(inputfile.c_str()); - std::streampos startPosition = infile.tellg(); - - infile.seekg(0, std::ios::end); - std::streampos endPosition = infile.tellg(); - infile.seekg(startPosition); - - ProgressBar progressbar(endPosition); - if (showProgress) { - progressbar.start("Run EleCa propagation"); - } - - if (!infile.good()) - throw std::runtime_error( - "EleCaPropagation: could not open file " + inputfile); - - bool PhotonOutput1D; - std::string line; - std::getline(infile, line); - if (line == "#ID E D pID pE iID iE iD") { - PhotonOutput1D = true; - } else if (line == "# D ID E ID0 E0 ID1 E1 X1") { - PhotonOutput1D = false; - } else { - throw std::runtime_error("DintElecaPropagation: Wrong header of input file. Use PhotonOutput1D or Event1D with additional columns enabled."); - } - - eleca::setSeed(); - eleca::Propagation propagation; - propagation.SetEthr(crossOverEnergy / eV ); - propagation.ReadTables(getDataPath("EleCa/eleca.dat")); - propagation.InitBkgArray("ALL"); - propagation.SetB(magneticFieldStrength / gauss); - std::vector ParticleAtGround; - - //////////////////////////////////////////////////////////////////////// - //Initialize DINT - dCVector energyGrid, energyWidth; - // Initialize the energy grids for dint - New_dCVector(&energyGrid, NUM_MAIN_BINS); - New_dCVector(&energyWidth, NUM_MAIN_BINS); - SetEnergyBins(MIN_ENERGY_EXP, &energyGrid, &energyWidth); - - std::ofstream outfile(outputfile.c_str()); - if (!outfile.good()) - throw std::runtime_error( - "DintPropagation: could not open file " + outputfile); - - Spectrum finalSpectrum; - NewSpectrum(&finalSpectrum, NUM_MAIN_BINS); - InitializeSpectrum(&finalSpectrum); - - std::string dataPath = getDataPath("dint"); - double h = H0() * Mpc / 1000; - double ol = omegaL(); - double om = omegaM(); - DintEMCascade dint(4, 4, dataPath, magneticFieldStrength/gauss, h, om, ol); - - //////////////////////////////////////////////////////////////////////// - // Loop over infile - - while (infile.good()) { - /// Eleca Propagation - if (infile.peek() == '#') { - infile.ignore(std::numeric_limits::max(), '\n'); - continue; - } - - double D, E, E0, E1, X1; - int ID, ID0, ID1; - if (PhotonOutput1D) { - infile >> ID >> E >> X1 >> ID1 >> E1 >> ID0 >> E0 >> D; - } else { - infile >> D >> ID >> E >> ID0 >> E0 >> ID1 >> E1 >> X1; - } - if (showProgress) { - progressbar.setPosition(infile.tellg()); - } - if (infile) { // stop at last line - double z = eleca::Mpc2z(X1); - eleca::Particle p0(ID, E * 1e18, z); - - std::vector ParticleAtMatrix; - ParticleAtMatrix.push_back(p0); - - while (ParticleAtMatrix.size() > 0) { - eleca::Particle p1 = ParticleAtMatrix.back(); - ParticleAtMatrix.pop_back(); - - if (p1.IsGood()) { - propagation.Propagate(p1, ParticleAtMatrix, - ParticleAtGround, false); - } - } - } - - // The vector is larger than ~1GB, or the infile is completely read - better call DINT. - if (ParticleAtGround.size() > 1000000 || !infile) { - const double dMargin = 0.1 * Mpc; - - std::sort(ParticleAtGround.begin(), ParticleAtGround.end(), _ParticlesAtGroundSortPredicate); - - Spectrum inputSpectrum, outputSpectrum; - NewSpectrum(&inputSpectrum, NUM_MAIN_BINS); - NewSpectrum(&outputSpectrum, NUM_MAIN_BINS); - - InitializeSpectrum(&inputSpectrum); - // process secondaries - while (ParticleAtGround.size() > 0) { - double currentDistance = redshift2LightTravelDistance(ParticleAtGround.back().Getz()); // dint expects light travel distance - bool lastStep = (currentDistance == 0.); - // add secondaries at the current distance to spectrum - while ((ParticleAtGround.size() > 0) && (redshift2LightTravelDistance(ParticleAtGround.back().Getz()) >= (currentDistance - dMargin))) { - if (redshift2LightTravelDistance(ParticleAtGround.back().Getz()) > 0. || lastStep) { - double criticalEnergy = ParticleAtGround.back().GetEnergy() / (ELECTRON_MASS); // units of dint - int maxBin = (int) ((log10(criticalEnergy * ELECTRON_MASS) - MIN_ENERGY_EXP) * BINS_PER_DECADE + 0.5 + 1); // +1 line before to avoid conversion error to int for negative values (int(-0.7) = 0) - maxBin -= 1; // remove the additional 1 from line before - if (maxBin >= NUM_MAIN_BINS) { - std::cout << "DintPropagation: Energy too high " << - ParticleAtGround.back().GetEnergy() << " eV" << - std::endl; - ParticleAtGround.pop_back(); - continue; - } - if (maxBin < 0) { - std::cout << "DintPropagation: Energy too low " << - ParticleAtGround.back().GetEnergy() << " eV" << std::endl; - ParticleAtGround.pop_back(); - continue; - } - int Id = ParticleAtGround.back().GetType(); - if (Id == 22) - inputSpectrum.spectrum[PHOTON][maxBin] += 1.; - else if (Id == 11) - inputSpectrum.spectrum[ELECTRON][maxBin] += 1.; - else if (Id == -11) - inputSpectrum.spectrum[POSITRON][maxBin] += 1.; - else { - std::cout << "DintPropagation: Unhandled particle ID " << Id - << std::endl; - } - ParticleAtGround.pop_back(); - } else - break; - } - - double D = 0; - // only propagate to next particle - if (ParticleAtGround.size() > 0) - D = redshift2LightTravelDistance(ParticleAtGround.back().Getz()); - - InitializeSpectrum(&outputSpectrum); - dint.propagate(currentDistance / Mpc, D / Mpc, &inputSpectrum, - &outputSpectrum, aCutcascade_Magfield); - SetSpectrum(&inputSpectrum, &outputSpectrum); - } // while (secondaries.size() > 0) - - AddSpectrum(&finalSpectrum, &inputSpectrum); - - DeleteSpectrum(&outputSpectrum); - DeleteSpectrum(&inputSpectrum); - } // dint call - } - - infile.close(); - - // output - outfile << "# logE photons electrons positrons\n"; - outfile << "# - logE: energy bin center \n"; - outfile << "# - photons, electrons, positrons: total flux weights\n"; - for (int j = 0; j < finalSpectrum.numberOfMainBins; j++) { - double logEc = MIN_ENERGY_EXP + 0.05 + j * 1. / BINS_PER_DECADE; - outfile << std::setw(5) << logEc; - for (int i = 0; i < 3; i++) { - outfile << std::setw(13) << finalSpectrum.spectrum[i][j]; - } - outfile << "\n"; - } - outfile.close(); - - DeleteSpectrum(&finalSpectrum); - Delete_dCVector(&energyGrid); - Delete_dCVector(&energyWidth); -} - -} // namespace crpropa diff --git a/src/module/EMCascade.cpp b/src/module/EMCascade.cpp deleted file mode 100644 index 924192e3c..000000000 --- a/src/module/EMCascade.cpp +++ /dev/null @@ -1,184 +0,0 @@ -#include "crpropa/module/EMCascade.h" -#include "crpropa/Cosmology.h" -#include "crpropa/Units.h" - -#include "dint/DintEMCascade.h" -#include "kiss/logger.h" - -#include -#include -#include -#include -#include -#include - -namespace crpropa { - -EMCascade::EMCascade() : nE(170), logEmin(7), logEmax(24), dlogE(0.1) { - KISS_LOG_WARNING << "EMCascade is deprecated and is no longer supported. Please use the EM* (EMPairProduction, EMInverseComptonScattering, ...) modules instead.\n"; - setDistanceBinning(1000 * Mpc, 1000); -} - -void EMCascade::setDistanceBinning(double Dmax, int nD) { - this->Dmax = Dmax; - this->nD = nD; - this->dD = Dmax / nD; - init(); -} - -void EMCascade::init() { - photonHist.reserve(nD * nE); - photonHist.assign(nD * nE, 0); - electronHist.reserve(nD * nE); - electronHist.assign(nD * nE, 0); - positronHist.reserve(nD * nE); - positronHist.assign(nD * nE, 0); -} - -std::string EMCascade::getDescription() const { - std::stringstream s; - s << "EMCascade"; - return s.str(); -} - -void EMCascade::process(Candidate *candidate) const { - int id = candidate->current.getId(); - if ((id != 22) and (id != 11) and (id != -11)) - return; - - candidate->setActive(false); - - double logE = log10(candidate->current.getEnergy() / eV); - double D = candidate->current.getPosition().getR(); // distance to (0,0,0) - - if ((logE < logEmin) or (logE > logEmax)) - return; - if (D > Dmax) - return; - - int iE = (logE - logEmin) / dlogE; - int iD = D / dD; - int i = (iD * nE) + iE; - -#pragma omp critical - { - if (id == 22) - photonHist[i] += 1; - else if (id == 11) - electronHist[i] += 1; - else - positronHist[i] += 1; - } -} - -void EMCascade::save(const std::string &filename) { - std::ofstream outfile(filename.c_str()); - if (!outfile) { - std::stringstream s; - s << "EMCascade: could not open " << filename; - throw std::runtime_error(s.str()); - } - outfile << "# D/Mpc log10(E/eV) nPhotons nElectrons nPositrons\n"; - for (int i = 0; i < (nD * nE); i++) { - div_t divresult = div(i, nE); - double D = (divresult.quot + 0.5) * dD / Mpc; - double logE = logEmin + (divresult.rem + 0.5) * dlogE; - outfile << D << "\t"; - outfile << logE << "\t"; - outfile << photonHist[i] << "\t"; - outfile << electronHist[i] << "\t"; - outfile << positronHist[i] << "\n"; - } - outfile.close(); -} - -void EMCascade::load(const std::string &filename) { - std::ifstream infile(filename.c_str()); - if (!infile) { - std::stringstream s; - s << "EMCascade: could not open " << filename; - throw std::runtime_error(s.str()); - } - - infile.ignore(std::numeric_limits::max(), '\n'); // skip header - double D, lE, h1, h2, h3; - for (int i = 0; i < (nD * nE); i++) { - infile >> D >> lE >> h1 >> h2 >> h3; - if (!infile.good()) - throw std::runtime_error("EMCascde: error reading file"); - photonHist[i] += h1; - electronHist[i] += h2; - positronHist[i] += h3; - } - infile.close(); -} - -void EMCascade::runCascade(const std::string &filename, int IRBFlag, - int RadioFlag, double Bfield, double cutCascade) { - - // set up DINT - std::string dataPath = getDataPath("dint"); - double B = Bfield / gauss; - double h = H0() * Mpc / 1000; - DintEMCascade dint(IRBFlag, RadioFlag, dataPath, B, h, omegaM(), omegaL()); - - Spectrum inputSpectrum, outputSpectrum; - NewSpectrum(&inputSpectrum, nE); - NewSpectrum(&outputSpectrum, nE); - InitializeSpectrum(&outputSpectrum); - - // step-wise cascade calculation - for (int iD = nD - 1; iD >= 0; iD--) { - // make output of previous step the new input and reset output - SetSpectrum(&inputSpectrum, &outputSpectrum); - InitializeSpectrum(&outputSpectrum); - - // add new particles to input - double count = 0; - for (int iE = 0; iE < nE; iE++) { - int i = (iD * nE) + iE; - inputSpectrum.spectrum[PHOTON][iE] += photonHist[i]; - inputSpectrum.spectrum[ELECTRON][iE] += electronHist[i]; - inputSpectrum.spectrum[POSITRON][iE] += positronHist[i]; - count += inputSpectrum.spectrum[PHOTON][iE]; - count += inputSpectrum.spectrum[ELECTRON][iE]; - count += inputSpectrum.spectrum[POSITRON][iE]; - } - // skip step if input spectrum empty - if (count == 0) - continue; - - // start and stop distance [Mpc,light travel] from bin center to bin center - double D1 = comoving2LightTravelDistance( (iD + 0.5) * dD ); - double D0 = comoving2LightTravelDistance( std::max((iD - 0.5) * dD, 0.) ); - - // propagate distance step - dint.propagate(D1/Mpc, D0/Mpc, &inputSpectrum, &outputSpectrum, cutCascade); - } - - // write output - std::ofstream outfile(filename.c_str()); - if (!outfile) { - std::stringstream s; - s << "EMCascade: could not open " << filename; - throw std::runtime_error(s.str()); - } - outfile << "# log10(E/eV) photons electrons positrons\n"; - for (int iE = 0; iE < nE; iE++) { - outfile << std::setw(5) << logEmin + (iE + 0.5) * dlogE; - for (int s = 0; s < 3; s++) - outfile << std::setw(13) << outputSpectrum.spectrum[s][iE]; - outfile << "\n"; - } - outfile.close(); - - // clear the histogram - photonHist.assign(nD * nE, 0); - electronHist.assign(nD * nE, 0); - positronHist.assign(nD * nE, 0); - - DeleteSpectrum(&outputSpectrum); - DeleteSpectrum(&inputSpectrum); -} - -} // namespace crpropa diff --git a/test/testDINT.cpp b/test/testDINT.cpp deleted file mode 100644 index cc0229342..000000000 --- a/test/testDINT.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include "dint/gauleg.h" - -#include "gtest/gtest.h" -#include - -namespace crpropa { - -class GaussLegendreIntegrationTest : public testing::Test { -protected: - size_t N; - double *x; - double *w; - double x1, x2; - double analytical, res; - virtual void SetUp() { - N = 16384; - x = new double[N]; - w = new double[N]; - } - - virtual void TearDown() { - delete[] x; - delete[] w; - } -}; - -TEST_F(GaussLegendreIntegrationTest, exp) { - x1 = -1; - x2 = 1; - - res = 0; - Gauleg(x1, x2, x, w, N); - for (int i =0; i < N; i++) - res+= w[i] * exp(x[i]); - - analytical = exp(x2) - exp(x1); - EXPECT_NEAR(res, analytical, 1E-10); -} - -TEST_F(GaussLegendreIntegrationTest, x2) { - x1 = -10; - x2 = 1; - - res = 0; - Gauleg(x1, x2, x, w, N); - for (int i =0; i < N; i++) - res+= w[i] * x[i] * x[i]; - - analytical = 1./3 * (x2*x2*x2 - x1*x1*x1); - EXPECT_NEAR(res, analytical, 1E-10); -} - -TEST_F(GaussLegendreIntegrationTest, x3) { - x1 = -4; - x2 = 7; - - res = 0; - Gauleg(x1, x2, x, w, N); - for (int i =0; i < N; i++) - res+= w[i] * x[i] * x[i] * x[i]; - - analytical = 1./4 * (x2*x2*x2*x2 - x1*x1*x1*x1); - EXPECT_NEAR(res, analytical, 1E-10); -} - -TEST_F(GaussLegendreIntegrationTest, cosx) { - x1 = -2; - x2 = 3; - - res = 0; - Gauleg(x1, x2, x, w, N); - for (int i =0; i < N; i++) - res+= w[i] * cos(x[i] * 1234); - - analytical = 1./1234 * (sin(x2 * 1234 ) - sin(x1 * 1234)); - EXPECT_NEAR(res, analytical, 1E-10); -} - -TEST_F(GaussLegendreIntegrationTest, sinx) { - x1 = -M_PI; - x2 = M_PI; - - res = 0; - Gauleg(x1, x2, x, w, N); - for (int i =0; i < N; i++) - res+= w[i] * sin(x[i]); - - analytical = 0; - EXPECT_NEAR(res, analytical, 1E-10); -} - -int main(int argc, char **argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} - -} // namespace crpropa diff --git a/test/testSimulationExecution.py b/test/testSimulationExecution.py index 1db919033..7e67c9dc8 100644 --- a/test/testSimulationExecution.py +++ b/test/testSimulationExecution.py @@ -37,8 +37,11 @@ def runTest(self): sim.add(crp.NuclearDecay()) sim.add(crp.ElectronPairProduction(CMB)) sim.add(crp.ElectronPairProduction(IRB)) + sim.add(crp.EMPairProduction(CMB)) + sim.add(crp.EMPairProduction(IRB)) + sim.add(crp.EMInverseComptonScattering(CMB)) + sim.add(crp.EMInverseComptonScattering(IRB)) sim.add(crp.MinimumEnergy(1 * crp.EeV)) - sim.add(crp.EMCascade()) # observer obs = crp.Observer() From aa12847fde7e17702d4fb2264a69a475388417a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?JulienD=C3=B6rner?= Date: Thu, 26 Oct 2023 12:27:17 +0200 Subject: [PATCH 2/5] remove EleCa --- CMakeLists.txt | 6 - include/CRPropa.h | 1 - include/crpropa/module/EMCascade.h | 56 --- include/crpropa/module/PhotonEleCa.h | 35 -- libs/EleCa/CMakeLists.txt | 17 - libs/EleCa/include/EleCa/Common.h | 32 -- libs/EleCa/include/EleCa/Constants.h | 63 --- libs/EleCa/include/EleCa/EnergyLoss.h | 31 -- libs/EleCa/include/EleCa/Particle.h | 59 --- libs/EleCa/include/EleCa/Process.h | 84 ---- libs/EleCa/include/EleCa/Propagation.h | 68 --- libs/EleCa/src/Common.cpp | 51 -- libs/EleCa/src/EnergyLoss.cpp | 612 ----------------------- libs/EleCa/src/Particle.cpp | 100 ---- libs/EleCa/src/Process.cpp | 227 --------- libs/EleCa/src/Propagation.cpp | 646 ------------------------- libs/EleCa/src/XLoss_CBR.h | 317 ------------ python/2_headers.i | 1 - src/module/PhotonEleCa.cpp | 81 ---- 19 files changed, 2487 deletions(-) delete mode 100644 include/crpropa/module/EMCascade.h delete mode 100644 include/crpropa/module/PhotonEleCa.h delete mode 100644 libs/EleCa/CMakeLists.txt delete mode 100644 libs/EleCa/include/EleCa/Common.h delete mode 100644 libs/EleCa/include/EleCa/Constants.h delete mode 100644 libs/EleCa/include/EleCa/EnergyLoss.h delete mode 100644 libs/EleCa/include/EleCa/Particle.h delete mode 100644 libs/EleCa/include/EleCa/Process.h delete mode 100644 libs/EleCa/include/EleCa/Propagation.h delete mode 100644 libs/EleCa/src/Common.cpp delete mode 100644 libs/EleCa/src/EnergyLoss.cpp delete mode 100644 libs/EleCa/src/Particle.cpp delete mode 100644 libs/EleCa/src/Process.cpp delete mode 100644 libs/EleCa/src/Propagation.cpp delete mode 100644 libs/EleCa/src/XLoss_CBR.h delete mode 100644 src/module/PhotonEleCa.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 68cfd4016..48406997c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,11 +164,6 @@ add_subdirectory(libs/sophia) list(APPEND CRPROPA_EXTRA_LIBRARIES sophia gfortran) list(APPEND CRPROPA_EXTRA_INCLUDES libs/sophia) -# EleCa (provided) -add_subdirectory(libs/EleCa) -list(APPEND CRPROPA_EXTRA_LIBRARIES eleca) -list(APPEND CRPROPA_EXTRA_INCLUDES libs/EleCa/include) - # GlacticMagneticLenses option(ENABLE_GALACTICMAGETICLENS "Galactic Magnetic Lens" ON) option(INSTALL_EIGEN "Install provided EIGEN headers" OFF) @@ -400,7 +395,6 @@ add_library(crpropa SHARED src/module/ParticleCollector.cpp src/module/PhotoDisintegration.cpp src/module/PhotoPionProduction.cpp - src/module/PhotonEleCa.cpp src/module/PhotonOutput1D.cpp src/module/PropagationBP.cpp src/module/PropagationCK.cpp diff --git a/include/CRPropa.h b/include/CRPropa.h index 6544a8129..b5794a314 100644 --- a/include/CRPropa.h +++ b/include/CRPropa.h @@ -44,7 +44,6 @@ #include "crpropa/module/ParticleCollector.h" #include "crpropa/module/PhotoDisintegration.h" #include "crpropa/module/PhotoPionProduction.h" -#include "crpropa/module/PhotonEleCa.h" #include "crpropa/module/PhotonOutput1D.h" #include "crpropa/module/PropagationBP.h" #include "crpropa/module/PropagationCK.h" diff --git a/include/crpropa/module/EMCascade.h b/include/crpropa/module/EMCascade.h deleted file mode 100644 index d12c4c9b5..000000000 --- a/include/crpropa/module/EMCascade.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef CRPROPA_EMCASCADE_H -#define CRPROPA_EMCASCADE_H - -#include "crpropa/Module.h" - -namespace crpropa { - -/** - @class EMCascade - @brief Collects and deactivates photons, electrons and positrons. Uses DINT to calculate the EM cascade. - */ -class EMCascade: public Module { -private: - // energy and distance binning - int nE, nD; - double logEmin, logEmax, dlogE, Dmax, dD; - - // histograms (distance,energy) of photons, electrons and positrons - mutable std::vector photonHist; - mutable std::vector electronHist; - mutable std::vector positronHist; - void init(); - -public: - EMCascade(); - - /** Change the distance binning */ - void setDistanceBinning( - double Dmax, //!< maximum distance [m] - int nD //!< number of distance bins - ); - - /** Collect and deactivate photons, electrons and positrons */ - void process(Candidate *candidate) const; - - /** Save the unpropagated histogram of EM particles */ - void save(const std::string &filename); - - /** Load the unpropagated histogram of EM particles */ - void load(const std::string &filename); - - /** Calculates the EM cascade with DINT */ - void runCascade( - const std::string &filename, //!< output filename - int IRBFlag = 4, //!< EBL background 0: high, 1: low, 2: Primack, 4: Stecker'06 - int RadioFlag = 4, //!< radio background 0: high, 1: medium, 2: obs, 3: none, 4: Protheroe'96 - double Bfield = 1E-13, //!< magnetic field strength [T], default = 1 nG - double cutCascade = 0 //!< a-parameter, see CRPropa 2 paper - ); - - std::string getDescription() const; -}; - -} // namespace crpropa - -#endif // CRPROPA_EMCASCADE_H diff --git a/include/crpropa/module/PhotonEleCa.h b/include/crpropa/module/PhotonEleCa.h deleted file mode 100644 index c3238e6fe..000000000 --- a/include/crpropa/module/PhotonEleCa.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef CRPROPA_PHOTONELECA_H -#define CRPROPA_PHOTONELECA_H - -#include "crpropa/Module.h" -#include "crpropa/magneticField/MagneticField.h" -#include "crpropa/Referenced.h" - -#include -#include - -// forward declaration -namespace eleca { -class Propagation; -} - -namespace crpropa { - -class PhotonEleCa: public Module { -private: - std::auto_ptr propagation; - mutable std::ofstream output; - Vector3d observer; - bool saveOnlyPhotonEnergies; -public: - PhotonEleCa(const std::string background, const std::string &outputFilename); - ~PhotonEleCa(); - void process(Candidate *candidate) const; - std::string getDescription() const; - void setObserver(const Vector3d &position); - void setSaveOnlyPhotonEnergies(bool photonsOnly); -}; - -} // namespace crpropa - -#endif // CRPROPA_PHOTONELECA_H diff --git a/libs/EleCa/CMakeLists.txt b/libs/EleCa/CMakeLists.txt deleted file mode 100644 index db3e4ae68..000000000 --- a/libs/EleCa/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.6) - -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) - -add_library(eleca STATIC - src/Common - src/EnergyLoss - src/Particle - src/Process - src/Propagation -) - -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - SET_TARGET_PROPERTIES(eleca PROPERTIES COMPILE_FLAGS "-fPIC -ffast-math -D__extern_always_inline=inline") -else() - SET_TARGET_PROPERTIES(eleca PROPERTIES COMPILE_FLAGS "-fPIC -ffast-math") -endif() diff --git a/libs/EleCa/include/EleCa/Common.h b/libs/EleCa/include/EleCa/Common.h deleted file mode 100644 index 627f1af2c..000000000 --- a/libs/EleCa/include/EleCa/Common.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef ELECA_COMMON_H_ -#define ELECA_COMMON_H_ - -namespace eleca { - -double z2Mpc(double z); -double Mpc2z(double D); -double Uniform(double min, double max); - -// set the seed for the random generator. If 0, current ime is used -void setSeed(long int seedval=0); - -void setUniformCallback(double (*Uniform)(double min, double max)); - - -// integer pow implementation as template that is evaluated at compile time -template -inline double pow_integer(double base) -{ - return pow_integer<(exponent >> 1)>(base*base) * (((exponent & 1) > 0) ? base : 1); -} - -template <> -inline double pow_integer<0>(double base) -{ - return 1; -} - - -} // namespace eleca - -#endif // ELECA_COMMON_H_ diff --git a/libs/EleCa/include/EleCa/Constants.h b/libs/EleCa/include/EleCa/Constants.h deleted file mode 100644 index 7263e116d..000000000 --- a/libs/EleCa/include/EleCa/Constants.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef ELECA_CONSTANTS_H_ -#define ELECA_CONSTANTS_H_ - -#include - -namespace eleca { - -static const double cPI = M_PI; - -static const int POINTS_VERY_FEW = 100; - -static const double M2MPC = 3.240779e-17 / 1.0e6; -static const double KM2MPC = 3.240779e-20; -static const double S2YR = 3.168808781403e-08; -static const double H0 = 70.4; -static const double H0y = H0 * (double) KM2MPC / S2YR; // H0 per years -static const double OC = 0.227; // Dark matter density -static const double OB = 0.0456; // Baryon density -static const double OM = OB + OC; // Matter density -static const double OL = 0.728; // Dark energy density - -static const double K_CBR = 1.318684673251832e+13; // =1/pi**2/hbarc**3 [eV^-3 cm^-3] -static const double eV2J = 1.602176487e-19; // from eV to J -static const double ElectronMass = 0.510998918e6; // [eV/c^2] -static const double K_boltz = 8.617342294984e-5; // [eV/K ] Boltzman constant -static const double C_speed = 299792458; // [m/s] speed of light -static const double SigmaThompson = 6.6524e-25; // cm**2 - -static const double T_CMB = 2.725; // [K] // evolution 2.725*(1-z) 1012.3164 -static const double T_COB = 5270; // [K] // Visible [380 - 760] nm. Scelgo 550 -static const double T_CIB = 1.45e+02; // [k] Middle IR 5 to (25-40) µm according to Nasa. scelgo 20e-6 m -static const double T_CRB = 3e-03; // [k] ~ cm - 10m. scelgo ~1 m - -static const double CMB_en = K_boltz * T_CMB; //2.348e-4; // [eV] -static const double CRB_en = K_boltz * T_CRB; -static const double COB_en = K_boltz * T_COB; -static const double CIB_en = K_boltz * T_CIB; -static const double CIOB_en = CIB_en + COB_en; // [eV] - -static const double h_Planck = 4.135667e-15; // [eV s]// -static const double hcut_Planck = h_Planck / 2 / cPI; // [eV s] hcut = h/2Pi [Js] -static const double LambdaCompton = hcut_Planck / (ElectronMass / C_speed); - -static const double eps_ph_inf_urb = 4.1e-12; // [eV] -static const double eps_ph_inf_cmb = 0.825e-6; // [eV] -static const double eps_ph_inf_cib = 2e-3; // [eV] -static const double eps_ph_inf_cob = 5e-2; // [eV] -static const double eps_ph_inf_ciob = 2e-3; // [eV] - -static const double eps_ph_sup_urb = eps_ph_inf_cmb; //4e-5; // [eV] -static const double eps_ph_sup_cmb = eps_ph_inf_cob; // [eV] -static const double eps_ph_sup_cob = 9.9; // [eV] -static const double eps_ph_sup_cib = 0.8; // [eV] -static const double eps_ph_sup_ciob = 9.9; // [eV] - -static const double eps_ph_sup_global = eps_ph_sup_cob; // [eV] *global -static const double eps_ph_inf_global = eps_ph_inf_urb; // [eV] *global - - - -} // namespace eleca - -#endif // ELECA_CONSTANTS_H_ diff --git a/libs/EleCa/include/EleCa/EnergyLoss.h b/libs/EleCa/include/EleCa/EnergyLoss.h deleted file mode 100644 index 6cd954bc6..000000000 --- a/libs/EleCa/include/EleCa/EnergyLoss.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef ELECA_ENERGY_LOSS_H_ -#define ELECA_ENERGY_LOSS_H_ - -namespace eleca { - -class Particle; -class Process; - -double dTdZ(double z); -double betaRsh(double z); -double fLossAdiabatic(double E, double z); -double AdiabaticELoss(double z0, double z, double E0); -double MeanRateSynchrotronLoss(double E, double B); -double ESynchrotronAdiabaticLoss(double z, double E, double B); - -void InitRK(); -double EnergyLoss1D(double Energy, double z0, double zfin, double B); -double dSigmadE_ICS(double Ee, double Eer, double s, double theta); -double dSigmadE_PP(double Ee, double E0, double eps, double theta, double s); -double ExtractPPSecondariesEnergy(Particle &pi, Particle &pt); -double ExtractPPSecondariesEnergy(Process &proc); -double ExtractICSSecondariesEnergy(Particle &pi, Particle &pt); -double ExtractICSSecondariesEnergy(Process &proc); -double ExtractTPPSecondariesEnergy(Particle &pi, Particle &pt); -double ExtractTPPSecondariesEnergy(Process &proc); -double ExtractDPPSecondariesEnergy(double E0); - -double __extractICSSecondaries(double Ee, double s, double theta); -} // namespace eleca - -#endif // ELECA_ENERGY_LOSS_H_ diff --git a/libs/EleCa/include/EleCa/Particle.h b/libs/EleCa/include/EleCa/Particle.h deleted file mode 100644 index b7b3ec176..000000000 --- a/libs/EleCa/include/EleCa/Particle.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef ELECA_PARTICLE_H_ -#define ELECA_PARTICLE_H_ - -#include "Constants.h" - -namespace eleca { - -class Particle { -private: - int ftype; - double fE0ph; - double fz0ph; - double fbeta; - double fmass; - bool fIsGood; - int fwi; - int fgeneration; - -public: - Particle(); - Particle(int _ft, double _fE, double _fz, int _fgeneration = 0); - ~ Particle(); - bool IsGood(); - int GetType() const; - - void SetType(int _ft); - - int GetWeigth() const; - - void SetWeigth(int _wi); - - double GetEnergy() const; - - void SetEnergy(double _fE); - - double Getz() const; - - void Setz(double _fz); - - double GetMass() const; - - double GetBeta() const; -// -// bool GetStatus() { -// fIsGood = IsGood(); -// return fIsGood; -// } - - void SetBetaAndMass(); - - int Generation(); - - - -}; - -} // namespace eleca - -#endif // ELECA_PARTICLE_H_ diff --git a/libs/EleCa/include/EleCa/Process.h b/libs/EleCa/include/EleCa/Process.h deleted file mode 100644 index 07f8e047a..000000000 --- a/libs/EleCa/include/EleCa/Process.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef ELECA_PROCESS_H_ -#define ELECA_PROCESS_H_ - -#include "Particle.h" - -#include -#include - -namespace eleca { - -class Process { - -public: - - enum Name - { - NONE, - PP, - DPP, - TPP, - ICS - }; - - double flambda; - double fsmin; - double fsmax; - double fCMEnergy; - double fInteractionAngle; - double feps_inf; - double feps_sup; - Particle fPi; - Particle fPt; - - std::string fback; - double fbackdensity; - - Process(); - Process(const Process&); - Process(Particle&, Particle&); - Process(Particle&, Particle&, Process::Name); - - ~Process(); - - void SetName(Process::Name nm); - const Process::Name &GetName() const; - - void SetInteractionAngle(double a); - double GetInteractionAngle() const; - - void SetLambda(double le); - double GetLambda() const; - - void SetLimits(double smin, double smax); - void SetLimits(Particle& p1, Process::Name nameproc); - void SetLimits(); - - void SetMax(double smax); - void SetMin(double smin); - double GetMin() const; - double GetMax() const; - - void SetCMEnergy(double s); - - void SetCMEnergy(Particle p1, Particle pb); - - void SetCMEnergy(); - double GetCMEnergy() const; - - void SetIncidentParticle(const Particle& p1); - void SetTargetParticle(Particle& p1); - const Particle &GetIncidentParticle() const; - const Particle &GetTargetParticle() const; - - const std::string &GetBackground() const; - void SetBackground(std::string BackRad); - -private: - - Process::Name _name; -}; - -} // namespace - -#endif diff --git a/libs/EleCa/include/EleCa/Propagation.h b/libs/EleCa/include/EleCa/Propagation.h deleted file mode 100644 index b3db0faec..000000000 --- a/libs/EleCa/include/EleCa/Propagation.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef ELECA_PROPAGATION_H -#define ELECA_PROPAGATION_H - -#include "EleCa/Particle.h" -#include "EleCa/Process.h" - -#include -#include - -namespace eleca { - -class Process; -class Propagation { - -private: - - double vPPle[1101]; - double vDPPle[1101]; - double vTPPle[1101]; - double vICSle[1101]; - double vEtab[1101]; - - std::vector BkgE, BkgA; - std::string Bkg; - double fEthr; - double _dEtab; - - double magneticFieldStrength; -public: - - Propagation(); - - void SetEthr(double eth) {fEthr = eth;}; - double GetEthr(); - ~Propagation(); - - void WriteOutput(std::ostream &out, Particle &p1, - std::vector &part) const; - - void ReadTables(const std::string &file); - void InitBkgArray(const std::string &BackRad); - - double GetMeanThetaBFDeflection(double Bin, double Ein, int ptype, - double Lin) const; - double GetLambdaTab(const Process &proc, Process::Name procName) const; - double ExtractMinDist(Process &proc, int type, double R, double R2, - std::vector &Etarget) const; - std::vector GetEtarget(Process &proc, - const Particle &particle) const; - void Propagate(Particle &curr_particle, - std::vector &ParticleAtMatrix, - std::vector &ParticleAtGround, - bool dropParticlesBelowEnergyThreshold = true) const; - double ExtractPhotonEnergyMC(double z, Process &proc) const; - double ShootPhotonEnergyMC(double z) const; - double ShootPhotonEnergyMC(double Emin, double z) const; - void SetInitVar(std::vector > bk, - std::vector > *le) const; - - void SetB(double B) - { - magneticFieldStrength = B; - } -}; - -} // namespace eleca - -#endif // ELECA_PROPAGATION_H diff --git a/libs/EleCa/src/Common.cpp b/libs/EleCa/src/Common.cpp deleted file mode 100644 index 32a1af8c5..000000000 --- a/libs/EleCa/src/Common.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "EleCa/Common.h" -#include "EleCa/Constants.h" - -#include -#include -#include -#include - -#include - -namespace eleca { - -double z2Mpc(double z) { - if (z < 0.4) { - return ((double) C_speed / 1000. / H0) * z; - } else { - // AV Uryson, Physics Particles and Nuclei, 2006, Vol. 37, No. 3, pp. 347 67 - // Assuming flat-matter-dominated cosmology. Error is negligible - return ((double) C_speed / 1000. / H0) * (2. / 3.) - * (1 - pow(1. + z, -1.5)); - } -} - -double Mpc2z(double D) { - if (D < 1700.) { - return (double) D / ((double) C_speed / 1000. / H0); - } else { - // AV Uryson, Physics Particles and Nuclei, 2006, Vol. 37, No. 3, pp. 347 67 - // Assuming flat-matter-dominated cosmology. Error is negligible - return pow(1 - (double) D / ((2. / 3.) * (double) C_speed / 1000. / H0), - -2. / 3.) - 1; - } -} - - -void setSeed(long int seedval) -{ - if (seedval == 0) - { // use system time - time(&seedval); - } - ::srand48(seedval); -} - - -double Uniform(double min, double max) { - return min + (max - min) * ::drand48(); -} - -} // namespace eleca - diff --git a/libs/EleCa/src/EnergyLoss.cpp b/libs/EleCa/src/EnergyLoss.cpp deleted file mode 100644 index c226d06f8..000000000 --- a/libs/EleCa/src/EnergyLoss.cpp +++ /dev/null @@ -1,612 +0,0 @@ -#ifndef ELECA_ENERGY_LOSS_H_ -#define ELECA_ENERGY_LOSS_H_ - -#include "EleCa/EnergyLoss.h" -#include "EleCa/Process.h" -#include "EleCa/Common.h" - -#include -#include -#include -#include - -namespace eleca { - -static const int MC_SAMPLING = 1000; - -double dTdZ(double z) { - // See High Energy Cosmic Rays, Todor Stanev, Pag. 232 (2009) - return -1. - / ((1 + z) * H0y - * sqrt( - pow_integer<3>(1. + z) * OM + OL - + (1 - OM - OL) * pow_integer<2>(1. + z))); -} - -double betaRsh(double z) { - // Energy loss term due to cosmological redshift - return H0y - * sqrt(pow_integer<3>(1. + z) * OM + OL + (1 - OM - OL) * pow_integer<2>(1. + z)); -} - -double fLossAdiabatic(double E, double z) { - return -dTdZ(z) * betaRsh(z) * E; -} - -double AdiabaticELoss(double z0, double z, double E0) { - return E0 * (double) (1. + z) / (1. + z0); -} - -// ################################################## -// # Synchrotron rate of Energy loss averaged over angles -// ################################################## -// for an ensemble of electrons that are scattered randomly in all directions: -double MeanRateSynchrotronLoss(double E, double B) { - double dEdt = 0; - if (B > 0) - dEdt = 3.79e-6 * pow_integer<2>(E / 1e9 * B) * 1e9 / E; - - return dEdt; -} - -// #################################### -// # Synchrotron Energy loss -// #################################### - -double ESynchrotronAdiabaticLoss(double z, double E, double B) { - double dEdt = MeanRateSynchrotronLoss(E, B); - - return E * (-dTdZ(z) * (dEdt + betaRsh(z))); -} - -static const int RK_ORDER = 6; -static double gRKa[RK_ORDER + 1]; -static double gRKc[RK_ORDER + 1]; -static double gRKcs[RK_ORDER + 1]; -static double gRKb[RK_ORDER + 1][RK_ORDER]; -static bool gRKInitialized = false; - -void InitRK() { - if (gRKInitialized) - return; - - // Current Runge-Kutta method for solving ODE - gRKa[0] = 0; - gRKa[1] = 0; - gRKa[2] = 1. / 5.; - gRKa[3] = 3. / 10.; - gRKa[4] = 3. / 5.; - gRKa[5] = 1.; - gRKa[6] = 7. / 8.; - - for (int i = 0; i < RK_ORDER + 1; i++) { - for (int j = 0; j < RK_ORDER; j++) - { - gRKb[i][j] = 0.; - } - } - - gRKb[2][1] = 1. / 5.; - gRKb[3][1] = 3. / 40.; - gRKb[3][2] = 9. / 40.; - gRKb[4][1] = 3. / 10.; - gRKb[4][2] = -9. / 10.; - gRKb[4][3] = 6. / 5.; - gRKb[5][1] = -11. / 54.; - gRKb[5][2] = 5. / 2.; - gRKb[5][3] = -70. / 27.; - gRKb[5][4] = 35. / 27.; - gRKb[6][1] = 1631. / 55296.; - gRKb[6][2] = 175. / 512.; - gRKb[6][3] = 575. / 13824.; - gRKb[6][4] = 44275. / 110592.; - gRKb[6][5] = 253. / 4096.; - - gRKc[0] = 0.; - gRKc[1] = 37. / 378.; - gRKc[2] = 0.; - gRKc[3] = 250. / 621.; - gRKc[4] = 125. / 594.; - gRKc[5] = 0.; - gRKc[6] = 512. / 1771.; - - gRKcs[0] = 0.; - gRKcs[1] = 2825. / 27648.; - gRKcs[2] = 0.; - gRKcs[3] = 18575. / 48384.; - gRKcs[4] = 13525. / 55296.; - gRKcs[5] = 277. / 14336.; - gRKcs[6] = 1. / 4.; - - gRKInitialized = true; -} - -//=================================== - -double EnergyLoss1D(double Energy, double z0, double zfin, double B) { - - double zStep = 2.5e-5; - -#pragma omp critical - { - InitRK(); - } - double k1, k2, k3, k4, k5, k6; - - bool FLAG_PROPAG = 1; - - while (z0 > zfin && FLAG_PROPAG) { - - k1 = -zStep * ESynchrotronAdiabaticLoss(z0 - zStep, Energy, B); - k2 = -zStep - * ESynchrotronAdiabaticLoss(z0 - zStep * gRKa[2], - Energy + k1 * gRKb[2][1], B); - - k3 = -zStep - * ESynchrotronAdiabaticLoss(z0 - zStep * gRKa[3], - Energy + k1 * gRKb[3][1] + k2 * gRKb[3][2], B); - k4 = -zStep - * ESynchrotronAdiabaticLoss(z0 - zStep * gRKa[4], - Energy + k1 * gRKb[4][1] + k2 * gRKb[4][2] - + k3 * gRKb[4][3], B); - k5 = -zStep - * ESynchrotronAdiabaticLoss(z0 - zStep * gRKa[5], - Energy + k1 * gRKb[5][1] + k2 * gRKb[5][2] - + k3 * gRKb[5][3] + k4 * gRKb[5][4], B); - k6 = -zStep - * ESynchrotronAdiabaticLoss(z0 - zStep * gRKa[6], - Energy + k1 * gRKb[6][2] + k2 * gRKb[6][2] - + k3 * gRKb[6][3] + k4 * gRKb[6][4] - + k5 * gRKb[6][5], B); - - Energy = Energy - + (k1 * gRKc[1] + k2 * gRKc[2] + k3 * gRKc[3] + k4 * gRKc[4] - + k5 * gRKc[5] + k6 * gRKc[6]); - - z0 -= zStep; - - if (fabs(z0) < 1e-8 || z0 < 0) { - z0 = 0.; - FLAG_PROPAG = 0; - } - if (fabs(z0 - zfin) < 1e-8 || z0 < zfin) - z0 = zfin; - - if (Energy < 1e9) { - FLAG_PROPAG = 0; - } - - if (std::isnan(Energy)) - return 0; - } - - return Energy; -} - -double dSigmadE_ICS(double Ee, double Eer, double s, double theta) { - /*! - Differential cross-section for inverse Compton scattering. from lee, eq. 23 - */ - - double beta = (s - ElectronMass * ElectronMass) - / (s + ElectronMass * ElectronMass); - // boundaries rewritten to avoid error due to numerical uncertainties - if ((1 - Eer / Ee) / (Eer / Ee +1) - beta > DBL_EPSILON || Eer / Ee > 1) - { - std::cerr << "ERROR, Energy outside limits for ICS [Lee96]! " << std::endl; - std::cerr << " Eer = " << Eer << " Ee = " << Ee << " Eer/Ee = " << - Eer / Ee << " (1 - beta) / (1 + beta) = " << (1 - beta) / (1 + beta) << - " beta = " << beta << std::endl; - return 0.; - } - else - { - double q = ((1 - beta) / beta) * (1 - Ee / Eer); - double A = Eer / Ee + Ee / Eer; - double k = (3.0 / 8.0) * (SigmaThompson * ElectronMass * ElectronMass) - / (s * Ee); - double dsigmadE = k * ((1 + beta) / beta) * (A + 2 * q + q * q); - - return dsigmadE; - } -} - - double dSigmadE_PP(double Ee, double E0, double eps, double theta, double s) { - /*! - Differential cross-section for pair production. - */ - // double s = ElectronMass * ElectronMass + 2 * eps * E0 * (1 - cos(theta)); - double beta = sqrt(1 - 4 * ElectronMass * ElectronMass / s); - - if (Ee / E0 <= 0.5 * (1 - beta) || Ee / E0 >= 0.5 * (1 + beta)) { - std::cerr << "ERROR, Energy outside limits for PP [Lee96]! " - << std::endl; - return 0.; - } else { - double q = E0 - Ee; - double k = (3.0 / 4.0) * (SigmaThompson * ElectronMass * ElectronMass) - / (s * E0); - double A = Ee / q + q / Ee; - double B = E0 * (1 - beta * beta) * (1. / Ee + 1. / q); - double C = -((1 - beta * beta) * (1 - beta * beta) * E0 * E0 / 4.0) - * pow_integer<2>(1. / Ee + 1. / q); - - double dsigmadE = k * (A + B + C); - - return dsigmadE; - } -} - -/// Differential cross-section for pair production for x = E/E0 -double dSigmadE_PPx(double x, double beta) { - - if ((x - 0.5 * (1 - beta)) < -1 * DBL_EPSILON || x - 0.5 * (1 + beta) > DBL_EPSILON ) { - std::cerr << "ERROR, Energy outside limits for PP [Lee96]! " << std::endl; - std::cerr << " x = " << x << " 0.5* (1-beta) = " << 0.5 * (1 - beta) << " 0.5* (1+beta) = " << 0.5 * (1 + beta) << " beta = " << beta << std::endl; - return 0.; - } else { - - const double A = (x / (1. - x) + (1. - x) / x ); - const double B = (1. / x + 1. / (1. - x) ); - - return A + (1. - beta*beta) * B - (1. - beta*beta) * (1. - beta*beta) / 4. * B*B; - } -} - - -/// Hold an data array to interpolate the energy distribution on -class PPSecondariesEnergyDistribution -{ - private: - double *_data; - size_t _Ns; - size_t _Nrer; - double _s_min; - double _s_max; - double _dls; - - public: - PPSecondariesEnergyDistribution(double s_min = 4. * ElectronMass * ElectronMass, double s_max =1e21, - size_t Ns = 1000, size_t Nrer = 1000 ) - { - if (s_min < 4.*ElectronMass*ElectronMass) - { - std::cerr << "Warning: Minimum COM Energy in PP Interpolation s = " << s_min << " < (2*m_e)**2 selected. Setting to s_min = (2*m_e)**2.\n" ; - s_min = 4.*ElectronMass*ElectronMass; - } - _Ns = Ns; - _Nrer = Nrer; - _s_min =s_min; - _s_max = s_max; - _data = new double[Ns*Nrer]; - - _dls = (log(s_max) - log(s_min)) / (Ns); - - for (size_t i = 0; i < Ns; i++) - { - const double s = s_min * exp(i*_dls); - double beta = sqrt(1. - 4. * ElectronMass*ElectronMass /s); - - double x0 = log((1.-beta) / 2.); - double dx = ( log((1. + beta)/2) - log((1.-beta) / 2.)) / (Nrer); - _data[i * Nrer] = exp(x0) ; - for (size_t j = 1; j < Nrer; j++) - { - double x = exp(x0 + j*dx); - _data[i * Nrer + j] = dSigmadE_PPx(x, beta) + _data[i * Nrer + j - 1]; - } - } - } - - // returns pointer to the the integrated distribution for a given s - double* getDistribution(double s) - { - size_t idx = (log(s / _s_min)) / _dls; - double *s0 = &_data[idx * _Nrer]; - return s0; - } - - //samples the integrated distribution and returns Eer(Ee, s) - double sample(double E0, double eps, double theta) - { - double s = 2. * E0 * eps * (1-cos(theta)); - - double *s0 = getDistribution(s); - double rnd = Uniform(0, 1.0) *s0[_Nrer-1]; - - for (size_t i=0; i < _Nrer; i++) - { - if (rnd < s0[i]) - { - double beta = sqrt(1. - 4.* ElectronMass * ElectronMass / s); - - double x0 = log((1.-beta) / 2.); - double dx = ( log((1. + beta)/2) - log((1.-beta) / 2.)) / (_Nrer); - if (Uniform(0, 1.0) < 0.5) - return exp(x0 + (i)*dx) * E0; - else - return E0 * (1-exp(x0 + (i)*dx) ); - } - } - std::cerr << "PPSecondariesEnergyDistribution out of bounds!" << std::endl; - std::cerr << " s0[0] = " << s0[0] << " s0[_Nrer-1] = " << s0[_Nrer-1] << " rnd = " << rnd << std::endl; - throw std::runtime_error("Grave logic error in PPSecondariesEnergyDistribution!"); - } -}; - - - -// Helper function for actual Monte Carlo sampling to avoid code-duplication -double __extractPPSecondariesEnergy(double E0, double eps, double beta) -{ - double theta = M_PI; - - static PPSecondariesEnergyDistribution interpolation; - return interpolation.sample(E0, eps, theta); -} - - -double ExtractPPSecondariesEnergy(Particle &pi, Particle &pt) { - /*! - Input: incident gamma Energy E0, background photon energy eps, - incidence angle theta. - Returns the energy of the produced e+ (e-) - */ - double E0 = pi.GetEnergy(); - double eps = pt.GetEnergy(); - double beta = pi.GetBeta(); - - return __extractPPSecondariesEnergy(E0, eps, beta); -} - - - -double ExtractPPSecondariesEnergy(Process &proc) { - /*! - Input: incident gamma Energy E0, background photon energy eps, - incidence angle theta. - Returns the energy of the produced e+ (e-) - */ - - double E0 = proc.GetIncidentParticle().GetEnergy(); - double s = proc.GetCMEnergy(); - double eps = proc.GetTargetParticle().GetEnergy(); - double theta = M_PI; - s = ElectronMass * ElectronMass + 2 * eps * E0 * (1 - cos(theta)); - double beta = sqrt(1 - 4 * ElectronMass * ElectronMass / s); - // double s2 = ElectronMass * ElectronMass - - return __extractPPSecondariesEnergy(E0, eps, beta); -} - - -/// Hold an data array to interpolate the energy distribution on -class ICSSecondariesEnergyDistribution -{ - private: - double *_data; - size_t _Ns; - size_t _Nrer; - double _s_min; - double _s_max; - double _dls; - - public: - ICSSecondariesEnergyDistribution(double s_min = 1.01 * ElectronMass * ElectronMass /*2.6373E+11*/, double s_max =1e21, - size_t Ns = 1000, size_t Nrer = 1000 ) - { - // ToDo: this boundary is just an estimate - const double l = 1.01; - if (s_min < l * ElectronMass*ElectronMass) - { - std::cerr << "Warning: Minimum COM Energy in ICS Interpolation s = " << s_min << " < " << l << " m_e**2 selected. Setting to s_min = " << l << " m_e**2.\n" ; - s_min = l * ElectronMass*ElectronMass; - } - _Ns = Ns; - _Nrer = Nrer; - _s_min =s_min; - _s_max = s_max; - _data = new double[Ns*Nrer]; - - double theta = M_PI; - - _dls = (log(s_max) - log(s_min)) / (Ns); - double dls_min = log(s_min); - - for (size_t i = 0; i < Ns; i++) - { - const double s = exp(dls_min + i*_dls); - double beta = (s - ElectronMass * ElectronMass) / (s + - ElectronMass * ElectronMass); - - double eer_0 = log((1-beta) / (1+beta)); - double deer = - log((1-beta) / (1+beta)) / (Nrer); - - const double Ee = 1E21; - _data[i * Nrer] = dSigmadE_ICS(Ee, Ee * exp(eer_0), s, theta); - for (size_t j = 1; j < Nrer; j++) - { - - double Eer = Ee * exp(eer_0 + (j)*deer); - _data[i * Nrer + j] = dSigmadE_ICS(Ee, Eer , s, theta) + _data[i * Nrer + j - 1]; - } - } - } - - // returns pointer to the the integrated distribution for a given s - double* getDistribution(double s) - { - size_t idx = (log(s / _s_min)) / _dls; - double *s0 = &_data[idx * _Nrer]; - return s0; - } - - //samples the integrated distribution and returns Eer(Ee, s) - double sample(double Ee, double s) - { - double *s0 = getDistribution(s); - double rnd = Uniform(0, 1.0) *s0[_Nrer-1]; - for (size_t i=0; i < _Nrer; i++) - { - if (rnd < s0[i]) - { - double beta = (s - ElectronMass * ElectronMass) / (s + - ElectronMass * ElectronMass); - double eer_0 = log((1-beta) / (1+beta)); - double deer = - log((1-beta) / (1+beta)) / (_Nrer ); - return exp(eer_0 + (i)*deer) * Ee; - } - } - throw std::runtime_error("Grave logic error in sampling ICSSecondariesEnergyDistribution!"); - } -}; - - -// Helper function for actual Monte Carlo sampling to avoid code-duplication -double __extractICSSecondaries(double Ee, double s, double theta) -{ - - static ICSSecondariesEnergyDistribution interpolation; - return interpolation.sample(Ee, s); - - //double beta = (s - ElectronMass * ElectronMass) - // / (s + ElectronMass * ElectronMass); - //bool failed = 1; - - //// reInitialization to zero.. - //double MC_Sampling_Hist[MC_SAMPLING][3]; - //for (int i = 0; i < MC_SAMPLING; i++) { - // for (int j = 0; j < 3; j++) - // MC_Sampling_Hist[i][j] = 0.; - //} - - //double f = pow((double) (1 + beta) / (1 - beta), (double) 1. / MC_SAMPLING); - //int cnt = 0; - //double NormFactor = 0; - - //for (double Eer = f * ((1 - beta) / (1 + beta)) * Ee; Eer <= Ee; Eer *= f) { - // MC_Sampling_Hist[cnt][0] = Eer; - // MC_Sampling_Hist[cnt][1] = dSigmadE_ICS(Ee, Eer, s, theta); - - // NormFactor += MC_Sampling_Hist[cnt][1]; - // MC_Sampling_Hist[cnt][2] = NormFactor; - - // if (MC_Sampling_Hist[cnt][1] > 0.) { - // cnt++; - // } else { - // break; - // } - //} - - //NormFactor = (double) 1. / (double) NormFactor; - - //for (int i = 0; i < cnt; i++) - // MC_Sampling_Hist[i][2] *= NormFactor; - - //double rnd = 0; - //double Eer = 0; - - //while (failed) { - // rnd = Uniform(0, 1.0); - // Eer = 0; - // for (int i = 0; i < cnt - 1; i++) { - // if (MC_Sampling_Hist[i][2] <= rnd <= MC_Sampling_Hist[i + 1][2]) { - // Eer = MC_Sampling_Hist[i][0]; - // failed = 0; - // break; - // } - // } - //} - //return Eer; -} - - -double ExtractICSSecondariesEnergy(Particle &pi, Particle &pt) { - /*! - Input: incident electron energy Ee, background photon energy eps, - incidence angle theta. - Returns the energy of the recoiled e+ (e-) - */ - if (::abs(pi.GetType()) != 11) { - std::cerr << "something wrong in type ExtractICSEnergy " << std::endl; - return 0.; - } - - double Ee = pi.GetEnergy(); - double eps = pt.GetEnergy(); - double theta = M_PI; - double s = 2 * Ee * eps * (1 - pi.GetBeta() * cos(cPI)) - + pi.GetMass() * pi.GetMass(); - - return __extractICSSecondaries(Ee, s, theta); -} - - -double ExtractICSSecondariesEnergy(Process &proc) { - /*! - Input: incident electron energy Ee, background photon energy eps, - incidence angle theta. - Returns the energy of the recoiled e+ (e-) - */ - double Ee = proc.GetIncidentParticle().GetEnergy(); - double s = proc.GetCMEnergy(); - double theta = proc.GetInteractionAngle(); - return __extractICSSecondaries(Ee, s , theta); -} - - -double ExtractTPPSecondariesEnergy(Particle &pi, Particle &pt) { - /* approximation based on A. Mastichiadis et al., - Astroph. Journ. 300:178-189 (1986), eq. 30. - This approx is valid only for alpha >=100 - where alpha = p0*eps*costheta - E0*eps; - for our purposes, me << E0 --> p0~ E0 --> - alpha = E0*eps*(costheta - 1) >= 100; - */ - - double E0 = pi.GetEnergy(); - double eps = pt.GetEnergy(); - double s = 2 * E0 * eps * (1 - pi.GetBeta() * cos(M_PI)) - + pi.GetMass() * pi.GetMass(); - double Epp = 5.7e-1 * pow(eps / ElectronMass, -0.56) * pow(E0 / ElectronMass, 0.44) * ElectronMass; - double Epp2 = E0 - * (1 - 1.768 * pow(s / ElectronMass / ElectronMass, -3.0 / 4.0)) - / 2.0; - //return the energy of each e+/e- in the pair. - return Epp; -} - - -double ExtractTPPSecondariesEnergy(Process &proc) { - /* approximation based on A. Mastichiadis et al., - Astroph. Journ. 300:178-189 (1986), eq. 30. - This approx is valid only for alpha >=100 - where alpha = p0*eps*costheta - E0*eps; - for our purposes, me << E0 --> p0~ E0 --> - alpha = E0*eps*(costheta - 1) >= 100; - */ - - double E0 = proc.GetIncidentParticle().GetEnergy(); - double eps = proc.GetTargetParticle().GetEnergy(); - double Epp = 5.7e-1 * pow(eps/ElectronMass, -0.56) * pow(E0/ElectronMass, 0.44) * ElectronMass; - double s = proc.GetCMEnergy(); - double Epp2 = E0 - * (1 - 1.768 * pow(s / ElectronMass / ElectronMass, -3.0 / 4.0)) - / 2.0; - return Epp; -} - - -double ExtractDPPSecondariesEnergy(double E0) { - /* - we use the same assumption of lee (i.e., all the energy goes equaly shared between only 1 couple of e+e-. - In DPPpaper has been shown that this approximation is valid within -1.5% - */ - if (E0 == 0) - std::cout << "error in extracting DPP: can not be =0 " << std::endl; - return (double) E0 / 2.0; -} - -} // namespace eleca - -#endif // ELECA_ENERGY_LOSS_H_ diff --git a/libs/EleCa/src/Particle.cpp b/libs/EleCa/src/Particle.cpp deleted file mode 100644 index 4a077c0f2..000000000 --- a/libs/EleCa/src/Particle.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include "EleCa/Particle.h" -#include - -namespace eleca { - -Particle::~Particle() { -} - -bool Particle::IsGood() { - double zmax_prop0 = 0.91425; - double zmax_prop1 = -0.101717; - double zmax_prop2 = 0.002855; - double Eloc = log10(fE0ph); - if (fE0ph <=3.0e12) - return 0; //for interaction lengths tab - if (Eloc > 12 && Eloc < 18) - Eloc = 18; - if (fz0ph > zmax_prop0 + zmax_prop1 * Eloc + zmax_prop2 * Eloc * Eloc) - return 0; - return 1; -} - -int Particle::GetType() const { - return ftype; -} - -void Particle::SetType(int _ft) { - ftype = _ft; -} - -int Particle::GetWeigth() const { - return fwi; -} - -void Particle::SetWeigth(int _wi) { - fwi = _wi; -} - -double Particle::GetEnergy() const { - return fE0ph; -} - -void Particle::SetEnergy(double _fE) { - fE0ph = _fE; - SetBetaAndMass(); -} - -double Particle::Getz() const { - return fz0ph; -} - -void Particle::Setz(double _fz) { - fz0ph = _fz; -} - -double Particle::GetMass() const { - return fmass; -} - -double Particle::GetBeta() const { - return fbeta; -} - -void Particle::SetBetaAndMass() { - if (ftype == 22) { - fbeta = 1.0; - fmass = 0; - } - if (abs(ftype) == 11) { - fmass = ElectronMass; - fbeta = (double) sqrt(1 - fmass * fmass / (fE0ph * fE0ph)); - - } -} - -int Particle::Generation() { - return fgeneration; -} - -Particle::Particle(int _ft, double _fE, double _fz, int _fgeneration) { - ftype = _ft; - fE0ph = _fE; - fz0ph = _fz; - SetBetaAndMass(); - fIsGood = IsGood(); - fwi = 1; - fgeneration = _fgeneration; -} - -Particle::Particle() { - ftype = 22; - fE0ph = 0; - fz0ph = 0; - fmass = 0; - fbeta = 0; - fIsGood = 0; - fwi = 1; -} - -} // namespace eleca diff --git a/libs/EleCa/src/Process.cpp b/libs/EleCa/src/Process.cpp deleted file mode 100644 index 8e5138782..000000000 --- a/libs/EleCa/src/Process.cpp +++ /dev/null @@ -1,227 +0,0 @@ -#include "EleCa/Process.h" - -#include -#include -#include - -namespace eleca { - -void Process::SetName(Process::Name nm) { - _name = nm; -} - -const Process::Name &Process::GetName() const { - return _name; -} - -void Process::SetInteractionAngle(double a) { - fInteractionAngle = a; -} -double Process::GetInteractionAngle() const { - return fInteractionAngle; -} - -void Process::SetLambda(double le) { - flambda = le; -} -double Process::GetLambda() const { - return flambda; -} - -void Process::SetLimits(double smin, double smax) { - fsmin = smin; - fsmax = smax; -} - -void Process::SetLimits() { - SetLimits(fPi, _name); -} - -void Process::SetMax(double smax) { - fsmax = smax; -} -void Process::SetMin(double smin) { - fsmin = smin; -} -double Process::GetMin() const { - return fsmin; -} -double Process::GetMax() const { - return fsmax; -} - -void Process::SetCMEnergy(double s) { - fCMEnergy = s; -} - -void Process::SetCMEnergy(Particle p1, Particle pb) { - fCMEnergy = 2 * p1.GetEnergy() * pb.GetEnergy() - * (1 - p1.GetBeta() * cos(fInteractionAngle)) - + p1.GetMass() * p1.GetMass() + pb.GetMass() * pb.GetMass(); -} - -void Process::SetCMEnergy() { - fCMEnergy = 2 * fPi.GetEnergy() * fPt.GetEnergy() - * (1 - fPi.GetBeta() * cos(fInteractionAngle)) - + fPi.GetMass() * fPi.GetMass() + fPt.GetMass() * fPt.GetMass(); - -} - -double Process::GetCMEnergy() const { - return fCMEnergy; -} - -void Process::SetIncidentParticle(const Particle& p1) { - fPi = p1; - SetLimits(); -} -void Process::SetTargetParticle(Particle& p1) { - fPt = p1; - SetLimits(); -} - -const Particle &Process::GetIncidentParticle() const { - return fPi; -} -const Particle &Process::GetTargetParticle() const { - return fPt; -} - -const std::string &Process::GetBackground() const { - return fback; -} - -Process::Process() { - _name = Process::NONE; - SetLimits(0.0, 1.0e23); - flambda = 0; - fCMEnergy = 0; - fInteractionAngle = cPI; - fback = "ALL"; - fbackdensity = 0; - feps_inf = eps_ph_inf_global; - feps_sup = eps_ph_sup_global; -} - -Process::Process(Particle& p1, Particle& p2) { - fPi = p1; - fPt = p2; - if (p1.GetType() == 22) - _name = Process::PP; - else if (abs(p1.GetType()) == 11) { - std::cerr << "NB: by default process set to ICS" << std::endl; - _name = ICS; - } else - _name = Process::NONE; - SetCMEnergy(p1, p2); - flambda = 0; - fInteractionAngle = cPI; - fback = "ALL"; - SetLimits(p1, _name); - fbackdensity = 0; - feps_inf = eps_ph_inf_global; - feps_sup = eps_ph_sup_global; -} - -Process::Process(Particle& p1, Particle& p2, Process::Name name) { - _name = name; - SetCMEnergy(p1, p2); - flambda = 0; - fInteractionAngle = cPI; - fPi = p1; - fPt = p2; - fback = "ALL"; - SetLimits(p1, _name); - fbackdensity = 0; - feps_inf = eps_ph_inf_global; - feps_sup = eps_ph_sup_global; -} - -Process::Process(const Process& proc2) { - _name = proc2.GetName(); - SetLimits(proc2.GetMin(), proc2.GetMax()); - fCMEnergy = proc2.GetCMEnergy(); - fInteractionAngle = proc2.GetInteractionAngle(); - fPi = proc2.GetIncidentParticle(); - fPt = proc2.GetTargetParticle(); - fback = proc2.GetBackground(); - fbackdensity = 0; - feps_inf = eps_ph_inf_global; - feps_sup = eps_ph_sup_global; -} - -Process::~Process() { -} - -//----------- - -void Process::SetBackground(std::string BackRad) { - - fback = BackRad; - - double eps_min = eps_ph_inf_global; - double eps_max = eps_ph_sup_global; - - if (BackRad == "CMB") { - eps_min = eps_ph_inf_cmb; - eps_max = eps_ph_sup_cmb; - } else if (BackRad == "COB") { - eps_min = eps_ph_inf_cob; - eps_max = eps_ph_sup_cob; - } else if (BackRad == "CIB") { - eps_min = eps_ph_inf_cib; - eps_max = eps_ph_sup_cib; - } else if (BackRad == "CIOB") { - eps_min = eps_ph_inf_ciob; - eps_max = eps_ph_sup_ciob; - } else if (BackRad == "URB") { - eps_min = eps_ph_inf_urb; - eps_max = eps_ph_sup_urb; - } - - feps_inf = eps_min; - feps_sup = eps_max; - -#ifdef DEBUG_ELECA - std::cout << "eps range set to " << eps_min << " , " << eps_max - << std::endl; -#endif - -} - -void Process::SetLimits(Particle& p1, Process::Name nameproc) { - if (p1.GetType() != 22 && p1.GetType() != 11 && p1.GetType() != -11) - std::cout << "error in type " << p1.GetType() << " != 11 and !=22 " - << std::endl; - - if (nameproc == Process::PP) { - if (abs(p1.GetType()) != 22) - std::cout << "\nERROR!! wrong particle or process!! " << " PP " - << p1.GetType() << "\n" << std::endl; - fsmin = 2 * ElectronMass * ElectronMass; - fsmax = 4 * p1.GetEnergy() * feps_sup; - } - if (nameproc == Process::DPP) { - if (abs(p1.GetType()) != 22) - std::cout << "\nERROR!! wrong particle or process!! " << " DPP " - << p1.GetType() << "\n" << std::endl; - fsmin = 4 * ElectronMass*ElectronMass; - fsmax = 4 * p1.GetEnergy() * feps_sup; - } - if (nameproc == Process::ICS) { - if (abs(p1.GetType()) != 11) - std::cout << "\nERROR!! wrong particle or process!! " << " ICS " - << p1.GetType() << "\n" << std::endl; - fsmin = 4 * 1e12 * feps_inf + ElectronMass*ElectronMass; //given the min E in lambda - fsmax = 4 * p1.GetEnergy() * feps_inf + p1.GetMass() * p1.GetMass(); - } - if (nameproc == Process::TPP) { - if (abs(p1.GetType()) != 11) - std::cout << "\nERROR!! wrong particle or process!! " << " TPP " - << p1.GetType() << "\n" << std::endl; - fsmin = std::max(4 * 1e12 * feps_inf + ElectronMass*ElectronMass,3 * ElectronMass * ElectronMass); - fsmax = 4 * p1.GetEnergy() * feps_sup + p1.GetMass() * p1.GetMass(); - } -} - -} // namespace diff --git a/libs/EleCa/src/Propagation.cpp b/libs/EleCa/src/Propagation.cpp deleted file mode 100644 index 2359bc068..000000000 --- a/libs/EleCa/src/Propagation.cpp +++ /dev/null @@ -1,646 +0,0 @@ -#include "EleCa/Propagation.h" -#include "EleCa/Particle.h" -#include "EleCa/Process.h" -#include "EleCa/Common.h" -#include "EleCa/EnergyLoss.h" -#include "EleCa/Constants.h" -#include "XLoss_CBR.h" - -#include -#include -#include -#include - -//#define DEBUG_ELECA -namespace eleca { - -Propagation::Propagation() { - fEthr = 1e16; -} - -Propagation::~Propagation() { -} - -void Propagation::ReadTables(const std::string &filename) { - -#ifdef DEBUG_ELECA - std::cout << filename << std::endl; -#endif - - std::ifstream fin(filename.c_str()); - - if (!fin.is_open()) { - std::cerr << "Unable to open lambda_table file: " << filename - << " ! exiting... "; - return; - } - - int k = 0; - double Etab, PPle, ICSle, DPPle, TPPle; - while (fin.good()) { - fin >> Etab >> PPle >> ICSle >> DPPle >> TPPle; - vEtab[k] = Etab; - vPPle[k] = PPle; - vICSle[k] = ICSle; - vDPPle[k] = DPPle; - vTPPle[k] = TPPle; - k++; - } - // store dEtab - _dEtab = log10(vEtab[0] / vEtab[1]); - if (k != 1101) - std::cerr << "Failed to read lambda_table file: " << filename - << "! only " << k << " entries, expected 1101!"; -} - -void Propagation::InitBkgArray(const std::string &BackRad) { - // Routine to build the array of cumulative distribution of - // background photons - - Bkg = BackRad; - BkgE.resize(POINTS_VERY_FEW); - BkgA.resize(POINTS_VERY_FEW); - - if (BackRad == "CMB") { - double de = pow((double) eps_ph_sup_cmb / eps_ph_inf_cmb, - 1. / POINTS_VERY_FEW); - double e = eps_ph_inf_cmb; - for (size_t i = 0; i < POINTS_VERY_FEW; i++) { - BkgE[i] = e; - BkgA[i] = CMBR(e); - e *= de; - } - } - - else if (BackRad == "CIOB") { - double de = pow((double) eps_ph_sup_ciob / eps_ph_inf_ciob, - 1. / POINTS_VERY_FEW); - double e = eps_ph_inf_ciob; - for (size_t i = 0; i < POINTS_VERY_FEW; i++) { - BkgE[i] = e; - BkgA[i] = CIOBR(e); - e *= de; - } - } - - else if (BackRad == "URB") { - double de = pow((double) eps_ph_sup_urb / eps_ph_inf_urb, - 1. / POINTS_VERY_FEW); - double e = eps_ph_inf_urb; - for (size_t i = 0; i < POINTS_VERY_FEW; i++) { - BkgE[i] = e; - BkgA[i] = URB(e); - e *= de; - } - } - - else { - double de = pow((double) eps_ph_sup_global / eps_ph_inf_global, - (double) 1. / POINTS_VERY_FEW); - double e = eps_ph_inf_global; - for (size_t i = 0; i < POINTS_VERY_FEW; i++) { - BkgE[i] = e; - BkgA[i] = CBR(e); - e *= de; - } - } - - // cumulate - for (size_t i = 1; i < POINTS_VERY_FEW; i++) { - BkgA[i] += BkgA[i - 1]; - } - - // normalize - double a = 1.0 / BkgA[POINTS_VERY_FEW - 1]; - for (size_t i = 0; i < POINTS_VERY_FEW; i++) { - BkgA[i] *= a; - } -} - -double Propagation::GetMeanThetaBFDeflection(double Bin, double Ein, int ptype, - double Lin) const { - //from D. Hooper, S. Sarkar, M. Taylor, arXiv: 0608085, 2006 - - if (Bin == 0 || Ein == 0) - return 0; - if (ptype == 22) - return 0; - - double lcoher = 1; - - return 0.8 * (1.0e20 / Ein) * sqrt(Lin / 10 * lcoher) * (Bin / 1.0e-9) - / 180.0 * 3.1415927; -} - -double Propagation::ExtractMinDist(Process &proc, int type, double R, double R2, - std::vector &Etarget) const { - - double min_dist1 = 0; - double min_dist2 = 0; - Process proc1(proc); - Process proc2(proc); - double tmp_lambda1 = 0; - double tmp_lambda2 = 0; - Particle pt; - pt.SetType(0); - pt.Setz(proc.GetIncidentParticle().Getz()); - - if (type == 22) { - if (Etarget[0]) { - proc1.SetName(Process::PP); - pt.SetEnergy(Etarget[0]); - proc1.SetTargetParticle(pt); - proc1.SetCMEnergy(); - - tmp_lambda1 = GetLambdaTab(proc1, Process::PP); - - min_dist1 = -tmp_lambda1 * log(R); - } - if (Etarget[1]) { - pt.SetEnergy(Etarget[1]); - proc2.SetTargetParticle(pt); - proc2.SetCMEnergy(); - tmp_lambda2 = GetLambdaTab(proc2, Process::DPP); - min_dist2 = -tmp_lambda2 * log(R2); - } -#ifdef DEBUG_ELECA - std::cerr << "comparing 2 mindists: " << min_dist1 << "(" - << tmp_lambda1 << ") vs " << min_dist2 << " ( " - << tmp_lambda2 << ") " << std::endl; -#endif - - if (min_dist2 < min_dist1) { - min_dist1 = min_dist2; - proc.SetName(Process::DPP); - pt.SetEnergy(Etarget[1]); - proc.SetTargetParticle(pt); - proc.SetCMEnergy(); - } else { - proc.SetName(Process::PP); - pt.SetEnergy(Etarget[0]); - proc.SetTargetParticle(pt); - proc.SetCMEnergy(); - } - } //end if type 0 - else if (abs(type) == 11) { - - proc1.SetName(Process::ICS); - pt.SetEnergy(Etarget[0]); - proc1.SetTargetParticle(pt); - tmp_lambda1 = GetLambdaTab(proc1, Process::ICS); - min_dist1 = -tmp_lambda1 * log(R); - - proc2.SetName(Process::TPP); - pt.SetEnergy(Etarget[1]); - proc2.SetTargetParticle(pt); - tmp_lambda2 = GetLambdaTab(proc2, Process::TPP); - min_dist2 = -tmp_lambda2 * log(R2); - -#ifdef DEBUG_ELECA - std::cerr << "comparing 2 mindists: " << min_dist1 << "(" - << tmp_lambda1 << ") vs " << min_dist2 << " ( " - << tmp_lambda2 << ") " << std::endl; -#endif - - if (min_dist2 < min_dist1) { - min_dist1 = min_dist2; - proc.SetName(Process::TPP); - pt.SetEnergy(Etarget[1]); - proc.SetTargetParticle(pt); - proc.SetCMEnergy(); - } else { - proc.SetName(Process::ICS); - pt.SetEnergy(Etarget[0]); - proc.SetTargetParticle(pt); - proc.SetCMEnergy(); - } - } //else e+/e- - else - std::cerr << "something wrong in particle type ( " << type - << ". Propagation of photons and e+/e- is the only allowed.)" - << std::endl; - - return min_dist1; -} - -double Propagation::GetLambdaTab(const Process &proc, - const Process::Name procName) const { - - double E1 = proc.GetIncidentParticle().GetEnergy(); - double z = proc.GetIncidentParticle().Getz(); - double res = 0; - - double E0taborg = vEtab[0]; - - //double dEtab = log10(vEtab[0] / vEtab[1]); - double evolution = GetEvolution(proc.GetTargetParticle().GetEnergy(), z); - int i = (int) (log10(E0taborg / (E1 * (1 + z))) / _dEtab); - - if (i < 0) { - std::cout << "WARNING!! GetLambdaTab in " << procName << " : i= " << i - << " <0! E1*(1+z) = " << E1 << "* (1 + " << z << ") < " - << E0taborg << ".. returning lambda[0];" << std::endl; - } - - else if (i >= 1001) { - std::cout << "WARNING!! GetLambdaTab in " << procName << " : i>= " - << 1001 << " ! E1*(1+z) = " << E1 << "* (1 + " << z - << ") .. returning lambda[nentries];" << std::endl; - - } else { - if (procName == Process::PP) - res = vPPle[i]; - else if (procName == Process::DPP) - res = vDPPle[i]; - else if (procName == Process::ICS) - res = vICSle[i]; - else if (procName == Process::TPP) - res = vTPPle[i]; - } - - if (evolution != 0) { - if (res / evolution < 0) - std::cerr - << "ERROR UNPHYSICAL SOLUTION!! CHECK HERE LAMBDA OR EVOLUTION!!" - << std::endl; - return res / evolution; - } - std::cerr << "warning!! evolution ==0 " << std::endl; - return 0; -} - -double Propagation::ShootPhotonEnergyMC(double z) const { - // Routine for the MC sampling of background photon energy - - double h = Uniform(0, 1); - for (int i = 0; i < POINTS_VERY_FEW; i++) { - if (h < BkgA[i]) { - return BkgE[i] * (1. + z); - break; - } - } -#ifdef DEBUG_ELECA - std::cout << "ShootPhotonEnergyMC. z = " << z << " h: " << h << " => 0" - << std::endl; -#endif - - return 0.; -} - -double Propagation::ShootPhotonEnergyMC(double Emin, double z) const { - // Routine for the MC sampling of background photon energy - std::vector::const_iterator it; - - // find lowest energy bin - if (Emin == 0) return 0; - it = std::lower_bound(BkgE.begin(), BkgE.end(), Emin); - - size_t iE; - if (it == BkgE.begin()) - iE = 0; - else if (it == BkgE.end()) - iE = BkgE.size() - 1; - else - iE = it - BkgE.begin(); - - // random number in selected range - double h = Uniform(BkgA[iE], 1); - it = std::upper_bound(BkgA.begin(), BkgA.end(), h); - - if (it == BkgA.begin()) - return BkgE.front(); - else if (it == BkgA.end()) - return BkgE.back(); - else - return BkgE[it - BkgA.begin()]; - -} - -std::vector Propagation::GetEtarget(Process &proc, - const Particle &particle) const { - - std::vector Etarget; - double Etarget_tmp = 0; - double smintmp = 0; - double z_curr = particle.Getz(); - double Energy = particle.GetEnergy(); - int pType = particle.GetType(); - double Eexp = smintmp/(4.0 * Energy); - - if (pType == 22) { - proc.SetName(Process::PP); - proc.SetLimits(); - smintmp = proc.GetMin(); - Eexp = std::max(proc.feps_inf,ElectronMass*ElectronMass/Energy); - if (Eexp > proc.feps_sup) { -// std::cout << proc.GetName() << " " << Eexp << " too big wrt " << proc.feps_sup << " , " << proc.feps_inf << " .. it should not interact!" << std::endl; - Eexp = 0; - Etarget.push_back(0);} - else - Etarget_tmp = ShootPhotonEnergyMC(Eexp, z_curr); - Etarget.push_back(Etarget_tmp); - - proc.SetName(Process::DPP); - proc.SetLimits(); - smintmp = proc.GetMin(); - Eexp = std::max(proc.feps_inf,2*ElectronMass*ElectronMass/Energy); - if (Eexp > proc.feps_sup) { -// std::cout << proc.GetName() << " " << Eexp << " too big wrt " << proc.feps_sup << " , " << proc.feps_inf << " .. it should not interact!" << std::endl; - Eexp = 0; - Etarget.push_back(0);} - else - Etarget_tmp = ShootPhotonEnergyMC(Eexp, z_curr); - Etarget.push_back(Etarget_tmp); - } - - else if (abs(pType) == 11) { - proc.SetName(Process::ICS); - proc.SetLimits(); - smintmp = proc.GetMin(); - Eexp = proc.feps_inf; - Etarget_tmp = ShootPhotonEnergyMC(Eexp, z_curr); - - Etarget.push_back(Etarget_tmp); - - proc.SetName(Process::TPP); - proc.SetLimits(); - smintmp = proc.GetMin(); - Eexp = std::max(proc.feps_inf,2*ElectronMass*ElectronMass/Energy); - if (Eexp > proc.feps_sup) { -// std::cout << proc.GetName() << " " << Eexp << " too big wrt " << proc.feps_sup << " , " << proc.feps_inf << " .. it should not interact!" << std::endl; - Eexp = 0; - Etarget.push_back(0);} - else - Etarget_tmp = ShootPhotonEnergyMC(Eexp, z_curr); - - Etarget.push_back(Etarget_tmp); - } //end e/e - else - std::cerr << "something wrong in particle type ( " << pType - << ". Propagation of photons and e+/e- is the only allowed.)" - << std::endl; - - if (Etarget.size() != 2) { - std::cout << "something wrong with the Etarget!! " << std::endl; - exit(0); - } - - return Etarget; -} - -double Propagation::ExtractPhotonEnergyMC(double z, Process &proc) const { - double esoft = 0; -//double snew = 0; - double emin = proc.GetMin(); - Particle pi = proc.GetIncidentParticle(); - Particle pb = proc.GetTargetParticle(); - - double Epi = pi.GetEnergy(); - double m = pi.GetMass(); - esoft = ShootPhotonEnergyMC(emin / (4.0 * Epi), z); - //snew = 4 * Epi * esoft + m * m; - pb.SetEnergy(esoft); - proc.SetTargetParticle(pb); - proc.SetCMEnergy(); - return esoft; -} - -void Propagation::WriteOutput(std::ostream &out, Particle &p1, - std::vector &ParticleAtGround) const { - double Bfield = 0; - size_t NsecG = ParticleAtGround.size(); - - out << fEthr << " " << Bfield / 1e-9 << " " << p1.GetEnergy() << " " - << p1.Getz() << " " << NsecG; - for (int i = 0; i < NsecG; ++i) { - Particle &p = ParticleAtGround[i]; - out << " " << p.GetWeigth() << " " << p.GetEnergy() << " " - << p.GetType(); - } - out << std::endl; -} -// -//void Propagation::Spectrum(std::vector &spectrum) const { -// double emin = 7.0; -// double dE = (24.0 - 7.0) / 170.0; -// size_t ipos = 0; -// size_t NsecG = ParticleAtGround.size(); -// -// for (int h = 0; h < NsecG; ++h) { -// ipos = (int) ((log10(EGround.at(h)) - emin) / dE); -// if (typeGround.at(h) == 22) -// fdN[ipos] += wGround.at(h); -// } -//} -// -//void Propagation::AddSpectrum(std::vector &spectrum) const { -// double emin = 7.0; -// double dE = (24.0 - 7.0) / 170.0; -// size_t ipos = 0; -// size_t NsecG = ParticleAtGround.size(); -// -// for (int h = 0; h < NsecG; ++h) { -// ipos = (int) ((log10(EGround.at(h)) - emin) / dE); -// if (typeGround.at(h) == 22) -// fdN[ipos] += wGround.at(h); -// } -//} - -void Propagation::Propagate(Particle &curr_particle, - std::vector &ParticleAtMatrix, - std::vector &ParticleAtGround, - bool dropParticlesBelowEnergyThreshold - ) const { - - double theta_deflBF = 0.0; - double BNorm = magneticFieldStrength; - - double zin = curr_particle.Getz(); - double Ein = curr_particle.GetEnergy(); - int type = curr_particle.GetType(); - - int wi_last = curr_particle.GetWeigth(); - - double z_curr = zin; - double Ecurr = Ein; - - bool interacted = 0; - double min_dist = 1e12; - double walkdone = 0; - - double E1 = 0; - double E2 = 0; - double E3 = 0; - - double stepsize = 0; - double Elast = 0; - - double R = Uniform(0.0, 1.0); - double R2 = Uniform(0.0, 1.0); - - Process proc; - proc.SetIncidentParticle(curr_particle); - proc.SetBackground(Bkg); - - double Ethr2 = std::max(fEthr, std::max(ElectronMass,ElectronMass*ElectronMass/proc.feps_sup)); - if (Ecurr < Ethr2) - { - if (!dropParticlesBelowEnergyThreshold) - ParticleAtGround.push_back(curr_particle); - - return; - } - - - std::vector EtargetAll = GetEtarget(proc, curr_particle); - - min_dist = ExtractMinDist(proc, curr_particle.GetType(), R, R2, EtargetAll); - - interacted = 0; - double dz = 0; - double zpos = zin; - - double corrB_factor = 0; - double realpath = 0; - - double min_dist_last = min_dist; - - while (!interacted) { - - proc.SetInteractionAngle(cPI); - theta_deflBF = 0; - realpath = 0.1 * min_dist; - - theta_deflBF = GetMeanThetaBFDeflection(BNorm, - curr_particle.GetEnergy(), curr_particle.GetType(), min_dist); - corrB_factor = cos(theta_deflBF); - - stepsize = realpath * corrB_factor; - dz = Mpc2z(stepsize); - - - if (zpos - dz <= 0) { - dz = zpos; - stepsize = z2Mpc(dz); - realpath = stepsize / corrB_factor; - } - - zpos -= dz; - walkdone += realpath; - Elast = Ecurr; - - if (type == 0 || type == 22) - Ecurr = EnergyLoss1D(Ecurr, zpos + Mpc2z(realpath), zpos, 0); - else - Ecurr = EnergyLoss1D(Ecurr, zpos + Mpc2z(realpath), zpos, BNorm); - - z_curr = zpos; - - curr_particle.Setz(z_curr); - curr_particle.SetEnergy(Ecurr); - - proc.SetIncidentParticle(curr_particle); - proc.SetCMEnergy(); - proc.SetLimits(); - // std::vector EtargetAll=GetEtarget(proc,curr_particle); - min_dist = ExtractMinDist(proc, curr_particle.GetType(), R, R2, - EtargetAll); - - if (Ecurr <= Ethr2) - { - if (!dropParticlesBelowEnergyThreshold) - { - ParticleAtGround.push_back(curr_particle); - } - return; - } - if (walkdone > min_dist) { - interacted = 1; - break; - } - - if (z_curr <= 0) - { - ParticleAtGround.push_back(curr_particle); - return; - } - - } //end while - - if (interacted == 1) { - if (proc.GetName() == Process::PP) { - - E1 = ExtractPPSecondariesEnergy(proc); - - if (E1 == 0 || E1 == Ecurr) - std::cerr << "ERROR in PP process: E : " << Ecurr << " " << E1 - << " " << std::endl; - - Particle pp(11, E1, z_curr,curr_particle.Generation()+1); - pp.SetWeigth(wi_last); - ParticleAtMatrix.push_back(pp); - - Particle pe(-11, Ecurr - E1, z_curr,curr_particle.Generation()+1); - pe.SetWeigth(wi_last); - ParticleAtMatrix.push_back(pe); - return; - } //if PP - else if (proc.GetName() == Process::DPP) { - E1 = (Ecurr - 2 * ElectronMass) / 2.0; - if (E1 == 0) - std::cerr << "ERROR in DPP process E : " << E1 << std::endl; - - Particle pp(11, E1, z_curr,curr_particle.Generation()+1); - pp.SetWeigth(wi_last); - ParticleAtMatrix.push_back(pp); - - Particle pe(-11, E1, z_curr,curr_particle.Generation()+1); - pe.SetWeigth(wi_last); - ParticleAtMatrix.push_back(pe); - - return; - } //end if DPP - else if (proc.GetName() == Process::ICS) { - - E1 = ExtractICSSecondariesEnergy(proc); - E2 = Ecurr - E1; - if (E1 == 0 || E2 == 0) - std::cerr << "ERROR in ICS process E : " << E1 << " " << E2 - << std::endl; - - Particle pp(curr_particle.GetType(), E1, z_curr,curr_particle.Generation()+1); - pp.SetWeigth(wi_last); - ParticleAtMatrix.push_back(pp); - Particle pg(22, E2, z_curr,curr_particle.Generation()+1); - pg.SetWeigth(wi_last); - ParticleAtMatrix.push_back(pg); - - return; - } //end if ics - else if (proc.GetName() == Process::TPP) { - E1 = E2 = ExtractTPPSecondariesEnergy(proc); - E3 = Ecurr - E1 - E2; - if (E1 == 0 || E2 == 0 || E3 == 0) - std::cerr << "ERROR in TPP process E : " << E1 << " " << E2 - << std::endl; - - Particle pp(11, E1, z_curr,curr_particle.Generation()+1); - pp.SetWeigth(wi_last); - ParticleAtMatrix.push_back(pp); - - Particle pe(-11, E1, z_curr,curr_particle.Generation()+1); - pe.SetWeigth(wi_last); - ParticleAtMatrix.push_back(pe); - - Particle psc(curr_particle.GetType(), E3, z_curr,curr_particle.Generation()+1); - psc.SetWeigth(wi_last); - ParticleAtMatrix.push_back(psc); - return; - } - } - - return; - -} - -} // namespace eleca diff --git a/libs/EleCa/src/XLoss_CBR.h b/libs/EleCa/src/XLoss_CBR.h deleted file mode 100644 index c89c94e6b..000000000 --- a/libs/EleCa/src/XLoss_CBR.h +++ /dev/null @@ -1,317 +0,0 @@ -#ifndef ELECA_XLOSS_CBR_H -#define ELECA_XLOSS_CBR_H - -#include - -namespace eleca { -/*===================================================================== - - License - ======= - - This file is part of xHERMES () and EleCa packages for - multi messenger data analysis. - - (C) Copyright 2009, 2010, 2011 Manlio De Domenico and Mariangela Settimo - - Author: Manlio De Domenico - Lab. for Complex Systems, Scuola Superiore di Catania - Universita' degli Studi di Catania, Italy - Mail: manlio.dedomenico@ct.infn.it - - (C) Copyright 2011, 2012 Mariangela Settimo - Author: Mariangela Settimo - Universaat Siegen, Germany, now at LPNHE Paris - Mail: mariangela.settimo@gmail.com - - =====================================================================*/ - -//########################################################################## -//# Cosmic Background Radiations -//########################################################################## -double CIB_Evolution_Baseline(double z) { - // Function for the CIB baseline evolution. - // Stecker, Malkan, Scully (2006) arXiv:astro-ph/0510449v4 - - double tmp = 0; - double m = 3.1; - double z_flat = 1.3; - - if (z <= z_flat) - tmp = pow(1. + z, m); - if (z_flat < z && z < 6) - tmp = pow(1. + z_flat, m); - if (z > 6) - tmp = 0; - - return tmp; -} - -double CIB_Evolution_Fast(double z) { - // Function for the CIB fast evolution. - // Stecker, Malkan, Scully (2006) arXiv:astro-ph/0510449v4 - - double tmp = 0; - double m = 4.; - double z_flat = 1.; - - if (z <= z_flat) - tmp = pow(1. + z, m); - if (z_flat < z && z < 6) - tmp = pow(1. + z_flat, m); - if (z > 6) - tmp = 0; - - return tmp; -} - -double CMB_Evolution(double z) { - return pow_integer<3>(1. + z); -} - -double CIB_Evolution(double z) { - return CIB_Evolution_Fast(z); -} - -double CIOB_Evolution(double z) { - return CIB_Evolution_Fast(z); -} - -double COB_Evolution(double z) { - return pow_integer<3>(1. + z); -} - -double URB_Evolution(double z) { - //from Protheroe - Bierman astro-ph:9605119 - if (z < 0.8) - return pow_integer<4>(1. + z); - return pow_integer<4>(1 + 0.8); // z>= z0 -} - -double CMBR(double eps) { - double tmp = 0; - - if (eps > eps_ph_inf_cmb && eps < eps_ph_sup_cmb) { - tmp = (K_CBR * eps * eps) / (exp((double) eps / (K_boltz * T_CMB)) - 1); - } else { - tmp = 0; - } - - if (std::isnan(tmp)) - tmp = 0; - - return tmp; -} - -double CIBR(double eps) { - double tmp = 0; - - if (eps > eps_ph_inf_cib && eps <= eps_ph_sup_cib) { - tmp = 5e-1 - * ((2.2e-6 * K_CBR * eps * eps) - / (exp((double) eps / (K_boltz * T_CMB) / 9.17) - 1) - + (2.e-11 * K_CBR * eps * eps) - / (exp( - (double) eps / (K_boltz * T_CMB) - / 128.44) - 1)); - } else { - tmp = 0; - } - - if (std::isnan(tmp)) - tmp = 0; - - return tmp; -} - -double CIOBR(double eps) { - // parametrization for infrared/optical by - // Hopkins, A. M. & Beacom, J. F. 2006, ApJ, 651, 142 - // See Model D Finke et al, arXiv:0905.1115v2 - - double tmp = 0; - - if (eps > eps_ph_inf_ciob && eps < eps_ph_sup_ciob) { - double x = log(eps); - tmp = -5.32524895349885 - 0.0741140642891119 * x - - 0.252586527659431 * pow_integer<2>(x) - + 0.234971297531891 * pow_integer<3>(x) - - 0.217014471117521 * pow_integer<4>(x) - - 0.364936722063572 * pow_integer<5>(x) - + 0.0880702191711222 * pow_integer<6>(x) - + 0.221947767409286 * pow_integer<7>(x) - + 0.0445499623085708 * pow_integer<8>(x) - - 0.0517435600939147 * pow_integer<9>(x) - - 0.0295646851279071 * pow_integer<10>(x) - - 0.00011943632049331 * pow_integer<11>(x) - + 0.00461621589174355 * pow_integer<12>(x) - + 0.00150906100702171 * pow_integer<13>(x) - + 1.91459088023263e-05 * pow_integer<14>(x) - - 0.000110272619218937 * pow_integer<15>(x) - - 3.45221358079085e-05 * pow_integer<16>(x) - - 5.42000122025042e-06 * pow_integer<17>(x) - - 4.90862622314226e-07 * pow_integer<18>(x) - - 2.45145316799091e-08 * pow_integer<19>(x) - - 5.25792204884819e-10 * pow_integer<20>(x); - tmp = 0.4 * (double) exp(tmp) / eps / eps; - } else { - tmp = 0; - } - - if (std::isnan(tmp)) - tmp = 0; - - return tmp; -} - -double COBR(double eps) { - double tmp = 0; - - if (eps > eps_ph_inf_cob && eps < eps_ph_sup_cob) { - tmp = 1.2e-15 * (K_CBR * eps * eps) - / (exp((double) eps / (K_boltz * T_COB)) - 1); - } else { - tmp = 0; - } - - if (std::isnan(tmp)) - tmp = 0; - - return tmp; -} - -// Universal Radio Background from Protheroe, Bierman 1996. - -double URB(double eps) { - //if (eps < eps_ph_inf_urb || eps > eps_ph_sup_urb) - if (eps < eps_ph_inf_urb) - return 0; - - double v = eps / h_Planck; - double x = log10(v / 1e9); - - double p0 = -2.23791e+01; - double p1 = -2.59696e-01; - double p2 = 3.51067e-01; - double p3 = -6.80104e-02; - double p4 = 5.82003e-01; - double p5 = -2.00075e+00; - double p6 = -1.35259e+00; - double p7 = -7.12112e-01; //xbreak - - double intensity = 0; - if (x > p7) - intensity = p0 + p1 * x + p3 * x * x * x / (exp(p4 * x) - 1) + p6 + p5 * x; - else - intensity = p0 + p1 * x + p2 * x * x - + p3 * x * x * x / (exp(p4 * x) - 1); - intensity = pow(10, intensity); - double n_eps = 0; - n_eps = 4 * M_PI / (h_Planck * C_speed) * (intensity / eps); - return n_eps / eV2J / 1.0e6; - -} - -double CMIBR(double eps) { - /*! - Cosmic background radiation photon number density (eV^-1 cm^-3) - as a function of ambient photon energy (eV), from CMB to Optical (COB) - - Ref: - - Funk et al, Astropart.Phys. 9 (1998) 97-103 - J.L. Puget, F.W. Stecker and J. Bredekamp, Astroph. J. 205 (1976) 638–654. - */ - return CMBR(eps) + CIBR(eps); -} - -double CMIOBR(double eps) { - /*! - Cosmic background radiation photon number density (eV^-1 cm^-3) - as a function of ambient photon energy (eV), from CMB to Optical (COB) - - Ref: - - Funk et al, Astropart.Phys. 9 (1998) 97-103 - J.L. Puget, F.W. Stecker and J. Bredekamp, Astroph. J. 205 (1976) 638–654. - */ - return CMBR(eps) + CIOBR(eps); -} - -double CBR(double eps, double z) { - /*! - Cosmic background radiation photon number density (eV^-1 cm^-3) - as a function of ambient photon energy (eV), from CMB to Optical (COB) - - Ref: - - Funk et al, Astropart.Phys. 9 (1998) 97-103 - J.L. Puget, F.W. Stecker and J. Bredekamp, Astroph. J. 205 (1976) 638–654. - */ - return CMBR(eps) * CMB_Evolution(z) + CIOBR(eps) * CIOB_Evolution(z) - + URB(eps) * URB_Evolution(z); -} - -double CBR(double eps) { - return CMBR(eps) + CIOBR(eps) + URB(eps); -} - -double GetEvolution(double eps, double z) { - - if (eps >= eps_ph_inf_urb && eps <= eps_ph_sup_urb) - return URB_Evolution(z); - if (eps >= eps_ph_inf_ciob && eps <= eps_ph_sup_ciob) - return CIOB_Evolution(z); - if (eps >= eps_ph_inf_cmb && eps <= eps_ph_sup_cmb) - return CMB_Evolution(z); - return 1; -} - -double GetEvolution(double z, std::string background) { - if (background == "CMB") - return CMB_Evolution(z); - if (background == "CIB") - return CIB_Evolution(z); - if (background == "CMIOB") - return CIOB_Evolution(z); - if (background == "CIOB") - return CIOB_Evolution(z); - if (background == "COB") - return COB_Evolution(z); - if (background == "URB") - return URB_Evolution(z); - - if (background == "ALL") { // come trattare questo caso???? - return CMB_Evolution(z); - } - return 1; -} - -//------ - -double CBR(double eps, double z, std::string background) { - double evolution = 1; - if (z == 0) - evolution = 1; - else - evolution = GetEvolution(eps, z); - - if (background == "CMB") - return CMBR(eps) * evolution; - else if (background == "URB") - return URB(eps) * evolution; - else if (background == "CIOB") - return CIOBR(eps) * evolution; - else if (background == "CMIB") - return CMIBR(eps) * evolution; - else if (background == "CMIOB") - return CMIOBR(eps) * evolution; - else - return (CMBR(eps) * CMB_Evolution(z) + CIOBR(eps) * CIOB_Evolution(z) - + URB(eps) * URB_Evolution(z)); -} - -} // namespace eleca - -#endif // ELECA_XLOSS_CBR_H - diff --git a/python/2_headers.i b/python/2_headers.i index 5c0674bc4..dafb6f31f 100644 --- a/python/2_headers.i +++ b/python/2_headers.i @@ -547,7 +547,6 @@ using namespace crpropa; // for usage of namespace in header files, necessary %include "crpropa/module/HDF5Output.h" %include "crpropa/module/OutputShell.h" -%include "crpropa/module/PhotonEleCa.h" %include "crpropa/module/PhotonOutput1D.h" %include "crpropa/module/NuclearDecay.h" %include "crpropa/module/ElectronPairProduction.h" diff --git a/src/module/PhotonEleCa.cpp b/src/module/PhotonEleCa.cpp deleted file mode 100644 index 97425fcab..000000000 --- a/src/module/PhotonEleCa.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include "crpropa/module/PhotonEleCa.h" -#include "crpropa/Units.h" - -#include "EleCa/Propagation.h" -#include "EleCa/Particle.h" -#include "EleCa/Common.h" -#include "kiss/logger.h" - -#include - -namespace crpropa { - -PhotonEleCa::PhotonEleCa(const std::string background, - const std::string &outputFilename) : - propagation(new eleca::Propagation), saveOnlyPhotonEnergies(false) { - KISS_LOG_WARNING << "EleCa propagation is deprecated and is no longer supported. Please use the EM* (EMPairProduction, EMInverseComptonScattering, ...) modules instead.\n"; - propagation->ReadTables(getDataPath("EleCa/eleca.dat")); - propagation->InitBkgArray(background); - output.open(outputFilename.c_str()); -} - -PhotonEleCa::~PhotonEleCa() { -} - -void PhotonEleCa::process(Candidate *candidate) const { - if (candidate->current.getId() != 22) - return; // do nothing if not a photon - - double z = candidate->getRedshift(); - if (z == 0) - z = eleca::Mpc2z( - (candidate->current.getPosition() - observer).getR() / Mpc); - eleca::Particle p0(candidate->current.getId(), - candidate->current.getEnergy() / eV, z); - std::vector ParticleAtMatrix; - std::vector ParticleAtGround; - ParticleAtMatrix.push_back(p0); - - while (ParticleAtMatrix.size() > 0) { - - eleca::Particle p1 = ParticleAtMatrix.back(); - ParticleAtMatrix.pop_back(); - - if (p1.IsGood()) { - propagation->Propagate(p1, ParticleAtMatrix, ParticleAtGround); - } - } - -#pragma omp critical - { - if (saveOnlyPhotonEnergies) { - for (int i = 0; i < ParticleAtGround.size(); ++i) { - eleca::Particle &p = ParticleAtGround[i]; - if (p.GetType() != 22) - continue; - output << p.GetEnergy() << "\n"; - } - } else { - propagation->WriteOutput(output, p0, ParticleAtGround); - } - } - - candidate->setActive(false); - return; -} - -void PhotonEleCa::setObserver(const Vector3d &position) { - observer = position; -} - -void PhotonEleCa::setSaveOnlyPhotonEnergies(bool photonsOnly) { - saveOnlyPhotonEnergies = photonsOnly; -} - -std::string PhotonEleCa::getDescription() const { - std::stringstream s; - s << "PhotonEleCa"; - return s.str(); -} - -} // namespace crpropa From 3bdc5cf86233ad400fc625e8a8b693ceb834ae76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?JulienD=C3=B6rner?= Date: Thu, 26 Oct 2023 16:22:02 +0200 Subject: [PATCH 3/5] remove PhotonPropagation --- include/CRPropa.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/CRPropa.h b/include/CRPropa.h index b5794a314..cb884e126 100644 --- a/include/CRPropa.h +++ b/include/CRPropa.h @@ -16,7 +16,6 @@ #include "crpropa/ParticleMass.h" #include "crpropa/ParticleState.h" #include "crpropa/PhotonBackground.h" -#include "crpropa/PhotonPropagation.h" #include "crpropa/Random.h" #include "crpropa/Referenced.h" #include "crpropa/Source.h" From 532deacdaca9c671b6e02e8c91e46d2072a554f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?JulienD=C3=B6rner?= Date: Fri, 27 Oct 2023 07:23:13 +0200 Subject: [PATCH 4/5] add remove to CHANGELOG --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 841fbfe97..bdb37a995 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,11 @@ * ObserverPoint will be renamed into Observer1D. * AMRMagenticField - underlying library (saga) is no longer supported. +### removed features +* External extensions DINT and Eleca, which can be replaced with the + EM*-modules combined with the thinning option for reasonable computation + times. + ### New plugins and resources linked on the webpages: * FieldlineIntegrator * grplinst From ad3bd3375405dc9fbf74c818e030bd5e35bdf3c0 Mon Sep 17 00:00:00 2001 From: Lukas Merten Date: Mon, 30 Oct 2023 15:32:08 +0100 Subject: [PATCH 5/5] Update CHANGELOG.md Fixed typo --- CHANGELOG.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bdb37a995..5644ac5e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ * ObserverPoint will be renamed into Observer1D. * AMRMagenticField - underlying library (saga) is no longer supported. -### removed features +### Removed features * External extensions DINT and Eleca, which can be replaced with the EM*-modules combined with the thinning option for reasonable computation times. @@ -27,8 +27,7 @@ * grplinst * monopole * ROOTOutputPlugin - - + ## CRPropa 3.2