BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
MesoCrystal Class Reference

Description

A particle with a crystalline inner structure, made of smaller particles, and an outer shape described by a particle form factor.

Definition at line 27 of file MesoCrystal.h.

Inheritance diagram for MesoCrystal:
[legend]
Collaboration diagram for MesoCrystal:
[legend]

Public Member Functions

 MesoCrystal (const Crystal &crystal, const IFormFactor &formfactor)
 
 ~MesoCrystal () override
 
double abundance () const
 
void checkNodeArgs () const
 Raises exception if a parameter value is invalid. More...
 
std::string className () const final
 Returns the class name, to be hard-coded in each leaf class that inherits from INode. More...
 
MesoCrystalclone () const override
 Returns a clone of this ISampleNode object. More...
 
std::vector< const Material * > containedMaterials () const
 Returns set of unique materials contained in this ISampleNode. More...
 
virtual std::vector< std::unique_ptr< IParticle > > decompose () const
 Decompose in constituent IParticle objects. More...
 
bool isMagnetic () const
 Returns true if there is any magnetic material in this ISampleNode. More...
 
virtual const Materialmaterial () const
 Returns nullptr, unless overwritten to return a specific material. More...
 
std::vector< const INode * > nodeChildren () const override
 Returns all children. More...
 
std::vector< const INode * > nodeOffspring () const
 Returns all descendants. More...
 
const IFormFactorouterShape () const
 
virtual std::vector< ParaMetaparDefs () const
 Returns the parameter definitions, to be hard-coded in each leaf class. More...
 
R3 particlePosition () const
 Returns particle position. More...
 
const CrystalparticleStructure () const
 
IParticlerotate (const IRotation &rotation)
 Rotates the particle, and returns this. More...
 
const IRotationrotation () const
 Returns rotation object. More...
 
void setAbundance (double abundance)
 Sets particle abundance. More...
 
void setParticlePosition (double x, double y, double z)
 Sets relative position of the particle's reference point in the coordinate system of parent. More...
 
void setParticlePosition (R3 position)
 Sets relative position of the particle's reference point in the coordinate system of parent. More...
 
void setRotation (const IRotation &rotation)
 Sets transformation. More...
 
virtual void transferToCPP ()
 Used for Python overriding of clone (see swig/tweaks.py) More...
 
IParticletranslate (R3 translation)
 Translates the particle, and returns this. More...
 

Protected Attributes

double m_abundance {1.0}
 
std::vector< double > m_P
 
R3 m_position
 
std::unique_ptr< IRotationm_rotation
 

Private Member Functions

 MesoCrystal (Crystal *crystal, IFormFactor *formfactor)
 

Private Attributes

const std::unique_ptr< Crystalm_crystal
 Crystalline inner structure. More...
 
const std::unique_ptr< IFormFactorm_meso_formfactor
 Outer shape of the mesocrystal. More...
 

Constructor & Destructor Documentation

◆ MesoCrystal() [1/2]

MesoCrystal::MesoCrystal ( const Crystal crystal,
const IFormFactor formfactor 
)

Definition at line 27 of file MesoCrystal.cpp.

28  : MesoCrystal(crystal.clone(), formfactor.clone())
29 {
30 }
Crystal * clone() const override
Returns a clone of this ISampleNode object.
Definition: Crystal.cpp:36
IFormFactor * clone() const override=0
Returns a clone of this ISampleNode object.
MesoCrystal(const Crystal &crystal, const IFormFactor &formfactor)
Definition: MesoCrystal.cpp:27

Referenced by clone().

◆ ~MesoCrystal()

MesoCrystal::~MesoCrystal ( )
overridedefault

◆ MesoCrystal() [2/2]

MesoCrystal::MesoCrystal ( Crystal crystal,
IFormFactor formfactor 
)
private

Definition at line 21 of file MesoCrystal.cpp.

22  : m_crystal(crystal)
23  , m_meso_formfactor(formfactor)
24 {
25 }
const std::unique_ptr< IFormFactor > m_meso_formfactor
Outer shape of the mesocrystal.
Definition: MesoCrystal.h:44
const std::unique_ptr< Crystal > m_crystal
Crystalline inner structure.
Definition: MesoCrystal.h:43

Member Function Documentation

