Skip to content
Snippets Groups Projects
Unverified Commit da30e758 authored by Wuttke, Joachim's avatar Wuttke, Joachim Committed by GitHub
Browse files

Merge pull request #1180 from jwuttke/jan15

reformat; rename -> IShape3D
parents 5c43a1d1 eb3250d0
No related branches found
No related tags found
No related merge requests found
Showing
with 64 additions and 68 deletions
...@@ -81,12 +81,12 @@ MainWindow::MainWindow() ...@@ -81,12 +81,12 @@ MainWindow::MainWindow()
fillerButton->setEnabled(false); fillerButton->setEnabled(false);
m_viewSelectionButtonsLayout->insertWidget(-1, fillerButton); m_viewSelectionButtonsLayout->insertWidget(-1, fillerButton);
# if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
connect(m_viewSelectionButtons, &QButtonGroup::idClicked, this, &MainWindow::setCurrentView); connect(m_viewSelectionButtons, &QButtonGroup::idClicked, this, &MainWindow::setCurrentView);
# else #else
connect(m_viewSelectionButtons, QOverload<int>::of(&QButtonGroup::buttonClicked), this, connect(m_viewSelectionButtons, QOverload<int>::of(&QButtonGroup::buttonClicked), this,
&MainWindow::setCurrentView); &MainWindow::setCurrentView);
# endif #endif
m_statusBar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); m_statusBar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
......
...@@ -62,23 +62,23 @@ double InterferenceFunction3DLattice::iff_without_dw(const kvector_t q) const ...@@ -62,23 +62,23 @@ double InterferenceFunction3DLattice::iff_without_dw(const kvector_t q) const
kvector_t center = q; kvector_t center = q;
double radius = 2.1 * m_rec_radius; double radius = 2.1 * m_rec_radius;
double inner_radius = 0.0; double inner_radius = 0.0;
// if (m_peak_shape->angularDisorder()) { // if (m_peak_shape->angularDisorder()) {
// center = kvector_t(0.0, 0.0, 0.0); // center = kvector_t(0.0, 0.0, 0.0);
// inner_radius = std::max(0.0, q.mag() - radius); // inner_radius = std::max(0.0, q.mag() - radius);
// radius += q.mag(); // radius += q.mag();
// } // }
const auto rec_vectors = m_lattice.reciprocalLatticeVectorsWithinRadius(center, radius); const auto rec_vectors = m_lattice.reciprocalLatticeVectorsWithinRadius(center, radius);
//std::cout << "IWD: q=" << q << ", r=" << radius << ", ir=" << inner_radius << // std::cout << "IWD: q=" << q << ", r=" << radius << ", ir=" << inner_radius <<
// ", disordered=" << m_peak_shape->angularDisorder() << " => nVec=" << rec_vectors.size() // ", disordered=" << m_peak_shape->angularDisorder() << " => nVec=" << rec_vectors.size()
// << std::endl; // << std::endl;
double result = 0.0; double result = 0.0;
for (const auto& q_rec : rec_vectors) for (const auto& q_rec : rec_vectors)
// if (!(q_rec.mag() < inner_radius)) { // if (!(q_rec.mag() < inner_radius)) {
// result += m_peak_shape->evaluate(q, q_rec); // result += m_peak_shape->evaluate(q, q_rec);
result += exp(-(q-q_rec).mag2()/2/pow(.06,2)); result += exp(-(q - q_rec).mag2() / 2 / pow(.06, 2));
// std::cout << " INCR: qr=" << q_rec << " => " << result << std::endl; // std::cout << " INCR: qr=" << q_rec << " => " << result << std::endl;
// } // }
return result; return result;
} }
......
...@@ -77,16 +77,11 @@ void FormFactorCantellatedCube::onChange() ...@@ -77,16 +77,11 @@ void FormFactorCantellatedCube::onChange()
double a = m_length / 2; double a = m_length / 2;
double c = a - m_removed_length; double c = a - m_removed_length;
setPolyhedron(topology, -a, {{-c, -c, +a}, // point 0 setPolyhedron(topology, -a, {{-c, -c, +a}, // point 0
{+c, -c, +a}, {+c, +c, +a}, {-c, +c, +a}, {+c, -c, +a}, {+c, +c, +a}, {-c, +c, +a}, {-a, -c, +c}, // point 4
{-a, -c, +c}, // point 4 {+c, -a, +c}, {+a, +c, +c}, {-c, +a, +c}, {-c, -a, +c}, // point 8
{+c, -a, +c}, {+a, +c, +c}, {-c, +a, +c}, {+a, -c, +c}, {+c, +a, +c}, {-a, +c, +c}, {-a, -c, -c}, // point 12
{-c, -a, +c}, // point 8 {+c, -a, -c}, {+a, +c, -c}, {-c, +a, -c}, {-c, -a, -c}, // point 16
{+a, -c, +c}, {+c, +a, +c}, {-a, +c, +c}, {+a, -c, -c}, {+c, +a, -c}, {-a, +c, -c}, {-c, -c, -a}, // point 20
{-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}}); {+c, -c, -a}, {+c, +c, -a}, {-c, +c, -a}});
} }
...@@ -91,5 +91,5 @@ void FormFactorCone::onChange() ...@@ -91,5 +91,5 @@ void FormFactorCone::onChange()
{ {
m_cot_alpha = Math::cot(m_alpha); m_cot_alpha = Math::cot(m_alpha);
double radius2 = m_radius - m_height * m_cot_alpha; double radius2 = m_radius - m_height * m_cot_alpha;
m_shape = std::make_unique<DoubleEllipse>(m_radius, m_radius, m_height, radius2, radius2); m_shape3D = std::make_unique<DoubleEllipse>(m_radius, m_radius, m_height, radius2, radius2);
} }
...@@ -59,5 +59,5 @@ IFormFactor* FormFactorCylinder::sliceFormFactor(ZLimits limits, const IRotation ...@@ -59,5 +59,5 @@ IFormFactor* FormFactorCylinder::sliceFormFactor(ZLimits limits, const IRotation
void FormFactorCylinder::onChange() void FormFactorCylinder::onChange()
{ {
m_shape = std::make_unique<DoubleEllipse>(m_radius, m_radius, m_height, m_radius, m_radius); m_shape3D = std::make_unique<DoubleEllipse>(m_radius, m_radius, m_height, m_radius, m_radius);
} }
...@@ -67,6 +67,6 @@ IFormFactor* FormFactorEllipsoidalCylinder::sliceFormFactor(ZLimits limits, cons ...@@ -67,6 +67,6 @@ IFormFactor* FormFactorEllipsoidalCylinder::sliceFormFactor(ZLimits limits, cons
void FormFactorEllipsoidalCylinder::onChange() void FormFactorEllipsoidalCylinder::onChange()
{ {
m_shape = m_shape3D =
std::make_unique<DoubleEllipse>(m_radius_x, m_radius_y, m_height, m_radius_x, m_radius_y); std::make_unique<DoubleEllipse>(m_radius_x, m_radius_y, m_height, m_radius_x, m_radius_y);
} }
...@@ -67,6 +67,6 @@ IFormFactor* FormFactorFullSpheroid::sliceFormFactor(ZLimits limits, const IRota ...@@ -67,6 +67,6 @@ IFormFactor* FormFactorFullSpheroid::sliceFormFactor(ZLimits limits, const IRota
void FormFactorFullSpheroid::onChange() void FormFactorFullSpheroid::onChange()
{ {
m_shape = m_shape3D =
std::make_unique<TruncatedEllipsoid>(m_radius, m_radius, m_height / 2.0, m_height, 0.0); std::make_unique<TruncatedEllipsoid>(m_radius, m_radius, m_height / 2.0, m_height, 0.0);
} }
...@@ -76,5 +76,6 @@ complex_t FormFactorHemiEllipsoid::evaluate_for_q(cvector_t q) const ...@@ -76,5 +76,6 @@ complex_t FormFactorHemiEllipsoid::evaluate_for_q(cvector_t q) const
void FormFactorHemiEllipsoid::onChange() void FormFactorHemiEllipsoid::onChange()
{ {
m_shape = std::make_unique<TruncatedEllipsoid>(m_radius_x, m_radius_x, m_height, m_height, 0.0); m_shape3D =
std::make_unique<TruncatedEllipsoid>(m_radius_x, m_radius_x, m_height, m_height, 0.0);
} }
...@@ -56,7 +56,7 @@ complex_t FormFactorHollowSphere::evaluate_for_q(cvector_t q) const ...@@ -56,7 +56,7 @@ complex_t FormFactorHollowSphere::evaluate_for_q(cvector_t q) const
void FormFactorHollowSphere::onChange() void FormFactorHollowSphere::onChange()
{ {
m_shape = std::make_unique<TruncatedEllipsoid>(m_mean, m_mean, m_mean, 2.0 * m_mean, 0.0); m_shape3D = std::make_unique<TruncatedEllipsoid>(m_mean, m_mean, m_mean, 2.0 * m_mean, 0.0);
} }
bool FormFactorHollowSphere::checkParameters() const bool FormFactorHollowSphere::checkParameters() const
......
...@@ -56,5 +56,5 @@ IFormFactor* FormFactorLongBoxGauss::sliceFormFactor(ZLimits limits, const IRota ...@@ -56,5 +56,5 @@ IFormFactor* FormFactorLongBoxGauss::sliceFormFactor(ZLimits limits, const IRota
void FormFactorLongBoxGauss::onChange() void FormFactorLongBoxGauss::onChange()
{ {
m_shape = std::make_unique<Box>(m_length, m_width, m_height); m_shape3D = std::make_unique<Box>(m_length, m_width, m_height);
} }
...@@ -56,5 +56,5 @@ IFormFactor* FormFactorLongBoxLorentz::sliceFormFactor(ZLimits limits, const IRo ...@@ -56,5 +56,5 @@ IFormFactor* FormFactorLongBoxLorentz::sliceFormFactor(ZLimits limits, const IRo
void FormFactorLongBoxLorentz::onChange() void FormFactorLongBoxLorentz::onChange()
{ {
m_shape = std::make_unique<Box>(m_length, m_width, m_height); m_shape3D = std::make_unique<Box>(m_length, m_width, m_height);
} }
...@@ -64,10 +64,8 @@ void FormFactorTruncatedCube::onChange() ...@@ -64,10 +64,8 @@ void FormFactorTruncatedCube::onChange()
double c = a - m_removed_length; double c = a - m_removed_length;
setPolyhedron(topology, -a, setPolyhedron(topology, -a,
{{-c, -a, -a}, {-a, -c, -a}, {-a, -a, -c}, {c, -a, -a}, {{-c, -a, -a}, {-a, -c, -a}, {-a, -a, -c}, {c, -a, -a}, {a, -c, -a}, {a, -a, -c},
{a, -c, -a}, {a, -a, -c}, {-c, a, -a}, {-a, c, -a}, {-c, a, -a}, {-a, c, -a}, {-a, a, -c}, {c, a, -a}, {a, c, -a}, {a, a, -c},
{-a, a, -c}, {c, a, -a}, {a, c, -a}, {a, a, -c}, {-c, -a, a}, {-a, -c, a}, {-a, -a, c}, {c, -a, a}, {a, -c, a}, {a, -a, c},
{-c, -a, a}, {-a, -c, a}, {-a, -a, c}, {c, -a, a}, {-c, a, a}, {-a, c, a}, {-a, a, c}, {c, a, a}, {a, c, a}, {a, a, c}});
{a, -c, a}, {a, -a, c}, {-c, a, a}, {-a, c, a},
{-a, a, c}, {c, a, a}, {a, c, a}, {a, a, c}});
} }
...@@ -90,5 +90,5 @@ IFormFactor* FormFactorTruncatedSphere::sliceFormFactor(ZLimits limits, const IR ...@@ -90,5 +90,5 @@ IFormFactor* FormFactorTruncatedSphere::sliceFormFactor(ZLimits limits, const IR
void FormFactorTruncatedSphere::onChange() void FormFactorTruncatedSphere::onChange()
{ {
m_shape = std::make_unique<TruncatedEllipsoid>(m_radius, m_radius, m_radius, m_height, m_dh); m_shape3D = std::make_unique<TruncatedEllipsoid>(m_radius, m_radius, m_radius, m_height, m_dh);
} }
...@@ -97,6 +97,6 @@ IFormFactor* FormFactorTruncatedSpheroid::sliceFormFactor(ZLimits limits, const ...@@ -97,6 +97,6 @@ IFormFactor* FormFactorTruncatedSpheroid::sliceFormFactor(ZLimits limits, const
void FormFactorTruncatedSpheroid::onChange() void FormFactorTruncatedSpheroid::onChange()
{ {
m_shape.reset( m_shape3D.reset(
new TruncatedEllipsoid(m_radius, m_radius, m_height_flattening * m_radius, m_height, m_dh)); new TruncatedEllipsoid(m_radius, m_radius, m_height_flattening * m_radius, m_height, m_dh));
} }
...@@ -26,9 +26,9 @@ class Polyhedron; ...@@ -26,9 +26,9 @@ class Polyhedron;
class IFormFactorPolyhedron : public IBornFF { class IFormFactorPolyhedron : public IBornFF {
public: public:
// #ifdef ALGORITHM_DIAGNOSTIC // #ifdef ALGORITHM_DIAGNOSTIC
// static void setLimits(double _q, int _n); // static void setLimits(double _q, int _n);
// #endif // #endif
IFormFactorPolyhedron() = delete; IFormFactorPolyhedron() = delete;
IFormFactorPolyhedron(const NodeMeta& meta, const std::vector<double>& PValues); IFormFactorPolyhedron(const NodeMeta& meta, const std::vector<double>& PValues);
......
...@@ -63,7 +63,7 @@ complex_t IProfileRectangularRipple::factor_yz(complex_t qy, complex_t qz) const ...@@ -63,7 +63,7 @@ complex_t IProfileRectangularRipple::factor_yz(complex_t qy, complex_t qz) const
void IProfileRectangularRipple::onChange() void IProfileRectangularRipple::onChange()
{ {
m_shape = std::make_unique<Box>(m_length, m_width, m_height); m_shape3D = std::make_unique<Box>(m_length, m_width, m_height);
} }
// ************************************************************************************************ // ************************************************************************************************
...@@ -84,7 +84,7 @@ complex_t ICosineRipple::factor_yz(complex_t qy, complex_t qz) const ...@@ -84,7 +84,7 @@ complex_t ICosineRipple::factor_yz(complex_t qy, complex_t qz) const
void ICosineRipple::onChange() void ICosineRipple::onChange()
{ {
m_shape = std::make_unique<RippleCosine>(m_length, m_width, m_height); m_shape3D = std::make_unique<RippleCosine>(m_length, m_width, m_height);
} }
// ************************************************************************************************ // ************************************************************************************************
...@@ -108,5 +108,5 @@ complex_t ISawtoothRipple::factor_yz(complex_t qy, complex_t qz) const ...@@ -108,5 +108,5 @@ complex_t ISawtoothRipple::factor_yz(complex_t qy, complex_t qz) const
void ISawtoothRipple::onChange() void ISawtoothRipple::onChange()
{ {
m_shape = std::make_unique<RippleSawtooth>(m_length, m_width, m_height, m_asymmetry); m_shape3D = std::make_unique<RippleSawtooth>(m_length, m_width, m_height, m_asymmetry);
} }
...@@ -24,10 +24,14 @@ constexpr auto ReciprocalFactorialArray = Math::generateReciprocalFactorialArray ...@@ -24,10 +24,14 @@ constexpr auto ReciprocalFactorialArray = Math::generateReciprocalFactorialArray
} // namespace } // namespace
#ifdef ALGORITHM_DIAGNOSTIC #ifdef ALGORITHM_DIAGNOSTIC
void PolyhedralDiagnosis::reset() { void PolyhedralDiagnosis::reset()
order = 0; algo = 0; msg.clear(); {
order = 0;
algo = 0;
msg.clear();
}; };
std::string PolyhedralDiagnosis::message() const { std::string PolyhedralDiagnosis::message() const
{
std::string ret = "algo=" + std::to_string(algo) + ", order=" + std::to_string(order); std::string ret = "algo=" + std::to_string(algo) + ", order=" + std::to_string(order);
if (!msg.empty()) if (!msg.empty())
ret += ", msg:\n" + msg; ret += ", msg:\n" + msg;
...@@ -35,15 +39,14 @@ std::string PolyhedralDiagnosis::message() const { ...@@ -35,15 +39,14 @@ std::string PolyhedralDiagnosis::message() const {
} }
bool PolyhedralDiagnosis::operator==(const PolyhedralDiagnosis& other) const bool PolyhedralDiagnosis::operator==(const PolyhedralDiagnosis& other) const
{ {
return order==other.order && algo==other.algo; return order == other.order && algo == other.algo;
} }
bool PolyhedralDiagnosis::operator!=(const PolyhedralDiagnosis& other) const bool PolyhedralDiagnosis::operator!=(const PolyhedralDiagnosis& other) const
{ {
return !(*this==other); return !(*this == other);
} }
#endif #endif
// ************************************************************************************************ // ************************************************************************************************
// PolyhedralEdge implementation // PolyhedralEdge implementation
// ************************************************************************************************ // ************************************************************************************************
......
...@@ -72,7 +72,7 @@ public: ...@@ -72,7 +72,7 @@ public:
complex_t ff_n(int m, cvector_t q) const; complex_t ff_n(int m, cvector_t q) const;
complex_t ff(cvector_t q, bool sym_Ci) const; complex_t ff(cvector_t q, bool sym_Ci) const;
complex_t ff_2D(cvector_t qpa) const; complex_t ff_2D(cvector_t qpa) const;
complex_t ff_2D_direct(cvector_t qpa) const; // for TestTriangle complex_t ff_2D_direct(cvector_t qpa) const; // for TestTriangle
complex_t ff_2D_expanded(cvector_t qpa) const; // for TestTriangle complex_t ff_2D_expanded(cvector_t qpa) const; // for TestTriangle
void assert_Ci(const PolyhedralFace& other) const; void assert_Ci(const PolyhedralFace& other) const;
......
...@@ -17,12 +17,12 @@ ...@@ -17,12 +17,12 @@
//! "Numerically stable form factor of any polygon and polyhedron" //! "Numerically stable form factor of any polygon and polyhedron"
#include "Sample/HardParticle/Polyhedron.h" #include "Sample/HardParticle/Polyhedron.h"
#include "Sample/HardParticle/PolyhedralTopology.h"
#include "Base/Math/Functions.h" #include "Base/Math/Functions.h"
#include "Sample/HardParticle/PolyhedralTopology.h"
#include <boost/format.hpp>
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include <stdexcept> // need overlooked by g++ 5.4 #include <stdexcept> // need overlooked by g++ 5.4
#include <boost/format.hpp>
namespace { namespace {
const double eps = 2e-16; const double eps = 2e-16;
...@@ -169,8 +169,8 @@ complex_t Polyhedron::evaluate_centered(const cvector_t& q) const ...@@ -169,8 +169,8 @@ complex_t Polyhedron::evaluate_centered(const cvector_t& q) const
term *= n_fac; term *= n_fac;
#ifdef ALGORITHM_DIAGNOSTIC_LEVEL2 #ifdef ALGORITHM_DIAGNOSTIC_LEVEL2
polyhedralDiagnosis.msg += polyhedralDiagnosis.msg +=
boost::str(boost::format(" + term(n=%2i) = %23.17e+i*%23.17e\n") boost::str(boost::format(" + term(n=%2i) = %23.17e+i*%23.17e\n") % n % term.real()
% n % term.real() % term.imag()); % term.imag());
#endif #endif
sum += term; sum += term;
if (std::abs(term) <= eps * std::abs(sum) || std::abs(sum) < eps * m_volume) if (std::abs(term) <= eps * std::abs(sum) || std::abs(sum) < eps * m_volume)
...@@ -193,14 +193,13 @@ complex_t Polyhedron::evaluate_centered(const cvector_t& q) const ...@@ -193,14 +193,13 @@ complex_t Polyhedron::evaluate_centered(const cvector_t& q) const
if (std::abs(qn) < eps * q.mag()) if (std::abs(qn) < eps * q.mag())
continue; continue;
complex_t term = qn * Gk.ff(q, m_sym_Ci); complex_t term = qn * Gk.ff(q, m_sym_Ci);
#ifdef ALGORITHM_DIAGNOSTIC//_LEVEL2 #ifdef ALGORITHM_DIAGNOSTIC //_LEVEL2
polyhedralDiagnosis.msg += polyhedralDiagnosis.msg += boost::str(boost::format(" + face_ff = %23.17e+i*%23.17e\n")
boost::str(boost::format(" + face_ff = %23.17e+i*%23.17e\n") % term.real() % term.imag());
% term.real() % term.imag());
#endif #endif
sum += term; sum += term;
} }
#ifdef ALGORITHM_DIAGNOSTIC//_LEVEL2 #ifdef ALGORITHM_DIAGNOSTIC //_LEVEL2
polyhedralDiagnosis.msg += polyhedralDiagnosis.msg +=
boost::str(boost::format(" -> raw sum = %23.17e+i*%23.17e; divisor = %23.17e\n") boost::str(boost::format(" -> raw sum = %23.17e+i*%23.17e; divisor = %23.17e\n")
% sum.real() % sum.imag() % q.mag2()); % sum.real() % sum.imag() % q.mag2());
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "Base/Utils/Algorithms.h" #include "Base/Utils/Algorithms.h"
#include "Sample/Material/WavevectorInfo.h" #include "Sample/Material/WavevectorInfo.h"
#include "Sample/Scattering/Rotations.h" #include "Sample/Scattering/Rotations.h"
#include "Sample/Shapes/IShape.h" #include "Sample/Shapes/IShape3D.h"
IBornFF::IBornFF() = default; IBornFF::IBornFF() = default;
...@@ -39,16 +39,16 @@ Eigen::Matrix2cd IBornFF::evaluatePol(const WavevectorInfo& wavevectors) const ...@@ -39,16 +39,16 @@ Eigen::Matrix2cd IBornFF::evaluatePol(const WavevectorInfo& wavevectors) const
double IBornFF::bottomZ(const IRotation& rotation) const double IBornFF::bottomZ(const IRotation& rotation) const
{ {
if (!m_shape) if (!m_shape3D)
return 0; return 0;
return BottomZ(m_shape->vertices(), rotation); return BottomZ(m_shape3D->vertices(), rotation);
} }
double IBornFF::topZ(const IRotation& rotation) const double IBornFF::topZ(const IRotation& rotation) const
{ {
if (!m_shape) if (!m_shape3D)
return 0; return 0;
return TopZ(m_shape->vertices(), rotation); return TopZ(m_shape3D->vertices(), rotation);
} }
bool IBornFF::canSliceAnalytically(const IRotation& rot) const bool IBornFF::canSliceAnalytically(const IRotation& rot) const
......
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