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

add CrosscorrelationModels

parent 9085b5cc
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 Sample/Interface/CrosscorrelationModels.cpp
//! @brief Implement CrossCorrModel classes.
//!
//! @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 "Sample/Interface/CrosscorrelationModels.h"
#include <cmath>
FixedDepthCrosscorrelation::FixedDepthCrosscorrelation(double cross_corr_depth)
: m_cross_corr_length(cross_corr_depth)
{
validateOrThrow();
}
FixedDepthCrosscorrelation* FixedDepthCrosscorrelation::clone() const
{
return new FixedDepthCrosscorrelation(m_cross_corr_length);
}
std::string FixedDepthCrosscorrelation::validate() const
{
std::vector<std::string> errs;
requestGe0(errs, m_cross_corr_length, "crossCorrLength");
if (!errs.empty())
return jointError(errs);
m_validated = true;
return "";
}
double FixedDepthCrosscorrelation::replicationFactor(double thickness) const
{
if (m_cross_corr_length == 0)
return 0;
return std::exp(-std::abs(thickness) / m_cross_corr_length);
}
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Sample/Interface/CrosscorrelationModels.h
//! @brief Define CrosscorrelationModel classes.
//!
//! @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_SAMPLE_INTERFACE_CROSSCORRELATIONMODELS_H
#define BORNAGAIN_SAMPLE_INTERFACE_CROSSCORRELATIONMODELS_H
#include "Base/Type/ICloneable.h"
#include "Param/Node/INode.h"
#include <heinz/Vectors3D.h>
//! Base class for cross-correlation function models.
class CrosscorrelationModel : public ICloneable, public INode {
public:
CrosscorrelationModel* clone() const override = 0;
virtual double crossCorrLength(const R3& k) const = 0;
virtual double replicationFactor(double thickness) const = 0;
};
//! The crosscorrelation factor depends on the distance between interfaces and does not depend
//! on the spatial frequency.
class FixedDepthCrosscorrelation : public CrosscorrelationModel {
public:
FixedDepthCrosscorrelation(double cross_corr_depth = 0);
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 replicationFactor(double thickness) const override;
private:
double m_cross_corr_length = 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