◆ abundance()

double IParticle::abundance ( ) const
inlineinherited

Definition at line 38 of file IParticle.h.

38 { return m_abundance; }
double m_abundance
Definition: IParticle.h:78

References IParticle::m_abundance.

Referenced by SampleToPython::defineParticleLayouts(), and IParticle::setAbundance().

◆ checkNodeArgs()

void INode::checkNodeArgs ( ) const
inherited

Raises exception if a parameter value is invalid.

Definition at line 27 of file INode.cpp.

28 {
29  size_t nP = m_P.size();
30  if (parDefs().size() != nP) {
31  std::cerr << "BUG in class " << className() << std::endl;
32  std::cerr << "#m_P = " << nP << std::endl;
33  std::cerr << "#PDf = " << parDefs().size() << std::endl;
34  for (const ParaMeta& pm : parDefs())
35  std::cerr << " PDf: " << pm.name << std::endl;
36  ASSERT(0);
37  }
38  ASSERT(parDefs().size() == nP);
39  for (size_t i = 0; i < nP; ++i) {
40  const ParaMeta pm = parDefs()[i];
41 
43  if (pm.vMin == -INF) {
44  ASSERT(pm.vMax == +INF);
45  // nothing to do
46  } else if (pm.vMax == +INF) {
47  ASSERT(pm.vMin == 0);
48  limits = RealLimits::nonnegative();
49  } else {
50  limits = RealLimits::limited(pm.vMin, pm.vMax);
51  }
52  limits.check(pm.name, m_P[i]);
53  }
54 }
#define ASSERT(condition)
Definition: Assert.h:45
const double INF
Definition: INode.h:26
virtual std::vector< ParaMeta > parDefs() const
Returns the parameter definitions, to be hard-coded in each leaf class.
Definition: INode.h:51
std::vector< double > m_P
Definition: INode.h:63
virtual std::string className() const =0
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
Limits for a real fit parameter.
Definition: RealLimits.h:24
static RealLimits limitless()
Creates an object without bounds (default)
Definition: RealLimits.cpp:139
void check(const std::string &name, double value) const
Throws if value is outside limits. Parameter 'name' is for exception message.
Definition: RealLimits.cpp:170
static RealLimits nonnegative()
Creates an object which can have only positive values with 0. included.
Definition: RealLimits.cpp:124
static RealLimits limited(double left_bound_value, double right_bound_value)
Creates an object bounded from the left and right.
Definition: RealLimits.cpp:134
Metadata of one model parameter.
Definition: INode.h:29
double vMin
Definition: INode.h:33
double vMax
Definition: INode.h:34
std::string name
Definition: INode.h:30

References ASSERT, RealLimits::check(), INode::className(), INF, RealLimits::limited(), RealLimits::limitless(), INode::m_P, ParaMeta::name, RealLimits::nonnegative(), INode::parDefs(), ParaMeta::vMax, and ParaMeta::vMin.

