90 lines
4.3 KiB
C++
90 lines
4.3 KiB
C++
//
|
|
// Created by jholder on 24.10.21.
|
|
//
|
|
#include <catch2/catch.hpp>
|
|
#include <Integratoren2d_forceless.h>
|
|
#include <Calculation.h>
|
|
#include <Compute.h>
|
|
#include <Integratoren2d_force.h>
|
|
|
|
TEST_CASE("Forceless Integratoren") {
|
|
const size_t SEED = Catch::rngSeed();
|
|
auto force = [](const Eigen::Vector2d & /*pos*/,
|
|
const Eigen::Vector2d & /*torque*/) -> Eigen::Vector2d { return {0.0, 0.0}; };
|
|
auto torque = [](const Eigen::Vector2d & /*pos*/,
|
|
const Eigen::Vector2d & /*torque*/) -> double { return 0.0; };
|
|
SECTION("Euler") {
|
|
|
|
Calculation euler(Integratoren2d_forceless::Set1_Euler, {{Compute::Type::msd, 1},
|
|
{Compute::Type::oaf, 1}}, 0.01, SEED);
|
|
{
|
|
euler.run(10000);
|
|
for (auto &c: euler.getComputes()) { CHECK(c.getDifference() <= 0.005); }
|
|
}
|
|
|
|
Calculation euler_force(Integratoren2d_force::Set1_Euler, {
|
|
{Compute::Type::msd, 1},
|
|
{Compute::Type::oaf, 1}}, 0.01, SEED, force, torque);
|
|
{
|
|
euler_force.run(10000);
|
|
for (auto &c: euler_force.getComputes()) { CHECK(c.getDifference() <= 0.005); }
|
|
}
|
|
CHECK(euler.getComputes()[0].getAgg().getMean() == euler_force.getComputes()[0].getAgg().getMean());
|
|
CHECK(euler.getComputes()[1].getAgg().getMean() == euler_force.getComputes()[1].getAgg().getMean());
|
|
}SECTION("Heun") {
|
|
|
|
Calculation heun(Integratoren2d_forceless::Set2_Heun, {{Compute::Type::msd, 1},
|
|
{Compute::Type::oaf, 1}}, 0.01, SEED);
|
|
{
|
|
heun.run(10000);
|
|
for (auto &c: heun.getComputes()) { CHECK(c.getDifference() <= 0.005); }
|
|
}
|
|
|
|
Calculation heun_force(Integratoren2d_force::Set2_Heun, {{Compute::Type::msd, 1},
|
|
{Compute::Type::oaf, 1}}, 0.01, SEED, force,
|
|
torque);
|
|
{
|
|
heun_force.run(10000);
|
|
for (auto &c: heun_force.getComputes()) { CHECK(c.getDifference() <= 0.005); }
|
|
}
|
|
CHECK(heun.getComputes()[0].getAgg().getMean() == heun_force.getComputes()[0].getAgg().getMean());
|
|
CHECK(heun.getComputes()[1].getAgg().getMean() == heun_force.getComputes()[1].getAgg().getMean());
|
|
}SECTION("Exact") {
|
|
|
|
Calculation exact(Integratoren2d_forceless::Set3_Exact, {{Compute::Type::msd, 1},
|
|
{Compute::Type::oaf, 1}}, 0.01, SEED);
|
|
{
|
|
exact.run(10000);
|
|
for (auto &c: exact.getComputes()) { CHECK(c.getDifference() <= 0.005); }
|
|
}
|
|
|
|
Calculation exact_force(Integratoren2d_force::Set3_Exact, {{Compute::Type::msd, 1},
|
|
{Compute::Type::oaf, 1}}, 0.01, SEED, force,
|
|
torque);
|
|
{
|
|
exact_force.run(10000);
|
|
for (auto &c: exact_force.getComputes()) { CHECK(c.getDifference() <= 0.005); }
|
|
}
|
|
CHECK(exact.getComputes()[0].getAgg().getMean() == Approx(exact_force.getComputes()[0].getAgg().getMean()).epsilon(1e-10));
|
|
CHECK(exact.getComputes()[1].getAgg().getMean() == exact_force.getComputes()[1].getAgg().getMean());
|
|
}SECTION("BDAS") {
|
|
|
|
Calculation bdas(Integratoren2d_forceless::Set4_BDAS, {{Compute::Type::msd, 1},
|
|
{Compute::Type::oaf, 1}}, 0.01, SEED);
|
|
{
|
|
bdas.run(10000);
|
|
for (auto &c: bdas.getComputes()) { CHECK(c.getDifference() <= 0.005); }
|
|
}
|
|
|
|
Calculation bdas_force(Integratoren2d_force::Set4_BDAS, {{Compute::Type::msd, 1},
|
|
{Compute::Type::oaf, 1}}, 0.01, SEED, force,
|
|
torque);
|
|
{
|
|
bdas_force.run(10000);
|
|
for (auto &c: bdas_force.getComputes()) { CHECK(c.getDifference() <= 0.005); }
|
|
}
|
|
CHECK(bdas.getComputes()[0].getAgg().getMean() == bdas_force.getComputes()[0].getAgg().getMean());
|
|
CHECK(bdas.getComputes()[1].getAgg().getMean() == bdas_force.getComputes()[1].getAgg().getMean());
|
|
}
|
|
}
|