30 #include "antioch_config.h"
34 #ifdef ANTIOCH_HAVE_EIGEN
35 #include "Eigen/Dense"
38 #ifdef ANTIOCH_HAVE_METAPHYSICL
39 #include "metaphysicl/numberarray.h"
42 #ifdef ANTIOCH_HAVE_VEXCL
43 #include "vexcl/vexcl.hpp"
63 #ifdef ANTIOCH_HAVE_GRVY
66 GRVY::GRVY_Timer_Class gt;
72 #ifdef ANTIOCH_HAVE_GSL
73 template <
typename Scalar,
typename Element>
74 int test_viscosity(
const Element & mu,
const Scalar & mu_exact,
const Scalar & tol )
80 const double rel_error = abs( (mu - mu_exact)/mu_exact);
84 std::cerr << std::setprecision(15) << std::scientific;
85 std::cerr <<
"Error: Mismatch in viscosity" << std::endl
86 <<
"mu(T) = " << mu << std::endl
87 <<
"mu_exact = " << mu_exact << std::endl
88 <<
"rel_error = " << rel_error << std::endl
89 <<
"tol = " << tol << std::endl;
96 template <
typename PairScalars>
97 int vectester(
const PairScalars& example,
const std::string& testname)
105 const Scalar LJ_depth(97.530L);
106 const Scalar LJ_diameter(3.621L);
107 const Scalar dipole_moment(0.L);
108 const Scalar mass(28.016e-3L/Antioch::Constants::Avogadro<Scalar>());
110 Antioch::KineticsTheoryViscosity<Scalar,Antioch::GSLSpliner> mu_sp(LJ_depth,LJ_diameter,dipole_moment,mass);
113 PairScalars T = example;
114 for (
unsigned int tuple=0; tuple != ANTIOCH_N_TUPLES; ++tuple)
117 T[2*tuple+1] = 1600.1;
120 const Scalar mu_exact0 = 0.0000417395098853601937871105407365424874568203066945573066;
121 const Scalar mu_exact1 = 0.0000431082906407300464864929380770860406892212065614947462;
125 #ifdef ANTIOCH_HAVE_GRVY
126 gt.BeginTimer(testname);
129 PairScalars mu = mu_sp(T) * mu_sp.Stockmayer(T);
131 #ifdef ANTIOCH_HAVE_GRVY
132 gt.EndTimer(testname);
135 const Scalar tol = (std::numeric_limits<Scalar>::epsilon()*10 < 5e-17)?5e-17:
136 std::numeric_limits<Scalar>::epsilon()*10;
138 for (
unsigned int tuple=0; tuple != ANTIOCH_N_TUPLES; ++tuple)
140 return_flag =
test_viscosity( mu[2*tuple], mu_exact0, tol ) || return_flag;
141 return_flag =
test_viscosity( mu[2*tuple+1], mu_exact1, tol ) || return_flag;
146 #endif // ANTIOCH_HAVE_GSL
152 #ifdef ANTIOCH_HAVE_GSL
154 returnval = returnval ||
155 vectester (std::valarray<float>(2*ANTIOCH_N_TUPLES),
"valarray<float>");
156 returnval = returnval ||
157 vectester (std::valarray<double>(2*ANTIOCH_N_TUPLES),
"valarray<double>");
158 returnval = returnval ||
159 vectester (std::valarray<long double>(2*ANTIOCH_N_TUPLES),
"valarray<ld>");
160 #ifdef ANTIOCH_HAVE_EIGEN
161 returnval = returnval ||
162 vectester (Eigen::Array<float, 2*ANTIOCH_N_TUPLES, 1>(),
"Eigen::ArrayXf");
163 returnval = returnval ||
164 vectester (Eigen::Array<double, 2*ANTIOCH_N_TUPLES, 1>(),
"Eigen::ArrayXd");
165 returnval = returnval ||
166 vectester (Eigen::Array<long double, 2*ANTIOCH_N_TUPLES, 1>(),
"Eigen::ArrayXld");
168 #ifdef ANTIOCH_HAVE_METAPHYSICL
169 returnval = returnval ||
170 vectester (MetaPhysicL::NumberArray<2*ANTIOCH_N_TUPLES, float> (0),
"NumberArray<float>");
171 returnval = returnval ||
172 vectester (MetaPhysicL::NumberArray<2*ANTIOCH_N_TUPLES, double> (0),
"NumberArray<double>");
173 returnval = returnval ||
174 vectester (MetaPhysicL::NumberArray<2*ANTIOCH_N_TUPLES, long double> (0),
"NumberArray<ld>");
176 #ifdef ANTIOCH_HAVE_VEXCL
177 vex::Context ctx_f (vex::Filter::All);
179 returnval = returnval ||
180 vectester (vex::vector<float> (ctx_f, 2*ANTIOCH_N_TUPLES),
"vex::vector<float>");
182 vex::Context ctx_d (vex::Filter::DoublePrecision);
184 returnval = returnval ||
185 vectester (vex::vector<double> (ctx_d, 2*ANTIOCH_N_TUPLES),
"vex::vector<double>");
188 #ifdef ANTIOCH_HAVE_GRVY
193 #else // ANTIOCH_HAVE_GSL
int test_viscosity(const Scalar mu, const Scalar mu_exact, const Scalar tol)
int vectester(const PairScalars &example, const std::string &testname)