Skip to content
Snippets Groups Projects
Commit 324840c3 authored by Ganeva, Marina's avatar Ganeva, Marina
Browse files

Functional test and the reference data for layer with correlated roughness.

parent c5284e14
No related branches found
No related tags found
No related merge requests found
#include "LayerRoughnessBuilder.h"
#include "MultiLayer.h"
#include "ParticleDecoration.h"
#include "MaterialManager.h"
#include "Units.h"
#include "IRoughness.h"
LayerRoughnessBuilder::LayerRoughnessBuilder()
: m_thicknessA(2.5*Units::nanometer)
, m_thicknessB(5.0*Units::nanometer)
, m_sigma(1.0*Units::nanometer)
, m_hurst(0.3)
, m_latteralCorrLength(5.0*Units::nanometer)
, m_crossCorrLength(1e-4)
{
init_parameters();
}
void LayerRoughnessBuilder::init_parameters()
{
clearParameterPool();
registerParameter("thicknessA", &m_thicknessA);
registerParameter("thicknessB", &m_thicknessB);
registerParameter("sigma", &m_sigma);
registerParameter("hurst", &m_hurst);
registerParameter("latteralCorrLength", &m_latteralCorrLength);
registerParameter("crossCorrLength", &m_crossCorrLength);
}
ISample *LayerRoughnessBuilder::buildSample() const
{
MultiLayer *multi_layer = new MultiLayer();
const IMaterial *p_air_material =
MaterialManager::getHomogeneousMaterial("Air", 0., 0.);
const IMaterial *p_substrate_material =
MaterialManager::getHomogeneousMaterial("Substrate", 15e-6, 0.0);
const IMaterial *p_part_a_material =
MaterialManager::getHomogeneousMaterial("PartA", 5e-6, 0.0);
const IMaterial *p_part_b_material =
MaterialManager::getHomogeneousMaterial("PartB", 10e-6, 0.0);
Layer air_layer;
air_layer.setMaterial(p_air_material, 0);
Layer partA_layer;
partA_layer.setMaterial(p_part_a_material, m_thicknessA);
Layer partB_layer;
partB_layer.setMaterial(p_part_b_material, m_thicknessB);
Layer substrate_layer;
substrate_layer.setMaterial(p_substrate_material, 0);
LayerRoughness *roughness = new LayerRoughness();
roughness->setSigma(m_sigma);
roughness->setHurstParameter(m_hurst);
roughness->setLatteralCorrLength(m_latteralCorrLength);
multi_layer->addLayer(air_layer);
for (int i = 0; i<5; ++i) {
multi_layer->addLayerWithTopRoughness(partA_layer, *roughness);
multi_layer->addLayerWithTopRoughness(partB_layer, *roughness);
}
multi_layer->addLayerWithTopRoughness(substrate_layer, *roughness);
multi_layer->setCrossCorrLength(m_crossCorrLength);
return multi_layer;
}
#ifndef LAYERROUGHNESSBUILDER_H
#define LAYERROUGHNESSBUILDER_H
#include "ISampleBuilder.h"
//! The LayerRoughnessBuilder class to build sample:
//! Layers with correlated roughness
class LayerRoughnessBuilder : public ISampleBuilder
{
public:
LayerRoughnessBuilder();
ISample *buildSample() const;
protected:
void init_parameters();
private:
double m_thicknessA;
double m_thicknessB;
double m_sigma;
double m_hurst;
double m_latteralCorrLength;
double m_crossCorrLength;
};
#endif // ISGISAXS01BUILDER_H
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "IsGISAXS15Builder.h" #include "IsGISAXS15Builder.h"
#include "MesoCrystal01Builder.h" #include "MesoCrystal01Builder.h"
#include "PolarizedDWBAZeroMagBuilder.h" #include "PolarizedDWBAZeroMagBuilder.h"
#include "LayerRoughnessBuilder.h"
SampleBuilderFactory::SampleBuilderFactory() SampleBuilderFactory::SampleBuilderFactory()
{ {
...@@ -113,6 +114,10 @@ SampleBuilderFactory::SampleBuilderFactory() ...@@ -113,6 +114,10 @@ SampleBuilderFactory::SampleBuilderFactory()
"PolarizedDWBAZeroMag", "PolarizedDWBAZeroMag",
IFactoryCreateFunction<PolarizedDWBAZeroMagBuilder, ISampleBuilder>, IFactoryCreateFunction<PolarizedDWBAZeroMagBuilder, ISampleBuilder>,
"polarized DWBA with zero magnetic field"); "polarized DWBA with zero magnetic field");
registerItem(
"LayerWithRoughness",
IFactoryCreateFunction<LayerRoughnessBuilder, ISampleBuilder>,
"Layer with correlated roughness");
} }
......
...@@ -89,6 +89,10 @@ SimulationRegistry::SimulationRegistry() ...@@ -89,6 +89,10 @@ SimulationRegistry::SimulationRegistry()
"PolarizedDWBAZeroMag", StandardSimulations::PolarizedDWBAZeroMag, "PolarizedDWBAZeroMag", StandardSimulations::PolarizedDWBAZeroMag,
"polarized DWBA with zero magnetic field"); "polarized DWBA with zero magnetic field");
registerItem(
"LayerWithRoughness", StandardSimulations::LayerWithRoughness,
"layer with correlated roughness");
} }
......
...@@ -394,3 +394,21 @@ Simulation *StandardSimulations::PolarizedDWBAZeroMag() ...@@ -394,3 +394,21 @@ Simulation *StandardSimulations::PolarizedDWBAZeroMag()
return result; return result;
} }
Simulation *StandardSimulations::LayerWithRoughness()
{
SampleBuilderFactory factory;
ISampleBuilder *builder = factory.createBuilder("LayerWithRoughness");
Simulation *result = new Simulation();
result->setDetectorParameters(
100,-0.5*Units::degree, 0.5*Units::degree, 100,
0.0*Units::degree, 1.0*Units::degree, true);
result->setBeamParameters(
1.0*Units::angstrom, 0.2*Units::degree, 0.0*Units::degree);
result->setSampleBuilder( builder );
return result;
}
...@@ -29,8 +29,7 @@ Simulation *IsGISAXS11(); ...@@ -29,8 +29,7 @@ Simulation *IsGISAXS11();
Simulation *IsGISAXS15(); Simulation *IsGISAXS15();
Simulation *MesoCrystal01(); Simulation *MesoCrystal01();
Simulation *PolarizedDWBAZeroMag(); Simulation *PolarizedDWBAZeroMag();
Simulation *LayerWithRoughness();
} }
......
...@@ -27,6 +27,7 @@ set(list_of_tests ...@@ -27,6 +27,7 @@ set(list_of_tests
"FormFactors" "FormFactors"
"MesoCrystal1" "MesoCrystal1"
"PolarizedDWBAZeroMag" "PolarizedDWBAZeroMag"
"LayerRoughness"
) )
# for some reason these flags doesn't propagated here by SetUpWindows.cmake # for some reason these flags doesn't propagated here by SetUpWindows.cmake
......
#include "LayerWithRoughness.h"
#include "OutputDataIOFactory.h"
#include "SampleBuilderFactory.h"
#include "Simulation.h"
#include "Utils.h"
#include "Units.h"
#include "MathFunctions.h"
#include "SimulationRegistry.h"
#include "OutputDataFunctions.h"
#include <iostream>
#include <cmath>
FunctionalTests::LayerWithRoughness::LayerWithRoughness()
: m_name("LayerWithRoughness")
, m_description("Layers with correlated roughness")
, m_result(0)
, m_reference(0)
{ }
void FunctionalTests::LayerWithRoughness::run(const std::string &path_to_data)
{
SimulationRegistry sim_registry;
Simulation *simulation = sim_registry.createSimulation("LayerWithRoughness");
// loading reference data
std::string filename = path_to_data + "layer_with_roughness.ima";
m_reference = OutputDataIOFactory::readIntensityData(filename);
simulation->runSimulation();
m_result = simulation->getIntensityData();
//OutputDataIOFactory::writeIntensityData(*m_result,filename);
delete simulation;
}
int FunctionalTests::LayerWithRoughness::analyseResults()
{
const double threshold(2e-10);
// Calculating average relative difference.
double diff = OutputDataFunctions::GetDifference(*m_result,*m_reference);
// Assess result.
bool status_ok(true);
if( diff > threshold ) status_ok=false;
std::cout << " diff " << diff << std::endl;
std::cout << m_name << " " << m_description << " " <<
(status_ok ? "[OK]" : "[FAILED]") << std::endl;
return (status_ok ? 0 : 1);
}
#ifdef STANDALONE
std::string GetPathToData(int argc, char **argv)
{
if(argc == 2) return argv[1];
return Utils::FileSystem::GetPathToData("../../../ReferenceData/BornAgain/", argv[0]);
}
int main(int argc, char **argv)
{
FunctionalTests::LayerWithRoughness test;
test.run(GetPathToData(argc, argv));
return test.analyseResults();
}
#endif
#ifndef FUNCTIONALTESTS_LAYERWITHROUGHNESS_H
#define FUNCTIONALTESTS_LAYERWITHROUGHNESS_H
#include "ISampleBuilder.h"
#include <string>
#include "OutputData.h"
namespace FunctionalTests {
class LayerWithRoughness
{
public:
LayerWithRoughness();
~LayerWithRoughness() { delete m_result; delete m_reference; }
void run(const std::string &path_to_data = std::string());
int analyseResults();
// const OutputData<double> *getOutputData() { return m_result;}
private:
std::string m_name;
std::string m_description;
OutputData<double> *m_result;
OutputData<double> *m_reference;
};
}
#endif
This diff is collapsed.
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