enable and apply clang-format
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -37,8 +36,8 @@
|
||||
#include "neigh_request.h"
|
||||
#include "neighbor.h"
|
||||
#include "pair.h"
|
||||
#include "update.h"
|
||||
#include "universe.h"
|
||||
#include "update.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
@ -116,8 +115,7 @@ static int constexpr albemunu[21][4] = {
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeBornMatrix::ComputeBornMatrix(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg), id_virial(nullptr), temp_x(nullptr),
|
||||
temp_f(nullptr)
|
||||
Compute(lmp, narg, arg), id_virial(nullptr), temp_x(nullptr), temp_f(nullptr)
|
||||
{
|
||||
if (narg < 3) error->all(FLERR, "Illegal compute born/matrix command");
|
||||
|
||||
@ -154,20 +152,28 @@ ComputeBornMatrix::ComputeBornMatrix(LAMMPS *lmp, int narg, char **arg) :
|
||||
if (compute_virial->pressflag == 0)
|
||||
error->all(FLERR, "Compute born/matrix pressure ID does not compute pressure");
|
||||
iarg += 3;
|
||||
} else if (strcmp(arg[iarg],"pair") == 0) pairflag = 1;
|
||||
else if (strcmp(arg[iarg],"bond") == 0) bondflag = 1;
|
||||
else if (strcmp(arg[iarg],"angle") == 0) angleflag = 1;
|
||||
else if (strcmp(arg[iarg],"dihedral") == 0) dihedflag = 1;
|
||||
else if (strcmp(arg[iarg],"improper") == 0) impflag = 1;
|
||||
else error->all(FLERR,"Illegal compute born/matrix command");
|
||||
} else if (strcmp(arg[iarg], "pair") == 0) {
|
||||
pairflag = 1;
|
||||
} else if (strcmp(arg[iarg], "bond") == 0) {
|
||||
bondflag = 1;
|
||||
} else if (strcmp(arg[iarg], "angle") == 0) {
|
||||
angleflag = 1;
|
||||
} else if (strcmp(arg[iarg], "dihedral") == 0) {
|
||||
dihedflag = 1;
|
||||
} else if (strcmp(arg[iarg], "improper") == 0) {
|
||||
impflag = 1;
|
||||
} else {
|
||||
error->all(FLERR, "Illegal compute born/matrix command");
|
||||
}
|
||||
++iarg;
|
||||
}
|
||||
}
|
||||
|
||||
if (pairflag) {
|
||||
if (numflag) error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags");
|
||||
if (numflag)
|
||||
error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags");
|
||||
if (force->pair) {
|
||||
if (force->pair->born_matrix_enable == 0) {
|
||||
if (force->pair->born_matrix_enable == 0)
|
||||
if (comm->me == 0) error->warning(FLERR, "Pair style does not support compute born/matrix");
|
||||
}
|
||||
} else {
|
||||
@ -175,7 +181,8 @@ ComputeBornMatrix::ComputeBornMatrix(LAMMPS *lmp, int narg, char **arg) :
|
||||
}
|
||||
}
|
||||
if (bondflag) {
|
||||
if (numflag) error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags");
|
||||
if (numflag)
|
||||
error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags");
|
||||
if (force->bond) {
|
||||
if (force->bond->born_matrix_enable == 0) {
|
||||
if (comm->me == 0) error->warning(FLERR, "Bond style does not support compute born/matrix");
|
||||
@ -185,7 +192,8 @@ ComputeBornMatrix::ComputeBornMatrix(LAMMPS *lmp, int narg, char **arg) :
|
||||
}
|
||||
}
|
||||
if (angleflag) {
|
||||
if (numflag) error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags");
|
||||
if (numflag)
|
||||
error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags");
|
||||
if (force->angle) {
|
||||
if (force->angle->born_matrix_enable == 0) {
|
||||
if (comm->me == 0) error->warning(FLERR, "Angle style does not support compute born/matrix");
|
||||
@ -195,20 +203,24 @@ ComputeBornMatrix::ComputeBornMatrix(LAMMPS *lmp, int narg, char **arg) :
|
||||
}
|
||||
}
|
||||
if (dihedflag) {
|
||||
if (numflag) error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags");
|
||||
if (numflag)
|
||||
error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags");
|
||||
if (force->dihedral) {
|
||||
if (force->dihedral->born_matrix_enable == 0) {
|
||||
if (comm->me == 0) error->warning(FLERR, "Dihedral style does not support compute born/matrix");
|
||||
if (comm->me == 0)
|
||||
error->warning(FLERR, "Dihedral style does not support compute born/matrix");
|
||||
}
|
||||
} else {
|
||||
dihedflag = 0;
|
||||
}
|
||||
}
|
||||
if (impflag) {
|
||||
if (numflag) error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags");
|
||||
if (numflag)
|
||||
error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags");
|
||||
if (force->improper) {
|
||||
if (force->improper->born_matrix_enable == 0) {
|
||||
if (comm->me == 0) error->warning(FLERR, "Improper style does not support compute born/matrix");
|
||||
if (comm->me == 0)
|
||||
error->warning(FLERR, "Improper style does not support compute born/matrix");
|
||||
}
|
||||
} else {
|
||||
impflag = 0;
|
||||
@ -297,8 +309,7 @@ void ComputeBornMatrix::init()
|
||||
// check for virial compute
|
||||
|
||||
int icompute = modify->find_compute(id_virial);
|
||||
if (icompute < 0) error->all(FLERR,
|
||||
"Virial compute ID for compute born/matrix does not exist");
|
||||
if (icompute < 0) error->all(FLERR, "Virial compute ID for compute born/matrix does not exist");
|
||||
compute_virial = modify->compute[icompute];
|
||||
|
||||
// set up reverse index lookup
|
||||
@ -318,7 +329,6 @@ void ComputeBornMatrix::init()
|
||||
virialVtoV[3] = 5;
|
||||
virialVtoV[4] = 4;
|
||||
virialVtoV[5] = 3;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -364,13 +374,10 @@ void ComputeBornMatrix::compute_vector()
|
||||
|
||||
double inv_nktv2p = 1.0 / force->nktv2p;
|
||||
double volume = domain->xprd * domain->yprd * domain->zprd;
|
||||
for (int m = 0; m < nvalues; m++) {
|
||||
values_global[m] *= inv_nktv2p * volume;
|
||||
}
|
||||
for (int m = 0; m < nvalues; m++) { values_global[m] *= inv_nktv2p * volume; }
|
||||
}
|
||||
|
||||
for (int m = 0; m < nvalues; m++) vector[m] = values_global[m];
|
||||
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -451,23 +458,18 @@ void ComputeBornMatrix::compute_pairs()
|
||||
|
||||
// Add contribution to Born tensor
|
||||
|
||||
pair->born_matrix(i, j, itype, jtype, rsq, factor_coul,
|
||||
factor_lj, dupair, du2pair);
|
||||
pair->born_matrix(i, j, itype, jtype, rsq, factor_coul, factor_lj, dupair, du2pair);
|
||||
pair_pref = du2pair - dupair * rinv;
|
||||
|
||||
// See albemunu in compute_born_matrix.h for indices order.
|
||||
|
||||
a = 0;
|
||||
b = 0;
|
||||
c = 0;
|
||||
d = 0;
|
||||
a = b = c = d = 0;
|
||||
for (int m = 0; m < nvalues; m++) {
|
||||
a = albemunu[m][0];
|
||||
b = albemunu[m][1];
|
||||
c = albemunu[m][2];
|
||||
d = albemunu[m][3];
|
||||
values_local[m] += pair_pref * rij[a] * rij[b] *
|
||||
rij[c] * rij[d] * r2inv;
|
||||
values_local[m] += pair_pref * rij[a] * rij[b] * rij[c] * rij[d] * r2inv;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -546,9 +548,7 @@ void ComputeBornMatrix::compute_numdiff()
|
||||
// restore original forces for owned and ghost atoms
|
||||
|
||||
for (int i = 0; i < nall; i++)
|
||||
for (int k = 0; k < 3; k++)
|
||||
f[i][k] = temp_f[i][k];
|
||||
|
||||
for (int k = 0; k < 3; k++) f[i][k] = temp_f[i][k];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -579,8 +579,7 @@ void ComputeBornMatrix::restore_atoms(int nall, int idir)
|
||||
|
||||
int k = dirlist[idir][0];
|
||||
double **x = atom->x;
|
||||
for (int i = 0; i < nall; i++)
|
||||
x[i][k] = temp_x[i][k];
|
||||
for (int i = 0; i < nall; i++) x[i][k] = temp_x[i][k];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -659,7 +658,6 @@ void ComputeBornMatrix::virial_addon()
|
||||
values_global[18] += 0.0;
|
||||
values_global[19] += 0.0;
|
||||
values_global[20] += sigv[5];
|
||||
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -744,7 +742,8 @@ void ComputeBornMatrix::compute_bonds()
|
||||
for (atom1 = 0; atom1 < nlocal; atom1++) {
|
||||
if (!(mask[atom1] & groupbit)) continue;
|
||||
|
||||
if (molecular == 1) nb = num_bond[atom1];
|
||||
if (molecular == 1)
|
||||
nb = num_bond[atom1];
|
||||
else {
|
||||
if (molindex[atom1] < 0) continue;
|
||||
imol = molindex[atom1];
|
||||
@ -777,16 +776,11 @@ void ComputeBornMatrix::compute_bonds()
|
||||
r2inv = 1.0 / rsq;
|
||||
rinv = sqrt(r2inv);
|
||||
|
||||
pair_pref = 0.0;
|
||||
dupair = 0.0;
|
||||
du2pair = 0.0;
|
||||
pair_pref = dupair = du2pair = 0.0;
|
||||
bond->born_matrix(btype, rsq, atom1, atom2, dupair, du2pair);
|
||||
pair_pref = du2pair - dupair * rinv;
|
||||
|
||||
a = 0;
|
||||
b = 0;
|
||||
c = 0;
|
||||
d = 0;
|
||||
a = b = c = d = 0;
|
||||
for (i = 0; i < 21; i++) {
|
||||
a = albemunu[i][0];
|
||||
b = albemunu[i][1];
|
||||
@ -848,20 +842,16 @@ void ComputeBornMatrix::compute_angles()
|
||||
|
||||
// Initializing array for intermediate cos derivatives
|
||||
// w regard to strain
|
||||
for (i = 0; i < 6; i++) {
|
||||
dcos[i] = 0;
|
||||
}
|
||||
for (i = 0; i < 21; i++) {
|
||||
d2cos[i] = 0;
|
||||
d2lncos[i] = 0;
|
||||
}
|
||||
for (i = 0; i < 6; i++) dcos[i] = 0;
|
||||
for (i = 0; i < 21; i++) d2cos[i] = d2lncos[i] = 0;
|
||||
|
||||
m = 0;
|
||||
while (m < nvalues) {
|
||||
for (atom2 = 0; atom2 < nlocal; atom2++) {
|
||||
if (!(mask[atom2] & groupbit)) continue;
|
||||
|
||||
if (molecular == 1) na = num_angle[atom2];
|
||||
if (molecular == 1)
|
||||
na = num_angle[atom2];
|
||||
else {
|
||||
if (molindex[atom2] < 0) continue;
|
||||
imol = molindex[atom2];
|
||||
@ -933,10 +923,8 @@ void ComputeBornMatrix::compute_angles()
|
||||
// Voigt notation
|
||||
// 1 = 11, 2 = 22, 3 = 33
|
||||
// 4 = 23, 5 = 13, 6 = 12
|
||||
a = 0;
|
||||
b = 0;
|
||||
c = 0;
|
||||
d = 0;
|
||||
a = b = c = d = 0;
|
||||
// clang-format off
|
||||
for (i = 0; i<6; i++) {
|
||||
a = sigma_albe[i][0];
|
||||
b = sigma_albe[i][1];
|
||||
@ -958,6 +946,7 @@ void ComputeBornMatrix::compute_angles()
|
||||
d2cos[i] = cost*d2lncos[i] + dcos[e]*dcos[f]*cinv;
|
||||
values_local[m+i] += duang*d2cos[i] + du2ang*dcos[e]*dcos[f];
|
||||
}
|
||||
// clang-format on
|
||||
}
|
||||
}
|
||||
m += 21;
|
||||
@ -1025,25 +1014,17 @@ void ComputeBornMatrix::compute_dihedrals()
|
||||
double dcos[6];
|
||||
double d2cos[21];
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
dmn[i] =0;
|
||||
dmm[i] = 0;
|
||||
dnn[i] = 0;
|
||||
dcos[i] = 0;
|
||||
}
|
||||
for (i = 0; i < 21; i++) {
|
||||
d2mn[i] = 0;
|
||||
d2mm[i] = 0;
|
||||
d2nn[i] = 0;
|
||||
d2cos[i] = 0;
|
||||
}
|
||||
for (i = 0; i < 6; i++) dmn[i] = dmm[i] = dnn[i] = dcos[i] = 0;
|
||||
|
||||
for (i = 0; i < 21; i++) d2mn[i] = d2mm[i] = d2nn[i] = d2cos[i] = 0;
|
||||
|
||||
m = 0;
|
||||
while (m < nvalues) {
|
||||
for (atom2 = 0; atom2 < nlocal; atom2++) {
|
||||
if (!(mask[atom2] & groupbit)) continue;
|
||||
|
||||
if (molecular == 1) nd = num_dihedral[atom2];
|
||||
if (molecular == 1)
|
||||
nd = num_dihedral[atom2];
|
||||
else {
|
||||
if (molindex[atom2] < 0) continue;
|
||||
imol = molindex[atom2];
|
||||
@ -1141,12 +1122,8 @@ void ComputeBornMatrix::compute_dihedrals()
|
||||
|
||||
// above a and b are m and n vectors
|
||||
// here they are integers indices
|
||||
a = 0;
|
||||
b = 0;
|
||||
c = 0;
|
||||
d = 0;
|
||||
e = 0;
|
||||
f = 0;
|
||||
a = b = c = d = e = f = 0;
|
||||
// clang-format off
|
||||
for (i = 0; i<6; i++) {
|
||||
a = sigma_albe[i][0];
|
||||
b = sigma_albe[i][1];
|
||||
@ -1180,6 +1157,7 @@ void ComputeBornMatrix::compute_dihedrals()
|
||||
- rb2inv*d2nn[i]);
|
||||
values_local[m+i] += dudih*d2cos[i] + du2dih*dcos[e]*dcos[f];
|
||||
}
|
||||
// clang-format on
|
||||
}
|
||||
}
|
||||
m += 21;
|
||||
|
||||
@ -38,7 +38,6 @@ namespace LAMMPS_NS {
|
||||
double memory_usage() override;
|
||||
|
||||
private:
|
||||
|
||||
// Born matrix contributions
|
||||
|
||||
void compute_pairs(); // pair and manybody
|
||||
@ -78,7 +77,7 @@ namespace LAMMPS_NS {
|
||||
double fixedpoint[NXYZ_VIRIAL]; // displacement field origin
|
||||
int dirlist[NDIR_VIRIAL][2]; // strain cartesian indices
|
||||
};
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user