357 lines
12 KiB
C++
357 lines
12 KiB
C++
//
|
|
// Created by jholder on 24.10.21.
|
|
//
|
|
#include "Calculation.h"
|
|
#include "Compute.h"
|
|
#include "Integratoren2d_force.h"
|
|
#include "Integratoren2d_forceless.h"
|
|
|
|
#include <catch2/catch.hpp>
|
|
|
|
TEST_CASE("Forceless Integratoren") {
|
|
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;
|
|
|
|
|
|
Calculation euler(Integratoren2d_forceless::Set1_Euler,
|
|
{{Compute::Type::msd, 1},
|
|
{Compute::Type::oaf, 1},
|
|
{Compute::Type::empxx, 1},
|
|
{Compute::Type::empyy, 1}},
|
|
0.01, SEED,length);
|
|
euler.run(steps);
|
|
|
|
Calculation heun(Integratoren2d_forceless::Set2_Heun,
|
|
{{Compute::Type::msd, 1},
|
|
{Compute::Type::oaf, 1},
|
|
{Compute::Type::empxx, 1},
|
|
{Compute::Type::empyy, 1}},
|
|
0.01, SEED,length);
|
|
heun.run(steps);
|
|
|
|
Calculation exact(Integratoren2d_forceless::Set3_Exact,
|
|
{{Compute::Type::msd, 1},
|
|
{Compute::Type::oaf, 1},
|
|
{Compute::Type::empxx, 1},
|
|
{Compute::Type::empyy, 1}},
|
|
0.01, SEED,length);
|
|
exact.run(steps);
|
|
Calculation bdas(Integratoren2d_forceless::Set4_BDAS,
|
|
{{Compute::Type::msd, 1},
|
|
{Compute::Type::oaf, 1},
|
|
{Compute::Type::empxx, 1},
|
|
{Compute::Type::empyy, 1}},
|
|
0.01, SEED,length);
|
|
bdas.run(steps);
|
|
Calculation mbd(Integratoren2d_forceless::Set5_MBD,
|
|
{{Compute::Type::msd, 1},
|
|
{Compute::Type::oaf, 1},
|
|
{Compute::Type::empxx, 1},
|
|
{Compute::Type::empyy, 1}},
|
|
0.01, SEED,length);
|
|
mbd.run(steps);
|
|
SECTION("ForceLess Euler") {
|
|
CAPTURE(length);
|
|
size_t i = 0;
|
|
for (auto &c: euler.getComputes()) {
|
|
CAPTURE(c);
|
|
CHECK(c.getDifference() <= delta*c.getAgg().getMean());
|
|
++i;
|
|
}
|
|
}
|
|
SECTION("ForceLess Heun") {
|
|
CAPTURE(length);
|
|
size_t i = 0;
|
|
for (auto &c: heun.getComputes()) {
|
|
CAPTURE(c);
|
|
CHECK(c.getDifference() <= delta*c.getAgg().getMean());
|
|
++i;
|
|
}
|
|
}
|
|
SECTION("ForceLess Exact") {
|
|
CAPTURE(length);
|
|
size_t i = 0;
|
|
for (auto &c: exact.getComputes()) {
|
|
CAPTURE(c);
|
|
CHECK(c.getDifference() <= delta*c.getAgg().getMean());
|
|
++i;
|
|
}
|
|
}
|
|
SECTION("ForceLess BDAS") {
|
|
CAPTURE(length);
|
|
size_t i = 0;
|
|
for (auto &c: bdas.getComputes()) {
|
|
CAPTURE(c);
|
|
CHECK(c.getDifference() <= delta*c.getAgg().getMean());
|
|
++i;
|
|
}
|
|
}
|
|
SECTION("ForceLess MBD") {
|
|
CAPTURE(length);
|
|
size_t i = 0;
|
|
for (auto &c: mbd.getComputes()) {
|
|
CAPTURE(c);
|
|
CHECK(c.getDifference() <= delta*c.getAgg().getMean());
|
|
++i;
|
|
}
|
|
}
|
|
|
|
[[maybe_unused]] auto zero_Force =
|
|
[](const Eigen::Vector2d & /*pos*/,
|
|
const Eigen::Vector2d & /*torque*/) -> Eigen::Vector2d {
|
|
return {0.0, 0.0};
|
|
};
|
|
[[maybe_unused]] auto zero_Torque = [](const Eigen::Vector2d & /*pos*/,
|
|
const Eigen::Vector2d & /*torque*/) -> double {
|
|
return 0.0;
|
|
};
|
|
Calculation euler_zero(Integratoren2d_force::Set1_Euler,
|
|
{{Compute::Type::msd, 1},
|
|
{Compute::Type::oaf, 1},
|
|
{Compute::Type::empxx, 1},
|
|
{Compute::Type::empyy, 1}},
|
|
0.01, SEED,zero_Force,zero_Torque,length);
|
|
euler_zero.run(steps);
|
|
|
|
Calculation heun_zero(Integratoren2d_force::Set2_Heun,
|
|
{{Compute::Type::msd, 1},
|
|
{Compute::Type::oaf, 1},
|
|
{Compute::Type::empxx, 1},
|
|
{Compute::Type::empyy, 1}},
|
|
0.01, SEED,zero_Force,zero_Torque,length);
|
|
heun_zero.run(steps);
|
|
|
|
Calculation exact_zero(Integratoren2d_force::Set3_Exact,
|
|
{{Compute::Type::msd, 1},
|
|
{Compute::Type::oaf, 1},
|
|
{Compute::Type::empxx, 1},
|
|
{Compute::Type::empyy, 1}},
|
|
0.01, SEED,zero_Force,zero_Torque,length);
|
|
exact_zero.run(steps);
|
|
|
|
Calculation bdas_zero(Integratoren2d_force::Set4_BDAS,
|
|
{{Compute::Type::msd, 1},
|
|
{Compute::Type::oaf, 1},
|
|
{Compute::Type::empxx, 1},
|
|
{Compute::Type::empyy, 1}},
|
|
0.01, SEED,zero_Force,zero_Torque,length);
|
|
bdas_zero.run(steps);
|
|
|
|
Calculation mbd_zero(Integratoren2d_force::Set5_MBD,
|
|
{{Compute::Type::msd, 1},
|
|
{Compute::Type::oaf, 1},
|
|
{Compute::Type::empxx, 1},
|
|
{Compute::Type::empyy, 1}},
|
|
0.01, SEED,zero_Force,zero_Torque,length);
|
|
mbd_zero.run(steps);
|
|
SECTION("Force Euler") {
|
|
CAPTURE(length);
|
|
size_t i = 0;
|
|
for (auto &c: euler_zero.getComputes()) {
|
|
CAPTURE(c);
|
|
CHECK(c.getDifference() <= delta*c.getAgg().getMean());
|
|
++i;
|
|
}
|
|
}
|
|
SECTION("Force Heun") {
|
|
CAPTURE(length);
|
|
|
|
size_t i = 0;
|
|
for (auto &c: heun_zero.getComputes()) {
|
|
CAPTURE(c);
|
|
CHECK(c.getDifference() <= delta*c.getAgg().getMean());
|
|
++i;
|
|
}
|
|
}
|
|
SECTION("Force Exact") {
|
|
CAPTURE(length);
|
|
size_t i = 0;
|
|
for (auto &c: exact_zero.getComputes()) {
|
|
CAPTURE(c);
|
|
CHECK(c.getDifference() <= delta*c.getAgg().getMean());
|
|
++i;
|
|
}
|
|
}
|
|
SECTION("Force BDAS") {
|
|
CAPTURE(length);
|
|
size_t i = 0;
|
|
for (auto &c: bdas_zero.getComputes()) {
|
|
CAPTURE(c);
|
|
CHECK(c.getDifference() <= delta*c.getAgg().getMean());
|
|
++i;
|
|
}
|
|
}
|
|
SECTION("Force MBD") {
|
|
CAPTURE(length);
|
|
size_t i = 0;
|
|
for (auto &c: mbd_zero.getComputes()) {
|
|
CAPTURE(c);
|
|
CHECK(c.getDifference() <= delta*c.getAgg().getMean());
|
|
++i;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SECTION("Euler") {
|
|
|
|
{
|
|
|
|
}
|
|
|
|
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},
|
|
{Compute::Type::empxx, 1},
|
|
{Compute::Type::empyy, 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},
|
|
{Compute::Type::empxx, 1},
|
|
{Compute::Type::empyy, 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},
|
|
{Compute::Type::empxx, 1},
|
|
{Compute::Type::empyy, 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},
|
|
{Compute::Type::empxx, 1},
|
|
{Compute::Type::empyy, 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},
|
|
{Compute::Type::empxx, 1},
|
|
{Compute::Type::empyy, 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},
|
|
{Compute::Type::empxx, 1},
|
|
{Compute::Type::empyy, 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() ==
|
|
Approx(bdas_force.getComputes()[0].getAgg().getMean())
|
|
.epsilon(10e-10));
|
|
CHECK(bdas.getComputes()[1].getAgg().getMean() ==
|
|
Approx(bdas_force.getComputes()[1].getAgg().getMean())
|
|
.epsilon(10e-10));
|
|
}
|
|
|
|
SECTION("MBD") {
|
|
Calculation mbd(Integratoren2d_forceless::Set5_MBD,
|
|
{{Compute::Type::msd, 1},
|
|
{Compute::Type::oaf, 1},
|
|
{Compute::Type::empxx, 1},
|
|
{Compute::Type::empyy, 1}},
|
|
0.01, SEED);
|
|
{
|
|
mbd.run(10000);
|
|
for (auto &c : mbd.getComputes()) {
|
|
CHECK(c.getDifference() <= 0.005);
|
|
}
|
|
}
|
|
|
|
Calculation mbd_force(Integratoren2d_force::Set5_MBD,
|
|
{{Compute::Type::msd, 1},
|
|
{Compute::Type::oaf, 1},
|
|
{Compute::Type::empxx, 1},
|
|
{Compute::Type::empyy, 1}},
|
|
0.01, SEED, force, torque);
|
|
{
|
|
mbd_force.run(10000);
|
|
for (auto &c : mbd_force.getComputes()) {
|
|
CHECK(c.getDifference() <= 0.005);
|
|
}
|
|
}
|
|
CHECK(mbd.getComputes()[0].getAgg().getMean() ==
|
|
Approx(mbd_force.getComputes()[0].getAgg().getMean())
|
|
.epsilon(10e-10));
|
|
CHECK(mbd.getComputes()[1].getAgg().getMean() ==
|
|
Approx(mbd_force.getComputes()[1].getAgg().getMean())
|
|
.epsilon(10e-10));
|
|
}
|
|
}
|
|
*/ |