Skip to content
Snippets Groups Projects
Commit f95150b3 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

sort tests; add FFBar test

parent 295b7b38
No related branches found
No related tags found
2 merge requests!590prepare further for local parDefs,!589checkNodeArgs from final c'tors
...@@ -94,20 +94,13 @@ TEST_F(FormFactorBasicTest, AnisoPyramid) ...@@ -94,20 +94,13 @@ TEST_F(FormFactorBasicTest, AnisoPyramid)
test_ff(&particle); test_ff(&particle);
} }
TEST_F(FormFactorBasicTest, HemiEllipsoid) TEST_F(FormFactorBasicTest, Bar)
{ {
EXPECT_THROW(FormFactorHemiEllipsoid(-6, -7, 5), std::runtime_error); EXPECT_THROW(FormFactorBarGauss(-100, -20, 4), std::runtime_error);
EXPECT_THROW(FormFactorBarGauss(100, 20, -4), std::runtime_error);
double radiusx = 6.; // TODO EXPECT_THROW(FormFactorBarGauss(0, 20, 4), std::runtime_error);
double radiusy = 7.; // TODO EXPECT_THROW(FormFactorBarGauss(100, 0, 4), std::runtime_error);
double height = 5.; // TODO EXPECT_THROW(FormFactorBarGauss(100, 20, 0), std::runtime_error);
double volume = M_TWOPI * radiusx * radiusy * height / 3.;
FormFactorHemiEllipsoid particle(radiusx, radiusy, height);
EXPECT_DOUBLE_EQ(volume, particle.volume());
test_ff(&particle);
} }
TEST_F(FormFactorBasicTest, Box) TEST_F(FormFactorBasicTest, Box)
...@@ -137,6 +130,25 @@ TEST_F(FormFactorBasicTest, Box) ...@@ -137,6 +130,25 @@ TEST_F(FormFactorBasicTest, Box)
test_ff(&particle); test_ff(&particle);
} }
TEST_F(FormFactorBasicTest, CantellatedCube)
{
EXPECT_THROW(FormFactorCantellatedCube(0, 0), std::runtime_error);
EXPECT_THROW(FormFactorCantellatedCube(10, -1), std::runtime_error);
EXPECT_THROW(FormFactorCantellatedCube(10, 6), std::runtime_error);
double L = 10.;
double t = 2.; // side length of removed trirectangular tetrahedron at each vertex
double volume = L * L * L - 6 * L * t * t + 16 * t * t * t / 3;
FormFactorCantellatedCube particle(L, t);
EXPECT_DOUBLE_EQ(particle.volume(), volume);
RotationZ rot(.42);
EXPECT_EQ(0., particle.bottomZ(&rot));
EXPECT_EQ(L, particle.topZ(&rot));
test_ff(&particle);
}
TEST_F(FormFactorBasicTest, Cone) TEST_F(FormFactorBasicTest, Cone)
{ {
EXPECT_THROW(FormFactorCone(-6, -5, 0.8), std::runtime_error); EXPECT_THROW(FormFactorCone(-6, -5, 0.8), std::runtime_error);
...@@ -180,6 +192,27 @@ TEST_F(FormFactorBasicTest, Cone6) ...@@ -180,6 +192,27 @@ TEST_F(FormFactorBasicTest, Cone6)
test_ff(&particle); test_ff(&particle);
} }
TEST_F(FormFactorBasicTest, CosineRippleBox)
{
EXPECT_THROW(FormFactorCosineRippleBox(-20, 4, -100), std::runtime_error);
// TODO EXPECT_THROW(FormFactorCosineRippleBox(0, 4, 100), std::runtime_error);
// TODO EXPECT_THROW(FormFactorCosineRippleBox(20, 0, 100), std::runtime_error);
// TODO EXPECT_THROW(FormFactorCosineRippleBox(20, 4, 0), std::runtime_error);
double width = 20.;
double height = 4.;
double length = 100.0;
double volume = 0.5 * height * width * length;
FormFactorCosineRippleBox particle(length, width, height);
EXPECT_DOUBLE_EQ(volume, particle.volume());
RotationZ rot(.42);
EXPECT_EQ(0., particle.bottomZ(&rot));
EXPECT_EQ(height, particle.topZ(&rot));
test_ff(&particle);
}
TEST_F(FormFactorBasicTest, Cuboctahedron) TEST_F(FormFactorBasicTest, Cuboctahedron)
{ {
double length = 10.; double length = 10.;
...@@ -273,25 +306,6 @@ TEST_F(FormFactorBasicTest, EllipsoidalCylinder) ...@@ -273,25 +306,6 @@ TEST_F(FormFactorBasicTest, EllipsoidalCylinder)
test_ff(&particle); test_ff(&particle);
} }
TEST_F(FormFactorBasicTest, CantellatedCube)
{
EXPECT_THROW(FormFactorCantellatedCube(0, 0), std::runtime_error);
EXPECT_THROW(FormFactorCantellatedCube(10, -1), std::runtime_error);
EXPECT_THROW(FormFactorCantellatedCube(10, 6), std::runtime_error);
double L = 10.;
double t = 2.; // side length of removed trirectangular tetrahedron at each vertex
double volume = L * L * L - 6 * L * t * t + 16 * t * t * t / 3;
FormFactorCantellatedCube particle(L, t);
EXPECT_DOUBLE_EQ(particle.volume(), volume);
RotationZ rot(.42);
EXPECT_EQ(0., particle.bottomZ(&rot));
EXPECT_EQ(L, particle.topZ(&rot));
test_ff(&particle);
}
TEST_F(FormFactorBasicTest, FullSphere) TEST_F(FormFactorBasicTest, FullSphere)
{ {
EXPECT_THROW(FormFactorFullSphere(-1), std::runtime_error); EXPECT_THROW(FormFactorFullSphere(-1), std::runtime_error);
...@@ -327,6 +341,22 @@ TEST_F(FormFactorBasicTest, FullSpheroid) ...@@ -327,6 +341,22 @@ TEST_F(FormFactorBasicTest, FullSpheroid)
test_ff(&particle); test_ff(&particle);
} }
TEST_F(FormFactorBasicTest, HemiEllipsoid)
{
EXPECT_THROW(FormFactorHemiEllipsoid(-6, -7, 5), std::runtime_error);
double radiusx = 6.;
double radiusy = 7.;
double height = 5.;
double volume = M_TWOPI * radiusx * radiusy * height / 3.;
FormFactorHemiEllipsoid particle(radiusx, radiusy, height);
EXPECT_DOUBLE_EQ(volume, particle.volume());
test_ff(&particle);
}
TEST_F(FormFactorBasicTest, Icosahedron) TEST_F(FormFactorBasicTest, Icosahedron)
{ {
EXPECT_THROW(FormFactorIcosahedron(-1), std::runtime_error); EXPECT_THROW(FormFactorIcosahedron(-1), std::runtime_error);
...@@ -407,6 +437,48 @@ TEST_F(FormFactorBasicTest, Pyramid) ...@@ -407,6 +437,48 @@ TEST_F(FormFactorBasicTest, Pyramid)
test_ff(&particle); test_ff(&particle);
} }
TEST_F(FormFactorBasicTest, SawtoothRippleBox)
{
EXPECT_THROW(FormFactorSawtoothRippleBox(-20, 4, -100, .3), std::runtime_error);
// TODO EXPECT_THROW(FormFactorSawtoothRippleBox(0, 4, 100, .3), std::runtime_error);
// TODO EXPECT_THROW(FormFactorSawtoothRippleBox(20, 0, 100, .3), std::runtime_error);
// TODO EXPECT_THROW(FormFactorSawtoothRippleBox(20, 4, 0, .3), std::runtime_error);
// TODO EXPECT_THROW(FormFactorSawtoothRippleBox(20, 4, 0, -.3), std::runtime_error);
double width = 20.;
double height = 4.;
double length = 100.0;
double d = 0.3; // asymmetry
double volume = 0.5 * height * width * length;
FormFactorSawtoothRippleBox particle(length, width, height, d);
EXPECT_DOUBLE_EQ(volume, particle.volume());
RotationZ rot(.42);
EXPECT_EQ(0., particle.bottomZ(&rot));
EXPECT_EQ(height, particle.topZ(&rot));
// test_ff( &particle ); WAITING: restore once radius returns the umkreis radius
}
TEST_F(FormFactorBasicTest, TruncatedCube)
{
EXPECT_THROW(FormFactorTruncatedCube(0, 0), std::runtime_error);
EXPECT_THROW(FormFactorTruncatedCube(10, -1), std::runtime_error);
EXPECT_THROW(FormFactorTruncatedCube(10, 6), std::runtime_error);
double length = 15.;
double t = 6.; // side length of removed trirectangular tetrahedron at each vertex
double volume = length * length * length - 4. / 3. * t * t * t;
FormFactorTruncatedCube particle(length, t);
EXPECT_DOUBLE_EQ(particle.volume(), volume);
RotationZ rot(.42);
EXPECT_EQ(0., particle.bottomZ(&rot));
EXPECT_EQ(length, particle.topZ(&rot));
test_ff(&particle);
}
TEST_F(FormFactorBasicTest, TruncatedSphere) TEST_F(FormFactorBasicTest, TruncatedSphere)
{ {
EXPECT_THROW(FormFactorTruncatedSphere(-5, -3, 1.7), std::runtime_error); EXPECT_THROW(FormFactorTruncatedSphere(-5, -3, 1.7), std::runtime_error);
...@@ -471,66 +543,3 @@ TEST_F(FormFactorBasicTest, Tetrahedron) ...@@ -471,66 +543,3 @@ TEST_F(FormFactorBasicTest, Tetrahedron)
test_ff(&particle); test_ff(&particle);
} }
TEST_F(FormFactorBasicTest, CosineRippleBox)
{
EXPECT_THROW(FormFactorCosineRippleBox(-20, 4, -100), std::runtime_error);
// TODO EXPECT_THROW(FormFactorCosineRippleBox(0, 4, 100), std::runtime_error);
// TODO EXPECT_THROW(FormFactorCosineRippleBox(20, 0, 100), std::runtime_error);
// TODO EXPECT_THROW(FormFactorCosineRippleBox(20, 4, 0), std::runtime_error);
double width = 20.;
double height = 4.;
double length = 100.0;
double volume = 0.5 * height * width * length;
FormFactorCosineRippleBox particle(length, width, height);
EXPECT_DOUBLE_EQ(volume, particle.volume());
RotationZ rot(.42);
EXPECT_EQ(0., particle.bottomZ(&rot));
EXPECT_EQ(height, particle.topZ(&rot));
test_ff(&particle);
}
TEST_F(FormFactorBasicTest, TruncatedCube)
{
EXPECT_THROW(FormFactorTruncatedCube(0, 0), std::runtime_error);
EXPECT_THROW(FormFactorTruncatedCube(10, -1), std::runtime_error);
EXPECT_THROW(FormFactorTruncatedCube(10, 6), std::runtime_error);
double length = 15.;
double t = 6.; // side length of removed trirectangular tetrahedron at each vertex
double volume = length * length * length - 4. / 3. * t * t * t;
FormFactorTruncatedCube particle(length, t);
EXPECT_DOUBLE_EQ(particle.volume(), volume);
RotationZ rot(.42);
EXPECT_EQ(0., particle.bottomZ(&rot));
EXPECT_EQ(length, particle.topZ(&rot));
test_ff(&particle);
}
TEST_F(FormFactorBasicTest, SawtoothRippleBox)
{
EXPECT_THROW(FormFactorSawtoothRippleBox(-20, 4, -100, .3), std::runtime_error);
// TODO EXPECT_THROW(FormFactorSawtoothRippleBox(0, 4, 100, .3), std::runtime_error);
// TODO EXPECT_THROW(FormFactorSawtoothRippleBox(20, 0, 100, .3), std::runtime_error);
// TODO EXPECT_THROW(FormFactorSawtoothRippleBox(20, 4, 0, .3), std::runtime_error);
// TODO EXPECT_THROW(FormFactorSawtoothRippleBox(20, 4, 0, -.3), std::runtime_error);
double width = 20.;
double height = 4.;
double length = 100.0;
double d = 0.3; // asymmetry
double volume = 0.5 * height * width * length;
FormFactorSawtoothRippleBox particle(length, width, height, d);
EXPECT_DOUBLE_EQ(volume, particle.volume());
RotationZ rot(.42);
EXPECT_EQ(0., particle.bottomZ(&rot));
EXPECT_EQ(height, particle.topZ(&rot));
// test_ff( &particle ); WAITING: restore once radius returns the umkreis radius
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment