49 template <
typename Scalar>
50 int check_rate(
const Scalar & rate_exact,
const Scalar & rate)
52 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 100;
53 int return_flag = (rate_exact > tol);
54 if(return_flag)std::cout <<
"Error: rate is null" << std::endl;
55 if( std::abs( (rate - rate_exact)/rate_exact ) > tol )
57 std::cout << std::scientific << std::setprecision(16)
58 <<
"Error: Mismatch in rate values." << std::endl
59 <<
"rate = " << rate << std::endl
60 <<
"rate_exact = " << rate_exact << std::endl
61 <<
"relative error = " << std::abs(rate_exact - rate)/rate_exact << std::endl
62 <<
"tolerance = " << tol << std::endl;
70 template <
typename Scalar>
71 int tester(std::string path_to_files)
73 std::ifstream CH4(path_to_files +
"/CH4_hv_cs.dat");
74 std::ifstream hv(path_to_files +
"/solar_flux.dat");
76 std::string first_line;
78 getline(CH4,first_line);
79 getline(hv,first_line);
81 std::vector<Scalar> CH4_cs;
82 std::vector<Scalar> CH4_lambda;
83 std::vector<Scalar> hv_irr;
84 std::vector<Scalar> hv_lambda;
91 CH4_lambda.push_back(l);
101 hv_lambda.push_back(l * 10);
102 hv_irr.push_back(w * 1e-4L
103 / (Antioch::Constants::Planck_constant<Scalar>() * Antioch::Constants::light_celerity<Scalar>() / l)
113 std::vector<Scalar> sigma_rescaled(hv_lambda.size());
116 Scalar rate = rate_hv.rate(part_flux);
118 Scalar rate_exact(0);
120 for(
unsigned int il = 0; il < hv_lambda.size() - 1; il++)
122 rate_exact += sigma_rescaled[il] * hv_irr[il] * (hv_lambda[il+1] - hv_lambda[il]);
125 int return_flag =
check_rate(rate_exact,rate);
128 int il = CH4_cs.size() * 2 / 3;
134 for(
unsigned int il = 0; il < hv_lambda.size() - 1; il++)
136 rate_exact += sigma_rescaled[il] * hv_irr[il] * (hv_lambda[il+1] - hv_lambda[il]);
139 rate = rate_hv.rate(part_flux);
141 return_flag =
check_rate(rate_exact,rate) || return_flag;
144 il = CH4_cs.size()/2;
150 for(
unsigned int il = 0; il < hv_lambda.size() - 1; il++)
152 rate_exact += sigma_rescaled[il] * hv_irr[il] * (hv_lambda[il+1] - hv_lambda[il]);
157 rate = rate_hv.rate(part_flux);
159 return_flag =
check_rate(rate_exact,rate) || return_flag;
164 int main(
int argc,
char* argv[])
169 std::cerr <<
"Error: Must specify input files location." << std::endl;
173 return (tester<float>(std::string(argv[1])) ||
174 tester<double>(std::string(argv[1])) ||
175 tester<long double>(std::string(argv[1]))
Stores the incoming flux of particles.
void reset_parameter_of_rate(KineticsType< CoeffType, VectorCoeffType > &rate, KineticsModel::Parameters parameter, const CoeffType new_value, const std::string &unit="SI")
The rate constant models derived from the Arrhenius model have an activation energy which is stored a...
int check_rate(const Scalar &rate_exact, const Scalar &rate)
void set_parameter(KineticsModel::Parameters parameter, int l, CoeffType new_value)
set one value of one parameter, characterized by enum and its index
void set_zero(_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &a)
void y_on_custom_grid(const VectorCoeffType &x_old, const VectorCoeffType &y_old, const VectorStateType &x_new, VectorStateType &y_new) const
int main(int argc, char *argv[])
int tester(std::string path_to_files)