Atom

class Atom

An Atom is a particle in the current Frame.

An atom stores atomic properties such as the atom name and type, the mass and the charge. It also stores arbitrary property using the Property class. Position and velocity are not stored in the Atom class, but in separated arrays in the Frame class.

The atom name is usually an unique identifier (“H1”, “C_a”) while the atom type will be shared between all particles of the same type: “H”, “Ow”, “CH3”.

Public Functions

explicit Atom(std::string name = "")

Create an atom with the given name and set the atom type to be the same as name.

If the atom type exists in the periodic table, the atom mass is set to the matching value. This check is executed with case-insensitive atom type: Na, NA, nA and na all get the Na mass.

Parameters:

name – atomic name for the new atom

Atom(std::string name, std::string type)

Create an atom from the given name and type

If the atom type exists in the periodic table, the atom mass is set to the matching value. This check is executed with case-insensitive atom type: Na, NA, nA and na all get the Na mass.

Parameters:
  • name – atomic name for the new atom

  • type – atomic type for the new atom

inline const std::string &name() const

Get the atom name.

inline const std::string &type() const

Get the atom type.

inline double mass() const

Get the atom mass.

The default mass is set when constructing the atom from the atomic type. To change the default value for a given type, you can use configuration files.

inline double charge() const

Get the atom charge.

The default charge is set when constructing the atom from the atomic type (usually to 0). To change the default value for a given type, you can use configuration files.

inline void set_name(std::string name)

Set the atom name to name.

inline void set_type(std::string type)

Set the atom type to type.

inline void set_mass(double mass)

Set the atom mass to mass.

inline void set_charge(double charge)

Set the atom charge to charge.

optional<std::string> full_name() const

Try to get the full atomic name from the atom type.

This function tries to get the full name corresponding to the current atom type: for example, the full name for He is "Helium". If no name can be found, this function returns nullopt. This check is executed with case-insensitive atom type: Na, NA, nA and na all get the Na full name. To change the value returned for a given type, you can use configuration files.

optional<double> vdw_radius() const

Try to get the Van der Waals radius from the atom type.

This function tries to get the Van der Waals radius corresponding to the current atom type: for example, the radius for He is 1.4 A. If no radius can be found, this function returns nullopt. This check is executed with case-insensitive atom type: Na, NA, nA and na all get the Na radius. To change the value returned for a given type, you can use configuration files.

optional<double> covalent_radius() const

Try to get the covalent radius from the atom type.

This function tries to get the covalent radius corresponding to the current atom type: for example, the radius for He is 0.32 A. If no radius can be found, this function returns nullopt. This check is executed with case-insensitive atom type: Na, NA, nA and na all get the Na radius. To change the value returned for a given type, you can use configuration files.

optional<uint64_t> atomic_number() const

Try to get the atomic number from the atom type.

This function tries to get the atomic number corresponding to the current atom type: for example, the atomic number for He is 2. If no atomic number can be found, this function returns nullopt. This check is executed with case-insensitive atom type: Na, NA, nA and na all get the Na atomic number. To change the value returned for a given type, you can use configuration files.

inline const property_map &properties() const

Get the map of properties associated with this atom. This map might be iterated over to list the properties of the atom, or directly accessed.

inline void set(std::string name, Property value)

Set an arbitrary Property for this atom with the given name and value. If a property with this name already exist, it is replaced with the new value.

inline optional<const Property&> get(const std::string &name) const

Get the Property with the given name for this atom if it exists.

If no property with the given name is found, this function returns nullopt.

template<Property::Kind kind>
inline optional<typename property_metadata<kind>::type> get(const std::string &name) const

Get the Property with the given name for this atom if it exists, and check that it has the required kind.

If no property with the given name is found, this function returns nullopt.

If a property with the given name is found, but has a different kind, this function emits a warning and returns nullopt.