Commit 5779fc40 authored by athomps's avatar athomps
Browse files

Added group keywords to fix gcmc

git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@13453 f3b2605a-c512-4ea7-a41b-209d697bcdaa
parent 73a87e79
Loading
Loading
Loading
Loading
+19 −23
Original line number Diff line number Diff line
@@ -293,7 +293,9 @@ void FixGCMC::options(int narg, char **arg)
      if (iarg+2 > narg) error->all(FLERR,"Illegal fix gcmc command");
      if (ngroups >= ngroupsmax) {
	ngroupsmax = ngroups+1;
	groupstrings = (char**) memory->srealloc(groupstrings,ngroupsmax*sizeof(char *),
	groupstrings = (char **) 
	  memory->srealloc(groupstrings,
			   ngroupsmax*sizeof(char *),
			   "fix_gcmc:groupstrings");
      }
      int n = strlen(arg[iarg+1]) + 1;
@@ -307,7 +309,9 @@ void FixGCMC::options(int narg, char **arg)
	ngrouptypesmax = ngrouptypes+1;
	grouptypes = (int*) memory->srealloc(grouptypes,ngrouptypesmax*sizeof(int),
			 "fix_gcmc:grouptypes");
	grouptypestrings = (char**) memory->srealloc(grouptypestrings,ngrouptypesmax*sizeof(char *),
	grouptypestrings = (char**) 
	  memory->srealloc(grouptypestrings,
			   ngrouptypesmax*sizeof(char *),
			   "fix_gcmc:grouptypestrings");
      }
      grouptypes[ngrouptypes] = atoi(arg[iarg+1]);
@@ -339,16 +343,6 @@ FixGCMC::~FixGCMC()
    delete [] group_arg;
  } 

  // This seems to be causing seg-faults
  
  if (exclusion_group && (strcmp(group->names[0],"all") == 0)) {
    char **group_arg = new char*[2];
    group_arg[0] = group->names[exclusion_group];
    group_arg[1] = (char *) "delete";
    group->assign(2,group_arg);
    delete [] group_arg;
  } 

  memory->destroy(local_gas_list);
  memory->destroy(atom_coord);
  memory->destroy(coords);
@@ -357,17 +351,15 @@ FixGCMC::~FixGCMC()
  delete [] idshake;

  if (ngroups > 0) {
    for (int igroup = 0; igroup < ngroups; igroup++)
      delete [] groupstrings[igroup];
    // calling 2d destructor
    memory->destroy(groupstrings);
  }

  if (ngrouptypes > 0) {
    for (int igroup = 0; igroup < ngrouptypes; igroup++)
      delete [] grouptypestrings[igroup];
    memory->destroy(grouptypestrings);
    memory->destroy(grouptypes);
    memory->destroy(grouptypebits);
    // calling 2d destructor
    memory->destroy(grouptypestrings);
  }
}

@@ -494,6 +486,8 @@ void FixGCMC::init()
    arg[3] = (char *) "all";
    neighbor->modify_params(narg,arg);
    delete [] group_arg[0];
    delete [] group_arg;
    delete [] arg;
  }
    
  // create a new group for temporary use with selected molecules
@@ -515,6 +509,7 @@ void FixGCMC::init()
    molecule_group_bit = group->bitmask[molecule_group];
    molecule_group_inversebit = molecule_group_bit ^ ~0;
    delete [] group_arg[0];
    delete [] group_arg;
  }
    
  // get all of the needed molecule data if mode == MOLECULE, 
@@ -1364,6 +1359,7 @@ void FixGCMC::attempt_atomic_translation_full()
void FixGCMC::attempt_atomic_deletion_full()
{
  double q_tmp;
  const int q_flag = atom->q_flag;

  ndeletion_attempts += 1.0;

@@ -1371,13 +1367,13 @@ void FixGCMC::attempt_atomic_deletion_full()
  
  double energy_before = energy_stored;

  int i = pick_random_gas_atom();
  const int i = pick_random_gas_atom();

  int tmpmask;
  if (i >= 0) {
    tmpmask = atom->mask[i];
    atom->mask[i] = exclusion_group_bit;
    if (atom->q_flag) {
    if (q_flag) {
      q_tmp = atom->q[i];
      atom->q[i] = 0.0;
    }
@@ -1398,7 +1394,7 @@ void FixGCMC::attempt_atomic_deletion_full()
  } else {
    if (i >= 0) {
      atom->mask[i] = tmpmask;
      if (atom->q_flag) atom->q[i] = q_tmp;
      if (q_flag) atom->q[i] = q_tmp;
    }
    if (force->kspace) force->kspace->qsum_qsq();
    energy_stored = energy_before;