1
0
Fork 0
mirror of https://github.com/gwm17/catima.git synced 2024-11-22 18:28:51 -05:00

reactions v1

This commit is contained in:
hrocho 2018-07-31 17:40:25 +02:00
parent 36da5f8d5d
commit 4c54ed0dd0
10 changed files with 66 additions and 16 deletions

View File

@ -11,6 +11,7 @@ option(GENERATE_DATA "make data tables generator" OFF)
option(THIN_TARGET_APPROXIMATION "thin target approximation" ON) option(THIN_TARGET_APPROXIMATION "thin target approximation" ON)
option(DOCS "build documentation (requires doxygen)" OFF) option(DOCS "build documentation (requires doxygen)" OFF)
option(GLOBAL "build with global, sources are required" OFF) option(GLOBAL "build with global, sources are required" OFF)
option(REACTIONS "enable/disable nuclear reaction rate" ON)
option(APPS "build catima applications" ON) option(APPS "build catima applications" ON)
######## build type ############ ######## build type ############
@ -148,6 +149,7 @@ if(EXAMPLES)
#add_subdirectory("examples") #add_subdirectory("examples")
endif(EXAMPLES) endif(EXAMPLES)
if(TESTS) if(TESTS)
enable_testing()
add_subdirectory("tests") add_subdirectory("tests")
endif(TESTS) endif(TESTS)

View File

@ -4,7 +4,7 @@
#cmakedefine THIN_TARGET_APPROXIMATION #cmakedefine THIN_TARGET_APPROXIMATION
#cmakedefine GSL_INTEGRATION #cmakedefine GSL_INTEGRATION
#cmakedefine GLOBAL #cmakedefine GLOBAL
#cmakedefine REACTIONS
#cmakedefine NUREX #cmakedefine NUREX
#endif #endif

View File

