programming style and error message updates
This commit is contained in:
@ -30,7 +30,7 @@ using namespace LAMMPS_NS;
|
|||||||
|
|
||||||
ComputeTempDrude::ComputeTempDrude(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg)
|
ComputeTempDrude::ComputeTempDrude(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg)
|
||||||
{
|
{
|
||||||
if (narg != 3) error->all(FLERR, "Illegal compute temp command");
|
if (narg != 3) error->all(FLERR, "Incorrect number of arguments for compute temp/drude");
|
||||||
|
|
||||||
vector_flag = 1;
|
vector_flag = 1;
|
||||||
scalar_flag = 1;
|
scalar_flag = 1;
|
||||||
@ -63,11 +63,13 @@ void ComputeTempDrude::init()
|
|||||||
{
|
{
|
||||||
// Fix drude already checks that there is only one fix drude instance
|
// Fix drude already checks that there is only one fix drude instance
|
||||||
auto &fixes = modify->get_fix_by_style("^drude$");
|
auto &fixes = modify->get_fix_by_style("^drude$");
|
||||||
if (fixes.size() == 0) error->all(FLERR, "compute temp/drude requires fix drude");
|
if (fixes.size() == 0)
|
||||||
|
error->all(FLERR, Error::NOLASTLINE, "compute temp/drude requires fix drude");
|
||||||
fix_drude = dynamic_cast<FixDrude *>(fixes[0]);
|
fix_drude = dynamic_cast<FixDrude *>(fixes[0]);
|
||||||
|
|
||||||
if (!comm->ghost_velocity)
|
if (!comm->ghost_velocity)
|
||||||
error->all(FLERR, "compute temp/drude requires ghost velocities. Use comm_modify vel yes");
|
error->all(FLERR, Error::NOLASTLINE,
|
||||||
|
"compute temp/drude requires ghost velocities. Use comm_modify vel yes");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -170,7 +172,7 @@ void ComputeTempDrude::compute_vector()
|
|||||||
error->one(FLERR, "Drude atom for core atom ID {} is not defined", atom->tag[i]);
|
error->one(FLERR, "Drude atom for core atom ID {} is not defined", atom->tag[i]);
|
||||||
} else {
|
} else {
|
||||||
error->one(FLERR, "Drude atom ID {} for core atom ID {} is out of range", drudeid[i],
|
error->one(FLERR, "Drude atom ID {} for core atom ID {} is out of range", drudeid[i],
|
||||||
atom->tag[i]);
|
atom->tag[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rmass) {
|
if (rmass) {
|
||||||
|
|||||||
@ -33,7 +33,9 @@ using namespace FixConst;
|
|||||||
FixDrude::FixDrude(LAMMPS *lmp, int narg, char **arg) :
|
FixDrude::FixDrude(LAMMPS *lmp, int narg, char **arg) :
|
||||||
Fix(lmp, narg, arg)
|
Fix(lmp, narg, arg)
|
||||||
{
|
{
|
||||||
if (narg != 3 + atom->ntypes) error->all(FLERR,"Illegal fix drude command");
|
if (narg != 3 + atom->ntypes)
|
||||||
|
error->all(FLERR,"Incorrect number of arguments ({} instead of {}) for fix drude command",
|
||||||
|
narg, 3 + atom->ntypes);
|
||||||
|
|
||||||
comm_border = 1; // drudeid
|
comm_border = 1; // drudeid
|
||||||
special_alter_flag = 1;
|
special_alter_flag = 1;
|
||||||
@ -49,7 +51,7 @@ FixDrude::FixDrude(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
else if (arg[i][0] == 'd' || arg[i][0] == 'D' || arg[i][0] == '2')
|
else if (arg[i][0] == 'd' || arg[i][0] == 'D' || arg[i][0] == '2')
|
||||||
drudetype[i-2] = DRUDE_TYPE;
|
drudetype[i-2] = DRUDE_TYPE;
|
||||||
else
|
else
|
||||||
error->all(FLERR, "Illegal fix drude command");
|
error->all(FLERR, i, "Unknown drude type {} for atom type {}", arg[i], i-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
drudeid = nullptr;
|
drudeid = nullptr;
|
||||||
@ -82,7 +84,8 @@ FixDrude::~FixDrude()
|
|||||||
|
|
||||||
void FixDrude::init()
|
void FixDrude::init()
|
||||||
{
|
{
|
||||||
if (modify->get_fix_by_style("^drude$").size() > 1) error->all(FLERR,"More than one fix drude");
|
if (modify->get_fix_by_style("^drude$").size() > 1)
|
||||||
|
error->all(FLERR, Error::NOLASTLINE, "More than one fix drude");
|
||||||
|
|
||||||
if (!rebuildflag) rebuild_special();
|
if (!rebuildflag) rebuild_special();
|
||||||
}
|
}
|
||||||
@ -106,8 +109,7 @@ void FixDrude::build_drudeid() {
|
|||||||
std::vector<tagint> core_drude_vec;
|
std::vector<tagint> core_drude_vec;
|
||||||
partner_set = new std::set<tagint>[nlocal]; // Temporary sets of bond partner tags
|
partner_set = new std::set<tagint>[nlocal]; // Temporary sets of bond partner tags
|
||||||
|
|
||||||
if (atom->molecular == Atom::MOLECULAR)
|
if (atom->molecular == Atom::MOLECULAR) {
|
||||||
{
|
|
||||||
// Build list of my atoms' bond partners
|
// Build list of my atoms' bond partners
|
||||||
for (int i=0; i<nlocal; i++) {
|
for (int i=0; i<nlocal; i++) {
|
||||||
if (drudetype[type[i]] == NOPOL_TYPE) continue;
|
if (drudetype[type[i]] == NOPOL_TYPE) continue;
|
||||||
@ -117,9 +119,7 @@ void FixDrude::build_drudeid() {
|
|||||||
core_drude_vec.push_back(atom->bond_atom[i][k]);
|
core_drude_vec.push_back(atom->bond_atom[i][k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// Template case
|
// Template case
|
||||||
class Molecule **atommols;
|
class Molecule **atommols;
|
||||||
atommols = atom->avec->onemols;
|
atommols = atom->avec->onemols;
|
||||||
@ -157,10 +157,10 @@ void FixDrude::build_drudeid() {
|
|||||||
// At this point each of my Drudes knows its core.
|
// At this point each of my Drudes knows its core.
|
||||||
// Send my list of Drudes to other procs and myself
|
// Send my list of Drudes to other procs and myself
|
||||||
// so that each core finds its Drude.
|
// so that each core finds its Drude.
|
||||||
comm->ring(drude_vec.size(), sizeof(tagint),
|
comm->ring(drude_vec.size(), sizeof(tagint), (char *) drude_vec.data(),
|
||||||
(char *) drude_vec.data(),
|
|
||||||
3, ring_search_drudeid, nullptr, (void *)this, 1);
|
3, ring_search_drudeid, nullptr, (void *)this, 1);
|
||||||
delete [] partner_set;
|
delete[] partner_set;
|
||||||
|
|
||||||
// Check if all cores have a drude particle attached
|
// Check if all cores have a drude particle attached
|
||||||
for (int i=0; i<nlocal; i++) {
|
for (int i=0; i<nlocal; i++) {
|
||||||
if (drudetype[type[i]] == CORE_TYPE) {
|
if (drudetype[type[i]] == CORE_TYPE) {
|
||||||
@ -354,7 +354,8 @@ void FixDrude::rebuild_special() {
|
|||||||
utils::logmesg(lmp, "New max number of 1-2 to 1-4 neighbors: {} (+{})\n", nspecmax, nspecmax - nspecmax_old);
|
utils::logmesg(lmp, "New max number of 1-2 to 1-4 neighbors: {} (+{})\n", nspecmax, nspecmax - nspecmax_old);
|
||||||
|
|
||||||
if (atom->maxspecial < nspecmax)
|
if (atom->maxspecial < nspecmax)
|
||||||
error->all(FLERR, "Not enough space in special: extra/special/per/atom should be at least {}", nspecmax - nspecmax_old);
|
error->all(FLERR, Error::NOLASTLINE, "Not enough space for special neighbors list: "
|
||||||
|
"use extra/special/per/atom with at least a value of {}", nspecmax - nspecmax_old);
|
||||||
|
|
||||||
// Build list of cores' special lists to communicate to ghost drude particles
|
// Build list of cores' special lists to communicate to ghost drude particles
|
||||||
for (int i=0; i<nlocal; i++) {
|
for (int i=0; i<nlocal; i++) {
|
||||||
@ -519,7 +520,8 @@ void FixDrude::ring_copy_drude(int size, char *cbuf, void *ptr) {
|
|||||||
void FixDrude::set_arrays(int i) {
|
void FixDrude::set_arrays(int i) {
|
||||||
if (drudetype[atom->type[i]] != NOPOL_TYPE) {
|
if (drudetype[atom->type[i]] != NOPOL_TYPE) {
|
||||||
if (atom->nspecial[i] == nullptr)
|
if (atom->nspecial[i] == nullptr)
|
||||||
error->all(FLERR, "Polarizable atoms cannot be inserted with special lists info from the molecule template");
|
error->all(FLERR, Error::NOLASTLINE, "Polarizable atoms cannot be inserted "
|
||||||
|
"with special lists info from the molecule template");
|
||||||
drudeid[i] = atom->special[i][0]; // Drude partner should be at first place in the special list
|
drudeid[i] = atom->special[i][0]; // Drude partner should be at first place in the special list
|
||||||
} else {
|
} else {
|
||||||
drudeid[i] = 0;
|
drudeid[i] = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user