diff --git a/src/AMOEBA/amoeba_file.cpp b/src/AMOEBA/amoeba_file.cpp index f3266b35d9..70f2196d7c 100644 --- a/src/AMOEBA/amoeba_file.cpp +++ b/src/AMOEBA/amoeba_file.cpp @@ -610,7 +610,7 @@ int PairAmoeba::read_section_line(FILE *fp, char *line, char *ptr,*copy,*copy_next; char **words,**words_next; - int nwords_next; + int nwords, nwords_next; copy = copy_next = NULL; words = words_next = NULL; diff --git a/src/AMOEBA/amoeba_multipole.cpp b/src/AMOEBA/amoeba_multipole.cpp index 58264bb6db..9532f3d7fd 100644 --- a/src/AMOEBA/amoeba_multipole.cpp +++ b/src/AMOEBA/amoeba_multipole.cpp @@ -61,13 +61,13 @@ void PairAmoeba::multipole() // owned atoms - int nlocal = atom->nlocal; + const int nlocal = atom->nlocal; // zero repulsion torque on owned + ghost atoms - int nall = nlocal + atom->nghost; + const int nall = nlocal + atom->nghost; - for (i = 0; i < nall; i++) { + for (int i = 0; i < nall; i++) { tq[i][0] = 0.0; tq[i][1] = 0.0; tq[i][2] = 0.0; @@ -90,7 +90,7 @@ void PairAmoeba::multipole() term = 2.0 * aewald * aewald; fterm = -felec * aewald / MY_PIS; - for (i = 0; i < nlocal; i++) { + for (int i = 0; i < nlocal; i++) { ci = rpole[i][0]; dix = rpole[i][1]; diy = rpole[i][2]; diff --git a/src/AMOEBA/atom_vec_amoeba.cpp b/src/AMOEBA/atom_vec_amoeba.cpp index 6c782a382b..b84ca7ab1e 100644 --- a/src/AMOEBA/atom_vec_amoeba.cpp +++ b/src/AMOEBA/atom_vec_amoeba.cpp @@ -32,47 +32,33 @@ AtomVecAmoeba::AtomVecAmoeba(LAMMPS *lmp) : AtomVec(lmp) // order of fields in a string does not matter // except: fields_data_atom & fields_data_vel must match data file - fields_grow = (char *) - "q molecule num_bond bond_type bond_atom " - "num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " - "num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " - "dihedral_atom3 dihedral_atom4 " - "num_improper improper_type improper_atom1 improper_atom2 " - "improper_atom3 improper_atom4 " - "nspecial special nspecial15 special15"; - fields_copy = (char *) - "q molecule num_bond bond_type bond_atom " - "num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " - "num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " - "dihedral_atom3 dihedral_atom4 " - "num_improper improper_type improper_atom1 improper_atom2 " - "improper_atom3 improper_atom4 " - "nspecial special nspecial15 special15"; - fields_comm = (char *) ""; - fields_comm_vel = (char *) ""; - fields_reverse = (char *) ""; - fields_border = (char *) "q molecule"; - fields_border_vel = (char *) "q molecule"; - fields_exchange = (char *) - "q molecule num_bond bond_type bond_atom " - "num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " - "num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " - "dihedral_atom3 dihedral_atom4 " - "num_improper improper_type improper_atom1 improper_atom2 " - "improper_atom3 improper_atom4 " - "nspecial special nspecial15 special15"; - fields_restart = (char *) - "q molecule num_bond bond_type bond_atom " - "num_angle angle_type angle_atom1 angle_atom2 angle_atom3 " - "num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 " - "dihedral_atom3 dihedral_atom4 " - "num_improper improper_type improper_atom1 improper_atom2 " - "improper_atom3 improper_atom4"; - fields_create = (char *) - "q molecule num_bond num_angle num_dihedral num_improper nspecial nspecial15"; - fields_data_atom = (char *) "id molecule type q x"; - fields_data_vel = (char *) "id v"; - + // clang-format off + fields_grow = {"q", "molecule", "num_bond", "bond_type", "bond_atom", "num_angle", "angle_type", + "angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type", "dihedral_atom1", + "dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper", "improper_type", + "improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4", "nspecial", "special", + "nspecial15", "special15"}; + fields_copy = {"q", "molecule", "num_bond", "bond_type", "bond_atom", "num_angle", "angle_type", + "angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type", "dihedral_atom1", + "dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper", "improper_type", + "improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4", "nspecial", "special", + "nspecial15", "special15"}; + fields_border = {"q", "molecule"}; + fields_border_vel = {"q", "molecule"}; + fields_exchange = {"q", "molecule", "num_bond", "bond_type", "bond_atom", "num_angle", + "angle_type", "angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type", + "dihedral_atom1", "dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper", + "improper_type", "improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4", + "nspecial", "special", "nspecial15", "special15"}; + fields_restart = {"q", "molecule", "num_bond", "bond_type", "bond_atom", "num_angle", + "angle_type", "angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type", + "dihedral_atom1", "dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper", + "improper_type", "improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4"}; + fields_create = {"q", "molecule", "num_bond", "num_angle", "num_dihedral", "num_improper", + "nspecial", "nspecial15"}; + fields_data_atom = {"id", "molecule", "type", "q", "x"}; + fields_data_vel = {"id", "v"}; + // clang-format on setup_fields(); bond_per_atom = angle_per_atom = dihedral_per_atom = improper_per_atom = 0; @@ -83,10 +69,10 @@ AtomVecAmoeba::AtomVecAmoeba(LAMMPS *lmp) : AtomVec(lmp) AtomVecAmoeba::~AtomVecAmoeba() { - delete [] bond_negative; - delete [] angle_negative; - delete [] dihedral_negative; - delete [] improper_negative; + delete[] bond_negative; + delete[] angle_negative; + delete[] dihedral_negative; + delete[] improper_negative; } /* ---------------------------------------------------------------------- @@ -117,22 +103,22 @@ void AtomVecAmoeba::pack_restart_pre(int ilocal) // insure negative vectors are needed length if (bond_per_atom < atom->bond_per_atom) { - delete [] bond_negative; + delete[] bond_negative; bond_per_atom = atom->bond_per_atom; bond_negative = new int[bond_per_atom]; } if (angle_per_atom < atom->angle_per_atom) { - delete [] angle_negative; + delete[] angle_negative; angle_per_atom = atom->angle_per_atom; angle_negative = new int[angle_per_atom]; } if (dihedral_per_atom < atom->dihedral_per_atom) { - delete [] dihedral_negative; + delete[] dihedral_negative; dihedral_per_atom = atom->dihedral_per_atom; dihedral_negative = new int[dihedral_per_atom]; } if (improper_per_atom < atom->improper_per_atom) { - delete [] improper_negative; + delete[] improper_negative; improper_per_atom = atom->improper_per_atom; improper_negative = new int[improper_per_atom]; } @@ -145,7 +131,8 @@ void AtomVecAmoeba::pack_restart_pre(int ilocal) bond_negative[m] = 1; bond_type[ilocal][m] = -bond_type[ilocal][m]; any_bond_negative = 1; - } else bond_negative[m] = 0; + } else + bond_negative[m] = 0; } any_angle_negative = 0; @@ -154,7 +141,8 @@ void AtomVecAmoeba::pack_restart_pre(int ilocal) angle_negative[m] = 1; angle_type[ilocal][m] = -angle_type[ilocal][m]; any_angle_negative = 1; - } else angle_negative[m] = 0; + } else + angle_negative[m] = 0; } any_dihedral_negative = 0; @@ -163,7 +151,8 @@ void AtomVecAmoeba::pack_restart_pre(int ilocal) dihedral_negative[m] = 1; dihedral_type[ilocal][m] = -dihedral_type[ilocal][m]; any_dihedral_negative = 1; - } else dihedral_negative[m] = 0; + } else + dihedral_negative[m] = 0; } any_improper_negative = 0; @@ -172,7 +161,8 @@ void AtomVecAmoeba::pack_restart_pre(int ilocal) improper_negative[m] = 1; improper_type[ilocal][m] = -improper_type[ilocal][m]; any_improper_negative = 1; - } else improper_negative[m] = 0; + } else + improper_negative[m] = 0; } } @@ -196,14 +186,12 @@ void AtomVecAmoeba::pack_restart_post(int ilocal) if (any_dihedral_negative) { for (int m = 0; m < num_dihedral[ilocal]; m++) - if (dihedral_negative[m]) - dihedral_type[ilocal][m] = -dihedral_type[ilocal][m]; + if (dihedral_negative[m]) dihedral_type[ilocal][m] = -dihedral_type[ilocal][m]; } if (any_improper_negative) { for (int m = 0; m < num_improper[ilocal]; m++) - if (improper_negative[m]) - improper_type[ilocal][m] = -improper_type[ilocal][m]; + if (improper_negative[m]) improper_type[ilocal][m] = -improper_type[ilocal][m]; } }