//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      Sample/Material/SLDMaterial.h
//! @brief     Defines class SLDMaterial.
//!
//! @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)
//
//  ************************************************************************************************

#ifndef BORNAGAIN_SAMPLE_MATERIAL_SLDMATERIAL_H
#define BORNAGAIN_SAMPLE_MATERIAL_SLDMATERIAL_H

#include "Sample/Material/Material.h"

//! Material implementation based on wavelength-independent data (valid for a range of wavelengths)

class SLDMaterial : public Material {
public:
    //! Constructs a wavelength-independent material with a given complex-valued
    //! scattering length density (SLD). SLD units are Å⁻².
    SLDMaterial(const std::string& name, const MaterialColor& color, double sld_real,
                double sld_imag, const R3& magnetization = {});
    ~SLDMaterial() override = default;

#ifndef SWIG
    //! Returns pointer to a copy of material
    SLDMaterial* clone() const override;

    bool hasNativeRefractiveIndex() const override { return false; }
    bool hasNativeSLD() const override { return true; }
    bool isVacuum() const override { return m_sld_real == 0 && m_sld_imag == 0; }

    //! Returns refractive index
    complex_t refractiveIndex(double wavelength) const override;

    //! Returns squared refractive index
    complex_t squaredRefractiveIndex(double wavelength) const override;

    //! Returns underlying material SLD in Å⁻²
    complex_t rawData() const override;

    //! Returns SLD in Å⁻² (wavelength-independent for this material type)
    complex_t sld(double wavelength) const override;

    //! Returns (π/λ² − SLD(in nm⁻²))
    complex_t plainSubtrSLD(double lambda0) const override;

private:
    //! Returns the scattering length density in Å⁻²
    complex_t sld() const;

    const double m_sld_real; //!< complex-valued scattering length density
    const double m_sld_imag; //!< imaginary part of scattering length density (negative by default)
#endif                       // SWIG
};

#endif // BORNAGAIN_SAMPLE_MATERIAL_SLDMATERIAL_H
