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

[adapt_cm4] All polyhedral formfactors now constructed by libff; files merged...

[adapt_cm4] All polyhedral formfactors now constructed by libff; files merged into Polyhedra.h|cpp ()

Merging branch 'adapt_cm4'  into 'main'.

See merge request !1188
parents 7df68224 177b6286
No related branches found
No related tags found
1 merge request!1188All polyhedral formfactors now constructed by libff; files merged into Polyhedra.h|cpp
Pipeline #83095 passed
Showing
with 833 additions and 938 deletions
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Sample/HardParticle/Bipyramid4.cpp
//! @brief Implements class Bipyramid4.
//!
//! @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)
//
// ************************************************************************************************
#include "Sample/HardParticle/Bipyramid4.h"
#include "Base/Math/Constants.h"
#include "Base/Math/Functions.h"
#include "Sample/HardParticle/Pyramid4.h"
const ff::Topology Bipyramid4::topology = {{{{3, 2, 1, 0}, true},
{{0, 1, 5, 4}, false},
{{1, 2, 6, 5}, false},
{{2, 3, 7, 6}, false},
{{3, 0, 4, 7}, false},
{{4, 5, 9, 8}, false},
{{5, 6, 10, 9}, false},
{{6, 7, 11, 10}, false},
{{7, 4, 8, 11}, false},
{{8, 9, 10, 11}, true}},
false};
Bipyramid4::Bipyramid4(const std::vector<double> P)
: IFormFactorPolyhedron(P)
, m_length(m_P[0])
, m_height(m_P[1])
, m_height_ratio(m_P[2])
, m_alpha(m_P[3])
{
validateOrThrow();
}
Bipyramid4::Bipyramid4(double length, double height, double height_ratio, double alpha)
: Bipyramid4(std::vector<double>{length, height, height_ratio, alpha})
{
}
std::string Bipyramid4::validate() const
{
std::vector<std::string> errs;
requestGt0(errs, m_length, "length");
requestGt0(errs, m_height, "height");
requestGt0(errs, m_height_ratio, "height_ratio");
const double cot_alpha = Math::cot(m_alpha);
if (m_alpha <= 0 || !std::isfinite(cot_alpha) || cot_alpha < 0)
errs.push_back("pyramid angle alpha=" + std::to_string(m_alpha) + " out of bounds");
if (!errs.empty())
return jointError(errs);
const double x = m_height_ratio;
const double r = cot_alpha * 2 * m_height / m_length;
if (std::max(1., x) * r > 1)
errs.push_back(
"parameters violate condition 2*height <= length*tan(alpha)*min(1,1/height_ratio)");
if (!errs.empty())
return jointError(errs);
const double a = m_length / 2 * (1 - r);
const double b = m_length / 2;
const double c = m_length / 2 * (1 - r * x);
const double dzcom =
m_height * ((x * x - 1) / 2 - 2 * r * (x * x * x - 1) / 3 + r * r * (x * x * x * x - 1) / 4)
/ ((x + 1) - r * (x * x + 1) + r * r * (x * x * x + 1) / 3);
const double za = -dzcom - m_height;
const double zb = -dzcom;
const double zc = -dzcom + x * m_height;
setPolyhedron(topology, za,
{// base:
{-a, -a, za},
{a, -a, za},
{a, a, za},
{-a, a, za},
// middle
{-b, -b, zb},
{b, -b, zb},
{b, b, zb},
{-b, b, zb},
// top
{-c, -c, zc},
{c, -c, zc},
{c, c, zc},
{-c, c, zc}});
m_validated = true;
return "";
}
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Sample/HardParticle/Bipyramid4.h
//! @brief Defines class Bipyramid4
//!
//! @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)
//
// ************************************************************************************************
#ifndef BORNAGAIN_SAMPLE_HARDPARTICLE_BIPYRAMID4_H
#define BORNAGAIN_SAMPLE_HARDPARTICLE_BIPYRAMID4_H
#include "Sample/HardParticle/IFormFactorPolyhedron.h"
//! A truncated bifrustum with quadratic base.
//! @ingroup hardParticle
class Bipyramid4 : public IFormFactorPolyhedron {
public:
Bipyramid4(double length, double height, double height_ratio, double alpha);
#ifndef USER_API
Bipyramid4(std::vector<double> P);
Bipyramid4* clone() const override
{
return new Bipyramid4(m_length, m_height, m_height_ratio, m_alpha);
}
std::string className() const final
{
return "Bipyramid4";
}
std::vector<ParaMeta> parDefs() const final
{
return {{"Length", "nm"}, {"Height", "nm"}, {"HeightRatio", ""}, {"Alpha", "rad"}};
}
double length() const
{
return m_length;
}
double height() const
{
return m_height;
}
double heightRatio() const
{
return m_height_ratio;
}
double alpha() const
{
return m_alpha;
}
std::string validate() const override;
#endif // USER_API
private:
static const ff::Topology topology;
const double& m_length;
const double& m_height;
const double& m_height_ratio;
const double& m_alpha;
};
#endif // BORNAGAIN_SAMPLE_HARDPARTICLE_BIPYRAMID4_H
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Sample/HardParticle/Box.cpp
//! @brief Implements class Box.
//!
//! @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)
//
// ************************************************************************************************
#include "Sample/HardParticle/Box.h"
#include "Base/Math/Functions.h"
#include "Base/Util/Assert.h"
Box::Box(const std::vector<double> P)
: IFormFactorPrism(P)
, m_length(m_P[0])
, m_width(m_P[1])
, m_height(m_P[2])
{
validateOrThrow();
}
Box::Box(double length, double width, double height)
: Box(std::vector<double>{length, width, height})
{
}
complex_t Box::formfactor(C3 q) const
{
ASSERT(m_validated);
complex_t qzHdiv2 = m_height / 2 * q.z();
return m_length * m_width * m_height * Math::sinc(m_length / 2 * q.x())
* Math::sinc(m_width / 2 * q.y()) * Math::sinc(qzHdiv2) * exp_I(qzHdiv2);
}
std::string Box::validate() const
{
std::vector<std::string> errs;
requestGt0(errs, m_length, "length");
requestGt0(errs, m_width, "width");
requestGt0(errs, m_height, "height");
if (!errs.empty())
return jointError(errs);
double a = m_length / 2;
double b = m_width / 2;
std::vector<R3> base_vertices{{a, b, 0.}, {-a, b, 0.}, {-a, -b, 0.}, {a, -b, 0}};
setPrism(true, base_vertices);
m_validated = true;
return "";
}
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Sample/HardParticle/Box.h
//! @brief Defines class Box.
//!
//! @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)
//
// ************************************************************************************************
#ifndef BORNAGAIN_SAMPLE_HARDPARTICLE_BOX_H
#define BORNAGAIN_SAMPLE_HARDPARTICLE_BOX_H
#include "Sample/HardParticle/IFormFactorPrism.h"
//! A rectangular prism (parallelepiped).
//! @ingroup hardParticle
class Box : public IFormFactorPrism {
public:
Box(double length, double width, double height);
#ifndef USER_API
Box(std::vector<double> P);
Box* clone() const override
{
return new Box(m_length, m_width, m_height);
}
std::string className() const final
{
return "Box";
}
std::vector<ParaMeta> parDefs() const final
{
return {{"Length", "nm"}, {"Width", "nm"}, {"Height", "nm"}};
}
double length() const
{
return m_length;
}
double width() const
{
return m_width;
}
double height() const override
{
return m_height;
}
double volume() const override
{
return m_length * m_height * m_width;
}
double radialExtension() const override
{
return m_length / 2.0;
}
complex_t formfactor(C3 q) const override;
std::string validate() const override;
private:
const double& m_length;
const double& m_width;
const double& m_height;
#endif // USER_API
};
#endif // BORNAGAIN_SAMPLE_HARDPARTICLE_BOX_H
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Sample/HardParticle/CantellatedCube.cpp
//! @brief Implements class CantellatedCube.
//!
//! @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)
//
// ************************************************************************************************
#include "Sample/HardParticle/CantellatedCube.h"
const ff::Topology CantellatedCube::topology = {{
/* 0 */ {{0, 1, 2, 3}, true},
/* 1 */ {{0, 8, 5, 1}, true},
/* 2 */ {{1, 9, 6, 2}, true},
/* 3 */ {{2, 10, 7, 3}, true},
/* 4 */ {{3, 11, 4, 0}, true},
/* 5 */ {{0, 4, 8}, false},
/* 6 */ {{1, 5, 9}, false},
/* 7 */ {{2, 6, 10}, false},
/* 8 */ {{3, 7, 11}, false},
/* 9 */ {{4, 12, 16, 8}, true},
/* 10 */ {{5, 13, 17, 9}, true},
/* 11 */ {{4, 11, 19, 12}, true},
/* 12 */ {{5, 8, 16, 13}, true},
/* 13 */ {{7, 10, 18, 15}, true},
/* 14 */ {{6, 9, 17, 14}, true},
/* 15 */ {{7, 15, 19, 11}, true},
/* 16 */ {{6, 14, 18, 10}, true},
/* 17 */ {{13, 21, 17}, false},
/* 18 */ {{12, 20, 16}, false},
/* 19 */ {{15, 23, 19}, false},
/* 20 */ {{14, 22, 18}, false},
/* 21 */ {{14, 17, 21, 22}, true},
/* 22 */ {{13, 16, 20, 21}, true},
/* 23 */ {{12, 19, 23, 20}, true},
/* 24 */ {{15, 18, 22, 23}, true},
/* 25 */ {{20, 23, 22, 21}, true},
},
true};
CantellatedCube::CantellatedCube(const std::vector<double> P)
: IFormFactorPolyhedron(P)
, m_length(m_P[0])
, m_removed_length(m_P[1])
{
validateOrThrow();
}
CantellatedCube::CantellatedCube(double length, double removed_length)
: CantellatedCube(std::vector<double>{length, removed_length})
{
}
std::string CantellatedCube::validate() const
{
std::vector<std::string> errs;
requestGt0(errs, m_length, "length");
requestGe0(errs, m_removed_length, "removed_length");
if (!errs.empty())
return jointError(errs);
if (m_removed_length > 0.5 * m_length) {
errs.push_back("parameters violate condition removed_length <= 0.5*length");
return jointError(errs);
}
double a = m_length / 2;
double c = a - m_removed_length;
setPolyhedron(topology, -a, {{-c, -c, +a}, // point 0
{+c, -c, +a}, {+c, +c, +a}, {-c, +c, +a}, {-a, -c, +c}, // point 4
{+c, -a, +c}, {+a, +c, +c}, {-c, +a, +c}, {-c, -a, +c}, // point 8
{+a, -c, +c}, {+c, +a, +c}, {-a, +c, +c}, {-a, -c, -c}, // point 12
{+c, -a, -c}, {+a, +c, -c}, {-c, +a, -c}, {-c, -a, -c}, // point 16
{+a, -c, -c}, {+c, +a, -c}, {-a, +c, -c}, {-c, -c, -a}, // point 20
{+c, -c, -a}, {+c, +c, -a}, {-c, +c, -a}});
m_validated = true;
return "";
}
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Sample/HardParticle/CantellatedCube.h
//! @brief Defines class CantellatedCube.
//!
//! @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)
//
// ************************************************************************************************
#ifndef BORNAGAIN_SAMPLE_HARDPARTICLE_CANTELLATEDCUBE_H
#define BORNAGAIN_SAMPLE_HARDPARTICLE_CANTELLATEDCUBE_H
#include "Sample/HardParticle/IFormFactorPolyhedron.h"
//! A cube, with truncation of all edges and corners, as in Croset (2017) Fig 7
//! @ingroup hardParticle
class CantellatedCube : public IFormFactorPolyhedron {
public:
CantellatedCube(double length, double removed_length);
#ifndef USER_API
CantellatedCube(std::vector<double> P);
CantellatedCube* clone() const override
{
return new CantellatedCube(m_length, m_removed_length);
}
std::string className() const final
{
return "CantellatedCube";
}
std::vector<ParaMeta> parDefs() const final
{
return {{"Length", "nm"}, {"RemovedLength", "nm"}};
}
double length() const
{
return m_length;
}
double removedLength() const
{
return m_removed_length;
}
std::string validate() const override;
#endif // USER_API
private:
static const ff::Topology topology;
const double& m_length;
const double& m_removed_length;
};
#endif // BORNAGAIN_SAMPLE_HARDPARTICLE_CANTELLATEDCUBE_H
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Sample/HardParticle/Dodecahedron.cpp
//! @brief Implements class Dodecahedron.
//!
//! @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)
//
// ************************************************************************************************
#include "Sample/HardParticle/Dodecahedron.h"
#include <ff/Make.h>
Dodecahedron::Dodecahedron(const std::vector<double> P)
: IFormFactorPolyhedron(P)
, m_edge(m_P[0])
{
pimpl.reset(ff::make::Dodecahedron(m_edge));
m_validated = true;
}
Dodecahedron::Dodecahedron(double edge)
: Dodecahedron(std::vector<double>{edge})
{
}
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Sample/HardParticle/Dodecahedron.h
//! @brief Defines class Dodecahedron.
//!
//! @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)
//
// ************************************************************************************************
#ifndef BORNAGAIN_SAMPLE_HARDPARTICLE_DODECAHEDRON_H
#define BORNAGAIN_SAMPLE_HARDPARTICLE_DODECAHEDRON_H
#include "Sample/HardParticle/IFormFactorPolyhedron.h"
//! A regular dodecahedron.
//! @ingroup hardParticle
class Dodecahedron : public IFormFactorPolyhedron {
public:
Dodecahedron(double edge);
#ifndef USER_API
Dodecahedron(std::vector<double> P);
Dodecahedron* clone() const override
{
return new Dodecahedron(m_edge);
}
std::string className() const final
{
return "Dodecahedron";
}
std::vector<ParaMeta> parDefs() const final
{
return {{"Edge", "nm"}};
}
double edge() const
{
return m_edge;
}
private:
static const ff::Topology topology;
const double& m_edge;
#endif // USER_API
};
#endif // BORNAGAIN_SAMPLE_HARDPARTICLE_DODECAHEDRON_H
...@@ -20,34 +20,24 @@ ...@@ -20,34 +20,24 @@
#ifndef BORNAGAIN_SAMPLE_HARDPARTICLE_HARDPARTICLES_H #ifndef BORNAGAIN_SAMPLE_HARDPARTICLE_HARDPARTICLES_H
#define BORNAGAIN_SAMPLE_HARDPARTICLE_HARDPARTICLES_H #define BORNAGAIN_SAMPLE_HARDPARTICLE_HARDPARTICLES_H
#include "Sample/HardParticle/Bar.h" #include "Sample/HardParticle/Polyhedra.h"
#include "Sample/HardParticle/Bipyramid4.h"
#include "Sample/HardParticle/Box.h"
#include "Sample/HardParticle/CantellatedCube.h"
#include "Sample/HardParticle/Cone.h" #include "Sample/HardParticle/Cone.h"
#include "Sample/HardParticle/CosineRipple.h"
#include "Sample/HardParticle/Cylinder.h" #include "Sample/HardParticle/Cylinder.h"
#include "Sample/HardParticle/Dodecahedron.h"
#include "Sample/HardParticle/EllipsoidalCylinder.h" #include "Sample/HardParticle/EllipsoidalCylinder.h"
#include "Sample/HardParticle/HemiEllipsoid.h" #include "Sample/HardParticle/HemiEllipsoid.h"
#include "Sample/HardParticle/HorizontalCylinder.h" #include "Sample/HardParticle/HorizontalCylinder.h"
#include "Sample/HardParticle/Icosahedron.h"
#include "Sample/HardParticle/LongBoxGauss.h"
#include "Sample/HardParticle/LongBoxLorentz.h"
#include "Sample/HardParticle/PlatonicOctahedron.h"
#include "Sample/HardParticle/PlatonicTetrahedron.h"
#include "Sample/HardParticle/Prism3.h"
#include "Sample/HardParticle/Prism6.h"
#include "Sample/HardParticle/Pyramid2.h"
#include "Sample/HardParticle/Pyramid3.h"
#include "Sample/HardParticle/Pyramid4.h"
#include "Sample/HardParticle/Pyramid6.h"
#include "Sample/HardParticle/SawtoothRipple.h"
#include "Sample/HardParticle/Sphere.h" #include "Sample/HardParticle/Sphere.h"
#include "Sample/HardParticle/Spheroid.h" #include "Sample/HardParticle/Spheroid.h"
#include "Sample/HardParticle/TruncatedCube.h"
#include "Sample/HardParticle/TruncatedSphere.h" #include "Sample/HardParticle/TruncatedSphere.h"
#include "Sample/HardParticle/TruncatedSpheroid.h" #include "Sample/HardParticle/TruncatedSpheroid.h"
#include "Sample/HardParticle/Bar.h"
#include "Sample/HardParticle/CosineRipple.h"
#include "Sample/HardParticle/SawtoothRipple.h"
#include "Sample/HardParticle/LongBoxGauss.h"
#include "Sample/HardParticle/LongBoxLorentz.h"
#endif // BORNAGAIN_SAMPLE_HARDPARTICLE_HARDPARTICLES_H #endif // BORNAGAIN_SAMPLE_HARDPARTICLE_HARDPARTICLES_H
#endif // USER_API #endif // USER_API
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Sample/HardParticle/Icosahedron.cpp
//! @brief Implements class Icosahedron.
//!
//! @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)
//
// ************************************************************************************************
#include "Sample/HardParticle/Icosahedron.h"
#include <ff/Make.h>
Icosahedron::Icosahedron(const std::vector<double> P)
: IFormFactorPolyhedron(P)
, m_edge(m_P[0])
{
pimpl.reset(ff::make::Icosahedron(m_edge));
m_validated = true;
}
Icosahedron::Icosahedron(double edge)
: Icosahedron(std::vector<double>{edge})
{
}
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Sample/HardParticle/Icosahedron.h
//! @brief Defines class Icosahedron.
//!
//! @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)
//
// ************************************************************************************************
#ifndef BORNAGAIN_SAMPLE_HARDPARTICLE_ICOSAHEDRON_H
#define BORNAGAIN_SAMPLE_HARDPARTICLE_ICOSAHEDRON_H
#include "Sample/HardParticle/IFormFactorPolyhedron.h"
//! A regular icosahedron.
//! @ingroup hardParticle
class Icosahedron : public IFormFactorPolyhedron {
public:
Icosahedron(double edge);
#ifndef USER_API
Icosahedron(std::vector<double> P);
Icosahedron* clone() const override
{
return new Icosahedron(m_edge);
}
std::string className() const final
{
return "Icosahedron";
}
std::vector<ParaMeta> parDefs() const final
{
return {{"Edge", "nm"}};
}
double edge() const
{
return m_edge;
}
private:
static const ff::Topology topology;
const double& m_edge;
#endif // USER_API
};
#endif // BORNAGAIN_SAMPLE_HARDPARTICLE_ICOSAHEDRON_H
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Sample/HardParticle/PlatonicOctahedron.cpp
//! @brief Implements class PlatonicOctahedron.
//!
//! @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)
//
// ************************************************************************************************
#include "Sample/HardParticle/PlatonicOctahedron.h"
#include "Base/Math/Constants.h"
#include "Base/Math/Functions.h"
#include <ff/Make.h>
PlatonicOctahedron::PlatonicOctahedron(const std::vector<double> P)
: IFormFactorPolyhedron(P)
, m_edge(m_P[0])
{
pimpl.reset(ff::make::Octahedron(m_edge));
m_validated = true;
}
PlatonicOctahedron::PlatonicOctahedron(double edge)
: PlatonicOctahedron(std::vector<double>{edge})
{
}
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Sample/HardParticle/PlatonicOctahedron.h
//! @brief Defines class PlatonicOctahedron
//!
//! @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)
//
// ************************************************************************************************
#ifndef BORNAGAIN_SAMPLE_HARDPARTICLE_PLATONICOCTAHEDRON_H
#define BORNAGAIN_SAMPLE_HARDPARTICLE_PLATONICOCTAHEDRON_H
#include "Sample/HardParticle/IFormFactorPolyhedron.h"
//! A truncated bifrustum with quadratic base.
//! @ingroup hardParticle
class PlatonicOctahedron : public IFormFactorPolyhedron {
public:
PlatonicOctahedron(double edge);
#ifndef USER_API
PlatonicOctahedron(std::vector<double> P);
PlatonicOctahedron* clone() const override
{
return new PlatonicOctahedron(m_edge);
}
std::string className() const final
{
return "PlatonicOctahedron";
}
std::vector<ParaMeta> parDefs() const final
{
return {{"Edge", "nm"}};
}
double edge() const
{
return m_edge;
}
double height() const
{
return sqrt(1 / 2.) * m_edge;
}
private:
static const ff::Topology topology;
const double& m_edge;
#endif // USER_API
};
#endif // BORNAGAIN_SAMPLE_HARDPARTICLE_PLATONICOCTAHEDRON_H
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Sample/HardParticle/PlatonicTetrahedron.cpp
//! @brief Implements class PlatonicTetrahedron.
//!
//! @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)
//
// ************************************************************************************************
#include "Sample/HardParticle/PlatonicTetrahedron.h"
#include "Base/Math/Constants.h"
#include "Base/Math/Functions.h"
#include <ff/Make.h>
PlatonicTetrahedron::PlatonicTetrahedron(const std::vector<double> P)
: IFormFactorPolyhedron(P)
, m_edge(m_P[0])
{
pimpl.reset(ff::make::Tetrahedron(m_edge));
m_validated = true;
}
PlatonicTetrahedron::PlatonicTetrahedron(double edge)
: PlatonicTetrahedron(std::vector<double>{edge})
{
}
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Sample/HardParticle/PlatonicTetrahedron.h
//! @brief Defines class PlatonicTetrahedron
//!
//! @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)
//
// ************************************************************************************************
#ifndef BORNAGAIN_SAMPLE_HARDPARTICLE_PLATONICTETRAHEDRON_H
#define BORNAGAIN_SAMPLE_HARDPARTICLE_PLATONICTETRAHEDRON_H
#include "Sample/HardParticle/IFormFactorPolyhedron.h"
//! A frustum with equilateral trigonal base.
//! @ingroup hardParticle
class PlatonicTetrahedron : public IFormFactorPolyhedron {
public:
PlatonicTetrahedron(double edge);
#ifndef USER_API
PlatonicTetrahedron(std::vector<double> P);
PlatonicTetrahedron* clone() const override
{
return new PlatonicTetrahedron(m_edge);
}
std::string className() const final
{
return "PlatonicTetrahedron";
}
std::vector<ParaMeta> parDefs() const final
{
return {{"Edge", "nm"}};
}
double edge() const
{
return m_edge;
}
double height() const
{
return sqrt(2. / 3) * m_edge;
}
private:
static const ff::Topology topology;
const double& m_edge;
#endif // USER_API
};
#endif // BORNAGAIN_SAMPLE_HARDPARTICLE_PLATONICTETRAHEDRON_H
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Sample/HardParticle/Box.cpp
//! @brief Implements class Box.
//!
//! @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)
//
// ************************************************************************************************
#include "Sample/HardParticle/Polyhedra.h"
#include <ff/Make.h>
// ************************************************************************************************
// Prisms
// ************************************************************************************************
Box::Box(const std::vector<double> P)
: IFormFactorPrism(P)
, m_length(m_P[0])
, m_width(m_P[1])
, m_height(m_P[2])
{
pimpl.reset(ff::make::Box(m_length, m_width, m_height));
m_validated = true;
}
Box::Box(double length, double width, double height)
: Box(std::vector<double>{length, width, height})
{
}
Prism3::Prism3(const std::vector<double> P)
: IFormFactorPrism(P)
, m_base_edge(m_P[0])
, m_height(m_P[1])
{
pimpl.reset(ff::make::Prism3(m_base_edge, m_height));
m_validated = true;
}
Prism3::Prism3(double base_edge, double height)
: Prism3(std::vector<double>{base_edge, height})
{
}
Prism6::Prism6(const std::vector<double> P)
: IFormFactorPrism(P)
, m_base_edge(m_P[0])
, m_height(m_P[1])
{
pimpl.reset(ff::make::Prism6(m_base_edge, m_height));
m_validated = true;
}
Prism6::Prism6(double base_edge, double height)
: Prism6(std::vector<double>{base_edge, height})
{
}
// ************************************************************************************************
// Platonic solids
// ************************************************************************************************
PlatonicTetrahedron::PlatonicTetrahedron(const std::vector<double> P)
: IFormFactorPolyhedron(P)
, m_edge(m_P[0])
{
pimpl.reset(ff::make::Tetrahedron(m_edge));
m_validated = true;
}
PlatonicTetrahedron::PlatonicTetrahedron(double edge)
: PlatonicTetrahedron(std::vector<double>{edge})
{
}
PlatonicOctahedron::PlatonicOctahedron(const std::vector<double> P)
: IFormFactorPolyhedron(P)
, m_edge(m_P[0])
{
pimpl.reset(ff::make::Octahedron(m_edge));
m_validated = true;
}
PlatonicOctahedron::PlatonicOctahedron(double edge)
: PlatonicOctahedron(std::vector<double>{edge})
{
}
Dodecahedron::Dodecahedron(const std::vector<double> P)
: IFormFactorPolyhedron(P)
, m_edge(m_P[0])
{
pimpl.reset(ff::make::Dodecahedron(m_edge));
m_validated = true;
}
Dodecahedron::Dodecahedron(double edge)
: Dodecahedron(std::vector<double>{edge})
{
}
Icosahedron::Icosahedron(const std::vector<double> P)
: IFormFactorPolyhedron(P)
, m_edge(m_P[0])
{
pimpl.reset(ff::make::Icosahedron(m_edge));
m_validated = true;
}
Icosahedron::Icosahedron(double edge)
: Icosahedron(std::vector<double>{edge})
{
}
// ************************************************************************************************
// Pyramids
// ************************************************************************************************
Pyramid2::Pyramid2(const std::vector<double> P)
: IFormFactorPolyhedron(P)
, m_length(m_P[0])
, m_width(m_P[1])
, m_height(m_P[2])
, m_alpha(m_P[3])
{
pimpl.reset(ff::make::Pyramid2(m_length, m_width, m_height, m_alpha));
m_validated = true;
}
Pyramid2::Pyramid2(double length, double width, double height, double alpha)
: Pyramid2(std::vector<double>{length, width, height, alpha})
{
}
Pyramid3::Pyramid3(const std::vector<double> P)
: IFormFactorPolyhedron(P)
, m_base_edge(m_P[0])
, m_height(m_P[1])
, m_alpha(m_P[2])
{
pimpl.reset(ff::make::Pyramid3(m_base_edge, m_height, m_alpha));
m_validated = true;
}
Pyramid3::Pyramid3(double base_edge, double height, double alpha)
: Pyramid3(std::vector<double>{base_edge, height, alpha})
{
}
Pyramid4::Pyramid4(const std::vector<double> P)
: IFormFactorPolyhedron(P)
, m_base_edge(m_P[0])
, m_height(m_P[1])
, m_alpha(m_P[2])
{
pimpl.reset(ff::make::Pyramid4(m_base_edge, m_height, m_alpha));
m_validated = true;
}
Pyramid4::Pyramid4(double base_edge, double height, double alpha)
: Pyramid4(std::vector<double>{base_edge, height, alpha})
{
}
Pyramid6::Pyramid6(const std::vector<double> P)
: IFormFactorPolyhedron(P)
, m_base_edge(m_P[0])
, m_height(m_P[1])
, m_alpha(m_P[2])
{
pimpl.reset(ff::make::Pyramid6(m_base_edge, m_height, m_alpha));
m_validated = true;
}
Pyramid6::Pyramid6(double base_edge, double height, double alpha)
: Pyramid6(std::vector<double>{base_edge, height, alpha})
{
}
Bipyramid4::Bipyramid4(const std::vector<double> P)
: IFormFactorPolyhedron(P)
, m_length(m_P[0])
, m_height(m_P[1])
, m_height_ratio(m_P[2])
, m_alpha(m_P[3])
{
pimpl.reset(ff::make::Bipyramid4(m_length, m_height, m_height_ratio, m_alpha));
m_validated = true;
}
Bipyramid4::Bipyramid4(double length, double height, double height_ratio, double alpha)
: Bipyramid4(std::vector<double>{length, height, height_ratio, alpha})
{
}
// ************************************************************************************************
// Others
// ************************************************************************************************
CantellatedCube::CantellatedCube(const std::vector<double> P)
: IFormFactorPolyhedron(P)
, m_length(m_P[0])
, m_removed_length(m_P[1])
{
pimpl.reset(ff::make::CantellatedCube(m_length, m_removed_length));
m_validated = true;
}
CantellatedCube::CantellatedCube(double length, double removed_length)
: CantellatedCube(std::vector<double>{length, removed_length})
{
}
TruncatedCube::TruncatedCube(const std::vector<double> P)
: IFormFactorPolyhedron(P)
, m_length(m_P[0])
, m_removed_length(m_P[1])
{
pimpl.reset(ff::make::TruncatedCube(m_length, m_removed_length));
m_validated = true;
}
TruncatedCube::TruncatedCube(double length, double removed_length)
: TruncatedCube(std::vector<double>{length, removed_length})
{
}
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Sample/HardParticle/Box.h
//! @brief Defines class Box.
//!
//! @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)
//
// ************************************************************************************************
#ifndef BORNAGAIN_SAMPLE_HARDPARTICLE_POLYHEDRA_H
#define BORNAGAIN_SAMPLE_HARDPARTICLE_POLYHEDRA_H
#include "Sample/HardParticle/IFormFactorPolyhedron.h"
#include "Sample/HardParticle/IFormFactorPrism.h"
// ************************************************************************************************
// Prisms
// ************************************************************************************************
//! A rectangular prism (parallelepiped).
//! @ingroup hardParticle
class Box : public IFormFactorPrism {
public:
Box(double length, double width, double height);
#ifndef USER_API
Box(std::vector<double> P);
Box* clone() const override
{
return new Box(m_length, m_width, m_height);
}
std::string className() const final
{
return "Box";
}
std::vector<ParaMeta> parDefs() const final
{
return {{"Length", "nm"}, {"Width", "nm"}, {"Height", "nm"}};
}
double length() const
{
return m_length;
}
double width() const
{
return m_width;
}
double height() const override
{
return m_height;
}
private:
const double& m_length;
const double& m_width;
const double& m_height;
#endif // USER_API
};
//! A prism based on an equilateral triangle.
//! @ingroup hardParticle
class Prism3 : public IFormFactorPrism {
public:
Prism3(double base_edge, double height);
#ifndef USER_API
Prism3(std::vector<double> P);
Prism3* clone() const override
{
return new Prism3(m_base_edge, m_height);
}
std::string className() const final
{
return "Prism3";
}
std::vector<ParaMeta> parDefs() const final
{
return {{"BaseEdge", "nm"}, {"Height", "nm"}};
}
double baseEdge() const
{
return m_base_edge;
}
double height() const override
{
return m_height;
}
private:
const double& m_base_edge;
const double& m_height;
#endif // USER_API
};
//! A prism based on a regular hexagonal.
//! @ingroup hardParticle
class Prism6 : public IFormFactorPrism {
public:
Prism6(double base_edge, double height);
#ifndef USER_API
Prism6(std::vector<double> P);
Prism6* clone() const override
{
return new Prism6(m_base_edge, m_height);
}
std::string className() const final
{
return "Prism6";
}
std::vector<ParaMeta> parDefs() const final
{
return {{"BaseEdge", "nm"}, {"Height", "nm"}};
}
double baseEdge() const
{
return m_base_edge;
}
double height() const override
{
return m_height;
}
private:
const double& m_base_edge;
const double& m_height;
#endif // USER_API
};
// ************************************************************************************************
// Platonic solids
// ************************************************************************************************
//! A frustum with equilateral trigonal base.
//! @ingroup hardParticle
class PlatonicTetrahedron : public IFormFactorPolyhedron {
public:
PlatonicTetrahedron(double edge);
#ifndef USER_API
PlatonicTetrahedron(std::vector<double> P);
PlatonicTetrahedron* clone() const override
{
return new PlatonicTetrahedron(m_edge);
}
std::string className() const final
{
return "PlatonicTetrahedron";
}
std::vector<ParaMeta> parDefs() const final
{
return {{"Edge", "nm"}};
}
double edge() const
{
return m_edge;
}
double height() const
{
return sqrt(2. / 3) * m_edge;
}
private:
const double& m_edge;
#endif // USER_API
};
//! A truncated bifrustum with quadratic base.
//! @ingroup hardParticle
class PlatonicOctahedron : public IFormFactorPolyhedron {
public:
PlatonicOctahedron(double edge);
#ifndef USER_API
PlatonicOctahedron(std::vector<double> P);
PlatonicOctahedron* clone() const override
{
return new PlatonicOctahedron(m_edge);
}
std::string className() const final
{
return "PlatonicOctahedron";
}
std::vector<ParaMeta> parDefs() const final
{
return {{"Edge", "nm"}};
}
double edge() const
{
return m_edge;
}
double height() const
{
return sqrt(1 / 2.) * m_edge;
}
private:
const double& m_edge;
#endif // USER_API
};
//! A regular dodecahedron.
//! @ingroup hardParticle
class Dodecahedron : public IFormFactorPolyhedron {
public:
Dodecahedron(double edge);
#ifndef USER_API
Dodecahedron(std::vector<double> P);
Dodecahedron* clone() const override
{
return new Dodecahedron(m_edge);
}
std::string className() const final
{
return "Dodecahedron";
}
std::vector<ParaMeta> parDefs() const final
{
return {{"Edge", "nm"}};
}
double edge() const
{
return m_edge;
}
private:
const double& m_edge;
#endif // USER_API
};
//! A regular icosahedron.
//! @ingroup hardParticle
class Icosahedron : public IFormFactorPolyhedron {
public:
Icosahedron(double edge);
#ifndef USER_API
Icosahedron(std::vector<double> P);
Icosahedron* clone() const override
{
return new Icosahedron(m_edge);
}
std::string className() const final
{
return "Icosahedron";
}
std::vector<ParaMeta> parDefs() const final
{
return {{"Edge", "nm"}};
}
double edge() const
{
return m_edge;
}
private:
const double& m_edge;
#endif // USER_API
};
// ************************************************************************************************
// Pyramids
// ************************************************************************************************
//! A frustum (truncated pyramid) with rectangular base.
//! @ingroup hardParticle
class Pyramid2 : public IFormFactorPolyhedron {
public:
Pyramid2(double length, double width, double height, double alpha);
#ifndef USER_API
Pyramid2(std::vector<double> P);
Pyramid2* clone() const override
{
return new Pyramid2(m_length, m_width, m_height, m_alpha);
}
std::string className() const final
{
return "Pyramid2";
}
std::vector<ParaMeta> parDefs() const final
{
return {{"Length", "nm"}, {"Width", "nm"}, {"Height", "nm"}, {"Alpha", "rad"}};
}
double length() const
{
return m_length;
}
double width() const
{
return m_width;
}
double height() const
{
return m_height;
}
double alpha() const
{
return m_alpha;
}
private:
const double& m_length;
const double& m_width;
const double& m_height;
const double& m_alpha;
#endif // USER_API
};
//! A frustum with equilateral trigonal base.
//! @ingroup hardParticle
class Pyramid3 : public IFormFactorPolyhedron {
public:
Pyramid3(double base_edge, double height, double alpha);
#ifndef USER_API
Pyramid3(std::vector<double> P);
Pyramid3* clone() const override
{
return new Pyramid3(m_base_edge, m_height, m_alpha);
}
std::string className() const final
{
return "Pyramid3";
}
std::vector<ParaMeta> parDefs() const final
{
return {{"BaseEdge", "nm"}, {"Height", "nm"}, {"Alpha", "rad"}};
}
double baseEdge() const
{
return m_base_edge;
}
double height() const
{
return m_height;
}
double alpha() const
{
return m_alpha;
}
private:
const double& m_base_edge;
const double& m_height;
const double& m_alpha;
#endif // USER_API
};
//! A frustum with a quadratic base.
//! @ingroup hardParticle
class Pyramid4 : public IFormFactorPolyhedron {
public:
Pyramid4(double base_edge, double height, double alpha);
#ifndef USER_API
Pyramid4(std::vector<double> P);
Pyramid4* clone() const override
{
return new Pyramid4(m_base_edge, m_height, m_alpha);
}
std::string className() const final
{
return "Pyramid4";
}
std::vector<ParaMeta> parDefs() const final
{
return {{"BaseEdge", "nm"}, {"Height", "nm"}, {"Alpha", "rad"}};
}
double height() const
{
return m_height;
}
double baseEdge() const
{
return m_base_edge;
}
double alpha() const
{
return m_alpha;
}
private:
const double& m_base_edge;
const double& m_height;
const double& m_alpha;
#endif // USER_API
};
//! A frustum (truncated pyramid) with regular hexagonal base.
//! @ingroup hardParticle
class Pyramid6 : public IFormFactorPolyhedron {
public:
Pyramid6(double base_edge, double height, double alpha);
#ifndef USER_API
Pyramid6(std::vector<double> P);
Pyramid6* clone() const override
{
return new Pyramid6(m_base_edge, m_height, m_alpha);
}
std::string className() const final
{
return "Pyramid6";
}
std::vector<ParaMeta> parDefs() const final
{
return {{"BaseEdge", "nm"}, {"Height", "nm"}, {"Alpha", "rad"}};
}
double baseEdge() const
{
return m_base_edge;
}
double height() const
{
return m_height;
}
double alpha() const
{
return m_alpha;
}
private:
const double& m_base_edge;
const double& m_height;
const double& m_alpha;
#endif // USER_API
};
//! A truncated bifrustum with quadratic base.
//! @ingroup hardParticle
class Bipyramid4 : public IFormFactorPolyhedron {
public:
Bipyramid4(double length, double height, double height_ratio, double alpha);
#ifndef USER_API
Bipyramid4(std::vector<double> P);
Bipyramid4* clone() const override
{
return new Bipyramid4(m_length, m_height, m_height_ratio, m_alpha);
}
std::string className() const final
{
return "Bipyramid4";
}
std::vector<ParaMeta> parDefs() const final
{
return {{"Length", "nm"}, {"Height", "nm"}, {"HeightRatio", ""}, {"Alpha", "rad"}};
}
double length() const
{
return m_length;
}
double height() const
{
return m_height;
}
double heightRatio() const
{
return m_height_ratio;
}
double alpha() const
{
return m_alpha;
}
#endif // USER_API
private:
const double& m_length;
const double& m_height;
const double& m_height_ratio;
const double& m_alpha;
};
// ************************************************************************************************
// Others
// ************************************************************************************************
//! A cube, with truncation of all edges and corners, as in Croset (2017) Fig 7
//! @ingroup hardParticle
class CantellatedCube : public IFormFactorPolyhedron {
public:
CantellatedCube(double length, double removed_length);
#ifndef USER_API
CantellatedCube(std::vector<double> P);
CantellatedCube* clone() const override
{
return new CantellatedCube(m_length, m_removed_length);
}
std::string className() const final
{
return "CantellatedCube";
}
std::vector<ParaMeta> parDefs() const final
{
return {{"Length", "nm"}, {"RemovedLength", "nm"}};
}
double length() const
{
return m_length;
}
double removedLength() const
{
return m_removed_length;
}
#endif // USER_API
private:
const double& m_length;
const double& m_removed_length;
};
//! A cube, with tetrahedral truncation of all corners
//! @ingroup hardParticle
class TruncatedCube : public IFormFactorPolyhedron {
public:
TruncatedCube(double length, double removed_length);
#ifndef USER_API
TruncatedCube(std::vector<double> P);
TruncatedCube* clone() const override
{
return new TruncatedCube(m_length, m_removed_length);
}
std::string className() const final
{
return "TruncatedCube";
}
std::vector<ParaMeta> parDefs() const final
{
return {{"Length", "nm"}, {"RemovedLength", "nm"}};
}
double length() const
{
return m_length;
}
double removedLength() const
{
return m_removed_length;
}
private:
const double& m_length;
const double& m_removed_length;
#endif // USER_API
};
#endif // BORNAGAIN_SAMPLE_HARDPARTICLE_POLYHEDRA_H
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Sample/HardParticle/Prism3.cpp
//! @brief Implements class Prism3.
//!
//! @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)
//
// ************************************************************************************************
#include "Sample/HardParticle/Prism3.h"
#include <ff/Make.h>
Prism3::Prism3(const std::vector<double> P)
: IFormFactorPrism(P)
, m_base_edge(m_P[0])
, m_height(m_P[1])
{
pimpl.reset(ff::make::Prism3(m_base_edge, m_height));
m_validated = true;
}
Prism3::Prism3(double base_edge, double height)
: Prism3(std::vector<double>{base_edge, height})
{
}
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Sample/HardParticle/Prism3.h
//! @brief Defines class Prism3.
//!
//! @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)
//
// ************************************************************************************************
#ifndef BORNAGAIN_SAMPLE_HARDPARTICLE_PRISM3_H
#define BORNAGAIN_SAMPLE_HARDPARTICLE_PRISM3_H
#include "Sample/HardParticle/IFormFactorPrism.h"
//! A prism based on an equilateral triangle.
//! @ingroup hardParticle
class Prism3 : public IFormFactorPrism {
public:
Prism3(double base_edge, double height);
#ifndef USER_API
Prism3(std::vector<double> P);
Prism3* clone() const override
{
return new Prism3(m_base_edge, m_height);
}
std::string className() const final
{
return "Prism3";
}
std::vector<ParaMeta> parDefs() const final
{
return {{"BaseEdge", "nm"}, {"Height", "nm"}};
}
double baseEdge() const
{
return m_base_edge;
}
double height() const override
{
return m_height;
}
private:
const double& m_base_edge;
const double& m_height;
#endif // USER_API
};
#endif // BORNAGAIN_SAMPLE_HARDPARTICLE_PRISM3_H
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Sample/HardParticle/Prism6.cpp
//! @brief Implements class Prism6.
//!
//! @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)
//
// ************************************************************************************************
#include "Sample/HardParticle/Prism6.h"
Prism6::Prism6(const std::vector<double> P)
: IFormFactorPrism(P)
, m_base_edge(m_P[0])
, m_height(m_P[1])
{
validateOrThrow();
}
Prism6::Prism6(double base_edge, double height)
: Prism6(std::vector<double>{base_edge, height})
{
}
std::string Prism6::validate() const
{
std::vector<std::string> errs;
requestGt0(errs, m_base_edge, "base_edge");
requestGt0(errs, m_height, "height");
if (!errs.empty())
return jointError(errs);
double a = m_base_edge;
double as = a * sqrt(3) / 2;
double ac = a / 2;
std::vector<R3> base_vertices{{a, 0., 0.}, {ac, as, 0.}, {-ac, as, 0.},
{-a, 0., 0.}, {-ac, -as, 0.}, {ac, -as, 0.}};
setPrism(false, base_vertices);
m_validated = true;
return "";
}
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