2006-09-28 03:51:33 +08:00
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
2007-01-30 08:22:05 +08:00
|
|
|
http://lammps.sandia.gov, Sandia National Laboratories
|
|
|
|
Steve Plimpton, sjplimp@sandia.gov
|
2006-09-28 03:51:33 +08:00
|
|
|
|
|
|
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
|
|
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
2012-06-07 06:47:51 +08:00
|
|
|
certain rights in this software. This software is distributed under
|
2006-09-28 03:51:33 +08:00
|
|
|
the GNU General Public License.
|
|
|
|
|
|
|
|
See the README file in the top-level LAMMPS directory.
|
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#include "mpi.h"
|
|
|
|
#include "stdlib.h"
|
|
|
|
#include "string.h"
|
|
|
|
#include "delete_bonds.h"
|
|
|
|
#include "atom.h"
|
2007-01-30 08:22:05 +08:00
|
|
|
#include "atom_vec.h"
|
2006-09-28 03:51:33 +08:00
|
|
|
#include "domain.h"
|
|
|
|
#include "neighbor.h"
|
|
|
|
#include "comm.h"
|
|
|
|
#include "force.h"
|
|
|
|
#include "group.h"
|
|
|
|
#include "special.h"
|
|
|
|
#include "error.h"
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
using namespace LAMMPS_NS;
|
|
|
|
|
2010-08-04 07:39:28 +08:00
|
|
|
enum{MULTI,ATOM,BOND,ANGLE,DIHEDRAL,IMPROPER,STATS};
|
2006-09-28 03:51:33 +08:00
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
DeleteBonds::DeleteBonds(LAMMPS *lmp) : Pointers(lmp) {}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
void DeleteBonds::command(int narg, char **arg)
|
|
|
|
{
|
2012-06-07 06:47:51 +08:00
|
|
|
if (domain->box_exist == 0)
|
2011-09-24 02:06:55 +08:00
|
|
|
error->all(FLERR,"Delete_bonds command before simulation box is defined");
|
2006-09-28 03:51:33 +08:00
|
|
|
if (atom->natoms == 0)
|
2011-09-24 02:06:55 +08:00
|
|
|
error->all(FLERR,"Delete_bonds command with no atoms existing");
|
2014-01-26 06:46:08 +08:00
|
|
|
if (atom->molecular != 1)
|
2011-09-24 02:06:55 +08:00
|
|
|
error->all(FLERR,"Cannot use delete_bonds with non-molecular system");
|
2014-01-26 06:46:08 +08:00
|
|
|
|
2011-09-24 02:06:55 +08:00
|
|
|
if (narg < 2) error->all(FLERR,"Illegal delete_bonds command");
|
2006-09-28 03:51:33 +08:00
|
|
|
|
|
|
|
// init entire system since comm->borders is done
|
|
|
|
// comm::init needs neighbor::init needs pair::init needs kspace::init, etc
|
|
|
|
|
|
|
|
if (comm->me == 0 && screen)
|
|
|
|
fprintf(screen,"System init for delete_bonds ...\n");
|
2007-01-30 08:22:05 +08:00
|
|
|
lmp->init();
|
2006-09-28 03:51:33 +08:00
|
|
|
|
|
|
|
if (comm->me == 0 && screen) fprintf(screen,"Deleting bonds ...\n");
|
|
|
|
|
|
|
|
// identify group
|
|
|
|
|
|
|
|
int igroup = group->find(arg[0]);
|
2011-09-24 02:06:55 +08:00
|
|
|
if (igroup == -1) error->all(FLERR,"Cannot find delete_bonds group ID");
|
2006-09-28 03:51:33 +08:00
|
|
|
int groupbit = group->bitmask[igroup];
|
2012-06-07 06:47:51 +08:00
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
// set style and which = type value
|
|
|
|
|
2014-04-18 23:25:28 +08:00
|
|
|
int style = -1;
|
2006-09-28 03:51:33 +08:00
|
|
|
if (strcmp(arg[1],"multi") == 0) style = MULTI;
|
|
|
|
else if (strcmp(arg[1],"atom") == 0) style = ATOM;
|
|
|
|
else if (strcmp(arg[1],"bond") == 0) style = BOND;
|
|
|
|
else if (strcmp(arg[1],"angle") == 0) style = ANGLE;
|
|
|
|
else if (strcmp(arg[1],"dihedral") == 0) style = DIHEDRAL;
|
|
|
|
else if (strcmp(arg[1],"improper") == 0) style = IMPROPER;
|
|
|
|
else if (strcmp(arg[1],"stats") == 0) style = STATS;
|
2011-09-24 02:06:55 +08:00
|
|
|
else error->all(FLERR,"Illegal delete_bonds command");
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2014-08-12 22:44:07 +08:00
|
|
|
// setup list of types (atom,bond,etc) to consider
|
|
|
|
// use force->bounds() to allow setting of range of types
|
|
|
|
// range can be 0 to ntypes inclusive
|
|
|
|
|
|
|
|
int *tlist = NULL;
|
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
int iarg = 2;
|
|
|
|
if (style != MULTI && style != STATS) {
|
2011-09-24 02:06:55 +08:00
|
|
|
if (narg < 3) error->all(FLERR,"Illegal delete_bonds command");
|
2014-08-12 22:44:07 +08:00
|
|
|
|
|
|
|
int n = -1;
|
|
|
|
if (style == ATOM) n = atom->ntypes;
|
|
|
|
if (style == BOND) n = atom->nbondtypes;
|
|
|
|
if (style == ANGLE) n = atom->nangletypes;
|
|
|
|
if (style == DIHEDRAL) n = atom->ndihedraltypes;
|
|
|
|
if (style == IMPROPER) n = atom->nimpropertypes;
|
|
|
|
|
|
|
|
tlist = new int[n+1];
|
|
|
|
for (int i = 0; i <= n; i++) tlist[i] = 0;
|
|
|
|
int nlo,nhi;
|
|
|
|
force->bounds(arg[2],n,nlo,nhi,0);
|
|
|
|
for (int i = nlo; i <= nhi; i++) tlist[i] = 1;
|
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
iarg++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// grab optional keywords
|
|
|
|
|
2012-02-29 01:41:29 +08:00
|
|
|
int any_flag = 0;
|
2006-09-28 03:51:33 +08:00
|
|
|
int undo_flag = 0;
|
|
|
|
int remove_flag = 0;
|
|
|
|
int special_flag = 0;
|
2013-02-20 00:13:19 +08:00
|
|
|
int induce_flag = 0;
|
2006-09-28 03:51:33 +08:00
|
|
|
|
|
|
|
while (iarg < narg) {
|
2012-02-29 01:41:29 +08:00
|
|
|
if (strcmp(arg[iarg],"any") == 0) any_flag = 1;
|
|
|
|
else if (strcmp(arg[iarg],"undo") == 0) undo_flag = 1;
|
2006-09-28 03:51:33 +08:00
|
|
|
else if (strcmp(arg[iarg],"remove") == 0) remove_flag = 1;
|
|
|
|
else if (strcmp(arg[iarg],"special") == 0) special_flag = 1;
|
2013-02-20 00:13:19 +08:00
|
|
|
else if (strcmp(arg[iarg],"induce") == 0) induce_flag = 1;
|
2011-09-24 02:06:55 +08:00
|
|
|
else error->all(FLERR,"Illegal delete_bonds command");
|
2006-09-28 03:51:33 +08:00
|
|
|
iarg++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// border swap to insure type and mask is current for off-proc atoms
|
|
|
|
// enforce PBC before in case atoms are outside box
|
|
|
|
|
2007-03-08 08:54:02 +08:00
|
|
|
if (domain->triclinic) domain->x2lamda(atom->nlocal);
|
2006-09-28 03:51:33 +08:00
|
|
|
domain->pbc();
|
|
|
|
domain->reset_box();
|
|
|
|
comm->setup();
|
|
|
|
comm->exchange();
|
|
|
|
comm->borders();
|
2007-03-08 08:54:02 +08:00
|
|
|
if (domain->triclinic) domain->lamda2x(atom->nlocal+atom->nghost);
|
2006-09-28 03:51:33 +08:00
|
|
|
|
|
|
|
// set topology interactions either off or on
|
|
|
|
// criteria for an interaction to potentially be changed (set flag = 1)
|
2013-02-20 00:13:19 +08:00
|
|
|
// all atoms or any atom in interaction must be in group, based on any_flag
|
|
|
|
// for style = MULTI, all bond/angle/dihedral/improper, no other criteria
|
2014-08-12 22:44:07 +08:00
|
|
|
// for style = ATOM, same as MULTI, plus at least one atom is specified type
|
2006-09-28 03:51:33 +08:00
|
|
|
// for style = BOND/ANGLE/DIHEDRAL/IMPROPER, interaction is specified type
|
|
|
|
// for style = STATS only compute stats, flag is always 0
|
|
|
|
// if flag = 1
|
|
|
|
// set interaction type negative if undo_flag = 0
|
|
|
|
// set interaction type positive if undo_flag = 1
|
|
|
|
|
|
|
|
int *mask = atom->mask;
|
|
|
|
int *type = atom->type;
|
|
|
|
int nlocal = atom->nlocal;
|
|
|
|
|
2014-08-12 22:44:07 +08:00
|
|
|
int i,m,n,consider,flag,itype;
|
2006-09-28 03:51:33 +08:00
|
|
|
int atom1,atom2,atom3,atom4;
|
|
|
|
|
2013-02-20 00:13:19 +08:00
|
|
|
if (atom->avec->bonds_allow &&
|
|
|
|
(style == BOND || style == MULTI || style == ATOM)) {
|
2006-09-28 03:51:33 +08:00
|
|
|
int *num_bond = atom->num_bond;
|
|
|
|
int **bond_type = atom->bond_type;
|
|
|
|
|
|
|
|
for (i = 0; i < nlocal; i++) {
|
|
|
|
for (m = 0; m < num_bond[i]; m++) {
|
2012-06-07 06:47:51 +08:00
|
|
|
atom1 = atom->map(atom->bond_atom[i][m]);
|
|
|
|
if (atom1 == -1) error->one(FLERR,"Bond atom missing in delete_bonds");
|
|
|
|
consider = 0;
|
|
|
|
if (!any_flag && mask[i] & groupbit && mask[atom1] & groupbit)
|
|
|
|
consider = 1;
|
|
|
|
if (any_flag && (mask[i] & groupbit || mask[atom1] & groupbit))
|
|
|
|
consider = 1;
|
|
|
|
if (consider) {
|
|
|
|
flag = 0;
|
|
|
|
if (style == MULTI) flag = 1;
|
2014-08-12 22:44:07 +08:00
|
|
|
else if (style == ATOM) {
|
|
|
|
if (tlist[type[i]] || tlist[type[atom1]]) flag = 1;
|
|
|
|
} else if (style == BOND) {
|
2014-08-15 00:30:03 +08:00
|
|
|
itype = abs(bond_type[i][m]);
|
2014-08-12 22:44:07 +08:00
|
|
|
if (tlist[itype]) flag = 1;
|
|
|
|
}
|
2012-06-07 06:47:51 +08:00
|
|
|
if (flag) {
|
|
|
|
if (undo_flag == 0 && bond_type[i][m] > 0)
|
|
|
|
bond_type[i][m] = -bond_type[i][m];
|
|
|
|
if (undo_flag == 1 && bond_type[i][m] < 0)
|
|
|
|
bond_type[i][m] = -bond_type[i][m];
|
|
|
|
}
|
|
|
|
}
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-20 00:13:19 +08:00
|
|
|
if (atom->avec->angles_allow &&
|
|
|
|
(style == ANGLE || style == MULTI || style == ATOM)) {
|
2006-09-28 03:51:33 +08:00
|
|
|
int *num_angle = atom->num_angle;
|
|
|
|
int **angle_type = atom->angle_type;
|
|
|
|
|
|
|
|
for (i = 0; i < nlocal; i++) {
|
|
|
|
for (m = 0; m < num_angle[i]; m++) {
|
2012-06-07 06:47:51 +08:00
|
|
|
atom1 = atom->map(atom->angle_atom1[i][m]);
|
|
|
|
atom2 = atom->map(atom->angle_atom2[i][m]);
|
|
|
|
atom3 = atom->map(atom->angle_atom3[i][m]);
|
|
|
|
if (atom1 == -1 || atom2 == -1 || atom3 == -1)
|
|
|
|
error->one(FLERR,"Angle atom missing in delete_bonds");
|
|
|
|
consider = 0;
|
|
|
|
if (!any_flag && mask[atom1] & groupbit && mask[atom2] & groupbit &&
|
|
|
|
mask[atom3] & groupbit) consider = 1;
|
|
|
|
if (any_flag && (mask[atom1] & groupbit || mask[atom2] & groupbit ||
|
|
|
|
mask[atom3] & groupbit)) consider = 1;
|
|
|
|
if (consider) {
|
|
|
|
flag = 0;
|
|
|
|
if (style == MULTI) flag = 1;
|
2014-08-12 22:44:07 +08:00
|
|
|
else if (style == ATOM) {
|
|
|
|
if (tlist[type[atom1]] || tlist[type[atom2]] ||
|
|
|
|
tlist[type[atom3]]) flag = 1;
|
|
|
|
} else if (style == ANGLE) {
|
2014-08-15 00:30:03 +08:00
|
|
|
itype = abs(angle_type[i][m]);
|
2014-08-12 22:44:07 +08:00
|
|
|
if (tlist[itype]) flag = 1;
|
|
|
|
}
|
2012-06-07 06:47:51 +08:00
|
|
|
if (flag) {
|
|
|
|
if (undo_flag == 0 && angle_type[i][m] > 0)
|
|
|
|
angle_type[i][m] = -angle_type[i][m];
|
|
|
|
if (undo_flag == 1 && angle_type[i][m] < 0)
|
|
|
|
angle_type[i][m] = -angle_type[i][m];
|
|
|
|
}
|
|
|
|
}
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-20 00:13:19 +08:00
|
|
|
if (atom->avec->dihedrals_allow &&
|
|
|
|
(style == DIHEDRAL || style == MULTI || style == ATOM)) {
|
2006-09-28 03:51:33 +08:00
|
|
|
int *num_dihedral = atom->num_dihedral;
|
|
|
|
int **dihedral_type = atom->dihedral_type;
|
|
|
|
|
|
|
|
for (i = 0; i < nlocal; i++) {
|
|
|
|
for (m = 0; m < num_dihedral[i]; m++) {
|
2012-06-07 06:47:51 +08:00
|
|
|
atom1 = atom->map(atom->dihedral_atom1[i][m]);
|
|
|
|
atom2 = atom->map(atom->dihedral_atom2[i][m]);
|
|
|
|
atom3 = atom->map(atom->dihedral_atom3[i][m]);
|
|
|
|
atom4 = atom->map(atom->dihedral_atom4[i][m]);
|
|
|
|
if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1)
|
|
|
|
error->one(FLERR,"Dihedral atom missing in delete_bonds");
|
|
|
|
consider = 0;
|
|
|
|
if (!any_flag && mask[atom1] & groupbit && mask[atom2] & groupbit &&
|
|
|
|
mask[atom3] & groupbit && mask[atom4] & groupbit) consider = 1;
|
|
|
|
if (any_flag && (mask[atom1] & groupbit || mask[atom2] & groupbit ||
|
|
|
|
mask[atom3] & groupbit || mask[atom4] & groupbit))
|
|
|
|
consider = 1;
|
|
|
|
if (consider) {
|
|
|
|
flag = 0;
|
|
|
|
if (style == MULTI) flag = 1;
|
2014-08-12 22:44:07 +08:00
|
|
|
else if (style == ATOM) {
|
|
|
|
if (tlist[type[atom1]] || tlist[type[atom2]] ||
|
|
|
|
tlist[type[atom3]] || tlist[type[atom4]]) flag = 1;
|
|
|
|
} else if (style == DIHEDRAL) {
|
2014-08-15 00:30:03 +08:00
|
|
|
itype = abs(dihedral_type[i][m]);
|
2014-08-12 22:44:07 +08:00
|
|
|
if (tlist[itype]) flag = 1;
|
|
|
|
}
|
2012-06-07 06:47:51 +08:00
|
|
|
if (flag) {
|
|
|
|
if (undo_flag == 0 && dihedral_type[i][m] > 0)
|
|
|
|
dihedral_type[i][m] = -dihedral_type[i][m];
|
|
|
|
if (undo_flag == 1 && dihedral_type[i][m] < 0)
|
|
|
|
dihedral_type[i][m] = -dihedral_type[i][m];
|
|
|
|
}
|
|
|
|
}
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-20 00:13:19 +08:00
|
|
|
if (atom->avec->impropers_allow &&
|
|
|
|
(style == IMPROPER || style == MULTI || style == ATOM)) {
|
2006-09-28 03:51:33 +08:00
|
|
|
int *num_improper = atom->num_improper;
|
|
|
|
int **improper_type = atom->improper_type;
|
|
|
|
|
|
|
|
for (i = 0; i < nlocal; i++) {
|
|
|
|
for (m = 0; m < num_improper[i]; m++) {
|
2012-06-07 06:47:51 +08:00
|
|
|
atom1 = atom->map(atom->improper_atom1[i][m]);
|
|
|
|
atom2 = atom->map(atom->improper_atom2[i][m]);
|
|
|
|
atom3 = atom->map(atom->improper_atom3[i][m]);
|
|
|
|
atom4 = atom->map(atom->improper_atom4[i][m]);
|
|
|
|
if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1)
|
|
|
|
error->one(FLERR,"Improper atom missing in delete_bonds");
|
|
|
|
consider = 0;
|
|
|
|
if (!any_flag && mask[atom1] & groupbit && mask[atom2] & groupbit &&
|
|
|
|
mask[atom3] & groupbit && mask[atom4] & groupbit) consider = 1;
|
|
|
|
if (any_flag && (mask[atom1] & groupbit || mask[atom2] & groupbit ||
|
|
|
|
mask[atom3] & groupbit || mask[atom4] & groupbit))
|
|
|
|
consider = 1;
|
|
|
|
if (consider) {
|
|
|
|
flag = 0;
|
|
|
|
if (style == MULTI) flag = 1;
|
2014-08-12 22:44:07 +08:00
|
|
|
else if (style == ATOM) {
|
|
|
|
if (tlist[type[atom1]] || tlist[type[atom2]] ||
|
|
|
|
tlist[type[atom3]] || tlist[type[atom4]]) flag = 1;
|
|
|
|
} else if (style == IMPROPER) {
|
2014-08-15 00:30:03 +08:00
|
|
|
itype = abs(improper_type[i][m]);
|
2014-08-12 22:44:07 +08:00
|
|
|
if (tlist[itype]) flag = 1;
|
|
|
|
}
|
2012-06-07 06:47:51 +08:00
|
|
|
if (flag) {
|
|
|
|
if (undo_flag == 0 && improper_type[i][m] > 0)
|
|
|
|
improper_type[i][m] = -improper_type[i][m];
|
|
|
|
if (undo_flag == 1 && improper_type[i][m] < 0)
|
|
|
|
improper_type[i][m] = -improper_type[i][m];
|
|
|
|
}
|
|
|
|
}
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-12 22:44:07 +08:00
|
|
|
delete [] tlist;
|
|
|
|
|
2013-02-20 00:13:19 +08:00
|
|
|
// induce turn off of angles, dihedral, impropers due to turned off bonds
|
|
|
|
// induce turn off of dihedrals due to turned off angles
|
|
|
|
// all atoms or any atom in interaction must be in group, based on any_flag
|
|
|
|
|
|
|
|
if (induce_flag) {
|
|
|
|
|
|
|
|
// circulate list of turned off bonds around ring of procs
|
|
|
|
|
|
|
|
// circulate list of turned off angles around ring of procs
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
// remove interactions if requested
|
2013-02-20 00:13:19 +08:00
|
|
|
// all atoms or any atom in interaction must be in group, based on any_flag
|
2006-09-28 03:51:33 +08:00
|
|
|
|
|
|
|
if (remove_flag) {
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
if (atom->avec->bonds_allow) {
|
2006-09-28 03:51:33 +08:00
|
|
|
for (i = 0; i < nlocal; i++) {
|
2012-06-07 06:47:51 +08:00
|
|
|
m = 0;
|
|
|
|
while (m < atom->num_bond[i]) {
|
|
|
|
if (atom->bond_type[i][m] <= 0) {
|
|
|
|
atom1 = atom->map(atom->bond_atom[i][m]);
|
2013-02-20 00:13:19 +08:00
|
|
|
flag = 0;
|
|
|
|
if (!any_flag && mask[i] & groupbit && mask[atom1] & groupbit)
|
|
|
|
flag = 1;
|
|
|
|
if (any_flag && (mask[i] & groupbit || mask[atom1] & groupbit))
|
|
|
|
flag = 1;
|
|
|
|
if (flag) {
|
2012-06-07 06:47:51 +08:00
|
|
|
n = atom->num_bond[i];
|
|
|
|
atom->bond_type[i][m] = atom->bond_type[i][n-1];
|
|
|
|
atom->bond_atom[i][m] = atom->bond_atom[i][n-1];
|
|
|
|
atom->num_bond[i]--;
|
|
|
|
} else m++;
|
|
|
|
} else m++;
|
|
|
|
}
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
if (atom->avec->angles_allow) {
|
2006-09-28 03:51:33 +08:00
|
|
|
for (i = 0; i < nlocal; i++) {
|
2012-06-07 06:47:51 +08:00
|
|
|
m = 0;
|
|
|
|
while (m < atom->num_angle[i]) {
|
|
|
|
if (atom->angle_type[i][m] <= 0) {
|
|
|
|
atom1 = atom->map(atom->angle_atom1[i][m]);
|
|
|
|
atom2 = atom->map(atom->angle_atom2[i][m]);
|
|
|
|
atom3 = atom->map(atom->angle_atom3[i][m]);
|
2013-02-20 00:13:19 +08:00
|
|
|
flag = 0;
|
|
|
|
if (!any_flag && mask[atom1] & groupbit && mask[atom2] & groupbit &&
|
|
|
|
mask[atom3] & groupbit) flag = 1;
|
|
|
|
if (any_flag && (mask[atom1] & groupbit || mask[atom2] & groupbit ||
|
|
|
|
mask[atom3] & groupbit)) flag = 1;
|
|
|
|
if (flag) {
|
2012-06-07 06:47:51 +08:00
|
|
|
n = atom->num_angle[i];
|
|
|
|
atom->angle_type[i][m] = atom->angle_type[i][n-1];
|
|
|
|
atom->angle_atom1[i][m] = atom->angle_atom1[i][n-1];
|
|
|
|
atom->angle_atom2[i][m] = atom->angle_atom2[i][n-1];
|
|
|
|
atom->angle_atom3[i][m] = atom->angle_atom3[i][n-1];
|
|
|
|
atom->num_angle[i]--;
|
|
|
|
} else m++;
|
|
|
|
} else m++;
|
|
|
|
}
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
if (atom->avec->dihedrals_allow) {
|
2006-09-28 03:51:33 +08:00
|
|
|
for (i = 0; i < nlocal; i++) {
|
2012-06-07 06:47:51 +08:00
|
|
|
m = 0;
|
|
|
|
while (m < atom->num_dihedral[i]) {
|
|
|
|
if (atom->dihedral_type[i][m] <= 0) {
|
|
|
|
atom1 = atom->map(atom->dihedral_atom1[i][m]);
|
|
|
|
atom2 = atom->map(atom->dihedral_atom2[i][m]);
|
|
|
|
atom3 = atom->map(atom->dihedral_atom3[i][m]);
|
|
|
|
atom4 = atom->map(atom->dihedral_atom4[i][m]);
|
2013-02-20 00:13:19 +08:00
|
|
|
flag = 0;
|
|
|
|
if (!any_flag && mask[atom1] & groupbit && mask[atom2] & groupbit &&
|
|
|
|
mask[atom3] & groupbit && mask[atom4] & groupbit) flag = 1;
|
|
|
|
if (any_flag && (mask[atom1] & groupbit || mask[atom2] & groupbit ||
|
|
|
|
mask[atom3] & groupbit || mask[atom4] & groupbit))
|
|
|
|
flag = 1;
|
|
|
|
if (flag) {
|
2012-06-07 06:47:51 +08:00
|
|
|
n = atom->num_dihedral[i];
|
|
|
|
atom->dihedral_type[i][m] = atom->dihedral_type[i][n-1];
|
|
|
|
atom->dihedral_atom1[i][m] = atom->dihedral_atom1[i][n-1];
|
|
|
|
atom->dihedral_atom2[i][m] = atom->dihedral_atom2[i][n-1];
|
|
|
|
atom->dihedral_atom3[i][m] = atom->dihedral_atom3[i][n-1];
|
|
|
|
atom->dihedral_atom4[i][m] = atom->dihedral_atom4[i][n-1];
|
|
|
|
atom->num_dihedral[i]--;
|
|
|
|
} else m++;
|
|
|
|
} else m++;
|
|
|
|
}
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
if (atom->avec->impropers_allow) {
|
2006-09-28 03:51:33 +08:00
|
|
|
for (i = 0; i < nlocal; i++) {
|
2012-06-07 06:47:51 +08:00
|
|
|
m = 0;
|
|
|
|
while (m < atom->num_improper[i]) {
|
|
|
|
if (atom->improper_type[i][m] <= 0) {
|
|
|
|
atom1 = atom->map(atom->improper_atom1[i][m]);
|
|
|
|
atom2 = atom->map(atom->improper_atom2[i][m]);
|
|
|
|
atom3 = atom->map(atom->improper_atom3[i][m]);
|
|
|
|
atom4 = atom->map(atom->improper_atom4[i][m]);
|
2013-02-20 00:13:19 +08:00
|
|
|
flag = 0;
|
|
|
|
if (!any_flag && mask[atom1] & groupbit && mask[atom2] & groupbit &&
|
|
|
|
mask[atom3] & groupbit && mask[atom4] & groupbit) flag = 1;
|
|
|
|
if (any_flag && (mask[atom1] & groupbit || mask[atom2] & groupbit ||
|
|
|
|
mask[atom3] & groupbit || mask[atom4] & groupbit))
|
|
|
|
flag = 1;
|
|
|
|
if (flag) {
|
2012-06-07 06:47:51 +08:00
|
|
|
n = atom->num_improper[i];
|
|
|
|
atom->improper_type[i][m] = atom->improper_type[i][n-1];
|
|
|
|
atom->improper_atom1[i][m] = atom->improper_atom1[i][n-1];
|
|
|
|
atom->improper_atom2[i][m] = atom->improper_atom2[i][n-1];
|
|
|
|
atom->improper_atom3[i][m] = atom->improper_atom3[i][n-1];
|
|
|
|
atom->improper_atom4[i][m] = atom->improper_atom4[i][n-1];
|
|
|
|
atom->num_improper[i]--;
|
|
|
|
} else m++;
|
|
|
|
} else m++;
|
|
|
|
}
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// if interactions were removed, recompute global counts
|
|
|
|
|
|
|
|
if (remove_flag) {
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
if (atom->avec->bonds_allow) {
|
2011-01-05 04:07:43 +08:00
|
|
|
bigint nbonds = 0;
|
2006-09-28 03:51:33 +08:00
|
|
|
for (i = 0; i < nlocal; i++) nbonds += atom->num_bond[i];
|
2011-01-07 07:23:37 +08:00
|
|
|
MPI_Allreduce(&nbonds,&atom->nbonds,1,MPI_LMP_BIGINT,
|
2012-06-07 06:47:51 +08:00
|
|
|
MPI_SUM,world);
|
2006-09-28 03:51:33 +08:00
|
|
|
if (force->newton_bond == 0) atom->nbonds /= 2;
|
|
|
|
}
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
if (atom->avec->angles_allow) {
|
2011-01-05 04:07:43 +08:00
|
|
|
bigint nangles = 0;
|
2006-09-28 03:51:33 +08:00
|
|
|
for (i = 0; i < nlocal; i++) nangles += atom->num_angle[i];
|
2011-01-07 07:23:37 +08:00
|
|
|
MPI_Allreduce(&nangles,&atom->nangles,1,MPI_LMP_BIGINT,
|
2012-06-07 06:47:51 +08:00
|
|
|
MPI_SUM,world);
|
2006-09-28 03:51:33 +08:00
|
|
|
if (force->newton_bond == 0) atom->nangles /= 3;
|
|
|
|
}
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
if (atom->avec->dihedrals_allow) {
|
2011-01-05 04:07:43 +08:00
|
|
|
bigint ndihedrals = 0;
|
2006-09-28 03:51:33 +08:00
|
|
|
for (i = 0; i < nlocal; i++) ndihedrals += atom->num_dihedral[i];
|
2011-01-05 04:07:43 +08:00
|
|
|
MPI_Allreduce(&ndihedrals,&atom->ndihedrals,
|
2012-06-07 06:47:51 +08:00
|
|
|
1,MPI_LMP_BIGINT,MPI_SUM,world);
|
2006-09-28 03:51:33 +08:00
|
|
|
if (force->newton_bond == 0) atom->ndihedrals /= 4;
|
|
|
|
}
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
if (atom->avec->impropers_allow) {
|
2011-01-05 04:07:43 +08:00
|
|
|
bigint nimpropers = 0;
|
2006-09-28 03:51:33 +08:00
|
|
|
for (i = 0; i < nlocal; i++) nimpropers += atom->num_improper[i];
|
2011-01-05 04:07:43 +08:00
|
|
|
MPI_Allreduce(&nimpropers,&atom->nimpropers,
|
2012-06-07 06:47:51 +08:00
|
|
|
1,MPI_LMP_BIGINT,MPI_SUM,world);
|
2006-09-28 03:51:33 +08:00
|
|
|
if (force->newton_bond == 0) atom->nimpropers /= 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// compute and print stats
|
|
|
|
|
2011-01-05 04:07:43 +08:00
|
|
|
bigint tmp;
|
|
|
|
bigint bond_on,bond_off;
|
|
|
|
bigint angle_on,angle_off;
|
|
|
|
bigint dihedral_on,dihedral_off;
|
|
|
|
bigint improper_on,improper_off;
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
if (atom->avec->bonds_allow) {
|
2006-09-28 03:51:33 +08:00
|
|
|
bond_on = bond_off = 0;
|
|
|
|
for (i = 0; i < nlocal; i++)
|
|
|
|
for (m = 0; m < atom->num_bond[i]; m++)
|
2012-06-07 06:47:51 +08:00
|
|
|
if (atom->bond_type[i][m] > 0) bond_on++;
|
|
|
|
else bond_off++;
|
2011-01-07 07:23:37 +08:00
|
|
|
MPI_Allreduce(&bond_on,&tmp,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
2006-09-28 03:51:33 +08:00
|
|
|
bond_on = tmp;
|
2011-01-07 07:23:37 +08:00
|
|
|
MPI_Allreduce(&bond_off,&tmp,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
2006-09-28 03:51:33 +08:00
|
|
|
bond_off = tmp;
|
|
|
|
if (force->newton_bond == 0) {
|
|
|
|
bond_on /= 2;
|
|
|
|
bond_off /= 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
if (atom->avec->angles_allow) {
|
2006-09-28 03:51:33 +08:00
|
|
|
angle_on = angle_off = 0;
|
|
|
|
for (i = 0; i < nlocal; i++)
|
|
|
|
for (m = 0; m < atom->num_angle[i]; m++)
|
2012-06-07 06:47:51 +08:00
|
|
|
if (atom->angle_type[i][m] > 0) angle_on++;
|
|
|
|
else angle_off++;
|
2011-01-07 07:23:37 +08:00
|
|
|
MPI_Allreduce(&angle_on,&tmp,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
2006-09-28 03:51:33 +08:00
|
|
|
angle_on = tmp;
|
2011-01-07 07:23:37 +08:00
|
|
|
MPI_Allreduce(&angle_off,&tmp,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
2006-09-28 03:51:33 +08:00
|
|
|
angle_off = tmp;
|
|
|
|
if (force->newton_bond == 0) {
|
|
|
|
angle_on /= 3;
|
|
|
|
angle_off /= 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
if (atom->avec->dihedrals_allow) {
|
2006-09-28 03:51:33 +08:00
|
|
|
dihedral_on = dihedral_off = 0;
|
|
|
|
for (i = 0; i < nlocal; i++)
|
|
|
|
for (m = 0; m < atom->num_dihedral[i]; m++)
|
2012-06-07 06:47:51 +08:00
|
|
|
if (atom->dihedral_type[i][m] > 0) dihedral_on++;
|
|
|
|
else dihedral_off++;
|
2011-01-07 07:23:37 +08:00
|
|
|
MPI_Allreduce(&dihedral_on,&tmp,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
2006-09-28 03:51:33 +08:00
|
|
|
dihedral_on = tmp;
|
2011-01-07 07:23:37 +08:00
|
|
|
MPI_Allreduce(&dihedral_off,&tmp,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
2006-09-28 03:51:33 +08:00
|
|
|
dihedral_off = tmp;
|
|
|
|
if (force->newton_bond == 0) {
|
|
|
|
dihedral_on /= 4;
|
|
|
|
dihedral_off /= 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
if (atom->avec->impropers_allow) {
|
2006-09-28 03:51:33 +08:00
|
|
|
improper_on = improper_off = 0;
|
|
|
|
for (i = 0; i < nlocal; i++)
|
|
|
|
for (m = 0; m < atom->num_improper[i]; m++)
|
2012-06-07 06:47:51 +08:00
|
|
|
if (atom->improper_type[i][m] > 0) improper_on++;
|
|
|
|
else improper_off++;
|
2011-01-07 07:23:37 +08:00
|
|
|
MPI_Allreduce(&improper_on,&tmp,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
2006-09-28 03:51:33 +08:00
|
|
|
improper_on = tmp;
|
2011-01-07 07:23:37 +08:00
|
|
|
MPI_Allreduce(&improper_off,&tmp,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
2006-09-28 03:51:33 +08:00
|
|
|
improper_off = tmp;
|
|
|
|
if (force->newton_bond == 0) {
|
|
|
|
improper_on /= 4;
|
|
|
|
improper_off /= 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (comm->me == 0) {
|
2011-01-08 05:42:19 +08:00
|
|
|
if (atom->avec->bonds_allow) {
|
2011-01-14 23:53:06 +08:00
|
|
|
if (screen) fprintf(screen,
|
2012-06-07 06:47:51 +08:00
|
|
|
" " BIGINT_FORMAT " total bonds, " BIGINT_FORMAT
|
|
|
|
" turned on, " BIGINT_FORMAT " turned off\n",
|
|
|
|
atom->nbonds,bond_on,bond_off);
|
2011-01-14 23:53:06 +08:00
|
|
|
if (logfile) fprintf(logfile,
|
2012-06-07 06:47:51 +08:00
|
|
|
" " BIGINT_FORMAT " total bonds, " BIGINT_FORMAT
|
|
|
|
" turned on, " BIGINT_FORMAT " turned off\n",
|
|
|
|
atom->nbonds,bond_on,bond_off);
|
2011-01-08 05:42:19 +08:00
|
|
|
}
|
|
|
|
if (atom->avec->angles_allow) {
|
2011-01-14 23:53:06 +08:00
|
|
|
if (screen) fprintf(screen,
|
2012-06-07 06:47:51 +08:00
|
|
|
" " BIGINT_FORMAT " total angles, " BIGINT_FORMAT
|
|
|
|
" turned on, " BIGINT_FORMAT " turned off\n",
|
|
|
|
atom->nangles,angle_on,angle_off);
|
2011-01-14 23:53:06 +08:00
|
|
|
if (logfile) fprintf(logfile,
|
2012-06-07 06:47:51 +08:00
|
|
|
" " BIGINT_FORMAT " total angles, " BIGINT_FORMAT
|
|
|
|
" turned on, " BIGINT_FORMAT " turned off\n",
|
|
|
|
atom->nangles,angle_on,angle_off);
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
2011-01-08 05:42:19 +08:00
|
|
|
if (atom->avec->dihedrals_allow) {
|
2011-01-14 23:53:06 +08:00
|
|
|
if (screen) fprintf(screen,
|
2012-06-07 06:47:51 +08:00
|
|
|
" " BIGINT_FORMAT " total dihedrals, "
|
|
|
|
BIGINT_FORMAT " turned on, " BIGINT_FORMAT
|
|
|
|
" turned off\n",
|
|
|
|
atom->ndihedrals,dihedral_on,dihedral_off);
|
2011-01-14 23:53:06 +08:00
|
|
|
if (logfile) fprintf(logfile,
|
2012-06-07 06:47:51 +08:00
|
|
|
" " BIGINT_FORMAT " total dihedrals, "
|
|
|
|
BIGINT_FORMAT " turned on, " BIGINT_FORMAT
|
|
|
|
" turned off\n",
|
|
|
|
atom->ndihedrals,dihedral_on,dihedral_off);
|
2011-01-08 05:42:19 +08:00
|
|
|
}
|
|
|
|
if (atom->avec->impropers_allow) {
|
2011-01-14 23:53:06 +08:00
|
|
|
if (screen) fprintf(screen,
|
2012-06-07 06:47:51 +08:00
|
|
|
" " BIGINT_FORMAT " total impropers, "
|
|
|
|
BIGINT_FORMAT " turned on, " BIGINT_FORMAT
|
|
|
|
" turned off\n",
|
|
|
|
atom->nimpropers,improper_on,improper_off);
|
2011-01-14 23:53:06 +08:00
|
|
|
if (logfile) fprintf(logfile,
|
2012-06-07 06:47:51 +08:00
|
|
|
" " BIGINT_FORMAT " total impropers, "
|
|
|
|
BIGINT_FORMAT " turned on, " BIGINT_FORMAT
|
|
|
|
" turned off\n",
|
|
|
|
atom->nimpropers,improper_on,improper_off);
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// re-compute special list if requested
|
|
|
|
|
|
|
|
if (special_flag) {
|
2007-01-30 08:22:05 +08:00
|
|
|
Special special(lmp);
|
2006-09-28 03:51:33 +08:00
|
|
|
special.build();
|
|
|
|
}
|
|
|
|
}
|