Merge pull request #1621 from akohlmey/collected-small-fixes

Collected small fixes and updates
This commit is contained in:
Axel Kohlmeyer
2019-08-20 19:36:10 -04:00
committed by GitHub
8 changed files with 59 additions and 32 deletions

View File

@ -30,9 +30,11 @@
#include "error.h"
#include "math_const.h"
#include "math_special.h"
using namespace LAMMPS_NS;
using namespace MathConst;
using namespace MathSpecial;
#define MAXLINE 1024
#define DELTA 4
@ -604,7 +606,7 @@ double PairTersoff::zeta(Param *param, double rsqij, double rsqik,
costheta = (delrij[0]*delrik[0] + delrij[1]*delrik[1] +
delrij[2]*delrik[2]) / (rij*rik);
if (param->powermint == 3) arg = pow(param->lam3 * (rij-rik),3.0);
if (param->powermint == 3) arg = cube(param->lam3 * (rij-rik));
else arg = param->lam3 * (rij-rik);
if (arg > 69.0776) ex_delr = 1.e30;
@ -744,7 +746,7 @@ void PairTersoff::ters_zetaterm_d(double prefactor,
fc = ters_fc(rik,param);
dfc = ters_fc_d(rik,param);
if (param->powermint == 3) tmp = pow(param->lam3 * (rij-rik),3.0);
if (param->powermint == 3) tmp = cube(param->lam3 * (rij-rik));
else tmp = param->lam3 * (rij-rik);
if (tmp > 69.0776) ex_delr = 1.e30;
@ -752,7 +754,7 @@ void PairTersoff::ters_zetaterm_d(double prefactor,
else ex_delr = exp(tmp);
if (param->powermint == 3)
ex_delr_d = 3.0*pow(param->lam3,3.0) * pow(rij-rik,2.0)*ex_delr;
ex_delr_d = 3.0*cube(param->lam3) * square(rij-rik)*ex_delr;
else ex_delr_d = param->lam3 * ex_delr;
cos_theta = vec3_dot(rij_hat,rik_hat);

View File

@ -25,11 +25,13 @@
#include "force.h"
#include "comm.h"
#include "math_const.h"
#include "math_special.h"
#include "memory.h"
#include "error.h"
using namespace LAMMPS_NS;
using namespace MathConst;
using namespace MathSpecial;
#define MAXLINE 1024
#define DELTA 4
@ -241,7 +243,7 @@ double PairTersoffMOD::zeta(Param *param, double rsqij, double rsqik,
costheta = (delrij[0]*delrik[0] + delrij[1]*delrik[1] +
delrij[2]*delrik[2]) / (rij*rik);
if (param->powermint == 3) arg = pow(param->lam3 * (rij-rik),3.0);
if (param->powermint == 3) arg = cube(param->lam3 * (rij-rik));
else arg = param->lam3 * (rij-rik);
if (arg > 69.0776) ex_delr = 1.e30;
@ -314,7 +316,7 @@ void PairTersoffMOD::ters_zetaterm_d(double prefactor,
fc = ters_fc(rik,param);
dfc = ters_fc_d(rik,param);
if (param->powermint == 3) tmp = pow(param->lam3 * (rij-rik),3.0);
if (param->powermint == 3) tmp = cube(param->lam3 * (rij-rik));
else tmp = param->lam3 * (rij-rik);
if (tmp > 69.0776) ex_delr = 1.e30;
@ -322,7 +324,7 @@ void PairTersoffMOD::ters_zetaterm_d(double prefactor,
else ex_delr = exp(tmp);
if (param->powermint == 3)
ex_delr_d = 3.0*pow(param->lam3,3.0) * pow(rij-rik,2.0)*ex_delr;
ex_delr_d = 3.0*cube(param->lam3) * square(rij-rik)*ex_delr;
else ex_delr_d = param->lam3 * ex_delr;
cos_theta = vec3_dot(rij_hat,rik_hat);

View File

@ -28,9 +28,11 @@
#include "memory.h"
#include "error.h"
#include "math_const.h"
#include "math_special.h"
using namespace LAMMPS_NS;
using namespace MathConst;
using namespace MathSpecial;
#define MAXLINE 1024
#define DELTA 4
@ -226,7 +228,7 @@ void PairTersoffZBL::repulsive(Param *param, double rsq, double &fforce,
// ZBL repulsive portion
double esq = pow(global_e,2.0);
double esq = square(global_e);
double a_ij = (0.8854*global_a_0) /
(pow(param->Z_i,0.23) + pow(param->Z_j,0.23));
double premult = (param->Z_i * param->Z_j * esq)/(4.0*MY_PI*global_epsilon_0);
@ -286,5 +288,5 @@ double PairTersoffZBL::F_fermi(double r, Param *param)
double PairTersoffZBL::F_fermi_d(double r, Param *param)
{
return param->ZBLexpscale*exp(-param->ZBLexpscale*(r-param->ZBLcut)) /
pow(1.0 + exp(-param->ZBLexpscale*(r-param->ZBLcut)),2.0);
square(1.0 + exp(-param->ZBLexpscale*(r-param->ZBLcut)));
}

View File

@ -14,7 +14,6 @@
#ifndef LMP_COMM_TILED_H
#define LMP_COMM_TILED_H
#include <mpi.h>
#include "comm.h"
namespace LAMMPS_NS {

View File

@ -14,7 +14,6 @@
#ifndef LMP_IRREGULAR_H
#define LMP_IRREGULAR_H
#include <mpi.h>
#include "pointers.h"
namespace LAMMPS_NS {

View File

@ -14,7 +14,6 @@
#ifndef LAMMPS_RCB_H
#define LAMMPS_RCB_H
#include <mpi.h>
#include "pointers.h"
namespace LAMMPS_NS {

View File

@ -22,7 +22,6 @@ CommandStyle(read_dump,ReadDump)
#ifndef LMP_READ_DUMP_H
#define LMP_READ_DUMP_H
#include <mpi.h>
#include "pointers.h"
namespace LAMMPS_NS {

View File

@ -18,6 +18,7 @@
#include <cstring>
#include <cctype>
#include <unistd.h>
#include <string>
#include "universe.h"
#include "atom.h"
#include "update.h"
@ -1302,8 +1303,12 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
if (word[0] == 'C') lowercase = 0;
int icompute = modify->find_compute(word+2);
if (icompute < 0)
print_var_error(FLERR,"Invalid compute ID in variable formula",ivar);
if (icompute < 0) {
std::string mesg = "Invalid compute ID '";
mesg += (word+2);
mesg += "' in variable formula";
print_var_error(FLERR,mesg.c_str(),ivar);
}
Compute *compute = modify->compute[icompute];
// parse zero or one or two trailing brackets
@ -1604,9 +1609,10 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
int ifix = modify->find_fix(word+2);
if (ifix < 0) {
char msg[128];
snprintf(msg,128,"Invalid fix ID '%s' in variable formula",word+2);
print_var_error(FLERR,msg,ivar);
std::string mesg = "Invalid fix ID '";
mesg += (word+2);
mesg += "' in variable formula";
print_var_error(FLERR,mesg.c_str(),ivar);
}
Fix *fix = modify->fix[ifix];
@ -3792,8 +3798,12 @@ int Variable::group_function(char *word, char *contents, Tree **tree,
// group to operate on
int igroup = group->find(args[0]);
if (igroup == -1)
print_var_error(FLERR,"Group ID in variable formula does not exist",ivar);
if (igroup == -1) {
std::string mesg = "Group ID '";
mesg += args[0];
mesg += "' in variable formula does not exist";
print_var_error(FLERR,mesg.c_str(),ivar);
}
// match word to group function
@ -4001,8 +4011,12 @@ int Variable::group_function(char *word, char *contents, Tree **tree,
int Variable::region_function(char *id, int ivar)
{
int iregion = domain->find_region(id);
if (iregion == -1)
print_var_error(FLERR,"Region ID in variable formula does not exist",ivar);
if (iregion == -1) {
std::string mesg = "Region ID '";
mesg += id;
mesg += "' in variable formula does not exist";
print_var_error(FLERR,mesg.c_str(),ivar);
}
// init region in case sub-regions have been deleted
@ -4080,9 +4094,10 @@ int Variable::special_function(char *word, char *contents, Tree **tree,
int icompute = modify->find_compute(&args[0][2]);
if (icompute < 0) {
char msg[128];
snprintf(msg,128,"Invalid compute ID '%s' in variable formula",word+2);
print_var_error(FLERR,msg,ivar);
std::string mesg = "Invalid compute ID '";
mesg += (args[0]+2);
mesg += "' in variable formula";
print_var_error(FLERR,mesg.c_str(),ivar);
}
compute = modify->compute[icompute];
if (index == 0 && compute->vector_flag) {
@ -4123,13 +4138,20 @@ int Variable::special_function(char *word, char *contents, Tree **tree,
} else index = 0;
int ifix = modify->find_fix(&args[0][2]);
if (ifix < 0)
print_var_error(FLERR,"Invalid fix ID in variable formula",ivar);
if (ifix < 0) {
std::string mesg = "Invalid fix ID '";
mesg += (args[0]+2);
mesg += "' in variable formula";
print_var_error(FLERR,mesg.c_str(),ivar);
}
fix = modify->fix[ifix];
if (index == 0 && fix->vector_flag) {
if (update->whichflag > 0 && update->ntimestep % fix->global_freq)
print_var_error(FLERR,"Fix in variable not computed at "
"compatible time",ivar);
if (update->whichflag > 0 && update->ntimestep % fix->global_freq) {
std::string mesg = "Fix with ID '";
mesg += (args[0]+2);
mesg += "' in variable formula not computed at compatible time";
print_var_error(FLERR,mesg.c_str(),ivar);
}
nvec = fix->size_vector;
nstride = 1;
} else if (index && fix->array_flag) {
@ -4336,9 +4358,12 @@ int Variable::special_function(char *word, char *contents, Tree **tree,
print_var_error(FLERR,"Invalid special function in variable formula",ivar);
int ivar = find(args[0]);
if (ivar < 0)
print_var_error(FLERR,"Variable ID in "
"variable formula does not exist",ivar);
if (ivar < 0) {
std::string mesg = "Variable ID '";
mesg += args[0];
mesg += "' in variable formula does not exist";
print_var_error(FLERR,mesg.c_str(),ivar);
}
// SCALARFILE has single current value, read next one
// save value in tree or on argstack