File: FormfactorOtherTest.cpp

package info (click to toggle)
bornagain 23.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 103,936 kB
  • sloc: cpp: 423,131; python: 40,997; javascript: 11,167; awk: 630; sh: 318; ruby: 173; xml: 130; makefile: 51; ansic: 24
file content (40 lines) | stat: -rw-r--r-- 1,208 bytes parent folder | download
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
#include "Sample/HardParticle/HardParticles.h"

#include "Sample/Scattering/Rotations.h"
#include "Tests/Unit/Numeric/MultiQTest.h"
#include <numbers>

using std::numbers::pi;

class FormfactorOtherTest : public testing::Test {};

//*********** cylinders ***************

TEST_F(FormfactorOtherTest, HorizontalCylinderAsCylinder)
{
    const double R = .3, L = 3;
    Cylinder f0(R, L);
    HorizontalCylinder f1(R, L);

    int failures = formfactorTest::run_test_for_many_q(
        [&](C3 q) -> complex_t { return f0.formfactor(q); },
        [&](C3 q) -> complex_t { return f1.formfactor(q.rotatedY(pi / 2)); }, 1e-99, 100, 2e-15,
        true);
    EXPECT_EQ(failures, 0);
}

TEST_F(FormfactorOtherTest, HorizontalCylinderSlices)
{
    const double R = .3, L = 3;
    HorizontalCylinder f0(R, L);
    HorizontalCylinder f1a(R, L, -R, -0.3 * R);
    HorizontalCylinder f1b(R, L, -0.3 * R, +R);

    int failures = formfactorTest::run_test_for_many_q(
        [&](C3 q) -> complex_t { return f0.formfactor(q); },
        [&](C3 q) -> complex_t {
            return f1a.formfactor(q) + exp_I(q.z() * 0.7 * R) * f1b.formfactor(q);
        },
        1e-99, 100, 1.2e-3, true);
    EXPECT_EQ(failures, 0);
}