Skip to content
Snippets Groups Projects
Commit beba8ce8 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

merge DpElement into simulation

parent e6cc598e
No related branches found
No related tags found
1 merge request!1552Depth probe computation without computation file and without element class
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Resample/Element/DepthprobeElement.cpp
//! @brief Implements class DepthprobeElement.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#include "Resample/Element/DepthprobeElement.h"
#include "Base/Axis/IAxis.h"
#include "Base/Util/Assert.h"
#include "Base/Vector/GisasDirection.h"
DepthprobeElement::DepthprobeElement(double wavelength, double alpha_i, const IAxis* z_positions,
bool calculation_flag)
: IElement()
, m_wavelength(wavelength)
, m_alpha_i(alpha_i)
, m_z_positions(z_positions)
, m_calculation_flag(calculation_flag)
{
ASSERT(z_positions);
m_intensities.resize(z_positions->size(), 0.0);
}
DepthprobeElement::DepthprobeElement(DepthprobeElement&& other) noexcept = default;
DepthprobeElement::~DepthprobeElement() = default;
R3 DepthprobeElement::getKi() const
{
return vecOfLambdaAlphaPhi(m_wavelength, m_alpha_i);
}
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Resample/Element/DepthprobeElement.h
//! @brief Defines class DepthprobeElement.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#ifdef SWIG
#error no need to expose this header to Swig
#endif // SWIG
#ifndef BORNAGAIN_RESAMPLE_ELEMENT_DEPTHPROBEELEMENT_H
#define BORNAGAIN_RESAMPLE_ELEMENT_DEPTHPROBEELEMENT_H
#include "Resample/Element/IElement.h"
#include <valarray>
class IAxis;
class DepthprobeElement : public IElement {
public:
DepthprobeElement(double wavelength, double alpha_i, const IAxis* z_positions,
bool calculation_flag);
DepthprobeElement(const DepthprobeElement& other) = delete;
DepthprobeElement(DepthprobeElement&& other) noexcept;
~DepthprobeElement();
double wavelength() const { return m_wavelength; }
double alphaI() const { return m_alpha_i; }
R3 getKi() const;
template <typename T>
void setIntensities(T&& intensities)
{
static_assert(
std::is_assignable<std::valarray<double>, typename std::decay<T>::type>::value,
"Error in DepthprobeElement::setIntensities: wrong type of input data.");
m_intensities = std::forward<T>(intensities);
}
const std::valarray<double>& getIntensities() const { return m_intensities; }
void setZPositions(const IAxis* z_positions) { m_z_positions = z_positions; }
const IAxis* getZPositions() const { return m_z_positions; }
size_t size() const { return m_intensities.size(); }
//! if it's false, zero intensity is assigned to the element
bool isCalculated() const { return m_calculation_flag; }
private:
const double m_wavelength;
const double m_alpha_i; //!< incident angle of the beam
std::valarray<double> m_intensities; //!< simulated intensity for the set of z positions
const IAxis* m_z_positions; //!< positions (lower z corresponds to a greater depth)
const bool m_calculation_flag;
};
#endif // BORNAGAIN_RESAMPLE_ELEMENT_DEPTHPROBEELEMENT_H
......@@ -16,19 +16,21 @@
#include "Base/Axis/Bin.h"
#include "Base/Axis/FixedBinAxis.h"
#include "Base/Math/Constants.h"
#include "Base/Progress/ProgressHandler.h"
#include "Base/Util/Assert.h"
#include "Base/Vector/GisasDirection.h"
#include "Device/Beam/IFootprintFactor.h"
#include "Device/Coord/CoordSystem2D.h"
#include "Device/Data/Datafield.h"
#include "Device/Histo/SimulationResult.h"
#include "Param/Distrib/DistributionHandler.h"
#include "Param/Distrib/Distributions.h"
#include "Resample/Element/DepthprobeElement.h"
#include "Sim/Scan/AlphaScan.h"
#include "Resample/Element/IElement.h"
#include "Resample/Flux/ScalarFlux.h"
#include "Resample/Processed/ReSample.h"
#include "Base/Progress/ProgressHandler.h"
#include "Sim/Scan/AlphaScan.h"
#include <iostream>
#include <valarray>
DepthprobeSimulation::DepthprobeSimulation(const IBeamScan& scan, const MultiLayer& sample,
const IAxis& zaxis)
......@@ -78,6 +80,71 @@ void DepthprobeSimulation::initDistributionHandler()
}
}
//>>>>>>>
class DepthprobeElement : public IElement {
public:
DepthprobeElement(double wavelength, double alpha_i, const IAxis* z_positions,
bool calculation_flag);
DepthprobeElement(const DepthprobeElement& other) = delete;
DepthprobeElement(DepthprobeElement&& other) noexcept;
~DepthprobeElement();
double wavelength() const { return m_wavelength; }
double alphaI() const { return m_alpha_i; }
R3 getKi() const;
template <typename T>
void setIntensities(T&& intensities)
{
static_assert(
std::is_assignable<std::valarray<double>, typename std::decay<T>::type>::value,
"Error in DepthprobeElement::setIntensities: wrong type of input data.");
m_intensities = std::forward<T>(intensities);
}
const std::valarray<double>& getIntensities() const { return m_intensities; }
void setZPositions(const IAxis* z_positions) { m_z_positions = z_positions; }
const IAxis* getZPositions() const { return m_z_positions; }
size_t size() const { return m_intensities.size(); }
//! if it's false, zero intensity is assigned to the element
bool isCalculated() const { return m_calculation_flag; }
private:
const double m_wavelength;
const double m_alpha_i; //!< incident angle of the beam
std::valarray<double> m_intensities; //!< simulated intensity for the set of z positions
const IAxis* m_z_positions; //!< positions (lower z corresponds to a greater depth)
const bool m_calculation_flag;
};
DepthprobeElement::DepthprobeElement(double wavelength, double alpha_i, const IAxis* z_positions,
bool calculation_flag)
: IElement()
, m_wavelength(wavelength)
, m_alpha_i(alpha_i)
, m_z_positions(z_positions)
, m_calculation_flag(calculation_flag)
{
ASSERT(z_positions);
m_intensities.resize(z_positions->size(), 0.0);
}
DepthprobeElement::DepthprobeElement(DepthprobeElement&& other) noexcept = default;
DepthprobeElement::~DepthprobeElement() = default;
R3 DepthprobeElement::getKi() const
{
return vecOfLambdaAlphaPhi(m_wavelength, m_alpha_i);
}
//<<<<<<<
void DepthprobeSimulation::runComputation(const ReSample& re_sample, size_t i, double weight)
{
const double result_angle = m_scan->coordinateAxis()->bin(i).center() + m_scan->alphaOffset();
......
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