tfep.utils.misc.forces_array_to_tensor
- tfep.utils.misc.forces_array_to_tensor(forces, distance_unit=None, energy_unit=None, dtype=None)[source]
Helper function to convert the a batch of forces from numpy array to PyTorch tensor.
distance_unitandenergy_unitmust be passed together. If they areboth
Noneno conversion is performed. If only one of them isNonean error is raised.
- Parameters:
forces (pint.Quantity) – The forces with shape
(batch_size, n_atoms, 3)with units.distance_unit (pint.Unit, optional) – The units of distance used in the returned forces. If
None, no conversion is performed, and the forces will be in the same units as the input.energy_unit (pint.Unit, optional) – The units of energy used in the returned forces. If
None, no conversion is performed, and the energy will be in the same units as the input.dtype (type, optional) – The
torchdata type to be used for the returnedTensor.
- Returns:
forces – The forces with shape
(batch_size, n_atoms*3)as a unitlessTensorin units ofenergy_unit/distance_unit.- Return type:
torch.Tensor
- Raises:
ValueError – If only one between
distance_unitandenergy_unitis passed.