Hi, I’m trying to run a single point step using the ASE molecular dynamics calculator ‘Langevin dynamics’, I want to pass in the force and energy to the atoms object prior to the calculation using extended xyz format. The code I’m using to run this is:
#!/usr/bin/env python3
#testing code to run a single point md trajectory using ase
import ase.io
from ase.io import write, read
from extxyz import read, iread, write, ExtXYZTrajectoryWriter
from ase.md.verlet import VelocityVerlet
import ase.units as units
from ase.md.langevin import Langevin
from ase import Atoms
atoms = ase.io.read('posfrc.xyz')
#ase MD
dyn = Langevin(atoms, timestep=0.5 * units.fs,friction=0.001, temperature_K=300.0, append_trajectory='true', trajectory='md.traj', logfile='md.log')
dyn.run(2) # take 1 steps
#print(atoms.get_forces())
I get the following error:
Traceback (most recent call last):
File "/home/575/sb5361/aselammpstest/commandlmp/asemdtest/test/./asemd.py", line 17, in <module>
dyn.run(2) # take 1 steps
File "/home/575/sb5361/.local/lib/python3.9/site-packages/ase/md/md.py", line 137, in run
return Dynamics.run(self)
File "/home/575/sb5361/.local/lib/python3.9/site-packages/ase/optimize/optimize.py", line 156, in run
for converged in Dynamics.irun(self):
File "/home/575/sb5361/.local/lib/python3.9/site-packages/ase/optimize/optimize.py", line 135, in irun
self.step()
File "/home/575/sb5361/.local/lib/python3.9/site-packages/ase/md/langevin.py", line 171, in step
forces = atoms.get_forces(md=True)
File "/home/575/sb5361/.local/lib/python3.9/site-packages/ase/atoms.py", line 788, in get_forces
forces = self._calc.get_forces(self)
File "/home/575/sb5361/.local/lib/python3.9/site-packages/ase/calculators/abc.py", line 23, in get_forces
return self.get_property('forces', atoms)
File "/home/575/sb5361/.local/lib/python3.9/site-packages/ase/calculators/singlepoint.py", line 46, in get_property
raise PropertyNotImplementedError(
ase.calculators.calculator.PropertyNotImplementedError: The property "forces" is not available.
For reference this is the format of my extended xyz file:
302
Lattice="14.6 0.0 0.0 0.0 14.6 0.0 0.0 0.0 14.6" Properties=species:S:1:charge:R:1:pos:R:3:forces:R:3 pbc="T T T" energy=-59661.091624332985
Na 1.0 7.83993942 10.71230898 13.36138093 -0.118310021 0.658968788 0.723592885
Cl -1.0 10.99044514 9.35112481 2.27891414 0.444130946 -0.0585057225 -1.41357435
O 0.0 9.94268299 6.93500707 6.18177058 -4.92307428 -0.61442374 -2.89964658
H 0.0 9.73431226 6.65407365 5.19911266 2.89126203 0.994593491 3.84950444
H 0.0 10.84943337 7.11118855 6.3696444 2.88858559 -0.20858934 -0.734134986
O 0.0 1.451532 2.59097658 3.35096074 -2.53525464 1.77331001 0.170883085
H 0.0 0.89633122 2.73365953 4.1413446 1.15882951 -0.818433153 0.534415809
H 0.0 0.95416921 3.22376416 2.7758606 1.77320988 -0.606616224 -0.479165294
O 0.0 13.38140995 6.76890768 7.29699437 -0.141447022 -0.776942196 0.87161687
H 0.0 12.76518976 7.20943855 7.94947946 1.20350077 -1.19892604 -0.569906632
H 0.0 13.8351859 5.951057 7.64943985 -1.33044094 1.36733397 0.581276364
O 0.0 1.14456779 7.07672639 0.11991482 2.4583902 -1.98707739 -1.01194557
H 0.0 0.63439509 6.7045337 13.99516197 -0.224952005 -0.815513355 -1.70497326
H 0.0 0.58304921 7.74996166 0.45467662 -2.44686514 2.47666994 1.50956217
O 0.0 4.4726161 7.99857473 13.40814182 2.55670539 -1.07587289 -0.844406742
H 0.0 4.09797262 7.91731126 14.27474747 -1.11207436 -0.288652964 2.31285102
H 0.0 3.76782483 7.84139173 12.78716141 -2.2475807 0.111230678 -1.64556581
O 0.0 13.20540959 10.61164285 10.21274274 1.74632584 -2.01003369 -6.59735601
H 0.0 12.78047438 10.51881172 9.24139813 1.16484535 1.51011897 5.33862694
H 0.0 12.63415376 10.92515366 10.90178645 -2.57798462 0.993695187 0.88017561
O 0.0 9.64670416 1.45041875 13.31399796 -0.0315202066 1.17058605 -4.29941683
H 0.0 9.34627598 0.56615169 13.00672565 0.461753332 -0.140324509 1.17821155
H 0.0 9.81497291 1.84555074 12.39010298 0.0622852666 -0.979831101 3.43437505
O 0.0 8.92242228 14.02845084 7.32122855 1.28084726 0.690799405 -1.64030462
H 0.0 7.97800783 14.19801041 7.25616743 -0.901182429 0.396329825 -0.309836364
H 0.0 9.37073893 14.52786047 6.59892832 -0.481597763 -0.494957776 1.08664918
O 0.0 14.46988012 4.51474759 8.67746932 2.11191429 -0.375164115 -1.37600806
H 0.0 0.54134682 5.05238344 9.22878369 -0.914173776 -1.45565608 -1.86510745