Referenced by BarGauss::BarGauss(), BarLorentz::BarLorentz(), Bipyramid4::Bipyramid4(), Box::Box(), CantellatedCube::CantellatedCube(), Cone::Cone(), ConstantBackground::ConstantBackground(), CosineRippleBox::CosineRippleBox(), CosineRippleGauss::CosineRippleGauss(), CosineRippleLorentz::CosineRippleLorentz(), Cylinder::Cylinder(), DistributionCosine::DistributionCosine(), DistributionGate::DistributionGate(), DistributionGaussian::DistributionGaussian(), DistributionLogNormal::DistributionLogNormal(), DistributionLorentz::DistributionLorentz(), DistributionTrapezoid::DistributionTrapezoid(), Dodecahedron::Dodecahedron(), EllipsoidalCylinder::EllipsoidalCylinder(), FootprintGauss::FootprintGauss(), FootprintSquare::FootprintSquare(), FuzzySphere::FuzzySphere(), GaussSphere::GaussSphere(), HemiEllipsoid::HemiEllipsoid(), HollowSphere::HollowSphere(), HorizontalCylinder::HorizontalCylinder(), Icosahedron::Icosahedron(), LongBoxGauss::LongBoxGauss(), LongBoxLorentz::LongBoxLorentz(), PlatonicOctahedron::PlatonicOctahedron(), PlatonicTetrahedron::PlatonicTetrahedron(), Prism3::Prism3(), Prism6::Prism6(), Profile1DCauchy::Profile1DCauchy(), Profile1DCosine::Profile1DCosine(), Profile1DGate::Profile1DGate(), Profile1DGauss::Profile1DGauss(), Profile1DTriangle::Profile1DTriangle(), Profile1DVoigt::Profile1DVoigt(), Profile2DCauchy::Profile2DCauchy(), Profile2DCone::Profile2DCone(), Profile2DGate::Profile2DGate(), Profile2DGauss::Profile2DGauss(), Profile2DVoigt::Profile2DVoigt(), Pyramid2::Pyramid2(), Pyramid3::Pyramid3(), Pyramid4::Pyramid4(), Pyramid6::Pyramid6(), RotationEuler::RotationEuler(), RotationX::RotationX(), RotationY::RotationY(), RotationZ::RotationZ(), SawtoothRippleBox::SawtoothRippleBox(), SawtoothRippleGauss::SawtoothRippleGauss(), SawtoothRippleLorentz::SawtoothRippleLorentz(), Sphere::Sphere(), Spheroid::Spheroid(), TruncatedCube::TruncatedCube(), TruncatedSphere::TruncatedSphere(), and TruncatedSpheroid::TruncatedSpheroid().

Here is the call graph for this function:

◆ className()

std::string MesoCrystal::className ( ) const
inlinefinalvirtual

Returns the class name, to be hard-coded in each leaf class that inherits from INode.

Implements INode.

Definition at line 34 of file MesoCrystal.h.

34 { return "MesoCrystal"; }

◆ clone()

MesoCrystal * MesoCrystal::clone ( ) const
overridevirtual

Returns a clone of this ISampleNode object.

Implements IParticle.

Definition at line 34 of file MesoCrystal.cpp.

35 {
36  auto* result = new MesoCrystal(m_crystal->clone(), m_meso_formfactor->clone());
37  result->setAbundance(m_abundance);
38  if (m_rotation)
39  result->setRotation(*m_rotation);
40  result->setParticlePosition(m_position);
41  return result;
42 }
R3 m_position
Definition: IParticle.h:79
std::unique_ptr< IRotation > m_rotation
Definition: IParticle.h:80

References MesoCrystal(), IParticle::m_abundance, m_crystal, m_meso_formfactor, IParticle::m_position, and IParticle::m_rotation.

Here is the call graph for this function:

◆ containedMaterials()

std::vector< const Material * > ISampleNode::containedMaterials ( ) const
inherited

Returns set of unique materials contained in this ISampleNode.

Definition at line 25 of file ISampleNode.cpp.

26 {
27  std::vector<const Material*> result;
28  if (const Material* p_material = material())
29  result.push_back(p_material);
30  for (const auto* child : nodeChildren()) {
31  if (const auto* sample = dynamic_cast<const ISampleNode*>(child)) {
32  for (const Material* p_material : sample->containedMaterials())
33  result.push_back(p_material);
34  }
35  }
36  return result;
37 }
virtual std::vector< const INode * > nodeChildren() const
Returns all children.
Definition: INode.cpp:56
Abstract base class for sample components and properties related to scattering.
Definition: ISampleNode.h:27
virtual const Material * material() const
Returns nullptr, unless overwritten to return a specific material.
Definition: ISampleNode.h:36
A wrapper for underlying material implementation.
Definition: Material.h:35

References ISampleNode::material(), and INode::nodeChildren().

Referenced by SampleUtils::Multilayer::ContainsCompatibleMaterials(), SampleToPython::initLabels(), and ISampleNode::isMagnetic().

Here is the call graph for this function:

◆ decompose()

std::vector< std::unique_ptr< IParticle > > IParticle::decompose ( ) const
virtualinherited

Decompose in constituent IParticle objects.

Reimplemented in ParticleComposition.

Definition at line 52 of file IParticle.cpp.

53 {
54  std::vector<std::unique_ptr<IParticle>> result;
55  result.emplace_back(this->clone());
56  return result;
57 }
IParticle * clone() const override=0
Returns a clone of this ISampleNode object.

References IParticle::clone().

Referenced by Compute::Slicing::createParticleInSlice().

