Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ani_quicktest.py example requires changes to script #29

Open
bannanc opened this issue Aug 14, 2019 · 4 comments
Open

ani_quicktest.py example requires changes to script #29

bannanc opened this issue Aug 14, 2019 · 4 comments

Comments

@bannanc
Copy link

bannanc commented Aug 14, 2019

Hello, I'm just getting started with ASE_ANI and am trying to make sure the simple ani_quicktest.py runs before I try anything else. I noticed what seem to be some python type problems that I'm hoping you could help with.

Once I got everything installed correctly and was able to run it (python ani_quicktest.py in the example folder) this is the output I got:

van Der Waals correction will be unavailable. Please install ased3
Traceback (most recent call last):
  File "ani_quicktest.py", line 24, in <module>
    ei = mol.get_potential_energy()
  File "/home/cbannan/.local/lib/python3.6/site-packages/ase/atoms.py", line 674, in get_potential_energy
    energy = self._calc.get_potential_energy(self)
  File "/home/cbannan/.local/lib/python3.6/site-packages/ase/calculators/calculator.py", line 618, in get_potential_energy
    energy = self.get_property('energy', atoms)
  File "/home/cbannan/.local/lib/python3.6/site-packages/ase/calculators/calculator.py", line 668, in get_property
    self.calculate(atoms, [name], system_changes)
  File "/home/cbannan/ANI/ASE_ANI/lib/ase_interface.py", line 689, in calculate
    self.nc.set_cell((self.atoms.get_cell()).astype(np.float32), pbc_inv)
AttributeError: 'Cell' object has no attribute 'astype'

After some digging into ase.Atoms and ase.cell.Cell, it became clear that the Cell object does not in fact have a method astype. Looking at other lines of code in ase_interface I noticed that on line 687 this call np.linalg.inv(self.atoms.get_cell())).astype(np.float32) works just fine which made me assume the astype needed an np.arrary instead of an ase.cell.Cell. I decided to try changing the Cell object to an array in line 689 with this change:

self.nc.set_cell(np.arrary(self.atoms.get_cell()).astype(np.float32), pbc_inv)

This appeared to "fix" things in that at least when I reran the script I got different out:

van Der Waals correction will be unavailable. Please install ased3
With Caitlin's change
Initial Energy:  -2078.5028228165684
Optimizing...
Traceback (most recent call last):
  File "ani_quicktest.py", line 31, in <module>
    dyn.run(fmax=0.001)
  File "/home/cbannan/.local/lib/python3.6/site-packages/ase/optimize/optimize.py", line 246, in run
    return Dynamics.run(self)
  File "/home/cbannan/.local/lib/python3.6/site-packages/ase/optimize/optimize.py", line 159, in run
    for converged in Dynamics.irun(self):
  File "/home/cbannan/.local/lib/python3.6/site-packages/ase/optimize/optimize.py", line 125, in irun
    self.atoms.get_forces()
  File "/home/cbannan/.local/lib/python3.6/site-packages/ase/atoms.py", line 728, in get_forces
    forces = self._calc.get_forces(self)
  File "/home/cbannan/.local/lib/python3.6/site-packages/ase/calculators/calculator.py", line 632, in get_forces
    return self.get_property('forces', atoms)
  File "/home/cbannan/.local/lib/python3.6/site-packages/ase/calculators/calculator.py", line 668, in get_property
    self.calculate(atoms, [name], system_changes)
  File "/home/cbannan/ANI/ASE_ANI/lib/ase_interface.py", line 703, in calculate
    self.nc.set_cell((self.atoms.get_cell()).astype(np.float32), pbc_inv)
AttributeError: 'Cell' object has no attribute 'astype'

So now line 703 seems to have the same problem 689 did. So I changed line 703 to:

self.nc.set_cell(np.array(self.atoms.get_cell()).astype(np.float32), pbc_inv)

Finally I was able to run the ani_quicktest.py without any errors and got the energies as:

  • Initial Energy: -2078.5028228165684
  • Final Energy: -2078.50426605258
    Is it possible these values don't agree with the values in the README because I'm missing the ased3 module?

Initially, I didn't install ased3 because I was under the impression it was optional and I wanted to make sure that I could run the script as is. However, now I've noticed that ased3 also doesn't have a license associated with it which makes me hesitant to try it. Do you know if this same issue will come up if I include ased3?

Thanks for your help in advance!

@isayev
Copy link
Owner

isayev commented Aug 14, 2019

Hey, @bannanc thanks for giving ANI a try:) Two things.

  1. It seems that recent changes in ASE broke the compatibility with our interface:/ We will check it out, but PR is welcome to fix it.
  2. This is a mixed-precision GPU code, so there is always some stochasticity in the last few digits because of rounding. Here is a run on my machine:

Initial Energy: -2078.50282282132
Final Energy:-2078.5042660113986

So if 7 digits agree, you are good to go!

@bannanc
Copy link
Author

bannanc commented Aug 14, 2019

Thanks @isayev I'm not going to bother with ased3 then for now.
I'm happy to put in a PR with the changes I mentioned above.

@bannanc bannanc changed the title ani_quicktest.py example requires changes to script and results disagree ani_quicktest.py example requires changes to script Aug 29, 2019
@UnixJunkie
Copy link

Hi from Tokyo @bannanc ,

How did you manage to make the test run?
I am still fighting with it; my latest trial script:
#45

Regards,
Francois.

@bannanc
Copy link
Author

bannanc commented Sep 26, 2023

Hi @UnixJunkie I managed to get something working back in 2019 for some benchmarking. However, I haven't used it since that summer so I don't remember what I did exactly. Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants