1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Sample/Material/RefractiveMaterialImpl.cpp
//! @brief Implements class RefractiveMaterialImpl.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#include "Sample/Material/RefractiveMaterialImpl.h"
#include "Base/Vector/WavevectorInfo.h"
#include <numbers>
#include <sstream>
using std::numbers::pi;
RefractiveMaterialImpl::RefractiveMaterialImpl(const std::string& name, double delta, double beta,
const R3& magnetization)
: IMaterialImpl(name, magnetization)
, m_delta(delta)
, m_beta(beta < 0.
? throw std::runtime_error(
"The imaginary part of the refractive index must be greater or equal zero")
: beta)
{
}
RefractiveMaterialImpl* RefractiveMaterialImpl::clone() const
{
return new RefractiveMaterialImpl(*this);
}
complex_t RefractiveMaterialImpl::refractiveIndex(double) const
{
return {1.0 - m_delta, m_beta};
}
complex_t RefractiveMaterialImpl::refractiveIndex2(double) const
{
complex_t result(1.0 - m_delta, m_beta);
return result * result;
}
complex_t RefractiveMaterialImpl::refractiveIndex_or_SLD() const
{
return {m_delta, m_beta};
}
complex_t RefractiveMaterialImpl::scalarSubtrSLD(double lambda0) const
{
if (std::isnan(lambda0))
throw std::runtime_error("wavelength not set");
return pi / lambda0 / lambda0 * refractiveIndex2(lambda0);
}
std::string RefractiveMaterialImpl::print() const
{
std::stringstream s;
s << "RefractiveMaterial:" << matName() << "<" << this << ">{ "
<< "delta=" << m_delta << ", beta=" << m_beta << ", B=" << magnetization() << "}";
return s.str();
}
|