Vacancy formation energy with 2D materials

When I delete the surface atom of the 2D material to search for the vacancy energy, the atom will be lost. and my code are as follows:
units metal
dimension 3
boundary p p p
atom_style atomic
read_data data.origin
change_box all boundary p p f remap units box
pair_style sw
pair_coeff * * wse2.sw W Se
#计算势能
compute eng all pe/atom
compute eatoms all reduce sum c_eng
#设置输出
thermo 10
thermo_style custom step pe c_eatoms
#能量最小化
min_style sd
minimize 1e-12 1e-12 1000 1000
run 0
variable N equal count(all)
variable No equal $N
variable E equal “c_eatoms”
variable Ei equal $E
clear

units metal
dimension 3
boundary p p p
atom_style atomic
read_data data.del
change_box all boundary p p f remap units box
pair_style sw
pair_coeff * * wse2.sw W Se
compute eng all pe/atom
compute eatoms all reduce sum c_eng
thermo_style custom step pe lx ly lz press pxx pyy pzz c_eatoms
min_style sd
minimize 1e-15 1e-15 1000 1000
run 0
variable Ef equal “c_eatoms”
variable Ev equal ({Ef}-(({No}-1)/{No})*{Ei})
print “Vacancy formation energy = {Ev}" print "after = {Ef}”
print “before = ${Ei}”

if I select the PPP boundary, the vacancy formation energy is false and if I select the ppf boundary, it can not run with lost atom