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
|
#include "Sample/HardParticle/HardParticles.h"
#include "Tests/GTestWrapper/google_test.h"
#include "Tests/Unit/Numeric/MultiQTest.h"
#include <ff/Face.h> // for diagnostic
#include <iomanip>
//! Compare form factor for particle shapes A and B, where A is given special
//! parameter values so that it coincides with the more symmetric B.
class FFSpecializationTest : public testing::Test {
protected:
void run_test(IFormfactor* ff0, IFormfactor* ff1, double eps, double qmag1, double qmag2)
{
int failures = formfactorTest::run_test_for_many_q(
[&](C3 q) -> complex_t { return ff0->formfactor(q); },
[&](C3 q) -> complex_t { return ff1->formfactor(q); }, qmag1, qmag2, eps);
EXPECT_EQ(failures, 0);
}
};
//*********** cylinders ***************
TEST_F(FFSpecializationTest, HorizontalCylinderSlicedVsUnsliced)
{
const double R = .3, L = 3;
HorizontalCylinder p0(R, L);
HorizontalCylinder p1(R, L, -R, +R * (1 - 3e-16));
run_test(&p0, &p1, 1e-14, 1e-99, 100);
}
//*********** spheroids ***************
TEST_F(FFSpecializationTest, HemiEllipsoidAsSphericalSegment)
{
const double R = 1.07;
HemiEllipsoid p0(R, R, R);
SphericalSegment p1(R, 0, R);
run_test(&p0, &p1, 6e-12, 1e-99, 5e2);
}
TEST_F(FFSpecializationTest, EllipsoidalCylinderAsCylinder)
{
const double R = .8, H = 1.2;
EllipsoidalCylinder p0(R, R, H);
Cylinder p1(R, H);
run_test(&p0, &p1, 8e-13, 1e-99, 50);
}
TEST_F(FFSpecializationTest, SphericalSegmentAsSphere)
{
const double R = 1.;
SphericalSegment p0(R, 0, 0);
Sphere p1(R);
run_test(&p0, &p1, 5e-13, .02, 5e1);
}
TEST_F(FFSpecializationTest, SpheroidAsSphere)
{
const double R = 1.;
Spheroid p0(R, R);
Sphere p1(R);
run_test(&p0, &p1, 1e-14, 1e-99, 50);
}
|