Class Parameter try to open the LAMMPS ”parameters” as file
When I run this code, there is a error: File "xxx/ase/calculators/calculator.py", line 436, in read with open(filename) as fd: TypeError: expected str, bytes or os.PathLike object, not dict
The variable parameters of calculator LAMMPS is passed into “Filename” of Class Parameter.
from ase import Atom, Atoms
from ase.calculators.lammpsrun import LAMMPS
from ase.optimize import BFGS,FIRE
from ase.io import read, write
from ase.io.vasp import read_vasp, write_vasp, write_vasp_xdatcar
from ase.constraints import ExpCellFilter
name = 'rutile'
atoms = read( filename= name +'.vasp',format='vasp')
parameters = {'atom_style': 'charge', 'model_post' : [
"set type 2 charge 2.196\n", "set type 1 charge -1.098\n"],
"pair_style": " buck/coul/long 12.0",
"pair_coeff": [ "2 2 717654.7494 0.154 120.9967875", " 1 2 391053.1759 0.194 290.39229", "1 1 271719.1310 0.234 696.941496"],
'kspace_style' : "ewald/disp 0.00001"}
lammps = LAMMPS(parameters=parameters, tmp_dir='tmp')
atoms.calc = lammps
print('cell: ', atoms.get_chemical_symbols() )
print("Energy ", atoms.get_potential_energy())
print('test2')
sys = ExpCellFilter(atoms)
dyn = FIRE(atoms= sys, trajectory= name + '.traj')
dyn.run(fmax=0.001)
traj = read(name + '.traj', index = ':')
traj = read(name + '.traj')
cont = write_vasp(name + "_out.vasp", traj, vasp5=True)
#VASP POSCAR:
rutile
1.00000000000000
4.6141111683276685 -0.0000851721276198 0.0000002019917788
-0.0000851789631610 4.6140906854809502 -0.0000091242339639
0.0000003200589885 -0.0000059595312348 2.9548526486850579
Ti O
2 4
Direct
0.0000034520543235 -0.0000014724324502 0.0000032084224203
0.5000010626978947 0.4999993392777680 0.4999983215016295
0.3032103822362655 0.3032057465535070 0.0000006518544110
0.1968017035657292 0.8031902574943331 0.5000001129072346
0.6967877870764090 0.6967961380735560 0.0000017091472324
0.8031956123693781 0.1968099910332859 0.499995996167072
Edited by jl chen