From c77c714be5f2bdb6680f9b13f5ac54915a9980a6 Mon Sep 17 00:00:00 2001 From: dbarrow257 Date: Tue, 17 Sep 2024 10:43:38 -0500 Subject: [PATCH 1/7] Initial attempt to include NuFAST --- Apps/SingleOscProbCalcer.cpp | 15 +++++++++++++++ CMakeLists.txt | 11 ++++++++++- OscProbCalcer/CMakeLists.txt | 6 ++++++ Oscillator/OscillatorBase.cpp | 11 +++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/Apps/SingleOscProbCalcer.cpp b/Apps/SingleOscProbCalcer.cpp index f3f7baf..66b9df4 100644 --- a/Apps/SingleOscProbCalcer.cpp +++ b/Apps/SingleOscProbCalcer.cpp @@ -17,6 +17,10 @@ #include "OscProbCalcer/OscProbCalcer_ProbGPULinear.h" #endif +#if UseNuFASTLinear==1 +#include "OscProbCalcer/OscProbCalcer_NuFASTLinear.h" +#endif + #include #include #include @@ -109,6 +113,17 @@ int main(int argc, char **argv) { throw; #endif } + + else if (OscProbCalcerImplementationToCreate == "NuFASTLinear") { +#if UseNuFASTLinear==1 + OscProbCalcerNuFastLinear* NuFASTLinear = new OscProbCalcerNuFastLinear(OscProbCalcerConfigname,Instance); + Calcer = (OscProbCalcerBase*)NuFASTLinear; + if (fVerbose >= INFO) {std::cout << "Initalised OscProbCalcer Implementation:" << Calcer->ReturnImplementationName() << " in OscillatorBase object" << std::endl;} +#else + std::cerr << "Oscillator was requsted to create " << OscProbCalcerImplementationToCreate << " OscProbCalcer but Use" << OscProbCalcerImplementationToCreate << " is undefined. Indicates problem in setup" << std::endl; + throw; +#endif + } else { std::cerr << "Executable was requsted to create " << OscProbCalcerImplementationToCreate << " OscProbCalcer but this is not implemented within " << __FILE__ << std::endl; diff --git a/CMakeLists.txt b/CMakeLists.txt index 91cb7aa..49b3566 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,7 @@ endif() add_library(NuOscillatorCompilerOptions INTERFACE) message(STATUS "NuOscillator Features: ") -foreach(VAR UseGPU UseMultithreading UseDoubles UseCUDAProb3 UseCUDAProb3Linear UseProb3ppLinear UseProbGPULinear) +foreach(VAR UseGPU UseMultithreading UseDoubles UseCUDAProb3 UseCUDAProb3Linear UseProb3ppLinear UseProbGPULinear UseNuFASTLinear) if(NOT DEFINED ${VAR}) message(FATAL_ERROR "${VAR} not defined") endif() @@ -221,6 +221,15 @@ if(${UseProb3ppLinear} EQUAL 1) LIBRARY DESTINATION lib/) endif() +if(${UseNuFASTLinear} EQUAL 1) + CPMFindPackage( + NAME NuFAST + GIT_TAG main + GITHUB_REPOSITORY PeterDenton/NuFast + DOWNLOAD_ONLY + ) +endif() + if(${UseGPU} EQUAL 1) target_compile_definitions(NuOscillatorCompilerOptions INTERFACE UseGPU=1) else() diff --git a/OscProbCalcer/CMakeLists.txt b/OscProbCalcer/CMakeLists.txt index bcc2aae..ca6b973 100644 --- a/OscProbCalcer/CMakeLists.txt +++ b/OscProbCalcer/CMakeLists.txt @@ -51,6 +51,12 @@ if(${UseProb3ppLinear} EQUAL 1) list(APPEND HEADERS OscProbCalcer_Prob3ppLinear.h) endif() +if(${UseNuFASTLinear} EQUAL 1) + include_directories(${NuFAST_SOURCE_DIR}) + target_sources(OscProbCalcer PRIVATE OscProbCalcer_NuFASTLinear.cpp) + list(APPEND HEADERS OscProbCalcer_NuFASTLinear.h) +endif() + if (${UseGPU} EQUAL 1) set_target_properties(OscProbCalcer PROPERTIES CUDA_SEPARABLE_COMPILATION ON diff --git a/Oscillator/OscillatorBase.cpp b/Oscillator/OscillatorBase.cpp index 775f240..1e334b9 100644 --- a/Oscillator/OscillatorBase.cpp +++ b/Oscillator/OscillatorBase.cpp @@ -163,6 +163,17 @@ OscProbCalcerBase* OscillatorBase::InitialiseOscProbCalcer(std::string OscProbCa throw; #endif } + + else if (OscProbCalcerImplementationToCreate == "NuFASTLinear") { +#if UseNuFASTLinear==1 + OscProbCalcerNuFastLinear* NuFASTLinear = new OscProbCalcerNuFastLinear(OscProbCalcerConfigname,Instance); + Calcer = (OscProbCalcerBase*)NuFASTLinear; + if (fVerbose >= INFO) {std::cout << "Initalised OscProbCalcer Implementation:" << Calcer->ReturnImplementationName() << " in OscillatorBase object" << std::endl;} +#else + std::cerr << "Oscillator was requsted to create " << OscProbCalcerImplementationToCreate << " OscProbCalcer but Use" << OscProbCalcerImplementationToCreate << " is undefined. Indicates problem in setup" << std::endl; + throw; +#endif + } else { std::cerr << "Oscillator was requsted to create " << OscProbCalcerImplementationToCreate << " OscProbCalcer but this is not implemented within " << __FILE__ << std::endl; From d48397b9b37f8e7b8fc0579bafa77cb3bee01b3c Mon Sep 17 00:00:00 2001 From: dbarrow257 Date: Tue, 17 Sep 2024 10:44:48 -0500 Subject: [PATCH 2/7] Add the NuFAST OscProbCalcer --- OscProbCalcer/OscProbCalcer_NuFASTLinear.cpp | 87 ++++++++++++++++++++ OscProbCalcer/OscProbCalcer_NuFASTLinear.h | 81 ++++++++++++++++++ 2 files changed, 168 insertions(+) create mode 100644 OscProbCalcer/OscProbCalcer_NuFASTLinear.cpp create mode 100644 OscProbCalcer/OscProbCalcer_NuFASTLinear.h diff --git a/OscProbCalcer/OscProbCalcer_NuFASTLinear.cpp b/OscProbCalcer/OscProbCalcer_NuFASTLinear.cpp new file mode 100644 index 0000000..0c76f3f --- /dev/null +++ b/OscProbCalcer/OscProbCalcer_NuFASTLinear.cpp @@ -0,0 +1,87 @@ +#include "OscProbCalcer_NuFASTLinear.h" + +#include + +#include "c++/NuFast.cpp" + +OscProbCalcerNuFASTLinear::OscProbCalcerNuFASTLinear(std::string ConfigName_, int Instance_) : OscProbCalcerBase(ConfigName_,"NuFASTLinear",Instance_) +{ + //======= + //Grab information from the config + + //======= + + fNOscParams = kNOscParams; + + fNNeutrinoTypes = 2; + InitialiseNeutrinoTypesArray(fNNeutrinoTypes); + fNeutrinoTypes[0] = Nu; + fNeutrinoTypes[1] = Nubar; + + // This implementation only considers linear propagation, thus no requirement to set cosineZ array + IgnoreCosineZBinning(true); +} + +void OscProbCalcerNuFASTLinear::SetupPropagator() { +} + +void OscProbCalcerNuFASTLinear::CalculateProbabilities(std::vector OscParams) { + double L, E, rho, Ye, probs_returned[3][3]; + double s12sq, s13sq, s23sq, delta, Dmsq21, Dmsq31; + int N_Newton; + + // ------------------------------- // + // Set the experimental parameters // + // ------------------------------- // + L = 1300; // km + E = 2.5; // GeV + rho = 3; // g/cc + Ye = 0.5; + + // --------------------------------------------------------------------- // + // Set the number of Newton-Raphson iterations which sets the precision. // + // 0 is close to the single precision limit and is better than DUNE/HK // + // in the high statistics regime. Increasig N_Newton to 1,2,... rapidly // + // improves the precision at a modest computational cost // + // --------------------------------------------------------------------- // + N_Newton = 0; + + // ------------------------------------- // + // Set the vacuum oscillation parameters // + // ------------------------------------- // + s12sq = 0.31; + s13sq = 0.02; + s23sq = 0.55; + delta = 0.7 * M_PI; + Dmsq21 = 7.5e-5; // eV^2 + Dmsq31 = 2.5e-3; // eV^2 + + // ------------------------------------------ // + // Calculate all 9 oscillationa probabilities // + // ------------------------------------------ // + Probability_Matter_LBL(s12sq, s13sq, s23sq, delta, Dmsq21, Dmsq31, L, E, rho, Ye, N_Newton, &probs_returned); + + // --------------------------- // + // Print out the probabilities // + // --------------------------- // + printf("L = %g E = %g rho = %g\n", L, E, rho); + printf("Probabilities:\n"); + printf("alpha beta P(nu_alpha -> nu_beta)\n"); + for (int alpha = 0; alpha < 3; alpha++) + { + for (int beta = 0; beta < 3; beta++) + { + printf("%d %d %g\n", alpha, beta, probs_returned[alpha][beta]); + } // beta, 3 + } // alpha, 3 +} + +int OscProbCalcerNuFASTLinear::ReturnWeightArrayIndex(int NuTypeIndex, int OscChanIndex, int EnergyIndex, int CosineZIndex) { + int IndexToReturn = NuTypeIndex*fNOscillationChannels*fNEnergyPoints + OscChanIndex*fNEnergyPoints + EnergyIndex; + return IndexToReturn; +} + +long OscProbCalcerNuFASTLinear::DefineWeightArraySize() { + long nCalculationPoints = fNEnergyPoints * fNOscillationChannels * fNNeutrinoTypes; + return nCalculationPoints; +} diff --git a/OscProbCalcer/OscProbCalcer_NuFASTLinear.h b/OscProbCalcer/OscProbCalcer_NuFASTLinear.h new file mode 100644 index 0000000..7966af4 --- /dev/null +++ b/OscProbCalcer/OscProbCalcer_NuFASTLinear.h @@ -0,0 +1,81 @@ +#ifndef __OSCILLATOR_NUFASTLINEAR_H__ +#define __OSCILLATOR_NUFASTLINEAR_H__ + +#include "OscProbCalcerBase.h" + +/** + * @file OscProbCalcer_NuFASTLinear.h + * + * @class OscProbCalcerNuFASTLinear + * + * @brief Oscillation calculation engine for linear propagation in NuFAST. + */ +class OscProbCalcerNuFASTLinear : public OscProbCalcerBase { + public: + + /** + * @brief Default constructor + * + * @param ConfigName_ Name of config used to setup the OscProbCalcerNuFASTLinear() instance + * @param Instance_ Which entry of the OscProbCalcerSetup config block should be read in the case where there are multiple OscProbCalcers to be initialised + */ + OscProbCalcerNuFASTLinear(std::string ConfigName_="", int Instance_=0); + + // ======================================================================================================================================================================== + // Functions which need implementation specific code + + /** + * @brief Setup NuFAST specific variables + */ + void SetupPropagator(); + + /** + * @brief Calculate some oscillation probabilities for a particular oscillation parameter set + * + * Calculator oscillation probabilities in NuFAST. This function both calculates and stores + * the oscillation probabilities in #fWeightArray. + * + * @param OscParams The parameter set to calculate oscillation probabilities at + */ + void CalculateProbabilities(std::vector OscParams); + + /** + * @brief Return implementation specific index in the weight array for a specific combination of neutrino oscillation channel, energy and cosine zenith + * + * @param NuTypeIndex The index in #fNeutrinoTypes (neutrino/antinuetrino) to return the pointer for + * @param OscChanIndex The index in #fOscillationChannels to return the pointer for + * @param EnergyIndex The index in #fEnergyArray to return the pointer for + * @param CosineZIndex The index in #fCosineZArray to return the pointer for + * + * @return Index in #fWeightArray which corresponds to the given inputs + */ + int ReturnWeightArrayIndex(int NuTypeIndex, int OscNuIndex, int EnergyIndex, int CosineZIndex=-1); + + /** + * @brief Define the size of fWeightArray + * + * This is implementation specific because because NuFAST is setup to calculate all oscillation channels together, whilst others calculate only a single oscillation channel. + * + * @return Length that #fWeightArray should be initialised to + */ + long DefineWeightArraySize(); + + // ======================================================================================================================================================================== + // Functions which help setup implementation specific code + + // ======================================================================================================================================================================== + // Variables which are needed for implementation specific code + + /** + * @brief Definition of oscillation parameters which are expected in this ProbGPU implementation + */ + enum OscParams{kTH12, kTH23, kTH13, kDM12, kDM23, kDCP, kPATHL, kDENS, kNOscParams}; + + /** + * @brief Define the neutrino and antineutrino values expected by this implementation + */ + enum NuType{Nubar=-1, Nu=1}; + +}; + +#endif From eaff45bd548ff6e5dd3c8d6f8a646a7d1d053cc8 Mon Sep 17 00:00:00 2001 From: dbarrow257 Date: Tue, 17 Sep 2024 10:49:27 -0500 Subject: [PATCH 3/7] Adding NuFAST config files --- Configs/NuFAST_Testing.yaml | 7 +++++++ .../NuFASTLinear_Testing.yaml | 15 +++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 Configs/NuFAST_Testing.yaml create mode 100644 Configs/OscProbCalcerConfigs/NuFASTLinear_Testing.yaml diff --git a/Configs/NuFAST_Testing.yaml b/Configs/NuFAST_Testing.yaml new file mode 100644 index 0000000..f9f9513 --- /dev/null +++ b/Configs/NuFAST_Testing.yaml @@ -0,0 +1,7 @@ +General: + Verbosity: "INFO" + CosineZIgnored: true + CalculationType: "Unbinned" + +OscProbCalcer: + - Config: "NuFASTLinear:./build/NuOscillatorConfigs/Configs/NuFASTLinear_Testing.yaml" \ No newline at end of file diff --git a/Configs/OscProbCalcerConfigs/NuFASTLinear_Testing.yaml b/Configs/OscProbCalcerConfigs/NuFASTLinear_Testing.yaml new file mode 100644 index 0000000..8270c25 --- /dev/null +++ b/Configs/OscProbCalcerConfigs/NuFASTLinear_Testing.yaml @@ -0,0 +1,15 @@ +General: + Verbosity: "NONE" + +OscProbCalcerSetup: + - NuFASTLinear: + OscChannelMapping: + - Entry: "Electron:Electron" + - Entry: "Electron:Muon" + - Entry: "Electron:Tau" + - Entry: "Muon:Electron" + - Entry: "Muon:Muon" + - Entry: "Muon:Tau" + - Entry: "Tau:Electron" + - Entry: "Tau:Muon" + - Entry: "Tau:Tau" From 8473af2e451f1008a21f452b483f947b7962f6f8 Mon Sep 17 00:00:00 2001 From: dbarrow257 Date: Tue, 17 Sep 2024 20:08:54 +0100 Subject: [PATCH 4/7] Somewhat operational version including NuFAST implementation --- Apps/DragRace.cpp | 13 ++-- Apps/SingleOscProbCalcer.cpp | 3 +- CMakeLists.txt | 5 +- ...TLinear_Testing.yaml => NuFASTLinear.yaml} | 0 OscProbCalcer/OscProbCalcer_NuFASTLinear.cpp | 66 ++++++++++++------- OscProbCalcer/OscProbCalcer_NuFASTLinear.h | 5 +- Oscillator/OscillatorBase.cpp | 6 +- 7 files changed, 63 insertions(+), 35 deletions(-) rename Configs/OscProbCalcerConfigs/{NuFASTLinear_Testing.yaml => NuFASTLinear.yaml} (100%) diff --git a/Apps/DragRace.cpp b/Apps/DragRace.cpp index a2993ed..5948edb 100644 --- a/Apps/DragRace.cpp +++ b/Apps/DragRace.cpp @@ -37,7 +37,7 @@ int main() { OscParams_Beam[6] = 250.0; OscParams_Beam[7] = 2.6; - std::vector EnergyArray = logspace(0.1,100.,1e5); + std::vector EnergyArray = logspace(0.1,20.,1e5); std::vector CosineZArray = linspace(-1.0,1.0,1); std::cout << "========================================================" << std::endl; @@ -54,8 +54,13 @@ int main() { ConfigNames.push_back("./Configs/Unbinned_CUDAProb3.yaml"); #endif +#if UseNuFASTLinear == 1 + //ConfigNames.push_back("./Configs/Binned_NuFASTLinear.yaml"); + ConfigNames.push_back("./Configs/Unbinned_NuFASTLinear.yaml"); +#endif + #if UseCUDAProb3Linear == 1 - ConfigNames.push_back("./Configs/Binned_CUDAProb3Linear.yaml"); + //ConfigNames.push_back("./Configs/Binned_CUDAProb3Linear.yaml"); ConfigNames.push_back("./Configs/Unbinned_CUDAProb3Linear.yaml"); #endif @@ -65,7 +70,7 @@ int main() { #endif #if UseProb3ppLinear == 1 - ConfigNames.push_back("./Configs/Binned_Prob3ppLinear.yaml"); + //ConfigNames.push_back("./Configs/Binned_Prob3ppLinear.yaml"); ConfigNames.push_back("./Configs/Unbinned_Prob3ppLinear.yaml"); #endif @@ -114,7 +119,7 @@ int main() { auto t1 = high_resolution_clock::now(); for (int iThrow=0;iThrow (rand()) / static_cast (RAND_MAX); OscParams_Atm[5] = RandVal; OscParams_Beam[5] = RandVal; diff --git a/Apps/SingleOscProbCalcer.cpp b/Apps/SingleOscProbCalcer.cpp index 66b9df4..d6b7cf7 100644 --- a/Apps/SingleOscProbCalcer.cpp +++ b/Apps/SingleOscProbCalcer.cpp @@ -116,9 +116,8 @@ int main(int argc, char **argv) { else if (OscProbCalcerImplementationToCreate == "NuFASTLinear") { #if UseNuFASTLinear==1 - OscProbCalcerNuFastLinear* NuFASTLinear = new OscProbCalcerNuFastLinear(OscProbCalcerConfigname,Instance); + OscProbCalcerNuFASTLinear* NuFASTLinear = new OscProbCalcerNuFASTLinear(OscProbCalcerConfigname); Calcer = (OscProbCalcerBase*)NuFASTLinear; - if (fVerbose >= INFO) {std::cout << "Initalised OscProbCalcer Implementation:" << Calcer->ReturnImplementationName() << " in OscillatorBase object" << std::endl;} #else std::cerr << "Oscillator was requsted to create " << OscProbCalcerImplementationToCreate << " OscProbCalcer but Use" << OscProbCalcerImplementationToCreate << " is undefined. Indicates problem in setup" << std::endl; throw; diff --git a/CMakeLists.txt b/CMakeLists.txt index 49b3566..8c3e0f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -206,7 +206,7 @@ endif() if(${UseProb3ppLinear} EQUAL 1) CPMFindPackage( NAME Prob3plusplus - VERSION 3.10.4 + VERSION 3.10.3 GITHUB_REPOSITORY rogerwendell/Prob3plusplus GIT_TAG main ) @@ -227,7 +227,8 @@ if(${UseNuFASTLinear} EQUAL 1) GIT_TAG main GITHUB_REPOSITORY PeterDenton/NuFast DOWNLOAD_ONLY - ) + ) + target_compile_definitions(NuOscillatorCompilerOptions INTERFACE UseNuFASTLinear=1) endif() if(${UseGPU} EQUAL 1) diff --git a/Configs/OscProbCalcerConfigs/NuFASTLinear_Testing.yaml b/Configs/OscProbCalcerConfigs/NuFASTLinear.yaml similarity index 100% rename from Configs/OscProbCalcerConfigs/NuFASTLinear_Testing.yaml rename to Configs/OscProbCalcerConfigs/NuFASTLinear.yaml diff --git a/OscProbCalcer/OscProbCalcer_NuFASTLinear.cpp b/OscProbCalcer/OscProbCalcer_NuFASTLinear.cpp index 0c76f3f..ee3e7fb 100644 --- a/OscProbCalcer/OscProbCalcer_NuFASTLinear.cpp +++ b/OscProbCalcer/OscProbCalcer_NuFASTLinear.cpp @@ -33,9 +33,10 @@ void OscProbCalcerNuFASTLinear::CalculateProbabilities(std::vector OscP // ------------------------------- // // Set the experimental parameters // // ------------------------------- // - L = 1300; // km - E = 2.5; // GeV - rho = 3; // g/cc + L = OscParams[kPATHL]; // km + rho = OscParams[kDENS]; // g/cc + + //Ye = OscParams[kELECDENS]; Ye = 0.5; // --------------------------------------------------------------------- // @@ -44,36 +45,53 @@ void OscProbCalcerNuFASTLinear::CalculateProbabilities(std::vector OscP // in the high statistics regime. Increasig N_Newton to 1,2,... rapidly // // improves the precision at a modest computational cost // // --------------------------------------------------------------------- // - N_Newton = 0; + N_Newton = 3; // ------------------------------------- // // Set the vacuum oscillation parameters // // ------------------------------------- // - s12sq = 0.31; - s13sq = 0.02; - s23sq = 0.55; - delta = 0.7 * M_PI; - Dmsq21 = 7.5e-5; // eV^2 + s12sq = OscParams[kTH12]; + s13sq = OscParams[kTH13]; + s23sq = OscParams[kTH23]; + delta = OscParams[kDCP]; + Dmsq21 = OscParams[kDM12]; + + //Need to convert OscParams[kDM23] to kDM31 Dmsq31 = 2.5e-3; // eV^2 // ------------------------------------------ // // Calculate all 9 oscillationa probabilities // // ------------------------------------------ // - Probability_Matter_LBL(s12sq, s13sq, s23sq, delta, Dmsq21, Dmsq31, L, E, rho, Ye, N_Newton, &probs_returned); - - // --------------------------- // - // Print out the probabilities // - // --------------------------- // - printf("L = %g E = %g rho = %g\n", L, E, rho); - printf("Probabilities:\n"); - printf("alpha beta P(nu_alpha -> nu_beta)\n"); - for (int alpha = 0; alpha < 3; alpha++) - { - for (int beta = 0; beta < 3; beta++) - { - printf("%d %d %g\n", alpha, beta, probs_returned[alpha][beta]); - } // beta, 3 - } // alpha, 3 + + for (int iOscProb=0;iOscProb-1e-6) {Weight = 0.;} + + if (Weight<0. || Weight > 1.) { + std::cout << "s12sq:" << s12sq << " s13sq:" << s13sq << " s23sq:" << s23sq << " delta:" << delta << " Dmsq21:" << Dmsq21 << " Dmsq31:" << Dmsq31 << " L:" << L << " E:" << E << " rho:" << rho << " Ye:" << Ye << " N_Newton:" << N_Newton << std::endl; + std::cout << "iOscProb:" << iOscProb << " iNuType:" << iNuType << " iOscChannel:" << iOscChannel << " IndexToFill:" << IndexToFill << " fWeightArray[IndexToFill+iOscProb]:" << fWeightArray[IndexToFill+iOscProb] << std::endl; + throw; + } + + fWeightArray[IndexToFill+iOscProb] = Weight; + } + + } + } + } int OscProbCalcerNuFASTLinear::ReturnWeightArrayIndex(int NuTypeIndex, int OscChanIndex, int EnergyIndex, int CosineZIndex) { diff --git a/OscProbCalcer/OscProbCalcer_NuFASTLinear.h b/OscProbCalcer/OscProbCalcer_NuFASTLinear.h index 7966af4..c5a27ad 100644 --- a/OscProbCalcer/OscProbCalcer_NuFASTLinear.h +++ b/OscProbCalcer/OscProbCalcer_NuFASTLinear.h @@ -69,12 +69,13 @@ class OscProbCalcerNuFASTLinear : public OscProbCalcerBase { /** * @brief Definition of oscillation parameters which are expected in this ProbGPU implementation */ + //enum OscParams{kTH12, kTH23, kTH13, kDM12, kDM23, kDCP, kPATHL, kDENS, kELECDENS, kNOscParams}; enum OscParams{kTH12, kTH23, kTH13, kDM12, kDM23, kDCP, kPATHL, kDENS, kNOscParams}; - + /** * @brief Define the neutrino and antineutrino values expected by this implementation */ - enum NuType{Nubar=-1, Nu=1}; + enum NuType{Nu=1,Nubar=-1}; }; diff --git a/Oscillator/OscillatorBase.cpp b/Oscillator/OscillatorBase.cpp index 1e334b9..36be221 100644 --- a/Oscillator/OscillatorBase.cpp +++ b/Oscillator/OscillatorBase.cpp @@ -16,6 +16,10 @@ #include "OscProbCalcer/OscProbCalcer_ProbGPULinear.h" #endif +#if UseNuFASTLinear==1 +#include "OscProbCalcer/OscProbCalcer_NuFASTLinear.h" +#endif + #include OscillatorBase::OscillatorBase(std::string ConfigName_) { @@ -166,7 +170,7 @@ OscProbCalcerBase* OscillatorBase::InitialiseOscProbCalcer(std::string OscProbCa else if (OscProbCalcerImplementationToCreate == "NuFASTLinear") { #if UseNuFASTLinear==1 - OscProbCalcerNuFastLinear* NuFASTLinear = new OscProbCalcerNuFastLinear(OscProbCalcerConfigname,Instance); + OscProbCalcerNuFASTLinear* NuFASTLinear = new OscProbCalcerNuFASTLinear(OscProbCalcerConfigname,Instance); Calcer = (OscProbCalcerBase*)NuFASTLinear; if (fVerbose >= INFO) {std::cout << "Initalised OscProbCalcer Implementation:" << Calcer->ReturnImplementationName() << " in OscillatorBase object" << std::endl;} #else From 7722c54f0a81833ed394eb531a48a74c5984b7eb Mon Sep 17 00:00:00 2001 From: dbarrow257 Date: Tue, 17 Sep 2024 20:41:53 +0100 Subject: [PATCH 5/7] Added NuFAST configs to implementation --- Apps/DragRace.cpp | 4 ++-- CMakeLists.txt | 2 ++ Configs/Binned_NuFASTLinear.yaml | 12 ++++++++++++ Configs/Unbinned_NuFASTLinear.yaml | 7 +++++++ OscProbCalcer/OscProbCalcer_NuFASTLinear.cpp | 4 ++-- 5 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 Configs/Binned_NuFASTLinear.yaml create mode 100644 Configs/Unbinned_NuFASTLinear.yaml diff --git a/Apps/DragRace.cpp b/Apps/DragRace.cpp index 5948edb..355fda7 100644 --- a/Apps/DragRace.cpp +++ b/Apps/DragRace.cpp @@ -61,7 +61,7 @@ int main() { #if UseCUDAProb3Linear == 1 //ConfigNames.push_back("./Configs/Binned_CUDAProb3Linear.yaml"); - ConfigNames.push_back("./Configs/Unbinned_CUDAProb3Linear.yaml"); + //ConfigNames.push_back("./Configs/Unbinned_CUDAProb3Linear.yaml"); #endif #if UseProbGPULinear == 1 @@ -71,7 +71,7 @@ int main() { #if UseProb3ppLinear == 1 //ConfigNames.push_back("./Configs/Binned_Prob3ppLinear.yaml"); - ConfigNames.push_back("./Configs/Unbinned_Prob3ppLinear.yaml"); + //ConfigNames.push_back("./Configs/Unbinned_Prob3ppLinear.yaml"); #endif //Alternative option to show how all information can be held in a single YAML file rather than using a preset diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c3e0f8..b9d7ae2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,6 +78,8 @@ if(${UseMultithreading} EQUAL 1) target_link_libraries(NuOscillatorCompilerOptions INTERFACE gomp) endif() +target_compile_options(NuOscillatorCompilerOptions INTERFACE -ffast-math) + if(NOT DEFINED NuOscillator_Compiler_Flags) set(NuOscillator_Compiler_Flags "") endif() diff --git a/Configs/Binned_NuFASTLinear.yaml b/Configs/Binned_NuFASTLinear.yaml new file mode 100644 index 0000000..2937f4b --- /dev/null +++ b/Configs/Binned_NuFASTLinear.yaml @@ -0,0 +1,12 @@ +General: + Verbosity: "NONE" + CosineZIgnored: true + CalculationType: "Binned" + +OscProbCalcer: + - Config: "NuFASTLinear:./build/Linux/Configs/OscProbCalcerConfigs/NuFASTLinear.yaml" + +Binned: + FileName: "./Inputs/ExampleAtmosphericBinning.root" + EnergyAxisHistName: "EnergyAxisBinning" + CosineZAxisHistName: "CosineZAxisBinning" diff --git a/Configs/Unbinned_NuFASTLinear.yaml b/Configs/Unbinned_NuFASTLinear.yaml new file mode 100644 index 0000000..391166c --- /dev/null +++ b/Configs/Unbinned_NuFASTLinear.yaml @@ -0,0 +1,7 @@ +General: + Verbosity: "NONE" + CosineZIgnored: true + CalculationType: "Unbinned" + +OscProbCalcer: + - Config: "NuFASTLinear:./build/Linux/Configs/OscProbCalcerConfigs/NuFASTLinear.yaml" diff --git a/OscProbCalcer/OscProbCalcer_NuFASTLinear.cpp b/OscProbCalcer/OscProbCalcer_NuFASTLinear.cpp index ee3e7fb..490d6ec 100644 --- a/OscProbCalcer/OscProbCalcer_NuFASTLinear.cpp +++ b/OscProbCalcer/OscProbCalcer_NuFASTLinear.cpp @@ -45,7 +45,7 @@ void OscProbCalcerNuFASTLinear::CalculateProbabilities(std::vector OscP // in the high statistics regime. Increasig N_Newton to 1,2,... rapidly // // improves the precision at a modest computational cost // // --------------------------------------------------------------------- // - N_Newton = 3; + N_Newton = 0; // ------------------------------------- // // Set the vacuum oscillation parameters // @@ -82,7 +82,7 @@ void OscProbCalcerNuFASTLinear::CalculateProbabilities(std::vector OscP if (Weight<0. || Weight > 1.) { std::cout << "s12sq:" << s12sq << " s13sq:" << s13sq << " s23sq:" << s23sq << " delta:" << delta << " Dmsq21:" << Dmsq21 << " Dmsq31:" << Dmsq31 << " L:" << L << " E:" << E << " rho:" << rho << " Ye:" << Ye << " N_Newton:" << N_Newton << std::endl; - std::cout << "iOscProb:" << iOscProb << " iNuType:" << iNuType << " iOscChannel:" << iOscChannel << " IndexToFill:" << IndexToFill << " fWeightArray[IndexToFill+iOscProb]:" << fWeightArray[IndexToFill+iOscProb] << std::endl; + std::cout << "iOscProb:" << iOscProb << " iNuType:" << iNuType << " iOscChannel:" << iOscChannel << " IndexToFill:" << IndexToFill << " fWeightArray[IndexToFill+iOscProb]:" << Weight << std::endl; throw; } From cd4dcd18d4a8bfc13308c4d0056b29f85ec3b883 Mon Sep 17 00:00:00 2001 From: Daniel Barrow Date: Tue, 17 Sep 2024 15:01:17 -0500 Subject: [PATCH 6/7] Fix the memory addressing issue --- CMakeLists.txt | 8 +++----- OscProbCalcer/OscProbCalcer_NuFASTLinear.cpp | 5 +++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b9d7ae2..e3843f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,8 +78,6 @@ if(${UseMultithreading} EQUAL 1) target_link_libraries(NuOscillatorCompilerOptions INTERFACE gomp) endif() -target_compile_options(NuOscillatorCompilerOptions INTERFACE -ffast-math) - if(NOT DEFINED NuOscillator_Compiler_Flags) set(NuOscillator_Compiler_Flags "") endif() @@ -206,9 +204,9 @@ if(${UseGPU} EQUAL 1) endif() if(${UseProb3ppLinear} EQUAL 1) - CPMFindPackage( + CPMAddPackage( NAME Prob3plusplus - VERSION 3.10.3 + VERSION 3.10.4 GITHUB_REPOSITORY rogerwendell/Prob3plusplus GIT_TAG main ) @@ -224,7 +222,7 @@ if(${UseProb3ppLinear} EQUAL 1) endif() if(${UseNuFASTLinear} EQUAL 1) - CPMFindPackage( + CPMAddPackage( NAME NuFAST GIT_TAG main GITHUB_REPOSITORY PeterDenton/NuFast diff --git a/OscProbCalcer/OscProbCalcer_NuFASTLinear.cpp b/OscProbCalcer/OscProbCalcer_NuFASTLinear.cpp index 490d6ec..6271906 100644 --- a/OscProbCalcer/OscProbCalcer_NuFASTLinear.cpp +++ b/OscProbCalcer/OscProbCalcer_NuFASTLinear.cpp @@ -45,7 +45,7 @@ void OscProbCalcerNuFASTLinear::CalculateProbabilities(std::vector OscP // in the high statistics regime. Increasig N_Newton to 1,2,... rapidly // // improves the precision at a modest computational cost // // --------------------------------------------------------------------- // - N_Newton = 0; + N_Newton = 1; // ------------------------------------- // // Set the vacuum oscillation parameters // @@ -75,7 +75,8 @@ void OscProbCalcerNuFASTLinear::CalculateProbabilities(std::vector OscP // Mapping which links the oscillation channel, neutrino type and energy index to the fWeightArray index int IndexToFill = iNuType*fNOscillationChannels*fNEnergyPoints + iOscChannel*fNEnergyPoints; - double Weight = probs_returned[fOscillationChannels[iOscChannel].GeneratedFlavour][fOscillationChannels[iOscChannel].DetectedFlavour]; + + double Weight = probs_returned[fOscillationChannels[iOscChannel].GeneratedFlavour-1][fOscillationChannels[iOscChannel].DetectedFlavour-1]; //Cancel floating point precision if (Weight<0. && Weight>-1e-6) {Weight = 0.;} From 44450841dae2fd4f91385ce91495a64fe47c8644 Mon Sep 17 00:00:00 2001 From: Daniel Barrow Date: Tue, 17 Sep 2024 16:38:30 -0500 Subject: [PATCH 7/7] Removed unneeded changes to include final implementation of NuFAST --- Apps/DragRace.cpp | 12 +++++----- Configs/NuFAST_Testing.yaml | 7 ------ Setup.sh | 45 ------------------------------------- 3 files changed, 6 insertions(+), 58 deletions(-) delete mode 100644 Configs/NuFAST_Testing.yaml diff --git a/Apps/DragRace.cpp b/Apps/DragRace.cpp index 355fda7..409cb66 100644 --- a/Apps/DragRace.cpp +++ b/Apps/DragRace.cpp @@ -37,7 +37,7 @@ int main() { OscParams_Beam[6] = 250.0; OscParams_Beam[7] = 2.6; - std::vector EnergyArray = logspace(0.1,20.,1e5); + std::vector EnergyArray = logspace(0.1,100.,1e5); std::vector CosineZArray = linspace(-1.0,1.0,1); std::cout << "========================================================" << std::endl; @@ -55,13 +55,13 @@ int main() { #endif #if UseNuFASTLinear == 1 - //ConfigNames.push_back("./Configs/Binned_NuFASTLinear.yaml"); + ConfigNames.push_back("./Configs/Binned_NuFASTLinear.yaml"); ConfigNames.push_back("./Configs/Unbinned_NuFASTLinear.yaml"); #endif #if UseCUDAProb3Linear == 1 - //ConfigNames.push_back("./Configs/Binned_CUDAProb3Linear.yaml"); - //ConfigNames.push_back("./Configs/Unbinned_CUDAProb3Linear.yaml"); + ConfigNames.push_back("./Configs/Binned_CUDAProb3Linear.yaml"); + ConfigNames.push_back("./Configs/Unbinned_CUDAProb3Linear.yaml"); #endif #if UseProbGPULinear == 1 @@ -70,8 +70,8 @@ int main() { #endif #if UseProb3ppLinear == 1 - //ConfigNames.push_back("./Configs/Binned_Prob3ppLinear.yaml"); - //ConfigNames.push_back("./Configs/Unbinned_Prob3ppLinear.yaml"); + ConfigNames.push_back("./Configs/Binned_Prob3ppLinear.yaml"); + ConfigNames.push_back("./Configs/Unbinned_Prob3ppLinear.yaml"); #endif //Alternative option to show how all information can be held in a single YAML file rather than using a preset diff --git a/Configs/NuFAST_Testing.yaml b/Configs/NuFAST_Testing.yaml deleted file mode 100644 index f9f9513..0000000 --- a/Configs/NuFAST_Testing.yaml +++ /dev/null @@ -1,7 +0,0 @@ -General: - Verbosity: "INFO" - CosineZIgnored: true - CalculationType: "Unbinned" - -OscProbCalcer: - - Config: "NuFASTLinear:./build/NuOscillatorConfigs/Configs/NuFASTLinear_Testing.yaml" \ No newline at end of file diff --git a/Setup.sh b/Setup.sh index abfe224..e0d2ab5 100644 --- a/Setup.sh +++ b/Setup.sh @@ -2,48 +2,3 @@ source /cvmfs/larsoft.opensciencegrid.org/spack-packages/setup-env.sh spack load root@6.28.06 spack load gcc@12.2.0 spack load cmake - -export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${PWD}/Prob3plusplus:${PWD}/ProbGPU: - -#Environment configs -#export UseGPU=0 -#export UseMultithreading=1 -#export OMP_NUM_THREADS=8 -#export UseDoubles=1 - -#if [ ${UseGPU} == 1 ]; then -# echo "Using GPU" -#else -# echo "Not using GPU" -#fi - -#if [ ${UseMultithreading} == 1 ]; then -# echo "Using Multithreading with:" ${OMP_NUM_THREADS} "threads" -#else -# echo "Not using Multithreading" -#fi - -#Which calculators to compile -#export UseCUDAProb3=0 -#export UseCUDAProb3Linear=1 -#export UseProbGPULinear=0 -#export UseProb3ppLinear=1 - -#ProbGPU only supported when using GPU -#if [ ${UseGPU} == 0 ]; then -# export UseProbGPULinear=0 -#fi - -#Set CUDA environment variables -#if [ ${UseGPU} == 1 ]; then -# export CUDAPATH=/usr/local/cuda/ -# export PATH=${PATH}:${CUDAPATH}/bin/ -#fi - -#if [ ${UseCUDAProb3} == 1 ] && [ ${UseCUDAProb3Linear} == 1 ]; then -# echo "error: CUDAProb3 and CUDAProb3Linear and not able to be built at the same time" -#fi - -#if [ ${UseCUDAProb3Linear} == 1 ]; then -# export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${PWD}/CUDAProb3Linear/build -#fi