Error: out of simulation box in molecules insertion

Hello!

I need help dealing with this error running lammps. I’m trying to insert some water molecules using gcmc (insertion/deletion) around the metal surface. I’m using the periodic unit cell with the metal surface at the bottom, and big vacuum in the unit cell on top.
I created the region to add water molecules in the vacuum as this -

region waterbox block 0.1 10.9025815964 0.1 8.15194 9.1 24.9
create_atoms 0 region waterbox mol h2omol 45585 units box

When I run the gcmc command below to insert/delete the water molecules in the region waterbox,
I keep getting the error :
ERROR: Fix gcmc region extends outside simulation box (…/fix_gcmc.cpp:139)

fix mygcmc h2o gcmc 100 100 0 0 54341 300 -0.5 0.1 mol h2omol tfac_insert ${tfac} group h2o shake wshake region waterbox

How could I fix this error? I was trying to fix this myself but It doesn’t seem to work .

Thank you for your help !

There is some crucial information missing here. When you have trouble with error messages, please always report which version of LAMMPS exactly you are using and on which platform. Please also provide a complete input.

For example, if you are using a “lattice” command setting a lattice parameter different from 1.0, then your region command is probably creating a larger region than you would expect since you are not using the “units box” when defining the region. You only use it for create_atoms, where it has no effect for the choice you have made.

Hello Dr. akohlmey,
,
Thank you for your response., and I apologize for the missing information! Here’s my input file below, I would appreciate if you can give advice where i’m going wrong :
(The lammps version 2020-03-03 on linux).

units real
dimension 3
boundary p p p

atom_style full
read_data data.now
molecule h2omol TIP4P2005.txt
lattice sc 1
region waterbox block 0 11.0025815964 0 8.25194 9 25 units box
create_atoms 0 region waterbox mol h2omol 45585 units box
lattice none 1

group Pd type 1
group h2o type 2 3

pair_style hybrid/overlay eam/fs lj/cut/tip4p/long 2 3 1 1 0.1546 10
pair_coeff * * eam/fs Pd_Zhou04.eam.alloy Pd NULL NULL
pair_coeff * * lj/cut/tip4p/long 0 0
pair_coeff 2 2 lj/cut/tip4p/long 0.008 3.1589
pair_coeff 3 3 lj/cut/tip4p/long 0.0 0.0

kspace_style pppm/tip4p 1.0e-4
kspace_modify gewald 0.2428
bond_style harmonic
angle_style harmonic

bond_coeff 1 0 0.9572
angle_coeff 1 0 104.52

fix mynvt1 Pd nvt temp 300 300 100
fix mynvt2 h2o nvt temp 300 300 100
fix wshake h2o shake 0.0001 50 0 b 1 a 1 mol h2omol

compute_modify thermo_temp dynamic/dof yes
compute_modify mynvt1_temp dynamic/dof yes
compute_modify mynvt2_temp dynamic/dof yes

timestep 1.0
thermo 100
thermo_style custom step pe ke etotal
thermo_modify flush yes

dump 1 all custom 100 traj_nvt.lammpstrj id type q x y z
dump_modify 1 sort id

run 2000

reset_timestep 0

#Gcmc
variable tfac equal 5.0/3.0 # (3 trans + 2 rot)/(3 trans)
fix mygcmc h2o gcmc 100 100 0 0 54341 300 -0.5 0.1 mol h2omol tfac_insert ${tfac} group h2o shake wshake region waterbox

variable oxygen atom “type==2”
variable hydrogen atom “type==3”

So, I still have the same error on the fix gcmc part. From my understanding in this input file, the block of water insertion in gcmc should be the same as waterblock I specified above. (range: 0 11.0025815964 0 8.25194 9 25) because I’ve added the units box in region command. So I assumed when I called the gcmc region as in water box, it should be able to insert/delete the water molecules in waterblock region.

Thank you for your help and your time again !

You should upgrade to a more recent version of LAMMPS. There have been multiple issues fixed with fix gcmc since 2020.

The relevant information about the box dimensions is in the data file “data.now”.
You have to watch out for rounding issues, so it would be safe to make the “waterbox” region a tiny bit smaller where it should match the box dimensions.