//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      Sample/Material/RefractiveMaterial.h
//! @brief     Defines class RefractiveMaterial.
//!
//! @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_REFRACTIVEMATERIAL_H
#define BORNAGAIN_SAMPLE_MATERIAL_REFRACTIVEMATERIAL_H

#include "Sample/Material/Material.h"

//! Material implementation based on refractive coefficiencts (valid for one wavelength value only)

class RefractiveMaterial : public Material {
public:
    RefractiveMaterial(const std::string& name, const MaterialColor& color, double delta,
                       double beta, const R3& magnetization = {});
    RefractiveMaterial(const std::string& name, const MaterialColor& color, complex_t refr_idx,
                       const R3& magnetization = {});
    ~RefractiveMaterial() override = default;

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

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

    //! Returns refractive index
    //! For this particular implementation returned value does not depend
    //! on passed wavelength
    complex_t refractiveIndex(double wavelength) const override;

    //! Returns squared refractive index.
    //! For this particular implementation returned value does not depend
    //! on passed wavelength.
    complex_t squaredRefractiveIndex(double wavelength) const override;

    //! Returns underlying refractive index value
    complex_t rawData() const override;

    complex_t averageableData() const override;

    //! Returns SLD in Å⁻² computed from refractive index at given wavelength in nm
    complex_t sld(double wavelength) const override;

    //! Returns (π/λ² − SLD(in nm⁻²)).
    //! If the wavelength associated with passed wavevector is different from the one
    //! associated with refractive coefficients used during the object construction,
    //! provided result is inconsistent.
    complex_t plainSubtrSLD(double lambda0) const override;

private:
    const double
        m_delta; //!< \f$\delta\f$ coefficient for refractive index \f$n = 1 - \delta + i \beta\f$
    const double
        m_beta; //!< \f$\beta\f$ coefficient for refractive index \f$n = 1 - \delta + i \beta\f$
#endif          // SWIG
};

#endif // BORNAGAIN_SAMPLE_MATERIAL_REFRACTIVEMATERIAL_H