Here is the call graph for this function:

◆ isMagnetic()

bool ISampleNode::isMagnetic ( ) const
inherited

Returns true if there is any magnetic material in this ISampleNode.

Definition at line 39 of file ISampleNode.cpp.

40 {
41  const auto materials = containedMaterials();
42  return std::any_of(materials.cbegin(), materials.cend(),
43  [](const Material* mat) { return mat->isMagneticMaterial(); });
44 }
std::vector< const Material * > containedMaterials() const
Returns set of unique materials contained in this ISampleNode.
Definition: ISampleNode.cpp:25

References ISampleNode::containedMaterials().

Referenced by reSample::make().

Here is the call graph for this function:

◆ material()

virtual const Material* ISampleNode::material ( ) const
inlinevirtualinherited

Returns nullptr, unless overwritten to return a specific material.

Reimplemented in Particle, and Layer.

Definition at line 36 of file ISampleNode.h.

36 { return nullptr; }

Referenced by ISampleNode::containedMaterials().

◆ nodeChildren()

std::vector< const INode * > MesoCrystal::nodeChildren ( ) const
overridevirtual

Returns all children.

Reimplemented from IParticle.

Definition at line 44 of file MesoCrystal.cpp.

45 {
46  return std::vector<const INode*>()
48 }
std::vector< const INode * > nodeChildren() const override
Returns all children.
Definition: IParticle.cpp:20

References m_crystal, m_meso_formfactor, and IParticle::nodeChildren().

Here is the call graph for this function:

◆ nodeOffspring()

std::vector< const INode * > INode::nodeOffspring ( ) const
inherited

Returns all descendants.

Definition at line 61 of file INode.cpp.

62 {
63  std::vector<const INode*> result;
64  result.push_back(this);
65  for (const auto* child : nodeChildren()) {
66  for (const auto* p : child->nodeOffspring())
67  result.push_back(p);
68  }
69  return result;
70 }

References INode::nodeChildren().

Here is the call graph for this function:

◆ outerShape()

const IFormFactor* MesoCrystal::outerShape ( ) const
inline

Definition at line 37 of file MesoCrystal.h.

37 { return m_meso_formfactor.get(); }

References m_meso_formfactor.

◆ parDefs()

virtual std::vector<ParaMeta> INode::parDefs ( ) const
inlinevirtualinherited

Returns the parameter definitions, to be hard-coded in each leaf class.

Reimplemented in ConstantBackground, GaussSphere, FuzzySphere, RotationEuler, RotationZ, RotationY, RotationX, Crystal, Layer, HexagonalLattice2D, SquareLattice2D, BasicLattice2D, LayerRoughness, TruncatedSpheroid, TruncatedSphere, TruncatedCube, Spheroid, Sphere, SawtoothRippleLorentz, SawtoothRippleGauss, SawtoothRippleBox, Pyramid6, Pyramid4, Pyramid3, Pyramid2, Prism6, Prism3, PlatonicTetrahedron, PlatonicOctahedron, LongBoxLorentz, LongBoxGauss, Icosahedron, HorizontalCylinder, HollowSphere, HemiEllipsoid, EllipsoidalCylinder, Dodecahedron, Cylinder, CosineRippleLorentz, CosineRippleGauss, CosineRippleBox, Cone, CantellatedCube, Box, Bipyramid4, BarLorentz, BarGauss, Profile2DVoigt, Profile2DCone, Profile2DGate, Profile2DGauss, Profile2DCauchy, Profile1DVoigt, Profile1DCosine, Profile1DTriangle, Profile1DGate, Profile1DGauss, Profile1DCauchy, MisesGaussPeakShape, MisesFisherGaussPeakShape, LorentzFisherPeakShape, GaussFisherPeakShape, IsotropicLorentzPeakShape, IsotropicGaussPeakShape, ParticleLayout, InterferenceTwin, InterferenceRadialParaCrystal, InterferenceHardDisk, Interference2DSuperLattice, Interference2DParaCrystal, Interference1DLattice, DistributionTrapezoid, DistributionCosine, DistributionLogNormal, DistributionGaussian, DistributionLorentz, DistributionGate, ResolutionFunction2DGaussian, PolFilter, FootprintSquare, and FootprintGauss.

