core
Utility functions for dealing with Atoms.
check_charge_and_spin ¶
check_charge_and_spin(
atoms: Atoms,
charge: int | None = None,
spin_multiplicity: int | None = None,
) -> tuple[int, int]
Check the validity of a given charge
and multiplicity
. If they are None
, then
set the charge and/or spin multiplicity of a molecule using the following routine,
raising a ValueError
if there is an incompatibility.
Charges:
-
If
charge
is specified, that is the charge. -
If
atoms.charge
is present, that is the charge. -
If
atoms.has("initial_charges")
, thenatoms.get_initial_charges.sum()
is the charge. -
If
spin_multiplicity
is set, set the charge to the smallest physically possible value. -
Otherwise, set to 0.
Spin multiplicity:
-
If
spin_multiplicity
is specified, that is the spin multiplicity. -
If
atoms.spin_multiplicity
is present, that is the spin multiplicity. -
If
atoms.has("initial_magmoms")
, thennp.abs(atoms.get_initial_magnetic_moments().sum())+1
is the spin multiplicity. -
If none of the above, use Pymatgen to identify the lowest physically possible spin multiplicity given the number of electrons and the charge, if set.
Parameters:
-
atoms
(Atoms
) –Atoms object
-
charge
(int | None
, default:None
) –Molecular charge
-
spin_multiplicity
(int | None
, default:None
) –Molecular multiplicity
Returns:
-
(charge, multiplicity)
–
Source code in quacc/atoms/core.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
|
check_is_metal ¶
Checks if a structure is a likely metal.
Parameters:
-
atoms
(Atoms
) –Atoms object
Returns:
-
bool
–True if the structure is likely a metal; False otherwise
Source code in quacc/atoms/core.py
copy_atoms ¶
Simple function to copy an atoms object to prevent mutability.
Parameters:
-
atoms
(Atoms
) –Atoms object
Returns:
-
atoms
–Atoms object
Source code in quacc/atoms/core.py
get_atoms_id ¶
Returns a unique ID for the Atoms object. Note: The .info dict and calculator is excluded from the hash generation.
Parameters:
-
atoms
(Atoms
) –Atoms object
Returns:
-
str
–MD5 hash of the Atoms object
Source code in quacc/atoms/core.py
get_charge_attribute ¶
Get the charge of an Atoms object.
Parameters:
-
atoms
(Atoms
) –Atoms object
Returns:
-
int | None
–Charge of the Atoms object
Source code in quacc/atoms/core.py
get_final_atoms_from_dynamics ¶
get_final_atoms_from_dynamics(dynamics: Dynamics) -> Atoms
Get the final atoms object from a dynamics run.
Parameters:
-
dynamics
(Dynamics
) –ASE dynamics object
Returns:
-
Atoms
–Atoms object
Source code in quacc/atoms/core.py
get_spin_multiplicity_attribute ¶
Get the spin multiplicity of an Atoms object.
Parameters:
-
atoms
(Atoms
) –Atoms object
Returns:
-
int | None
–Spin multiplicity of the Atoms object
Source code in quacc/atoms/core.py
perturb ¶
Perturb each atom in a molecule by a (scaled) 1x3 vector, reflecting e.g. a vibrational normal mode.
Parameters:
-
mol
(Atoms
) –ASE Atoms object representing a molecule
-
matrix
(list[list[float]] | NDArray
) –Nx3 matrix, where N is the numebr of atoms. This means that there is potentially a different translation vector for each atom in the molecule.
-
scale
(float
) –Scaling factor for perturbation
Returns:
-
Atoms
–The input molecule after perturbation