turn some warnings into errors and produce better error messages

This commit is contained in:
Axel Kohlmeyer
2022-02-20 06:07:39 -05:00
parent 60a6747c0e
commit c1dfd944af

View File

@ -126,17 +126,9 @@ ComputeBornMatrix::ComputeBornMatrix(LAMMPS *lmp, int narg, char **arg) :
numflag = 0; numflag = 0;
numdelta = 0.0; numdelta = 0.0;
pairflag = 0; pairflag = bondflag = angleflag = dihedflag = impflag = 0;
bondflag = 0;
angleflag = 0;
dihedflag = 0;
impflag = 0;
if (narg == 3) { if (narg == 3) {
pairflag = 1; pairflag = bondflag = angleflag = dihedflag = impflag = 1;
bondflag = 1;
angleflag = 1;
dihedflag = 1;
impflag = 1;
} else { } else {
int iarg = 3; int iarg = 3;
while (iarg < narg) { while (iarg < narg) {
@ -174,104 +166,106 @@ ComputeBornMatrix::ComputeBornMatrix(LAMMPS *lmp, int narg, char **arg) :
error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags"); error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags");
if (force->pair) { 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"); error->all(FLERR, "Pair style {} does not support compute born/matrix", force->pair_style);
} else {
pairflag = 0;
} }
} else {
pairflag = 0;
} }
}
if (bondflag) { if (bondflag) {
if (numflag) if (numflag)
error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags"); error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags");
if (force->bond) { if (force->bond) {
if (force->bond->born_matrix_enable == 0) { if (force->bond->born_matrix_enable == 0)
if (comm->me == 0) error->warning(FLERR, "Bond style does not support compute born/matrix"); error->all(FLERR, "Bond style {} does not support compute born/matrix", force->bond_style);
} else {
bondflag = 0;
} }
} else {
bondflag = 0;
} }
}
if (angleflag) { if (angleflag) {
if (numflag) if (numflag)
error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags"); error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags");
if (force->angle) { if (force->angle) {
if (force->angle->born_matrix_enable == 0) { if (force->angle->born_matrix_enable == 0)
if (comm->me == 0) error->warning(FLERR, "Angle style does not support compute born/matrix"); error->all(FLERR, "Angle style {} does not support compute born/matrix",
force->angle_style);
} else {
angleflag = 0;
} }
} else {
angleflag = 0;
} }
}
if (dihedflag) { if (dihedflag) {
if (numflag) if (numflag)
error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags"); error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags");
if (force->dihedral) { if (force->dihedral) {
if (force->dihedral->born_matrix_enable == 0) { if (force->dihedral->born_matrix_enable == 0)
if (comm->me == 0) error->all(FLERR, "Dihedral style {} does not support compute born/matrix",
error->warning(FLERR, "Dihedral style does not support compute born/matrix"); force->dihedral_style);
} else {
dihedflag = 0;
} }
} else {
dihedflag = 0;
} }
}
if (impflag) { if (impflag) {
if (numflag) if (numflag)
error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags"); error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags");
if (force->improper) { if (force->improper) {
if (force->improper->born_matrix_enable == 0) { if (force->improper->born_matrix_enable == 0)
if (comm->me == 0) error->all(FLERR, "Improper style {} does not support compute born/matrix",
error->warning(FLERR, "Improper style does not support compute born/matrix"); force->improper_style);
} else {
impflag = 0;
} }
} else {
impflag = 0;
} }
}
if (force->kspace) {
if (!numflag) error->warning(FLERR, "KSPACE contribution not supported by compute born/matrix");
}
// Initialize some variables if (force->kspace) {
if (!numflag && (comm->me == 0))
error->all(FLERR, "KSpace contribution not supported by compute born/matrix");
}
values_local = values_global = vector = nullptr; // Initialize some variables
// this fix produces a global vector values_local = values_global = vector = nullptr;
memory->create(vector, nvalues, "born_matrix:vector"); // this fix produces a global vector
memory->create(values_global, nvalues, "born_matrix:values_global");
size_vector = nvalues;
vector_flag = 1; memory->create(vector, nvalues, "born_matrix:vector");
extvector = 0; memory->create(values_global, nvalues, "born_matrix:values_global");
maxatom = 0; size_vector = nvalues;
if (!numflag) { vector_flag = 1;
memory->create(values_local, nvalues, "born_matrix:values_local"); extvector = 0;
} else { maxatom = 0;
reallocate(); if (!numflag) {
memory->create(values_local, nvalues, "born_matrix:values_local");
} else {
// set fixed-point to default = center of cell reallocate();
fixedpoint[0] = 0.5 * (domain->boxlo[0] + domain->boxhi[0]); // set fixed-point to default = center of cell
fixedpoint[1] = 0.5 * (domain->boxlo[1] + domain->boxhi[1]);
fixedpoint[2] = 0.5 * (domain->boxlo[2] + domain->boxhi[2]);
// define the cartesian indices for each strain (Voigt order) fixedpoint[0] = 0.5 * (domain->boxlo[0] + domain->boxhi[0]);
fixedpoint[1] = 0.5 * (domain->boxlo[1] + domain->boxhi[1]);
fixedpoint[2] = 0.5 * (domain->boxlo[2] + domain->boxhi[2]);
dirlist[0][0] = 0; // define the cartesian indices for each strain (Voigt order)
dirlist[0][1] = 0;
dirlist[1][0] = 1;
dirlist[1][1] = 1;
dirlist[2][0] = 2;
dirlist[2][1] = 2;
dirlist[3][0] = 1; dirlist[0][0] = 0;
dirlist[3][1] = 2; dirlist[0][1] = 0;
dirlist[4][0] = 0; dirlist[1][0] = 1;
dirlist[4][1] = 2; dirlist[1][1] = 1;
dirlist[5][0] = 0; dirlist[2][0] = 2;
dirlist[5][1] = 1; dirlist[2][1] = 2;
}
dirlist[3][0] = 1;
dirlist[3][1] = 2;
dirlist[4][0] = 0;
dirlist[4][1] = 2;
dirlist[5][0] = 0;
dirlist[5][1] = 1;
}
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */