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

EnergyTable is not constexpr now to support older compiler, + small other fixes like missing returns

This commit is contained in:
hrocho 2017-07-26 20:22:18 +02:00
parent fd334455bb
commit c0f0679033
6 changed files with 28 additions and 8 deletions

View File

@ -34,7 +34,7 @@ extern "C" {
mat.add_element(ta,tz,1.0); mat.add_element(ta,tz,1.0);
} }
catima::angular_straggling_from_E(p,Tin,Tout,mat); return catima::angular_straggling_from_E(p,Tin,Tout,mat);
} }
double catima_energy_straggling_from_E(double pa, int pz, double Tin, double Tout,double ta, double tz){ double catima_energy_straggling_from_E(double pa, int pz, double Tin, double Tout,double ta, double tz){
@ -46,7 +46,7 @@ extern "C" {
else{ else{
mat.add_element(ta,tz,1.0); mat.add_element(ta,tz,1.0);
} }
catima::energy_straggling_from_E(p,Tin,Tout,mat); return catima::energy_straggling_from_E(p,Tin,Tout,mat);
} }
} }

View File

@ -13,7 +13,8 @@ constexpr double a_rel_increase=0.05;
constexpr double logEmin = 0; constexpr double logEmin = 0;
constexpr double logEmax = 5; constexpr double logEmax = 5;
// energy points array in MeV/u // energy points array in MeV/u
constexpr EnergyTable<200> ls_energy_table(0,5); //constexpr EnergyTable<200> ls_energy_table(0,5);
EnergyTable<200> ls_energy_table(0,5);
//arrays dimensions are [z][energy], z=1 starts from index=0 //arrays dimensions are [z][energy], z=1 starts from index=0

View File

@ -3,7 +3,7 @@
#include "storage.h" #include "storage.h"
namespace catima { namespace catima {
Data _storage; Data _storage;
EnergyTable<max_datapoints> energy_table(logEmin,logEmax);
bool operator==(const DataPoint &a, const DataPoint &b){ bool operator==(const DataPoint &a, const DataPoint &b){
if( (a.m == b.m) && (a.p == b.p) && (a.config == b.config)){ if( (a.m == b.m) && (a.p == b.p) && (a.config == b.config)){

View File

@ -31,8 +31,8 @@ namespace catima{
//inline double energy_function( int i ) { return exp(M_LN10*(logEmin + ((double)i)*(logEmax-logEmin)/(max_datapoints - 1.0))); } //inline double energy_function( int i ) { return exp(M_LN10*(logEmin + ((double)i)*(logEmax-logEmin)/(max_datapoints - 1.0))); }
enum DataType{TYPE_RANGE,TYPE_LS}; //enum DataType{TYPE_RANGE,TYPE_LS};
/*
template<int N> template<int N>
struct EnergyTable{ struct EnergyTable{
constexpr EnergyTable(double logmin, double logmax):values(),step(0.0),num(N){ constexpr EnergyTable(double logmin, double logmax):values(),step(0.0),num(N){
@ -46,6 +46,23 @@ namespace catima{
double step; double step;
std::size_t num; std::size_t num;
}; };
*/
template<int N>
struct EnergyTable{
EnergyTable(double logmin, double logmax):values(),step(0.0),num(N){
step = (logmax-logmin)/(N - 1.0);
for(auto i=0;i<N;i++){
values[i]=exp(M_LN10*(logmin + ((double)i)*step));
}
}
double operator()(int i)const{return values[i];}
double values[N];
double step;
std::size_t num;
};
extern EnergyTable<max_datapoints> energy_table;
template<int N> template<int N>
int EnergyTable_index(const EnergyTable<N> &table, double val){ int EnergyTable_index(const EnergyTable<N> &table, double val){
@ -68,6 +85,7 @@ namespace catima{
r = (x*y[i]) + ((1-x)*y[i+1]); r = (x*y[i]) + ((1-x)*y[i+1]);
return r; return r;
} }
/* /*
template<int N> template<int N>
struct EnergyTableLinear{ struct EnergyTableLinear{
@ -81,7 +99,6 @@ namespace catima{
std::size_t num; std::size_t num;
}; };
*/ */
constexpr EnergyTable<max_datapoints> energy_table(logEmin,logEmax);
class DataPoint{ class DataPoint{
public: public:

View File

@ -92,6 +92,7 @@ Layers operator+(const Layers &a, const Material &m){
res.add(e); res.add(e);
} }
res.add(m); res.add(m);
return res;
} }

View File

@ -46,7 +46,8 @@ int main(){
file<<"constexpr double logEmin = "<<logEmin_forLS<<";\n"; file<<"constexpr double logEmin = "<<logEmin_forLS<<";\n";
file<<"constexpr double logEmax = "<<logEmax_forLS<<";\n"; file<<"constexpr double logEmax = "<<logEmax_forLS<<";\n";
file<<"// energy points array in MeV/u \n"; file<<"// energy points array in MeV/u \n";
file<<"constexpr EnergyTable<"<<num_LS_datapoints<<"> ls_energy_table("<<logEmin_forLS<<","<<logEmax_forLS<<");\n"; //file<<"constexpr EnergyTable<"<<num_LS_datapoints<<"> ls_energy_table("<<logEmin_forLS<<","<<logEmax_forLS<<");\n";
file<<"EnergyTable<"<<num_LS_datapoints<<"> ls_energy_table("<<logEmin_forLS<<","<<logEmax_forLS<<");\n";
/* /*
file<<"double ls_energy_points["<<num_LS_datapoints<<"]={"; file<<"double ls_energy_points["<<num_LS_datapoints<<"]={";