Error in running table.file of LAMMPS

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

There is not enough information here to be able to tell which is the specific problem, since you don’t provide the complete information to recreate the table files and a complete input file. Also, whenever you report and unexpected crash or error, you should state which LAMMPS version you are using and on what platform.

Chances are that your table file is not correctly formatted.

As of recent, LAMMPS provides python code examples for correctly creating table files in the tools/tabulate folder of the LAMMPS source code: lammps/tools/tabulate at develop · lammps/lammps · GitHub

There is no python script and the script from the previous post requires a whole bunch of command line arguments.

Yes, the script above is the one I want to reproduce from others.My command line parameters are:python3 Write_potential.py 1618.80 0.33849 19.27 71 8 10.0119 -7.15593 1.91572 -0.214047 0.8 1.5
Thanks for the reply.

Your python script has an error. It cannot finish and thus produces a short file.

$ python gentable.py 1618.80 0.33849 19.27 71 8 10.0119 -7.15593 1.91572 -0.214047 0.8 1.5
1618.8
Traceback (most recent call last):
  File "/home/akohlmey/compile/lammps/build-test/gentable.py", line 99, in <module>
    wp(A,P,C,Z1,Z2,P1,P2,P3,P4,r1,r2)
  File "/home/akohlmey/compile/lammps/build-test/gentable.py", line 94, in wp
    a=str(index)+' '+str('%.3f'%r12)+' '+str('%.3f'%V)+' ' +str('%.3f'%F)   
                                                                ~~~~~~^~
  File "/home/akohlmey/.local/lib/python3.11/site-packages/sympy/core/expr.py", line 351, in __float__
    raise TypeError("Cannot convert expression to float")
TypeError: Cannot convert expression to float

There is no maybe here. Of course this is definitely the problem!! How can you not have noticed the error message?

More importantly, just look at your table file and compare to the description of the table file format.
Your table header says there are 10000 entries in the table, but it stops at number 799 and an r value of 0.799 Angstrom. This is just common sense checking of your input data. Smart people do this before using the table, but as soon as you would have an error, anybody in their right mind should have checked the table for inconsistencies and maybe make some plots. And the shortness of the file becomes glaringly obvious in that case.

Be grateful you don’t work for or with me and hope that your PI/Adviser/Supervisor or similar does not follow this forum. Otherwise there might be some uncomfortable days ahead.

Thanks for your guidance, I ran the .py file several times to generate 799 columns, I don’t know how to solve this problem, I will subsequently rewrite it according to the official website.
Also, thanks for your concern, I’m just a freshman trying to learn something related to my course. Took up a lot of your time, hope not to reply again