Skip to content
Snippets Groups Projects
Commit eecf46b2 authored by Mikhail Svechnikov's avatar Mikhail Svechnikov
Browse files

add CrosscorrelationItem

parent 060d7ea5
No related branches found
No related tags found
1 merge request!2715Replace single crossCorrelationLength parameter by CrosscorrelationModel individual for each interface
// ************************************************************************************************
//
// 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();
}
}
// ************************************************************************************************
//
// 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
......@@ -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);
}
......@@ -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
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