diff --git a/CMakeLists.txt b/CMakeLists.txt index cbd6c55..e110597 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,31 +113,6 @@ if(PYTHON_MODULE) $) target_link_libraries(pycatima PRIVATE catima) -# find_program(CYTHON_EXECUTABLE -# NAMES cython cython2 cython3 cython.bat -# DOC "path to the cython executable" -# ) -# if(NOT CYTHON_EXECUTABLE) -# MESSAGE(SEND_ERROR "Cython not found, it is required to build nurex python modules") -# endif(NOT CYTHON_EXECUTABLE) -# MESSAGE(STATUS "Cython found: " ${CYTHON_EXECUTABLE}) - - ### build libraries string -# foreach(entry ${EXTRA_LIBS} ${GSL_LIBRARIES} catima) -# LIST (APPEND EXTRA_PYTHON_LIBS \"${entry}\") -# endforeach(entry ${EXTRA_LIBS} ${GSL_LIBRARIES} catima) -# string (REPLACE ";" "," EXTRA_PYTHON_LIBS "${EXTRA_PYTHON_LIBS}") -# if(THREADS) -# set (CYTHON_DEFINES "-DUSE_THREADS=1") -# endif(THREADS) - ### insert libraries string and create setup.py -# FILE(COPY catimac.pxd catima.pyx DESTINATION ${PROJECT_BINARY_DIR}) -# set(CATIMA_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}catima${CMAKE_SHARED_LIBRARY_SUFFIX}) -# configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in ${PROJECT_BINARY_DIR}/setup.py) -# add_custom_target(target_python ALL DEPENDS catima) -# add_custom_command(TARGET target_python -# COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_BINARY_DIR}/setup.py build_ext ${CYTHON_DEFINES} -i -# ) endif(PYTHON_MODULE ) ########## Sub Directories ########### diff --git a/constants.h b/constants.h index 24c365d..96ce7c8 100644 --- a/constants.h +++ b/constants.h @@ -27,7 +27,7 @@ constexpr bool reactions = true; constexpr bool reactions = false; #endif - +constexpr double PI = 3.1415926535897932384626433832795; constexpr double Avogadro = 6.022140857; // 10^23 constexpr double electron_mass = 0.510998928; // MeV/c^2 constexpr double atomic_mass_unit = 931.4940954; // MeV/c^2 diff --git a/docs/catima_manual.md b/docs/catima_manual.md index 97ddf54..0661a93 100644 --- a/docs/catima_manual.md +++ b/docs/catima_manual.md @@ -1,10 +1,10 @@ -CATima library manual {#mainpage} +CATima library manual ===================== Compiling and Instalation ------------------------- See [README.md](README.md) for details. - +[link2](catima_calculator.md) Units ------ The following units are used for input and outputs: @@ -41,27 +41,29 @@ There are 2 ways to define materials: specifying all elements in constructor or The example of water definition: ```cpp + +catima::Material carbon({0,6,1}); // carbon with elemental atomic weight + catima::Material water1({ - {1,1,2}, // 2 atoms of 1H - {16,8,1} // 1 atom of 16O + {1,1,2}, // {weight, Z, stn or weight fraction} + {16,8,1} }); water1.density(1.0); -water1.thickness(2.0); +water1.thickness(2.0); +water1.I(78.); // set custom ionization potential in eV catima::Material water2; water2.add_element(1,1,2); water2.add_element(16,8,1); water2.density(1.0).thickness(2.0); ``` -If mass number is equal to 0, the mass number of the element is taken as atomic weight of the element with provided Z -Other methods which can be used for Material: +If mass number is equal to 0, the mass number of the element is taken as atomic weight of the element. +Compound elements can be defined either via stoichiometric number or via weight fraction. If the number is less than 1 +it is assumed weight fraction is being used, otherwise stoichiometric number or molar fraction is being used. ```cpp -double den = water2.density(); //den equals 1.0 -double th = water2.thickness(); //th equals 2.0 -double molar_mass = water2.M(); // get molar mass of water -int ncomp = water2.ncomponents(); // ncomp equals 2 +catima::Material air ({{0,7,0.755267},{0,8,0.231781},{0,18,0.012827},{0,6,0.000124}},0.001205); // weight fractions +catima::Material water ({{0,1,2},{0,8,1}},1); // mole fraction ``` - ### predefined materials ### If the library is compiled with predefined materials database, the Material can be retrieved from the database as: ```cpp @@ -69,32 +71,9 @@ using namespace catimal Material water = get_material(material::WATER); Material graphite = get_material(6); ``` -currently all meterial up to Z=98 are predefined plus compounds from MOCADI: -``` - enum material{ - PLASTIC = 201, - AIR = 202, - CH2, - LH2, - LD2, - WATER, - DIAMOND, - GLASS, - ALMG3, - ARCO2_30, - CF4, - ISOBUTANE, - KAPTON, - MYLAR, - NAF, - P10, - POLYOLEFIN, - CMO2, - SUPRASIL, - HAVAR - }; -``` - + +The list of predefined material can be found at __material_database.h__ file + Calculation ----------- @@ -117,7 +96,7 @@ Both function returns structure ___Result___ which contains all calculated varia double sigma_E=0.0; double sigma_a=0.0; double sigma_r=0.0; - double tof=0.0; + double tof=0.0; }; ``` @@ -130,7 +109,6 @@ double domega2dx(Projectile &p, double T, const Material &t, Config c=default_co double range(Projectile &p, double T, const Material &t, Config c=default_config); double range_straggling(Projectile &p, double T, const Material &t, Config c=default_config); double angular_straggling(Projectile &p, double T, const Material &t, Config c=default_config); -\end{verbatim} ``` Example calculation: @@ -162,7 +140,7 @@ Layers can be copied from existing Layes: ```cpp catima::Layers matter2; matter2 = matter1; //matter2 contain 3 layers -matter2.add(nitrogen); +matter2.add(nitrogen); matter2.add(graphite); //matter2 contains 5 layers now ``` @@ -179,9 +157,20 @@ This __default_config__ is supplied as default argument to functions like catima the structure Config is defined as: ```cpp struct Config{ - char z_effective=z_eff_type::atima; - char skip=skip_none; - char dedx = 0; + #ifndef GLOBAL + unsigned char z_effective=z_eff_type::pierce_blann; + #else + unsigned char z_effective=z_eff_type::atima14; + #endif + + #ifdef REACTIONS + unsigned char skip=skip_none; + #else + unsigned char skip=skip_calculation::skip_reactions; + #endif + + unsigned char corrections = 0; + unsigned char calculation = 1; }; ``` @@ -223,7 +212,7 @@ For example check examples directory and makefile inside to see how to link. All functions and classes are inside __catima namespace__ Normally including main file is enough: -```cppp +```cpp #include "catima/catima.h" ``` diff --git a/examples/dedx b/examples/dedx new file mode 100755 index 0000000..fd408f7 Binary files /dev/null and b/examples/dedx differ diff --git a/examples/dedx.cpp b/examples/dedx.cpp index f13ac59..a2697c1 100644 --- a/examples/dedx.cpp +++ b/examples/dedx.cpp @@ -5,22 +5,22 @@ using std::cout; using std::endl; -int main(){ +int main(){ catima::Material water({ // material with 2 atoms {1,1,2}, // 1H - two atoms {16,8,1} // 16O - 1 atom }); water.density(1.0).thickness(2.0); - + catima::Material water2({ // material with 2 atoms {1,1,2}, // 1H - two atoms {16,8,1} // 16O - 1 atom - },1.0,78); - + }, 1.0,78.); // density and custom ionization potential + water2.thickness(2.0); - + catima::Projectile p(12,6); // define projectile, ie 12C - + cout<<"C->H2O\n"; for(double T=0; T<11000;T+=50){ auto result = catima::calculate(p,water,T/12); diff --git a/examples/ls_coefficients b/examples/ls_coefficients new file mode 100755 index 0000000..a34ac15 Binary files /dev/null and b/examples/ls_coefficients differ diff --git a/examples/makefile b/examples/makefile index 9effe4b..5f74a75 100644 --- a/examples/makefile +++ b/examples/makefile @@ -1,4 +1,4 @@ -PROGRAMS=simple dedx example2 materials ls_coefficients reactions +PROGRAMS=simple dedx materials ls_coefficients GCC=g++ -Wall -std=c++14 INCDIR=-I$(CATIMAPATH)/include diff --git a/examples/materials b/examples/materials new file mode 100755 index 0000000..85752b6 Binary files /dev/null and b/examples/materials differ diff --git a/examples/materials.cpp b/examples/materials.cpp index fa9fc99..c373eb7 100644 --- a/examples/materials.cpp +++ b/examples/materials.cpp @@ -6,16 +6,16 @@ using std::endl; int main(){ - catima::Material graphite = catima::get_material(6); - catima::Material water = catima::get_material(catima::material::Water); + catima::Material graphite = catima::get_material(6); + catima::Material P10 = catima::get_material(catima::material::P10); cout<<"Material info"< -#endif namespace catima{ @@ -58,17 +56,7 @@ 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; -} -*/ + /// calculates Ecm fom T, return in MeV units inline double Ecm_from_T(double T, double Ap, double At){ return T*Ap*At/(Ap+At); diff --git a/structures.h b/structures.h index 53f37ad..154911c 100644 --- a/structures.h +++ b/structures.h @@ -87,6 +87,7 @@ namespace catima{ * Maetrial water({ {1,1,2}, {16,8,1}, + 1.0, // optional density }); * \endcode */