From 76aea6d3c74662e553f1e55c89cfd6acf9390855 Mon Sep 17 00:00:00 2001 From: Walter Van Herck <w.van.herck@fz-juelich.de> Date: Thu, 25 Oct 2012 17:02:33 +0200 Subject: [PATCH] Added source and header file for IsGISAXS8 test --- App/inc/TestIsGISAXS8.h | 44 ++++++++++++++++++++ App/src/TestIsGISAXS4.cpp | 2 +- App/src/TestIsGISAXS8.cpp | 85 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 App/inc/TestIsGISAXS8.h create mode 100644 App/src/TestIsGISAXS8.cpp diff --git a/App/inc/TestIsGISAXS8.h b/App/inc/TestIsGISAXS8.h new file mode 100644 index 00000000000..a3bb4da3d41 --- /dev/null +++ b/App/inc/TestIsGISAXS8.h @@ -0,0 +1,44 @@ +#ifndef TESTISGISAXS8_H_ +#define TESTISGISAXS8_H_ +// ******************************************************************** +// * The BornAgain project * +// * Simulation of neutron and x-ray scattering at grazing incidence * +// * * +// * LICENSE AND DISCLAIMER * +// * Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris * +// * eget quam orci. Quisque porta varius dui, quis posuere nibh * +// * mollis quis. Mauris commodo rhoncus porttitor. * +// ******************************************************************** +//! @file TestIsGISAXS8.h +//! @brief Definition of TestIsGISAXS8 class for IsGISAXS validation +//! @author Scientific Computing Group at FRM II +//! @date Oct 25, 2012 + +#include "IFunctionalTest.h" + +//- ------------------------------------------------------------------- +//! @class TestIsGISAXS8 +//! @brief Comparison with IsGISAXS ex-8: cylinder with interference 2DDL_lattice +//- ------------------------------------------------------------------- +class TestIsGISAXS8 : public IFunctionalTest +{ +public: + TestIsGISAXS8(); + virtual ~TestIsGISAXS8(){} + + virtual void execute(); + virtual void finalise(); +private: + // structure to hold info over several compare cases + struct CompareStruct + { + CompareStruct(std::string _isginame, std::string _thisname, std::string _descr) : isginame(_isginame), thisname(_thisname), descr(_descr){} + std::string isginame; + std::string thisname; + std::string descr; + }; + + std::string m_data_path; +}; + +#endif /* TESTISGISAXS8_H_ */ diff --git a/App/src/TestIsGISAXS4.cpp b/App/src/TestIsGISAXS4.cpp index c80fc030b28..81dd6c84fbc 100644 --- a/App/src/TestIsGISAXS4.cpp +++ b/App/src/TestIsGISAXS4.cpp @@ -25,7 +25,7 @@ void TestIsGISAXS4::execute() MultiLayer *p_sample(0); -// // 1DDL + // 1DDL p_sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("IsGISAXS4_1DDL")); experiment.setSample(*p_sample); experiment.runSimulation(); diff --git a/App/src/TestIsGISAXS8.cpp b/App/src/TestIsGISAXS8.cpp new file mode 100644 index 00000000000..648f5865c4f --- /dev/null +++ b/App/src/TestIsGISAXS8.cpp @@ -0,0 +1,85 @@ +#include "TestIsGISAXS8.h" +#include "IsGISAXSTools.h" +#include "Units.h" +#include "Utils.h" +#include "MultiLayer.h" +#include "GISASExperiment.h" +#include "SampleFactory.h" +#include "DrawHelper.h" + +#include "TCanvas.h" +#include <gsl/gsl_errno.h> + +TestIsGISAXS8::TestIsGISAXS8() : IFunctionalTest("TestIsGISAXS8") +{ + m_data_path = std::string(Utils::FileSystem::GetHomePath()+"./Examples/IsGISAXS_examples/ex-8/"); +} + +void TestIsGISAXS8::execute() +{ + gsl_set_error_handler_off(); + + 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); + + MultiLayer *p_sample(0); + + // 1DDL + p_sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("IsGISAXS8_1DDL")); + experiment.setSample(*p_sample); + experiment.runSimulation(); + IsGISAXSTools::writeOutputDataToFile(*experiment.getOutputData(), m_data_path+"this_1DDL.ima"); + delete p_sample; + + // 2DDL + p_sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("IsGISAXS4_2DDL")); + experiment.setSample(*p_sample); + experiment.runSimulation(); + IsGISAXSTools::writeOutputDataToFile(*experiment.getOutputData(), m_data_path+"this_2DDLh.ima"); + delete p_sample; +} + + +void TestIsGISAXS8::finalise() +{ + std::vector< CompareStruct > tocompare; + tocompare.push_back( CompareStruct("isgi_1DDL.ima", "this_1DDL.ima", "Cylinder 1DDL") ); + tocompare.push_back( CompareStruct("isgi_2DDLh.ima", "this_2DDLh.ima", "Cylinder 2DDL") ); + + for(size_t i=0; i<tocompare.size(); ++i) { + OutputData<double> *isgi_data = IsGISAXSTools::readOutputDataFromFile( m_data_path+tocompare[i].isginame ); + OutputData<double> *our_data = IsGISAXSTools::readOutputDataFromFile( 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::setMinimum(1); + IsGISAXSTools::drawOutputDataDifference1D(*our_data, *isgi_data, "", "Difference spectra"); + + IsGISAXSTools::resetMinimum(); IsGISAXSTools::resetMaximum(); + delete isgi_data; + delete our_data; + } +} -- GitLab