Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/framework/tests/grid_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 1 addition & 13 deletions src/framework/tests/parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,6 @@ auto main(int argc, char* argv[]) -> int {
fbc.size(),
"grid.boundaries.fields.size()");

assert_equal(params_mink_1d.get<std::size_t>("particles.nspec"),
(std::size_t)2,
"particles.nspec");

const auto species = params_mink_1d.get<std::vector<ParticleSpecies>>(
"particles.species");
assert_equal<std::string>(species[0].label(), "e-", "species[0].label");
Expand Down Expand Up @@ -380,10 +376,6 @@ auto main(int argc, char* argv[]) -> int {
true,
"particles.use_weights");

assert_equal(params_sph_2d.get<std::size_t>("particles.nspec"),
(std::size_t)3,
"particles.nspec");

assert_equal(params_sph_2d.get<real_t>("algorithms.gca.e_ovr_b_max"),
(real_t)0.95,
"algorithms.gca.e_ovr_b_max");
Expand Down Expand Up @@ -460,7 +452,7 @@ auto main(int argc, char* argv[]) -> int {
(real_t)(0.99),
"grid.metric.ks_a");
assert_equal<real_t>(params_qks_2d.get<real_t>("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<std::string, real_t> {
Expand Down Expand Up @@ -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<std::size_t>("particles.nspec"),
(std::size_t)2,
"particles.nspec");

const auto species = params_qks_2d.get<std::vector<ParticleSpecies>>(
"particles.species");
assert_equal<std::string>(species[0].label(), "e-", "species[0].label");
Expand Down
26 changes: 14 additions & 12 deletions src/kernels/tests/deposit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,21 @@ void testDeposit(const std::vector<std::size_t>& 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);
Expand All @@ -109,16 +113,14 @@ void testDeposit(const std::vector<std::size_t>& 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<int>(i1, i0, 0);
put_value<int>(i2, j0, 0);
put_value<int>(i1_prev, i0, 0);
put_value<int>(i2_prev, j0, 0);
put_value<prtldx_t>(dx1, xf, 0);
put_value<prtldx_t>(dx2, yf, 0);
put_value<prtldx_t>(dx1_prev, xi, 0);
put_value<prtldx_t>(dx2_prev, yi, 0);
put_value<prtldx_t>(dx1, dxf, 0);
put_value<prtldx_t>(dx2, dyf, 0);
put_value<prtldx_t>(dx1_prev, dxi, 0);
put_value<prtldx_t>(dx2_prev, dyi, 0);
put_value<real_t>(weight, 1.0, 0);
put_value<short>(tag, ParticleTag::alive, 0);

Expand Down
29 changes: 14 additions & 15 deletions src/kernels/tests/particle_moments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,24 +225,22 @@ void testParticleMoments(const std::vector<std::size_t>& 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));
}
Expand All @@ -260,7 +258,8 @@ auto main(int argc, char* argv[]) -> int {
10
},
{ { 0.0, 10.0 }, { 0.0, 10.0 } },
{});
{},
10);

testParticleMoments<SimEngine::SRPIC, Spherical<Dim::_2D>>(
{
Expand Down
37 changes: 18 additions & 19 deletions src/kernels/tests/prtl_bc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ void testPeriodicBC(const std::vector<std::size_t>& res,
metric.template convert_xyz<Crd::Cd, Crd::XYZ>(xCd_1, xPh_1);
metric.template convert_xyz<Crd::Cd, Crd::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;
Expand All @@ -282,12 +281,12 @@ void testPeriodicBC(const std::vector<std::size_t>& 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;
Expand All @@ -304,12 +303,12 @@ void testPeriodicBC(const std::vector<std::size_t>& 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;
Expand All @@ -326,12 +325,12 @@ void testPeriodicBC(const std::vector<std::size_t>& 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;
}
Expand Down