I’m trying to generate a density profile from the example GCMC script (examples/mc/in.gcmc.co2), Carbon is a dynamic group defined in (group carbon dynamic co2 var carbon)
I added
compute C_chunks carbon chunk/atom bin/1d x 0.0 1.0 units box ids every
compute nC_chunks carbon property/chunk C_chunks count
and
fix nC_x all ave/time 100 10 1000 c_nC_chunks file “C_profile.txt” mode vector
or
fix rhoC_x all ave/chunk 100 10 1000 C_chunks density/number norm sample ave window 100 file “C_rho.txt”
It produces an error:
Fix STORE/ATOM does not allow use with a dynamic group
I find that if I define chunks on all atoms (or any other static group):
compute chunks all chunk/atom bin/1d x 0.0 1.0 units box ids every
compute nC_chunks carbon property/chunk chunks count
The program can run correctly, but I’m doubting if “compute chunk/atom” correctly renew the groups for a dynamic group when running GCMC.
You can do the analysis you are looking for completely without dynamics groups using:
compute C_chunks all chunk/atom bin/1d x 0.0 1.0 units box ids every
compute C_count all reduce/chunk C_chunks sum v_carbon
fix nC_x1 all ave/time 100 10 1000 c_C_count file "C_counts.txt" mode vector
but you should find that this produces the exact same output as:
compute C_chunks all chunk/atom bin/1d x 0.0 1.0 units box ids every
compute nC_chunks carbon property/chunk C_chunks count
fix nC_x2 all ave/time 100 10 1000 c_nC_chunks file "C_profile.txt" mode vector
It looks like your doubt is not confirmed.
Upon a closer look, there is nothing technical in compute chunk/atom that would make it incompatible with dynamic groups. Also, the error message is misleading. This can be addressed by the following changes to the source code:
diff --git a/src/compute_chunk_atom.cpp b/src/compute_chunk_atom.cpp
index 750849a04b..a7f36daacc 100644
--- a/src/compute_chunk_atom.cpp
+++ b/src/compute_chunk_atom.cpp
@@ -591,7 +591,7 @@ void ComputeChunkAtom::init()
if ((idsflag == ONCE || lockcount) && !fixstore) {
id_fix = utils::strdup(id + std::string("_COMPUTE_STORE"));
fixstore = dynamic_cast<FixStoreAtom *>(
- modify->add_fix(fmt::format("{} {} STORE/ATOM 1 0 0 1", id_fix, group->names[igroup])));
+ modify->add_fix(fmt::format("{} all STORE/ATOM 1 0 0 1", id_fix)));
}
if ((idsflag != ONCE && !lockcount) && fixstore) {
diff --git a/src/fix_store_atom.cpp b/src/fix_store_atom.cpp
index 461959d264..4bc7d6301d 100644
--- a/src/fix_store_atom.cpp
+++ b/src/fix_store_atom.cpp
@@ -38,6 +38,7 @@ FixStoreAtom::FixStoreAtom(LAMMPS *lmp, int narg, char **arg) :
if (narg != 7) error->all(FLERR, "Illegal fix STORE/ATOM command: number of args");
disable = 0;
+ dynamic_group_allow = 1;
n1 = utils::inumeric(FLERR, arg[3], false, lmp);
n2 = utils::inumeric(FLERR, arg[4], false, lmp);
diff --git a/src/fix_store_global.cpp b/src/fix_store_global.cpp
index 89577893cd..72d82d506a 100644
--- a/src/fix_store_global.cpp
+++ b/src/fix_store_global.cpp
@@ -33,6 +33,7 @@ FixStoreGlobal::FixStoreGlobal(LAMMPS *lmp, int narg, char **arg) :
// N2 = 1 is vector, N2 > 1 is array, no tensor allowed (yet)
vecflag = arrayflag = 0;
+ dynamic_group_allow = 1;
restart_global = 1;
n1 = utils::inumeric(FLERR, arg[3], false, lmp);