BornAgain  1.19.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 reflection and scattering
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 
16 #include "Base/Math/Constants.h"
19 
22  , m_material(HomogeneousMaterial())
23  , m_ambient_material(HomogeneousMaterial())
24 {
25  setName("FormFactorDecoratorMaterial");
26 }
27 
29 
31 {
32  auto* result = new FormFactorDecoratorMaterial(*m_ff);
33  result->setMaterial(m_material);
34  result->setAmbientMaterial(m_ambient_material);
35  return result;
36 }
37 
39 {
41 }
42 
44 {
46 }
47 
49 {
50  return getRefractiveIndexFactor(wavevectors) * m_ff->evaluate(wavevectors);
51 }
52 
53 Eigen::Matrix2cd FormFactorDecoratorMaterial::evaluatePol(const WavevectorInfo& wavevectors) const
54 {
55  // the conjugated linear part of time reversal operator T
56  // (T=UK with K complex conjugate operator and U is linear)
57  Eigen::Matrix2cd time_reverse_conj = Eigen::Matrix2cd::Zero();
58  time_reverse_conj(0, 1) = 1.0;
59  time_reverse_conj(1, 0) = -1.0;
60  // the interaction and time reversal taken together:
61  Eigen::Matrix2cd V_eff = time_reverse_conj
62  * (m_material.polarizedSubtrSLD(wavevectors)
63  - m_ambient_material.polarizedSubtrSLD(wavevectors));
64  return m_ff->evaluate(wavevectors) * V_eff;
65 }
66 
69 {
70  return m_material.scalarSubtrSLD(wavevectors) - m_ambient_material.scalarSubtrSLD(wavevectors);
71 }
std::complex< double > complex_t
Definition: Complex.h:20
Defines M_PI and some more mathematical constants.
Defines class FormFactorDecoratorMaterial.
Factory functions used to create material instances.
Defines WavevectorInfo.
Decorates a scalar formfactor with the correct factor for the material's refractive index and that of...
FormFactorDecoratorMaterial(const IFormFactor &ff)
void setMaterial(const Material &material)
Sets the material of the scatterer.
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.
~FormFactorDecoratorMaterial() override
FormFactorDecoratorMaterial * clone() const override
Returns a clone of this ISampleNode object.
Eigen::Matrix2cd evaluatePol(const WavevectorInfo &wavevectors) const override
Returns scattering amplitude for matrix interactions.
Encapsulates another formfactor and adds extra functionality (a scalar factor, a position-dependent p...
Abstract base class for all form factors.
Definition: IFormFactor.h:36
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: ISampleNode.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:96
complex_t scalarSubtrSLD(const WavevectorInfo &wavevectors) const
Returns ( - sld), sld (in ) being the scattering length density.
Definition: Material.cpp:91
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).