ERROR on proc 0: Particle outside surface of region used in fix wall/region

My code is:

clear
units lj
boundary p p p
atom_style full
read_data diff.data

pair_style lj/cut 2.5
pair_coeff 1 1 1 1 1.125
region bsph sphere 0.0 0.0 0.0 15 side in

neighbor 4 bin
neigh_modify every 1 delay 1

thermo_style custom step pe etotal vol epair ebond eangle edihed
thermo 1000

fix 1 all nve/limit 0.1
fix 2 all wall/region bsph harmonic 1.0 0.0 2.5
fix 3 all langevin 1 1 10 25496

timestep 0.001
run 1000000

dump 1 all xyz 1000 diff.xyz
run 100000

And it is giving an error of particles outside the box.

Is it necessary for all the particles to be inside region?

My intention is that the particles inside should have this potential and also particles from outside should be able to enter the region “bsph” . But, due to this harmonic potential, the particles get trapped into that region.

Is there any other way to do this?

Thanks

And it is giving an error of particles outside the box.

Is it necessary for all the particles to be inside region?

yes. the wall is supposed to be impenetrable and the potential has a discontinuity, so you cannot have particles go past that.

My intention is that the particles inside should have this potential and also particles from outside should be able to enter the region “bsph” . But, due to this harmonic potential, the particles get trapped into that region.

Is there any other way to do this?

you could do this with defining atom style variables and fix addforce. but you have to decide how you handle the issue of the discontinuity.
you can define atom style variable computing the force components of each particle. in those variables you can use expressions like (v_dist<10.0) or (v_dist>15.0) to define cutoffs. since the logical expression will evaluate to either 1.0 or 0.0 depending on whether they are true of false.

for more details, please see the documentation of fix addforce and variable

axel.