I then want to restrict the region on which mc operate for that I specify my region as:
region mc prism 0 22.857331427793579 0 EDGE 28 32 10.084116806379519 0 0
Thinking that this box is the exact same one I specified in the data file, but then I get the error:
Fix gcmc region extends outside simulation box (src/MC/fix_gcmc.cpp:144)
Last command: fix gcmc_equi gas gcmc 50 10 50 2 147028938 350.0 -72.15115097 0.025 overlap_cutoff 0.7 full_energy region mc
After carefully reading the documentation I guess this is happening because:
“For non-rectangular regions, random trial points are generated within the rectangular bounding box until a point is found that lies inside the region.”
I tried to reduce the region and the biggest I can get is:
region mc prism 0 $(22.857331427793579 - 10.084116806379519) 0 EDGE 28 32 10.084116806379519 0 0
Which reinforces my opinion on the rectangular problem, since a bigger box than this one would create a rectangular region falling outside the range of x?
Is this me being stupid? Is there a way to do what I want to do?
From looking at the source code in fix gcmc and in region prism it looks to me as if the case of a non-orthogonal box for restricting the region for inserting atoms has not been considered.
If my understanding of the relevant source code is correct, the following modification should add the lacking triclinic cell support to this specific check.
To test fix gcmc, my input file code is as follows:
boundary p p p # 3D box
units metal # do not change!
atom_style atomic # do not change!
atom_modify map array sort 99999 1.0 # Recommend
read_data 1.data
mass 1 55.845 # Fe
mass 2 12.0107 # C
mass 3 1.00794 # H gcmc
timestep 0.0005
pair_style laspnn # do not change!
neighbor 2.0 bin
neigh_modify every 1 delay 0 check yes # Recommend
# ----- Relax calculation (0 K) -----
print "----- Relax calculation (0 K) -----"
fix f1 all box/relax iso 0.0
minimize 1.0e-10 0.0 1000 100000
unfix f1
# ----- reset timestep and dt -----
reset_timestep 0
timestep 0.0005
# ----- GCMC Calculation-----
print "----- GCMC Calculation -----"
region bottom prism 0.0 18.6898 0.0 20.2274 0 6 -3.1459 0.0 0.0 units box#Fe5C2 fix
group bottom region bottom
velocity bottom set 0 0 0
fix 1 bottom setforce 0 0 0
region mobile2 prism 0.0 18.6898 0.0 20.2274 0 27.2972 -3.1459 0.0 0.0 side in units box#Fe5C2 unfix
group mobile2 region mobile2 #gcmc
group FeC type 1:2 # 1=Fe, 2=C
group g1 type 3 # 3=H
fix f1 g1 nvt temp 550 550 0.05
fix f2 g1 gcmc 10 100 100 3 7618 550 -5.4 0.1 pressure 1.1 #region mobile2
# ----- atom count -----
variable type1 atom "type==1" # Fe
variable type2 atom "type==2" # C
variable type3 atom "type==3" # H
group type1 dynamic FeC var type1 # Fe
group type2 dynamic FeC var type2 # C
group type3 dynamic g1 var type3 # H
variable na equal count(type1) # Fe
variable nb equal count(type2) # C
variable nc equal count(type3) # H
compute_modify thermo_temp dynamic/dof yes
thermo_style custom step temp press pe ke density atoms v_na v_nb v_nc
thermo 1
fix_modify f1 temp thermo_temp
dump 1 all atom 1 dump.atom
run 1000
This code worked fine。However,I will get the error"ERROR: Fix gcmc region extends outside simulation box (…/fix_gcmc.cpp:140)"when I use the keywords “region” whose value is “mobile2”
Can you tell me what I should I do?
Well, your region obviously extends beyond the box. This may be due to using fix box/relax (BTW why relax the box isotropically??) during the minimization, which will change the simulation box dimensions.
Thank you very much for your answer. I finally know what’s wrong with me. This code was modified on the basis of others. The original code explained that “fix f1 all box/relax iso 0.0” is necessary for energy minimization, so I didn’t care too much. After you pointed out the problem, I read the relevant parts of the manual carefully, and I realized that “fix box/real” appeared in my simulation is extremely inappropriate
During the last few days I had time to try out the fix you sent me. I can say that 50% of the time it works every time.
In my case it will sometimes perform just fine, sometimes throw me “box extend outside simulation box” or just get stuck forever (numerical inaccuracies?).
Should I be worried that this break something behind the scene and just get over this project?
I see that the contributors are “Paul Crozier, Aidan Thompson” should I contact them by email or are they active on this forum?
Paul is no longer actively working on LAMMPS (Authors of LAMMPS), Aidan is our “go-to person” in case of fix gcmc. He should be notified when using his @athomps handle in the forum.
But generally, if you have concerns like yours, the best approach is to submit an issue in the LAMMPS GitHub project at Issues · lammps/lammps · GitHub and include a small reproducer input deck. That way your issue will remain open unless somebody actively closes it. Emails and forum posts will fade from view quickly as new emails or forum posts come in.
After a few additional tests, it seems that the problem comes from MPI, when calling lammps without it your fix works quite well.
I am keen to open an issues on the official LAMMPS github. Should it be opened as “Bug” or “Feature request”? I will probably wait for the insight of @athomps first anyway.
Yes, please submit a bug report. Please provide an input script that demonstrates the issue. The one you show above has a lot of things in it that are probably unrelated to the issue. It would be helpful if you could eliminate as many of those as possible, before posting. This will increase the likelihood that we can quickly isolate the problem.