Update gcmc to have a max and min

This commit is contained in:
Jared
2019-06-27 17:50:45 +02:00
parent 0849e03d1b
commit eb9f5cf128
2 changed files with 24 additions and 4 deletions

View File

@ -272,6 +272,8 @@ void FixGCMC::options(int narg, char **arg)
tfac_insert = 1.0;
overlap_cutoffsq = 0.0;
overlap_flag = 0;
min_ngas = -1;
max_ngas = -1;
int iarg = 0;
while (iarg < narg) {
@ -391,6 +393,14 @@ void FixGCMC::options(int narg, char **arg)
overlap_cutoffsq = rtmp*rtmp;
overlap_flag = 1;
iarg += 2;
} else if (strcmp(arg[iarg],"min") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix gcmc command");
min_ngas = force->numeric(FLERR,arg[iarg+1]);
iarg += 2;
} else if (strcmp(arg[iarg],"max") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix gcmc command");
max_ngas = force->numeric(FLERR,arg[iarg+1]);
iarg += 2;
} else error->all(FLERR,"Illegal fix gcmc command");
}
}
@ -897,7 +907,7 @@ void FixGCMC::attempt_atomic_deletion()
{
ndeletion_attempts += 1.0;
if (ngas == 0) return;
if (ngas == 0 || ngas == min_ngas) return;
int i = pick_random_gas_atom();
@ -938,6 +948,8 @@ void FixGCMC::attempt_atomic_insertion()
ninsertion_attempts += 1.0;
if (ngas == max_ngas) return;
// pick coordinates for insertion point
double coord[3];
@ -1252,7 +1264,7 @@ void FixGCMC::attempt_molecule_deletion()
{
ndeletion_attempts += 1.0;
if (ngas == 0) return;
if (ngas == 0 || ngas == min_ngas) return;
// work-around to avoid n=0 problem with fix rigid/nvt/small
@ -1291,6 +1303,8 @@ void FixGCMC::attempt_molecule_insertion()
double lamda[3];
ninsertion_attempts += 1.0;
if (ngas == max_ngas) return;
double com_coord[3];
if (regionflag) {
int region_attempt = 0;
@ -1574,7 +1588,7 @@ void FixGCMC::attempt_atomic_deletion_full()
ndeletion_attempts += 1.0;
if (ngas == 0) return;
if (ngas == 0 || ngas == min_ngas) return;
double energy_before = energy_stored;
@ -1623,6 +1637,8 @@ void FixGCMC::attempt_atomic_insertion_full()
double lamda[3];
ninsertion_attempts += 1.0;
if (ngas == max_ngas) return;
double energy_before = energy_stored;
double coord[3];
@ -1918,7 +1934,7 @@ void FixGCMC::attempt_molecule_deletion_full()
{
ndeletion_attempts += 1.0;
if (ngas == 0) return;
if (ngas == 0 || ngas == min_ngas) return;
// work-around to avoid n=0 problem with fix rigid/nvt/small
@ -2001,6 +2017,8 @@ void FixGCMC::attempt_molecule_insertion_full()
double lamda[3];
ninsertion_attempts += 1.0;
if (ngas == max_ngas) return;
double energy_before = energy_stored;
tagint maxmol = 0;

View File

@ -120,6 +120,8 @@ class FixGCMC : public Fix {
imageint imagezero;
double overlap_cutoffsq; // square distance cutoff for overlap
int overlap_flag;
int max_ngas;
int min_ngas;
double energy_intra;