inquanto.geometries
- class GeometryMolecular(geometry=None, distance_units='angstrom')
Bases:
Geometry
Geometry class for handling and manipulating molecular systems.
Various transformations of the system in 3D space are supported. The default units are Angstroms and degrees. Alternatively, one can use Bohrs and radians.
- Parameters:
geometry (
Union
[str
,DataFrame
,list
,None
], default:None
) – Geometrical information - can be a list of lists (e.g[['H', [0, 0, 0]], ['H', [0, 0, 1]]]
), a zmatrix string, xyz coordinates as a string orpandas.DataFrame
.distance_units (
str
, default:"angstrom"
) – Specification of distance units. Supported units are Angstroms ("angstrom"
) and Bohrs ("bohr"
).
- add_atom(element, position=None)
Add an atom to the geometry.
- Parameters:
- Returns:
DataFrame
– The updateddataframe
object.
- align_bond_to_axis(atom_ids, axis)
Align any bond to an axis.
Rotate and translate the geometry to align the bond defined by the elements of the
atom_ids
list to a co-ordinate axis.Align
- Parameters:
:param
"y"
: :param"z"
.:- Returns:
DataFrame
– The updateddataframe
object.
- align_bond_to_vector(atom_ids, vector)
Align any bond to any user-defined vector.
Rotate and translate the geometry to align the bond defined by the elements of the
atom_ids
list to a vector.
- align_to_plane(atom_ids, vectors)
Rotate and translate the geometry such that three atoms lie in the plane defined by the vectors provided.
- Parameters:
- Returns:
DataFrame
– The updateddataframe
object.
- align_to_xy_plane(atom_ids=None)
Align any three atoms to the \(xy\) plane.
Rotate and translate the geometry such that the plane defined by the three atom indices in
atom_ids
becomes the \(xy\) plane.
- align_to_xz_plane(atom_ids=None)
Align any three atoms to the \(xz\) plane.
Rotate and translate the geometry such that the plane defined by the three atom indices in the
atom_ids
variable becomes the \(xz\) plane.
- align_to_yz_plane(atom_ids=None)
Align any three atoms to the \(yz\) plane.
Rotate and translate the geometry such that the plane defined by the three atom indices in
atom_ids
becomes the \(yz\) plane.
- property atomic_coordinates: ndarray[Any, dtype[_ScalarType_co]]
Get an array of position vectors of each atom in the geometry.
Each row corresponds to one position vector.
- Returns:
An array of floats where each row at index \(i\) contains the \(x, y, z\) coordinates of atom \(i\).
- bond_angle(atom_ids, units='deg')
Compute the bond angle defined by the three atoms indexed by the elements of
atom_ids
.The angle is at the middle atom, or second index in the
atom_ids
list. For example, to compute the bond angle at the oxygen atom in water, one would pass[index of H1, index of O, index of H2]
.
- bond_length(atom_ids)
Compute the inter-nuclear separation between the two atoms indexed by the elements of
atom_ids
.
- build_2atom_chain(atom='H', num_pair=4, d_intra=0.75, d_inter=0.75)
Construct xyz geometry for a chain of homonuclear diatomics.
- build_alternating_ring(element_a, a, bb, b, n)
Builds a ring geometry of atoms as -A–B–A–B-…
- build_rectangle(element, dx, nx, dy=0, ny=1)
Builds a rectangular grid geometry of atoms.
- Parameters:
- Return type:
- build_ring(element, d, n)
Builds a ring geometry of atoms.
- compute_distance_matrix()
Compute a distance matrix.
Each \(i\), \(j\) th element is the internuclear separation between atom \(i\) and \(j\).
- property dataframe: DataFrame
Return the geometry in a
pandas.DataFrame
object.Each row corresponds to an atom in the geometry and each column holds the atomic symbol of an element and their \(x, y, z\) coordinates.
- Returns:
An
pandas.DataFrame
containing a geometry.
- delete_atom(atom_index)
Delete an atom from the geometry.
- dihedral_angle(atom_ids, units='deg')
Compute the dihedral angle defined by the four atoms specified in
atom_ids
.
- static from_xyz_string(xyz_string, distance_units='angstrom')
Create a
Geometry
object from a string.- Parameters:
- Returns:
Geometry
– AGeometry
object containing the geometry provided in thexyz_string
argument.
- classmethod load_xyz(filename, distance_units='angstrom')
Load geometry from an xyz file.
Currently, only the xyz file format is supported.
- load_zmatrix(filename, distance_units='angstrom')
Load a z-matrix from file into the
zmatrix
attribute.
- modify_bond_angle(atom_ids, theta, units='deg')
Change the bond angle at the atom with the index that matches the second element of
atom_ids
.The atom indexed by the third element of
atom_ids
has its position updated.
- modify_bond_angle_by_group(atom_ids, theta, group, units='deg')
Modify the bond angle between two groups of atoms.
Modify the bond angle at the second element of
atom_ids
, moving the third element ofatom_ids
and the subgroup it belongs to by the same angle. Elements 1 and 2 ofatom_ids
must belong to a different subgroup to the final element. The structure within each subgroup is preserved.
- modify_bond_length(atom_ids, new_bond_length)
Change the internuclear separation between two atoms.
The first atom in
atom_ids
is fixed, the second atom is moved.
- modify_bond_length_by_group(atom_ids, bond_length, group)
Modify the bond length connecting two groups of atoms.
Modify the bond length connecting two atoms in different subgroups. Each subgroup’s internal structure is preserved. The two atoms specified in
atom_ids
must belong to different subgroups as defined by the group argument. The subgroup translated is the one containing the second atom indexed inatom_ids
.
- modify_dihedral_angle(atom_ids, theta, units='deg')
Modify a dihedral angle.
Change the dihedral angle defined by the four atoms indexed by the elements of
atom_ids
. The atom indexed by the last element has its position updated.
- modify_dihedral_angle_by_group(atom_ids, theta, group, units='deg')
Modify a dihedral angle between two groups of atoms.
Modify the dihedral angle defined by atoms indexed in
atom_ids
. The structure within each group is retained. The 3rd and 4th elements ofatom_ids
must belong to the same label, and be different to the label defined by atoms indexed by the 1st and 2nd elements.
- randomize_xyz(sigma=0.05, seed=0, freeze_atoms=None)
Add random numbers to the xyz geometry.
The random numbers are sampled from Gaussian distributions centred at each atomic position.
- rescale_position_vectors(factor)
Multiply the atomic position vectors by a constant factor.
- rotate_around_axis(theta, axis, units='deg')
Rotate the geometry around one of the coordinate axes.
- rotate_around_vector(vector, theta, units='deg')
Rotate the geometry around a vector defined by input
theta
.- Parameters:
- Returns:
DataFrame
– The updateddataframe
object.
- save_json(fn)
Write the current
self.df
property of theGeometry
object to a json file.
- save_xyz(filename)
Save geometry to an xyz file.
Currently, only the file format xyz is supported.
- scan_bond_angle(atom_ids, bond_angles, units='deg')
Construct many
Geometry
objects corresponding to a scan of a bond angle.Create a list of
Geometry
objects that correspond to a scan of the potential energy surface by bond angle. The modification of the angle moves only one atom - the atom corresponding to the third element of theatom_ids
argument by index.
- scan_bond_angle_by_group(atom_ids, bond_angles, group, units='deg')
Scan a bond angle between two different groups while retaining the geometry of each group.
- Parameters:
- Returns:
list
– A list of geometries corresponding to the description andbond_angles
passed in.
- scan_bond_length(atom_ids, bond_lengths)
Construct many
Geometry
objects corresponding to a scan of bond lengths.Create
Geometry
objects corresponding to a scan of the potential energy surface by bond length. The bond stretching moves only one atom - the atom corresponding to the second element of theatom_ids
argument by index.
- scan_bond_length_by_group(atom_ids, bond_lengths, group)
Scan a bond length between two different subgroups while retaining the geometry of each subgroup.
- scan_dihedral_angle(atom_ids, dihedral_angles, units='deg')
Construct many
Geometry
objects corresponding to a scan of dihedral angles.Create
Geometry
objects corresponding to a scan of the potential energy surface by dihedral angle. The modification of the angle moves only one atom - the atom corresponding to the fourth element of theatom_ids
argument by index.
- scan_dihedral_angle_by_group(atom_ids, dihedral_angles, group, units='deg')
Scan a dihedral angle between atoms in different groups while retaining the geometry of each group.
- Parameters:
- Returns:
list
– A list of geometries corresponding to the description and dihedral angles passed in.
- set_groups(target, source, mapping=None)
Set group information for the atoms in the system.
Target specifies the heading of the new column created in the underlying
dataframe
attribute of the geometry. The source argument can be either adict
, where the keys are the labels of the group and the values are the atom indices corresponding to the label, or astring
. If source is adict
, the mapping argument does nothing. If source is astring
, it must be an existing column heading indataframe
. In which case, the mapping argument must be provided as a callable function which modifies the existing entries in the source column and inserts them into the new target column.
- set_subgroups(target, pattern, subgroup)
Set subgroups on the target grouping via regular expression pattern.
- to_angstrom()
Convert the geometry in the
dataframe
attribute from Bohrs to Angstroms.- Returns:
DataFrame
– The updateddataframe
object.
- to_bohr()
Convert the geometry in the
dataframe
attribute from Angstroms to Bohrs.- Returns:
DataFrame
– The updateddataframe
object.
- to_zmatrix()
Map the geometry held in the
dataframe
attribute to a z-matrix.Atoms are taken in order, and z-matrix sequences are defined backwards through the geometry. For example, the first dihedral is defined by the 4th, 3rd, 2nd and 1st atoms in the geometry.
- translate_by_vector(v)
Translate all atoms in the geometry by a vector,
v
.
- property xyz: list[tuple[str, tuple[float, float, float]]]
Return the geometry in xyz format.
- Returns:
The geometry as a list of lists of atom symbols and positions
- xyz_to_df(xyz)
Convert the xyz geometry to a
pandas.DataFrame
.
- class GeometryPeriodic(geometry=None, unit_cell=None, distance_units='angstrom')
Bases:
Geometry
Geometry class for handling periodic systems.
Various transformations and extensions of the system in 3D space are supported. The default units are Angstroms and degrees. Alternatively, one can use bohrs and radians.
- Parameters:
geometry (
Union
[str
,DataFrame
,list
,None
], default:None
) – Geometrical information - can be a list of lists (e.g[['H', [0, 0, 0]], ['H', [0, 0, 1]]]
), xyz coordinates as a string orpandas.DataFrame
.unit_cell (
Optional
[ndarray
[Any
,dtype
[TypeVar
(_ScalarType_co
, bound=generic
, covariant=True)]]], default:None
) – The unit cell as a 3x3 array with each row being one cell vector.distance_units (str) – Specification of distance units. Supported units are Angstrom (
"angstrom"
) and Bohrs ("bohr"
).
- add_atom(element, position=None)
Add an atom to the geometry.
- Parameters:
- Returns:
DataFrame
– The updateddataframe
object.
- align_bond_to_axis(atom_ids, axis)
Align any bond to an axis.
Rotate and translate the geometry to align the bond defined by the elements of the
atom_ids
list to a co-ordinate axis.Align
- Parameters:
:param
"y"
: :param"z"
.:- Returns:
DataFrame
– The updateddataframe
object.
- align_bond_to_vector(atom_ids, vector)
Align any bond to any user-defined vector.
Rotate and translate the geometry to align the bond defined by the elements of the
atom_ids
list to a vector.
- align_to_plane(atom_ids, vectors)
Rotate and translate the geometry such that three atoms lie in the plane defined by the vectors provided.
- Parameters:
- Returns:
DataFrame
– The updateddataframe
object.
- align_to_xy_plane(atom_ids=None)
Align any three atoms to the \(xy\) plane.
Rotate and translate the geometry such that the plane defined by the three atom indices in
atom_ids
becomes the \(xy\) plane.
- align_to_xz_plane(atom_ids=None)
Align any three atoms to the \(xz\) plane.
Rotate and translate the geometry such that the plane defined by the three atom indices in the
atom_ids
variable becomes the \(xz\) plane.
- align_to_yz_plane(atom_ids=None)
Align any three atoms to the \(yz\) plane.
Rotate and translate the geometry such that the plane defined by the three atom indices in
atom_ids
becomes the \(yz\) plane.
- property atomic_coordinates: ndarray[Any, dtype[_ScalarType_co]]
Get an array of position vectors of each atom in the geometry.
Each row corresponds to one position vector.
- Returns:
An array of floats where each row at index \(i\) contains the \(x, y, z\) coordinates of atom \(i\).
- bond_angle(atom_ids, units='deg')
Compute the bond angle defined by the three atoms indexed by the elements of
atom_ids
.The angle is at the middle atom, or second index in the
atom_ids
list. For example, to compute the bond angle at the oxygen atom in water, one would pass[index of H1, index of O, index of H2]
.
- bond_length(atom_ids)
Compute the inter-nuclear separation between the two atoms indexed by the elements of
atom_ids
.
- build_2atom_chain(atom='H', num_pair=4, d_intra=0.75, d_inter=0.75)
Construct xyz geometry for a chain of homonuclear diatomics.
- build_alternating_ring(element_a, a, bb, b, n)
Builds a ring geometry of atoms as -A–B–A–B-…
- build_rectangle(element, dx, nx, dy=0, ny=1)
Builds a rectangular grid geometry of atoms.
- Parameters:
- Return type:
- build_ring(element, d, n)
Builds a ring geometry of atoms.
- build_supercell(dimensions)
Construct a supercell.
Repeat the unit cell geometry in each direction according to the elements of the provided dimensions list.
- compute_distance_matrix()
Compute a distance matrix.
Each \(i\), \(j\) th element is the internuclear separation between atom \(i\) and \(j\).
- property dataframe: DataFrame
Return the geometry in a
pandas.DataFrame
object.Each row corresponds to an atom in the geometry and each column holds the atomic symbol of an element and their \(x, y, z\) coordinates.
- Returns:
An
pandas.DataFrame
containing a geometry.
- delete_atom(atom_index)
Delete an atom from the geometry.
- dihedral_angle(atom_ids, units='deg')
Compute the dihedral angle defined by the four atoms specified in
atom_ids
.
- static from_xyz_string(xyz_string, distance_units='angstrom')
Create a
Geometry
object from a string.- Parameters:
- Returns:
Geometry
– AGeometry
object containing the geometry provided in thexyz_string
argument.
- classmethod load_xyz(filename, distance_units='angstrom')
Load geometry from an xyz file.
Currently, only the xyz file format is supported.
- modify_bond_angle(atom_ids, theta, units='deg')
Change the bond angle at the atom with the index that matches the second element of
atom_ids
.The atom indexed by the third element of
atom_ids
has its position updated.
- modify_bond_angle_by_group(atom_ids, theta, group, units='deg')
Modify the bond angle between two groups of atoms.
Modify the bond angle at the second element of
atom_ids
, moving the third element ofatom_ids
and the subgroup it belongs to by the same angle. Elements 1 and 2 ofatom_ids
must belong to a different subgroup to the final element. The structure within each subgroup is preserved.
- modify_bond_length(atom_ids, new_bond_length)
Change the internuclear separation between two atoms.
The first atom in
atom_ids
is fixed, the second atom is moved.
- modify_bond_length_by_group(atom_ids, bond_length, group)
Modify the bond length connecting two groups of atoms.
Modify the bond length connecting two atoms in different subgroups. Each subgroup’s internal structure is preserved. The two atoms specified in
atom_ids
must belong to different subgroups as defined by the group argument. The subgroup translated is the one containing the second atom indexed inatom_ids
.
- modify_dihedral_angle(atom_ids, theta, units='deg')
Modify a dihedral angle.
Change the dihedral angle defined by the four atoms indexed by the elements of
atom_ids
. The atom indexed by the last element has its position updated.
- modify_dihedral_angle_by_group(atom_ids, theta, group, units='deg')
Modify a dihedral angle between two groups of atoms.
Modify the dihedral angle defined by atoms indexed in
atom_ids
. The structure within each group is retained. The 3rd and 4th elements ofatom_ids
must belong to the same label, and be different to the label defined by atoms indexed by the 1st and 2nd elements.
- randomize_xyz(sigma=0.05, seed=0, freeze_atoms=None)
Add random numbers to the xyz geometry.
The random numbers are sampled from Gaussian distributions centred at each atomic position.
- rescale_position_vectors(factor)
Multiply the atomic position vectors by a constant factor.
- rotate_around_axis(theta, axis, units='deg')
Rotate the geometry around one of the coordinate axes.
- rotate_around_vector(vector, theta, units='deg')
Rotate the geometry around a vector defined by input
theta
.- Parameters:
- Returns:
DataFrame
– The updateddataframe
object.
- save_json(fn)
Write the current
self.df
property of theGeometry
object to a json file.
- save_xyz(filename)
Save geometry to an xyz file.
Currently, only the file format xyz is supported.
- scan_bond_angle(atom_ids, bond_angles, units='deg')
Construct many
Geometry
objects corresponding to a scan of a bond angle.Create a list of
Geometry
objects that correspond to a scan of the potential energy surface by bond angle. The modification of the angle moves only one atom - the atom corresponding to the third element of theatom_ids
argument by index.
- scan_bond_angle_by_group(atom_ids, bond_angles, group, units='deg')
Scan a bond angle between two different groups while retaining the geometry of each group.
- Parameters:
- Returns:
list
– A list of geometries corresponding to the description andbond_angles
passed in.
- scan_bond_length(atom_ids, bond_lengths)
Construct many
Geometry
objects corresponding to a scan of bond lengths.Create
Geometry
objects corresponding to a scan of the potential energy surface by bond length. The bond stretching moves only one atom - the atom corresponding to the second element of theatom_ids
argument by index.
- scan_bond_length_by_group(atom_ids, bond_lengths, group)
Scan a bond length between two different subgroups while retaining the geometry of each subgroup.
- scan_dihedral_angle(atom_ids, dihedral_angles, units='deg')
Construct many
Geometry
objects corresponding to a scan of dihedral angles.Create
Geometry
objects corresponding to a scan of the potential energy surface by dihedral angle. The modification of the angle moves only one atom - the atom corresponding to the fourth element of theatom_ids
argument by index.
- scan_dihedral_angle_by_group(atom_ids, dihedral_angles, group, units='deg')
Scan a dihedral angle between atoms in different groups while retaining the geometry of each group.
- Parameters:
- Returns:
list
– A list of geometries corresponding to the description and dihedral angles passed in.
- set_groups(target, source, mapping=None)
Set group information for the atoms in the system.
Target specifies the heading of the new column created in the underlying
dataframe
attribute of the geometry. The source argument can be either adict
, where the keys are the labels of the group and the values are the atom indices corresponding to the label, or astring
. If source is adict
, the mapping argument does nothing. If source is astring
, it must be an existing column heading indataframe
. In which case, the mapping argument must be provided as a callable function which modifies the existing entries in the source column and inserts them into the new target column.
- set_subgroups(target, pattern, subgroup)
Set subgroups on the target grouping via regular expression pattern.
- to_angstrom()
Convert the geometry in the
dataframe
attribute from Bohrs to Angstroms.- Returns:
DataFrame
– The updateddataframe
object.
- to_bohr()
Convert the geometry in the
dataframe
attribute from Angstroms to Bohrs.- Returns:
DataFrame
– The updateddataframe
object.
- translate_by_vector(v)
Translate all atoms in the geometry by a vector,
v
.