diff --git a/.gitignore b/.gitignore index de78f2b..8717f0a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ bin/ lib/ include/ .vscode/ +tables/ *.o *.so @@ -15,4 +16,4 @@ include/ .DS_Store -!.gitignore \ No newline at end of file +!.gitignore diff --git a/CMakeLists.txt b/CMakeLists.txt index 80e49ef..4d51321 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,14 @@ cmake_minimum_required(VERSION 3.16) project(PunchTable) -set(CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 17) + +if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + set(CMAKE_BUILD_TYPE "Release") + MESSAGE(STATUS "Build type Release") +else() + MESSAGE(STATUS "Build type Debug") +endif() set(PUNCHTABLE_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bin) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a62d3c9..f470cbb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,6 +10,7 @@ target_sources(PunchTable PRIVATE PunchTable.cpp GenerateTable.h GenerateTable.cpp + main.cpp ) target_link_libraries(PunchTable catima) diff --git a/src/CubicSpline.cpp b/src/CubicSpline.cpp index 86c585f..06a09ee 100644 --- a/src/CubicSpline.cpp +++ b/src/CubicSpline.cpp @@ -190,7 +190,7 @@ namespace PunchTable { } else if (i == (m_splines.size() -1)) { - //std::cerr<<"Error at CubicSpline::Evaluate! Input x value: "< +#include #include +#include "catima/gwm_integrators.h" + namespace PunchTable { void GenerateTable(const TableParameters& params) { + static double s_deg2rad = M_PI/180.0; //deg -> radians + static double s_energyPrecision = 0.001; // keV precision + static double s_ug2g = 1.0e-6; //ug -> g + MassLookup& masses = MassLookup::GetInstance(); + catima::Projectile projectile(masses.FindMassU(params.projectileZ, params.projectileA), params.projectileZ, 0.0, 0.0); + std::vector materials; + + if(params.targetZ.size() != params.targetA.size() || + params.targetZ.size() != params.targetS.size() || + params.targetZ.size() != params.targetThickness.size()) + { + std::cerr<<"ERR -- Invalid target parameters passed to GenerateTable. Mismatching target arrays."< energyInData; + std::vector energyDepositedData; + + double theta, ke; + double edep; + double totalDep; + bool stopped; + + size_t totalBins = thetaBins*energyBins; + double flush_percent=0.01; + size_t count=0, flush_val = flush_percent*totalBins, flush_count=0; + for(size_t i=0; i < thetaBins; i++) + { + theta = (params.minTheta + i*params.stepTheta)*s_deg2rad; + energyInData.clear(); + energyDepositedData.clear(); + for(size_t j=0; j s_energyPrecision) + { + energyInData.push_back(ke); + energyDepositedData.push_back(edep); + } + } + + output<<"begin_theta "< g + MassLookup& masses = MassLookup::GetInstance(); + + + catima::Projectile projectile(masses.FindMassU(params.projectileZ, params.projectileA), params.projectileZ, 0.0, 0.0); + std::vector materials; + + if(params.targetZ.size() != params.targetA.size() || + params.targetZ.size() != params.targetS.size() || + params.targetZ.size() != params.targetThickness.size()) + { + std::cerr<<"ERR -- Invalid target parameters passed to GenerateTable. Mismatching target arrays."<> targetZ; + std::vector> targetZ; //Last element is the deposition layer std::vector> targetA; - std::vector> targetS; - double targetThickness; + std::vector> targetS; //Stoichiometry + std::vector targetThickness; //ug/cm2 std::string filename; }; void GenerateTable(const TableParameters& params); + + //For testing (thetaIncident = radians, initialKE = MeV) + double GetEnergyDeposited(const TableParameters& params, double thetaIncident, double initialKE); } #endif \ No newline at end of file diff --git a/src/PunchTable.cpp b/src/PunchTable.cpp index 960357a..dcabb12 100644 --- a/src/PunchTable.cpp +++ b/src/PunchTable.cpp @@ -34,12 +34,15 @@ namespace PunchTable { std::vector energyIn, energyDep; std::getline(input, junk); - input>>junk>>thickness; + while(junk != "---------------------------------") + { + std::getline(input, junk); + } input>>junk>>m_thetaMin>>junk>>m_thetaMax>>junk>>m_thetaStep; std::getline(input, junk); std::getline(input, junk); std::getline(input, junk); - + std::getline(input, junk); while(input>>junk) { if(junk == "begin_theta") @@ -87,7 +90,6 @@ namespace PunchTable { return 0.0; } - float thetaf_bin = (theta_incident - m_thetaMin)/m_thetaStep; int theta_bin = (theta_incident - m_thetaMin)/m_thetaStep; std::cout<<"theta bin: "< #include #include @@ -16,94 +18,43 @@ int main(int argc, char** argv) options = argv[1]; } - int Zp = 1; - int Ap = 1; + PunchTable::TableParameters params; - float keStep = 0.01; - float thickness = 500.0 * 1e-4 * 2.3216 * 1e6; //1000 um thick times density of Si-> ug/cm^2 - float deg2rad = M_PI/180.0; - float thetaStep = 0.1*deg2rad; - float precision = 1.0e-6; + params.projectileA = 1; + params.projectileZ = 1; - std::vector ZT(1), AT(1), ST(1); - ZT[0] = 14; - AT[0] = 28; - ST[0] = 1; + params.minKE = 8.23; + params.maxKE = 25.0; + params.stepKE = 0.01; - EnergyLoss energyLoss; - energyLoss.SetTargetComponents(ZT, AT, ST); + params.minTheta = 0.0; + params.maxTheta = 75.0; + params.stepTheta = 0.1; - float keMin = 8.23f; - float keMax = 25.0f; + double thicknessSABRE = 500.0 * 1.0e-4 * 2.3216 * 1.0e6; //500 um thick times density of Si-> ug/cm^2 - float thetaMin = 0.0f*deg2rad; - float thetaMax = 85.0f*deg2rad; + params.targetZ = {{14}}; + params.targetA = {{28}}; + params.targetS = {{1}}; + params.targetThickness = {thicknessSABRE}; - int nebins = int((keMax-keMin)/keStep); - int ntbins = int ((thetaMax-thetaMin)/thetaStep); + params.filename = "tables/test.ptab"; if(options == "--make-table" || options == "") { - - std::cout<<"nebins: "<> energy_dep(ntbins); - std::vector> energy_in(ntbins); - - for(int i=0; i precision) - { - energy_dep[i].push_back(energy); - energy_in[i].push_back(keCur); - } - } - } - std::cout<FindSymbol(ZT[i], AT[i]); - output<FindSymbol(Zp, Ap)<<" with kinetic energy "<