Definition at line 51 of file INode.h.

51 { return {}; }

Referenced by INode::checkNodeArgs(), and IFormFactor::pythonConstructor().

◆ particlePosition()

R3 IParticle::particlePosition ( ) const
inlineinherited

Returns particle position.

Definition at line 46 of file IParticle.h.

46 { return m_position; }

References IParticle::m_position.

Referenced by ParticleComposition::decompose().

◆ particleStructure()

const Crystal & MesoCrystal::particleStructure ( ) const

Definition at line 50 of file MesoCrystal.cpp.

51 {
53  return *m_crystal;
54 }

References ASSERT, and m_crystal.

◆ rotate()

IParticle * IParticle::rotate ( const IRotation rotation)
inherited

Rotates the particle, and returns this.

Definition at line 41 of file IParticle.cpp.

42 {
43  if (m_rotation)
45  else
46  m_rotation.reset(rotation.clone());
48  return this;
49 }
IRotation * createProduct(const IRotation &left, const IRotation &right)
Returns concatenated rotation (first right, then left).
Definition: Rotations.cpp:59
const IRotation * rotation() const
Returns rotation object.
Definition: IParticle.cpp:31
IRotation * clone() const override=0
R3 transformed(const R3 &v) const
Definition: Rotations.cpp:42

References IRotation::clone(), createProduct(), IParticle::m_position, IParticle::m_rotation, IParticle::rotation(), and IRotation::transformed().

Referenced by ExemplarySamples::createBoxCompositionRotateZandY(), ExemplarySamples::createCoreShellBoxRotateZandY(), ExemplarySamples::createLayersWithAbsorptionBySLD(), ExemplarySamples::createLayersWithAbsorptionWithFF(), ExemplarySamples::createMagneticRotation(), ExemplarySamples::createRotatedPyramids(), ExemplarySamples::createTransformBox(), and ParticleComposition::decompose().

Here is the call graph for this function:

◆ rotation()

const IRotation * IParticle::rotation ( ) const
inherited

Returns rotation object.

Definition at line 31 of file IParticle.cpp.

32 {
33  return m_rotation.get();
34 }

References IParticle::m_rotation.

Referenced by Particle::Particle(), ParticleComposition::decompose(), IParticle::rotate(), and IParticle::setRotation().

◆ setAbundance()

void IParticle::setAbundance ( double  abundance)
inlineinherited

Sets particle abundance.

Parameters
abundanceproportion of this type of particles normalized to the total number of particles in the layout.

Definition at line 43 of file IParticle.h.

double abundance() const
Definition: IParticle.h:38

References IParticle::abundance(), and IParticle::m_abundance.

Referenced by ParticleLayout::addParticle().

Here is the call graph for this function:

◆ setParticlePosition() [1/2]

void IParticle::setParticlePosition ( double  x,
double  y,
double  z 
)
inlineinherited

Sets relative position of the particle's reference point in the coordinate system of parent.

Parameters
xx-coordinate in nanometers
yy-coordinate in nanometers
zz-coordinate in nanometers

Definition at line 58 of file IParticle.h.

58 { m_position = R3(x, y, z); }

References IParticle::m_position.

◆ setParticlePosition() [2/2]

◆ setRotation()

◆ transferToCPP()

virtual void ICloneable::transferToCPP ( )
inlinevirtualinherited

Used for Python overriding of clone (see swig/tweaks.py)

Definition at line 32 of file ICloneable.h.

◆ translate()

IParticle * IParticle::translate ( R3  translation)
inherited

Member Data Documentation

◆ m_abundance

double IParticle::m_abundance {1.0}
protectedinherited

◆ m_crystal

const std::unique_ptr<Crystal> MesoCrystal::m_crystal
private

Crystalline inner structure.

Definition at line 43 of file MesoCrystal.h.

Referenced by clone(), nodeChildren(), and particleStructure().

◆ m_meso_formfactor

const std::unique_ptr<IFormFactor> MesoCrystal::m_meso_formfactor
private

Outer shape of the mesocrystal.

Definition at line 44 of file MesoCrystal.h.

Referenced by clone(), nodeChildren(), and outerShape().

◆ m_P

◆ m_position

◆ m_rotation


The documentation for this class was generated from the following files: