Skip to content

Commit

Permalink
Fixed: symeig deprication (#627)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
kfir4444 authored Mar 21, 2023
1 parent 46c554a commit 40cf334
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion torchani/ase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion torchani/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 40cf334

Please sign in to comment.