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

Description

A particle with a core/shell geometry.

Definition at line 25 of file ParticleCoreShell.h.

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

Public Member Functions

 ParticleCoreShell (const Particle &shell, const Particle &core, R3 relative_core_position=R3(0.0, 0.0, 0.0))
 
 ~ParticleCoreShell () 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...
 
ParticleCoreShellclone () 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...
 
const ParticlecoreParticle () const
 
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...
 
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...
 
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...
 
const ParticleshellParticle () const
 
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::unique_ptr< Particlem_core
 
std::vector< double > m_P
 
R3 m_position
 
std::unique_ptr< IRotationm_rotation
 
std::unique_ptr< Particlem_shell
 

Constructor & Destructor Documentation

◆ ParticleCoreShell()

ParticleCoreShell::ParticleCoreShell ( const Particle shell,
const Particle core,
R3  relative_core_position = R3(0.0, 0.0, 0.0) 
)

Definition at line 22 of file ParticleCoreShell.cpp.

24 {
25  m_core.reset(core.clone());
26  m_core->translate(relative_core_position);
27  m_shell.reset(shell.clone());
28 }
std::unique_ptr< Particle > m_shell
std::unique_ptr< Particle > m_core
Particle * clone() const override
Returns a clone of this ISampleNode object.
Definition: Particle.cpp:34

References Particle::clone(), m_core, and m_shell.

Referenced by clone().

Here is the call graph for this function:

◆ ~ParticleCoreShell()

ParticleCoreShell::~ParticleCoreShell ( )
overridedefault

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 ParticleCoreShell::className ( ) const
inlinefinalvirtual

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

Implements INode.

Definition at line 32 of file ParticleCoreShell.h.

32 { return "ParticleCoreShell"; }

◆ clone()

ParticleCoreShell * ParticleCoreShell::clone ( ) const
overridevirtual

Returns a clone of this ISampleNode object.

Implements IParticle.

Definition at line 32 of file ParticleCoreShell.cpp.

33 {
34  auto* p_result = new ParticleCoreShell(*m_shell, *m_core);
35  p_result->setAbundance(m_abundance);
36  if (m_rotation)
37  p_result->setRotation(*m_rotation);
38  p_result->setParticlePosition(m_position);
39  return p_result;
40 }
R3 m_position
Definition: IParticle.h:79
std::unique_ptr< IRotation > m_rotation
Definition: IParticle.h:80
ParticleCoreShell(const Particle &shell, const Particle &core, R3 relative_core_position=R3(0.0, 0.0, 0.0))

References ParticleCoreShell(), IParticle::m_abundance, m_core, IParticle::m_position, IParticle::m_rotation, and m_shell.

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:

◆ coreParticle()

const Particle* ParticleCoreShell::coreParticle ( ) const
inline

Definition at line 36 of file ParticleCoreShell.h.

36 { return m_core.get(); }

References m_core.

◆ 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 * > ParticleCoreShell::nodeChildren ( ) const
overridevirtual

Returns all children.

Reimplemented from IParticle.

Definition at line 42 of file ParticleCoreShell.cpp.

43 {
44  return std::vector<const INode*>() << IParticle::nodeChildren() << m_core << m_shell;
45 }
std::vector< const INode * > nodeChildren() const override
Returns all children.
Definition: IParticle.cpp:20

References m_core, m_shell, 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:

◆ 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().

◆ 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()

◆ shellParticle()

const Particle* ParticleCoreShell::shellParticle ( ) const
inline

Definition at line 35 of file ParticleCoreShell.h.

35 { return m_shell.get(); }

References m_shell.

◆ 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_core

std::unique_ptr<Particle> ParticleCoreShell::m_core
protected

Definition at line 40 of file ParticleCoreShell.h.

Referenced by ParticleCoreShell(), clone(), coreParticle(), and nodeChildren().

◆ m_P

◆ m_position

◆ m_rotation

std::unique_ptr<IRotation> IParticle::m_rotation
protectedinherited

◆ m_shell

std::unique_ptr<Particle> ParticleCoreShell::m_shell
protected

Definition at line 39 of file ParticleCoreShell.h.

Referenced by ParticleCoreShell(), clone(), nodeChildren(), and shellParticle().


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