63 lines
2.1 KiB
C++
63 lines
2.1 KiB
C++
|
|
//
|
|
// Created by jholder on 24.10.21.
|
|
//
|
|
#include "Calculation.h"
|
|
#include "Compute.h"
|
|
#include "Integratoren2d.h"
|
|
#include "force_lambdas.h"
|
|
|
|
#include <catch2/catch.hpp>
|
|
#include <utility>
|
|
|
|
TEST_CASE("Integrator Check") {
|
|
const size_t SEED = Catch::rngSeed();
|
|
const double length = GENERATE(1.0, 1.4, 2.0);
|
|
constexpr int steps = 10000;
|
|
constexpr double delta = 0.1;
|
|
|
|
using type = std::tuple<std::function<void(Rod2d &, Simulation &)>, Calculation::inte_force_type, std::string>;
|
|
auto[integrator, integrator_force, name] = GENERATE(
|
|
type(Integratoren2d::Set1_Euler, Integratoren2d::Set1_Euler_f, "Euler"),
|
|
type(Integratoren2d::Set2_Heun, Integratoren2d::Set2_Heun_f, "Heun"),
|
|
type(Integratoren2d::Set3_Exact, Integratoren2d::Set3_Exact_f, "Exact"),
|
|
type(Integratoren2d::Set4_BDAS, Integratoren2d::Set4_BDAS_f, "BDAS"),
|
|
type(Integratoren2d::Set5_MBD, Integratoren2d::Set5_MBD_f, "MBD"));
|
|
|
|
Calculation calc(integrator,
|
|
{{Compute::Type::msd, 1},
|
|
{Compute::Type::oaf, 1},
|
|
{Compute::Type::empxx, 1},
|
|
{Compute::Type::empyy, 1}},
|
|
0.01, SEED, length);
|
|
calc.run(steps);
|
|
SECTION("ForceLess") {
|
|
CAPTURE(name);
|
|
CAPTURE(length);
|
|
size_t i = 0;
|
|
for (const auto &c: calc.getComputes()) {
|
|
CAPTURE(c);
|
|
CHECK(c.getDifference() <= delta * c.getAgg().getMean());
|
|
++i;
|
|
}
|
|
}
|
|
|
|
Calculation calc_f(integrator_force,
|
|
{{Compute::Type::msd, 1},
|
|
{Compute::Type::oaf, 1},
|
|
{Compute::Type::empxx, 1},
|
|
{Compute::Type::empyy, 1}},
|
|
0.01, SEED, zero_Force, zero_Torque, length);
|
|
calc_f.run(steps);
|
|
|
|
SECTION("ForceLess") {
|
|
CAPTURE(length);
|
|
CAPTURE(name);
|
|
for (const auto &c: calc_f.getComputes()) {
|
|
CAPTURE(c);
|
|
CHECK(c.getDifference() <= delta * c.getAgg().getMean());
|
|
}
|
|
}
|
|
|
|
}
|