Skip to content
Snippets Groups Projects
Commit c4402097 authored by Yurov, Dmitry's avatar Yurov, Dmitry
Browse files

Refactoring: MaterialUtils namespace introduced + slight changes in documentation

parent a89601ab
No related branches found
No related tags found
No related merge requests found
...@@ -43,7 +43,7 @@ Eigen::Matrix2cd BaseMaterialImpl::polarizedSubtrSLD(const WavevectorInfo& wavev ...@@ -43,7 +43,7 @@ Eigen::Matrix2cd BaseMaterialImpl::polarizedSubtrSLD(const WavevectorInfo& wavev
{ {
cvector_t mag_ortho = OrthogonalToBaseVector(wavevectors.getQ(), m_magnetization); cvector_t mag_ortho = OrthogonalToBaseVector(wavevectors.getQ(), m_magnetization);
complex_t unit_factor = scalarSubtrSLD(wavevectors); complex_t unit_factor = scalarSubtrSLD(wavevectors);
return MagnetizationCorrection(unit_factor, magnetization_prefactor, mag_ortho); return MaterialUtils::MagnetizationCorrection(unit_factor, magnetization_prefactor, mag_ortho);
} }
BaseMaterialImpl* BaseMaterialImpl::transformedMaterial(const Transform3D& transform) const BaseMaterialImpl* BaseMaterialImpl::transformedMaterial(const Transform3D& transform) const
......
...@@ -27,8 +27,10 @@ const Eigen::Matrix2cd Pauli_Z((Eigen::Matrix2cd() << 1, 0, ...@@ -27,8 +27,10 @@ const Eigen::Matrix2cd Pauli_Z((Eigen::Matrix2cd() << 1, 0,
} }
template <typename T> template <typename T>
Eigen::Matrix2cd MagnetizationCorrection(complex_t unit_factor, double magnetic_factor, Eigen::Matrix2cd MaterialUtils::MagnetizationCorrection(complex_t unit_factor,
BasicVector3D<T> polarization){ double magnetic_factor,
BasicVector3D<T> polarization)
{
Eigen::Matrix2cd result = unit_factor * Unit_Matrix + Eigen::Matrix2cd result = unit_factor * Unit_Matrix +
magnetic_factor * ( magnetic_factor * (
Pauli_X * polarization[0] + Pauli_X * polarization[0] +
...@@ -37,17 +39,19 @@ Eigen::Matrix2cd MagnetizationCorrection(complex_t unit_factor, double magnetic_ ...@@ -37,17 +39,19 @@ Eigen::Matrix2cd MagnetizationCorrection(complex_t unit_factor, double magnetic_
); );
return result; return result;
} }
template Eigen::Matrix2cd MagnetizationCorrection(complex_t unit_factor, double magnetic_factor, template Eigen::Matrix2cd MaterialUtils::MagnetizationCorrection(complex_t unit_factor,
kvector_t polarization); double magnetic_factor,
template Eigen::Matrix2cd MagnetizationCorrection(complex_t unit_factor, double magnetic_factor, kvector_t polarization);
cvector_t polarization); template Eigen::Matrix2cd MaterialUtils::MagnetizationCorrection(complex_t unit_factor,
double magnetic_factor,
cvector_t polarization);
complex_t ScalarReducedPotential(complex_t n, kvector_t k, double n_ref) complex_t MaterialUtils::ScalarReducedPotential(complex_t n, kvector_t k, double n_ref)
{ {
return n*n - n_ref*n_ref*k.sin2Theta(); return n*n - n_ref*n_ref*k.sin2Theta();
} }
Eigen::Matrix2cd PolarizedReducedPotential(complex_t n, kvector_t b_field, Eigen::Matrix2cd MaterialUtils::PolarizedReducedPotential(complex_t n, kvector_t b_field,
kvector_t k, double n_ref) kvector_t k, double n_ref)
{ {
Eigen::Matrix2cd result; Eigen::Matrix2cd result;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// //
// BornAgain: simulate and fit scattering at grazing incidence // BornAgain: simulate and fit scattering at grazing incidence
// //
//! @file Core/Material/Material.h //! @file Core/Material/MaterialUtils.h
//! @brief materials-related global functions and utilities //! @brief materials-related global functions and utilities
//! //!
//! @homepage http://www.bornagainproject.org //! @homepage http://www.bornagainproject.org
...@@ -20,15 +20,19 @@ ...@@ -20,15 +20,19 @@
#include "Vectors3D.h" #include "Vectors3D.h"
#include "EigenCore.h" #include "EigenCore.h"
//! A number of helper functions for internal use
//! @ingroup materials
namespace MaterialUtils {
//! Function for calculating the reduced potential, used for obtaining the Fresnel coefficients //! Function for calculating the reduced potential, used for obtaining the Fresnel coefficients
//! (non-polarized material case) //! (non-polarized material case)
complex_t ScalarReducedPotential(complex_t n, kvector_t k, double n_ref); BA_CORE_API_ complex_t ScalarReducedPotential(complex_t n, kvector_t k, double n_ref);
#ifndef SWIG #ifndef SWIG
//! Function for calculating the reduced potential, used for obtaining the Fresnel coefficients //! Function for calculating the reduced potential, used for obtaining the Fresnel coefficients
//! (polarized material case) //! (polarized material case)
Eigen::Matrix2cd PolarizedReducedPotential(complex_t n, kvector_t b_field, BA_CORE_API_ Eigen::Matrix2cd PolarizedReducedPotential(complex_t n, kvector_t b_field, kvector_t k,
kvector_t k, double n_ref); double n_ref);
//! Utility to compute magnetization correction for reduced potential and scattering length density //! Utility to compute magnetization correction for reduced potential and scattering length density
template <typename T> template <typename T>
...@@ -36,5 +40,6 @@ BA_CORE_API_ Eigen::Matrix2cd MagnetizationCorrection(complex_t unit_factor, dou ...@@ -36,5 +40,6 @@ BA_CORE_API_ Eigen::Matrix2cd MagnetizationCorrection(complex_t unit_factor, dou
BasicVector3D<T> polarization); BasicVector3D<T> polarization);
#endif /* SWIG */ #endif /* SWIG */
}
#endif /* MATERIALUTILS_H_ */ #endif /* MATERIALUTILS_H_ */
...@@ -145,14 +145,14 @@ SafePointerVector<Layer> Layer::slice(ZLimits limits, Layer::ELayerType layer_ty ...@@ -145,14 +145,14 @@ SafePointerVector<Layer> Layer::slice(ZLimits limits, Layer::ELayerType layer_ty
complex_t Layer::scalarReducedPotential(kvector_t k, double n_ref) const complex_t Layer::scalarReducedPotential(kvector_t k, double n_ref) const
{ {
complex_t n = m_material.refractiveIndex(2.0 * M_PI / k.mag()); complex_t n = m_material.refractiveIndex(2.0 * M_PI / k.mag());
return ScalarReducedPotential(n, k, n_ref); return MaterialUtils::ScalarReducedPotential(n, k, n_ref);
} }
Eigen::Matrix2cd Layer::polarizedReducedPotential(kvector_t k, double n_ref) const Eigen::Matrix2cd Layer::polarizedReducedPotential(kvector_t k, double n_ref) const
{ {
complex_t n = m_material.refractiveIndex(2.0 * M_PI / k.mag()); complex_t n = m_material.refractiveIndex(2.0 * M_PI / k.mag());
kvector_t b_field = bField(); kvector_t b_field = bField();
return PolarizedReducedPotential(n, b_field, k, n_ref); return MaterialUtils::PolarizedReducedPotential(n, b_field, k, n_ref);
} }
void Layer::initBField(kvector_t h_field, double b_z) void Layer::initBField(kvector_t h_field, double b_z)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment