BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
ParticleLayout.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Aggregate/ParticleLayout.h
6 //! @brief Defines class ParticleLayout.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_SAMPLE_AGGREGATE_PARTICLELAYOUT_H
16 #define BORNAGAIN_SAMPLE_AGGREGATE_PARTICLELAYOUT_H
17 
20 #include <memory>
21 
22 class IInterference;
23 class IParticle;
24 
25 //! Decorator class that adds particles to ISampleNode objects.
26 //! @ingroup samples
27 
28 class ParticleLayout : public ISampleNode {
29 public:
31  ParticleLayout(const IParticle& particle, double abundance = -1.0);
32  ~ParticleLayout() override;
33 
34  ParticleLayout* clone() const override;
35  std::string className() const final { return "ParticleLayout"; }
36  std::vector<ParaMeta> parDefs() const final
37  {
38  return {{"Abundance", "", "e.g. surface fraction covered by this layout", 0, +INF, -1}};
39  }
40  std::vector<const INode*> nodeChildren() const override;
41 
42  void addParticle(const IParticle& particle, double abundance = -1.0);
43 
44  std::vector<const IParticle*> particles() const;
45 
46  const IInterference* interferenceFunction() const;
47 
48  double totalAbundance() const;
49 
50  void setInterference(const IInterference& interparticle);
51 
52  double totalParticleSurfaceDensity() const;
53  void setTotalParticleSurfaceDensity(double particle_density);
54 
55  //! Returns the relative weight of this layout
56  double weight() const { return m_weight; }
57 
58  //! Sets the relative weight of this layout
59  void setWeight(double weight) { m_weight = weight; }
60 
61  double weightedParticleSurfaceDensity() const;
62 
63 private:
66 
67  double m_weight{1};
69  OwningVector<IParticle> m_particles; //!< Vector of particle types
70  std::unique_ptr<IInterference> m_interparticle;
71 };
72 
73 #endif // BORNAGAIN_SAMPLE_AGGREGATE_PARTICLELAYOUT_H
const double INF
Definition: INode.h:26
Defines interface class ISampleNode.
Defines and implements templated class OwningVector.
Abstract base class of interference functions.
Definition: IInterference.h:24
Abstract base class for Particle, ParticleComposition, ParticleCoreShell, MesoCrystal....
Definition: IParticle.h:31
Abstract base class for sample components and properties related to scattering.
Definition: ISampleNode.h:27
Decorator class that adds particles to ISampleNode objects.
double weight() const
Returns the relative weight of this layout.
OwningVector< IParticle > m_particles
Vector of particle types.
void addAndRegisterAbstractParticle(IParticle *child)
Adds particle information with simultaneous registration in parent class.
void setTotalParticleSurfaceDensity(double particle_density)
Sets total particle surface density.
void setAndRegisterInterference(IInterference *child)
Sets interference function with simultaneous registration in parent class.
ParticleLayout * clone() const override
Returns a clone of this ISampleNode object.
void addParticle(const IParticle &particle, double abundance=-1.0)
Adds particle to the layout with abundance, position and the rotation defined.
double totalAbundance() const
const IInterference * interferenceFunction() const
std::unique_ptr< IInterference > m_interparticle
std::vector< ParaMeta > parDefs() const final
Returns the parameter definitions, to be hard-coded in each leaf class.
~ParticleLayout() override
std::string className() const final
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
void setInterference(const IInterference &interparticle)
Adds interference functions.
std::vector< const IParticle * > particles() const
double weightedParticleSurfaceDensity() const
double m_total_particle_density
void setWeight(double weight)
Sets the relative weight of this layout.
std::vector< const INode * > nodeChildren() const override
Returns all children.
double totalParticleSurfaceDensity() const