BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
MaterialFactoryFuncs.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Material/MaterialFactoryFuncs.cpp
6 //! @brief Factory functions used to create material instances.
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 
15 #include "Base/Const/Units.h"
19 #include <functional>
20 
21 Material RefractiveMaterial(const std::string& name, complex_t refractive_index, R3 magnetization)
22 {
23  const double delta = 1.0 - refractive_index.real();
24  const double beta = refractive_index.imag();
25  return RefractiveMaterial(name, delta, beta, magnetization);
26 }
27 
28 Material RefractiveMaterial(const std::string& name, double delta, double beta, R3 magnetization)
29 {
30  std::unique_ptr<RefractiveMaterialImpl> mat_impl(
31  new RefractiveMaterialImpl(name, delta, beta, magnetization));
32  return Material(std::move(mat_impl));
33 }
34 
36 {
37  return RefractiveMaterial("vacuum", 0.0, 0.0, R3{});
38 }
39 
41 {
42  return MaterialBySLD("vacuum", 0.0, 0.0, R3{});
43 }
44 
45 Material MaterialBySLD(const std::string& name, double sld_real, double sld_imag, R3 magnetization)
46 {
47  constexpr double inv_sq_angstroms = 1.0 / (Units::angstrom * Units::angstrom);
48  std::unique_ptr<MaterialBySLDImpl> mat_impl(new MaterialBySLDImpl(
49  name, sld_real * inv_sq_angstroms, sld_imag * inv_sq_angstroms, magnetization));
50  return Material(std::move(mat_impl));
51 }
Defines class MaterialBySLDImpl.
Declares functions in namespace MaterialUtils.
Defines class RefractiveMaterialImpl.
Defines some unit conversion factors and other constants in namespace Units.
Material implementation based on wavelength-independent data (valid for a range of wavelengths)
A wrapper for underlying material implementation.
Definition: Material.h:35
Material implementation based on refractive coefficiencts (valid for one wavelength value only)
Material RefractiveMaterial(const std::string &name, complex_t refractive_index, R3 magnetization)
Material MaterialBySLD()
Material Vacuum()
double beta(double z, double w)
static constexpr double angstrom
Definition: Units.h:34