Combine and split¶
Combining two ChemicalSystems¶
- ChemicalSystem.add_other(other: ChemicalSystem) None
Merges another ChemicalSystem into this one.
The number of atoms of
selfincreases by the number of atoms ofother. All atomic coordinates, properties and bonds between atoms will be kept. The total charge ofotherwill be added to the total charge ofself.The regions of each atom do not change in the process. Regions with the same name in
selfandotherare merged.Systems with a lattice can only be merged with systems having a compatible lattice or no lattice at all. Lattices compatibility is checked with the
lattice.is_close()method. If both systems have a lattice, and the lattice is compatible but not exactly the same, the lattice of the original system (self) is kept. If only one side has a lattice, that side determines the lattice of the result.If both sides have a compatible lattice and bonds, merging them is only supported if either both or none of the two have the lattice displacements of the bonds set. If one side has lattice displacements, and the other does not, a ChemicalSystemError is raised.
- ChemicalSystem.__iadd__(arg0: ChemicalSystem) ChemicalSystem
Merges another ChemicalSystem into this one.
Note that lhs += rhs is just the operator version of lhs.add_other(rhs). See ChemicalSystem.add_other for details about merging systems.
- ChemicalSystem.__add__(arg0: ChemicalSystem) ChemicalSystem
Creates a new ChemicalSystem by merging two others.
Note that C = A + B is equivalent to C = copy(A); C.add_other(B). See ChemicalSystem.add_other for details about merging systems.
Splitting of ChemicalSystems into parts¶
- ChemicalSystem.extract_atoms(atom_indices: ArrayLike) ChemicalSystem
Returns a new system build from a subset of atoms.
Bonds within the subset will be preserved, but bonds to atoms not extracted will disappear. The returned system will have the same lattice as the original and a total charge of zero. Atomic attributes and regions of the extracted atoms are preserved, but the returned system does not have any selected atoms.
- ChemicalSystem.split(part_indices: ArrayLike) List[ChemicalSystem]
Splits the system into parts and returns a list of these parts as separate systems.
Accepts a
num_atomslong sequence, assigning the atoms of the system to the parts. The length of the returned list of parts ismax(part_indices)+1.Example: for a 6 atom system and a
part_indicesof[0, 0, 0, 1, 1, 1]a list of two systems will be returned. The system will contain the first three atoms of the original, and the second system the other three atoms.The returned systems will have the same lattice as the original and a total charge of zero. Atomic attributes and regions are preserved, but the returned systems do not have any selected atoms.