int main() { double x = 1.0; double y = 1.0; int i = 1; acosh(x); asinh(x); atanh(x); cbrt(x); expm1(x); erf(x); erfc(x); isnan(x); j0(x); j1(x); jn(i,x); ilogb(x); logb(x); log1p(x); rint(x); y0(x); y1(x); yn(i,x); # ifdef _THREAD_SAFE gamma_r(x,&i); lgamma_r(x,&i); # else gamma(x); lgamma(x); # endif hypot(x,y); nextafter(x,y); remainder(x,y); scalb(x,y); return 0; }
TEST(math, gamma_r) { #if defined(__BIONIC__) int sign; ASSERT_DOUBLE_EQ(log(24.0), gamma_r(5.0, &sign)); ASSERT_EQ(1, sign); #else // __BIONIC__ GTEST_LOG_(INFO) << "glibc doesn't have gamma_r.\n"; #endif // __BIONIC__ }
TEST(math, gamma_r) { #if defined(__BIONIC__) int sign; ASSERT_FLOAT_EQ(log(24.0), gamma_r(5.0, &sign)); ASSERT_EQ(1, sign); #else // __BIONIC__ GTEST_LOG_(INFO) << "This test does nothing.\n"; #endif // __BIONIC__ }
int test( ChemicalMixture& chem_mixture ) { const unsigned int N_index = chem_mixture.species_index("N"); const unsigned int N2_index = chem_mixture.species_index("N2"); const double gamma = 0.03; GRINS::ConstantCatalycity gamma_r( gamma ); GRINS::GasRecombinationCatalyticWall<ChemicalMixture> wall_N( chem_mixture, gamma_r, N_index, N2_index ); const double w_s = 0.2; const double rho = 1.0e-3; const double rho_s = rho*w_s; const double T = 620.1; const double R_N = chem_mixture.R( chem_mixture.species_index("N") ); const double R = 30.1; const double omega_dot_exact = rho_s*gamma*std::sqrt( R_N*T/(GRINS::Constants::two_pi) ); const double domega_dot_dT_exact = 0.5*rho_s*gamma*std::sqrt( R_N/(T*GRINS::Constants::two_pi) ); const double drho_dws = -rho*rho_s/R; const double domega_dot_dws_exact = drho_dws*w_s*gamma*std::sqrt( R_N*T/(GRINS::Constants::two_pi) ) + rho*gamma*std::sqrt( R_N*T/(GRINS::Constants::two_pi) ); int return_flag = 0; const double omega_dot_N = wall_N.omega_dot( rho_s, T ); const double domega_dot_dT_N = wall_N.domega_dot_dT( rho_s, T ); const double domega_dot_dws_N = wall_N.domega_dot_dws( rho_s, w_s, T, R ); const double tol = 1.0e-15; /* omega_dot tests */ { double rel_error = std::fabs( (omega_dot_N - omega_dot_exact)/omega_dot_exact ); if( rel_error > tol ) { std::cerr << std::setprecision(16) << std::scientific << "Mismatch in omega_dot_N!" << std::endl << "omega_dot_N = " << omega_dot_N << std::endl << "omega_dot_exact = " << omega_dot_exact << std::endl << "rel error = " << rel_error << std::endl; return_flag = 1; } } /* domega_dot_dT tests */ { double rel_error = std::fabs( (domega_dot_dT_N - domega_dot_dT_exact)/domega_dot_dT_exact ); if( rel_error > tol ) { std::cerr << std::setprecision(16) << std::scientific << "Mismatch in domega_dot_dT_N!" << std::endl << "domega_dot_dT_N = " << domega_dot_dT_N << std::endl << "domega_dot_dT_exact = " << domega_dot_dT_exact << std::endl << "rel error = " << rel_error << std::endl; return_flag = 1; } } /* domega_dot_dws tests */ { double rel_error = std::fabs( (domega_dot_dws_N - domega_dot_dws_exact)/domega_dot_dws_exact ); if( rel_error > tol ) { std::cerr << std::setprecision(16) << std::scientific << "Mismatch in domega_dot_dws_N!" << std::endl << "domega_dot_dws_N = " << domega_dot_dws_N << std::endl << "domega_dot_dws_exact = " << domega_dot_dws_exact << std::endl << "rel error = " << rel_error << std::endl; return_flag = 1; } } return return_flag; }
int test( ChemicalMixture& chem_mixture ) { const unsigned int N_index = chem_mixture.species_index("N"); const unsigned int C_index = chem_mixture.species_index("C"); const unsigned int CN_index = chem_mixture.species_index("CN"); const double gamma = 0.03; GRINS::ConstantCatalycity gamma_r( gamma ); GRINS::GasSolidCatalyticWall<ChemicalMixture> wall( chem_mixture, gamma_r, N_index, C_index, CN_index ); const double w_s = 0.2; const double rho = 1.0e-3; const double rho_s = rho*w_s; const double T = 620.1; const double R_N = chem_mixture.R( chem_mixture.species_index("N") ); const double R = 30.1; const double omega_dot_exact = rho_s*gamma*std::sqrt( R_N*T/(GRINS::Constants::two_pi) ); const double domega_dot_dT_exact = 0.5*rho_s*gamma*std::sqrt( R_N/(T*GRINS::Constants::two_pi) ); const double drho_dws = -rho*rho_s/R; const double domega_dot_dws_exact = drho_dws*w_s*gamma*std::sqrt( R_N*T/(GRINS::Constants::two_pi) ) + rho*gamma*std::sqrt( R_N*T/(GRINS::Constants::two_pi) ); const double mdot_C_exact = -omega_dot_exact*chem_mixture.M( chem_mixture.species_index("C") )/chem_mixture.M( chem_mixture.species_index("N") ); const double mdot_CN_exact = omega_dot_exact*chem_mixture.M( chem_mixture.species_index("CN") )/chem_mixture.M( chem_mixture.species_index("N") ); int return_flag = 0; const double omega_dot_N = wall.omega_dot( rho_s, T ); const double domega_dot_dT_N = wall.domega_dot_dT( rho_s, T ); const double domega_dot_dws_N = wall.domega_dot_dws( rho_s, w_s, T, R ); const double mdot_N = wall.compute_reactant_gas_mass_flux( rho, w_s, T ); const double mdot_C = wall.compute_reactant_solid_mass_consumption( rho, w_s, T ); const double mdot_CN = wall.compute_product_mass_flux( rho, w_s, T ); const double tol = 1.0e-15; /* omega_dot tests */ { double rel_error = std::fabs( (omega_dot_N - omega_dot_exact)/omega_dot_exact ); if( rel_error > tol ) { std::cerr << std::setprecision(16) << std::scientific << "Mismatch in omega_dot_N!" << std::endl << "omega_dot_N = " << omega_dot_N << std::endl << "omega_dot_exact = " << omega_dot_exact << std::endl << "rel error = " << rel_error << std::endl; return_flag = 1; } } /* domega_dot_dT tests */ { double rel_error = std::fabs( (domega_dot_dT_N - domega_dot_dT_exact)/domega_dot_dT_exact ); if( rel_error > tol ) { std::cerr << std::setprecision(16) << std::scientific << "Mismatch in domega_dot_dT_N!" << std::endl << "domega_dot_dT_N = " << domega_dot_dT_N << std::endl << "domega_dot_dT_exact = " << domega_dot_dT_exact << std::endl << "rel error = " << rel_error << std::endl; return_flag = 1; } } /* domega_dot_dws tests */ { double rel_error = std::fabs( (domega_dot_dws_N - domega_dot_dws_exact)/domega_dot_dws_exact ); if( rel_error > tol ) { std::cerr << std::setprecision(16) << std::scientific << "Mismatch in domega_dot_dws_N!" << std::endl << "domega_dot_dws_N = " << domega_dot_dws_N << std::endl << "domega_dot_dws_exact = " << domega_dot_dws_exact << std::endl << "rel error = " << rel_error << std::endl; return_flag = 1; } } /* mdot_N tests */ { double rel_error = std::fabs( (mdot_N-(-omega_dot_exact))/(-omega_dot_exact) ); if( rel_error > tol ) { std::cerr << std::setprecision(16) << std::scientific << "Mismatch in mdot_N!" << std::endl << "mdot_N = " << mdot_N << std::endl << "mdot_N_exact = " << -omega_dot_exact << std::endl << "rel error = " << rel_error << std::endl; return_flag = 1; } } /* mdot_C tests */ { double rel_error = std::fabs( (mdot_C - mdot_C_exact)/mdot_C_exact ); if( rel_error > tol ) { std::cerr << std::setprecision(16) << std::scientific << "Mismatch in mdot_C!" << std::endl << "mdot_C = " << mdot_C << std::endl << "mdot_C_exact = " << mdot_C_exact << std::endl << "rel error = " << rel_error << std::endl; return_flag = 1; } } /* mdot_CN tests */ { double rel_error = std::fabs( (mdot_CN - mdot_CN_exact)/mdot_CN_exact ); if( rel_error > tol ) { std::cerr << std::setprecision(16) << std::scientific << "Mismatch in mdot_CN!" << std::endl << "mdot_CN = " << mdot_CN << std::endl << "mdot_CN_exact = " << mdot_CN_exact << std::endl << "rel error = " << rel_error << std::endl; return_flag = 1; } } return return_flag; }