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

Functions

complex_t ScalarReducedPotential (complex_t n, kvector_t k, double n_ref)
 
Eigen::Matrix2cd PolarizedReducedPotential (complex_t n, kvector_t b_field, kvector_t k, double n_ref)
 
template<typename T >
Eigen::Matrix2cd MagnetizationCorrection (complex_t unit_factor, double magnetic_factor, BasicVector3D< T > polarization)
 
MATERIAL_TYPES checkMaterialTypes (const std::vector< const Material * > &materials)
 

Detailed Description

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

Function Documentation

◆ 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 56 of file MaterialUtils.cpp.

57 {
58  return n * n - n_ref * n_ref * k.sin2Theta();
59 }
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:

◆ 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 61 of file MaterialUtils.cpp.

63 {
64  Eigen::Matrix2cd result;
65  double factor = magnetic_prefactor / k.mag2();
66  complex_t unit_factor = ScalarReducedPotential(n, k, n_ref);
67  return MagnetizationCorrection(unit_factor, factor, b_field);
68 }
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:

◆ MagnetizationCorrection()

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

Definition at line 37 of file MaterialUtils.cpp.

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

References anonymous_namespace{MaterialUtils.cpp}::Pauli_X(), anonymous_namespace{MaterialUtils.cpp}::Pauli_Y(), anonymous_namespace{MaterialUtils.cpp}::Pauli_Z(), and Unit_Matrix().

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

Here is the call graph for this function:

◆ 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 70 of file MaterialUtils.cpp.

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

References InvalidMaterialType, and RefractiveMaterial.

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