@ -9,7 +9,7 @@
#include "catima/storage.h" #include "catima/storage.h"
#include "catima/nucdata.h" #include "catima/nucdata.h"
#include "catima/calculations.h" #include "catima/calculations.h"
#ifdef NUREX #ifdef REACTIONS
#include "catima/reactions.h" #include "catima/reactions.h"
#endif #endif
@ -254,7 +254,7 @@ Result calculate(Projectile &p, const Material &t, const Config &c){
} }
res.sigma_r = sqrt(range_straggling_spline(T)); res.sigma_r = sqrt(range_straggling_spline(T));
res.Eloss = (res.Ein - res.Eout)*p.A; res.Eloss = (res.Ein - res.Eout)*p.A;
#ifdef NUREX #ifdef REACTIONS
res.sp = nonreaction_rate(p,t,c); res.sp = nonreaction_rate(p,t,c);
#endif #endif
return res; return res;
@ -274,7 +274,7 @@ MultiResult calculate(Projectile &p, const Layers &layers, const Config &c){
res.total_result.sigma_E += r.sigma_E*r.sigma_E; res.total_result.sigma_E += r.sigma_E*r.sigma_E;
res.total_result.tof += r.tof; res.total_result.tof += r.tof;
res.total_result.Eout = r.Eout; res.total_result.Eout = r.Eout;
#ifdef NUREX #ifdef REACTIONS
res.total_result.sp = (r.sp>=0.0)?res.total_result.sp*r.sp:-1; res.total_result.sp = (r.sp>=0.0)?res.total_result.sp*r.sp:-1;
#endif #endif
res.results.push_back(r); res.results.push_back(r);

View File

@ -60,7 +60,7 @@ namespace catima{
//char z_effective=z_eff_type::atima14; //char z_effective=z_eff_type::atima14;
unsigned char dedx = 0; unsigned char dedx = 0;
unsigned char dedx_straggling = omega::atima; unsigned char dedx_straggling = omega::atima;
#ifdef NUREX #ifdef REACTIONS
unsigned char skip=skip_none; unsigned char skip=skip_none;
#else #else
unsigned char skip=skip_calculation::skip_reactions; unsigned char skip=skip_calculation::skip_reactions;

View File

@ -20,7 +20,7 @@ constexpr double int_eps_tof = 0.01;
*/ */
constexpr double thin_target_limit = 1 - 1e-3; constexpr double thin_target_limit = 1 - 1e-3;
#ifdef NUREX #ifdef REACTIONS
constexpr double emin_reaction = 30.0; constexpr double emin_reaction = 30.0;
constexpr bool reactions = true; constexpr bool reactions = true;
#else #else

View File

@ -1,12 +1,18 @@
#include "catima/reactions.h" #include "catima/reactions.h"
#ifdef NUREX
#include "nurex/Parametrization.h"
#include "catima/catima.h" #include "catima/catima.h"
#include "catima/abundance_database.h" #include "catima/abundance_database.h"
#include "catima/storage.h" #include "catima/storage.h"
#include <cmath> #include <cmath>
#include <iostream> #include <iostream>
#ifdef NUREX
#include "nurex/Parametrization.h"
using nurex::SigmaR_Kox;
#else
using catima::SigmaR_Kox;
#endif
namespace catima{ namespace catima{
double nonreaction_rate(Projectile &projectile, const Material &target, const Config &c){ double nonreaction_rate(Projectile &projectile, const Material &target, const Config &c){
@ -27,7 +33,7 @@ double nonreaction_rate(Projectile &projectile, const Material &target, const Co
double e = energy_out(projectile.T, th, range_spline); double e = energy_out(projectile.T, th, range_spline);
for(unsigned int i = 0;i<target.ncomponents();i++){ for(unsigned int i = 0;i<target.ncomponents();i++){
stn_sum += target.molar_fraction(i); stn_sum += target.molar_fraction(i);
sum += target.molar_fraction(i)*nurex::SigmaR_Kox(ap,zp,e,at,zt); sum += target.molar_fraction(i)*SigmaR_Kox(ap,zp,e,at,zt);
} }
return sum/stn_sum; return sum/stn_sum;
}; };
@ -52,4 +58,29 @@ double nonreaction_rate(Projectile &projectile, const Material &target, const Co
} }
#ifndef NUREX
double SigmaR_Kox(int Ap, int Zp, double E, int At, int Zt){
constexpr double rc = 1.3;
constexpr double r0 = 1.1;
constexpr double a = 1.85;
constexpr double c1 = 2-(10.0/(1.5*1.5*1.5*1.5*1.5));
double Ap13 = pow(Ap,1.0/3.0);
double At13 = pow(At,1.0/3.0);
double D = 5.0*(At-2*Zt)*Zp/(Ap*At);
double Bc = Zp*Zt/(rc*(Ap13+At13));
double logE = std::log10(E);
double c = 0;
if(logE < 1.5){
c = c1*std::pow(logE/1.5,3);
}
else{
c = (-10.0/std::pow(logE,5)) + 2;
}
double Rs = r0 * ((a*Ap13*At13)/(Ap13+At13)-c)+D;
double Rv = r0 * (Ap13 + At13);
double Ri = Rv + Rs;
double Ecm = Ecm_from_T_relativistic(E,Ap,At);
return 10.0*PI*Ri*Ri*(1-(Bc/Ecm));
}
#endif #endif

View File

@ -50,8 +50,24 @@ namespace catima{
return 1.0 - std::exp(-i*0.0001); return 1.0 - std::exp(-i*0.0001);
} }
double nonreaction_rate(Projectile &projectile, const Material &target, const Config &c=default_config); double nonreaction_rate(Projectile &projectile, const Material &target, const Config &c=default_config);
}
#else
double SigmaR_Kox(int Ap, int Zp, double E, int At, int Zt);
inline double p_from_T(double T, double M=1.0){
return M*sqrt(T*T + 2*T*atomic_mass_unit);
}
inline double Ecm_from_T_relativistic(double T, double Ap, double At){
double mp = Ap*atomic_mass_unit;
double mt = At*atomic_mass_unit;
double plab= p_from_T(T,Ap);
double elab = sqrt(plab*plab + mp*mp);
double ecm = sqrt(mp*mp + mt*mt + 2*elab*mt);
double pcm = plab * mt / ecm;
return sqrt(pcm*pcm+mp*mp)-mp;
} }
#endif //NUREX #endif //NUREX

View File

@ -227,7 +227,7 @@ namespace catima{
double sigma_a=0.0; double sigma_a=0.0;
double sigma_r=0.0; double sigma_r=0.0;
double tof=0.0; double tof=0.0;
#ifdef NUREX #ifdef REACTIONS
double sp = 1.0; double sp = 1.0;
#endif #endif
}; };

View File

@ -1,4 +1,3 @@
enable_testing()
add_definitions(-Dlest_FEATURE_COLOURISE=1) add_definitions(-Dlest_FEATURE_COLOURISE=1)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/tests) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/tests)
@ -10,11 +9,11 @@ foreach(entry ${CATIMA_TESTS})
add_test(${entry} ${PROJECT_BINARY_DIR}/tests/${entry}) add_test(${entry} ${PROJECT_BINARY_DIR}/tests/${entry})
endforeach(entry in ${CATIMA_TESTS}) endforeach(entry in ${CATIMA_TESTS})
if(NUREX) if(REACTIONS)
add_executable(test_reaction test_reaction.cpp) add_executable(test_reaction test_reaction.cpp)
target_link_libraries(test_reaction catima) target_link_libraries(test_reaction catima)
add_test(test_reaction ${PROJECT_BINARY_DIR}/tests/test_reaction) add_test(test_reaction ${PROJECT_BINARY_DIR}/tests/test_reaction)
endif(NUREX) endif(REACTIONS)
set(C_TESTS test_c) set(C_TESTS test_c)
MESSAGE( STATUS "CMAKE_C_COMPILER: " ${CMAKE_C_COMPILER} ) MESSAGE( STATUS "CMAKE_C_COMPILER: " ${CMAKE_C_COMPILER} )

View File

@ -12,6 +12,8 @@ const lest::test specification[] =
CASE("reaction"){ CASE("reaction"){
catima::Projectile proj{12,6,6,870}; catima::Projectile proj{12,6,6,870};
auto c = catima::get_material(6); auto c = catima::get_material(6);
auto h = catima::get_material(1);
catima::Material water({{0,8,2},{0,1,1}},1.0);
c.thickness(2.0); c.thickness(2.0);
double r; double r;