[ase-users] small problem with lammps calculator

Olga Lopez-Acevedo olga.lopez.acevedo at aalto.fi
Tue Apr 3 17:19:35 CEST 2012


Hi,

I have started to run LAMMPS with ASE recently. To just test the code is 
running with command line the following script would work:

--------------------------

import os
	
from ase.test import NotAvailable
	
try:
     lammps_command = os.getenv('LAMMPS_COMMAND')
     if lammps_command == None:
         raise NotAvailable('LAMMPS_COMMAND not defined')
except NotAvailable:
     raise NotAvailable('Lammps required')
	
import numpy as np
	
from ase.tasks.main import run
	
atoms, task = run('lammps bulk Pd')
atoms, task = run('lammps bulk Pd -s')


--------------------------------

there is small script for testing energy and forces at the end of the 
lammps.py script in ASE. It would require the file Pd_u3.eam that comes 
with lammps code, I am attaching it and these tests in one file. 
Defining the file with path to that specific place is also possible with 
the recent applied patch. I am not sure however what is the standard use 
in LAMMPS, if there is one directory file for all parameter files (like 
the setup directory in GPAW) or the users tend to add the parameter file 
with every calculation. It would rather define one directory for all 
parameter files but maybe there is a practical reason why not to do that.


-----------------------------------


pair_style = 'eam'
Pd_eam_file = 'Pd_u3.eam'
#when defining the path to lammps potential directory, modify and use
#Pd_eam_file =  '/home/user/lammps/potentials/Pd_u3.eam'
pair_coeff = [ '* * ' + Pd_eam_file ]
parameters = { 'pair_style' : pair_style, 'pair_coeff' : pair_coeff }
files = [ Pd_eam_file ]

from ase import Atoms
a0 = 3.93
b0 = a0 / 2.0
from ase.calculators.lammps import LAMMPS
calc = LAMMPS(parameters={ 'pair_style' : pair_style, 'pair_coeff': 
pair_coeff},
               files=files)
bulk = Atoms(['Pd']*4,
              positions=[(0,0,0),(b0,b0,0),(b0,0,b0),(0,b0,b0)],
              cell=[a0]*3,
              pbc=True)

# test get_forces
print 'forces for a = %f' % a0
print calc.get_forces(bulk)
# single points for various lattice constants
bulk.set_calculator(calc)
n=-1
a = a0 * (1 + n/100.0)
bulk.set_cell([a]*3)
print 'a : %f , total energy : %f' % (a, bulk.get_potential_energy())

----------------------------------

Best,

Olga




On 2012-03-30 19:06, Marcin Dulak wrote:
> Hi,
>
> i have applied the patch.
> Could one of you try to create lammps ase command line test, similar to:
> https://trac.fysik.dtu.dk/projects/ase/browser/trunk/ase/test/nwchem/nwchem_cmdline.py
> The test could test some advanced features of lammps interface as long
> as it's fast (less then 1min).
> Please read about the command line tool at:
> https://wiki.fysik.dtu.dk/ase/ase/cmdline.html
>
> Best regards,
>
> Marcin
>
> On 03/29/12 00:02, Rye Terrell wrote:
>> Line 125 in lammps.py is:
>>
>> shutil.copy(f, os.path.join(self.tmp_dir, f))
>>
>> Should it not be:
>>
>> shutil.copy(f, os.path.join(self.tmp_dir, os.path.basename(f)))
>>
>> Otherwise, I do not think it will work unless the filenames passed to
>> the LAMMPS class are in the current directory and have no path
>> information.
>>
>> Thanks,
>> Rye Terrell
>>
>
>
>
>
> _______________________________________________
> ase-users mailing list
> ase-users at listserv.fysik.dtu.dk
> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users


-- 
Department of Applied Physics, Aalto University, P.O. Box 11100
(Otakaari 1) Office U208, FI-02150, Espoo, Finland
http://tfy.tkk.fi/~lopezo1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lammps_cmdline.py
Type: application/x-chimera
Size: 1293 bytes
Desc: not available
URL: <http://listserv.fysik.dtu.dk/pipermail/ase-users/attachments/20120403/93945bee/attachment.bin>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Pd_u3.eam
URL: <http://listserv.fysik.dtu.dk/pipermail/ase-users/attachments/20120403/93945bee/attachment.ksh>


More information about the ase-users mailing list