1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Tests/Functional/Consistence/ConsistenceTests.cpp
//! @brief Implements Core consistence tests through gtest macros.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
// These tests check whether pairs of reference data sets, generated by
// some other tests, coincide within reasonable numeric error margins.
#include "Device/Data/Datafield.h"
#include "Sample/StandardSample/CylindersAndPrismsBuilder.h"
#include "Sample/StandardSample/PlainMultiLayerBySLDBuilder.h"
#include "Sim/Simulation/ScatteringSimulation.h"
#include "Sim/Simulation/SpecularSimulation.h"
#include "Tests/GTestWrapper/google_test.h"
#include "Tests/SimFactory/MakeSimulations.h"
#include <string>
int compareTwoReferences(const std::string& name0, const std::string& name1, double limit);
TEST(Consistence, SpecularWithSlicing)
{
EXPECT_TRUE(compareTwoReferences("SpecularWithSlicing1", "SpecularWithSlicing2", 2e-10));
EXPECT_TRUE(compareTwoReferences("SpecularWithSlicing1", "SpecularWithSlicing3", 2e-10));
}
TEST(Consistence, DepthprobeEffectiveLayer)
{
EXPECT_TRUE(compareTwoReferences("DepthprobeAveragedLayer", "DepthprobeSimpleLayer", 2e-10));
}
TEST(Consistence, MesocrystalVsCompound)
{
EXPECT_TRUE(compareTwoReferences("CompoundPlus", "MesocrystalPlus", 2e-10));
}
TEST(Consistence, InstrumentDefinitionComparison)
{
EXPECT_TRUE(compareTwoReferences("InstrumentDefinitionComparison_0",
"InstrumentDefinitionComparison_Q", 2e-10));
}
TEST(Consistence, TOFResolutionComparison)
{
EXPECT_TRUE(
compareTwoReferences("TOFResolutionComparison_TP", "TOFResolutionComparison_TR", 2e-10));
}
TEST(Consistence, PolarizedQAngleReflectivity)
{
EXPECT_TRUE(compareTwoReferences("BasicSpecularPP", "PolarizedQAngleReflectivityPP_Q", 2e-10));
EXPECT_TRUE(compareTwoReferences("BasicSpecularMM", "PolarizedQAngleReflectivityMM_Q", 2e-10));
}
TEST(Consistence, PolarizedScalarSpinFlip)
{
auto* sample = ExemplarySamples::createPlainMultiLayerBySLD();
auto simulation = test::makeSimulation::BasicYPolarizedSpecular(*sample, "PM", false);
const Datafield result = simulation->simulate();
for (auto r : result.flatVector())
EXPECT_TRUE(fabs(r) < 1e-31); // On most architectures, exactly 0, but not on s390
}
TEST(Consistence, PolarizedScalarSpinFlipParticles)
{
auto* sample = ExemplarySamples::createCylindersAndPrisms();
auto simulation = test::makeSimulation::MiniZPolarizedGISAS(*sample, "PM");
const Datafield result = simulation->simulate();
for (auto r : result.flatVector())
EXPECT_EQ(r, 0);
}
|