BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
MesoCrystal.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Particle/MesoCrystal.cpp
6 //! @brief Implements class MesoCrystal.
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 
21 
22 MesoCrystal::MesoCrystal(const Crystal& particle_structure, const IFormFactor& form_factor)
23  : m_particle_structure(particle_structure.clone()), m_meso_form_factor(form_factor.clone())
24 {
25  initialize();
26 }
27 
28 MesoCrystal::~MesoCrystal() = default;
29 
31 {
32  MesoCrystal* p_result =
33  new MesoCrystal(m_particle_structure->clone(), m_meso_form_factor->clone());
34  p_result->setAbundance(m_abundance);
35  if (m_rotation)
36  p_result->setRotation(*m_rotation);
37  p_result->setPosition(m_position);
38  return p_result;
39 }
40 
41 void MesoCrystal::accept(INodeVisitor* visitor) const
42 {
43  visitor->visit(this);
44 }
45 
47 {
49  return {};
50  std::unique_ptr<IRotation> rotation(new IdentityRotation);
51  if (m_rotation)
52  rotation.reset(m_rotation->clone());
53  std::unique_ptr<IFormFactor> tem_ff(
54  m_meso_form_factor->createSlicedFormFactor(limits, *rotation, m_position));
55  std::unique_ptr<IFormFactor> total_ff(
56  m_particle_structure->createTotalFormFactor(*tem_ff, rotation.get(), m_position));
57  double meso_volume = m_meso_form_factor->volume();
58  auto regions = m_particle_structure->homogeneousRegions();
59  for (auto& region : regions)
60  region.m_volume *= meso_volume;
61  SlicedParticle result;
62  result.m_slicedff = std::move(total_ff);
63  result.m_regions = regions;
64  return result;
65 }
66 
67 std::vector<const INode*> MesoCrystal::getChildren() const
68 {
69  return std::vector<const INode*>()
71 }
72 
73 MesoCrystal::MesoCrystal(Crystal* particle_structure, IFormFactor* form_factor)
74  : m_particle_structure(particle_structure), m_meso_form_factor(form_factor)
75 {
76  initialize();
77 }
78 
80 {
81  setName("MesoCrystal");
85 }
Defines class Crystal.
Defines class FormFactorDecoratorPositionFactor.
Defines class FormFactorDecoratorRotation.
Defines class MesoCrystal.
Defines IRotation classes.
Defines class SlicedParticle.
A crystal structure, defined by a Bravais lattice, a basis, and a position variance.
Definition: Crystal.h:35
void setAbundance(double abundance)
Sets particle abundance.
Abstract base class for all form factors.
Definition: IFormFactor.h:36
Visitor interface to visit ISampleNode objects.
Definition: INodeVisitor.h:146
virtual void visit(const BasicLattice2D *)
Definition: INodeVisitor.h:151
void registerChild(INode *node)
Definition: INode.cpp:57
void setName(const std::string &name)
std::vector< const INode * > getChildren() const override
Returns a vector of children.
Definition: IParticle.cpp:61
void setPosition(kvector_t position)
Sets relative position of the particle's reference point in the coordinate system of parent.
Definition: IParticle.h:50
const IRotation * rotation() const
Returns rotation object.
Definition: IParticle.cpp:39
kvector_t m_position
Definition: IParticle.h:94
std::unique_ptr< IRotation > m_rotation
Definition: IParticle.h:95
void setRotation(const IRotation &rotation)
Sets transformation.
Definition: IParticle.cpp:44
void registerParticleProperties()
Registers abundance and position.
Definition: IParticle.cpp:125
The identity rotation, which leaves everything in place.
Definition: Rotations.h:57
A particle with an internal structure of smaller particles.
Definition: MesoCrystal.h:25
MesoCrystal * clone() const final
Returns a clone of this ISampleNode object.
Definition: MesoCrystal.cpp:30
void accept(INodeVisitor *visitor) const final
Calls the INodeVisitor's visit method.
Definition: MesoCrystal.cpp:41
std::unique_ptr< Crystal > m_particle_structure
Crystal structure.
Definition: MesoCrystal.h:42
std::vector< const INode * > getChildren() const final
Returns a vector of children.
Definition: MesoCrystal.cpp:67
std::unique_ptr< IFormFactor > m_meso_form_factor
Outer shape of this mesocrystal.
Definition: MesoCrystal.h:43
void initialize()
Definition: MesoCrystal.cpp:79
SlicedParticle createSlicedParticle(ZLimits limits) const final
Creates a sliced form factor for this particle.
Definition: MesoCrystal.cpp:46
MesoCrystal(const Crystal &particle_structure, const IFormFactor &form_factor)
Definition: MesoCrystal.cpp:22
Class that contains upper and lower limits of the z-coordinate for the slicing of form factors.
Definition: ZLimits.h:45
Struct that contains information on a sliced particle.
std::vector< HomogeneousRegion > m_regions
std::unique_ptr< IFormFactor > m_slicedff