ASE-Workshop-2023 / tutorial

Tutorial site for the 2023 workshop "Open Science with the Atomic Simulation Environment"
https://ase-workshop-2023.github.io/tutorial
Other
2 stars 4 forks source link

MOPAC cannot get potential energy #1

Closed lucydot closed 1 year ago

lucydot commented 1 year ago

When I run the following code

from ase.calculators.mopac import MOPAC
atoms.calc = MOPAC(label='isopropyl-alcohol')
atoms.get_potential_energy()

I get the following error:

MOPAC Job: "isopropyl-alcohol.mop" ended normally on Apr 13, 2023, at 10:53.

---------------------------------------------------------------------------
PropertyNotImplementedError               Traceback (most recent call last)
Cell In[6], line 1
----> 1 atoms.get_potential_energy()

File ~/miniconda3/envs/ase-tutorial/lib/python3.10/site-packages/ase/atoms.py:731, in Atoms.get_potential_energy(self, force_consistent, apply_constraint)
    728     energy = self._calc.get_potential_energy(
    729         self, force_consistent=force_consistent)
    730 else:
--> 731     energy = self._calc.get_potential_energy(self)
    732 if apply_constraint:
    733     for constraint in self.constraints:

File ~/miniconda3/envs/ase-tutorial/lib/python3.10/site-packages/ase/calculators/calculator.py:709, in Calculator.get_potential_energy(self, atoms, force_consistent)
    708 def get_potential_energy(self, atoms=None, force_consistent=False):
--> 709     energy = self.get_property('energy', atoms)
    710     if force_consistent:
    711         if 'free_energy' not in self.results:

File ~/miniconda3/envs/ase-tutorial/lib/python3.10/site-packages/ase/calculators/calculator.py:742, in Calculator.get_property(self, name, atoms, allow_calculation)
    737     self.calculate(atoms, [name], system_changes)
    739 if name not in self.results:
    740     # For some reason the calculator was not able to do what we want,
    741     # and that is OK.
--> 742     raise PropertyNotImplementedError('{} not present in this '
    743                                       'calculation'.format(name))
    745 result = self.results[name]
    746 if isinstance(result, np.ndarray):

PropertyNotImplementedError: energy not present in this calculation

So it seems to find and run MOPAC ok, but there is an issue getting the property.

I have the conda-forge version of MOPAC (MOPAC version 22.0.6) and ASE from a pip install in the same conda environment (ase-3.22.1). The same problem is happening on my laptop, and on the Docker image from Alin.

@ajjackson can you tell me which version of ASE and MOPAC you are using where this problem is avoided?

ajjackson commented 1 year ago

I think I fixed this in ASE, can you try installing the master branch?

pip install git+https://gitlab.com/ase/ase.git@master

https://gitlab.com/ase/ase/-/merge_requests/2745 https://gitlab.com/ase/ase/-/issues/1118

lucydot commented 1 year ago

Hi @ajjackson, yes just installed the master branch and can confirm that get_potential_energy returns energy as expected 👍