26 : m_par_distribution(par_distr)
28 setName(
"ParticleDistribution");
58 std::unique_ptr<ParameterPool> P_pool{
mP_particle->createParameterTree()};
60 double main_par_value = P_pool->getUniqueMatch(main_par_name)->value();
63 std::map<std::string, double> linked_ratios;
66 main_par_value == 0 ? 1.0 : P_pool->getUniqueMatch(name)->value() / main_par_value;
75 for (
auto it = linked_ratios.begin(); it != linked_ratios.end(); ++it)
76 P_new_pool->setUniqueMatchValue(it->first, main_sample.value * it->second);
85 std::vector<const INode*> result = std::vector<const INode*>() <<
mP_particle;
87 result.push_back(dist);
Defines classes representing one-dimensional distributions.
Defines many exception classes in namespace Exceptionss.
Defines interface IParticle.
Defines class ParameterPool.
Defines namespace ParameterUtils.
Defines class ParticleDistribution.
Defines class RealParameter.
void setAbundance(double abundance)
Sets particle abundance.
ParameterPool * createParameterTree() const
Creates new parameter pool, with all local parameters and those of its children.
void registerChild(INode *node)
RealParameter & registerParameter(const std::string &name, double *parpointer)
void setName(const std::string &name)
Pure virtual base class for Particle, ParticleComposition, ParticleCoreShell, MesoCrystal.
IParticle * clone() const override=0
Returns a clone of this ISample object.
Pure virtual interface for rotations.
A parametric distribution function, for use with any model parameter.
const IDistribution1D * getDistribution() const
std::vector< ParameterSample > generateSamples() const
generate list of sampled values with their weight
std::vector< std::string > getLinkedParameterNames() const
get list of linked parameter names
std::string getMainParameterName() const
get the main parameter's name
void setUniqueMatchValue(const std::string &pattern, double value)
Sets value of the one parameter that matches pattern ('*' allowed), or throws.
A parameter value with a weight, as obtained when sampling from a distribution.
A particle type that is a parametric distribution of IParticle's.
ParameterDistribution m_par_distribution
const IParticle & prototype() const
Returns the prototype particle, used for generating multiple ones.
std::vector< const INode * > getChildren() const override final
Returns a vector of children (const).
std::unique_ptr< IParticle > mP_particle
SafePointerVector< IParticle > generateParticles() const
Returns list of new particles generated according to a distribution.
ParameterDistribution parameterDistribution() const
Returns the distributed parameter data.
std::string mainUnits() const
ParticleDistribution(const IParticle &prototype, const ParameterDistribution &par_distr)
void rotate(const IRotation &rotation) override final
Applies the given rotation to the particle.
ParticleDistribution * clone() const override final
Returns a clone of this ISample object.
void translate(kvector_t translation) override final
Translates the particle with the given vector.
A vector of pointers, owned by *this, with methods to handle them safely.
void push_back(T *pointer)
std::string poolParameterUnits(const IParameterized &node, const std::string &parName)
Returns units of main parameter.