//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      Sample/Aggregate/Crystal1D.h
//! @brief     Defines class Crystal1D.
//!
//! @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_AGGREGATE_CRYSTAL1D_H
#define BORNAGAIN_SAMPLE_AGGREGATE_CRYSTAL1D_H

#include "Sample/Aggregate/LongRangeOrdered2D.h"

class Profile1D;

//! Interference function of a 1D crystal.
//! Contains lateral position variance which is gived in "2D", not just along the lattice => uses 2D
//! Debye-Waller factor.
class Crystal1D : public LongRangeOrdered2D {
public:
    Crystal1D(const IParticle& particle, double length, double xi, double linear_density);
    ~Crystal1D() override;

    void setDecayFunction(const Profile1D& decay);

    std::string className() const final { return "Crystal1D"; }

#ifndef SWIG
    Crystal1D* clone() const override;
    void validate() const override;

    double areaNumberDensity() const override { return m_linear_density / m_length; }

    double length() const { return m_length; }
    double xi() const { return m_xi; }
    double linearDensity() const { return m_linear_density; }
    double decayLength() const;

private:
    double iff_without_dw(const R3& q) const override;

    double m_length;
    double m_xi;
    double m_linear_density; //!< linear density of independent 1D lattices on the surface
    std::unique_ptr<Profile1D> m_decay;
    int m_na; //!< determines the number of reciprocal lattice points to use

#endif // SWIG
};

#endif // BORNAGAIN_SAMPLE_AGGREGATE_CRYSTAL1D_H
