Skip to content
Snippets Groups Projects
Commit 385bf6f7 authored by Celine Durniak's avatar Celine Durniak
Browse files

IsGISAXS02 is ready

parent 9bdd0f59
No related branches found
No related tags found
No related merge requests found
Showing
with 1278 additions and 136 deletions
...@@ -2,6 +2,11 @@ TEMPLATE = subdirs ...@@ -2,6 +2,11 @@ TEMPLATE = subdirs
SUBDIRS += \ SUBDIRS += \
IsGISAXS01 IsGISAXS01 \
IsGISAXS02 \
IsGISAXS03 \
IsGISAXS07 \
IsGISAXS010 \
IsGISAXS011
CONFIG += ordered CONFIG += ordered
This diff is collapsed.
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "MultiLayer.h" #include "MultiLayer.h"
#include "ParticleDecoration.h" #include "ParticleDecoration.h"
#include "LayerDecorator.h" #include "LayerDecorator.h"
#include "InterferenceFunctionNone.h" #include "InterferenceFunctionNone.h"
#include "FormFactorCylinder.h" #include "FormFactorCylinder.h"
#include "FormFactorPrism3.h" #include "FormFactorPrism3.h"
......
#include "IsGISAXS010.h"
#include "MultiLayer.h"
#include "ParticleDecoration.h"
#include "LayerDecorator.h"
#include "InterferenceFunction1DParaCrystal.h"
#include "FormFactorCylinder.h"
#include "GISASExperiment.h"
#include "MaterialManager.h"
#include "OutputDataIOFactory.h"
#include "Units.h"
#include "Utils.h"
#include <iostream>
#include <cmath>
FunctionalTests::IsGISAXS010::IsGISAXS010()
: m_name("IsGISAXS010")
, m_description("Cylinders with interference on top of substrate")
, m_result(0)
{ }
void FunctionalTests::IsGISAXS010::run()
{
// ---------------------
// building sample
// ---------------------
MultiLayer multi_layer;
const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air10", 1.0, 0.0);
const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate10", 1.0-5e-6, 2e-8);
Layer air_layer;
air_layer.setMaterial(p_air_material);
Layer substrate_layer;
substrate_layer.setMaterial(p_substrate_material);
// IInterferenceFunction *p_interference_function = new InterferenceFunction1DParaCrystal(20.0*Units::nanometer,7*Units::nanometer, 1e7*Units::nanometer);
complex_t n_particle(1.0-5e-5, 2e-8);
ParticleDecoration particle_decoration(new Particle(n_particle, new FormFactorCylinder(5*Units::nanometer, 5*Units::nanometer)));
//particle_decoration.addInterferenceFunction(p_interference_function);
particle_decoration.addInterferenceFunction(new InterferenceFunction1DParaCrystal(20.0*Units::nanometer,7*Units::nanometer, 1e7*Units::nanometer));
LayerDecorator air_layer_decorator(air_layer, particle_decoration);
multi_layer.addLayer(air_layer_decorator);
multi_layer.addLayer(substrate_layer);
// ---------------------
// building experiment
// ---------------------
GISASExperiment experiment;
experiment.setDetectorParameters(100, 0.0*Units::degree, 2.0*Units::degree, 100, 0.0*Units::degree, 2.0*Units::degree, true);
experiment.setBeamParameters(1.0*Units::angstrom, -0.2*Units::degree, 0.0*Units::degree);
// ---------------------
// running experiment
// ---------------------
experiment.setSample(multi_layer);
experiment.runSimulation();
// ---------------------
// copying data
// ---------------------
m_result = experiment.getOutputDataClone();
}
int FunctionalTests::IsGISAXS010::analyseResults()
{
const double threshold(1e-10);
// retrieving reference data
std::string filename = Utils::FileSystem::GetHomePath() + "/Tests/FunctionalTests/TestCore/IsGISAXS010/isgisaxs010_reference.ima.gz";
OutputData<double > *reference = OutputDataIOFactory::getOutputData(filename);
// calculating average relative difference
*m_result -= *reference;
*m_result /= *reference;
double diff(0);
for(OutputData<double>::const_iterator it=m_result->begin(); it!=m_result->end(); ++it) {
diff+= std::fabs(*it);
}
diff /= m_result->getAllocatedSize();
bool status_ok(true);
if( diff > threshold ) status_ok=false;
std::cout << m_name << " " << m_description << " " << (status_ok ? "[OK]" : "[FAILED]") << std::endl;
return (int)status_ok;
}
#ifdef STANDALONE
int main()
{
FunctionalTests::IsGISAXS010 test;
test.run();
return test.analyseResults();
}
#endif
#ifndef FUNCTIONALTESTS_ISGISAXS010_H
#define FUNCTIONALTESTS_ISGISAXS010_H
#include <string>
#include "OutputData.h"
class MultiLayer;
class GISASExperiment;
namespace FunctionalTests {
class IsGISAXS010
{
public :
IsGISAXS010();
~IsGISAXS010() { delete m_result; }
void run();
int analyseResults();
const OutputData<double> *getOutputData() { return m_result; }
private:
std::string m_name;
std::string m_description;
OutputData<double> *m_result;
};
}
#endif
TEMPLATE = app
include($$PWD/../shared.pri)
SOURCES += IsGISAXS010.cpp
HEADERS += IsGISAXS010.h
#include "IsGISAXS011.h"
#include "MultiLayer.h"
#include "ParticleDecoration.h"
#include "ParticleBuilder.h"
#include "ParticleCoreShell.h"
#include "LayerDecorator.h"
#include "OutputDataIOFactory.h"
#include "GISASExperiment.h"
#include "InterferenceFunctionNone.h"
#include "FormFactorParallelepiped.h"
#include "MaterialManager.h"
#include "Units.h" //kvector_t
#include "Utils.h"
/*#include "Particle.h"
#include "FormFactors.h"
#include "Transform3D.h"
#include "LayerDecorator.h"
#include "Lattice.h"
#include "LatticeBasis.h"
#include "Crystal.h"
#include "MesoCrystal.h"
#include "FormFactorWeighted.h"
#include "Numeric.h"
#include "MathFunctions.h"
#include "StochasticSampledParameter.h"
#include "IsGISAXSMorphologyFileDecoration.h"*/
#include <iostream>
#include <cmath>
FunctionalTests::IsGISAXS011::IsGISAXS011()
: m_name("IsGISAXS011")
, m_description("Core shell nanoparticles")
, m_result(0)
{ }
void FunctionalTests::IsGISAXS011::run()
{
// ---------------------
// building sample
// ---------------------
MultiLayer multi_layer;
const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0, 0.0);
Layer air_layer;
air_layer.setMaterial(p_air_material);
complex_t n_particle_shell(1.0-1e-4, 2e-8);
complex_t n_particle_core(1.0-6e-5, 2e-8);
Particle shell_particle(n_particle_shell, new FormFactorParallelepiped(8*Units::nanometer, 8*Units::nanometer));
Particle core_particle(n_particle_core, new FormFactorParallelepiped(7*Units::nanometer, 6*Units::nanometer));
kvector_t core_position(0.0, 0.0, 0.0);
ParticleCoreShell particle(shell_particle, core_particle, core_position);
ParticleDecoration particle_decoration(particle.clone());
particle_decoration.addInterferenceFunction(new InterferenceFunctionNone());
LayerDecorator air_layer_decorator(air_layer, particle_decoration);
multi_layer.addLayer(air_layer_decorator);
// ---------------------
// building experiment
// ---------------------
GISASExperiment experiment;
experiment.setDetectorParameters(100, 0.0*Units::degree, 2.0*Units::degree, 100, 0.0*Units::degree, 2.0*Units::degree, true);
experiment.setBeamParameters(1.0*Units::angstrom, -0.2*Units::degree, 0.0*Units::degree);
// ---------------------
// running experiment
// ---------------------
experiment.setSample(multi_layer);
experiment.runSimulation();
// ---------------------
// copying data
// ---------------------
m_result = experiment.getOutputDataClone();
}
int FunctionalTests::IsGISAXS011::analyseResults()
{
const double threshold(1e-10);
// retrieving reference data
std::string filename = Utils::FileSystem::GetHomePath() + "/Tests/FunctionalTests/TestCore/IsGISAXS011/isgisaxs011_reference.ima.gz";
OutputData<double > *reference = OutputDataIOFactory::getOutputData(filename);
// calculating average relative difference
*m_result -= *reference;
*m_result /= *reference;
double diff(0);
for(OutputData<double>::const_iterator it=m_result->begin(); it!=m_result->end(); ++it) {
diff+= std::fabs(*it);
}
diff /= m_result->getAllocatedSize();
bool status_ok(true);
if( diff > threshold ) status_ok=false;
std::cout << m_name << " " << m_description << " " << (status_ok ? "[OK]" : "[FAILED]") << std::endl;
return (int)status_ok;
}
#ifdef STANDALONE
int main()
{
FunctionalTests::IsGISAXS011 test;
test.run();
return test.analyseResults();
}
#endif
#ifndef FUNCTIONALTESTS_ISGISAXS011_H
#define FUNCTIONALTESTS_ISGISAXS011_H
#include <string>
#include "OutputData.h"
class MultiLayer;
class GISASExperiment;
namespace FunctionalTests {
class IsGISAXS011
{
public :
IsGISAXS011();
~IsGISAXS011() { delete m_result; }
void run();
int analyseResults();
const OutputData<double> *getOutputData() { return m_result; }
private:
std::string m_name;
std::string m_description;
OutputData<double> *m_result;
};
}
#endif
TEMPLATE = app
include($$PWD/../shared.pri)
SOURCES += IsGISAXS011.cpp
HEADERS += IsGISAXS011.h
#include "IsGISAXS02.h"
#include "MultiLayer.h"
#include "ParticleDecoration.h"
#include "ParticleBuilder.h"
#include "FormFactorCylinder.h"
#include "LayerDecorator.h"
#include "OutputDataIOFactory.h"
#include "GISASExperiment.h"
#include "InterferenceFunctionNone.h"
#include "StochasticSampledParameter.h"
#include "StochasticGaussian.h"
#include "MaterialManager.h"
#include "Units.h"
#include "Utils.h"
#include <iostream>
#include <cmath>
FunctionalTests::IsGISAXS02::IsGISAXS02()
: m_name("IsGISAXS02")
, m_description("Mixture cylinder particles with different size distribution")
, m_result(0)
{ }
void FunctionalTests::IsGISAXS02::run()
{
// ---------------------
// building sample
// ---------------------
MultiLayer multi_layer;
const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0, 0.0);
Layer air_layer;
air_layer.setMaterial(p_air_material);
ParticleDecoration particle_decoration;
complex_t n_particle(1.0-6e-4, 2e-8);
// preparing nano particles prototypes for seeding layer's particle_decoration
double radius1 = 5*Units::nanometer;
double radius2 = 10*Units::nanometer;
double height1 = radius1;
double height2 = radius2;
FormFactorCylinder *p_ff_cylinder1 = new FormFactorCylinder(height1, radius1);
Particle cylinder1(n_particle, p_ff_cylinder1 );
FormFactorCylinder *p_ff_cylinder2 = new FormFactorCylinder(height2, radius2);
Particle cylinder2(n_particle, p_ff_cylinder2 );
// radius of nanoparticles will be sampled with gaussian probability
int nbins=150;
double sigma1 = radius1*0.2;
double sigma2 = radius2*0.02;
int nfwhm(3); // to have xmin=average-nfwhm*FWHM, xmax=average+nfwhm*FWHM (nfwhm = xR/2, where xR is what is defined in isgisaxs *.inp file)
StochasticSampledParameter par1(StochasticDoubleGaussian(radius1, sigma1), nbins, nfwhm);
StochasticSampledParameter par2(StochasticDoubleGaussian(radius2, sigma2), nbins, nfwhm);
// building nano particles
ParticleBuilder builder;
builder.setPrototype(cylinder1,"/Particle/FormFactorCylinder/radius", par1, 0.95);
builder.plantParticles(particle_decoration);
builder.setPrototype(cylinder2,"/Particle/FormFactorCylinder/radius", par2, 0.05);
builder.plantParticles(particle_decoration);
particle_decoration.addInterferenceFunction(new InterferenceFunctionNone());
// making layer holding all whose nano particles
LayerDecorator air_layer_decorator(air_layer, particle_decoration);
multi_layer.addLayer(air_layer_decorator);
// ---------------------
// building experiment
// ---------------------
GISASExperiment experiment;
experiment.setDetectorParameters(100, 0.0*Units::degree, 2.0*Units::degree, 100, 0.0*Units::degree, 2.0*Units::degree, true);
experiment.setBeamParameters(1.0*Units::angstrom, -0.2*Units::degree, 0.0*Units::degree);
// ---------------------
// running experiment
// ---------------------
experiment.setSample(multi_layer);
experiment.runSimulation();
// ---------------------
// copying data
// ---------------------
m_result = experiment.getOutputDataClone();
}
int FunctionalTests::IsGISAXS02::analyseResults()
{
const double threshold(1e-10);
// retrieving reference data
std::string filename = Utils::FileSystem::GetHomePath() + "/Tests/FunctionalTests/TestCore/IsGISAXS02/isgisaxs02_reference.ima.gz";
OutputData<double > *reference = OutputDataIOFactory::getOutputData(filename);
// calculating average relative difference
*m_result -= *reference;
*m_result /= *reference;
double diff(0);
for(OutputData<double>::const_iterator it=m_result->begin(); it!=m_result->end(); ++it) {
diff+= std::fabs(*it);
}
diff /= m_result->getAllocatedSize();
bool status_ok(true);
if( diff > threshold ) status_ok=false;
std::cout << m_name << " " << m_description << " " << (status_ok ? "[OK]" : "[FAILED]") << std::endl;
return (int)status_ok;
}
#ifdef STANDALONE
int main()
{
FunctionalTests::IsGISAXS02 test;
test.run();
return test.analyseResults();
}
#endif
#ifndef FUNCTIONALTESTS_ISGISAXS02_H
#define FUNCTIONALTESTS_ISGISAXS02_H
#include <string>
#include "OutputData.h"
class MultiLayer;
class GISASExperiment;
namespace FunctionalTests {
class IsGISAXS02
{
public :
IsGISAXS02();
~IsGISAXS02() { delete m_result; }
void run();
int analyseResults();
const OutputData<double> *getOutputData() { return m_result; }
private:
std::string m_name;
std::string m_description;
OutputData<double> *m_result;
};
}
#endif
TEMPLATE = app
include($$PWD/../shared.pri)
SOURCES += IsGISAXS02.cpp
HEADERS += IsGISAXS02.h
IsGISAXS02.cpp
IsGISAXS02.h
IsGISAXS02.o
IsGISAXS02.pro
Makefile
README
\ No newline at end of file
File added
#include "IsGISAXS03.h"
#include "MultiLayer.h"
//#include "ParticleDecoration.h"
//#include "LayerDecorator.h"
//#include "InterferenceFunctionNone.h"
//#include "FormFactorCylinder.h"
//#include "FormFactorPrism3.h"
//#include "Units.h"
//#include "MaterialManager.h"
//#include "OutputDataIOFactory.h"
#include "GISASExperiment.h"
#include "Utils.h"
#include <iostream>
#include <cmath>
FunctionalTests::IsGISAXS03::IsGISAXS03()
: m_name("IsGISAXS03")
, m_description("cylinder on top of substrate")
, m_result(0)
{ }
void FunctionalTests::IsGISAXS03::run()
{
// ---------------------
// building sample
// ---------------------
// ---------------------
// building experiment
// ---------------------
// ---------------------
// running experiment
// ---------------------
// ---------------------
// copying data
// ---------------------
m_result = experiment.getOutputDataClone();
}
int FunctionalTests::IsGISAXS03::analyseResults()
{
const double threshold(1e-10);
// retrieving reference data
// std::string filename = Utils::FileSystem::GetHomePath() + "/Tests/FunctionalTests/TestCore/IsGISAXS03/isgisaxs03_reference.ima.gz";
OutputData<double > *reference = OutputDataIOFactory::getOutputData(filename);
// calculating average relative difference
*m_result -= *reference;
*m_result /= *reference;
double diff(0);
for(OutputData<double>::const_iterator it=m_result->begin(); it!=m_result->end(); ++it) {
diff+= std::fabs(*it);
}
diff /= m_result->getAllocatedSize();
bool status_ok(true);
if( diff > threshold ) status_ok=false;
std::cout << m_name << " " << m_description << " " << (status_ok ? "[OK]" : "[FAILED]") << std::endl;
return (int)status_ok;
}
//Rest done
#ifdef STANDALONE
int main()
{
FunctionalTests::IsGISAXS03 test;
test.run();
return test.analyseResults();
}
#endif
////////////////////////////
// IsGISAXS01.cpp
#include "MultiLayer.h"
#include "ParticleDecoration.h"
#include "LayerDecorator.h"
#include "InterferenceFunctionNone.h"
#include "FormFactorCylinder.h"
#include "FormFactorPrism3.h"
#include "GISASExperiment.h"
#include "Units.h"
#include "MaterialManager.h"
#include "OutputDataIOFactory.h"
#include "Utils.h"
void FunctionalTests::IsGISAXS01::run()
{
// ---------------------
// building sample
// ---------------------
MultiLayer multi_layer;
const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0, 0.0);
const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
Layer air_layer;
air_layer.setMaterial(p_air_material);
Layer substrate_layer;
substrate_layer.setMaterial(p_substrate_material);
ParticleDecoration particle_decoration;
complex_t n_particle(1.0-6e-4, 2e-8);
particle_decoration.addParticle(new Particle(n_particle, new FormFactorCylinder(5*Units::nanometer, 5*Units::nanometer)), 0.0, 0.5);
particle_decoration.addParticle(new Particle(n_particle, new FormFactorPrism3(5*Units::nanometer, 5*Units::nanometer)), 0.0, 0.5);
particle_decoration.addInterferenceFunction(new InterferenceFunctionNone());
LayerDecorator air_layer_decorator(air_layer, particle_decoration);
multi_layer.addLayer(air_layer_decorator);
multi_layer.addLayer(substrate_layer);
// ---------------------
// building experiment
// ---------------------
GISASExperiment experiment;
experiment.setDetectorParameters(100,-1.0*Units::degree, 1.0*Units::degree, 100, 0.0*Units::degree, 2.0*Units::degree, true);
experiment.setBeamParameters(1.0*Units::angstrom, -0.2*Units::degree, 0.0*Units::degree);
// ---------------------
// running experiment
// ---------------------
experiment.setSample(multi_layer);
experiment.runSimulation();
// ---------------------
// copying data
// ---------------------
m_result = experiment.getOutputDataClone();
}
int FunctionalTests::IsGISAXS01::analyseResults()
{
const double threshold(1e-10);
// retrieving reference data
std::string filename = Utils::FileSystem::GetHomePath() + "/Tests/FunctionalTests/TestCore/IsGISAXS01/isgisaxs01_reference.ima.gz";
OutputData<double > *reference = OutputDataIOFactory::getOutputData(filename);
// calculating average relative difference
*m_result -= *reference;
*m_result /= *reference;
double diff(0);
for(OutputData<double>::const_iterator it=m_result->begin(); it!=m_result->end(); ++it) {
diff+= std::fabs(*it);
}
diff /= m_result->getAllocatedSize();
bool status_ok(true);
if( diff > threshold ) status_ok=false;
std::cout << m_name << " " << m_description << " " << (status_ok ? "[OK]" : "[FAILED]") << std::endl;
return (int)status_ok;
}
#ifdef STANDALONE
int main()
{
FunctionalTests::IsGISAXS01 test;
test.run();
return test.analyseResults();
}
#endif
//////////////////////////////////////////////////////////
//StandardSamples.cpp
/* ************************************************************************* */
// IsGISAXS3 functional test: cylinder on top of substrate
/* ************************************************************************* */
ISample *StandardSamples::IsGISAXS3_CylinderDWBA()
{
MultiLayer *p_multi_layer = new MultiLayer();
complex_t n_air(1.0, 0.0);
complex_t n_substrate(1.0-6e-6, 2e-8);
complex_t n_particle(1.0-6e-4, 2e-8);
const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
Layer air_layer;
air_layer.setMaterial(p_air_material);
Layer substrate_layer;
substrate_layer.setMaterial(p_substrate_material);
ParticleDecoration particle_decoration( new Particle(n_particle, new FormFactorCylinder(5*Units::nanometer, 5*Units::nanometer)));
particle_decoration.addInterferenceFunction(new InterferenceFunctionNone());
LayerDecorator air_layer_decorator(air_layer, particle_decoration);
p_multi_layer->addLayer(air_layer_decorator);
p_multi_layer->addLayer(substrate_layer);
return p_multi_layer;
}
// IsGISAXS3 functional test: cylinder in the air
ISample *StandardSamples::IsGISAXS3_CylinderBA()
{
MultiLayer *p_multi_layer = new MultiLayer();
complex_t n_air(1.0, 0.0);
complex_t n_particle(1.0-6e-4, 2e-8);
const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
Layer air_layer;
air_layer.setMaterial(p_air_material);
ParticleDecoration particle_decoration( new Particle(n_particle, new FormFactorCylinder(5*Units::nanometer, 5*Units::nanometer)));
particle_decoration.addInterferenceFunction(new InterferenceFunctionNone());
LayerDecorator air_layer_decorator(air_layer, particle_decoration);
p_multi_layer->addLayer(air_layer_decorator);
return p_multi_layer;
}
// IsGISAXS3 functional test: cylinder in the air with size distribution
ISample *StandardSamples::IsGISAXS3_CylinderBASize()
{
MultiLayer *p_multi_layer = new MultiLayer();
complex_t n_air(1.0, 0.0);
complex_t n_particle(1.0-6e-4, 2e-8);
const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
Layer air_layer;
air_layer.setMaterial(p_air_material);
ParticleDecoration particle_decoration;
// preparing prototype of nano particle
double radius = 5*Units::nanometer;
double sigma = 0.2*radius;
FormFactorCylinder *p_ff_cylinder = new FormFactorCylinder( 5*Units::nanometer, radius);
Particle nano_particle(n_particle, p_ff_cylinder);
// radius of nanoparticles will be sampled with gaussian probability
int nbins(100), nfwhm(2);
StochasticSampledParameter par(StochasticDoubleGaussian(radius, sigma), nbins, nfwhm);
ParticleBuilder builder;
builder.setPrototype(nano_particle,"/Particle/FormFactorCylinder/radius", par);
builder.plantParticles(particle_decoration);
particle_decoration.addInterferenceFunction(new InterferenceFunctionNone());
LayerDecorator air_layer_decorator(air_layer, particle_decoration);
p_multi_layer->addLayer(air_layer_decorator);
return p_multi_layer;
}
///////////////////////////
//TestIsGISAXS03.cpp
#include "IsGISAXSTools.h"
#include "Units.h"
#include "Utils.h"
#include "MultiLayer.h"
#include "GISASExperiment.h"
#include "FormFactors.h"
#include "SampleFactory.h"
#include "DrawHelper.h"
#include "OutputDataIOFactory.h"
#include <sstream>
TestIsGISAXS3::TestIsGISAXS3() : IFunctionalTest("TestIsGISAXS3")
{
m_data_path = std::string(Utils::FileSystem::GetHomePath()+"./Examples/IsGISAXS_examples/ex-3/");
}
void TestIsGISAXS3::execute()
{
GISASExperiment experiment(mp_options);
experiment.setDetectorParameters(100, 0.0*Units::degree, 2.0*Units::degree,
100, 0.0*Units::degree, 2.0*Units::degree, true);
experiment.setBeamParameters(1.0*Units::angstrom, -0.2*Units::degree, 0.0*Units::degree);
// cylinder in BA
MultiLayer *sample = dynamic_cast<MultiLayer *>(
SampleFactory::instance().createItem("IsGISAXS3_CylinderBA"));
experiment.setSample(*sample);
experiment.runSimulation();
OutputDataIOFactory::writeOutputData(*experiment.getOutputData(),m_data_path+"this_cylinder_BA.ima");
// cylinder in BA with size distribution
sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("IsGISAXS3_CylinderBASize"));
experiment.setSample(*sample);
experiment.runSimulation();
OutputDataIOFactory::writeOutputData(*experiment.getOutputData(),m_data_path+"this_cylinder_BA_size.ima");
// cylinder in DWBA
sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("IsGISAXS3_CylinderDWBA"));
experiment.setSample(*sample);
experiment.runSimulation();
OutputDataIOFactory::writeOutputData(*experiment.getOutputData(),m_data_path+"this_cylinder_DWBA.ima");
}
void TestIsGISAXS3::finalise()
{
std::vector< CompareStruct > tocompare;
tocompare.push_back( CompareStruct("isgi_cylinder_BA.ima.gz", "this_cylinder_BA.ima",
"Cylinder BA Formfactor") );
tocompare.push_back( CompareStruct("isgi_cylinder_BA_size.ima.gz", "this_cylinder_BA_size.ima",
"Cylinder BA Formfactor with size distribution") );
tocompare.push_back( CompareStruct("isgi_cylinder_DWBA.ima.gz", "this_cylinder_DWBA.ima",
"Cylinder DWBA Formfactor") );
for(size_t i=0; i<tocompare.size(); ++i) {
OutputData<double> *isgi_data = OutputDataIOFactory::getOutputData(m_data_path+tocompare[i].isginame);
OutputData<double> *our_data = OutputDataIOFactory::getOutputData(m_data_path+tocompare[i].thisname);
std::ostringstream os;
os<<i;
std::string cname = getName()+"_c"+os.str();
TCanvas *c1 = DrawHelper::instance().createAndRegisterCanvas(cname.c_str(), tocompare[i].descr);
c1->Divide(2,2);
IsGISAXSTools::setMinimum(1.);
// our calculations
c1->cd(1); gPad->SetLogz();
IsGISAXSTools::drawOutputDataInPad(*our_data, "CONT4 Z", "Our cylinder FF");
// isgisaxs data
c1->cd(2); gPad->SetLogz();
IsGISAXSTools::drawOutputDataInPad(*isgi_data, "CONT4 Z", "IsGisaxs mean FF");
// difference
c1->cd(3);
IsGISAXSTools::setMinimum(-0.0001);
IsGISAXSTools::setMaximum(0.0001);
IsGISAXSTools::drawOutputDataRelativeDifference2D(*our_data, *isgi_data, "CONT4 Z", "2D Difference map");
// difference
c1->cd(4);
IsGISAXSTools::resetMinimumAndMaximum();
IsGISAXSTools::drawOutputDataDifference1D(*our_data, *isgi_data, "", "Difference spectra");
IsGISAXSTools::resetMinimum(); IsGISAXSTools::resetMaximum();
delete isgi_data;
delete our_data;
}
}
#ifndef FUNCTIONALTESTS_ISGISAXS03_H
#define FUNCTIONALTESTS_ISGISAXS03_H
#include <string>
#include "OutputData.h"
class MultiLayer;
class GISASExperiment;
namespace FunctionalTests {
class IsGISAXS03
{
public:
IsGISAXS03();
~IsGISAXS03() { delete m_result; }
void run();
int analyseResults();
const OutputData<double> *getOutputData() { return m_result;}
private:
std::string m_name;
std::string m_description;
OutputData<double> *m_result;
};
}
#endif
TEMPLATE = app
include($$PWD/../shared.pri)
SOURCES += IsGISAXS03.cpp
HEADERS += IsGISAXS03.h
#include "IsGISAXS07.h"
#include "MultiLayer.h"
#include "MaterialManager.h"
#include "IsGISAXSMorphologyFileDecoration.h"
#include "FormFactorBox.h"
#include "ParticleDecoration.h"
#include "LayerDecorator.h"
#include "GISASExperiment.h"
#include "OutputDataIOFactory.h"
#include "Utils.h"
#include "Units.h"
#include <iostream>
#include <cmath>
FunctionalTests::IsGISAXS07::IsGISAXS07()
: m_name("IsGISAXS07")
, m_description("Mixture of different particles defined in morphology file")
, m_result(0)
{ }
void FunctionalTests::IsGISAXS07::run()
{
// ---------------------
// building sample
// ---------------------
MultiLayer multi_layer;
const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0, 0.0);
Layer air_layer;
air_layer.setMaterial(p_air_material);
complex_t n_particle(1.0-6e-4, 2e-8);
IsGISAXSMorphologyFileDecoration particle_decoration;
// add particle number 1:
FormFactorBox ff1(1.0*Units::nanometer, 1.0*Units::nanometer,1.0*Units::nanometer);
kvector_t pos1(0.0*Units::nanometer, 0.0*Units::nanometer, 0.0);
particle_decoration.addParticle(new Particle(n_particle, ff1), 0, pos1, 0.5);
// add particle number 2:
FormFactorBox ff2(1.0*Units::nanometer, 2.0*Units::nanometer,1.0*Units::nanometer);
kvector_t pos2(5.0*Units::nanometer, 5.0*Units::nanometer, 0.0);
Geometry::RotateZ3D rot2(10*Units::degree);
Particle particle2(n_particle, ff2);
particle_decoration.addParticle(particle2, rot2, pos2, 0.5);
// add particle number 3:
FormFactorBox ff3(1.0*Units::nanometer, 3.0*Units::nanometer,1.0*Units::nanometer);
kvector_t pos3(-5.0*Units::nanometer, -5.0*Units::nanometer, 0.0);
Geometry::RotateZ3D rot3(20*Units::degree);
Particle particle3(n_particle, ff3);
particle_decoration.addParticle(particle3, rot3, pos3, 0.5);
// add particle number 4:
FormFactorBox ff4(1.0*Units::nanometer, 4.0*Units::nanometer,1.0*Units::nanometer);
kvector_t pos4(5.0*Units::nanometer, -5.0*Units::nanometer, 0.0);
Geometry::RotateZ3D rot4(30*Units::degree);
Particle particle4(n_particle, ff4);
particle_decoration.addParticle(particle4, rot4, pos4, 0.5);
// add particle number 5:
FormFactorBox ff5(1.0*Units::nanometer, 5.0*Units::nanometer,1.0*Units::nanometer);
kvector_t pos5(-5.0*Units::nanometer, 5.0*Units::nanometer, 0.0);
Geometry::RotateZ3D rot5(40*Units::degree);
Particle particle5(n_particle, ff5);
particle_decoration.addParticle(particle5, rot5, pos5, 0.5);
// add particle number 6:
FormFactorBox ff6(1.0*Units::nanometer, 1.0*Units::nanometer,1.0*Units::nanometer);
kvector_t pos6(0.0*Units::nanometer, 0.0*Units::nanometer, 0.0);
Geometry::RotateZ3D rot6(50*Units::degree);
Particle particle6(n_particle, ff6);
particle_decoration.addParticle(particle6, rot6, pos6, 0.5);
// add particle number 7:
FormFactorBox ff7(1.0*Units::nanometer, 2.0*Units::nanometer,1.0*Units::nanometer);
kvector_t pos7(5.0*Units::nanometer, 5.0*Units::nanometer, 0.0);
Geometry::RotateZ3D rot7(60*Units::degree);
Particle particle7(n_particle, ff7);
particle_decoration.addParticle(particle7, rot7, pos7, 0.5);
// add particle number 8:
FormFactorBox ff8(1.0*Units::nanometer, 3.0*Units::nanometer,1.0*Units::nanometer);
kvector_t pos8(-5.0*Units::nanometer, -5.0*Units::nanometer, 0.0);
Geometry::RotateZ3D rot8(70*Units::degree);
Particle particle8(n_particle, ff8);
particle_decoration.addParticle(particle8, rot8, pos8, 0.5);
// add particle number 9:
FormFactorBox ff9(1.0*Units::nanometer, 4.0*Units::nanometer,1.0*Units::nanometer);
kvector_t pos9(5.0*Units::nanometer, -5.0*Units::nanometer, 0.0);
Geometry::RotateZ3D rot9(80*Units::degree);
Particle particle9(n_particle, ff9);
particle_decoration.addParticle(particle9, rot9, pos9, 0.5);
// add particle number 10:
FormFactorBox ff10(1.0*Units::nanometer, 5.0*Units::nanometer,1.0*Units::nanometer);
kvector_t pos10(-5.0*Units::nanometer, 5.0*Units::nanometer, 0.0);
Geometry::RotateZ3D rot10(90*Units::degree);
Particle particle10(n_particle, ff10);
particle_decoration.addParticle(particle10, rot10, pos10, 0.5);
LayerDecorator air_layer_decorator(air_layer, particle_decoration);
multi_layer.addLayer(air_layer_decorator);
// ---------------------
// building experiment
// ---------------------
GISASExperiment experiment;
experiment.setDetectorParameters(100, 0.0*Units::degree, 1.0*Units::degree,
100, 0.0*Units::degree, 1.0*Units::degree, true);
experiment.setBeamParameters(1.0*Units::angstrom, 0.0*Units::degree, 0.0*Units::degree);
// ---------------------
// running experiment
// ---------------------
experiment.setSample(multi_layer);
experiment.runSimulation();
// ---------------------
// copying data
// ---------------------
m_result = experiment.getOutputDataClone();
}
int FunctionalTests::IsGISAXS07::analyseResults()
{
const double threshold(1e-10);
// retrieving reference data
std::string filename = Utils::FileSystem::GetHomePath() + "/Tests/FunctionalTests/TestCore/IsGISAXS07/isgisaxs07_reference.ima.gz";
OutputData<double > *reference = OutputDataIOFactory::getOutputData(filename);
// calculating average relative difference
*m_result -= *reference;
*m_result /= *reference;
double diff(0);
for(OutputData<double>::const_iterator it=m_result->begin(); it!=m_result->end(); ++it) {
diff+= std::fabs(*it);
}
diff /= m_result->getAllocatedSize();
bool status_ok(true);
if( diff > threshold ) status_ok=false;
std::cout << m_name << " " << m_description << " " << (status_ok ? "[OK]" : "[FAILED]") << std::endl;
return (int)status_ok;
}
#ifdef STANDALONE
int main()
{
FunctionalTests::IsGISAXS07 test;
test.run();
return test.analyseResults();
}
#endif
#ifndef FUNCTIONALTESTS_ISGISAXS07_H
#define FUNCTIONALTESTS_ISGISAXS07_H
#include <string>
#include "OutputData.h"
class MultiLayer;
class GISASExperiment;
namespace FunctionalTests {
class IsGISAXS07
{
public:
IsGISAXS07();
~IsGISAXS07() { delete m_result; }
void run();
int analyseResults();
const OutputData<double> *getOutputData() { return m_result;}
private:
std::string m_name;
std::string m_description;
OutputData<double> *m_result;
};
}
#endif
TEMPLATE = app
include($$PWD/../shared.pri)
SOURCES += IsGISAXS07.cpp
HEADERS += IsGISAXS07.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