BD_Integratoren/test/test_Calculation.cpp
2021-10-22 21:58:37 +02:00

53 lines
2.2 KiB
C++

//
// Created by jholder on 22.10.21.
//
#include <catch2/catch.hpp>
#include <Calculation.h>
#include "LiveAgg.hpp"
#include "Integratoren2d_forceless.h"
TEST_CASE("Basic run of Calculation") {
Calculation euler(Integratoren2d_forceless::Set1_Euler, {{Compute::Type::msd, 10},
{Compute::Type::oaf, 10}}, 1, 1);
Calculation heun(Integratoren2d_forceless::Set2_Heun, {{Compute::Type::msd, 10},
{Compute::Type::oaf, 10}}, 1, 1);
Calculation exact(Integratoren2d_forceless::Set3_Exact, {{Compute::Type::msd, 10},
{Compute::Type::oaf, 10}}, 1, 1);
Calculation bdas(Integratoren2d_forceless::Set4_BDAS, {{Compute::Type::msd, 10},
{Compute::Type::oaf, 10}}, 1, 1);
SECTION("Euler") {
euler.run(100);
CHECK(euler.getRod().getE().norm() == Catch::Detail::Approx(1.0));
CHECK(euler.getComputes()[0].getType() == Compute::Type::msd);
CHECK(euler.getComputes()[1].getType() == Compute::Type::oaf);
}SECTION("Heun") {
heun.run(100);
CHECK(heun.getRod().getE().norm() == Catch::Detail::Approx(1.0));
}SECTION("Exact") {
exact.run(100);
CHECK(exact.getRod().getE().norm() == Catch::Detail::Approx(1.0));
}SECTION("Euler") {
bdas.run(100);
CHECK(bdas.getRod().getE().norm() == Catch::Detail::Approx(1.0));
}
SECTION("MSD") {
euler.run(100);
CHECK(euler.getComputes()[0].getAgg().getNumPoints() == 10);
CHECK(euler.getComputes()[1].getAgg().getNumPoints() == 10);
}SECTION("Deterministic") {
Calculation determ(Integratoren2d_forceless::Set0_deterministic,
{{Compute::Type::msd, 1},
{Compute::Type::oaf, 1}}, 1, 1);
determ.run(10);
auto time = 1;
auto targetMSD = pow(0.01, 2) * time;
auto targetOAF = cos(0.1);
CHECK(determ.getComputes()[0].getAgg().getMean() == Catch::Detail::Approx(targetMSD));
CHECK(determ.getComputes()[1].getAgg().getMean() == Catch::Detail::Approx(targetOAF));
}
}