From 40cf334dbdf71903f30be8560784ca793b830221 Mon Sep 17 00:00:00 2001 From: kfir4444 <75449651+kfir4444@users.noreply.github.com> Date: Tue, 21 Mar 2023 16:30:59 +0200 Subject: [PATCH] Fixed: symeig deprication (#627) * Fixed: symeig deprication This causes: RuntimeError: This function was deprecated since version 1.9 and is now removed. Please use the `torch.linalg.eigh` function instead. * Fix: slow tensor creation This raises: Creating a tensor from a list of numpy.ndarrays is extremely slow. Please consider converting the list to a single numpy.ndarray with numpy.array() before converting to a tensor. --- torchani/ase.py | 2 +- torchani/utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/torchani/ase.py b/torchani/ase.py index a589d1aca..ac5ecb400 100644 --- a/torchani/ase.py +++ b/torchani/ase.py @@ -50,7 +50,7 @@ def __init__(self, species, model, overwrite=False): def calculate(self, atoms=None, properties=['energy'], system_changes=ase.calculators.calculator.all_changes): super().calculate(atoms, properties, system_changes) - cell = torch.tensor(self.atoms.get_cell(complete=True), + cell = torch.tensor(self.atoms.get_cell(complete=True).array, dtype=self.dtype, device=self.device) pbc = torch.tensor(self.atoms.get_pbc(), dtype=torch.bool, device=self.device) diff --git a/torchani/utils.py b/torchani/utils.py index ae6c71ac8..4578a822f 100644 --- a/torchani/utils.py +++ b/torchani/utils.py @@ -322,7 +322,7 @@ def vibrational_analysis(masses, hessian, mode_type='MDU', unit='cm^-1'): if mass_scaled_hessian.shape[0] != 1: raise ValueError('The input should contain only one molecule') mass_scaled_hessian = mass_scaled_hessian.squeeze(0) - eigenvalues, eigenvectors = torch.symeig(mass_scaled_hessian, eigenvectors=True) + eigenvalues, eigenvectors = torch.linalg.eigh(mass_scaled_hessian) angular_frequencies = eigenvalues.sqrt() frequencies = angular_frequencies / (2 * math.pi) # converting from sqrt(hartree / (amu * angstrom^2)) to cm^-1 or meV