diff --git a/GUI/Model/Sample/CrosscorrelationItems.cpp b/GUI/Model/Sample/CrosscorrelationItems.cpp new file mode 100644 index 0000000000000000000000000000000000000000..798ecb218819a5423fec52880fc0f5b97acb9e46 --- /dev/null +++ b/GUI/Model/Sample/CrosscorrelationItems.cpp @@ -0,0 +1,49 @@ +// ************************************************************************************************ +// +// BornAgain: simulate and fit reflection and scattering +// +//! @file GUI/Model/Sample/CrosscorrelationItems.h +//! @brief Implements classes CrosscorrelationItem. +//! +//! @homepage http://www.bornagainproject.org +//! @license GNU General Public License v3 or higher (see COPYING) +//! @copyright Forschungszentrum Jülich GmbH 2024 +//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) +// +// ************************************************************************************************ + +#include "GUI/Model/Sample/CrosscorrelationItems.h" +#include "GUI/Model/Util/UtilXML.h" + +namespace { +namespace Tag { + +const QString CrosscorrelationDepth("CrosscorrelationDepth"); + +} // namespace Tag +} // namespace + +FixedDepthCrosscorrelationItem::FixedDepthCrosscorrelationItem(double cross_corr_depth) +{ + m_crosscorrelation_depth.init( + "Crosscorrelation depth (nm)", + "Vertical length for the correlation of roughness at different interfaces", + cross_corr_depth, "crossCorrDepth"); +} + +void FixedDepthCrosscorrelationItem::writeTo(QXmlStreamWriter* w) const +{ + m_crosscorrelation_depth.writeTo2(w, Tag::CrosscorrelationDepth); +} + +void FixedDepthCrosscorrelationItem::readFrom(QXmlStreamReader* r) +{ + while (r->readNextStartElement()) { + QString tag = r->name().toString(); + + if (tag == Tag::CrosscorrelationDepth) + m_crosscorrelation_depth.readFrom2(r, tag); + else + r->skipCurrentElement(); + } +} diff --git a/GUI/Model/Sample/CrosscorrelationItems.h b/GUI/Model/Sample/CrosscorrelationItems.h new file mode 100644 index 0000000000000000000000000000000000000000..04493becf750ead2ef86281ca1c47c7fbae2ee4f --- /dev/null +++ b/GUI/Model/Sample/CrosscorrelationItems.h @@ -0,0 +1,46 @@ +// ************************************************************************************************ +// +// BornAgain: simulate and fit reflection and scattering +// +//! @file GUI/Model/Sample/CrosscorrelationItems.h +//! @brief Defines classes CrosscorrelationItem. +//! +//! @homepage http://www.bornagainproject.org +//! @license GNU General Public License v3 or higher (see COPYING) +//! @copyright Forschungszentrum Jülich GmbH 2024 +//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) +// +// ************************************************************************************************ + +#ifndef BORNAGAIN_GUI_MODEL_SAMPLE_CROSSCORRELATIONITEMS_H +#define BORNAGAIN_GUI_MODEL_SAMPLE_CROSSCORRELATIONITEMS_H + +#include "GUI/Model/Descriptor/DoubleProperty.h" +#include <QXmlStreamReader> + +class CrosscorrelationItem { +public: + virtual ~CrosscorrelationItem() = default; + + virtual void writeTo(QXmlStreamWriter*) const {} + virtual void readFrom(QXmlStreamReader*) {} + virtual DoubleProperties crossCorrProperties() = 0; + +protected: + CrosscorrelationItem() = default; +}; + +class FixedDepthCrosscorrelationItem : public CrosscorrelationItem { +public: + FixedDepthCrosscorrelationItem(double cross_corr_depth); + + void writeTo(QXmlStreamWriter* w) const override; + void readFrom(QXmlStreamReader* r) override; + + DoubleProperties crossCorrProperties() override { return {&m_crosscorrelation_depth}; } + +private: + DoubleProperty m_crosscorrelation_depth; +}; + +#endif // BORNAGAIN_GUI_MODEL_SAMPLE_CROSSCORRELATIONITEMS_H diff --git a/Sample/Interface/CrosscorrelationModels.cpp b/Sample/Interface/CrosscorrelationModels.cpp index 0811c074ee62f27a8f2281aed371d565d9fb1eca..613cf1d5107f3a891e4f859f724311ec0c6ee378 100644 --- a/Sample/Interface/CrosscorrelationModels.cpp +++ b/Sample/Interface/CrosscorrelationModels.cpp @@ -17,20 +17,20 @@ #include <cmath> FixedDepthCrosscorrelation::FixedDepthCrosscorrelation(double cross_corr_depth) - : m_cross_corr_length(cross_corr_depth) + : m_crosscorrelation_depth(cross_corr_depth) { validateOrThrow(); } FixedDepthCrosscorrelation* FixedDepthCrosscorrelation::clone() const { - return new FixedDepthCrosscorrelation(m_cross_corr_length); + return new FixedDepthCrosscorrelation(m_crosscorrelation_depth); } std::string FixedDepthCrosscorrelation::validate() const { std::vector<std::string> errs; - requestGe0(errs, m_cross_corr_length, "crossCorrLength"); + requestGe0(errs, m_crosscorrelation_depth, "crossCorrLength"); if (!errs.empty()) return jointError(errs); m_validated = true; @@ -39,13 +39,13 @@ std::string FixedDepthCrosscorrelation::validate() const std::string FixedDepthCrosscorrelation::pythonArguments() const { - return Py::Fmt::printArguments({{m_cross_corr_length, parDefs()[0].unit}}); + return Py::Fmt::printArguments({{m_crosscorrelation_depth, parDefs()[0].unit}}); } double FixedDepthCrosscorrelation::replicationFactor(double thickness) const { - if (m_cross_corr_length == 0) + if (m_crosscorrelation_depth == 0) return 0; - return std::exp(-std::abs(thickness) / m_cross_corr_length); + return std::exp(-std::abs(thickness) / m_crosscorrelation_depth); } diff --git a/Sample/Interface/CrosscorrelationModels.h b/Sample/Interface/CrosscorrelationModels.h index 95115adf912c2f32607e3c9c2b803ade50e70325..61b9c2a58f1b4477279f29e72cb2c87b0b04271a 100644 --- a/Sample/Interface/CrosscorrelationModels.h +++ b/Sample/Interface/CrosscorrelationModels.h @@ -40,16 +40,16 @@ public: FixedDepthCrosscorrelation* clone() const override; std::string className() const override { return "FixedDepthCrosscorrelation"; } std::string validate() const override; - double crossCorrLength(const R3&) const override { return m_cross_corr_length; } + double crossCorrLength(const R3&) const override { return m_crosscorrelation_depth; } double replicationFactor(double thickness) const override; - std::vector<ParaMeta> parDefs() const final { return {{"CrossCorrLength", "nm"}}; } + std::vector<ParaMeta> parDefs() const final { return {{"CrossCorrDepth", "nm"}}; } #ifndef SWIG std::string pythonArguments() const override; #endif private: - double m_cross_corr_length = 0; + double m_crosscorrelation_depth = 0; }; #endif // BORNAGAIN_SAMPLE_INTERFACE_CROSSCORRELATIONMODELS_H