AvogadroLibs
1.91.0
|
The Molecule class represents a chemical molecule.
#include <avogadro/core/molecule.h>
Public Types | |
typedef Atom | AtomType |
typedef Bond | BondType |
typedef std::map< unsigned char, std::string > | CustomElementMap |
Public Member Functions | |
Molecule () | |
Molecule (const Molecule &other) | |
Molecule (Molecule &&other) noexcept | |
Molecule & | operator= (const Molecule &other) |
Molecule & | operator= (Molecule &&other) noexcept |
virtual | ~Molecule () |
void | setData (const std::string &name, const Variant &value) |
Variant | data (const std::string &name) const |
bool | hasData (const std::string &name) const |
void | setDataMap (const VariantMap &map) |
const VariantMap & | dataMap () const |
VariantMap & | dataMap () |
Array< unsigned char > & | atomicNumbers () |
const Array< unsigned char > & | atomicNumbers () const |
unsigned char | atomicNumber (Index atomId) const |
bool | setAtomicNumbers (const Core::Array< unsigned char > &nums) |
bool | setAtomicNumber (Index atomId, unsigned char atomicNumber) |
Array< AtomHybridization > & | hybridizations () |
const Array< AtomHybridization > & | hybridizations () const |
AtomHybridization | hybridization (Index atomId) const |
bool | setHybridizations (const Core::Array< AtomHybridization > &hybs) |
bool | setHybridization (Index atomId, AtomHybridization hybridization) |
Array< signed char > & | formalCharges () |
const Array< signed char > & | formalCharges () const |
signed char | formalCharge (Index atomId) const |
bool | setFormalCharges (const Core::Array< signed char > &charges) |
bool | setFormalCharge (Index atomId, signed char charge) |
const Array< Vector2 > & | atomPositions2d () const |
Array< Vector2 > & | atomPositions2d () |
Vector2 | atomPosition2d (Index atomId) const |
bool | setAtomPositions2d (const Core::Array< Vector2 > &pos) |
bool | setAtomPosition2d (Index atomId, const Vector2 &pos) |
const Array< Vector3 > & | atomPositions3d () const |
Array< Vector3 > & | atomPositions3d () |
Vector3 | atomPosition3d (Index atomId) const |
bool | setAtomPositions3d (const Core::Array< Vector3 > &pos) |
bool | setAtomPosition3d (Index atomId, const Vector3 &pos) |
void | setAtomSelected (Index atomId, bool selected) |
bool | atomSelected (Index atomId) const |
bool | isSelectionEmpty () const |
Array< std::pair< Index, Index > > & | bondPairs () |
const Array< std::pair< Index, Index > > & | bondPairs () const |
std::pair< Index, Index > | bondPair (Index bondId) const |
bool | setBondPairs (const Array< std::pair< Index, Index >> &pairs) |
bool | setBondPair (Index bondId, const std::pair< Index, Index > &pair) |
Array< unsigned char > & | bondOrders () |
const Array< unsigned char > & | bondOrders () const |
unsigned char | bondOrder (Index bondId) const |
bool | setBondOrders (const Array< unsigned char > &orders) |
bool | setBondOrder (Index bondId, unsigned char order) |
Graph & | graph () |
const Graph & | graph () const |
bool | hasCustomElements () const |
virtual AtomType | addAtom (unsigned char atomicNumber) |
virtual bool | removeAtom (Index index) |
Remove the specified atom from the molecule. More... | |
virtual bool | removeAtom (const AtomType &atom) |
Remove the specified atom from the molecule. More... | |
virtual void | clearAtoms () |
AtomType | atom (Index index) const |
Index | atomCount () const |
Index | atomCount (unsigned char atomicNumber) const |
Get the number of atoms in the molecule that match atomicNumber. More... | |
virtual bool | removeBond (Index index) |
Remove the specified bond. More... | |
virtual bool | removeBond (const BondType &bond) |
Remove the specified bond. More... | |
virtual void | clearBonds () |
BondType | bond (Index index) const |
BondType | bond (const AtomType &a, const AtomType &b) const |
BondType | bond (Index atomId1, Index atomId2) const |
Index | bondCount () const |
Mesh * | addMesh () |
Add a mesh to the molecule. More... | |
Mesh * | mesh (Index index) |
const Mesh * | mesh (Index index) const |
Index | meshCount () const |
void | clearMeshes () |
Cube * | addCube () |
Add a cube to the molecule. More... | |
Cube * | cube (Index index) |
const Cube * | cube (Index index) const |
Index | cubeCount () const |
void | clearCubes () |
std::vector< Cube * > | cubes () |
Get the cubes vector set (if present) for the molecule. More... | |
const std::vector< Cube * > | cubes () const |
std::string | formula (const std::string &delimiter="", int showCountsOver=1) const |
double | mass () const |
void | setBasisSet (BasisSet *basis) |
BasisSet * | basisSet () |
const BasisSet * | basisSet () const |
Array< double > | vibrationFrequencies () const |
void | setVibrationFrequencies (const Array< double > &freq) |
Array< double > | vibrationIntensities () const |
void | setVibrationIntensities (const Array< double > &intensities) |
Array< Vector3 > | vibrationLx (int mode) const |
void | setVibrationLx (const Array< Array< Vector3 >> &lx) |
void | perceiveBondsSimple () |
int | coordinate3dCount () |
bool | setCoordinate3d (int coord) |
int | coordinate3d () const |
bool | setCoordinate3d (const Array< Vector3 > &coords, int index) |
const CustomElementMap & | customElementMap () const |
void | setCustomElementMap (const CustomElementMap &map) |
virtual BondType | addBond (Index atom1, Index atom2, unsigned char order=1) |
virtual BondType | addBond (const AtomType &atom1, const AtomType &atom2, unsigned char order=1) |
virtual bool | removeBond (Index atom1, Index atom2) |
Remove the specified bond. More... | |
virtual bool | removeBond (const AtomType &atom1, const AtomType &atom2) |
Remove the specified bond. More... | |
Array< BondType > | bonds (const AtomType &a) |
Get all bonds to a . More... | |
Array< BondType > | bonds (Index a) |
Get all bonds to a . More... | |
void | setUnitCell (UnitCell *uc) |
UnitCell * | unitCell () |
const UnitCell * | unitCell () const |
Protected Member Functions | |
void | updateGraph () const |
Protected Attributes | |
Graph | m_graph |
bool | m_graphDirty |
VariantMap | m_data |
CustomElementMap | m_customElementMap |
Array< unsigned char > | m_atomicNumbers |
Array< Vector2 > | m_positions2d |
Array< Vector3 > | m_positions3d |
Array< Array< Vector3 > > | m_coordinates3d |
Array< AtomHybridization > | m_hybridizations |
Array< signed char > | m_formalCharges |
Array< double > | m_vibrationFrequencies |
Array< double > | m_vibrationIntensities |
Array< Array< Vector3 > > | m_vibrationLx |
Array< std::pair< Index, Index > > | m_bondPairs |
Array< unsigned char > | m_bondOrders |
std::vector< bool > | m_selectedAtoms |
std::vector< Mesh * > | m_meshes |
std::vector< Cube * > | m_cubes |
BasisSet * | m_basisSet |
UnitCell * | m_unitCell |
typedef std::map<unsigned char, std::string> CustomElementMap |
Type for custom element map.
Molecule | ( | ) |
Creates a new, empty molecule.
void setData | ( | const std::string & | name, |
const Variant & | value | ||
) |
Sets the data value with name
to value
.
Variant data | ( | const std::string & | name | ) | const |
Returns the data value for name
.
bool hasData | ( | const std::string & | name | ) | const |
Returns true if the molecule has data with the given key, false otherwise.
void setDataMap | ( | const VariantMap & | map | ) |
Set the molecule's variant data to the entries in map.
const VariantMap& dataMap | ( | ) | const |
Return the molecule's variant data.
VariantMap& dataMap | ( | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Array<unsigned char>& atomicNumbers | ( | ) |
Returns a vector of atomic numbers for the atoms in the molecule.
const Array<unsigned char>& atomicNumbers | ( | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
unsigned char atomicNumber | ( | Index | atomId | ) | const |
Get the atomic number for the requested atom.
atomId | The index of the atom. |
bool setAtomicNumbers | ( | const Core::Array< unsigned char > & | nums | ) |
Replace the current array of atomic numbers.
nums | The new atomic number array. Must be of length atomCount(). |
bool setAtomicNumber | ( | Index | atomId, |
unsigned char | atomicNumber | ||
) |
Set the atomic number of a single atom.
atomId | The index of the atom to modify. |
atomicNumber | The new atomic number. |
Array<AtomHybridization>& hybridizations | ( | ) |
Returns a vector of hybridizations for the atoms in the moleucle.
const Array<AtomHybridization>& hybridizations | ( | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
AtomHybridization hybridization | ( | Index | atomId | ) | const |
Get the hybridization for the requested atom.
atomId | The index of the atom. |
bool setHybridizations | ( | const Core::Array< AtomHybridization > & | hybs | ) |
Replace the current array of hybridizations.
hybs | The new hybridization array. Must be of length atomCount(). |
bool setHybridization | ( | Index | atomId, |
AtomHybridization | hybridization | ||
) |
Set the hybridization of a single atom.
atomId | The index of the atom to modify. |
charge | The new hybridization. |
Array<signed char>& formalCharges | ( | ) |
Returns a vector of formal charges for the atoms in the moleucle.
const Array<signed char>& formalCharges | ( | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
signed char formalCharge | ( | Index | atomId | ) | const |
Get the formal charge for the requested atom.
atomId | The index of the atom. |
bool setFormalCharges | ( | const Core::Array< signed char > & | charges | ) |
Replace the current array of formal charges.
charges | The new formal charge array. Must be of length atomCount(). |
bool setFormalCharge | ( | Index | atomId, |
signed char | charge | ||
) |
Set the formal charge of a single atom.
atomId | The index of the atom to modify. |
charge | The new formal charge. |
Returns a vector of 2d atom positions for the atoms in the molecule.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Get the 2D position of a single atom.
atomId | The index of the atom. |
bool setAtomPositions2d | ( | const Core::Array< Vector2 > & | pos | ) |
Replace the current array of 2D atomic coordinates.
pos | The new coordinate array. Must be of length atomCount(). |
Set the 2D position of a single atom.
atomId | The index of the atom to modify. |
pos | The new position of the atom. |
const Array<Vector3>& atomPositions3d | ( | ) | const |
Returns a vector of 2d atom positions for the atoms in the molecule.
Array<Vector3>& atomPositions3d | ( | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Vector3 atomPosition3d | ( | Index | atomId | ) | const |
Get the 3D position of a single atom.
atomId | The index of the atom. |
bool setAtomPositions3d | ( | const Core::Array< Vector3 > & | pos | ) |
Replace the current array of 3D atomic coordinates.
pos | The new coordinate array. Must be of length atomCount(). |
bool setAtomPosition3d | ( | Index | atomId, |
const Vector3 & | pos | ||
) |
Set the 3D position of a single atom.
atomId | The index of the atom to modify. |
pos | The new position of the atom. |
void setAtomSelected | ( | Index | atomId, |
bool | selected | ||
) |
Set whether the specified atom is selected or not.
bool atomSelected | ( | Index | atomId | ) | const |
Query whether the supplied atom index has been selected.
bool isSelectionEmpty | ( | ) | const |
Returns whether the selection is empty or not
Returns a vector of pairs of atom indices of the bonds in the molecule.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Get the set of bonded atoms corresponding to bondId.
bondId | The index of the requested bond. |
Replace the current array of bonded atoms.
pairs | The array. |
Set the bonded atoms for a bond.
bondId | The bond to modify. |
pair | The new bond pair. |
Array<unsigned char>& bondOrders | ( | ) |
Returns a vector of the bond orders for the bonds in the molecule.
const Array<unsigned char>& bondOrders | ( | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
unsigned char bondOrder | ( | Index | bondId | ) | const |
Get the order of a bond.
bondId | The id of the bond. |
bool setBondOrders | ( | const Array< unsigned char > & | orders | ) |
Replace the current array of bond orders.
orders | The new array. |
bool setBondOrder | ( | Index | bondId, |
unsigned char | order | ||
) |
Set the order of a bond in the molecule.
bondId | The bond's index. |
order | The new order of the bond. |
Graph& graph | ( | ) |
Returns the graph for the molecule.
const Graph& graph | ( | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
const CustomElementMap& customElementMap | ( | ) | const |
A map of custom element atomic numbers to string identifiers. These ids can be used to override the generic custom element names returned by the Elements class, and should be somewhat meaningful to the user.
void setCustomElementMap | ( | const CustomElementMap & | map | ) |
A map of custom element atomic numbers to string identifiers. These ids can be used to override the generic custom element names returned by the Elements class, and should be somewhat meaningful to the user.
bool hasCustomElements | ( | ) | const |
|
virtual |
Adds an atom to the molecule.
Reimplemented in Molecule.
|
virtual |
index | The index of the atom to be removed. |
Reimplemented in Molecule.
|
virtual |
atom | The atom to be removed. |
Reimplemented in Molecule.
|
virtual |
Remove all atoms from the molecule.
Index atomCount | ( | ) | const |
Index atomCount | ( | unsigned char | atomicNumber | ) | const |
atomicNumber | The atomic number to match on. |
Create a new bond in the molecule.
atom1 | The first atom in the bond. |
atom2 | The second order in the bond. |
order | The bond order. |
Reimplemented in Molecule.
|
virtual |
Create a new bond in the molecule.
atom1 | The first atom in the bond. |
atom2 | The second order in the bond. |
order | The bond order. |
Reimplemented in Molecule.
|
virtual |
index | The index of the bond to be removed. |
Reimplemented in Molecule.
|
virtual |
bond | The bond to be removed. |
Reimplemented in Molecule.
atom1 | One atom in the bond. |
atom2 | The other atom in the bond. |
Reimplemented in Molecule.
atom1 | One atom in the bond. |
atom2 | The other atom in the bond. |
Reimplemented in Molecule.
|
virtual |
Remove all bonds from the molecule.
Returns the bond between atoms a
and b
.
Index bondCount | ( | ) | const |
Returns the number of bonds in the molecule.
Mesh* addMesh | ( | ) |
Cube* addCube | ( | ) |
std::vector<Cube*> cubes | ( | ) |
std::string formula | ( | const std::string & | delimiter = "" , |
int | showCountsOver = 1 |
||
) | const |
Returns the chemical formula of the molecule.
delimiter | Delimiter to insert between tokens, defaults to none. |
showCountsOver | Show atom counts above this (defaults to 1). |
double mass | ( | ) | const |
void setBasisSet | ( | BasisSet * | basis | ) |
Set the basis set for the molecule, note that the molecule takes ownership of the object.
BasisSet* basisSet | ( | ) |
Get the basis set (if present) for the molecule.
void setUnitCell | ( | UnitCell * | uc | ) |
The unit cell for this molecule. May be nullptr for non-periodic structures.
UnitCell* unitCell | ( | ) |
The unit cell for this molecule. May be nullptr for non-periodic structures.
const UnitCell* unitCell | ( | ) | const |
The unit cell for this molecule. May be nullptr for non-periodic structures.
void perceiveBondsSimple | ( | ) |
Perceives bonds in the molecule based on the 3D coordinates of the atoms.
|
protected |
Update the graph to correspond to the current molecule.