Simplified access of force errors
This commit is contained in:
@ -1,8 +1,5 @@
|
||||
import lammps
|
||||
|
||||
def sqerr(a,b):
|
||||
return (a[0]-b[0])**2+(a[1]-b[1])**2+(a[2]-b[2])**2
|
||||
|
||||
infile = "in.fnum"
|
||||
|
||||
fdeltalist = [1.0e-2,1.0e-3,1.0e-4,1.0e-5,1.0e-6,1.0e-7,1.0e-8,1.0e-9,1.0e-10]
|
||||
@ -12,13 +9,6 @@ for fdelta in fdeltalist:
|
||||
cmdlist = ["-screen","none","-var","fdelta",f'{fdelta}']
|
||||
lmp = lammps.lammps(cmdargs = cmdlist)
|
||||
lmp.file(infile)
|
||||
nlocal = lmp.extract_global("nlocal")
|
||||
|
||||
f = lmp.extract_atom("f")
|
||||
fnum = lmp.extract_fix("fnum", lammps.LMP_STYLE_ATOM, lammps.LMP_TYPE_ARRAY)
|
||||
|
||||
sumsq = 0
|
||||
for i in range(nlocal):
|
||||
sumsq += sqerr(fnum[i],f[i])
|
||||
rmse = (sumsq/nlocal)**0.5
|
||||
faverrsq = lmp.extract_compute("faverrsq", lammps.LMP_STYLE_GLOBAL, lammps.LMP_TYPE_SCALAR)
|
||||
rmse = faverrsq**0.5
|
||||
print(f"{fdelta} {rmse}")
|
||||
|
||||
@ -54,10 +54,8 @@ pair_style sna/grid grid ${ngrid} ${ngrid} ${ngrid} &
|
||||
pair_coeff * * Al
|
||||
|
||||
fix fnum all numdiff 1 ${fdelta}
|
||||
variable fz1 equal fz[1]
|
||||
variable fnumz1 equal f_fnum[1][3]
|
||||
variable ferrz1 equal f_fnum[1][3]-fz[1]
|
||||
thermo_style custom v_fz1 v_fnumz1 v_ferrz1
|
||||
thermo_modify norm yes
|
||||
variable ferrsq atom (fx-f_fnum[1])^2+(fy-f_fnum[2])^2+(fz-f_fnum[3])^2
|
||||
compute faverrsq all reduce ave v_ferrsq
|
||||
thermo_style custom c_faverrsq
|
||||
|
||||
run 0
|
||||
|
||||
Reference in New Issue
Block a user