diff --git a/Tests/Algebra/GMRES/main.cpp b/Tests/Algebra/GMRES/main.cpp index f87d7317c43..e088620d5d8 100644 --- a/Tests/Algebra/GMRES/main.cpp +++ b/Tests/Algebra/GMRES/main.cpp @@ -113,7 +113,11 @@ int main (int argc, char* argv[]) amrex::Axpy(xvec, Real(-1.0), exact); auto error = xvec.norminf(); amrex::Print() << " Max norm error: " << error << "\n"; +#ifdef AMREX_USE_FLOAT + AMREX_ALWAYS_ASSERT(error < eps); +#else AMREX_ALWAYS_ASSERT(error*10 < eps); +#endif } amrex::Finalize(); } diff --git a/Tests/CommType/main.cpp b/Tests/CommType/main.cpp index ce4cd013ee3..2d625acfccf 100644 --- a/Tests/CommType/main.cpp +++ b/Tests/CommType/main.cpp @@ -12,9 +12,9 @@ int main(int argc, char* argv[]) int ret_code = EXIT_SUCCESS; { - int ncells = 128; + int ncells = 64; BoxArray ba(Box(IntVect(0), IntVect(ncells-1))); - ba.maxSize(32); + ba.maxSize(16); ba.convert(IntVect(1)); DistributionMapping dm(ba); diff --git a/Tests/FFT/Batch/main.cpp b/Tests/FFT/Batch/main.cpp index 69f5aa5711c..6b2dec3d8da 100644 --- a/Tests/FFT/Batch/main.cpp +++ b/Tests/FFT/Batch/main.cpp @@ -106,7 +106,7 @@ int main (int argc, char* argv[]) auto error = mf2.norminf(0, batch_size, IntVect(0)); amrex::Print() << " Expected to be close to zero: " << error << "\n"; #ifdef AMREX_USE_FLOAT - auto eps = 1.e-6f; + auto eps = 3.e-6F; #else auto eps = 1.e-13; #endif @@ -133,7 +133,7 @@ int main (int argc, char* argv[]) auto error = errmf.norminf(0, batch_size, IntVect(0)); amrex::Print() << " Expected to be close to zero: " << error << "\n"; #ifdef AMREX_USE_FLOAT - auto eps = 0.5e-6f; + auto eps = 3.e-6F; #else auto eps = 1.e-15; #endif @@ -156,7 +156,7 @@ int main (int argc, char* argv[]) auto error = mf2.norminf(0, batch_size, IntVect(0)); amrex::Print() << " Expected to be close to zero: " << error << "\n"; #ifdef AMREX_USE_FLOAT - auto eps = 1.e-6f; + auto eps = 3.e-6F; #else auto eps = 1.e-13; #endif diff --git a/Tests/FFT/RawPtr/main.cpp b/Tests/FFT/RawPtr/main.cpp index b5173ae8893..66eefddaf66 100644 --- a/Tests/FFT/RawPtr/main.cpp +++ b/Tests/FFT/RawPtr/main.cpp @@ -69,7 +69,7 @@ int main (int argc, char* argv[]) }); amrex::Print() << " Expected to be close to zero: " << error << "\n"; #ifdef AMREX_USE_FLOAT - auto eps = 1.e-6f; + auto eps = 3.e-6F; #else auto eps = 1.e-13; #endif @@ -124,7 +124,7 @@ int main (int argc, char* argv[]) }); amrex::Print() << " Expected to be close to zero: " << error << "\n"; #ifdef AMREX_USE_FLOAT - auto eps = 1.e-6f; + auto eps = 3.e-6F; #else auto eps = 1.e-13; #endif diff --git a/Tests/LinearSolvers/NodalPoisson/MyTest.cpp b/Tests/LinearSolvers/NodalPoisson/MyTest.cpp index af0248e7e05..a8b6f825862 100644 --- a/Tests/LinearSolvers/NodalPoisson/MyTest.cpp +++ b/Tests/LinearSolvers/NodalPoisson/MyTest.cpp @@ -166,6 +166,9 @@ MyTest::readParameters () pp.query("max_iter", max_iter); pp.query("max_fmg_iter", max_fmg_iter); pp.query("reltol", reltol); +#ifdef AMREX_USE_FLOAT + reltol = std::max(reltol, 1.e-5F); +#endif pp.query("gpu_regtest", gpu_regtest); diff --git a/Tests/LinearSolvers/Nodal_Projection_EB/main.cpp b/Tests/LinearSolvers/Nodal_Projection_EB/main.cpp index 78c2f197c77..f1af062ce8d 100644 --- a/Tests/LinearSolvers/Nodal_Projection_EB/main.cpp +++ b/Tests/LinearSolvers/Nodal_Projection_EB/main.cpp @@ -249,7 +249,11 @@ int main (int argc, char* argv[]) // nodal_solver.setBottomSolver(MLMG::BottomSolver::hypre); // Define the relative tolerance +#ifdef AMREX_USE_FLOAT + Real reltol = 2.e-4; +#else Real reltol = 1.e-8; +#endif // Define the absolute tolerance; note that this argument is optional Real abstol = 1.e-15; diff --git a/Tests/Parser/main.cpp b/Tests/Parser/main.cpp index a0cbf37dc93..9a74d93c84d 100644 --- a/Tests/Parser/main.cpp +++ b/Tests/Parser/main.cpp @@ -12,10 +12,10 @@ namespace { template int test1 (std::string const& f, - std::map const& constants, + std::map const& constants, Vector const& variables, - F const& fb, Array const& lo, Array const& hi, - int N, Real reltol, Real abstol) + F const& fb, Array const& lo, Array const& hi, + int N, double reltol, double abstol) { amrex::Print() << test_number++ << ". Testing \"" << f << "\" "; @@ -27,16 +27,16 @@ int test1 (std::string const& f, auto const exe = parser.compile<1>(); max_stack_size = std::max(max_stack_size, parser.maxStackSize()); - GpuArray dx{(hi[0]-lo[0]) / (N-1)}; + GpuArray dx{(hi[0]-lo[0]) / (N-1)}; int nfail = 0; - Real max_relerror = 0.; + double max_relerror = 0.; for (int i = 0; i < N; ++i) { - Real x = lo[0] + i*dx[0]; - Real result = exe(x); - Real benchmark = fb(x); - Real abserror = std::abs(result-benchmark); - Real relerror = abserror / (1.e-50 + std::max(std::abs(result),std::abs(benchmark))); + double x = lo[0] + i*dx[0]; + double result = exe(x); + double benchmark = fb(x); + double abserror = std::abs(result-benchmark); + double relerror = abserror / (1.e-50 + std::max(std::abs(result),std::abs(benchmark))); if (abserror > abstol && relerror > reltol) { amrex::Print() << "\n f(" << x << ") = " << result << ", " << benchmark; @@ -56,10 +56,10 @@ int test1 (std::string const& f, template int test3 (std::string const& f, - std::map const& constants, + std::map const& constants, Vector const& variables, - F const& fb, Array const& lo, Array const& hi, - int N, Real reltol, Real abstol) + F const& fb, Array const& lo, Array const& hi, + int N, double reltol, double abstol) { amrex::Print() << test_number++ << ". Testing \"" << f << "\" "; @@ -71,20 +71,20 @@ int test3 (std::string const& f, auto const exe = parser.compile<3>(); max_stack_size = std::max(max_stack_size, parser.maxStackSize()); - GpuArray dx{(hi[0]-lo[0]) / (N-1), - (hi[1]-lo[1]) / (N-1), - (hi[2]-lo[2]) / (N-1)}; + GpuArray dx{(hi[0]-lo[0]) / (N-1), + (hi[1]-lo[1]) / (N-1), + (hi[2]-lo[2]) / (N-1)}; int nfail = 0; for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { for (int k = 0; k < N; ++k) { - Real x = lo[0] + i*dx[0]; - Real y = lo[1] + j*dx[1]; - Real z = lo[2] + k*dx[2]; - Real result = exe(x,y,z); - Real benchmark = fb(x,y,z); - Real abserror = std::abs(result-benchmark); - Real relerror = abserror / (1.e-50 + std::max(std::abs(result),std::abs(benchmark))); + double x = lo[0] + i*dx[0]; + double y = lo[1] + j*dx[1]; + double z = lo[2] + k*dx[2]; + double result = exe(x,y,z); + double benchmark = fb(x,y,z); + double abserror = std::abs(result-benchmark); + double relerror = abserror / (1.e-50 + std::max(std::abs(result),std::abs(benchmark))); if (abserror > abstol && relerror > reltol) { amrex::Print() << " f(" << x << "," << y << "," << z << ") = " << result << ", " << benchmark << "\n"; @@ -102,10 +102,10 @@ int test3 (std::string const& f, template int test4 (std::string const& f, - std::map const& constants, + std::map const& constants, Vector const& variables, - F const& fb, Array const& lo, Array const& hi, - int N, Real reltol, Real abstol) + F const& fb, Array const& lo, Array const& hi, + int N, double reltol, double abstol) { amrex::Print() << test_number++ << ". Testing \"" << f << "\" "; @@ -117,23 +117,23 @@ int test4 (std::string const& f, auto const exe = parser.compile<4>(); max_stack_size = std::max(max_stack_size, parser.maxStackSize()); - GpuArray dx{(hi[0]-lo[0]) / (N-1), - (hi[1]-lo[1]) / (N-1), - (hi[2]-lo[2]) / (N-1), - (hi[3]-lo[3]) / (N-1)}; + GpuArray dx{(hi[0]-lo[0]) / (N-1), + (hi[1]-lo[1]) / (N-1), + (hi[2]-lo[2]) / (N-1), + (hi[3]-lo[3]) / (N-1)}; int nfail = 0; for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { for (int k = 0; k < N; ++k) { for (int m = 0; m < N; ++m) { - Real x = lo[0] + i*dx[0]; - Real y = lo[1] + j*dx[1]; - Real z = lo[2] + k*dx[2]; - Real t = lo[3] + m*dx[3]; - Real result = exe(x,y,z,t); - Real benchmark = fb(x,y,z,t); - Real abserror = std::abs(result-benchmark); - Real relerror = abserror / (1.e-50 + std::max(std::abs(result),std::abs(benchmark))); + double x = lo[0] + i*dx[0]; + double y = lo[1] + j*dx[1]; + double z = lo[2] + k*dx[2]; + double t = lo[3] + m*dx[3]; + double result = exe(x,y,z,t); + double benchmark = fb(x,y,z,t); + double abserror = std::abs(result-benchmark); + double relerror = abserror / (1.e-50 + std::max(std::abs(result),std::abs(benchmark))); if (abserror > abstol && relerror > reltol) { amrex::Print() << " f(" << x << "," << y << "," << z << "," << t << ") = " << result << ", " << benchmark << "\n"; @@ -159,9 +159,9 @@ int main (int argc, char* argv[]) nerror += test3("if( ((z-zc)*(z-zc)+(y-yc)*(y-yc)+(x-xc)*(x-xc))^(0.5) < (r_star-dR), 0.0, if(((z-zc)*(z-zc)+(y-yc)*(y-yc)+(x-xc)*(x-xc))^(0.5) <= r_star, dens, 0.0))", {{"xc", 0.1}, {"yc", -1.0}, {"zc", 0.2}, {"r_star", 0.73}, {"dR", 0.57}, {"dens", 12.}}, {"x","y","z"}, - [=] (Real x, Real y, Real z) -> Real { - Real xc=0.1, yc=-1.0, zc=0.2, r_star=0.73, dR=0.57, dens=12.; - Real r = std::sqrt((z-zc)*(z-zc) + (y-yc)*(y-yc) + (x-xc)*(x-xc)); + [=] (double x, double y, double z) -> double { + double xc=0.1, yc=-1.0, zc=0.2, r_star=0.73, dR=0.57, dens=12.; + double r = std::sqrt((z-zc)*(z-zc) + (y-yc)*(y-yc) + (x-xc)*(x-xc)); if (r >= r_star-dR && r <= r_star) { return dens; } else { @@ -174,9 +174,9 @@ int main (int argc, char* argv[]) nerror += test3("r=sqrt((z-zc)*(z-zc)+(y-yc)*(y-yc)+(x-xc)*(x-xc)); if(r < (r_star-dR), 0.0, if(r <= r_star, dens, 0.0))", {{"xc", 0.1}, {"yc", -1.0}, {"zc", 0.2}, {"r_star", 0.73}, {"dR", 0.57}, {"dens", 12.}}, {"x","y","z"}, - [=] (Real x, Real y, Real z) -> Real { - Real xc=0.1, yc=-1.0, zc=0.2, r_star=0.73, dR=0.57, dens=12.; - Real r = std::sqrt((z-zc)*(z-zc) + (y-yc)*(y-yc) + (x-xc)*(x-xc)); + [=] (double x, double y, double z) -> double { + double xc=0.1, yc=-1.0, zc=0.2, r_star=0.73, dR=0.57, dens=12.; + double r = std::sqrt((z-zc)*(z-zc) + (y-yc)*(y-yc) + (x-xc)*(x-xc)); if (r >= r_star-dR && r <= r_star) { return dens; } else { @@ -189,9 +189,9 @@ int main (int argc, char* argv[]) nerror += test3("r2=(z-zc)*(z-zc)+(y-yc)*(y-yc)+(x-xc)*(x-xc); r=sqrt(r2); if(r < (r_star-dR), 0.0, if(r <= r_star, dens, 0.0))", {{"xc", 0.1}, {"yc", -1.0}, {"zc", 0.2}, {"r_star", 0.73}, {"dR", 0.57}, {"dens", 12.}}, {"x","y","z"}, - [=] (Real x, Real y, Real z) -> Real { - Real xc=0.1, yc=-1.0, zc=0.2, r_star=0.73, dR=0.57, dens=12.; - Real r = std::sqrt((z-zc)*(z-zc) + (y-yc)*(y-yc) + (x-xc)*(x-xc)); + [=] (double x, double y, double z) -> double { + double xc=0.1, yc=-1.0, zc=0.2, r_star=0.73, dR=0.57, dens=12.; + double r = std::sqrt((z-zc)*(z-zc) + (y-yc)*(y-yc) + (x-xc)*(x-xc)); if (r >= r_star-dR && r <= r_star) { return dens; } else { @@ -204,9 +204,9 @@ int main (int argc, char* argv[]) nerror += test3("( ((( (z-zc)*(z-zc) + (y-yc)*(y-yc) + (x-xc)*(x-xc) )^(0.5))<=r_star) * ((( (z-zc)*(z-zc) + (y-yc)*(y-yc) + (x-xc)*(x-xc) )^(0.5))>=(r_star-dR)) )*dens", {{"xc", 0.1}, {"yc", -1.0}, {"zc", 0.2}, {"r_star", 0.73}, {"dR", 0.57}, {"dens", 12.}}, {"x","y","z"}, - [=] (Real x, Real y, Real z) -> Real { - Real xc=0.1, yc=-1.0, zc=0.2, r_star=0.73, dR=0.57, dens=12.; - Real r = std::sqrt((z-zc)*(z-zc) + (y-yc)*(y-yc) + (x-xc)*(x-xc)); + [=] (double x, double y, double z) -> double { + double xc=0.1, yc=-1.0, zc=0.2, r_star=0.73, dR=0.57, dens=12.; + double r = std::sqrt((z-zc)*(z-zc) + (y-yc)*(y-yc) + (x-xc)*(x-xc)); if (r >= r_star-dR && r <= r_star) { return dens; } else { @@ -219,12 +219,12 @@ int main (int argc, char* argv[]) nerror += test4("( (( (z-zc)*(z-zc) + (y-yc)*(y-yc) + (x-xc)*(x-xc) )^(0.5))>=r_star)*(-( (t=to)*omega )*(((x-xc)*(x-xc) + (y-yc)*(y-yc))^(0.5))/((1.0-( ( (t=to)*omega) *(((x-xc)*(x-xc) + (y-yc)*(y-yc))^(0.5))/c)^2)^(0.5)) * (y-yc)/(((x-xc)*(x-xc) + (y-yc)*(y-yc))^(0.5)))", {{"xc", 0.1}, {"yc", -1.0}, {"zc", 0.2}, {"to", 3.}, {"omega", 0.33}, {"c", 30.}, {"r_star", 0.75}}, {"x","y","z","t"}, - [=] (Real x, Real y, Real z, Real t) -> Real { - Real xc=0.1, yc=-1.0, zc=0.2, to=3., omega=0.33, c=30., r_star=0.75; - Real r = std::sqrt((z-zc)*(z-zc) + (y-yc)*(y-yc) + (x-xc)*(x-xc)); + [=] (double x, double y, double z, double t) -> double { + double xc=0.1, yc=-1.0, zc=0.2, to=3., omega=0.33, c=30., r_star=0.75; + double r = std::sqrt((z-zc)*(z-zc) + (y-yc)*(y-yc) + (x-xc)*(x-xc)); if (r >= r_star) { - Real tomega = (t>=to) ? omega : omega*(t/to); - Real r2d = std::sqrt((x-xc)*(x-xc) + (y-yc)*(y-yc)); + double tomega = (t>=to) ? omega : omega*(t/to); + double r2d = std::sqrt((x-xc)*(x-xc) + (y-yc)*(y-yc)); return -tomega * r / std::sqrt(1.0-(tomega*r2d/c)*(tomega*r2d/c)) * (y-yc)/r; } else { return 0.0; @@ -236,12 +236,12 @@ int main (int argc, char* argv[]) nerror += test4("r=sqrt((z-zc)*(z-zc) + (y-yc)*(y-yc) + (x-xc)*(x-xc)); tomega=if(t>=to, omega, omega*(t/to)); r2d=sqrt((y-yc)*(y-yc) + (x-xc)*(x-xc)); (r>=r_star)*(-tomega*r/(1.0-((tomega*r2d/c)^2))^0.5 * (y-yc)/r)", {{"xc", 0.1}, {"yc", -1.0}, {"zc", 0.2}, {"to", 3.}, {"omega", 0.33}, {"c", 30.}, {"r_star", 0.75}}, {"x","y","z","t"}, - [=] (Real x, Real y, Real z, Real t) -> Real { - Real xc=0.1, yc=-1.0, zc=0.2, to=3., omega=0.33, c=30., r_star=0.75; - Real r = std::sqrt((z-zc)*(z-zc) + (y-yc)*(y-yc) + (x-xc)*(x-xc)); + [=] (double x, double y, double z, double t) -> double { + double xc=0.1, yc=-1.0, zc=0.2, to=3., omega=0.33, c=30., r_star=0.75; + double r = std::sqrt((z-zc)*(z-zc) + (y-yc)*(y-yc) + (x-xc)*(x-xc)); if (r >= r_star) { - Real tomega = (t>=to) ? omega : omega*(t/to); - Real r2d = std::sqrt((x-xc)*(x-xc) + (y-yc)*(y-yc)); + double tomega = (t>=to) ? omega : omega*(t/to); + double r2d = std::sqrt((x-xc)*(x-xc) + (y-yc)*(y-yc)); return -tomega * r / std::sqrt(1.0-(tomega*r2d/c)*(tomega*r2d/c)) * (y-yc)/r; } else { return 0.0; @@ -253,8 +253,8 @@ int main (int argc, char* argv[]) nerror += test3("cos(m * pi / Lx * (x - Lx / 2)) * cos(n * pi / Ly * (y - Ly / 2)) * sin(p * pi / Lz * (z - Lz / 2))*mu_0*(x>-0.5)*(x<0.5)*(y>-0.5)*(y<0.5)*(z>-0.5)*(z<0.5)", {{"m", 0.0}, {"n", 1.0}, {"pi", 3.14}, {"p", 1.0}, {"Lx", 1.}, {"Ly", 1.}, {"Lz", 1.}, {"mu_0", 1.27e-6}}, {"x","y","z"}, - [=] (Real x, Real y, Real z) -> Real { - Real m=0.0,n=1.0,pi=3.14,p=1.0,Lx=1.,Ly=1.,Lz=1.,mu_0=1.27e-6; + [=] (double x, double y, double z) -> double { + double m=0.0,n=1.0,pi=3.14,p=1.0,Lx=1.,Ly=1.,Lz=1.,mu_0=1.27e-6; if ((x>-0.5) && (x<0.5) && (y>-0.5) && (y<0.5) && (z>-0.5) &&(z<0.5)) { return std::cos(m * pi / Lx * (x - Lx / 2)) * std::cos(n * pi / Ly * (y - Ly / 2)) * std::sin(p * pi / Lz * (z - Lz / 2))*mu_0; } else { @@ -267,8 +267,8 @@ int main (int argc, char* argv[]) nerror += test3("if ((x>-0.5) and (x<0.5) and (y>-0.5) and (y<0.5) and (z>-0.5) and (z<0.5), cos(m * pi / Lx * (x - Lx / 2)) * cos(n * pi / Ly * (y - Ly / 2)) * sin(p * pi / Lz * (z - Lz / 2))*mu_0*(x>-0.5)*(x<0.5)*(y>-0.5)*(y<0.5)*(z>-0.5)*(z<0.5), 0)", {{"m", 0.0}, {"n", 1.0}, {"pi", 3.14}, {"p", 1.0}, {"Lx", 1.}, {"Ly", 1.}, {"Lz", 1.}, {"mu_0", 1.27e-6}}, {"x","y","z"}, - [=] (Real x, Real y, Real z) -> Real { - Real m=0.0,n=1.0,pi=3.14,p=1.0,Lx=1.,Ly=1.,Lz=1.,mu_0=1.27e-6; + [=] (double x, double y, double z) -> double { + double m=0.0,n=1.0,pi=3.14,p=1.0,Lx=1.,Ly=1.,Lz=1.,mu_0=1.27e-6; if ((x>-0.5) && (x<0.5) && (y>-0.5) && (y<0.5) && (z>-0.5) &&(z<0.5)) { return std::cos(m * pi / Lx * (x - Lx / 2)) * std::cos(n * pi / Ly * (y - Ly / 2)) * std::sin(p * pi / Lz * (z - Lz / 2))*mu_0; } else { @@ -281,8 +281,8 @@ int main (int argc, char* argv[]) nerror += test3("if ((-0.5 < x < 0.5) and (-0.5< (x+y) <0.5) and (-0.5 Real { - Real m=0.0,n=1.0,pi=3.14,p=1.0,Lx=1.,Ly=1.,Lz=1.,mu_0=1.27e-6; + [=] (double x, double y, double z) -> double { + double m=0.0,n=1.0,pi=3.14,p=1.0,Lx=1.,Ly=1.,Lz=1.,mu_0=1.27e-6; if ((x>-0.5) && (x<0.5) && ((x+y)>-0.5) && ((x+y)<0.5) && (z>-0.5) &&(z<0.5)) { return std::cos(m * pi / Lx * (x - Lx / 2)) * std::cos(n * pi / Ly * (y - Ly / 2)) * std::sin(p * pi / Lz * (z - Lz / 2))*mu_0; } else { @@ -295,8 +295,8 @@ int main (int argc, char* argv[]) nerror += test3("cos(m * pi / Lx * (x - Lx / 2)) * cos(n * pi / Ly * (y - Ly / 2)) * sin(p * pi / Lz * (z - Lz / 2))*mu_0*(0.5>x>y>z>(x+z)>-0.5)", {{"m", 0.0}, {"n", 1.0}, {"pi", 3.14}, {"p", 1.0}, {"Lx", 1.}, {"Ly", 1.}, {"Lz", 1.}, {"mu_0", 1.27e-6}}, {"x","y","z"}, - [=] (Real x, Real y, Real z) -> Real { - Real m=0.0,n=1.0,pi=3.14,p=1.0,Lx=1.,Ly=1.,Lz=1.,mu_0=1.27e-6; + [=] (double x, double y, double z) -> double { + double m=0.0,n=1.0,pi=3.14,p=1.0,Lx=1.,Ly=1.,Lz=1.,mu_0=1.27e-6; if ((0.5>x) && (x>y) && (y>z) && (z>(x+z)) && ((x+z)>-0.5)) { return std::cos(m * pi / Lx * (x - Lx / 2)) * std::cos(n * pi / Ly * (y - Ly / 2)) * std::sin(p * pi / Lz * (z - Lz / 2))*mu_0; } else { @@ -309,8 +309,8 @@ int main (int argc, char* argv[]) nerror += test3("2.*sqrt(2.)+sqrt(-log(x))*cos(2*pi*z)", {{"pi", 3.14}}, {"x","y","z"}, - [=] (Real x, Real, Real z) -> Real { - Real pi = 3.14; + [=] (double x, double, double z) -> double { + double pi = 3.14; return 2.*std::sqrt(2.)+std::sqrt(-std::log(x))*std::cos(2*pi*z); }, {0.5, 0.8, 0.3}, {16, 16, 16}, 100, @@ -319,8 +319,8 @@ int main (int argc, char* argv[]) nerror += test1("nc*n0*(if(abs(z)<=r0, 1.0, if(abs(z) Real { - Real nc=1.742e27, n0=30., r0=2.5e-6, Lcut=2.e-6, L=0.05e-6; + [=] (double z) -> double { + double nc=1.742e27, n0=30., r0=2.5e-6, Lcut=2.e-6, L=0.05e-6; if (std::abs(z) <= r0) { return nc*n0; } else if (std::abs(z) < r0+Lcut) { @@ -335,8 +335,8 @@ int main (int argc, char* argv[]) nerror += test1("(zlramp)*dens", {{"lramp",8.e-3},{"pi",3.14},{"dens",1.e23}}, {"z"}, - [=] (Real z) -> Real { - Real lramp=8.e-3, pi=3.14, dens=1.e23; + [=] (double z) -> double { + double lramp=8.e-3, pi=3.14, dens=1.e23; if (z < lramp) { return 0.5*(1-std::cos(pi*z/lramp))*dens; } else { @@ -349,8 +349,8 @@ int main (int argc, char* argv[]) nerror += test1("if(z Real { - Real lramp=8.e-3, pi=3.14, dens=1.e23; + [=] (double z) -> double { + double lramp=8.e-3, pi=3.14, dens=1.e23; if (z < lramp) { auto x = std::sin(pi/2*z/lramp); return x*x*dens; @@ -364,8 +364,8 @@ int main (int argc, char* argv[]) nerror += test1("if(z Real { - Real zc=20.e-6, zp=20.05545177444479562e-6, nc=1.74e27, lgrad=0.08e-6, zp2=24.e-6, zc2=24.05545177444479562e6; + [=] (double z) -> double { + double zc=20.e-6, zp=20.05545177444479562e-6, nc=1.74e27, lgrad=0.08e-6, zp2=24.e-6, zc2=24.05545177444479562e6; if (z < zp) { return nc*std::exp((z-zc)/lgrad); } else if (z <= zp2) { @@ -380,8 +380,8 @@ int main (int argc, char* argv[]) nerror += test3("epsilon/kp*2*x/w0**2*exp(-(x**2+y**2)/w0**2)*sin(k0*z)", {{"epsilon",0.01},{"kp",3.5},{"w0",5.e-6},{"k0",3.e5}}, {"x","y","z"}, - [=] (Real x, Real y, Real z) -> Real { - Real epsilon=0.01, kp=3.5, w0=5.e-6, k0=3.e5; + [=] (double x, double y, double z) -> double { + double epsilon=0.01, kp=3.5, w0=5.e-6, k0=3.e5; return epsilon/kp*2*x/(w0*w0)*std::exp(-(x*x+y*y)/(w0*w0))*sin(k0*z); }, {0.e-6, 0.0, -20.e-6}, {20.e-6, 1.e-10, 20.e-6}, 100,