BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
MaterialUtils Namespace Reference

A number of materials-related helper functions for internal use. More...

Functions

MATERIAL_TYPES checkMaterialTypes (const std::vector< const Material * > &materials)
 Checks if all non-default materials in materials are of the same type and returns this type. More...
 
template<typename T >
Eigen::Matrix2cd MagnetizationCorrection (complex_t unit_factor, double magnetic_factor, BasicVector3D< T > polarization)
 
Eigen::Matrix2cd PolarizedReducedPotential (complex_t n, kvector_t b_field, kvector_t k, double n_ref)
 Function for calculating the reduced potential, used for obtaining the Fresnel coefficients (polarized material case) More...
 
complex_t ScalarReducedPotential (complex_t n, kvector_t k, double n_ref)
 Function for calculating the reduced potential, used for obtaining the Fresnel coefficients (non-polarized material case) More...
 

Detailed Description

A number of materials-related helper functions for internal use.

Function Documentation

◆ checkMaterialTypes()

MATERIAL_TYPES MaterialUtils::checkMaterialTypes ( const std::vector< const Material * > &  materials)

Checks if all non-default materials in materials are of the same type and returns this type.

If several types of materials are involved, InvalidMaterialType identifier is returned.

Definition at line 69 of file MaterialUtils.cpp.

70 {
72  bool isDefault = true;
73  for (const Material* mat : materials) {
74  if (isDefault) {
75  result = mat->typeID();
76  isDefault = mat->isDefaultMaterial();
77  continue;
78  }
79  if (mat->typeID() != result && !mat->isDefaultMaterial())
81  }
82  return result;
83 }
MATERIAL_TYPES
A wrapper for underlying material implementation.
Definition: Material.h:29

References InvalidMaterialType, and RefractiveMaterial.

Referenced by MultiLayerUtils::ContainsCompatibleMaterials(), and createAveragedMaterial().

◆ MagnetizationCorrection()

template<typename T >
Eigen::Matrix2cd MaterialUtils::MagnetizationCorrection ( complex_t  unit_factor,
double  magnetic_factor,
BasicVector3D< T >  polarization 
)

Definition at line 36 of file MaterialUtils.cpp.

39 {
40  Eigen::Matrix2cd result =
41  unit_factor * Unit_Matrix
42  + magnetic_factor
43  * (Pauli_X * polarization[0] + Pauli_Y * polarization[1] + Pauli_Z * polarization[2]);
44  return result;
45 }
const Eigen::Matrix2cd Unit_Matrix(Eigen::Matrix2cd::Identity())

References Unit_Matrix().

Referenced by PolarizedReducedPotential(), and MagneticMaterialImpl::polarizedSubtrSLD().

Here is the call graph for this function:

◆ PolarizedReducedPotential()

Eigen::Matrix2cd MaterialUtils::PolarizedReducedPotential ( complex_t  n,
kvector_t  b_field,
kvector_t  k,
double  n_ref 
)

Function for calculating the reduced potential, used for obtaining the Fresnel coefficients (polarized material case)

Definition at line 60 of file MaterialUtils.cpp.

62 {
63  Eigen::Matrix2cd result;
64  double factor = magnetic_prefactor / k.mag2();
65  complex_t unit_factor = ScalarReducedPotential(n, k, n_ref);
66  return MagnetizationCorrection(unit_factor, factor, b_field);
67 }
std::complex< double > complex_t
Definition: Complex.h:20
constexpr double magnetic_prefactor
double mag2() const
Returns magnitude squared of the vector.
complex_t ScalarReducedPotential(complex_t n, kvector_t k, double n_ref)
Function for calculating the reduced potential, used for obtaining the Fresnel coefficients (non-pola...
Eigen::Matrix2cd MagnetizationCorrection(complex_t unit_factor, double magnetic_factor, BasicVector3D< T > polarization)

References BasicVector3D< T >::mag2(), magnetic_prefactor, MagnetizationCorrection(), and ScalarReducedPotential().

Referenced by Slice::polarizedReducedPotential().

Here is the call graph for this function:

◆ ScalarReducedPotential()

complex_t MaterialUtils::ScalarReducedPotential ( complex_t  n,
kvector_t  k,
double  n_ref 
)

Function for calculating the reduced potential, used for obtaining the Fresnel coefficients (non-polarized material case)

Definition at line 55 of file MaterialUtils.cpp.

56 {
57  return n * n - n_ref * n_ref * k.sin2Theta();
58 }
double sin2Theta() const
Returns squared sine of polar angle.

References BasicVector3D< T >::sin2Theta().

Referenced by PolarizedReducedPotential(), and Slice::scalarReducedPotential().

Here is the call graph for this function: