Files
lammps/examples/mliap/ace/Ta_example/numerical_diff_reference/in.numdiff
2024-01-16 11:31:53 -07:00

73 lines
1.9 KiB
Plaintext

# Demonstrate MLIAP/PyTorch interface to linear SNAP potential
# Initialize simulation
# Initialize simulation
variable nthermo index 10 # thermo output interval
variable ndump index 10 # dump output interval
variable fdelta index 1.0e-4 # displacement size
variable vdelta index 1.0e-6 # strain size for numdiff/virial
variable bdelta index 1.0e-8 # strain size for numdiff Born matrix
variable temp index 10.0 # temperature
variable nugget equal 1.0e-6 # regularization for relerr
variable nsteps index 100
units metal
atom_modify map yes
variable nrep equal 1
variable a equal 3.316
# generate the box and atom positions using a BCC lattice
variable nx equal ${nrep}
variable ny equal ${nrep}
variable nz equal ${nrep}
boundary p p p
lattice bcc $a
region box block 0 ${nx} 0 ${ny} 0 ${nz}
create_box 1 box
create_atoms 1 box
mass 1 180.88
# choose potential
include Ta06A.ace.pytorch.mliap
# Set up NVE run
velocity all create 300.0 4928459 loop geom
fix 1 all nve
timestep 0.5e-3
neighbor 1.0 bin
neigh_modify once no every 1 delay 0 check yes
# Run MD
compute eatom all pe/atom
compute energy all reduce sum c_eatom
compute satom all stress/atom NULL
compute str all reduce sum c_satom[1] c_satom[2] c_satom[3]
variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol)
fix numforce all numdiff ${nthermo} ${fdelta}
variable ferrx atom f_numforce[1]-fx
variable ferry atom f_numforce[2]-fy
variable ferrz atom f_numforce[3]-fz
variable ferrsq atom v_ferrx^2+v_ferry^2+v_ferrz^2
compute faverrsq all reduce ave v_ferrsq
variable fsq atom fx^2+fy^2+fz^2
compute favsq all reduce ave v_fsq
variable frelerr equal sqrt(c_faverrsq/(c_favsq+${nugget}))
dump errors all custom ${ndump} force_error.dump v_ferrx v_ferry v_ferrz
thermo_style custom step temp v_frelerr
run ${nsteps}