Skip to content
Snippets Groups Projects
Commit dd3b8e50 authored by Celine Durniak's avatar Celine Durniak
Browse files

Unit test for all form factors

parent 6921f123
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// BornAgain: simulate and fit scattering at grazing incidence // BornAgain: simulate and fit scattering at grazing incidence
// //
//! @file FormFactors/inc/IFormFactorDecorator.h //! @file FormFactors/inc/IFormFactorDecorator.h
//! @brief Defines pure vurtual interface class IFormFactorDecorator. //! @brief Defines pure virtual interface class IFormFactorDecorator.
//! //!
//! @homepage http://apps.jcns.fz-juelich.de/BornAgain //! @homepage http://apps.jcns.fz-juelich.de/BornAgain
//! @license GNU General Public License v3 or higher (see COPYING) //! @license GNU General Public License v3 or higher (see COPYING)
......
...@@ -15,22 +15,22 @@ ...@@ -15,22 +15,22 @@
#ifndef FORMFACTORTEST_H #ifndef FORMFACTORTEST_H
#define FORMFACTORTEST_H #define FORMFACTORTEST_H
//#include "FormFactorAnisoPyramid.h" #include "FormFactorAnisoPyramid.h"
#include "FormFactorBox.h" #include "FormFactorBox.h"
#include "FormFactorCone.h" #include "FormFactorCone.h"
#include "FormFactorCone6.h" #include "FormFactorCone6.h"
#include "FormFactorCylinder.h" #include "FormFactorCylinder.h"
//#include "FormFactorCuboctahedron.h" #include "FormFactorCuboctahedron.h"
#include "FormFactorEllipsoid.h" #include "FormFactorEllipsoidalCylinder.h"
#include "FormFactorFullSphere.h" #include "FormFactorFullSphere.h"
#include "FormFactorFullSpheroid.h" #include "FormFactorFullSpheroid.h"
//#include "FormFactorHemiSpheroid.h" #include "FormFactorHemiEllipsoid.h"
#include "FormFactorParallelepiped.h" #include "FormFactorParallelepiped.h"
#include "FormFactorPrism3.h" #include "FormFactorPrism3.h"
#include "FormFactorPrism6.h" #include "FormFactorPrism6.h"
#include "FormFactorPyramid.h" #include "FormFactorPyramid.h"
#include "FormFactorSphere.h" #include "FormFactorSphere.h"
//#include "FormFactorSpheroid.h" #include "FormFactorSpheroid.h"
#include "FormFactorTetrahedron.h" #include "FormFactorTetrahedron.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
...@@ -42,6 +42,66 @@ class FormFactorTest : public ::testing::Test ...@@ -42,6 +42,66 @@ class FormFactorTest : public ::testing::Test
virtual ~FormFactorTest(){} virtual ~FormFactorTest(){}
}; };
//Test form factor of an anisotropic pyramid
TEST_F(FormFactorTest, AnisoPyramid)
{
double length = 12.;
double height = 5.;
double width = 14.;
double alpha = 0.8;
double tga = std::tan(alpha);
double volume = height*(length*width
- (length + width)*height/tga
+ 4.0/3.0*height*height/(tga*tga));
FormFactorAnisoPyramid anisopyramid(length, width, height, alpha);
EXPECT_EQ("FormFactorAnisoPyramid",anisopyramid.getName());
EXPECT_DOUBLE_EQ(volume, anisopyramid.getVolume());
EXPECT_EQ(12., anisopyramid.getLength());
EXPECT_EQ(14., anisopyramid.getWidth());
EXPECT_EQ(5., anisopyramid.getHeight());
EXPECT_EQ(0.8, anisopyramid.getAlpha());
EXPECT_EQ((int)4, anisopyramid.getNumberOfStochasticParameters());
FormFactorAnisoPyramid *anisopyramidclone = anisopyramid.clone();
EXPECT_EQ("FormFactorAnisoPyramid",anisopyramidclone->getName());
EXPECT_DOUBLE_EQ(volume, anisopyramidclone->getVolume());
EXPECT_EQ(12., anisopyramidclone->getLength());
EXPECT_EQ(14., anisopyramidclone->getWidth());
EXPECT_EQ(5., anisopyramidclone->getHeight());
EXPECT_EQ(0.8, anisopyramidclone->getAlpha());
EXPECT_EQ((int)4, anisopyramidclone->getNumberOfStochasticParameters());
}
//Test form factor of an hemiellipsoid
TEST_F(FormFactorTest, HemiEllipsoid)
{
double radius_a = 6.;
double radius_b = 7.;
double height = 5.;
double volume = 2.*M_PI*radius_a*radius_b*height/3.;
FormFactorHemiEllipsoid hemiellipsoid(radius_a, radius_b, height);
EXPECT_EQ("FormFactorHemiEllipsoid",hemiellipsoid.getName());
EXPECT_EQ(6., hemiellipsoid.getRadiusA());
EXPECT_EQ(7., hemiellipsoid.getRadiusB());
EXPECT_EQ(5., hemiellipsoid.getHeight());
EXPECT_DOUBLE_EQ(volume, hemiellipsoid.getVolume());
EXPECT_EQ((int)3, hemiellipsoid.getNumberOfStochasticParameters());
FormFactorHemiEllipsoid *hemiellipsoidclone = hemiellipsoid.clone();
EXPECT_EQ("FormFactorHemiEllipsoid",hemiellipsoidclone->getName());
EXPECT_EQ(6., hemiellipsoidclone->getRadiusA());
EXPECT_EQ(7., hemiellipsoidclone->getRadiusB());
EXPECT_EQ(5., hemiellipsoidclone->getHeight());
EXPECT_DOUBLE_EQ(volume, hemiellipsoidclone->getVolume());
EXPECT_EQ((int)3, hemiellipsoidclone->getNumberOfStochasticParameters());
}
// Test form factor of a box // Test form factor of a box
TEST_F(FormFactorTest, Box) TEST_F(FormFactorTest, Box)
{ {
...@@ -56,25 +116,24 @@ TEST_F(FormFactorTest, Box) ...@@ -56,25 +116,24 @@ TEST_F(FormFactorTest, Box)
EXPECT_EQ(7., box.getWidth()); EXPECT_EQ(7., box.getWidth());
EXPECT_EQ(5., box.getHeight()); EXPECT_EQ(5., box.getHeight());
EXPECT_EQ(3., box.getRadius()); EXPECT_EQ(3., box.getRadius());
EXPECT_EQ(volume, box.getVolume()); EXPECT_DOUBLE_EQ(volume, box.getVolume());
EXPECT_EQ(3, box.getNumberOfStochasticParameters()); EXPECT_EQ((int)3, box.getNumberOfStochasticParameters());
FormFactorBox *boxclone = box.clone(); FormFactorBox *boxclone = box.clone();
EXPECT_EQ("FormFactorBox",boxclone->getName()); EXPECT_EQ("FormFactorBox",boxclone->getName());
EXPECT_EQ(7., boxclone->getWidth()); EXPECT_EQ(7., boxclone->getWidth());
EXPECT_EQ(5., boxclone->getHeight()); EXPECT_EQ(5., boxclone->getHeight());
EXPECT_EQ(3., boxclone->getRadius()); EXPECT_EQ(3., boxclone->getRadius());
EXPECT_EQ(volume, boxclone->getVolume()); EXPECT_DOUBLE_EQ(volume, boxclone->getVolume());
EXPECT_EQ(3, boxclone->getNumberOfStochasticParameters()); EXPECT_EQ((int)3, boxclone->getNumberOfStochasticParameters());
} }
// Test form factor of a cone // Test form factor of a cone
TEST_F(FormFactorTest, Cone) TEST_F(FormFactorTest, Cone)
{ {
double radius = 3.; double radius = 6.;
double height = 5.; double height = 5.;
double alpha = 0.5; double alpha = 0.8;
double tga = std::tan(alpha); double tga = std::tan(alpha);
double HdivRtga = height/tga/radius; double HdivRtga = height/tga/radius;
double volume = M_PI/3.*tga*radius*radius*radius* double volume = M_PI/3.*tga*radius*radius*radius*
...@@ -83,28 +142,27 @@ TEST_F(FormFactorTest, Cone) ...@@ -83,28 +142,27 @@ TEST_F(FormFactorTest, Cone)
FormFactorCone cone(radius, height, alpha); FormFactorCone cone(radius, height, alpha);
EXPECT_EQ("FormFactorCone",cone.getName()); EXPECT_EQ("FormFactorCone",cone.getName());
EXPECT_EQ(3., cone.getRadius()); EXPECT_EQ(6., cone.getRadius());
EXPECT_EQ(5., cone.getHeight()); EXPECT_EQ(5., cone.getHeight());
EXPECT_EQ(0.5, cone.getAlpha()); EXPECT_EQ(0.8, cone.getAlpha());
EXPECT_EQ(volume, cone.getVolume()); EXPECT_DOUBLE_EQ(volume, cone.getVolume());
EXPECT_EQ((int)3, cone.getNumberOfStochasticParameters()); EXPECT_EQ((int)3, cone.getNumberOfStochasticParameters());
FormFactorCone *coneclone = cone.clone(); FormFactorCone *coneclone = cone.clone();
EXPECT_EQ("FormFactorCone",coneclone->getName()); EXPECT_EQ("FormFactorCone",coneclone->getName());
EXPECT_EQ(3., coneclone->getRadius()); EXPECT_EQ(6., coneclone->getRadius());
EXPECT_EQ(5., coneclone->getHeight()); EXPECT_EQ(5., coneclone->getHeight());
EXPECT_EQ(0.5, coneclone->getAlpha()); EXPECT_EQ(0.8, coneclone->getAlpha());
EXPECT_EQ(volume, coneclone->getVolume()); EXPECT_DOUBLE_EQ(volume, coneclone->getVolume());
EXPECT_EQ((int)3, coneclone->getNumberOfStochasticParameters()); EXPECT_EQ((int)3, coneclone->getNumberOfStochasticParameters());
} }
// Test form factor of a cone6 // Test form factor of a cone6
TEST_F(FormFactorTest, Cone6) TEST_F(FormFactorTest, Cone6)
{ {
double radius = 3.; double radius = 6.;
double height = 5.; double height = 5.;
double alpha = 0.5; double alpha = 0.8;
double tga = std::tan(alpha); double tga = std::tan(alpha);
double HdivRtga = 2.*height/tga/radius/std::sqrt(3.); double HdivRtga = 2.*height/tga/radius/std::sqrt(3.);
double volume = 3./4.*tga*radius*radius*radius* double volume = 3./4.*tga*radius*radius*radius*
...@@ -113,48 +171,57 @@ TEST_F(FormFactorTest, Cone6) ...@@ -113,48 +171,57 @@ TEST_F(FormFactorTest, Cone6)
FormFactorCone6 cone6(radius, height, alpha); FormFactorCone6 cone6(radius, height, alpha);
EXPECT_EQ("FormFactorCone6",cone6.getName()); EXPECT_EQ("FormFactorCone6",cone6.getName());
EXPECT_EQ(3., cone6.getRadius()); EXPECT_EQ(6., cone6.getRadius());
EXPECT_EQ(5., cone6.getHeight()); EXPECT_EQ(5., cone6.getHeight());
EXPECT_EQ(0.5, cone6.getAlpha()); EXPECT_EQ(0.8, cone6.getAlpha());
EXPECT_EQ(volume, cone6.getVolume()); EXPECT_DOUBLE_EQ(volume, cone6.getVolume());
EXPECT_EQ((int)3, cone6.getNumberOfStochasticParameters()); EXPECT_EQ((int)3, cone6.getNumberOfStochasticParameters());
FormFactorCone6 *cone6clone = cone6.clone(); FormFactorCone6 *cone6clone = cone6.clone();
EXPECT_EQ("FormFactorCone6",cone6clone->getName()); EXPECT_EQ("FormFactorCone6",cone6clone->getName());
EXPECT_EQ(3., cone6clone->getRadius()); EXPECT_EQ(6., cone6clone->getRadius());
EXPECT_EQ(5., cone6clone->getHeight()); EXPECT_EQ(5., cone6clone->getHeight());
EXPECT_EQ(0.5, cone6clone->getAlpha()); EXPECT_EQ(0.8, cone6clone->getAlpha());
EXPECT_EQ(volume, cone6clone->getVolume()); EXPECT_DOUBLE_EQ(volume, cone6clone->getVolume());
EXPECT_EQ((int)3, cone6clone->getNumberOfStochasticParameters()); EXPECT_EQ((int)3, cone6clone->getNumberOfStochasticParameters());
} }
// Test form factor of a cuboctahedron // Test form factor of a cuboctahedron
//TEST_F(FormFactorTest, Cuboctahedron) TEST_F(FormFactorTest, Cuboctahedron)
//{ {
// double radius = 3.; double half_side = 5.;
// double height = 4; double height = 4;
// double height_ratio = 1.; double height_ratio = 1.;
// double alpha = 0.5; double alpha = 0.8;
// double tga = std::tan(alpha);
// double HdivRtga = height/half_side/tga;
// double ratioHdivRtga = height_ratio*height/half_side/tga;
//double volume = 4./3.*tga*half_side*half_side*half_side*( 2.
// - (1. - HdivRtga)*(1. - HdivRtga)*(1. - HdivRtga)
// - (1. - ratioHdivRtga)*(1. - ratioHdivRtga)*(1. - ratioHdivRtga));
// FormFactorCuboctahedron cuboctahedron(radius, width, height, alpha);
// EXPECT_EQ(4., cuboctahedron.getHeight());
// EXPECT_EQ(3., cuboctahedron.getRadius());
// EXPECT_EQ(5., cuboctahedron.getWidth());
//EXPECT_EQ(5., cuboctahedron.getVolume());
// EXPECT_EQ(2, ellipsoid.getNumberOfStochasticParameters());
//FormFactorCuboctahedron *cuboctahedronclone = cuboctahedron.clone(); double tga = std::tan(alpha);
double HdivRtga = height/half_side/tga;
double ratioHdivRtga = height_ratio*height/half_side/tga;
double volume = 4./3.*tga*half_side*half_side*half_side*( 2.
- (1. - HdivRtga)*(1. - HdivRtga)*(1. - HdivRtga)
- (1. - ratioHdivRtga)*(1. - ratioHdivRtga)*(1. - ratioHdivRtga));
FormFactorCuboctahedron cuboctahedron(half_side, height,
height_ratio, alpha);
EXPECT_EQ("FormFactorCuboctahedron",cuboctahedron.getName());
EXPECT_EQ(4., cuboctahedron.getHeight());
EXPECT_EQ(5., cuboctahedron.getHalfSide());
EXPECT_EQ(1., cuboctahedron.getHeightRatio());
EXPECT_EQ(0.8, cuboctahedron.getAlpha());
EXPECT_DOUBLE_EQ(volume, cuboctahedron.getVolume());
EXPECT_EQ((int)4, cuboctahedron.getNumberOfStochasticParameters());
FormFactorCuboctahedron *cuboctahedronclone = cuboctahedron.clone();
EXPECT_EQ("FormFactorCuboctahedron",cuboctahedronclone->getName());
EXPECT_EQ(4., cuboctahedronclone->getHeight());
EXPECT_EQ(5., cuboctahedronclone->getHalfSide());
EXPECT_EQ(1., cuboctahedronclone->getHeightRatio());
EXPECT_EQ(0.8, cuboctahedronclone->getAlpha());
EXPECT_DOUBLE_EQ(volume, cuboctahedron.getVolume());
EXPECT_EQ((int)4, cuboctahedronclone->getNumberOfStochasticParameters());
//} }
// Test form factor of a cylinder // Test form factor of a cylinder
TEST_F(FormFactorTest, Cylinder) TEST_F(FormFactorTest, Cylinder)
...@@ -164,43 +231,46 @@ TEST_F(FormFactorTest, Cylinder) ...@@ -164,43 +231,46 @@ TEST_F(FormFactorTest, Cylinder)
double volume = M_PI*radius*radius*height; double volume = M_PI*radius*radius*height;
FormFactorCylinder cylinder(height,radius); FormFactorCylinder cylinder(height,radius);
EXPECT_EQ("FormFactorCylinder",cylinder.getName()); EXPECT_EQ("FormFactorCylinder",cylinder.getName());
EXPECT_EQ(5., cylinder.getHeight()); EXPECT_EQ(5., cylinder.getHeight());
EXPECT_EQ(3., cylinder.getRadius()); EXPECT_EQ(3., cylinder.getRadius());
EXPECT_EQ(volume, cylinder.getVolume()); EXPECT_DOUBLE_EQ(volume, cylinder.getVolume());
EXPECT_EQ((int)2, cylinder.getNumberOfStochasticParameters()); EXPECT_EQ((int)2, cylinder.getNumberOfStochasticParameters());
FormFactorCylinder *cylinderclone = cylinder.clone(); FormFactorCylinder *cylinderclone = cylinder.clone();
EXPECT_EQ("FormFactorCylinder",cylinderclone->getName()); EXPECT_EQ("FormFactorCylinder",cylinderclone->getName());
EXPECT_EQ(5., cylinderclone->getHeight()); EXPECT_EQ(5., cylinderclone->getHeight());
EXPECT_EQ(3., cylinderclone-> getRadius()); EXPECT_EQ(3., cylinderclone-> getRadius());
EXPECT_EQ(volume, cylinderclone-> getVolume()); EXPECT_DOUBLE_EQ(volume, cylinderclone-> getVolume());
EXPECT_EQ((int)2, cylinderclone-> getNumberOfStochasticParameters()); EXPECT_EQ((int)2, cylinderclone-> getNumberOfStochasticParameters());
} }
// Test form factor of an ellipsoid - check form factor // Test form factor of an ellipsoidal cylinder
//TEST_F(FormFactorTest, Ellipsoid) TEST_F(FormFactorTest, EllipsoidalCylinder)
//{ {
// double radius = 3.; double radius = 3.;
// double width = 5.; double width = 5.;
// double height = 4; double height = 4;
// double alpha = 0.5; double volume = M_PI*radius*width*height;
//double volume = ;
FormFactorEllipsoidalCylinder ellipscyl(radius, width, height);
// FormFactorEllipsoid ellipsoid(radius, width, height, alpha);
EXPECT_EQ("FormFactorEllipsoidalCylinder",ellipscyl.getName());
// EXPECT_EQ("FormFactorEllipsoid",ellipsoid.getName()); EXPECT_EQ(4., ellipscyl.getHeight());
// EXPECT_EQ(4., ellipsoid.getHeight()); EXPECT_EQ(3., ellipscyl.getRadius());
// EXPECT_EQ(3., ellipsoid.getRadius()); EXPECT_EQ(5., ellipscyl.getWidth());
// EXPECT_EQ(5., ellipsoid.getWidth()); EXPECT_DOUBLE_EQ(volume, ellipscyl.getVolume());
// EXPECT_EQ(5., ellipsoid.getVolume()); EXPECT_EQ((int)3, ellipscyl.getNumberOfStochasticParameters());
// EXPECT_EQ(2, ellipsoid.getNumberOfStochasticParameters());
FormFactorEllipsoidalCylinder *ellipscylclone = ellipscyl.clone();
//FormFactorEllipsoid *ellispoidclone = ellipsoid.clone(); EXPECT_EQ("FormFactorEllipsoidalCylinder",ellipscylclone->getName());
EXPECT_EQ(4., ellipscylclone->getHeight());
EXPECT_EQ(3., ellipscylclone->getRadius());
EXPECT_EQ(5., ellipscylclone->getWidth());
EXPECT_DOUBLE_EQ(volume, ellipscylclone->getVolume());
EXPECT_EQ((int)3, ellipscylclone->getNumberOfStochasticParameters());
//} }
// Test form factor of a full sphere // Test form factor of a full sphere
TEST_F(FormFactorTest, FullSphere) TEST_F(FormFactorTest, FullSphere)
...@@ -213,14 +283,14 @@ TEST_F(FormFactorTest, FullSphere) ...@@ -213,14 +283,14 @@ TEST_F(FormFactorTest, FullSphere)
EXPECT_EQ("FormFactorFullSphere",fullsphere.getName()); EXPECT_EQ("FormFactorFullSphere",fullsphere.getName());
EXPECT_EQ(5., fullsphere.getRadius()); EXPECT_EQ(5., fullsphere.getRadius());
EXPECT_EQ(2.*5., fullsphere.getHeight()); EXPECT_EQ(2.*5., fullsphere.getHeight());
EXPECT_EQ(volume, fullsphere.getVolume()); EXPECT_DOUBLE_EQ(volume, fullsphere.getVolume());
EXPECT_EQ((int)1, fullsphere.getNumberOfStochasticParameters()); EXPECT_EQ((int)1, fullsphere.getNumberOfStochasticParameters());
FormFactorFullSphere *fullsphereclone = fullsphere.clone(); FormFactorFullSphere *fullsphereclone = fullsphere.clone();
EXPECT_EQ("FormFactorFullSphere",fullsphereclone->getName()); EXPECT_EQ("FormFactorFullSphere",fullsphereclone->getName());
EXPECT_EQ(5., fullsphereclone->getRadius()); EXPECT_EQ(5., fullsphereclone->getRadius());
EXPECT_EQ(2.*5., fullsphereclone->getHeight()); EXPECT_EQ(2.*5., fullsphereclone->getHeight());
EXPECT_EQ(volume, fullsphereclone->getVolume()); EXPECT_DOUBLE_EQ(volume, fullsphereclone->getVolume());
EXPECT_EQ((int)1, fullsphereclone->getNumberOfStochasticParameters()); EXPECT_EQ((int)1, fullsphereclone->getNumberOfStochasticParameters());
} }
...@@ -229,21 +299,22 @@ TEST_F(FormFactorTest, FullSpheroid) ...@@ -229,21 +299,22 @@ TEST_F(FormFactorTest, FullSpheroid)
{ {
double radius = 3.; double radius = 3.;
double height = 5.; double height = 5.;
// double volume = 2./3.*M_PI*radius*radius*height; double volume = 2./3.*M_PI*radius*radius*height;
FormFactorFullSpheroid fullspheroid(radius,height); FormFactorFullSpheroid fullspheroid(radius,height);
EXPECT_EQ("FormFactorFullSpheroid",fullspheroid.getName()); EXPECT_EQ("FormFactorFullSpheroid",fullspheroid.getName());
EXPECT_EQ(3., fullspheroid.getRadius()); EXPECT_EQ(3., fullspheroid.getRadius());
EXPECT_EQ(5., fullspheroid.getHeight()); EXPECT_EQ(5., fullspheroid.getHeight());
// EXPECT_EQ(volume, fullspheroid.getVolume()); EXPECT_DOUBLE_EQ(volume, fullspheroid.getVolume());
EXPECT_EQ((int)2, fullspheroid.getNumberOfStochasticParameters()); EXPECT_EQ((int)2, fullspheroid.getNumberOfStochasticParameters());
// FormFactorFullSpheroid *fullspheroidclone = fullspheroid.clone(); FormFactorFullSpheroid *fullspheroidclone = fullspheroid.clone();
// EXPECT_EQ(3., fullspheroidclone->getRadius()); EXPECT_EQ("FormFactorFullSpheroid",fullspheroidclone->getName());
// EXPECT_EQ(5, fullspheroidclone->getHeight()); EXPECT_EQ(3., fullspheroidclone->getRadius());
/* EXPECT_EQ(volume, fullspheroidclone->getVolume()); EXPECT_EQ(5, fullspheroidclone->getHeight());
EXPECT_EQ((int)2, fullspheroidclone->getNumberOfStochasticParameters());*/ EXPECT_DOUBLE_EQ(volume, fullspheroidclone->getVolume());
EXPECT_EQ((int)2, fullspheroidclone->getNumberOfStochasticParameters());
} }
...@@ -259,14 +330,14 @@ TEST_F(FormFactorTest, Parallelepiped) ...@@ -259,14 +330,14 @@ TEST_F(FormFactorTest, Parallelepiped)
EXPECT_EQ("FormFactorParallelepiped",parallelepiped.getName()); EXPECT_EQ("FormFactorParallelepiped",parallelepiped.getName());
EXPECT_EQ(10., parallelepiped.getHeight()); EXPECT_EQ(10., parallelepiped.getHeight());
EXPECT_EQ(11., parallelepiped.getRadius()); EXPECT_EQ(11., parallelepiped.getRadius());
EXPECT_EQ(volume, parallelepiped.getVolume()); EXPECT_DOUBLE_EQ(volume, parallelepiped.getVolume());
EXPECT_EQ((int)2, parallelepiped.getNumberOfStochasticParameters()); EXPECT_EQ((int)2, parallelepiped.getNumberOfStochasticParameters());
FormFactorParallelepiped *parallelepipedclone = parallelepiped.clone(); FormFactorParallelepiped *parallelepipedclone = parallelepiped.clone();
EXPECT_EQ("FormFactorParallelepiped",parallelepipedclone->getName()); EXPECT_EQ("FormFactorParallelepiped",parallelepipedclone->getName());
EXPECT_EQ(10., parallelepipedclone-> getHeight()); EXPECT_EQ(10., parallelepipedclone-> getHeight());
EXPECT_EQ(11., parallelepipedclone-> getRadius()); EXPECT_EQ(11., parallelepipedclone-> getRadius());
EXPECT_EQ(volume, parallelepipedclone-> getVolume()); EXPECT_DOUBLE_EQ(volume, parallelepipedclone-> getVolume());
EXPECT_EQ((int)2, parallelepipedclone-> getNumberOfStochasticParameters()); EXPECT_EQ((int)2, parallelepipedclone-> getNumberOfStochasticParameters());
} }
...@@ -282,15 +353,15 @@ TEST_F(FormFactorTest, Prism3) ...@@ -282,15 +353,15 @@ TEST_F(FormFactorTest, Prism3)
EXPECT_EQ("FormFactorPrism3",prism3.getName()); EXPECT_EQ("FormFactorPrism3",prism3.getName());
EXPECT_EQ(4., prism3.getHeight()); EXPECT_EQ(4., prism3.getHeight());
EXPECT_EQ(3., prism3.getHalfSide()); EXPECT_EQ(3., prism3.getHalfSide());
EXPECT_EQ(volume, prism3.getVolume()); EXPECT_DOUBLE_EQ(volume, prism3.getVolume());
EXPECT_EQ((int)2, prism3.getNumberOfStochasticParameters()); EXPECT_EQ((int)2, prism3.getNumberOfStochasticParameters());
FormFactorPrism3 *prism3clone = prism3.clone(); FormFactorPrism3 *prism3clone = prism3.clone();
EXPECT_EQ("FormFactorPrism3",prism3clone->getName()); EXPECT_EQ("FormFactorPrism3",prism3clone->getName());
EXPECT_EQ(double(4.), prism3clone->getHeight()); EXPECT_EQ(4., prism3clone->getHeight());
EXPECT_EQ(3., prism3clone->getHalfSide()); EXPECT_EQ(3., prism3clone->getHalfSide());
EXPECT_EQ(volume, prism3clone->getVolume()); EXPECT_DOUBLE_EQ(volume, prism3clone->getVolume());
EXPECT_EQ((int)2, prism3clone->getNumberOfStochasticParameters()); EXPECT_EQ((int)2, prism3clone->getNumberOfStochasticParameters());
} }
...@@ -306,7 +377,7 @@ TEST_F(FormFactorTest, Prism6) ...@@ -306,7 +377,7 @@ TEST_F(FormFactorTest, Prism6)
EXPECT_EQ("FormFactorPrism6",prism6.getName()); EXPECT_EQ("FormFactorPrism6",prism6.getName());
EXPECT_EQ(4., prism6.getHeight()); EXPECT_EQ(4., prism6.getHeight());
EXPECT_EQ(3., prism6.getRadius()); EXPECT_EQ(3., prism6.getRadius());
EXPECT_EQ(volume, prism6.getVolume()); EXPECT_DOUBLE_EQ(volume, prism6.getVolume());
EXPECT_EQ((int)2, prism6.getNumberOfStochasticParameters()); EXPECT_EQ((int)2, prism6.getNumberOfStochasticParameters());
FormFactorPrism6 *prism6clone = prism6.clone(); FormFactorPrism6 *prism6clone = prism6.clone();
...@@ -314,7 +385,7 @@ TEST_F(FormFactorTest, Prism6) ...@@ -314,7 +385,7 @@ TEST_F(FormFactorTest, Prism6)
EXPECT_EQ("FormFactorPrism6",prism6clone->getName()); EXPECT_EQ("FormFactorPrism6",prism6clone->getName());
EXPECT_EQ(4., prism6clone->getHeight()); EXPECT_EQ(4., prism6clone->getHeight());
EXPECT_EQ(3., prism6clone->getRadius()); EXPECT_EQ(3., prism6clone->getRadius());
EXPECT_EQ(volume, prism6clone->getVolume()); EXPECT_DOUBLE_EQ(volume, prism6clone->getVolume());
EXPECT_EQ((int)2, prism6clone->getNumberOfStochasticParameters()); EXPECT_EQ((int)2, prism6clone->getNumberOfStochasticParameters());
} }
...@@ -322,8 +393,8 @@ TEST_F(FormFactorTest, Prism6) ...@@ -322,8 +393,8 @@ TEST_F(FormFactorTest, Prism6)
TEST_F(FormFactorTest, Pyramid) TEST_F(FormFactorTest, Pyramid)
{ {
double height = 4.; double height = 4.;
double half_side = 3.; double half_side = 5.;
double alpha = 0.5; double alpha = 0.8;
double tga = std::tan(alpha); double tga = std::tan(alpha);
double HdivRtga = height/half_side/tga; double HdivRtga = height/half_side/tga;
double volume = 4./3.*tga*half_side*half_side*half_side*( 1. double volume = 4./3.*tga*half_side*half_side*half_side*( 1.
...@@ -333,17 +404,17 @@ TEST_F(FormFactorTest, Pyramid) ...@@ -333,17 +404,17 @@ TEST_F(FormFactorTest, Pyramid)
EXPECT_EQ("FormFactorPyramid", pyramid.getName()); EXPECT_EQ("FormFactorPyramid", pyramid.getName());
EXPECT_EQ(4., pyramid.getHeight()); EXPECT_EQ(4., pyramid.getHeight());
EXPECT_EQ(3., pyramid.getHalfSide()); EXPECT_EQ(5., pyramid.getHalfSide());
EXPECT_EQ(0.5, pyramid.getAlpha()); EXPECT_EQ(0.8, pyramid.getAlpha());
EXPECT_EQ(volume, pyramid.getVolume()); EXPECT_DOUBLE_EQ(volume, pyramid.getVolume());
EXPECT_EQ((int)3, pyramid.getNumberOfStochasticParameters()); EXPECT_EQ((int)3, pyramid.getNumberOfStochasticParameters());
FormFactorPyramid *pyramidclone = pyramid.clone(); FormFactorPyramid *pyramidclone = pyramid.clone();
EXPECT_EQ("FormFactorPyramid", pyramidclone->getName()); EXPECT_EQ("FormFactorPyramid", pyramidclone->getName());
EXPECT_EQ(4., pyramidclone->getHeight()); EXPECT_EQ(4., pyramidclone->getHeight());
EXPECT_EQ(3., pyramidclone->getHalfSide()); EXPECT_EQ(5., pyramidclone->getHalfSide());
EXPECT_EQ(0.5, pyramidclone->getAlpha()); EXPECT_EQ(0.8, pyramidclone->getAlpha());
EXPECT_EQ(volume, pyramidclone->getVolume()); EXPECT_DOUBLE_EQ(volume, pyramidclone->getVolume());
EXPECT_EQ((int)3, pyramidclone->getNumberOfStochasticParameters()); EXPECT_EQ((int)3, pyramidclone->getNumberOfStochasticParameters());
} }
...@@ -360,21 +431,48 @@ TEST_F(FormFactorTest, Sphere) ...@@ -360,21 +431,48 @@ TEST_F(FormFactorTest, Sphere)
EXPECT_EQ("FormFactorSphere", sphere.getName()); EXPECT_EQ("FormFactorSphere", sphere.getName());
EXPECT_EQ(3., sphere.getHeight()); EXPECT_EQ(3., sphere.getHeight());
EXPECT_EQ(volume, sphere.getVolume()); EXPECT_DOUBLE_EQ(volume, sphere.getVolume());
EXPECT_EQ((int)2, sphere.getNumberOfStochasticParameters()); EXPECT_EQ((int)2, sphere.getNumberOfStochasticParameters());
FormFactorSphere *sphereclone = sphere.clone(); FormFactorSphere *sphereclone = sphere.clone();
EXPECT_EQ("FormFactorSphere", sphereclone->getName()); EXPECT_EQ("FormFactorSphere", sphereclone->getName());
EXPECT_EQ(3., sphereclone->getHeight()); EXPECT_DOUBLE_EQ(3., sphereclone->getHeight());
EXPECT_EQ((int)2, sphereclone->getNumberOfStochasticParameters()); EXPECT_EQ((int)2, sphereclone->getNumberOfStochasticParameters());
} }
// Test form factor of a spheroid
TEST_F(FormFactorTest, Spheroid)
{
double height = 5.;
double radius = 3.;
double flattening = 1.5;
double total_height =2.*flattening *radius;
double volume = M_PI*radius*height/flattening*(1.-height/(3.*flattening*radius));
FormFactorSpheroid spheroid(radius, height,flattening);
EXPECT_EQ("FormFactorSpheroid", spheroid.getName());
EXPECT_EQ(5., spheroid.getHeight());
EXPECT_EQ(3., spheroid.getRadius());
EXPECT_DOUBLE_EQ(total_height, spheroid.getHeightFullSpheroid());
EXPECT_DOUBLE_EQ(volume, spheroid.getVolume());
EXPECT_EQ((int)3, spheroid.getNumberOfStochasticParameters());
FormFactorSpheroid *spheroidclone = spheroid.clone();
EXPECT_EQ("FormFactorSpheroid", spheroidclone->getName());
EXPECT_EQ(5., spheroidclone->getHeight());
EXPECT_EQ(3., spheroidclone->getRadius());
EXPECT_DOUBLE_EQ(total_height, spheroidclone->getHeightFullSpheroid());
EXPECT_DOUBLE_EQ(volume, spheroidclone->getVolume());
EXPECT_EQ((int)3, spheroidclone->getNumberOfStochasticParameters());
}
// Test form factor of a tetrahedron // Test form factor of a tetrahedron
TEST_F(FormFactorTest, Tetrahedron) TEST_F(FormFactorTest, Tetrahedron)
{ {
double height = 5.; double height = 4.;
double half_side = 3.; double half_side = 8.;
double alpha = 0.5; double alpha = 0.8;
double tga = std::tan(alpha); double tga = std::tan(alpha);
double sqrt3HdivRtga = std::sqrt(3.)*height/half_side/tga; double sqrt3HdivRtga = std::sqrt(3.)*height/half_side/tga;
double volume = tga/3.*half_side*half_side*half_side*( double volume = tga/3.*half_side*half_side*half_side*(
...@@ -383,21 +481,22 @@ TEST_F(FormFactorTest, Tetrahedron) ...@@ -383,21 +481,22 @@ TEST_F(FormFactorTest, Tetrahedron)
FormFactorTetrahedron tetrahedron(half_side, height, alpha); FormFactorTetrahedron tetrahedron(half_side, height, alpha);
EXPECT_EQ("FormFactorTetrahedron", tetrahedron.getName()); EXPECT_EQ("FormFactorTetrahedron", tetrahedron.getName());
EXPECT_EQ(5., tetrahedron.getHeight()); EXPECT_EQ(4., tetrahedron.getHeight());
EXPECT_EQ(3., tetrahedron.getHalfSide()); EXPECT_EQ(8., tetrahedron.getHalfSide());
EXPECT_EQ(0.5, tetrahedron.getAlpha()); EXPECT_EQ(0.8, tetrahedron.getAlpha());
EXPECT_EQ(volume, tetrahedron.getVolume()); EXPECT_DOUBLE_EQ(volume, tetrahedron.getVolume());
EXPECT_EQ((int)3, tetrahedron.getNumberOfStochasticParameters()); EXPECT_EQ((int)3, tetrahedron.getNumberOfStochasticParameters());
FormFactorTetrahedron *tetrahedronclone = tetrahedron.clone(); FormFactorTetrahedron *tetrahedronclone = tetrahedron.clone();
EXPECT_EQ("FormFactorTetrahedron", tetrahedronclone->getName()); EXPECT_EQ("FormFactorTetrahedron", tetrahedronclone->getName());
EXPECT_EQ(5., tetrahedronclone->getHeight()); EXPECT_EQ(4., tetrahedronclone->getHeight());
EXPECT_EQ(3., tetrahedronclone->getHalfSide()); EXPECT_EQ(8., tetrahedronclone->getHalfSide());
EXPECT_EQ(0.5, tetrahedronclone->getAlpha()); EXPECT_EQ(0.8, tetrahedronclone->getAlpha());
EXPECT_EQ(volume, tetrahedronclone->getVolume()); EXPECT_DOUBLE_EQ(volume, tetrahedronclone->getVolume());
EXPECT_EQ((int)3, tetrahedronclone->getNumberOfStochasticParameters()); EXPECT_EQ((int)3, tetrahedronclone->getNumberOfStochasticParameters());
} }
#endif // FORMFACTORTEST_H #endif // FORMFACTORTEST_H
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