Hi all,
I am trying to initialize CO2 and H2O molecules on a simple cubic grid. My script (shown below) works perfectly fine when run in serial, but as soon as I run it on multiple processors it gives the following error:
LAMMPS (3 Mar 2020)
Lattice spacing in x,y,z = 4 4 4
Created orthogonal box = (0 0 0) to (40 40 40)
3 by 2 by 2 MPI processor grid
Read molecule co2mol:
3 atoms with max type 2
2 bonds with max type 1
1 angles with max type 1
0 dihedrals with max type 0
0 impropers with max type 0
Read molecule h2omol:
3 atoms with max type 2
2 bonds with max type 2
1 angles with max type 2
0 dihedrals with max type 0
0 impropers with max type 0
filip,
this is a bug in a (rather new) feature of the create_atoms code that is caused by the fact, that your choice of regions create a situation where there are no atoms created on some MPI ranks for during one of the create_atoms commands, and the code to select the ratio did not account for that. when running on a single MPI ranks, that is obviously not the case, hence no crash.
these two one liner changes to the random_mars.cpp file should correct it:
diff --git a/src/random_mars.cpp b/src/random_mars.cpp
index 36fd2b4bc…66c12f8ff 100644
— a/src/random_mars.cpp
+++ b/src/random_mars.cpp
@@ -201,7 +201,7 @@ void RanMars::select_subset(bigint ntarget, int nmine, int *mark, int *next)
for (int i = 0; i < nmine; i++) mark[i] = 0;
for (int i = 0; i < nmine; i++) next[i] = i+1;
- if (nmine > 0) next[nmine-1] = -1;
nmark = 0;
niter = 0;
@@ -241,7 +241,7 @@ void RanMars::select_subset(bigint ntarget, int nmine, int *mark, int *next)
// flip each value based on RN < thresh
nflip = 0;
- while ((nmine > 0) && (index >= 0)) {
if (uniform() < thresh) {
mark[index] = newvalue;
nflip++;
a simple workaround would be to run initially in serial and just create the atoms and write out a data file.
then continue in parallel from the data file you created.
doing this (even with the bugfix and both in parallel) would be a good idea as well, as read_data will automatically determine the optimal settings for that you now need to provide as “extra” parameters when creating the box.
as for using random placement instead of lattice positions.
that is easily resolved by starting your simulation with a different pair style, e.g. soft that has no discontinuity at short distance and you can adjust the amount of repulsion. run minimization / md for a little while at increasing height of the potential repulsion to “unoverlap” the atoms/molecules
and then once you reached a sufficiently regular configuration, switch to the actually desired pair style. the micelle example has a demo for that.
this process is often preferred over starting from a regular lattice, as it can take a long time even when running at elevated temperature to remove the “memory” of the regular lattice geometry from the system.
axel.