Skip to content

python wrappers for generating training files for the ReaxFF code

Notifications You must be signed in to change notification settings

jkitchin/python-reaxff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

this is a module to facilitate preparation of reaxx input files, especially the geometry file and trainset.in file.

See this file for some documentation of the formats. http://www.wag.caltech.edu/home/duin/reax_um.pdf

Generating trainset.in.

The trainsets are more complicated to make. The trainset.in file has several different sections. We need to create a dictionary that has the contents of these sections in it, and then a convenient function will write out the file for us. This file has heats of formation, and equation of state data.

import glob, os

from trainset import *
from jasp import *

os.chdir('/home-research/jkitchin/research/fe-ni-al/AlNi_fcc')
if os.path.exists('trainset.in'): os.unlink('trainset.in')
# reference endpoints
with jasp('0') as c0:
    atoms0 = c0.get_atoms()
    e0 = atoms0.get_potential_energy()/len(atoms0)
    d0 = reax_hash(atoms0)

with jasp('1') as c1:
    atoms1 = c1.get_atoms()
    e1 = atoms1.get_potential_energy()/len(atoms1)
    d1 = reax_hash(atoms1)

#reference energies in eV/atom
reference_energies = {}
reference_energies[atoms0[0].symbol] = (d0, e0)  # (description, energy)
reference_energies[atoms1[0].symbol] = (d1, e1)

cells = parse_trainset()

dirs = [0, 1, 2, 3]
# First we do the equations of state
for wd in dirs:
    d = str(wd) # directory name as string
    if (os.path.exists(os.path.join(d,'OUTCAR'))
        and not os.path.exists(os.path.join(d,'error'))):
        # geometry of cell
        with jasp(d) as calc:
            atoms = calc.get_atoms()
        cells = cell_parameters(atoms, weight=1.0, cells=cells)

        # equation of state Adri suggested we put a higher weight on
        # points close to the minimum
        eosdir = os.path.join(d,'eos-exp')
        if os.path.isdir(eosdir):
            edirs = glob.glob('%s/*' % eosdir)
            cells['ENERGY'].append('# Volume %s' % reax_hash(atoms))
            for ed in edirs:
                if (os.path.exists(os.path.join(ed,'energy'))
                    and not os.path.exists(os.path.join(ed,'error'))):
                    with jasp(ed) as calc2:
                        atoms2 = calc2.get_atoms()
                        e1 = atoms.get_potential_energy()
                        e2 = atoms2.get_potential_energy()
                        weight = 0.1 + 0.25*np.abs((e2 - e1))*23.061 #kcal

                        cells = eos(atoms,
                                    atoms2,
                                    weight=weight,
                                    cells=cells)


# comment line for readability
cells['ENERGY'].append('# Heats_of_formation')

for i in [0, 1, 2]:
    with jasp('{}'.format(i)) as calc:
        atoms = calc.get_atoms()
        
    # This is a heat of formation
    cells = energy(atoms,
                   reference_energies,
                   weight=1.0,
                   cells=cells)

write_trainset('trainset.in', cells=cells)

Now the results.

cat /home-research/jkitchin/research/fe-ni-al/AlNi_fcc/trainset.in

About

python wrappers for generating training files for the ReaxFF code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages