ParticleFactory

class ParticleFactory

A container for a list of particles. There are effectively three different uses:

  1. A list of particles that exist in a simulation. In this case there can be multiple particles and sites of the same type.

  2. A list of particle types that may exist in a simulation. In this case there can not be multiple particles of the same type. This is enforced by ParticleFactory::unique_particles().

  3. A list of site and bond types (contained within particles) that may exist in a simulation. In this case, there can not be multiple sites or bonds of the same type. This contains site-based and bond-based properties. This is enforced by ParticleFactory::unique_types().

Public Functions

ParticleFactory &unique_particles()

Adjust the site types of added particles to ensure uniqueness. Returns self for chain setting.

ParticleFactory &unique_types()

Only add sites or bonds which are new as a holder for site- or bond- type properties. Note that ParticleFactory::unique_particles() is also applied. Returns self for chain setting.

void check_types(int *num_site_types, int *num_particle_types, int *num_bond_types, int *num_angle_types, int *num_dihedral_types) const

Check that no site, particle, bond, angle or dihedral type is skipped. As particles and sites are added, a never before seen type must be only one higher than the previous maximum index. Types begin with 0.

For example, a particle with sites of type {0, 2} is invalid because the second site of type “2” appears without a previous type “1” site.

In another example, a particle with sites of type {1,2} is invalid because the site type doesn’t begin with 0.

Note: for partial configurations by groups, these checks may not apply.

void check_types() const

Check that no site, particle, bond, angle or dihedral type is skipped.

int check_site_types() const

Check that no site type is skipped. Return number of site types.

int check_particle_types() const

Check that no particle type is skipped. Return number of particle types.

int check_bond_types() const

Check that no bond type is skipped. Return number of bond types.

int check_angle_types() const

Check that no angle type is skipped. Return number of angle types.

int check_dihedral_types() const

Check that no dihedral type is skipped. Return number of dihedral types.

void add(const std::string file_name)

Add particle by file.

void add(const Particle &particle)

Add a particle.

void remove(const int particle_index)

Remove particle by index.

const Particle &particle(const int particle_index) const

Return particle by index.

const std::vector<Particle> &particles() const

Return particles.

int num() const

Return the number of particles.

void replace_position(const int particle_index, const Particle &replacement)

Replace position of the particle by index.

void replace_position(const int particle_index, const int site_index, const Position &replacement)

Replace position of the site by index.

void replace_properties(const int particle_index, const int site_index, const Properties &replacement)

Replace properties of the site by index.

void scale_particle_positions(const int dimen, const double factor)

Scale particle positions by a constant factor in the given dimension.

param dimen:

Scale in this dimension. If -1, scale in all dimensions.

void check(const int dimension = -1) const

Check consistency of dimensionality of positions of particles and sites. By default, for dimension == -1, determine automatically.

int num_site_types() const

Return the number of site types.

int num_sites() const

Return the number of sites.

int num_particle_types() const

Return the number of particle types.

int num_bond_types() const

Return the number of bond types.

int num_bonds() const

Return the number of bonds.

int num_angle_types() const

Return the number of angle types.

int num_angles() const

Return the number of angles.

int num_dihedral_types() const

Return the number of dihedral types.

int num_dihedrals() const

Return the number of dihedrals.

void set_site_type(const int particle, const int site, const int site_type)

Change the site type of a given site in a particle.

void remove(const Group &group)

Remove particles and sites based on the group.

void displace(const int particle_index, const Position &displacement)

Displace the particle with given index.

const ModelParams &model_params() const

Return the model parameters.

void add(const std::shared_ptr<ModelParam> param)

Add a custom type of model parameter.

void set_model_param(const std::string name, const int site_type, const double value)

Modify model parameter of a given site type and name to value.

void set_model_param(const std::string name, const int site_type1, const int site_type2, const double value)

Modify a mixed model parameter of given site types and name to value.

void set_model_param(const std::string name, const std::string filename)

Set mixed model parameters using a file.

void add_model_param(const std::string name, const double value)

Add model parameter of a given name to value.

void add_or_set_model_param(const std::string name, const double value)

Add or set model parameter of a given name to value.

void set_cutoff_min_to_sigma()

Set the minimum cutoff to sigma.

void set_physical_constants(std::shared_ptr<PhysicalConstants> constants)

Set the physical constants in model parameters.

void set_site_physical(const int particle, const int site, const bool phys)

Set site as physical/nonphysical.

void add_property(const std::string name, const double value, const int particle_index)

Add particle property.

void add_property(const std::string name, const double value)

Add property to all particles.

void set_property(const std::string name, const double value, const int particle_index)

Set particle property.

void add_site_property(const std::string name, const double value, const int particle_index, const int site_index)

Add the property of sites in a particle.

void add_or_set_site_property(const std::string name, const double value, const int particle_index, const int site_index)

Add or set the property of sites in a particle.

void set_site_property(const std::string name, const double value, const int particle_index, const int site_index)

Set the property of sites in a particle.

void set_site_property(const int index, const double value, const int particle_index, const int site_index)

Set the property of sites in a particle by index instead of name.