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

export to script

parent b7d6fa55
No related branches found
No related tags found
1 merge request!2715Replace single crossCorrelationLength parameter by CrosscorrelationModel individual for each interface
......@@ -22,7 +22,7 @@ using std::numbers::pi;
//! @param sigma: rms of the roughness in nanometers
//! @param hurstParameter: hurst parameter which describes how jagged the interface,
//! dimensionless [0.0, 1.0], where 0.0 gives more spikes, 1.0 more smoothness
//! dimensionless (0.0, 1.0], where 0.0 gives more spikes, 1.0 more smoothness
//! @param lateralCorrLength: lateral correlation length of the roughness in nanometers
K_CorrelationModel::K_CorrelationModel(double sigma, double hurst, double lateralCorrLength)
: m_sigma(sigma)
......
......@@ -28,7 +28,7 @@ public:
virtual double corrFunction(const R3& k) const = 0;
#ifndef SWIG
//! Creates the Python constructor of this class
//! Used to create the Python constructor of this class
virtual std::string pythonArguments() const = 0;
#endif
};
......
......@@ -13,6 +13,7 @@
// ************************************************************************************************
#include "Sample/Interface/CrosscorrelationModels.h"
#include "Base/Py/PyFmt.h"
#include <cmath>
FixedDepthCrosscorrelation::FixedDepthCrosscorrelation(double cross_corr_depth)
......@@ -36,6 +37,11 @@ std::string FixedDepthCrosscorrelation::validate() const
return "";
}
std::string FixedDepthCrosscorrelation::pythonArguments() const
{
return Py::Fmt::printArguments({{m_cross_corr_length, parDefs()[0].unit}});
}
double FixedDepthCrosscorrelation::replicationFactor(double thickness) const
{
if (m_cross_corr_length == 0)
......
......@@ -25,6 +25,11 @@ public:
CrosscorrelationModel* clone() const override = 0;
virtual double crossCorrLength(const R3& k) const = 0;
virtual double replicationFactor(double thickness) const = 0;
#ifndef SWIG
//! Used to create the Python constructor of this class
virtual std::string pythonArguments() const = 0;
#endif
};
//! The crosscorrelation factor depends on the distance between interfaces and does not depend
......@@ -37,6 +42,11 @@ public:
std::string validate() const override;
double crossCorrLength(const R3&) const override { return m_cross_corr_length; }
double replicationFactor(double thickness) const override;
std::vector<ParaMeta> parDefs() const final { return {{"CrossCorrLength", "nm"}}; }
#ifndef SWIG
std::string pythonArguments() const override;
#endif
private:
double m_cross_corr_length = 0;
......
......@@ -42,7 +42,7 @@
using Py::Fmt::indent;
static const std::map<int, char> axisChar{{0, 'X'}, {1, 'Y'}, {2, 'Z'}};
#include <iostream>
namespace {
void setRotationInformation(const IParticle* particle, std::string name, std::ostringstream& result)
......@@ -149,12 +149,15 @@ std::string defineLayers(const ComponentKeyHandler& objHandler,
std::string defineRoughnesses(const ComponentKeyHandler& objHandler)
{
std::vector<const LayerRoughness*> roughness = objHandler.objectsOfType<LayerRoughness>();
std::vector<const AutocorrelationModel*> autocorr =
std::vector<const AutocorrelationModel*> autocorrelation =
objHandler.objectsOfType<AutocorrelationModel>();
std::vector<const InterlayerModel*> interlayer = objHandler.objectsOfType<InterlayerModel>();
std::vector<const CrosscorrelationModel*> crosscorrelation =
objHandler.objectsOfType<CrosscorrelationModel>();
ASSERT(roughness.size() == interlayer.size());
ASSERT(roughness.size() == autocorr.size());
ASSERT(roughness.size() == autocorrelation.size());
ASSERT(roughness.size() >= crosscorrelation.size());
if (roughness.empty())
return "";
......@@ -175,9 +178,9 @@ std::string defineRoughnesses(const ComponentKeyHandler& objHandler)
for (size_t i = 0; i < roughness.size(); i++) {
if (!roughness[i]->showInScriptOrGui())
continue;
const std::string& key = objHandler.obj2key(autocorr[i]);
result << indent() << key << " = ba." << autocorr[i]->className() << "("
<< autocorr[i]->pythonArguments() << ")\n";
const std::string& key = objHandler.obj2key(autocorrelation[i]);
result << indent() << key << " = ba." << autocorrelation[i]->className() << "("
<< autocorrelation[i]->pythonArguments() << ")\n";
}
result << "\n";
// define interlayers
......@@ -188,15 +191,29 @@ std::string defineRoughnesses(const ComponentKeyHandler& objHandler)
result << indent() << key << " = ba." << interlayer[i]->className() << "()\n";
}
result << "\n";
// define crosscorrelations
if (crosscorrelation.size() > 0) {
for (const auto r : roughness) {
if (!r->showInScriptOrGui())
continue;
if (const auto cc = r->crosscorrelationModel())
result << indent() << objHandler.obj2key(cc) << " = ba." << cc->className() << "("
<< cc->pythonArguments() << ")\n";
}
result << "\n";
}
// define roughnesses
for (size_t i = 0; i < roughness.size(); i++) {
if (!roughness[i]->showInScriptOrGui())
for (const auto r : roughness) {
if (!r->showInScriptOrGui())
continue;
const std::string& roughness_key = objHandler.obj2key(roughness[i]);
const std::string& autocorr_key = objHandler.obj2key(autocorr[i]);
const std::string& interlayer_key = objHandler.obj2key(interlayer[i]);
result << indent() << roughness_key << " = ba." << roughness[i]->className() << "("
<< autocorr_key << ", " << interlayer_key << ")\n";
const std::string& roughness_key = objHandler.obj2key(r);
const std::string& autocorr_key = objHandler.obj2key(r->autocorrelationModel());
const std::string& interlayer_key = objHandler.obj2key(r->interlayerModel());
result << indent() << roughness_key << " = ba." << r->className() << "(" << autocorr_key
<< ", " << interlayer_key;
if (const auto crosscorrelation = r->crosscorrelationModel())
result << ", " << objHandler.obj2key(crosscorrelation);
result << ")\n";
}
return result.str();
}
......@@ -213,7 +230,6 @@ std::string defineFormfactors(const ComponentKeyHandler& objHandler)
const std::string& key = objHandler.obj2key(s);
result << indent() << key << " = ba." << s->pythonConstructor() << "\n";
}
return result.str();
}
......@@ -556,6 +572,8 @@ std::string SampleToPython::sampleCode(const MultiLayer& sample)
objHandler.insertModel("layer", x);
for (const auto* x : NodeUtil::AllDescendantsOfType<LayerRoughness>(sample))
objHandler.insertModel("roughness", x);
for (const auto* x : NodeUtil::AllDescendantsOfType<CrosscorrelationModel>(sample))
objHandler.insertModel("crosscorrelation", x);
for (const auto* x : NodeUtil::AllDescendantsOfType<InterlayerModel>(sample))
objHandler.insertModel("interlayer", x);
for (const auto* x : NodeUtil::AllDescendantsOfType<AutocorrelationModel>(sample))
......
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