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:
parent
fd334455bb
commit
c0f0679033
|
@ -34,7 +34,7 @@ extern "C" {
|
|||
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){
|
||||
|
@ -46,7 +46,7 @@ extern "C" {
|
|||
else{
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
|
@ -13,7 +13,8 @@ constexpr double a_rel_increase=0.05;
|
|||
constexpr double logEmin = 0;
|
||||
constexpr double logEmax = 5;
|
||||
// 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
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "storage.h"
|
||||
namespace catima {
|
||||
Data _storage;
|
||||
|
||||
EnergyTable<max_datapoints> energy_table(logEmin,logEmax);
|
||||
|
||||
bool operator==(const DataPoint &a, const DataPoint &b){
|
||||
if( (a.m == b.m) && (a.p == b.p) && (a.config == b.config)){
|
||||
|
|
23
storage.h
23
storage.h
|
@ -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))); }
|
||||
|
||||
enum DataType{TYPE_RANGE,TYPE_LS};
|
||||
|
||||
//enum DataType{TYPE_RANGE,TYPE_LS};
|
||||
/*
|
||||
template<int N>
|
||||
struct EnergyTable{
|
||||
constexpr EnergyTable(double logmin, double logmax):values(),step(0.0),num(N){
|
||||
|
@ -46,6 +46,23 @@ namespace catima{
|
|||
double step;
|
||||
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>
|
||||
int EnergyTable_index(const EnergyTable<N> &table, double val){
|
||||
|
@ -68,6 +85,7 @@ namespace catima{
|
|||
r = (x*y[i]) + ((1-x)*y[i+1]);
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
template<int N>
|
||||
struct EnergyTableLinear{
|
||||
|
@ -81,7 +99,6 @@ namespace catima{
|
|||
std::size_t num;
|
||||
};
|
||||
*/
|
||||
constexpr EnergyTable<max_datapoints> energy_table(logEmin,logEmax);
|
||||
|
||||
class DataPoint{
|
||||
public:
|
||||
|
|
|
@ -92,6 +92,7 @@ Layers operator+(const Layers &a, const Material &m){
|
|||
res.add(e);
|
||||
}
|
||||
res.add(m);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -46,7 +46,8 @@ int main(){
|
|||
file<<"constexpr double logEmin = "<<logEmin_forLS<<";\n";
|
||||
file<<"constexpr double logEmax = "<<logEmax_forLS<<";\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<<"]={";
|
||||
|
|
Loading…
Reference in New Issue
Block a user