Dears
hope you are doing well
I want to reproduce what other people do with table.files, but I get an error when I run it.This is what is reported in the error:terminate called after throwing an instance of ‘std::logic_error’
what(): basic_string::_M_construct null not valid
I would like to ask if this is an error caused by my table.file or by my LAMMPS configuration (there was a successful run of the in file before this example).If it is one of these two cases, how can I solve this problem?Thank you in advance for answering my questions.
There are my pair settings in in.file:
pair_style table linear 1000
pair_coeff * 2 Lu-O.table Lu-O
This is the python statement I used to generate the table.file:
#define constant
a0=0.052922e-9
e_0=8.8542e-12
e_e=1.6023e-19
rcut=10
import math
import sys
import sympy
from sympy import diff
from sympy import symbols
A=float(sys.argv[1])
P=float(sys.argv[2])
C=float(sys.argv[3])
Z1=float(sys.argv[4])
Z2=float(sys.argv[5])
P1=float(sys.argv[6])
P2=float(sys.argv[7])
P3=float(sys.argv[8])
P4=float(sys.argv[9])
r1=float(sys.argv[10])
r2=float(sys.argv[11])
print(A)
# define phi
def phi(Z1,Z2,r12):
x=r12*(pow(Z1,0.2300)+pow(Z2,0.2306))/(0.8854*a0)
phi=0.1818*math.exp(-3.2*x)+0.5099*math.exp(-0.9423*x)+0.2802*math.exp(-0.4029*x)+0.02817*math.exp(-0.2016*x)
return phi
# def zbl(Z1.Z2)
def zbl(Z1,Z2,r12):
r12=r12*1e-10
a=1/(4*3.1415926*e_0)
b=Z1*Z2*pow(e_e,2)/r12
ZBL=a*b*phi(Z1,Z2,r12)
return ZBL
#zbl force fuction
def zbl_f(Z1,Z2,r12):
r=r12*1e-10
x=r*(pow(Z1,0.2300)+pow(Z2,0.2300))/(0.8854*a0)
d_x=(pow(Z1,0.2300)+pow(Z2,0.2300))/(0.8854*a0)
d_Phi=d_x*(-3.2*0.1818*math.exp(-3.2*x)-0.9423*0.5099*math.exp(-0.9423*x)-0.4029*0.2802*math.exp(-0.4029*x)-0.2016*0.02817*math.exp(-0.2016*x))
f=(-zbl(Z1,Z2,r12)/r)*phi(Z1,Z2,r)+zbl(Z1,Z2,r12)*d_Phi/phi(Z1,Z2,r)
return -f
def spine(P1,P2,P3,P4,r12):
v2=sympy.exp(P1+P2*r12+P3*pow(r12,2)+P4*pow(r12,3))
return v2
def spine_f(P1,P2,P3,P4,r12):
r12=symbols("r12")
v2=spine(P1,P2,P3,P4,r12)
v4=sympy.Derivative(v2,r12).doit()
return v4
def buck(A,P,C,r12):
p=-r12/P
if isinstance(p, float):
p = sympy.Float(p)
p_float = p.evalf()
v3=A*sympy.exp(p_float)-C/r12**6
return v3
def buck_f(A,P,C,r12):
r12=symbols("r12")
v3=buck(A,P,C,r12)
v5=sympy.Derivative(v3,r12).doit()
return v5
def wp(A,P,C,Z1,Z2,P1,P2,P3,P4,r1,r2):
judge=True
r12=0.001
V=0
F=0
index=1
f=open("Lu-O.table" ,"a+")
headline="# DATE: 2021-05-22 UNITS: metal"
comment="# potential for Lu-O"
keyword="Lu-O"
parameters="N 10000 R 0.001 10.0"
L=headline+'\n'+comment+'\n'+keyword+'\n'+parameters+'\n'
f.write(L+'\n')
while judge:
if r12 <= r1:
V=zbl(Z1,Z2,r12)/e_e
F=1e-10*zbl_f(Z1,Z2,r12)/e_e
elif (r12 > r1) and (r12 < r2):
V=spine(P1,P2,P3,P4,r12)
F=spine_f(P1,P2,P3,P4,r12)
elif (r12 >= r2) and (r12 < (rcut-0.001)):
V=buck(A,P,C,r12)
F=buck_f(A,P,C,r12)
else:
judge=False
a=str(index)+' '+str('%.3f'%r12)+' '+str('%.3f'%V)+' ' +str('%.3f'%F)
f.write(a+"\t\n")
r12=r12+0.001
index=index+1
f.close()
wp(A,P,C,Z1,Z2,P1,P2,P3,P4,r1,r2)
Please forgive me if I make basic mistakes in this process, I am new to using LAMMPS.
Thank you