Skip to content

ani_quicktest.py example requires changes to script #29

@bannanc

Description

@bannanc

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions