pydft_qmmm.utils.misc¶
Helper functions accessed by multiple classes.
Functions
|
Center positions about the centroid of a set of atoms. |
|
Check if an array has any NaN or Inf vlaues. |
|
Generate velocities with the Maxwell-Boltzmann distribution. |
|
Calculate the numerical energy gradients for a set of atoms. |
|
Perform the residue-wise system partitioning. |
|
Wrap atom positions in accord with PBC. |
- pydft_qmmm.utils.misc.center_positions(positions, box, atoms)[source]¶
Center positions about the centroid of a set of atoms.
- Parameters:
positions (
ndarray
[tuple
[Any
,...
],dtype
[float64
]]) – The positions (\(\mathrm{\mathring{A}}\)) to center.box (
ndarray
[tuple
[Any
,...
],dtype
[float64
]]) – The lattice vectors (\(\mathrm{\mathring{A}}\)) of the box containing the system.atoms (
frozenset
[int
]) – The set of atom indices whose centroid will become the center of the box.
- Return type:
- Returns:
The new centered positions of the system.
- pydft_qmmm.utils.misc.generate_velocities(masses, temperature, seed=None)[source]¶
Generate velocities with the Maxwell-Boltzmann distribution.
- Parameters:
- Return type:
- Returns:
A set of velocities (\(\mathrm{\mathring{A}\;fs^{-1}}\)) equal in number to the set of masses provided.
- pydft_qmmm.utils.misc.numerical_gradient(calculator, atoms, dist=0.0025, components=None)[source]¶
Calculate the numerical energy gradients for a set of atoms.
- Parameters:
calculator (
Calculator
) – A calculator object used for the energy evaluations.atoms (
frozenset
[int
]) – The atoms for which to perform a numerical gradient calculation.dist (
int
|float
, default:0.0025
) – The displacement for central differencing (\(\mathrm{\mathring{A}}\)).component – The component of the energy dictionary to use in central differencing calculations.
- Return type:
- Returns:
The numerical gradients of the energy (\(\mathrm{kJ\;mol^{-1}\;\mathring{A}^{-1}}\)).
- pydft_qmmm.utils.misc.residue_partition(atoms, positions, residue_map, atoms_metric, other_metric, cutoff)[source]¶
Perform the residue-wise system partitioning.
- Parameters:
atoms (
frozenset
[int
]) – The set of atom indices whose metric will be used to determine the partition.positions (
ndarray
[tuple
[Any
,...
],dtype
[float64
]]) – The system positions (\(\mathrm{\mathring{A}}\)).residue_map (
dict
[int
,frozenset
[int
]]) – Sets of atom indices indexed by residue index.atoms_metric (
Callable
[[ndarray
[tuple
[Any
,...
],dtype
[TypeVar
(_ScalarT
, bound=generic
)]]],float
]) – A function to apply to a residue’s positions to generate a single relevant coordinate. This metric is applied to the provided set of atoms.other_metric (
Callable
[[ndarray
[tuple
[Any
,...
],dtype
[TypeVar
(_ScalarT
, bound=generic
)]]],float
]) – A function to apply to a residue’s positions to generate a single relevant coordinate. This metric is applied to all residues in the system.cutoff (
float
|int
) – The cutoff distance (\(\mathrm{\mathring{A}}\)) to apply in the partition.
- Return type:
- pydft_qmmm.utils.misc.wrap_positions(positions, box, residue_map)[source]¶
Wrap atom positions in accord with PBC.
Atoms are wrapped to stay inside of the periodic box. This function ensures molecules are not broken up by a periodic boundary, since OpenMM electrostatics will be incorrect if atoms in a molecule are not on the same side of the periodic box.
- Parameters:
positions (
ndarray
[tuple
[Any
,...
],dtype
[float64
]]) – The positions (\(\mathrm{\mathring{A}}\)) to wrap.box (
ndarray
[tuple
[Any
,...
],dtype
[float64
]]) – The lattice vectors (\(\mathrm{\mathring{A}}\)) of the box containing the system.residue_map (
dict
[int
,frozenset
[int
]]) – Sets of atom indices indexed by residue index.
- Return type:
- Returns:
The new wrapped positions of the system.