programming style updates

This commit is contained in:
Axel Kohlmeyer
2024-01-19 00:03:13 -05:00
parent 4015d1bb39
commit e28f93dca4
7 changed files with 73 additions and 100 deletions

View File

@ -25,14 +25,14 @@
using namespace LAMMPS_NS;
enum{UNKNOWN,FFIELD,LITERATURE,ATOMTYPE,VDWL,VDWLPAIR,BSTRETCH,SBEND,ABEND,
PAULI,DISPERSION,UB,OUTPLANE,TORSION,PITORSION,ATOMMULT,
QPENETRATION,DIPPOLAR,QTRANSFER,END_OF_FILE};
enum{ALLINGER,BUFFERED_14_7};
enum{ARITHMETIC,GEOMETRIC,CUBIC_MEAN,R_MIN,SIGMA,DIAMETER,HARMONIC,HHG,W_H};
enum{MUTUAL,OPT,TCG,DIRECT};
enum{NOFRAME,ZONLY,ZTHENX,BISECTOR,ZBISECT,THREEFOLD};
enum{GEAR,ASPC,LSQR};
enum { UNKNOWN, FFIELD, LITERATURE, ATOMTYPE, VDWL, VDWLPAIR, BSTRETCH, SBEND, ABEND,
PAULI, DISPERSION, UB, OUTPLANE, TORSION, PITORSION, ATOMMULT, QPENETRATION, DIPPOLAR,
QTRANSFER, END_OF_FILE };
enum { ALLINGER, BUFFERED_14_7 };
enum { ARITHMETIC, GEOMETRIC, CUBIC_MEAN, R_MIN, SIGMA, DIAMETER, HARMONIC, HHG, W_H };
enum { MUTUAL, OPT, TCG, DIRECT };
enum { NOFRAME, ZONLY, ZTHENX, BISECTOR, ZBISECT, THREEFOLD };
enum { GEAR, ASPC, LSQR };
static constexpr int MAXLINE = 65536; // crazy big for TORSION-TORSION section
static constexpr int MAX_TYPE_PER_GROUP = 6; // max types per AMOEBA group

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -42,31 +41,30 @@ using namespace LAMMPS_NS;
using namespace FixConst;
static const char cite_user_bocs_package[] =
"BOCS package: doi:10.1021/acs.jpcb.7b09993\n\n"
"@Article{Dunn2018,\n"
" author = {N. J. H. Dunn and K. M. Lebold and M. R. {DeLyser} and\n"
" J. F. Rudzinski and W. G. Noid},\n"
" title = {{BOCS}: Bottom-Up Open-Source Coarse-Graining Software},\n"
" journal = {J.~Phys.\\ Chem.~B},\n"
" year = 2018,\n"
" volume = 122,\n"
" number = 13,\n"
" pages = {3363--3377}\n"
"}\n\n";
enum{NOBIAS,BIAS};
enum{NONE,XYZ,XY,YZ,XZ};
enum{ISO,ANISO,TRICLINIC};
"BOCS package: doi:10.1021/acs.jpcb.7b09993\n\n"
"@Article{Dunn2018,\n"
" author = {N. J. H. Dunn and K. M. Lebold and M. R. {DeLyser} and\n"
" J. F. Rudzinski and W. G. Noid},\n"
" title = {{BOCS}: Bottom-Up Open-Source Coarse-Graining Software},\n"
" journal = {J.~Phys.\\ Chem.~B},\n"
" year = 2018,\n"
" volume = 122,\n"
" number = 13,\n"
" pages = {3363--3377}\n"
"}\n\n";
static constexpr double DELTAFLIP = 0.1;
static constexpr double TILTMAX = 1.5;
static constexpr int NUM_INPUT_DATA_COLUMNS = 2; // columns in the pressure correction file
enum { NOBIAS, BIAS };
enum { NONE, XYZ, XY, YZ, XZ };
enum { ISO, ANISO, TRICLINIC };
/* ----------------------------------------------------------------------
NVT,NPH,NPT integrators for improved Nose-Hoover equations of motion
---------------------------------------------------------------------- */
// clang-format off
FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg), id_dilate(nullptr), irregular(nullptr), id_temp(nullptr),
@ -75,7 +73,7 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) :
{
if (lmp->citeme) lmp->citeme->add(cite_user_bocs_package);
if (narg < 4) error->all(FLERR,"Illegal fix bocs command");
if (narg < 4) utils::missing_cmd_args(FLERR,"fix bocs",error);
restart_global = 1;
dynamic_group_allow = 1;
@ -649,17 +647,13 @@ int FixBocs::read_F_table( char *filename, int p_basis_type )
for (int i = 0; i < (int)inputLines.size(); ++i) {
lineNum++; // count each line processed now so lineNum messages can be 1-based
test_sscanf = sscanf(inputLines.at(i).c_str()," %f , %f ",&f1, &f2);
if (test_sscanf == 2)
{
if (test_sscanf == 2) {
data[VOLUME][i] = (double)f1;
data[PRESSURE_CORRECTION][i] = (double)f2;
if (i == 1)
{
if (i == 1) {
// second entry is used to compute the validation interval used below
stdVolumeInterval = data[VOLUME][i] - data[VOLUME][i-1];
}
else if (i > 1)
{
} else if (i > 1) {
// after second entry, all intervals are validated
currVolumeInterval = data[VOLUME][i] - data[VOLUME][i-1];
if (fabs(currVolumeInterval - stdVolumeInterval) > volumeIntervalTolerance) {
@ -673,17 +667,14 @@ int FixBocs::read_F_table( char *filename, int p_basis_type )
}
// no concluding else is intentional: i = 0, first line, no interval to validate
}
}
else
{
} else {
if (comm->me == 0)
error->warning(FLERR,"Bad input format: did not find 2 comma separated numeric"
" values in line {} of file {}\nWARNING:\tline: {}",
lineNum, filename, inputLines.at(i));
badInput = true;
}
if (badInput)
{
if (badInput) {
numBadVolumeIntervals++;
}
}
@ -700,18 +691,13 @@ int FixBocs::read_F_table( char *filename, int p_basis_type )
error->warning(FLERR,"Bad volume / pressure-correction data: {}\nSee details above", filename);
}
if (p_basis_type == BASIS_LINEAR_SPLINE)
{
if (p_basis_type == BASIS_LINEAR_SPLINE) {
spline_length = numEntries;
numEntries = build_linear_splines(data);
}
else if (p_basis_type == BASIS_CUBIC_SPLINE)
{
} else if (p_basis_type == BASIS_CUBIC_SPLINE) {
spline_length = numEntries;
numEntries = build_cubic_splines(data);
}
else
{
} else {
error->all(FLERR,"ERROR: invalid p_basis_type value of {} in read_F_table", p_basis_type);
}
@ -724,8 +710,7 @@ int FixBocs::build_linear_splines(double **data) {
splines[VOLUME] = (double *) calloc(spline_length,sizeof(double));
splines[PRESSURE_CORRECTION] = (double *) calloc(spline_length,sizeof(double));
for (int i = 0; i < spline_length; ++i)
{
for (int i = 0; i < spline_length; ++i) {
splines[VOLUME][i] = data[VOLUME][i];
splines[PRESSURE_CORRECTION][i] = data[PRESSURE_CORRECTION][i];
}
@ -758,18 +743,15 @@ int FixBocs::build_cubic_splines(double **data)
memory->create(mu, n, "mu");
memory->create(z, n, "z");
for (int i=0; i<n; i++)
{
for (int i=0; i<n; i++) {
a[i] = data[1][i];
b[i] = 0.0;
d[i] = 0.0;
if (i<(n-1))
{
if (i<(n-1)) {
h[i] = (data[0][i+1] - data[0][i]);
}
double alpha_i;
if (i>1 && i<(n-1))
{
if (i>1 && i<(n-1)) {
alpha_i = (3.0 / h[i]) * ( data[1][i+1] - data[1][i]) - (3.0 / h[i-1] )
* ( data[1][i] - data[1][i-1] );
alpha[i-1] = alpha_i;
@ -779,8 +761,7 @@ int FixBocs::build_cubic_splines(double **data)
mu[0] = 0.0;
z[0] = 0.0;
for (int i=1; i<n-1; i++)
{
for (int i=1; i<n-1; i++) {
l[i] = 2*(data[0][i+1] - data[0][i-1]) - h[i-1] * mu[i-1];
mu[i] = h[i]/l[i];
z[i] = (alpha[i] - h[i-1] * z[i-1]) / l[i];
@ -797,19 +778,15 @@ int FixBocs::build_cubic_splines(double **data)
c[n] = 0.0;
d[n] = 0.0;
for (int j=n-1; j>=0; j--)
{
for (int j=n-1; j>=0; j--) {
c[j] = z[j] - mu[j]*c[j+1];
b[j] = (a[j+1]-a[j])/h[j] - h[j]*(c[j+1] + 2.0 * c[j])/3.0;
d[j] = (c[j+1]-c[j])/(3.0 * h[j]);
}
int numSplines = n - 1;
memory->create(splines, NUM_CUBIC_SPLINE_COLUMNS, numSplines, "splines");
for (int idx = 0; idx < numSplines; ++idx)
{
for (int idx = 0; idx < numSplines; ++idx) {
splines[0][idx] = data[0][idx];
splines[1][idx] = a[idx];
splines[2][idx] = b[idx];

View File

@ -38,8 +38,8 @@ using namespace LAMMPS_NS;
using namespace FixConst;
using namespace MathSpecial;
enum{NONE,HARMONIC};
enum{LUCY};
enum { NONE, HARMONIC };
enum { LUCY };
static constexpr int MAXLINE = 1024;
static constexpr int DELTA = 4;

View File

@ -39,8 +39,7 @@
using namespace LAMMPS_NS;
using MathConst::MY_PI;
enum{NONE,RLINEAR,RSQ};
enum { NONE, RLINEAR, RSQ };
static constexpr int MAXLINE = 1024;
static const char cite_pair_multi_lucy[] =

View File

@ -41,7 +41,7 @@
using namespace LAMMPS_NS;
using MathConst::MY_PI;
enum{NONE,RLINEAR,RSQ};
enum{ NONE, RLINEAR, RSQ };
static constexpr int MAXLINE = 1024;
@ -488,11 +488,8 @@ void PairMultiLucyRX::read_table(Table *tb, char *file, char *keyword)
// open file
FILE *fp = utils::open_potential(file,lmp,nullptr);
if (fp == nullptr) {
char str[128];
snprintf(str,128,"Cannot open file %s",file);
error->one(FLERR,str);
}
if (fp == nullptr)
error->one(FLERR, "Cannot open file {}: {}",file,utils::getsyserror());
// loop until section found with matching keyword

View File

@ -47,7 +47,7 @@ using namespace FixConst;
static constexpr int MAXLINE = 512;
enum{FORWARD=-1,BACKWARD=1};
enum{ FORWARD=-1, BACKWARD=1 };
static const char cite_fix_phonon[] =
"fix phonon command: doi:10.1016/j.cpc.2011.04.019\n\n"

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -58,26 +57,26 @@ using namespace FixConst;
using namespace MathConst;
static const char cite_fix_bond_react[] =
"fix bond/react: reacter.org doi:10.1016/j.polymer.2017.09.038, doi:10.1021/acs.macromol.0c02012\n\n"
"@Article{Gissinger17,\n"
" author = {J. R. Gissinger and B. D. Jensen and K. E. Wise},\n"
" title = {Modeling Chemical Reactions in Classical Molecular Dynamics Simulations},\n"
" journal = {Polymer},\n"
" year = 2017,\n"
" volume = 128,\n"
" pages = {211--217}\n"
"}\n\n"
"@Article{Gissinger20,\n"
" author = {J. R. Gissinger, B. D. Jensen, K. E. Wise},\n"
" title = {{REACTER}: A Heuristic Method for Reactive Molecular Dynamics},\n"
" journal = {Macromolecules},\n"
" year = 2020,\n"
" volume = 53,\n"
" number = 22,\n"
" pages = {9953--9961}\n"
"}\n\n";
"fix bond/react: reacter.org doi:10.1016/j.polymer.2017.09.038, "
"doi:10.1021/acs.macromol.0c02012\n\n"
"@Article{Gissinger17,\n"
" author = {J. R. Gissinger and B. D. Jensen and K. E. Wise},\n"
" title = {Modeling Chemical Reactions in Classical Molecular Dynamics Simulations},\n"
" journal = {Polymer},\n"
" year = 2017,\n"
" volume = 128,\n"
" pages = {211--217}\n"
"}\n\n"
"@Article{Gissinger20,\n"
" author = {J. R. Gissinger, B. D. Jensen, K. E. Wise},\n"
" title = {{REACTER}: A Heuristic Method for Reactive Molecular Dynamics},\n"
" journal = {Macromolecules},\n"
" year = 2020,\n"
" volume = 53,\n"
" number = 22,\n"
" pages = {9953--9961}\n"
"}\n\n";
static constexpr double BIG = 1.0e20;
static constexpr int DELTA = 16;
static constexpr int MAXGUESS = 20; // max # of guesses allowed by superimpose algorithm
@ -91,24 +90,25 @@ static constexpr int NUMVARVALS = 5; // max # of keyword values that have va
// CONTINUE: a neighbor has been assigned, skip to next neighbor
// GUESSFAIL: a guess has failed (if no more restore points, status = 'REJECT')
// RESTORE: restore mode, load most recent restore point
enum{ACCEPT,REJECT,PROCEED,CONTINUE,GUESSFAIL,RESTORE};
enum { ACCEPT, REJECT, PROCEED, CONTINUE, GUESSFAIL, RESTORE };
// types of available reaction constraints
enum{DISTANCE,ANGLE,DIHEDRAL,ARRHENIUS,RMSD,CUSTOM};
enum { DISTANCE, ANGLE, DIHEDRAL, ARRHENIUS, RMSD, CUSTOM };
// ID type used by constraint
enum{ATOM,FRAG};
enum { ATOM, FRAG };
// keyword values that accept variables as input
enum{NEVERY,RMIN,RMAX,PROB,NRATE};
enum { NEVERY, RMIN, RMAX, PROB, NRATE };
// flag for one-proc vs shared reaction sites
enum{LOCAL,GLOBAL};
enum { LOCAL, GLOBAL };
// values for molecule_keyword
enum{OFF,INTER,INTRA};
enum { OFF, INTER, INTRA };
/* ---------------------------------------------------------------------- */
// clang-format off
FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg)