Merge pull request #2856 from akohlmey/collected-small-changes

Collected small changes and fixes
This commit is contained in:
Axel Kohlmeyer
2021-07-30 11:36:40 -04:00
committed by GitHub
27 changed files with 242 additions and 233 deletions

63
.github/CODEOWNERS vendored
View File

@ -22,42 +22,42 @@ src/MESSAGE/* @sjplimp
src/MLIAP/* @athomps
src/SNAP/* @athomps
src/SPIN/* @julient31
src/BROWNIAN/* @samueljmcameron
src/CG-DNA/* @ohenrich
src/CG-SDK/* @akohlmey
src/COLVARS/* @giacomofiorin
src/DIELECTRIC/* @ndtrung81
src/FEP/* @agiliopadua
src/ML-HDNNP/* @singraber
src/INTEL/* @wmbrownintel
src/MANIFOLD/* @Pakketeretet2
src/MDI/* @taylor-a-barnes
src/MEAM/* @martok
src/MESONT/* @iafoss
src/MOFFF/* @hheenen
src/MOLFILE/* @akohlmey
src/NETCDF/* @pastewka
src/ML-PACE/* @yury-lysogorskiy
src/PLUMED/* @gtribello
src/PHONON/* @lingtikong
src/PTM/* @pmla
src/OPENMP/* @akohlmey
src/QMMM/* @akohlmey
src/REAXFF/* @hasanmetin
src/REACTION/* @jrgissing
src/SCAFACOS/* @rhalver
src/TALLY/* @akohlmey
src/UEF/* @danicholson
src/VTK/* @rbberger
src/BROWNIAN/* @samueljmcameron
src/CG-DNA/* @ohenrich
src/CG-SDK/* @akohlmey
src/COLVARS/* @giacomofiorin
src/DIELECTRIC/* @ndtrung81
src/FEP/* @agiliopadua
src/ML-HDNNP/* @singraber
src/INTEL/* @wmbrownintel
src/MANIFOLD/* @Pakketeretet2
src/MDI/* @taylor-a-barnes
src/MEAM/* @martok
src/MESONT/* @iafoss
src/MOFFF/* @hheenen
src/MOLFILE/* @akohlmey
src/NETCDF/* @pastewka
src/ML-PACE/* @yury-lysogorskiy
src/PLUMED/* @gtribello
src/PHONON/* @lingtikong
src/PTM/* @pmla
src/OPENMP/* @akohlmey
src/QMMM/* @akohlmey
src/REAXFF/* @hasanmetin @stanmoore1
src/REACTION/* @jrgissing
src/SCAFACOS/* @rhalver
src/TALLY/* @akohlmey
src/UEF/* @danicholson
src/VTK/* @rbberger
# individual files in packages
src/GPU/pair_vashishta_gpu.* @andeplane
src/KOKKOS/pair_vashishta_kokkos.* @andeplane
src/MANYBODY/pair_vashishta_table.* @andeplane
src/MANYBODY/pair_atm.* @sergeylishchuk
src/USER-MISC/*_grem.* @dstelter92
src/USER-MISC/compute_stress_mop*.* @RomainVermorel
src/REPLICA/*_grem.* @dstelter92
src/EXTRA-COMPUTE/compute_stress_mop*.* @RomainVermorel
src/MISC/*_tracker.* @jtclemm
# core LAMMPS classes
src/lammps.* @sjplimp
@ -81,6 +81,7 @@ src/kspace.* @sjplimp
src/lmptyp.h @sjplimp
src/library.* @sjplimp
src/main.cpp @sjplimp
src/min_*.* @sjplimp
src/memory.* @sjplimp
src/modify.* @sjplimp
src/molecule.* @sjplimp
@ -109,7 +110,6 @@ src/thermo.* @sjplimp
src/universe.* @sjplimp
src/update.* @sjplimp
src/variable.* @sjplimp
src/verlet.* @sjplimp
src/velocity.* @sjplimp
src/write_data.* @sjplimp
src/write_restart.* @sjplimp
@ -122,6 +122,7 @@ src/info.* @akohlmey @rbberger
src/timer.* @akohlmey
src/min* @sjplimp @stanmoore1
src/utils.* @akohlmey @rbberger
src/verlet.* @sjplimp @stanmoore1
src/math_eigen_impl.h @jewettaij
# tools

View File

@ -29,7 +29,7 @@ OPT.
* :doc:`hybrid/scaled <pair_hybrid>`
* :doc:`kim <pair_kim>`
* :doc:`list <pair_list>`
*
* :doc:`tracker <pair_tracker>`
*
*
*
@ -273,7 +273,6 @@ OPT.
* :doc:`tip4p/cut (o) <pair_coul>`
* :doc:`tip4p/long (o) <pair_coul>`
* :doc:`tip4p/long/soft (o) <pair_fep_soft>`
* :doc:`tracker <pair_tracker>`
* :doc:`tri/lj <pair_tri_lj>`
* :doc:`ufm (got) <pair_ufm>`
* :doc:`vashishta (gko) <pair_vashishta>`

View File

@ -84,7 +84,10 @@ This pair style can only be used via the *pair* keyword of the
Restrictions
""""""""""""
none
This pair style is part of the EXTRA-PAIR package. It is only enabled if
LAMMPS was built with that package. See the
:doc:`Build package <Build_package>` page for more info.
Related commands
""""""""""""""""

View File

@ -1 +1 @@
../../../../potentials/NiAlH_jea.eam.alloy
../../../potentials/NiAlH_jea.eam.alloy

View File

@ -1 +1 @@
../../../../potentials/Si.sw
../../../potentials/Si.sw

View File

@ -1 +1 @@
../../../../potentials/Ni_u3.eam
../../../potentials/Ni_u3.eam

65
src/.gitignore vendored
View File

@ -77,6 +77,7 @@
/compute_mliap.h
/mliap_*.cpp
/mliap_*.h
/mliap_model_python_couple.pyx
/pair_mliap.cpp
/pair_mliap.h
@ -250,8 +251,12 @@
/pair_mesont_tpm.cpp
/pair_mesont_tpm.h
/compute_adf.cpp
/compute_adf.h
/compute_contact_atom.cpp
/compute_contact_atom.h
/compute_hexorder_atom.cpp
/compute_hexorder_atom.h
/dump_dcd.cpp
/dump_dcd.h
/fix_controller.cpp
@ -270,6 +275,8 @@
/fix_temp_csvr.h
/fix_tmd.cpp
/fix_tmd.h
/pair_beck.cpp
/pair_beck.h
/pair_born_coul_dsf.cpp
/pair_born_coul_dsf.h
/pair_born_coul_wolf.cpp
@ -284,6 +291,7 @@
/pair_lj96_cut.h
/pair_lj_cubic.cpp
/pair_lj_cubic.h
/pair_lj_cubic_const.h
/pair_lj_cut_coul_debye.cpp
/pair_lj_cut_coul_debye.h
/pair_lj_cut_coul_dsf.cpp
@ -292,8 +300,8 @@
/pair_lj_cut_coul_wolf.h
/pair_lj_gromacs.cpp
/pair_lj_gromacs.h
/pair_lj_gromacs_could_gromacs.cpp
/pair_lj_gromacs_could_gromacs.h
/pair_lj_gromacs_coul_gromacs.cpp
/pair_lj_gromacs_coul_gromacs.h
/pair_lj_relres.cpp
/pair_lj_relres.h
/pair_lj_smooth.cpp
@ -783,18 +791,18 @@
/fix_pour.h
/fix_qeq_comb.cpp
/fix_qeq_comb.h
/fix_qeq_reax.cpp
/fix_qeq_fire.cpp
/fix_qeq_fire.h
/fix_qeq_reax.h
/fix_qeq_reaxff.cpp
/fix_qeq_reaxff.h
/fix_qmmm.cpp
/fix_qmmm.h
/fix_reaxc.cpp
/fix_reaxc.h
/fix_reaxc_bonds.cpp
/fix_reaxc_bonds.h
/fix_reaxc_species.cpp
/fix_reaxc_species.h
/fix_reaxff.cpp
/fix_reaxff.h
/fix_reaxff_bonds.cpp
/fix_reaxff_bonds.h
/fix_reaxff_species.cpp
/fix_reaxff_species.h
/fix_rhok.cpp
/fix_rhok.h
/fix_rigid.cpp
@ -1182,8 +1190,8 @@
/pair_peri_ves.h
/pair_quip.cpp
/pair_quip.h
/pair_reaxc.cpp
/pair_reaxc.h
/pair_reaxff.cpp
/pair_reaxff.h
/pair_rebo.cpp
/pair_rebo.h
/pair_resquared.cpp
@ -1270,23 +1278,22 @@
/reader_adios.h
/reader_molfile.cpp
/reader_molfile.h
/reaxc_allocate.cpp
/reaxc_basic_comm.cpp
/reaxc_bond_orders.cpp
/reaxc_bonds.cpp
/reaxc_control.cpp
/reaxc_ffield.cpp
/reaxc_forces.cpp
/reaxc_hydrogen_bonds.cpp
/reaxc_init_md.cpp
/reaxc_list.cpp
/reaxc_lookup.cpp
/reaxc_multi_body.cpp
/reaxc_nonbonded.cpp
/reaxc_reset_tools.cpp
/reaxc_tool_box.cpp
/reaxc_torsion_angles.cpp
/reaxc_valence_angles.cpp
/reaxff_allocate.cpp
/reaxff_bond_orders.cpp
/reaxff_bonds.cpp
/reaxff_control.cpp
/reaxff_ffield.cpp
/reaxff_forces.cpp
/reaxff_hydrogen_bonds.cpp
/reaxff_init_md.cpp
/reaxff_list.cpp
/reaxff_lookup.cpp
/reaxff_multi_body.cpp
/reaxff_nonbonded.cpp
/reaxff_reset_tools.cpp
/reaxff_tool_box.cpp
/reaxff_torsion_angles.cpp
/reaxff_valence_angles.cpp
/reaxff_api.h
/reaxff_defs.h
/reaxff_inline.h

View File

@ -80,7 +80,7 @@ void AtomVecOxdna::data_atom_post(int ilocal)
store 5' partner to inform 3'->5' bond directionality
------------------------------------------------------------------------- */
void AtomVecOxdna::data_bonds_post(int m, int num_bond, tagint atom1, tagint atom2,
void AtomVecOxdna::data_bonds_post(int /*m*/, int /*num_bond*/, tagint atom1, tagint atom2,
tagint id_offset)
{
int n;

View File

@ -255,7 +255,6 @@ void PairOxdnaStk::compute(int eflag, int vflag)
double f1,f4t4,f4t5,f4t6,f5c1,f5c2;
double df1,df4t4,df4t5,df4t6,df5c1,df5c2;
double tptofp;
evdwl = 0.0;
ev_init(eflag,vflag);

View File

@ -272,7 +272,6 @@ void PairOxrna2Stk::compute(int eflag, int vflag)
double f1,f4t5,f4t6,f4t9,f4t10,f5c1,f5c2;
double df1,df4t5,df4t6,df4t9,df4t10,df5c1,df5c2;
double tptofp;
evdwl = 0.0;
ev_init(eflag,vflag);

View File

@ -609,7 +609,6 @@ void PPPMDispDielectric::fieldforce_c_ad()
double *q = atom->q;
double **x = atom->x;
double **f = atom->f;
double *eps = atom->epsilon;
int nlocal = atom->nlocal;
for (i = 0; i < nlocal; i++) {

View File

@ -68,7 +68,7 @@ FixMesoMove::FixMesoMove (LAMMPS *lmp, int narg, char **arg) :
// parse args
int iarg;
int iarg = narg;
if (strcmp(arg[3],"linear") == 0) {
if (narg < 7) error->all(FLERR,"Illegal fix meso/move command");

View File

@ -73,6 +73,8 @@ fi
if (test $1 = "DPD-BASIC") then
depend GPU
depend OPENMP
depend INTEL
fi
if (test $1 = "EXTRA-MOLECULE") then

View File

@ -41,14 +41,14 @@ action fix_npt_gpu.cpp
action fix_nve_asphere_gpu.h fix_nve_asphere.h
action fix_nve_asphere_gpu.cpp fix_nve_asphere.cpp
action gpu_extra.h
action pair_beck_gpu.cpp
action pair_beck_gpu.h
action pair_beck_gpu.cpp pair_beck.cpp
action pair_beck_gpu.h pair_beck.h
action pair_born_coul_long_gpu.cpp pair_born_coul_long.cpp
action pair_born_coul_long_gpu.h pair_born_coul_long.cpp
action pair_born_coul_long_cs_gpu.cpp pair_born_coul_long_cs.cpp
action pair_born_coul_long_cs_gpu.h pair_born_coul_long_cs.cpp
action pair_born_coul_wolf_gpu.cpp
action pair_born_coul_wolf_gpu.h
action pair_born_coul_wolf_gpu.cpp pair_born_coul_wolf.cpp
action pair_born_coul_wolf_gpu.h pair_born_coul_wolf.h
action pair_born_coul_wolf_cs_gpu.cpp pair_born_coul_wolf_cs.cpp
action pair_born_coul_wolf_cs_gpu.h pair_born_coul_wolf_cs.cpp
action pair_born_gpu.cpp
@ -71,10 +71,10 @@ action pair_coul_long_gpu.cpp pair_coul_long.cpp
action pair_coul_long_gpu.h pair_coul_long.cpp
action pair_coul_long_cs_gpu.cpp pair_coul_long_cs.cpp
action pair_coul_long_cs_gpu.h pair_coul_long_cs.cpp
action pair_dpd_gpu.cpp
action pair_dpd_gpu.h
action pair_dpd_tstat_gpu.cpp
action pair_dpd_tstat_gpu.h
action pair_dpd_gpu.cpp pair_dpd.cpp
action pair_dpd_gpu.h pair_dpd.h
action pair_dpd_tstat_gpu.cpp pair_dpd_tstat.cpp
action pair_dpd_tstat_gpu.h pair_dpd_tstat.h
action pair_lj_cut_dipole_cut_gpu.cpp pair_lj_cut_dipole_cut.cpp
action pair_lj_cut_dipole_cut_gpu.h pair_lj_cut_dipole_cut.cpp
action pair_lj_sf_dipole_sf_gpu.cpp pair_lj_sf_dipole_sf.cpp
@ -85,12 +85,12 @@ action pair_eam_fs_gpu.cpp pair_eam.cpp
action pair_eam_fs_gpu.h pair_eam.cpp
action pair_eam_gpu.cpp pair_eam.cpp
action pair_eam_gpu.h pair_eam.cpp
action pair_gauss_gpu.cpp
action pair_gauss_gpu.h
action pair_gauss_gpu.cpp pair_gauss.cpp
action pair_gauss_gpu.h pair_gauss.h
action pair_gayberne_gpu.cpp pair_gayberne.cpp
action pair_gayberne_gpu.h pair_gayberne.cpp
action pair_lj96_cut_gpu.cpp
action pair_lj96_cut_gpu.h
action pair_lj96_cut_gpu.cpp pair_lj96_cut.cpp
action pair_lj96_cut_gpu.h pair_lj96_cut.h
action pair_lj_charmm_coul_long_gpu.cpp pair_lj_charmm_coul_long.cpp
action pair_lj_charmm_coul_long_gpu.h pair_lj_charmm_coul_long.cpp
action pair_lj_charmm_coul_charmm_gpu.cpp pair_lj_charmm_coul_charmm.cpp
@ -99,14 +99,14 @@ action pair_lj_class2_coul_long_gpu.cpp pair_lj_class2_coul_long.cpp
action pair_lj_class2_coul_long_gpu.h pair_lj_class2_coul_long.cpp
action pair_lj_class2_gpu.cpp pair_lj_class2.cpp
action pair_lj_class2_gpu.h pair_lj_class2.cpp
action pair_lj_cubic_gpu.cpp
action pair_lj_cubic_gpu.h
action pair_lj_cubic_gpu.cpp pair_lj_cubic.cpp
action pair_lj_cubic_gpu.h pair_lj_cubic.h
action pair_lj_cut_coul_cut_gpu.cpp
action pair_lj_cut_coul_cut_gpu.h
action pair_lj_cut_coul_debye_gpu.cpp
action pair_lj_cut_coul_debye_gpu.h
action pair_lj_cut_coul_dsf_gpu.cpp
action pair_lj_cut_coul_dsf_gpu.h
action pair_lj_cut_coul_debye_gpu.cpp pair_lj_cut_coul_debye.cpp
action pair_lj_cut_coul_debye_gpu.h pair_lj_cut_coul_debye.h
action pair_lj_cut_coul_dsf_gpu.cpp pair_lj_cut_coul_dsf.cpp
action pair_lj_cut_coul_dsf_gpu.h pair_lj_cut_coul_dsf.h
action pair_lj_cut_coul_long_gpu.cpp pair_lj_cut_coul_long.cpp
action pair_lj_cut_coul_long_gpu.h pair_lj_cut_coul_long.cpp
action pair_lj_cut_coul_msm_gpu.cpp pair_lj_cut_coul_msm.cpp
@ -119,14 +119,14 @@ action pair_lj_expand_gpu.cpp
action pair_lj_expand_gpu.h
action pair_lj_expand_coul_long_gpu.cpp pair_lj_expand_coul_long.cpp
action pair_lj_expand_coul_long_gpu.h pair_lj_expand_coul_long.cpp
action pair_lj_gromacs_gpu.cpp
action pair_lj_gromacs_gpu.h
action pair_lj_gromacs_gpu.cpp pair_lj_gromacs.cpp
action pair_lj_gromacs_gpu.h pair_lj_gromacs.h
action pair_lj_sdk_coul_long_gpu.cpp pair_lj_sdk_coul_long.cpp
action pair_lj_sdk_coul_long_gpu.h pair_lj_sdk_coul_long.cpp
action pair_lj_sdk_gpu.cpp pair_lj_sdk.cpp
action pair_lj_sdk_gpu.h pair_lj_sdk.cpp
action pair_mie_cut_gpu.cpp
action pair_mie_cut_gpu.h
action pair_mie_cut_gpu.cpp pair_mie_cut.cpp
action pair_mie_cut_gpu.h pair_mie_cut.h
action pair_morse_gpu.cpp
action pair_morse_gpu.h
action pair_resquared_gpu.cpp pair_resquared.cpp
@ -153,8 +153,8 @@ action pair_zbl_gpu.cpp
action pair_zbl_gpu.h
action pppm_gpu.cpp pppm.cpp
action pppm_gpu.h pppm.cpp
action pair_ufm_gpu.cpp
action pair_ufm_gpu.h
action pair_ufm_gpu.cpp pair_ufm.cpp
action pair_ufm_gpu.h pair_ufm.h
action pair_lj_cut_dipole_long_gpu.cpp pair_lj_cut_dipole_long.cpp
action pair_lj_cut_dipole_long_gpu.h pair_lj_cut_dipole_long.cpp
action pair_lj_cut_tip4p_long_gpu.h pair_lj_cut_tip4p_long.cpp

View File

@ -1,21 +0,0 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
namespace LAMMPS_NS {
template class KissFFTKokkos<LMPDeviceType>;
#ifdef LMP_KOKKOS_GPU
template class KissFFTKokkos<LMPHostType>;
#endif
}

View File

@ -554,7 +554,7 @@ void FixMDIEngine::send_charges(Error *error)
void FixMDIEngine::send_energy(Error *error)
{
// get conversion factor to atomic units
double energy_conv;
double energy_conv = 1.0;
if (lmpunits == REAL) {
double kelvin_to_hartree;
MDI_Conversion_factor("kelvin_energy", "hartree", &kelvin_to_hartree);
@ -884,10 +884,9 @@ void FixMDIEngine::receive_cell(Error *error)
// ensure that the new cell vector is orthogonal
double small = std::numeric_limits<double>::min();
if (abs(celldata[1]) > small or abs(celldata[2]) > small or abs(celldata[3]) > small or
abs(celldata[5]) > small or abs(celldata[6]) > small or abs(celldata[7]) > small) {
error->all(FLERR,
"MDI: LAMMPS currently only supports the >CELL command for orthogonal cell vectors");
if (fabs(celldata[1]) > small or fabs(celldata[2]) > small or fabs(celldata[3]) > small or
fabs(celldata[5]) > small or fabs(celldata[6]) > small or fabs(celldata[7]) > small) {
error->all(FLERR, "MDI: LAMMPS currently only supports the >CELL command for orthogonal cell vectors");
}
// set the new LAMMPS cell dimensions

View File

@ -32,6 +32,7 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918
#include "pair_rann.h"
#include "atom.h"
#include "citeme.h"
#include "comm.h"
#include "error.h"
#include "force.h"
@ -61,7 +62,7 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918
using namespace LAMMPS_NS;
static const char cite_user_rann_package[] =
static const char cite_ml_rann_package[] =
"ML-RANN package:\n\n"
"@Article{Nitol2021,\n"
" author = {Nitol, Mashroor S and Dickel, Doyl E and Barrett, Christopher D},\n"
@ -75,6 +76,8 @@ static const char cite_user_rann_package[] =
PairRANN::PairRANN(LAMMPS *lmp) : Pair(lmp)
{
if (lmp->citeme) lmp->citeme->add(cite_ml_rann_package);
//initialize ints and bools
single_enable = 0;
restartinfo = 0;
@ -353,7 +356,7 @@ void PairRANN::read_file(char *filename)
int eof = 0;
std::string line,line1;
const int longline = 4096;
int linenum;
int linenum=0;
char linetemp[longline];
std::string strtemp;
char *ptr;

View File

@ -104,11 +104,11 @@ void PairLJCutCoulCutDielectricOMP::compute(int eflag, int vflag)
template <int EVFLAG, int EFLAG, int NEWTON_PAIR>
void PairLJCutCoulCutDielectricOMP::eval(int iifrom, int iito, ThrData *const thr)
{
int i, j, ii, jj, jnum, itype, jtype, itable;
double qtmp, etmp, xtmp, ytmp, ztmp, delx, dely, delz, evdwl, ecoul, fpair;
int i, j, ii, jj, jnum, itype, jtype;
double qtmp, etmp, xtmp, ytmp, ztmp, delx, dely, delz, evdwl, ecoul;
double fpair_i, fpair_j;
double r, rsq, r2inv, r6inv, forcecoul, forcelj, factor_coul, factor_lj;
double grij, expm2, prefactor, t, erfc, prefactorE, efield_i, epot_i;
double rsq, r2inv, r6inv, forcecoul, forcelj, factor_coul, factor_lj;
double efield_i, epot_i;
int *ilist, *jlist, *numneigh, **firstneigh;
evdwl = ecoul = 0.0;
@ -221,7 +221,7 @@ void PairLJCutCoulCutDielectricOMP::eval(int iifrom, int iito, ThrData *const th
}
if (EVFLAG)
ev_tally_thr(this, i, j, nlocal, NEWTON_PAIR, evdwl, ecoul, fpair, delx, dely, delz, thr);
ev_tally_thr(this, i, j, nlocal, NEWTON_PAIR, evdwl, ecoul, fpair_i, delx, dely, delz, thr);
}
}
f[i].x += fxtmp;

View File

@ -68,11 +68,11 @@ ArgInfo::ArgInfo(const std::string &arg, int allowed) : type(NONE), dim(0), inde
} else
has_idx2 = arg.size();
if (arg[has_idx2 - 1] != ']') {
if ((arg[has_idx2 - 1] != ']') || ((dim == 1) && (arg.find(']') != has_idx2 - 1))) {
type = UNKNOWN;
} else {
try {
index1 = std::stoi(arg.substr(has_idx1 + 1, arg.size() - (has_idx2 + 2)));
index1 = std::stoi(arg.substr(has_idx1 + 1, arg.size() - (has_idx1 + 2)));
} catch (std::invalid_argument &) {
type = UNKNOWN;
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -14,6 +13,7 @@
#include "imbalance_neigh.h"
#include "accelerator_kokkos.h"
#include "atom.h"
#include "comm.h"
#include "error.h"
@ -36,9 +36,9 @@ ImbalanceNeigh::ImbalanceNeigh(LAMMPS *lmp) : Imbalance(lmp)
int ImbalanceNeigh::options(int narg, char **arg)
{
if (narg < 1) error->all(FLERR,"Illegal balance weight command");
factor = utils::numeric(FLERR,arg[0],false,lmp);
if (factor <= 0.0) error->all(FLERR,"Illegal balance weight command");
if (narg < 1) error->all(FLERR, "Illegal balance weight command");
factor = utils::numeric(FLERR, arg[0], false, lmp);
if (factor <= 0.0) error->all(FLERR, "Illegal balance weight command");
return 1;
}
@ -50,19 +50,30 @@ void ImbalanceNeigh::compute(double *weight)
if (factor == 0.0) return;
// cannot use neighbor list weight with KOKKOS using GPUs
if (lmp->kokkos && lmp->kokkos->kokkos_exists) {
if (lmp->kokkos->ngpus > 0) {
if (comm->me == 0 && !did_warn)
error->warning(FLERR, "Balance weight neigh skipped with KOKKOS using GPUs");
did_warn = 1;
return;
}
}
// find suitable neighbor list
// can only use certain conventional neighbor lists
// NOTE: why not full list, if half does not exist?
for (req = 0; req < neighbor->old_nrequest; ++req) {
if (neighbor->old_requests[req]->half &&
neighbor->old_requests[req]->skip == 0 &&
neighbor->lists[req] && neighbor->lists[req]->numneigh) break;
if (neighbor->old_requests[req]->half && neighbor->old_requests[req]->skip == 0 &&
neighbor->lists[req] && neighbor->lists[req]->numneigh)
break;
}
if (req >= neighbor->old_nrequest || neighbor->ago < 0) {
if (comm->me == 0 && !did_warn)
error->warning(FLERR,"Balance weight neigh skipped b/c no list found");
error->warning(FLERR, "Balance weight neigh skipped b/c no list found");
did_warn = 1;
return;
}
@ -72,16 +83,16 @@ void ImbalanceNeigh::compute(double *weight)
NeighList *list = neighbor->lists[req];
const int inum = list->inum;
const int * const ilist = list->ilist;
const int * const numneigh = list->numneigh;
const int *const ilist = list->ilist;
const int *const numneigh = list->numneigh;
int nlocal = atom->nlocal;
bigint neighsum = 0;
for (int i = 0; i < inum; ++i) neighsum += numneigh[ilist[i]];
double localwt = 0.0;
if (nlocal) localwt = 1.0*neighsum/nlocal;
if (nlocal) localwt = 1.0 * neighsum / nlocal;
if (nlocal && localwt <= 0.0) error->one(FLERR,"Balance weight <= 0.0");
if (nlocal && localwt <= 0.0) error->one(FLERR, "Balance weight <= 0.0");
// apply factor if specified != 1.0
// wtlo,wthi = lo/hi values excluding 0.0 due to no atoms on this proc
@ -90,15 +101,15 @@ void ImbalanceNeigh::compute(double *weight)
// expand/contract all localwt values from lo->hi to lo->newhi
if (factor != 1.0) {
double wtlo,wthi;
double wtlo, wthi;
if (localwt == 0.0) localwt = BIG;
MPI_Allreduce(&localwt,&wtlo,1,MPI_DOUBLE,MPI_MIN,world);
MPI_Allreduce(&localwt, &wtlo, 1, MPI_DOUBLE, MPI_MIN, world);
if (localwt == BIG) localwt = 0.0;
MPI_Allreduce(&localwt,&wthi,1,MPI_DOUBLE,MPI_MAX,world);
MPI_Allreduce(&localwt, &wthi, 1, MPI_DOUBLE, MPI_MAX, world);
if (wtlo == wthi) return;
double newhi = wthi*factor;
localwt = wtlo + ((localwt-wtlo)/(wthi-wtlo)) * (newhi-wtlo);
double newhi = wthi * factor;
localwt = wtlo + ((localwt - wtlo) / (wthi - wtlo)) * (newhi - wtlo);
}
for (int i = 0; i < nlocal; i++) weight[i] *= localwt;
@ -108,5 +119,5 @@ void ImbalanceNeigh::compute(double *weight)
std::string ImbalanceNeigh::info()
{
return fmt::format(" neighbor weight factor: {}\n",factor);
return fmt::format(" neighbor weight factor: {}\n", factor);
}

View File

@ -71,16 +71,18 @@ void ReadRestart::command(int narg, char **arg)
// if filename contains "*", search dir for latest restart file
char *file = new char[strlen(arg[0]) + 16];
char *file;
if (strchr(arg[0],'*')) {
int n;
int n=0;
if (me == 0) {
file_search(arg[0],file);
n = strlen(file) + 1;
auto fn = file_search(arg[0]);
n = fn.size()+1;
file = utils::strdup(fn);
}
MPI_Bcast(&n,1,MPI_INT,0,world);
if (me != 0) file = new char[n];
MPI_Bcast(file,n,MPI_CHAR,0,world);
} else strcpy(file,arg[0]);
} else file = utils::strdup(arg[0]);
// check for multiproc files and an MPI-IO filename
@ -90,14 +92,12 @@ void ReadRestart::command(int narg, char **arg)
else mpiioflag = 0;
if (multiproc && mpiioflag)
error->all(FLERR,
"Read restart MPI-IO input not allowed with % in filename");
error->all(FLERR,"Read restart MPI-IO input not allowed with % in filename");
if (mpiioflag) {
mpiio = new RestartMPIIO(lmp);
if (!mpiio->mpiio_exists)
error->all(FLERR,"Reading from MPI-IO filename when "
"MPIIO package is not installed");
error->all(FLERR,"Reading from MPI-IO filename when MPIIO package is not installed");
}
// open single restart file or base file for multiproc case
@ -538,83 +538,45 @@ void ReadRestart::command(int narg, char **arg)
only called by proc 0
------------------------------------------------------------------------- */
void ReadRestart::file_search(char *inpfile, char *outfile)
std::string ReadRestart::file_search(const std::string &inpfile)
{
char *ptr;
// separate inpfile into dir + filename
char *dirname = new char[strlen(inpfile) + 1];
char *filename = new char[strlen(inpfile) + 1];
if (strchr(inpfile,'/')) {
ptr = strrchr(inpfile,'/');
*ptr = '\0';
strcpy(dirname,inpfile);
strcpy(filename,ptr+1);
*ptr = '/';
} else {
strcpy(dirname,"./");
strcpy(filename,inpfile);
}
auto dirname = utils::path_dirname(inpfile);
auto filename = utils::path_basename(inpfile);
// if filename contains "%" replace "%" with "base"
char *pattern = new char[strlen(filename) + 16];
auto pattern = filename;
auto loc = pattern.find('%');
if (loc != std::string::npos) pattern.replace(loc,1,"base");
if ((ptr = strchr(filename,'%'))) {
*ptr = '\0';
sprintf(pattern,"%s%s%s",filename,"base",ptr+1);
*ptr = '%';
} else strcpy(pattern,filename);
// scan all files in directory, searching for files that match regexp pattern
// maxnum = largest integer that matches "*"
// scan all files in directory, searching for files that match pattern
// maxnum = largest int that matches "*"
int n = strlen(pattern) + 16;
char *begin = new char[n];
char *middle = new char[n];
char *end = new char[n];
ptr = strchr(pattern,'*');
*ptr = '\0';
strcpy(begin,pattern);
strcpy(end,ptr+1);
int nbegin = strlen(begin);
bigint maxnum = -1;
loc = pattern.find('*');
if (loc != std::string::npos) {
// convert pattern to equivalent regexp
pattern.replace(loc,1,"\\d+");
struct dirent *ep;
DIR *dp = opendir(dirname.c_str());
if (dp == nullptr)
error->one(FLERR,"Cannot open directory {} to search for restart file: {}",
dirname, utils::getsyserror());
struct dirent *ep;
DIR *dp = opendir(dirname);
if (dp == nullptr)
error->one(FLERR,"Cannot open dir to search for restart file");
while ((ep = readdir(dp))) {
if (strstr(ep->d_name,begin) != ep->d_name) continue;
if ((ptr = strstr(&ep->d_name[nbegin],end)) == nullptr) continue;
if (strlen(end) == 0) ptr = ep->d_name + strlen(ep->d_name);
*ptr = '\0';
if ((int)strlen(&ep->d_name[nbegin]) < n) {
strcpy(middle,&ep->d_name[nbegin]);
if (ATOBIGINT(middle) > maxnum) maxnum = ATOBIGINT(middle);
while ((ep = readdir(dp))) {
std::string candidate(ep->d_name);
if (utils::strmatch(candidate,pattern)) {
bigint num = ATOBIGINT(utils::strfind(candidate.substr(loc),"\\d+").c_str());
if (num > maxnum) maxnum = num;
}
}
closedir(dp);
if (maxnum < 0) error->one(FLERR,"Found no restart file matching pattern");
filename.replace(filename.find('*'),1,std::to_string(maxnum));
}
closedir(dp);
if (maxnum < 0) error->one(FLERR,"Found no restart file matching pattern");
// create outfile with maxint substituted for "*"
// use original inpfile, not pattern, since need to retain "%" in filename
std::string newoutfile = inpfile;
newoutfile.replace(newoutfile.find("*"),1,fmt::format("{}",maxnum));
strcpy(outfile,newoutfile.c_str());
// clean up
delete [] dirname;
delete [] filename;
delete [] pattern;
delete [] begin;
delete [] middle;
delete [] end;
return utils::path_join(dirname,filename);
}
/* ----------------------------------------------------------------------

View File

@ -46,7 +46,7 @@ class ReadRestart : public Command {
bigint assignedChunkSize;
MPI_Offset assignedChunkOffset, headerOffset;
void file_search(char *, char *);
std::string file_search(const std::string &);
void header();
void type_arrays();
void force_fields();

View File

@ -45,7 +45,7 @@ namespace utils {
*
* \param text the text to be matched against the pattern
* \param pattern the search pattern, which may contain regexp markers
* \return the string that matches the patters or an empty one */
* \return the string that matches the pattern or an empty one */
std::string strfind(const std::string &text, const std::string &pattern);

View File

@ -94,25 +94,25 @@ class LammpsShell(unittest.TestCase):
def testExpandComputeGroup(self):
"""Test expansion of a group-ID and a compute command"""
matches = re.findall(cmd_group_re, self.InputRunner(b'compute test al\tcentro/at\t\n'), re.MULTILINE)
matches = re.findall(cmd_group_re, self.InputRunner(b'compute test al\tstress/at\t\n'), re.MULTILINE)
if self.timeout:
self.fail("Timeout")
else:
self.assertEqual(matches[0][1],"compute")
self.assertEqual(matches[0][2],"test")
self.assertEqual(matches[0][3],"all")
self.assertEqual(matches[0][4],"centro/atom")
self.assertEqual(matches[0][4],"stress/atom")
def testExpandFixGroup(self):
"""Test expansion of a group-ID and a fix command"""
matches = re.findall(cmd_group_re, self.InputRunner(b'fix test al\tcontroll\t\n'), re.MULTILINE)
matches = re.findall(cmd_group_re, self.InputRunner(b'fix test al\tpropert\t\n'), re.MULTILINE)
if self.timeout:
self.fail("Timeout")
else:
self.assertEqual(matches[0][1],"fix")
self.assertEqual(matches[0][2],"test")
self.assertEqual(matches[0][3],"all")
self.assertEqual(matches[0][4],"controller")
self.assertEqual(matches[0][4],"property/atom")
def testExpandSource(self):
"""Test expansion of a shell command and a file name"""

View File

@ -51,10 +51,10 @@ TEST(ArgInfo, compute0)
TEST(ArgInfo, compute1)
{
ArgInfo arg("c_1[5]", ArgInfo::COMPUTE);
ArgInfo arg("c_1[15]", ArgInfo::COMPUTE);
ASSERT_EQ(arg.get_dim(), 1);
ASSERT_EQ(arg.get_type(), ArgInfo::COMPUTE);
ASSERT_EQ(arg.get_index1(), 5);
ASSERT_EQ(arg.get_index1(), 15);
ASSERT_EQ(arg.get_index2(), -1);
ASSERT_THAT(arg.get_name(), StrEq("1"));
}
@ -69,6 +69,26 @@ TEST(ArgInfo, compute2)
ASSERT_THAT(arg.get_name(), StrEq("text"));
}
TEST(ArgInfo, compute3)
{
ArgInfo arg("c_text[08123][51]", ArgInfo::COMPUTE | ArgInfo::FIX);
ASSERT_EQ(arg.get_dim(), 2);
ASSERT_EQ(arg.get_type(), ArgInfo::COMPUTE);
ASSERT_EQ(arg.get_index1(), 8123);
ASSERT_EQ(arg.get_index2(), 51);
ASSERT_THAT(arg.get_name(), StrEq("text"));
}
TEST(ArgInfo, compute4)
{
ArgInfo arg("c_text[111][0125]", ArgInfo::COMPUTE | ArgInfo::FIX);
ASSERT_EQ(arg.get_dim(), 2);
ASSERT_EQ(arg.get_type(), ArgInfo::COMPUTE);
ASSERT_EQ(arg.get_index1(), 111);
ASSERT_EQ(arg.get_index2(), 125);
ASSERT_THAT(arg.get_name(), StrEq("text"));
}
TEST(ArgInfo, fix0)
{
ArgInfo arg("f_2");
@ -99,6 +119,26 @@ TEST(ArgInfo, fix2)
ASSERT_THAT(arg.get_name(), StrEq("text"));
}
TEST(ArgInfo, fix3)
{
ArgInfo arg("f_text[1234][5]", ArgInfo::FIX);
ASSERT_EQ(arg.get_dim(), 2);
ASSERT_EQ(arg.get_type(), ArgInfo::FIX);
ASSERT_EQ(arg.get_index1(), 1234);
ASSERT_EQ(arg.get_index2(), 5);
ASSERT_THAT(arg.get_name(), StrEq("text"));
}
TEST(ArgInfo, fix4)
{
ArgInfo arg("f_text[22][120]", ArgInfo::FIX);
ASSERT_EQ(arg.get_dim(), 2);
ASSERT_EQ(arg.get_type(), ArgInfo::FIX);
ASSERT_EQ(arg.get_index1(), 22);
ASSERT_EQ(arg.get_index2(), 120);
ASSERT_THAT(arg.get_name(), StrEq("text"));
}
TEST(ArgInfo, variable0)
{
ArgInfo arg("v_text");
@ -169,19 +209,25 @@ TEST(ArgInfo, unsupported3)
TEST(ArgInfo, no_bracket1)
{
ArgInfo arg("v_text[2");
ArgInfo arg("v_text[22");
ASSERT_EQ(arg.get_type(), ArgInfo::UNKNOWN);
}
TEST(ArgInfo, no_bracket2)
{
ArgInfo arg("v_text[2][1");
ArgInfo arg("v_text[123][12");
ASSERT_EQ(arg.get_type(), ArgInfo::UNKNOWN);
}
TEST(ArgInfo, no_bracket3)
{
ArgInfo arg("v_text[2[1]");
ArgInfo arg("v_text[2[11]");
ASSERT_EQ(arg.get_type(), ArgInfo::UNKNOWN);
}
TEST(ArgInfo, no_bracket4)
{
ArgInfo arg("v_text[25]021]");
ASSERT_EQ(arg.get_type(), ArgInfo::UNKNOWN);
}