diff --git a/src/framework/tests/grid_mesh.cpp b/src/framework/tests/grid_mesh.cpp index 17f734a19..4dea275ce 100644 --- a/src/framework/tests/grid_mesh.cpp +++ b/src/framework/tests/grid_mesh.cpp @@ -39,7 +39,7 @@ auto main(int argc, char* argv[]) -> int { HERE); raise::ErrorIf(mesh.extent(d) != ext[(unsigned short)d], "extent != ext", HERE); } - raise::ErrorIf(not cmp::AlmostEqual(mesh.metric.dxMin(), (real_t)0.1154700538), + raise::ErrorIf(not cmp::AlmostEqual(mesh.metric.dxMin(), (real_t)(0.2 / std::sqrt(3.0))), "dxMin wrong", HERE); } catch (const std::exception& e) { diff --git a/src/framework/tests/parameters.cpp b/src/framework/tests/parameters.cpp index 7b353a542..8f02d1750 100644 --- a/src/framework/tests/parameters.cpp +++ b/src/framework/tests/parameters.cpp @@ -275,10 +275,6 @@ auto main(int argc, char* argv[]) -> int { fbc.size(), "grid.boundaries.fields.size()"); - assert_equal(params_mink_1d.get("particles.nspec"), - (std::size_t)2, - "particles.nspec"); - const auto species = params_mink_1d.get>( "particles.species"); assert_equal(species[0].label(), "e-", "species[0].label"); @@ -380,10 +376,6 @@ auto main(int argc, char* argv[]) -> int { true, "particles.use_weights"); - assert_equal(params_sph_2d.get("particles.nspec"), - (std::size_t)3, - "particles.nspec"); - assert_equal(params_sph_2d.get("algorithms.gca.e_ovr_b_max"), (real_t)0.95, "algorithms.gca.e_ovr_b_max"); @@ -460,7 +452,7 @@ auto main(int argc, char* argv[]) -> int { (real_t)(0.99), "grid.metric.ks_a"); assert_equal(params_qks_2d.get("grid.metric.ks_rh"), - (real_t)(1.1410673598), + (real_t)((1.0 + std::sqrt(1 - 0.99 * 0.99))), "grid.metric.ks_rh"); const auto expect = std::map { @@ -532,10 +524,6 @@ auto main(int argc, char* argv[]) -> int { defaults::bc::absorb::coeff, "grid.boundaries.absorb.coeff"); - assert_equal(params_qks_2d.get("particles.nspec"), - (std::size_t)2, - "particles.nspec"); - const auto species = params_qks_2d.get>( "particles.species"); assert_equal(species[0].label(), "e-", "species[0].label"); diff --git a/src/kernels/tests/deposit.cpp b/src/kernels/tests/deposit.cpp index 26d2e71eb..02292c643 100644 --- a/src/kernels/tests/deposit.cpp +++ b/src/kernels/tests/deposit.cpp @@ -85,17 +85,21 @@ void testDeposit(const std::vector& res, auto J_scat = Kokkos::Experimental::create_scatter_view(J); - const real_t xi = 0.53, xf = 0.47; - const real_t yi = 0.34, yf = 0.52; + const int i0 = 4, j0 = 4; + + const prtldx_t dxi = 0.53, dxf = 0.47; + const prtldx_t dyi = 0.34, dyf = 0.52; + const real_t xi = (real_t)i0 + (real_t)dxi, xf = (real_t)i0 + (real_t)dxf; + const real_t yi = (real_t)j0 + (real_t)dyi, yf = (real_t)j0 + (real_t)dyf; const real_t xr = 0.5 * (xi + xf); const real_t yr = 0.5 * (yi + yf); - const real_t Wx1 = 0.5 * (xi + xr); - const real_t Wx2 = 0.5 * (xf + xr); + const real_t Wx1 = 0.5 * (xi + xr) - (real_t)i0; + const real_t Wx2 = 0.5 * (xf + xr) - (real_t)i0; - const real_t Wy1 = 0.5 * (yi + yr); - const real_t Wy2 = 0.5 * (yf + yr); + const real_t Wy1 = 0.5 * (yi + yr) - (real_t)j0; + const real_t Wy2 = 0.5 * (yf + yr) - (real_t)j0; const real_t Fx1 = (xr - xi); const real_t Fx2 = (xf - xr); @@ -109,16 +113,14 @@ void testDeposit(const std::vector& res, const real_t Jy1 = Fy1 * (1 - Wx1) + Fy2 * (1 - Wx2); const real_t Jy2 = Fy1 * Wx1 + Fy2 * Wx2; - const int i0 = 4, j0 = 4; - put_value(i1, i0, 0); put_value(i2, j0, 0); put_value(i1_prev, i0, 0); put_value(i2_prev, j0, 0); - put_value(dx1, xf, 0); - put_value(dx2, yf, 0); - put_value(dx1_prev, xi, 0); - put_value(dx2_prev, yi, 0); + put_value(dx1, dxf, 0); + put_value(dx2, dyf, 0); + put_value(dx1_prev, dxi, 0); + put_value(dx2_prev, dyi, 0); put_value(weight, 1.0, 0); put_value(tag, ParticleTag::alive, 0); diff --git a/src/kernels/tests/particle_moments.cpp b/src/kernels/tests/particle_moments.cpp index 29b1c3598..25ed7d4d9 100644 --- a/src/kernels/tests/particle_moments.cpp +++ b/src/kernels/tests/particle_moments.cpp @@ -225,24 +225,22 @@ void testParticleMoments(const std::vector& res, } } } - const real_t gamma_1 = math::sqrt( - ONE + v1[0] * v1[0] + v1[1] * v1[1] + v1[2] * v1[2]); - const real_t gamma_2 = math::sqrt( - ONE + v2[0] * v2[0] + v2[1] * v2[1] + v2[2] * v2[2]); + const real_t gammaSQR_1 = ONE + v1[0] * v1[0] + v1[1] * v1[1] + v1[2] * v1[2]; + const real_t gammaSQR_2 = ONE + v2[0] * v2[0] + v2[1] * v2[1] + v2[2] * v2[2]; - const real_t gamma_1_expect = math::sqrt(1.0 + 1.0 + 4.0 + 9.0); - const real_t gamma_2_expect = math::sqrt(1.0 + 9.0 + 4.0 + 1.0); + const real_t gammaSQR_1_expect = 15.0; + const real_t gammaSQR_2_expect = 15.0; - errorIf(not cmp::AlmostEqual(gamma_1, gamma_1_expect, epsilon * acc), - fmt::format("wrong gamma_1 %.8e %.8e for %dD %s", - gamma_1, - gamma_1_expect, + errorIf(not cmp::AlmostEqual_host(gammaSQR_1, gammaSQR_1_expect, epsilon * acc), + fmt::format("wrong gamma_1 %.12e %.12e for %dD %s", + gammaSQR_1, + gammaSQR_1_expect, metric.Dim, metric.Label)); - errorIf(not cmp::AlmostEqual(gamma_2, gamma_2_expect, epsilon * acc), - fmt::format("wrong gamma_2 %.8e %.8e for %dD %s", - gamma_2, - gamma_2_expect, + errorIf(not cmp::AlmostEqual_host(gammaSQR_2, gammaSQR_2_expect, epsilon * acc), + fmt::format("wrong gamma_2 %.12e %.12e for %dD %s", + gammaSQR_2, + gammaSQR_2_expect, metric.Dim, metric.Label)); } @@ -260,7 +258,8 @@ auto main(int argc, char* argv[]) -> int { 10 }, { { 0.0, 10.0 }, { 0.0, 10.0 } }, - {}); + {}, + 10); testParticleMoments>( { diff --git a/src/kernels/tests/prtl_bc.cpp b/src/kernels/tests/prtl_bc.cpp index a8817c36f..fa1103043 100644 --- a/src/kernels/tests/prtl_bc.cpp +++ b/src/kernels/tests/prtl_bc.cpp @@ -266,7 +266,6 @@ void testPeriodicBC(const std::vector& res, metric.template convert_xyz(xCd_1, xPh_1); metric.template convert_xyz(xCd_2, xPh_2); - // printf("t = %f\n", time); if constexpr (M::Dim == Dim::_1D or M::Dim == Dim::_2D or M::Dim == Dim::_3D) { xi_1 += dt * ux_1 / gamma_1; xi_2 += dt * ux_2 / gamma_2; @@ -282,12 +281,12 @@ void testPeriodicBC(const std::vector& res, if (xi_2 < extent[0].first) { xi_2 += sx; } - // printf(" x_1 = %.6e | %.6e\n", xPh_1[0], xi_1); - // printf(" x_2 = %.6e | %.6e\n", xPh_2[0], xi_2); - errorIf( - not equal(xPh_1[0], xi_1, fmt::format("xPh_1[0] != xi_1 @ t = %f", time))); - errorIf( - not equal(xPh_2[0], xi_2, fmt::format("xPh_2[0] != xi_2 @ t = %f", time))); + errorIf(not equal(xPh_1[0] / sx, + xi_1 / sx, + fmt::format("xPh_1[0] != xi_1 @ t = %f", time))); + errorIf(not equal(xPh_2[0] / sx, + xi_2 / sx, + fmt::format("xPh_2[0] != xi_2 @ t = %f", time))); } if constexpr (M::Dim == Dim::_2D or M::Dim == Dim::_3D) { yi_1 += dt * uy_1 / gamma_1; @@ -304,12 +303,12 @@ void testPeriodicBC(const std::vector& res, if (yi_2 < extent[1].first) { yi_2 += sy; } - // printf(" y_1 = %.6e | %.6e\n", xPh_1[1], yi_1); - // printf(" y_2 = %.6e | %.6e\n", xPh_2[1], yi_2); - errorIf( - not equal(xPh_1[1], yi_1, fmt::format("xPh_1[1] != yi_1 @ t = %f", time))); - errorIf( - not equal(xPh_2[1], yi_2, fmt::format("xPh_2[1] != yi_2 @ t = %f", time))); + errorIf(not equal(xPh_1[1] / sy, + yi_1 / sy, + fmt::format("xPh_1[1] != yi_1 @ t = %f", time))); + errorIf(not equal(xPh_2[1] / sy, + yi_2 / sy, + fmt::format("xPh_2[1] != yi_2 @ t = %f", time))); } if constexpr (M::Dim == Dim::_3D) { zi_1 += dt * uz_1 / gamma_1; @@ -326,12 +325,12 @@ void testPeriodicBC(const std::vector& res, if (zi_2 < extent[2].first) { zi_2 += sz; } - // printf(" z_1 = %.6e | %.6e\n", xPh_1[2], zi_1); - // printf(" z_2 = %.6e | %.6e\n", xPh_2[2], zi_2); - errorIf( - not equal(xPh_1[2], zi_1, fmt::format("xPh_1[2] != zi_1 @ t = %f", time))); - errorIf( - not equal(xPh_2[2], zi_2, fmt::format("xPh_2[2] != zi_2 @ t = %f", time))); + errorIf(not equal(xPh_1[2] / sz, + zi_1 / sz, + fmt::format("xPh_1[2] != zi_1 @ t = %f", time))); + errorIf(not equal(xPh_2[2] / sz, + zi_2 / sz, + fmt::format("xPh_2[2] != zi_2 @ t = %f", time))); } time += dt; }