BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
FormFactorDecoratorMaterial.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/Scattering/FormFactorDecoratorMaterial.cpp
6 //! @brief Implements class FormFactorDecoratorMaterial.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************** //
14 
19 
21  : IFormFactorDecorator(form_factor), m_material(HomogeneousMaterial()),
22  m_ambient_material(HomogeneousMaterial())
23 {
24  setName("FormFactorDecoratorMaterial");
25 }
26 
28 
30 {
31  auto* result = new FormFactorDecoratorMaterial(*mp_form_factor);
32  result->setMaterial(m_material);
33  result->setAmbientMaterial(m_ambient_material);
34  return result;
35 }
36 
38 {
40 }
41 
43 {
45 }
46 
48 {
49  return getRefractiveIndexFactor(wavevectors) * mp_form_factor->evaluate(wavevectors);
50 }
51 
52 Eigen::Matrix2cd FormFactorDecoratorMaterial::evaluatePol(const WavevectorInfo& wavevectors) const
53 {
54  // the conjugated linear part of time reversal operator T
55  // (T=UK with K complex conjugate operator and U is linear)
56  Eigen::Matrix2cd time_reverse_conj = Eigen::Matrix2cd::Zero();
57  time_reverse_conj(0, 1) = 1.0;
58  time_reverse_conj(1, 0) = -1.0;
59  // the interaction and time reversal taken together:
60  Eigen::Matrix2cd V_eff = time_reverse_conj
61  * (m_material.polarizedSubtrSLD(wavevectors)
62  - m_ambient_material.polarizedSubtrSLD(wavevectors));
63  return mp_form_factor->evaluate(wavevectors) * V_eff;
64 }
65 
68 {
69  return m_material.scalarSubtrSLD(wavevectors) - m_ambient_material.scalarSubtrSLD(wavevectors);
70 }
std::complex< double > complex_t
Definition: Complex.h:20
Defines class FormFactorDecoratorMaterial.
Factory functions used to create material instances.
Defines M_PI and some more mathematical constants.
Defines WavevectorInfo.
Decorates a scalar formfactor with the correct factor for the material's refractive index and that of...
void setMaterial(const Material &material)
Sets the material of the scatterer.
FormFactorDecoratorMaterial(const IFormFactor &form_factor)
FormFactorDecoratorMaterial * clone() const override final
Returns a clone of this ISample object.
~FormFactorDecoratorMaterial() override final
void setAmbientMaterial(const Material &material) override
Sets the ambient material.
complex_t getRefractiveIndexFactor(const WavevectorInfo &wavevectors) const
complex_t evaluate(const WavevectorInfo &wavevectors) const override
Returns scattering amplitude for complex wavevectors ki, kf.
Eigen::Matrix2cd evaluatePol(const WavevectorInfo &wavevectors) const override final
Returns scattering amplitude for matrix interactions.
Encapsulates another formfactor and adds extra functionality (a scalar factor, a position-dependent p...
Pure virtual base class for all form factors.
Definition: IFormFactor.h:40
virtual complex_t evaluate(const WavevectorInfo &wavevectors) const =0
Returns scattering amplitude for complex wavevectors ki, kf.
void setName(const std::string &name)
virtual const Material * material() const
Returns nullptr, unless overwritten to return a specific material.
Definition: ISample.h:37
A wrapper for underlying material implementation.
Definition: Material.h:29
Eigen::Matrix2cd polarizedSubtrSLD(const WavevectorInfo &wavevectors) const
Returns ( - sld) matrix with magnetization corrections.
Definition: Material.cpp:99
complex_t scalarSubtrSLD(const WavevectorInfo &wavevectors) const
Returns ( - sld), sld (in ) being the scattering length density.
Definition: Material.cpp:94
Holds all wavevector information relevant for calculating form factors.
Material HomogeneousMaterial(const std::string &name, complex_t refractive_index, kvector_t magnetization)
Constructs a material with name, refractive_index and magnetization (in A/m).