Skip to content
Snippets Groups Projects
Commit e4328121 authored by Van Herck, Walter's avatar Van Herck, Walter
Browse files

Replaced InterferenceFunction1DLattice constructor with one that shares

the same style as the other interference functions
parent bfc3abdc
No related branches found
No related tags found
No related merge requests found
......@@ -59,7 +59,8 @@ TestInfLongBox::TestInfLongBox()
, mp_simulation(0)
, mp_sample_builder(new TestSampleBuilder())
{
setOutputPath(Utils::FileSystem::GetPathToData("../Tests/ReferenceData/BornAgain/" ));
setOutputPath(Utils::FileSystem::GetPathToData(
"../Tests/ReferenceData/BornAgain/" ));
}
void TestInfLongBox::execute()
......@@ -67,7 +68,6 @@ void TestInfLongBox::execute()
// initializing simulation and sample builder
initializeSimulation();
mp_simulation->runSimulation();
// save_results();
plot_results();
// plot the pure formfactor
......@@ -79,8 +79,6 @@ void TestInfLongBox::execute()
/* ************************************************************************* */
void TestInfLongBox::save_results()
{
// run simulation for default sample parameters
//mp_simulation->runSimulation();
std::string filename(getOutputPath()+"test_inflongbox.ima");
IntensityDataIOFactory::writeIntensityData(*(mp_simulation->getIntensityData()),
filename);
......@@ -94,7 +92,7 @@ void TestInfLongBox::drawff()
FormFactorInfLongBox *ff = new FormFactorInfLongBox(100.0*Units::nanometer, 50.0*Units::nanometer);
size_t pfbins = 400;
size_t afbins = 400;
double afmin = -2.0;
double afmax = 2.0;
double pfmin = -2.0;
......@@ -135,8 +133,7 @@ void TestInfLongBox::drawff()
double value = std::pow(std::abs(ff->evaluate(k_i, k_f_bin, alpha_f_bin)),2);
hist->Fill(pf, af, value + 1);
//std::cout << "qy=" << qy << " qz=" << qz << " I=" << value*value << std::endl;
}
}
}
hist->SetContour(50);
......@@ -160,13 +157,7 @@ void TestInfLongBox::drawff()
/* ************************************************************************* */
void TestInfLongBox::initializeSimulation()
{
// mp_sample_builder = new SampleBuilder();
delete mp_simulation;
// mp_simulation = new Simulation(mp_options);
// mp_simulation->setSampleBuilder(mp_sample_builder);
// mp_simulation->setDetectorParameters(400, -1.0*Units::degree, 1.0*Units::degree, 400, 0.0*Units::degree, 5.2*Units::degree, true);
// mp_simulation->setBeamParameters(12.0*Units::angstrom, 0.3*Units::degree, 0.0*Units::degree);
delete mp_simulation;
mp_simulation = new OffSpecSimulation(mp_options);
mp_simulation->setSampleBuilder(mp_sample_builder);
......@@ -218,16 +209,12 @@ ISample *TestInfLongBox::TestSampleBuilder::buildSample() const
ParticleLayout particle_layout;
particle_layout.addParticle(ibox,transform);
Lattice1DIFParameters lattice_params;
lattice_params.m_length=m_lattice_length;
lattice_params.m_xi = m_xi;
InterferenceFunction1DLattice *p_interference_function = new InterferenceFunction1DLattice(lattice_params);
InterferenceFunction1DLattice *p_interference_function =
new InterferenceFunction1DLattice(m_lattice_length, m_xi);
FTDistribution1DCauchy pdf(10e6*Units::nanometer);
p_interference_function->setProbabilityDistribution(pdf);
//IInterferenceFunction *p_interference_function = new InterferenceFunctionNone();
particle_layout.addInterferenceFunction(p_interference_function);
//particle_layout.printParameters();
// making layer holding all whose nano particles
air_layer.addLayout(particle_layout);
......@@ -239,9 +226,6 @@ ISample *TestInfLongBox::TestSampleBuilder::buildSample() const
cr_layer.setMaterialAndThickness(cr_material, 1.1*Units::nanometer) ;
Layer silver_layer;
silver_layer.setMaterialAndThickness(silver_material, 150.0*Units::nanometer);
//Layer iron_layer = Layer(iron_material, 15.0*nanometer);
//Layer cr_layer = Layer(cr_material, 1.1*nanometer);
//Layer silver_layer = Layer(silver_material, 150.0*nanometer);
Layer substrate_layer;
substrate_layer.setMaterial(substrate_material);
......@@ -258,7 +242,7 @@ ISample *TestInfLongBox::TestSampleBuilder::buildSample() const
void TestInfLongBox::plot_results()
{
OutputData<double> *m_result = mp_simulation->getIntensityData();
OutputData<double> *m_result = mp_simulation->getIntensityData();
const IAxis *axisPhi = m_result->getAxis(0);
const IAxis *axisAlpha = m_result->getAxis(1);
......@@ -266,8 +250,10 @@ void TestInfLongBox::plot_results()
size_t nAlphabins = axisAlpha->getSize();
TH2D *hist = new TH2D("Ibox", "Ibox",
(int)nPhibins, axisPhi->getMin()/Units::degree, axisPhi->getMax()/Units::degree,
(int)nAlphabins, axisAlpha->getMin()/Units::degree, axisAlpha->getMax()/Units::degree);
(int)nPhibins, axisPhi->getMin()/Units::degree,
axisPhi->getMax()/Units::degree,
(int)nAlphabins, axisAlpha->getMin()/Units::degree,
axisAlpha->getMax()/Units::degree);
hist->GetXaxis()->SetTitle( axisPhi->getName().c_str() );
hist->GetYaxis()->SetTitle( axisAlpha->getName().c_str() );
......
......@@ -94,7 +94,7 @@ void TestInfLongRipple1::drawff()
FormFactorInfLongRipple1 *ff = new FormFactorInfLongRipple1(100.0*Units::nanometer, 50.0*Units::nanometer);
size_t pfbins = 400;
size_t afbins = 400;
double afmin = -2.0;
double afmax = 2.0;
double pfmin = -2.0;
......@@ -135,8 +135,8 @@ void TestInfLongRipple1::drawff()
double value = std::pow(std::abs(ff->evaluate(k_i, k_f_bin, alpha_f_bin)),2);
hist->Fill(pf, af, value + 1);
//std::cout << "qy=" << qy << " qz=" << qz << " I=" << value*value << std::endl;
}
//std::cout << "qy=" << qy << " qz=" << qz << " I=" << value*value << std::endl;
}
}
hist->SetContour(50);
......@@ -161,8 +161,8 @@ void TestInfLongRipple1::drawff()
void TestInfLongRipple1::initializeSimulation()
{
// mp_sample_builder = new SampleBuilder();
delete mp_simulation;
delete mp_simulation;
// mp_simulation = new Simulation(mp_options);
// mp_simulation->setSampleBuilder(mp_sample_builder);
// mp_simulation->setDetectorParameters(400, -1.0*Units::degree, 1.0*Units::degree, 400, 0.0*Units::degree, 5.2*Units::degree, true);
......@@ -218,10 +218,8 @@ ISample *TestInfLongRipple1::TestSampleBuilder::buildSample() const
ParticleLayout particle_layout;
particle_layout.addParticle(ibox,transform);
Lattice1DIFParameters lattice_params;
lattice_params.m_length=m_lattice_length;
lattice_params.m_xi = m_xi;
InterferenceFunction1DLattice *p_interference_function = new InterferenceFunction1DLattice(lattice_params);
InterferenceFunction1DLattice *p_interference_function =
new InterferenceFunction1DLattice(m_lattice_length, m_xi);
FTDistribution1DCauchy pdf(10e6*Units::nanometer);
p_interference_function->setProbabilityDistribution(pdf);
......@@ -255,7 +253,7 @@ ISample *TestInfLongRipple1::TestSampleBuilder::buildSample() const
void TestInfLongRipple1::plot_results()
{
OutputData<double> *m_result = mp_simulation->getIntensityData();
OutputData<double> *m_result = mp_simulation->getIntensityData();
const IAxis *axisPhi = m_result->getAxis(0);
const IAxis *axisAlpha = m_result->getAxis(1);
......
......@@ -95,7 +95,7 @@ void TestInfLongRipple2::drawff()
FormFactorInfLongRipple2 *ff = new FormFactorInfLongRipple2(100.0*Units::nanometer, 50.0*Units::nanometer, 0.0);
size_t pfbins = 400;
size_t afbins = 400;
double afmin = -2.0;
double afmax = 2.0;
double pfmin = -2.0;
......@@ -136,8 +136,8 @@ void TestInfLongRipple2::drawff()
double value = std::pow(std::abs(ff->evaluate(k_i, k_f_bin, alpha_f_bin)),2);
hist->Fill(pf, af, value + 1);
//std::cout << "qy=" << qy << " qz=" << qz << " I=" << value*value << std::endl;
}
//std::cout << "qy=" << qy << " qz=" << qz << " I=" << value*value << std::endl;
}
}
hist->SetContour(50);
......@@ -162,8 +162,8 @@ void TestInfLongRipple2::drawff()
void TestInfLongRipple2::initializeSimulation()
{
// mp_sample_builder = new SampleBuilder();
delete mp_simulation;
delete mp_simulation;
// mp_simulation = new Simulation(mp_options);
// mp_simulation->setSampleBuilder(mp_sample_builder);
// mp_simulation->setDetectorParameters(400, -1.0*Units::degree, 1.0*Units::degree, 400, 0.0*Units::degree, 5.2*Units::degree, true);
......@@ -223,10 +223,8 @@ ISample *TestInfLongRipple2::TestSampleBuilder::buildSample() const
ParticleLayout particle_layout;
particle_layout.addParticle(ibox,transform);
Lattice1DIFParameters lattice_params;
lattice_params.m_length=m_lattice_length;
lattice_params.m_xi = m_xi;
InterferenceFunction1DLattice *p_interference_function = new InterferenceFunction1DLattice(lattice_params);
InterferenceFunction1DLattice *p_interference_function =
new InterferenceFunction1DLattice(m_lattice_length, m_xi);
FTDistribution1DCauchy pdf(10e6*Units::nanometer);
p_interference_function->setProbabilityDistribution(pdf);
......@@ -260,7 +258,7 @@ ISample *TestInfLongRipple2::TestSampleBuilder::buildSample() const
void TestInfLongRipple2::plot_results()
{
OutputData<double> *m_result = mp_simulation->getIntensityData();
OutputData<double> *m_result = mp_simulation->getIntensityData();
const IAxis *axisPhi = m_result->getAxis(0);
const IAxis *axisAlpha = m_result->getAxis(1);
......
......@@ -18,8 +18,8 @@ namespace bp = boost::python;
struct InterferenceFunction1DLattice_wrapper : InterferenceFunction1DLattice, bp::wrapper< InterferenceFunction1DLattice > {
InterferenceFunction1DLattice_wrapper(::Lattice1DIFParameters const & lattice_params )
: InterferenceFunction1DLattice( boost::ref(lattice_params) )
InterferenceFunction1DLattice_wrapper(double length, double xi )
: InterferenceFunction1DLattice( length, xi )
, bp::wrapper< InterferenceFunction1DLattice >(){
// constructor
......@@ -218,7 +218,7 @@ void register_InterferenceFunction1DLattice_class(){
{ //::InterferenceFunction1DLattice
typedef bp::class_< InterferenceFunction1DLattice_wrapper, bp::bases< IInterferenceFunction >, boost::noncopyable > InterferenceFunction1DLattice_exposer_t;
InterferenceFunction1DLattice_exposer_t InterferenceFunction1DLattice_exposer = InterferenceFunction1DLattice_exposer_t( "InterferenceFunction1DLattice", bp::init< Lattice1DIFParameters const & >(( bp::arg("lattice_params") )) );
InterferenceFunction1DLattice_exposer_t InterferenceFunction1DLattice_exposer = InterferenceFunction1DLattice_exposer_t( "InterferenceFunction1DLattice", bp::init< double, double >(( bp::arg("length"), bp::arg("xi") )) );
bp::scope InterferenceFunction1DLattice_scope( InterferenceFunction1DLattice_exposer );
{ //::InterferenceFunction1DLattice::clone
......
......@@ -30,7 +30,9 @@ public:
//! @brief constructor
//! @param lattice_params Lattice parameters
InterferenceFunction1DLattice(const Lattice1DIFParameters& lattice_params);
//! @param length Lattice length
//! @param xi rotation of lattice with respect to x-axis
InterferenceFunction1DLattice(double length, double xi);
virtual ~InterferenceFunction1DLattice();
virtual InterferenceFunction1DLattice *clone() const;
......@@ -51,6 +53,7 @@ protected:
IFTDistribution1D *mp_pdf;
static const int nmax = 20; //!< maximum value for qx*Lambdax and qy*lambday
private:
InterferenceFunction1DLattice(const Lattice1DIFParameters& lattice_params);
//! Registers some class members for later access via parameter pool
virtual void init_parameters();
......
......@@ -29,7 +29,10 @@ class BA_CORE_API_ InterferenceFunction2DLattice : public IInterferenceFunction
public:
//! @brief contructor
//! @param lattice_params Lattice parameters
//! @param length_1 Lattice length 1
//! @param length_2 Lattice length 2
//! @param angle angle between lattice vectors
//! @param xi rotation of lattice with respect to x-axis
InterferenceFunction2DLattice(double length_1, double length_2,
double angle, double xi=0.0);
virtual ~InterferenceFunction2DLattice();
......
......@@ -16,13 +16,14 @@
#include "InterferenceFunction1DLattice.h"
#include <cassert>
InterferenceFunction1DLattice::InterferenceFunction1DLattice(
const Lattice1DIFParameters& lattice_params)
: m_lattice_params(lattice_params)
, mp_pdf(0)
InterferenceFunction1DLattice::InterferenceFunction1DLattice(double length,
double xi)
: mp_pdf(0)
, m_prefactor(1.0)
, m_na(0)
{
m_lattice_params.m_length = length;
m_lattice_params.m_xi = xi;
setName("InterferenceFunction1DLattice");
init_parameters();
}
......@@ -33,7 +34,8 @@ InterferenceFunction1DLattice::~InterferenceFunction1DLattice()
}
InterferenceFunction1DLattice *InterferenceFunction1DLattice::clone() const {
InterferenceFunction1DLattice *result = new InterferenceFunction1DLattice(m_lattice_params);
InterferenceFunction1DLattice *result =
new InterferenceFunction1DLattice(m_lattice_params);
if(mp_pdf) result->setProbabilityDistribution(*mp_pdf);
result->setName(getName());
return result;
......@@ -75,13 +77,23 @@ double InterferenceFunction1DLattice::evaluate(const cvector_t& q) const
qx_frac = qx_prime - qa_int*a_rec;
for (int i=-m_na-1; i<m_na+2; ++i)
{
{
double qx = qx_frac + i*a_rec;
result += mp_pdf->evaluate(qx);
}
return m_prefactor*result;
}
InterferenceFunction1DLattice::InterferenceFunction1DLattice(
const Lattice1DIFParameters& lattice_params)
: m_lattice_params(lattice_params)
, mp_pdf(0)
, m_prefactor(1.0)
, m_na(0)
{
setName("InterferenceFunction1DLattice");
init_parameters();
}
void InterferenceFunction1DLattice::init_parameters()
{
......
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