diff --git a/doc/src/Developer_updating.rst b/doc/src/Developer_updating.rst index 1913a38cbd..c4831d8db7 100644 --- a/doc/src/Developer_updating.rst +++ b/doc/src/Developer_updating.rst @@ -24,6 +24,7 @@ Available topics in mostly chronological order are: - `Use of "override" instead of "virtual"`_ - `Simplified and more compact neighbor list requests`_ - `Split of fix STORE into fix STORE/GLOBAL and fix STORE/PERATOM`_ +- `Use Output::get_dump_by_id() instead of Output::find_dump()`_ ---- @@ -382,3 +383,43 @@ New: FixStoreGlobal *fix = dynamic_cast(modify->get_fix_by_id(id_fix)); This change is **required** or else the code will not compile. + +Use Output::get_dump_by_id() instead of Output::find_dump() +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. versionchanged:: TBD + +The accessor function to individual dump style instances has been changed +from ``Output::find_dump()`` returning the index of the dump instance in +the list of dumps to ``Output::get_dump_by_id()`` returning a pointer to +the dump directly. Example: + +Old: + +.. code-block:: C++ + + int idump = output->find_dump(arg[iarg+1]); + if (idump < 0) + error->all(FLERR,"Dump ID in hyper command does not exist"); + memory->grow(dumplist,ndump+1,"hyper:dumplist"); + dumplist[ndump++] = idump; + + [...] + + if (dumpflag) + for (int idump = 0; idump < ndump; idump++) + output->dump[dumplist[idump]]->write(); + +New: + +.. code-block:: C++ + + auto idump = output->get_dump_by_id(arg[iarg+1]); + if (!idump) error->all(FLERR,"Dump ID {} in hyper command does not exist", arg[iarg+1]); + dumplist.emplace_back(idump); + + [...] + + if (dumpflag) for (auto idump : dumplist) idump->write(); + +This change is **required** or else the code will not compile. diff --git a/doc/src/fix_shake.rst b/doc/src/fix_shake.rst index f0c847cb5e..f5742b8f9f 100644 --- a/doc/src/fix_shake.rst +++ b/doc/src/fix_shake.rst @@ -33,12 +33,14 @@ Syntax *m* value = one or more mass values * zero or more keyword/value pairs may be appended -* keyword = *mol* +* keyword = *mol* or *kbond* .. parsed-literal:: *mol* value = template-ID template-ID = ID of molecule template specified in a separate :doc:`molecule ` command + *kbond* value = force constant + force constant = force constant used to apply a restraint force when used during minimization Examples """""""" @@ -56,7 +58,10 @@ Description Apply bond and angle constraints to specified bonds and angles in the simulation by either the SHAKE or RATTLE algorithms. This typically -enables a longer timestep. +enables a longer timestep. The SHAKE or RATTLE algorithms, however, can +*only* be applied during molecular dynamics runs. When this fix is used +during a minimization, the constraints are *approximated* by strong +harmonic restraints. **SHAKE vs RATTLE:** @@ -90,7 +95,7 @@ The SHAKE algorithm satisfies the first condition, i.e. the sites at time *n+1* will have the desired separations Dij immediately after the coordinates are integrated. If we also enforce the second condition, the velocity components along the bonds will vanish. RATTLE satisfies -both conditions. As implemented in LAMMPS, fix rattle uses fix shake +both conditions. As implemented in LAMMPS, *fix rattle* uses fix shake for satisfying the coordinate constraints. Therefore the settings and optional keywords are the same for both fixes, and all the information below about SHAKE is also relevant for RATTLE. @@ -139,30 +144,47 @@ for. .. note:: - This command works by using the current forces on atoms to - calculate an additional constraint force which when added will leave - the atoms in positions that satisfy the SHAKE constraints (e.g. bond - length) after the next time integration step. If you define fixes - (e.g. :doc:`fix efield `) that add additional force to the - atoms after fix shake operates, then this fix will not take them into - account and the time integration will typically not satisfy the SHAKE - constraints. The solution for this is to make sure that fix shake is - defined in your input script after any other fixes which add or change - forces (to atoms that fix shake operates on). + This command works by using the current forces on atoms to calculate + an additional constraint force which when added will leave the atoms + in positions that satisfy the SHAKE constraints (e.g. bond length) + after the next time integration step. If you define fixes + (e.g. :doc:`fix efield `) that add additional force to + the atoms after *fix shake* operates, then this fix will not take them + into account and the time integration will typically not satisfy the + SHAKE constraints. The solution for this is to make sure that fix + shake is defined in your input script after any other fixes which add + or change forces (to atoms that *fix shake* operates on). ---------- -The *mol* keyword should be used when other commands, such as :doc:`fix deposit ` or :doc:`fix pour `, add molecules +The *mol* keyword should be used when other commands, such as :doc:`fix +deposit ` or :doc:`fix pour `, add molecules on-the-fly during a simulation, and you wish to constrain the new molecules via SHAKE. You specify a *template-ID* previously defined using the :doc:`molecule ` command, which reads a file that defines the molecule. You must use the same *template-ID* that the command adding molecules uses. The coordinates, atom types, special -bond restrictions, and SHAKE info can be specified in the molecule -file. See the :doc:`molecule ` command for details. The only +bond restrictions, and SHAKE info can be specified in the molecule file. +See the :doc:`molecule ` command for details. The only settings required to be in this file (by this command) are the SHAKE info of atoms in the molecule. +The *kbond* keyword sets the restraint force constant when *fix shake* +or fix rattle are used during minimization. In that case the constraint +algorithms are *not* applied and restraint forces are used instead to +maintain the geometries similar to the constraints. How well the +geometries are maintained and how quickly a minimization converges, +depends largely on the force constant *kbond*: larger values will reduce +the deviation from the desired geometry, but can also lead to slower +convergence of the minimization or lead to instabilities depending on +the minimization algorithm requiring to reduce the value of +:doc:`timestep `. Even though the restraints will not +preserve the bond lengths and angles as closely as the constraints +during the MD, they are generally close enough so that the constraints +will be fulfilled to the desired accuracy within a few MD steps +following the minimization. The default value for *kbond* depends on the +:doc:`units ` setting and is 1.0e6*k_B. + ---------- .. include:: accel_styles.rst @@ -177,10 +199,10 @@ LAMMPS closely follows (:ref:`Andersen (1983) `). .. note:: - The fix rattle command modifies forces and velocities and thus + The *fix rattle* command modifies forces and velocities and thus should be defined after all other integration fixes in your input script. If you define other fixes that modify velocities or forces - after fix rattle operates, then fix rattle will not take them into + after *fix rattle* operates, then *fix rattle* will not take them into account and the overall time integration will typically not satisfy the RATTLE constraints. You can check whether the constraints work correctly by setting the value of RATTLE_DEBUG in src/fix_rattle.cpp @@ -194,19 +216,32 @@ Restart, fix_modify, output, run start/stop, minimize info No information about these fixes is written to :doc:`binary restart files `. -The :doc:`fix_modify ` *virial* option is supported by -these fixes to add the contribution due to the added forces on atoms -to both the global pressure and per-atom stress of the system via the -:doc:`compute pressure ` and :doc:`compute -stress/atom ` commands. The former can be -accessed by :doc:`thermodynamic output `. The default -setting for this fix is :doc:`fix_modify virial yes `. +Both fix *shake* and fix *rattle* behave differently during a minimization +in comparison to a molecular dynamics run: + +- When used during a minimization, the SHAKE or RATTLE constraint + algorithms themselves are **not** applied. Instead the constraints + are replaced by harmonic restraint forces. The energy and virial + contributions due to the restraint forces are tallied into global and + per-atom accumulators. The total restraint energy is also accessible + as a global scalar property of the fix. + +- During molecular dynamics runs, however, the fixes do apply the + requested SHAKE or RATTLE constraint algorithms. + + The :doc:`fix_modify ` *virial* option is supported by + these fixes to add the contribution due to the added constraint forces + on atoms to both the global pressure and per-atom stress of the system + via the :doc:`compute pressure ` and :doc:`compute + stress/atom ` commands. The former can be + accessed by :doc:`thermodynamic output `. + + The default setting for this fix is :doc:`fix_modify virial yes + `. No global or per-atom quantities are stored by these + fixes for access by various :doc:`output commands ` during + an MD run. No parameter of these fixes can be used with the + *start/stop* keywords of the :doc:`run ` command. -No global or per-atom quantities are stored by these fixes for access -by various :doc:`output commands `. No parameter of -these fixes can be used with the *start/stop* keywords of the -:doc:`run ` command. These fixes are not invoked during -:doc:`energy minimization `. Restrictions """""""""""" @@ -224,21 +259,27 @@ which can lead to poor energy conservation. You can test for this in your system by running a constant NVE simulation with a particular set of SHAKE parameters and monitoring the energy versus time. -SHAKE or RATTLE should not be used to constrain an angle at 180 -degrees (e.g. linear CO2 molecule). This causes numeric difficulties. -You can use :doc:`fix rigid or fix rigid/small ` instead to -make a linear molecule rigid. +SHAKE or RATTLE should not be used to constrain an angle at 180 degrees +(e.g. a linear CO2 molecule). This causes a divergence when solving the +constraint equations numerically. You can use :doc:`fix rigid or fix +rigid/small ` instead to make a linear molecule rigid. + +When used during minimization choosing a too large value of the *kbond* +can make minimization very inefficient and also cause stability problems +with some minimization algorithms. Sometimes those can be avoided by +reducing the :doc:`timestep `. Related commands """""""""""""""" -none +`fix rigid `, `fix ehex `, +`fix nve/manifold/rattle ` Default """"""" -none +kbond = 1.0e9*k_B ---------- diff --git a/doc/src/minimize.rst b/doc/src/minimize.rst index 14bc4d0d21..5143cab5d5 100644 --- a/doc/src/minimize.rst +++ b/doc/src/minimize.rst @@ -32,30 +32,51 @@ Description Perform an energy minimization of the system, by iteratively adjusting atom coordinates. Iterations are terminated when one of the stopping criteria is satisfied. At that point the configuration will hopefully -be in local potential energy minimum. More precisely, the +be in a local potential energy minimum. More precisely, the configuration should approximate a critical point for the objective function (see below), which may or may not be a local minimum. -The minimization algorithm used is set by the -:doc:`min_style ` command. Other options are set by the -:doc:`min_modify ` command. Minimize commands can be -interspersed with :doc:`run ` commands to alternate between -relaxation and dynamics. The minimizers bound the distance atoms move -in one iteration, so that you can relax systems with highly overlapped -atoms (large energies and forces) by pushing the atoms off of each -other. +The minimization algorithm used is set by the :doc:`min_style +` command. Other options are set by the :doc:`min_modify +` command. Minimize commands can be interspersed with +:doc:`run ` commands to alternate between relaxation and dynamics. +The minimizers bound the distance atoms may move in one iteration, so +that you can relax systems with highly overlapped atoms (large energies +and forces) by pushing the atoms off of each other. -Alternate means of relaxing a system are to run dynamics with a small -or :doc:`limited timestep `. Or dynamics can be run -using :doc:`fix viscous ` to impose a damping force that -slowly drains all kinetic energy from the system. The :doc:`pair_style soft ` potential can be used to un-overlap atoms while -running dynamics. -un-overlap atoms while running dynamics. +.. admonition:: Neighbor list update settings + :class: note + + The distance that atoms can move during individual minimization steps + can be quite large, especially at the beginning of a minimization. + Thus `neighbor list settings ` of *every = 1* and + *delay = 0* are **required**. This may be combined with either + *check = no* (always update the neighbor list) or *check = yes* (only + update the neighbor list if at least one atom has moved more than + half the `neighbor list skin ` distance since the last + reneighboring). Using *check = yes* is recommended since it avoids + unneeded reneighboring steps when the system is closer to the minimum + and thus atoms move only small distances. Using *check = no* may + be required for debugging or when coupling LAMMPS with external + codes that require a predictable sequence of neighbor list updates. + + If the settings are **not** *every = 1* and *delay = 0*, LAMMPS + will temporarily apply a `neigh_modify every 1 delay 0 check yes + ` setting during the minimization and restore the + original setting at the end of the minimization. A corresponding + message will be printed to the screen and log file, if this happens. + +Alternate means of relaxing a system are to run dynamics with a small or +:doc:`limited timestep `. Or dynamics can be run using +:doc:`fix viscous ` to impose a damping force that slowly +drains all kinetic energy from the system. The :doc:`pair_style soft +` potential can be used to un-overlap atoms while running +dynamics. Note that you can minimize some atoms in the system while holding the -coordinates of other atoms fixed by applying :doc:`fix setforce -` to the other atoms. See a fuller discussion of using -fixes while minimizing below. +coordinates of other atoms fixed by applying :doc:`fix setforce 0.0 0.0 +0.0 ` to the other atoms. See a more detailed discussion +of :ref:`using fixes while minimizing below `. The :doc:`minimization styles ` *cg*, *sd*, and *hftn* involves an outer iteration loop which sets the search direction along @@ -74,10 +95,11 @@ they require a :doc:`timestep ` be defined. .. note:: - The damped dynamic minimizers use whatever timestep you have - defined via the :doc:`timestep ` command. Often they - will converge more quickly if you use a timestep about 10x larger - than you would normally use for dynamics simulations. + The damped dynamic minimizer algorithms will use the timestep you + have defined via the :doc:`timestep ` command or its + default value. Often they will converge more quickly if you use a + timestep about 10x larger than you would normally use for regular + molecular dynamics simulations. ---------- @@ -210,34 +232,42 @@ The iterations and force evaluation values are what is checked by the .. note:: - There are several force fields in LAMMPS which have - discontinuities or other approximations which may prevent you from - performing an energy minimization to high tolerances. For example, - you should use a :doc:`pair style ` that goes to 0.0 at the - cutoff distance when performing minimization (even if you later change - it when running dynamics). If you do not do this, the total energy of + There are several force fields in LAMMPS which have discontinuities + or other approximations which may prevent you from performing an + energy minimization to tight tolerances. For example, you should use + a :doc:`pair style ` that goes to 0.0 at the cutoff + distance when performing minimization (even if you later change it + when running dynamics). If you do not do this, the total energy of the system will have discontinuities when the relative distance - between any pair of atoms changes from cutoff+epsilon to - cutoff-epsilon and the minimizer may behave poorly. Some of the - many-body potentials use splines and other internal cutoffs that - inherently have this problem. The :doc:`long-range Coulombic styles ` (PPPM, Ewald) are approximate to within the - user-specified tolerance, which means their energy and forces may not - agree to a higher precision than the Kspace-specified tolerance. In - all these cases, the minimizer may give up and stop before finding a - minimum to the specified energy or force tolerance. + between any pair of atoms changes from cutoff *plus* epsilon to + cutoff *minus* epsilon and the minimizer may thus behave poorly. + Some of the many-body potentials use splines and other internal + cutoffs that inherently have this problem. The :doc:`long-range + Coulombic styles ` (PPPM, Ewald) are approximate to + within the user-specified tolerance, which means their energy and + forces may not agree to a higher precision than the Kspace-specified + tolerance. This agreement is further reduced when using tabulation + to speed up the computation of the real-space part of the Coulomb + interactions, which is enabled by default. In all these cases, the + minimizer may give up and stop before finding a minimum to the + specified energy or force tolerance. Note that a cutoff Lennard-Jones potential (and others) can be shifted -so that its energy is 0.0 at the cutoff via the -:doc:`pair_modify ` command. See the doc pages for -individual :doc:`pair styles ` for details. Note that -Coulombic potentials always have a cutoff, unless versions with a -long-range component are used (e.g. :doc:`pair_style lj/cut/coul/long `). The CHARMM potentials go to 0.0 at -the cutoff (e.g. :doc:`pair_style lj/charmm/coul/charmm `), -as do the GROMACS potentials (e.g. :doc:`pair_style lj/gromacs `). +so that its energy is 0.0 at the cutoff via the :doc:`pair_modify +` command. See the doc pages for individual :doc:`pair +styles ` for details. Note that most Coulombic potentials +have a cutoff, unless versions with a long-range component are used +(e.g. :doc:`pair_style lj/cut/coul/long `) or some +other damping/smoothing schemes are used. The CHARMM potentials go to +0.0 at the cutoff (e.g. :doc:`pair_style lj/charmm/coul/charmm +`), as do the GROMACS potentials (e.g. :doc:`pair_style +lj/gromacs `). If a soft potential (:doc:`pair_style soft `) is used the Astop value is used for the prefactor (no time dependence). +.. _fix_minimize: + The :doc:`fix box/relax ` command can be used to apply an external pressure to the simulation box and allow it to shrink/expand during the minimization. diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 56fd7a1305..a324f41941 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -13,6 +13,7 @@ Accelrys acceptor Acceptor acceptors +accessor accomx accomy accomz @@ -1623,6 +1624,7 @@ kb kB kbit kbits +kbond kcal kcl Kd diff --git a/src/AMOEBA/amoeba_induce.cpp b/src/AMOEBA/amoeba_induce.cpp index 7434c57e27..ae801e5a62 100644 --- a/src/AMOEBA/amoeba_induce.cpp +++ b/src/AMOEBA/amoeba_induce.cpp @@ -53,8 +53,7 @@ enum{GORDON1,GORDON2}; void PairAmoeba::induce() { bool done; - int i,j,m,itype; - int iter,maxiter; + int i,j,m,itype,iter; double polmin; double eps,epsold; double epsd,epsp; @@ -159,7 +158,6 @@ void PairAmoeba::induce() if (poltyp == MUTUAL) { done = false; - maxiter = 100; iter = 0; polmin = 0.00000001; eps = 100.0; diff --git a/src/ASPHERE/pair_gayberne.cpp b/src/ASPHERE/pair_gayberne.cpp index 04fa5330f9..71b8a82cc7 100644 --- a/src/ASPHERE/pair_gayberne.cpp +++ b/src/ASPHERE/pair_gayberne.cpp @@ -34,13 +34,14 @@ using namespace LAMMPS_NS; static const char cite_pair_gayberne[] = - "pair gayberne command:\n\n" + "pair gayberne command: doi:10.1063/1.3058435\n\n" "@Article{Brown09,\n" - " author = {W. M. Brown, M. K. Petersen, S. J. Plimpton, and G. S. Grest},\n" - " title = {Liquid crystal nanodroplets in solution},\n" - " journal = {J.~Chem.~Phys.},\n" + " author = {W. M. Brown and M. K. Petersen and S. J. Plimpton and G. S. Grest},\n" + " title = {Liquid Crystal Nanodroplets in Solution},\n" + " journal = {J.~Chem.\\ Phys.},\n" " year = 2009,\n" " volume = 130,\n" + " number = 4,\n" " pages = {044901}\n" "}\n\n"; diff --git a/src/BOCS/fix_bocs.cpp b/src/BOCS/fix_bocs.cpp index 3083286be8..449deefd59 100644 --- a/src/BOCS/fix_bocs.cpp +++ b/src/BOCS/fix_bocs.cpp @@ -42,13 +42,15 @@ using namespace LAMMPS_NS; using namespace FixConst; static const char cite_user_bocs_package[] = - "BOCS package:\n\n" + "BOCS package: doi:10.1021/acs.jpcb.7b09993\n\n" "@Article{Dunn2018,\n" - " author = {NJH Dunn, KM Lebold, MR DeLyser, JF Rudzinski, WG Noid},\n" - " title = {BOCS: Bottom-Up Open-Source Coarse-Graining Software},\n" - " journal = {J. Phys. Chem. B},\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"; diff --git a/src/DIELECTRIC/atom_vec_dielectric.cpp b/src/DIELECTRIC/atom_vec_dielectric.cpp index 67bb9f7dc3..f1126d8d7a 100644 --- a/src/DIELECTRIC/atom_vec_dielectric.cpp +++ b/src/DIELECTRIC/atom_vec_dielectric.cpp @@ -21,13 +21,13 @@ using namespace LAMMPS_NS; static const char cite_user_dielectric_package[] = - "DIELECTRIC package:\n\n" + "DIELECTRIC package: doi:10.1016/j.cpc.2019.03.006\n\n" "@Article{TrungCPC19,\n" - " author = {Trung Dac Nguyen, Honghao Li, Debarshee Bagchi," - " Francisco J. Solis, Monica Olvera de la Cruz,\n" - " title = {Incorporating surface polarization effects into large-scale" - " coarse-grained Molecular Dynamics simulation},\n" - " journal = {Comp.~Phys.~Comm.},\n" + " author = {Trung Dac Nguyen and Honghao Li and Debarshee Bagchi and" + " Francisco J. Solis and Olvera de la Cruz, Monica}\n" + " title = {Incorporating Surface Polarization Effects Into Large-Scale\n" + " Coarse-Grained Molecular Dynamics Simulation},\n" + " journal = {Comput.\\ Phys.\\ Commun.},\n" " year = 2019,\n" " volume = 241,\n" " pages = {80--91}\n" diff --git a/src/DIFFRACTION/compute_saed.cpp b/src/DIFFRACTION/compute_saed.cpp index e21570d76d..ba16b65352 100644 --- a/src/DIFFRACTION/compute_saed.cpp +++ b/src/DIFFRACTION/compute_saed.cpp @@ -37,10 +37,10 @@ using namespace LAMMPS_NS; using namespace MathConst; static const char cite_compute_saed_c[] = - "compute_saed command: doi:10.1088/0965-0393/21/5/055020\n\n" + "compute saed command: doi:10.1088/0965-0393/21/5/055020\n\n" "@Article{Coleman13,\n" - " author = {S. P. Coleman, D. E. Spearot, L. Capolungo},\n" - " title = {Virtual diffraction analysis of Ni [010] symmetric tilt grain boundaries},\n" + " author = {S. P. Coleman and D. E. Spearot and L. Capolungo},\n" + " title = {Virtual Diffraction Analysis of {Ni} [010] Symmetric Tilt Grain Boundaries},\n" " journal = {Modelling and Simulation in Materials Science and Engineering},\n" " year = 2013,\n" " volume = 21,\n" diff --git a/src/DIFFRACTION/compute_xrd.cpp b/src/DIFFRACTION/compute_xrd.cpp index aef4d932a9..153f8fddb5 100644 --- a/src/DIFFRACTION/compute_xrd.cpp +++ b/src/DIFFRACTION/compute_xrd.cpp @@ -38,10 +38,10 @@ using namespace LAMMPS_NS; using namespace MathConst; static const char cite_compute_xrd_c[] = - "compute_xrd command: doi:10.1088/0965-0393/21/5/055020\n\n" + "compute xrd command: doi:10.1088/0965-0393/21/5/055020\n\n" "@Article{Coleman13,\n" - " author = {S. P. Coleman, D. E. Spearot, L. Capolungo},\n" - " title = {Virtual diffraction analysis of Ni [010] symmetric tilt grain boundaries},\n" + " author = {S. P. Coleman and D. E. Spearot and L. Capolungo},\n" + " title = {Virtual Diffraction Analysis of {Ni} [010] Symmetric Tilt Grain Boundaries},\n" " journal = {Modelling and Simulation in Materials Science and Engineering},\n" " year = 2013,\n" " volume = 21,\n" diff --git a/src/DPD-MESO/pair_edpd.cpp b/src/DPD-MESO/pair_edpd.cpp index b05f588b7c..13cbed2ece 100644 --- a/src/DPD-MESO/pair_edpd.cpp +++ b/src/DPD-MESO/pair_edpd.cpp @@ -41,18 +41,18 @@ using namespace LAMMPS_NS; #define EPSILON 1.0e-10 static const char cite_pair_edpd[] = - "pair edpd command:\n\n" + "pair edpd command: doi:10.1016/j.jcp.2014.02.003\n\n" "@Article{ZLi2014_JCP,\n" - " author = {Li, Z. and Tang, Y.-H. and Lei, H. and Caswell, B. and Karniadakis, G.E.},\n" - " title = {Energy-conserving dissipative particle dynamics with temperature-dependent properties},\n" + " author = {Li, Z. and Tang, Y.-H. and Lei, H. and Caswell, B. and Karniadakis, G. E.},\n" + " title = {Energy-Conserving Dissipative Particle Dynamics with Temperature-Dependent Properties},\n" " journal = {Journal of Computational Physics},\n" " year = {2014},\n" " volume = {265},\n" " pages = {113--127}\n" "}\n\n" "@Article{ZLi2015_CC,\n" - " author = {Li, Z. and Tang, Y.-H. and Li, X. and Karniadakis, G.E.},\n" - " title = {Mesoscale modeling of phase transition dynamics of thermoresponsive polymers},\n" + " author = {Li, Z. and Tang, Y.-H. and Li, X. and Karniadakis, G. E.},\n" + " title = {Mesoscale Modeling of Phase Transition Dynamics of Thermoresponsive Polymers},\n" " journal = {Chemical Communications},\n" " year = {2015},\n" " volume = {51},\n" diff --git a/src/DPD-MESO/pair_mdpd.cpp b/src/DPD-MESO/pair_mdpd.cpp index ec0a57be15..c08ac2dde3 100644 --- a/src/DPD-MESO/pair_mdpd.cpp +++ b/src/DPD-MESO/pair_mdpd.cpp @@ -37,13 +37,14 @@ using namespace LAMMPS_NS; #define EPSILON 1.0e-10 static const char cite_pair_mdpd[] = - "pair mdpd command:\n\n" + "pair mdpd command: doi:10.1063/1.4812366\n\n" "@Article{ZLi2013_POF,\n" - " author = {Li, Z. and Hu, G.H. and Wang, Z.L. and Ma Y.B. and Zhou, Z.W.},\n" - " title = {Three dimensional flow structures in a moving droplet on substrate: a dissipative particle dynamics study},\n" + " author = {Li, Z. and Hu, G. H. and Wang, Z. L. and Ma Y. B. and Zhou, Z. W.},\n" + " title = {Three Dimensional Flow Structures in a Moving Droplet on Substrate: a Dissipative Particle Dynamics Study},\n" " journal = {Physics of Fluids},\n" " year = {2013},\n" " volume = {25},\n" + " number = {7},\n" " pages = {072103}\n" "}\n\n"; diff --git a/src/DPD-MESO/pair_tdpd.cpp b/src/DPD-MESO/pair_tdpd.cpp index 39d9a151d9..6efe3f4546 100644 --- a/src/DPD-MESO/pair_tdpd.cpp +++ b/src/DPD-MESO/pair_tdpd.cpp @@ -40,13 +40,14 @@ using namespace LAMMPS_NS; #define EPSILON 1.0e-10 static const char cite_pair_tdpd[] = - "pair tdpd command:\n\n" + "pair tdpd command: doi:10.1063/1.4923254\n\n" "@Article{ZLi2015_JCP,\n" - " author = {Li, Z. and Yazdani, A. and Tartakovsky, A. and Karniadakis, G.E.},\n" - " title = {Transport dissipative particle dynamics model for mesoscopic advection-diffusion-reaction problems},\n" + " author = {Li, Z. and Yazdani, A. and Tartakovsky, A. and Karniadakis, G. E.},\n" + " title = {Transport Dissipative Particle Dynamics Model for Mesoscopic Advection-Diffusion-Reaction Problems},\n" " journal = {The Journal of Chemical Physics},\n" " year = {2015},\n" " volume = {143},\n" + " number = {1},\n" " pages = {014101}\n" "}\n\n"; diff --git a/src/DPD-REACT/fix_shardlow.cpp b/src/DPD-REACT/fix_shardlow.cpp index 7ab8c6f857..41239c9058 100644 --- a/src/DPD-REACT/fix_shardlow.cpp +++ b/src/DPD-REACT/fix_shardlow.cpp @@ -63,21 +63,22 @@ using namespace random_external_state; #define EPSILON_SQUARED ((EPSILON) * (EPSILON)) static const char cite_fix_shardlow[] = - "fix shardlow command:\n\n" + "fix shardlow command: doi:10.1016/j.cpc.2014.03.029, doi:10.1063/1.3660209\n\n" "@Article{Larentzos14,\n" - " author = {J. P. Larentzos, J. K. Brennan, J. D. Moore, M. Lisal, W. D. Mattson},\n" - " title = {Parallel implementation of isothermal and isoenergetic Dissipative Particle Dynamics using Shardlow-like splitting algorithms},\n" - " journal = {Computer Physics Communications},\n" + " author = {J. P. Larentzos and J. K. Brennan and J. D. Moore and M. Lisal and W. D. Mattson},\n" + " title = {Parallel Implementation of Isothermal and Isoenergetic Dissipative Particle Dynamics Using {S}hardlow-Like Splitting Algorithms},\n" + " journal = {Comput.\\ Phys.\\ Commun.},\n" " year = 2014,\n" " volume = 185\n" " pages = {1987--1998}\n" "}\n\n" "@Article{Lisal11,\n" - " author = {M. Lisal, J. K. Brennan, J. Bonet Avalos},\n" - " title = {Dissipative particle dynamics at isothermal, isobaric, isoenergetic, and isoenthalpic conditions using Shardlow-like splitting algorithms},\n" - " journal = {Journal of Chemical Physics},\n" + " author = {M. Lisal and J. K. Brennan and J. Bonet Avalos},\n" + " title = {Dissipative Particle Dynamics at Isothermal, Isobaric, Isoenergetic, and Isoenthalpic Conditions Using {S}hardlow-Like Splitting Algorithms},\n" + " journal = {J.~Chem.\\ Phys.},\n" " year = 2011,\n" - " volume = 135\n" + " volume = 135,\n" + " number = 20,\n" " pages = {204105}\n" "}\n\n"; diff --git a/src/DPD-REACT/pair_multi_lucy.cpp b/src/DPD-REACT/pair_multi_lucy.cpp index 009ebfc21f..bb6792da74 100644 --- a/src/DPD-REACT/pair_multi_lucy.cpp +++ b/src/DPD-REACT/pair_multi_lucy.cpp @@ -44,13 +44,14 @@ enum{NONE,RLINEAR,RSQ}; #define MAXLINE 1024 static const char cite_pair_multi_lucy[] = - "pair_style multi/lucy command:\n\n" + "pair_style multi/lucy command: doi:10.1063/1.4942520\n\n" "@Article{Moore16,\n" - " author = {J.D. Moore, B.C. Barnes, S. Izvekov, M. Lisal, M.S. Sellers, D.E. Taylor and J. K. Brennan},\n" - " title = {A coarse-grain force field for RDX: Density dependent and energy conserving},\n" - " journal = {J. Chem. Phys.},\n" + " author = {J. D. Moore and B. C. Barnes and S. Izvekov and M. Lisal and M. S. Sellers and D. E. Taylor and J. K. Brennan},\n" + " title = {A Coarse-Grain Force Field for {RDX}: Density Dependent and Energy Conserving},\n" + " journal = {J.~Chem.\\ Phys.},\n" " year = 2016,\n" " volume = 144\n" + " number = 10,\n" " pages = {104501}\n" "}\n\n"; diff --git a/src/DPD-REACT/pair_multi_lucy_rx.cpp b/src/DPD-REACT/pair_multi_lucy_rx.cpp index bd508707dd..c2a3f1a55e 100644 --- a/src/DPD-REACT/pair_multi_lucy_rx.cpp +++ b/src/DPD-REACT/pair_multi_lucy_rx.cpp @@ -55,11 +55,11 @@ enum{NONE,RLINEAR,RSQ}; #define isOneFluid(_site) ( (_site) == oneFluidParameter ) static const char cite_pair_multi_lucy_rx[] = - "pair_style multi/lucy/rx command:\n\n" + "pair_style multi/lucy/rx command: doi:10.1063/1.4942520\n\n" "@Article{Moore16,\n" - " author = {J.D. Moore, B.C. Barnes, S. Izvekov, M. Lisal, M.S. Sellers, D.E. Taylor and J. K. Brennan},\n" - " title = {A coarse-grain force field for RDX: Density dependent and energy conserving},\n" - " journal = {J. Chem. Phys.},\n" + " author = {J. D. Moore and B. C. Barnes and S. Izvekov and M. Lisal and M. S. Sellers and D. E. Taylor and J. K. Brennan},\n" + " title = {A Coarse-Grain Force Field for {RDX}: {D}ensity Dependent and Energy Conserving},\n" + " journal = {J.~Chem.\\ Phys.},\n" " year = 2016,\n" " volume = 144\n" " pages = {104501}\n" diff --git a/src/EFF/atom_vec_electron.cpp b/src/EFF/atom_vec_electron.cpp index 1f9d1f3e65..5d600b5037 100644 --- a/src/EFF/atom_vec_electron.cpp +++ b/src/EFF/atom_vec_electron.cpp @@ -23,14 +23,15 @@ using namespace LAMMPS_NS; static const char cite_user_eff_package[] = - "EFF package:\n\n" + "EFF package: doi:10.1002/jcc.21637\n\n" "@Article{Jaramillo-Botero11,\n" - " author = {A. Jaramillo-Botero, J. Su, A. Qi, W. A. Goddard III},\n" + " author = {A. Jaramillo-Botero and J. Su and A. Qi and Goddard, III, W. A.},\n" " title = {Large-Scale, Long-Term Nonadiabatic Electron Molecular Dynamics for Describing " "Material Properties and Phenomena in Extreme Environments},\n" - " journal = {J.~Comp.~Chem.},\n" + " journal = {J.~Comp.\\ Chem.},\n" " year = 2011,\n" " volume = 32,\n" + " number = 3,\n" " pages = {497--512}\n" "}\n\n"; diff --git a/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp b/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp index 2dde2397db..1e942627bb 100644 --- a/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp @@ -37,10 +37,10 @@ using namespace LAMMPS_NS; ------------------------------------------------------------------------------------*/ static const char cite_compute_stress_cartesian[] = - "compute stress/cartesian:\n\n" + "compute stress/cartesian: doi:10.3390/nano11010165\n\n" "@article{galteland2021nanothermodynamic,\n" - "title={Nanothermodynamic description and molecular simulation of a single-phase fluid in a " - "slit pore},\n" + "title={Nanothermodynamic Description and Molecular Simulation of a\n" + " Single-Phase Fluid in a Slit Pore},\n" "author={Galteland, Olav and Bedeaux, Dick and Kjelstrup, Signe},\n" "journal={Nanomaterials},\n" "volume={11},\n" diff --git a/src/EXTRA-COMPUTE/compute_stress_cylinder.cpp b/src/EXTRA-COMPUTE/compute_stress_cylinder.cpp index e4c246b469..6304744ba1 100644 --- a/src/EXTRA-COMPUTE/compute_stress_cylinder.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_cylinder.cpp @@ -43,13 +43,14 @@ using MathSpecial::square; ------------------------------------------------------------------------------------*/ static const char cite_compute_stress_cylinder[] = - "compute stress/cylinder:\n\n" + "compute stress/cylinder: doi:10.1063/1.5037054\n\n" "@Article{Addington,\n" - " author = {C. K. Addington, Y. Long, K. E. Gubbins},\n" - " title = {The pressure in interfaces having cylindrical geometry},\n" - " journal = {J.~Chem.~Phys.},\n" + " author = {C. K. Addington and Y. Long and K. E. Gubbins},\n" + " title = {The Pressure in Interfaces Having Cylindrical Geometry},\n" + " journal = {J.~Chem.\\ Phys.},\n" " year = 2018,\n" " volume = 149,\n" + " number = 8,\n" " pages = {084109}\n" "}\n\n"; diff --git a/src/EXTRA-COMPUTE/compute_stress_spherical.cpp b/src/EXTRA-COMPUTE/compute_stress_spherical.cpp index 18165513f9..c893d21f51 100644 --- a/src/EXTRA-COMPUTE/compute_stress_spherical.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_spherical.cpp @@ -46,11 +46,11 @@ using MathSpecial::square; ------------------------------------------------------------------------------------*/ static const char cite_compute_stress_sphere[] = - "compute stress/spherical:\n\n" + "compute stress/spherical: doi:10.48550/arXiv.2201.13060\n\n" "@article{galteland2022defining,\n" - "title={Defining the pressures of a fluid in a nanoporous, heterogeneous medium},\n" + "title={Defining the Pressures of a Fluid in a Nanoporous, Heterogeneous Medium},\n" "author={Galteland, Olav and Rauter, Michael T and Varughese, Kevin K and Bedeaux, Dick and " - "Kjelstrup, Signe},\n" + " Kjelstrup, Signe},\n" "journal={arXiv preprint arXiv:2201.13060},\n" "year={2022}\n" "}\n\n"; diff --git a/src/EXTRA-FIX/fix_ave_correlate_long.cpp b/src/EXTRA-FIX/fix_ave_correlate_long.cpp index c51ff7f3bd..9ed8a1e466 100644 --- a/src/EXTRA-FIX/fix_ave_correlate_long.cpp +++ b/src/EXTRA-FIX/fix_ave_correlate_long.cpp @@ -43,13 +43,14 @@ using namespace FixConst; enum{AUTO,UPPER,LOWER,AUTOUPPER,AUTOLOWER,FULL}; static const char cite_fix_ave_correlate_long[] = -"fix ave/correlate/long command:\n\n" +"fix ave/correlate/long command: doi:10.1063/1.3491098\n\n" "@Article{Ramirez10,\n" " author = {Jorge Rami{\'}rez and Sathish K. Sukumaran and Bart Vorselaars and Alexei E. Likhtman},\n" -" title = {Efficient on the fly calculation of time correlation functions in computer simulations}," -" journal = {J.~Chem.~Phys.},\n" +" title = {Efficient on the Fly Calculation of Time Correlation Functions in Computer Simulations}," +" journal = {J.~Chem.\\ Phys.},\n" " year = 2010,\n" " volume = 133,\n" +" number = 15,\n" " pages = {154103}\n" "}\n\n"; diff --git a/src/EXTRA-FIX/fix_electron_stopping_fit.cpp b/src/EXTRA-FIX/fix_electron_stopping_fit.cpp index 0e0ccc0ebb..aa3e7fc867 100644 --- a/src/EXTRA-FIX/fix_electron_stopping_fit.cpp +++ b/src/EXTRA-FIX/fix_electron_stopping_fit.cpp @@ -35,24 +35,24 @@ using namespace FixConst; // --------------------------------------------------------------------- static const char cite_fix_electron_stopping_fit_c[] = - "fix electron/stopping/fit command:\n\n" + "fix electron/stopping/fit command: doi:10.1063/1.5022471, doi:10.1103/PhysRevB.102.024107\n\n" "@Article{Stewart2018,\n" - " author = { J.A. Stewart and G. Brookman and P. Price and M. Franco and W. Ji and K. Hattar and R. Dingreville },\n" - " title = { Characterizing single isolated radiation-damage events from molecular dynamics via virtual diffraction methods },\n" - " journal = { Journal of Applied Physics },\n" - " year = { 2018 },\n" - " volume = { 123 },\n" - " number = { 16 },\n" - " pages = { 165902 }\n" + " author = {J. A. Stewart and G. Brookman and P. Price and M. Franco and W. Ji and K. Hattar and R. Dingreville},\n" + " title = {Characterizing Single Isolated Radiation-Damage Events from Molecular Dynamics via Virtual Diffraction Methods},\n" + " journal = {Journal of Applied Physics},\n" + " year = {2018},\n" + " volume = {123},\n" + " number = {16},\n" + " pages = {165902}\n" "}\n\n" "@Article{Lee2020,\n" - " author = { C.W. Lee and J.A. Stewart and S.M. Foiles and R. Dingreville and A. Schleife },\n" - " title = { Multiscale simulations of electron and ion dynamics in self-irradiated silicon },\n" - " journal = { Physical Review B },\n" - " year = { 2020 },\n" - " volume = { 102 },\n" - " number = { 2 },\n" - " pages = { 024107 }\n" + " author = {C. W. Lee and J. A. Stewart and S. M. Foiles and R. Dingreville and A. Schleife },\n" + " title = {Multiscale Simulations of Electron and Ion Dynamics in Self-Irradiated Silicon},\n" + " journal = {Physical Review~B},\n" + " year = {2020},\n" + " volume = {102},\n" + " number = {2},\n" + " pages = {024107}\n" "}\n\n"; // --------------------------------------------------------------------- diff --git a/src/EXTRA-FIX/fix_filter_corotate.cpp b/src/EXTRA-FIX/fix_filter_corotate.cpp index e2bd982617..06eefd9ebd 100644 --- a/src/EXTRA-FIX/fix_filter_corotate.cpp +++ b/src/EXTRA-FIX/fix_filter_corotate.cpp @@ -46,14 +46,14 @@ using namespace FixConst; #define MASSDELTA 0.1 static const char cite_filter_corotate[] = - "Mollified Impulse Method with Corotational Filter:\n\n" + "Mollified Impulse Method with Corotational Filter: doi:10.1016/j.jcp.2016.12.024\n\n" "@Article{Fath2017,\n" " Title =" - "{A fast mollified impulse method for biomolecular atomistic simulations},\n" - " Author = {L. Fath and M. Hochbruck and C.V. Singh},\n" + "{A Fast Mollified Impulse Method for Biomolecular Atomistic Simulations},\n" + " Author = {L. Fath and M. Hochbruck and C. V. Singh},\n" " Journal = {Journal of Computational Physics},\n" " Year = {2017},\n" - " Pages = {180 - 198},\n" + " Pages = {180--198},\n" " Volume = {333},\n\n" " Doi = {https://doi.org/10.1016/j.jcp.2016.12.024},\n" " ISSN = {0021-9991},\n" diff --git a/src/EXTRA-FIX/fix_flow_gauss.cpp b/src/EXTRA-FIX/fix_flow_gauss.cpp index a1238ea748..8b9d9dca8f 100644 --- a/src/EXTRA-FIX/fix_flow_gauss.cpp +++ b/src/EXTRA-FIX/fix_flow_gauss.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; using namespace FixConst; static const char cite_flow_gauss[] = - "Gaussian dynamics package:\n\n" + "Gaussian dynamics package: doi:10.1021/acs.jpcb.6b09387\n\n" "@Article{strong_water_2017,\n" "title = {The Dynamics of Water in Porous Two-Dimensional Crystals},\n" "volume = {121},\n" @@ -41,7 +41,7 @@ static const char cite_flow_gauss[] = "url = {https://doi.org/10.1021/acs.jpcb.6b09387},\n" "doi = {10.1021/acs.jpcb.6b09387},\n" "urldate = {2016-12-07},\n" - "journal = {J. Phys. Chem. B},\n" + "journal = {J.~Phys.\\ Chem.~B},\n" "author = {Strong, Steven E. and Eaves, Joel D.},\n" "year = {2017},\n" "pages = {189--207}\n" diff --git a/src/EXTRA-FIX/fix_pafi.cpp b/src/EXTRA-FIX/fix_pafi.cpp index d6ee4627c9..1326dcc44a 100644 --- a/src/EXTRA-FIX/fix_pafi.cpp +++ b/src/EXTRA-FIX/fix_pafi.cpp @@ -40,11 +40,11 @@ using namespace LAMMPS_NS; static const char cite_fix_pafi_package[] = - "citation for fix pafi:\n\n" + "citation for fix pafi: doi:10.1103/PhysRevLett.120.135503\n\n" "@article{SwinburneMarinica2018,\n" "author={T. D. Swinburne and M. C. Marinica},\n" - "title={Unsupervised calculation of free energy barriers in large " - "crystalline systems},\n" + "title={Unsupervised Calculation of Free Energy Barriers in Large\n" + " Crystalline Systems},\n" "journal={Physical Review Letters},\n" "volume={120},\n" "number={13},\n" diff --git a/src/EXTRA-FIX/fix_rhok.cpp b/src/EXTRA-FIX/fix_rhok.cpp index 9bdf940a7b..077dad7f25 100644 --- a/src/EXTRA-FIX/fix_rhok.cpp +++ b/src/EXTRA-FIX/fix_rhok.cpp @@ -31,15 +31,15 @@ using namespace FixConst; using namespace MathConst; static const char cite_fix_rhok[] = - "Bias on the collective density field (fix rhok):\n\n" + "Bias on the collective density field (fix rhok): doi:10.1063/1.4818747\n\n" "@Article{pedersen_jcp139_104102_2013,\n" - "title = {Direct calculation of the solid-liquid Gibbs free energy difference in a single equilibrium simulation},\n" + "title = {Direct Calculation of the Solid-Liquid {G}ibbs Free Energy Difference in a Single Equilibrium Simulation},\n" "volume = {139},\n" "number = {10},\n" "url = {https://aip.scitation.org/doi/10.1063/1.4818747},\n" "doi = {10.1063/1.4818747},\n" "urldate = {2017-10-03},\n" - "journal = {J. Chem. Phys.},\n" + "journal = {J.~Chem.\\ Phys.},\n" "author = {Pedersen, Ulf R.},\n" "year = {2013},\n" "pages = {104102}\n" diff --git a/src/EXTRA-FIX/fix_ti_spring.cpp b/src/EXTRA-FIX/fix_ti_spring.cpp index b332c18148..e44afdba01 100644 --- a/src/EXTRA-FIX/fix_ti_spring.cpp +++ b/src/EXTRA-FIX/fix_ti_spring.cpp @@ -35,10 +35,10 @@ using namespace LAMMPS_NS; using namespace FixConst; static const char cite_fix_ti_spring[] = - "ti/spring command:\n\n" + "ti/spring command: doi:10.1016/j.commatsci.2015.10.050\n\n" "@article{freitas2016,\n" " author={Freitas, Rodrigo and Asta, Mark and de Koning, Maurice},\n" - " title={Nonequilibrium free-energy calculation of solids using LAMMPS},\n" + " title={Nonequilibrium Free-Energy Calculation of Solids Using {LAMMPS}},\n" " journal={Computational Materials Science},\n" " volume={112},\n" " pages={333--341},\n" diff --git a/src/EXTRA-FIX/fix_ttm_mod.cpp b/src/EXTRA-FIX/fix_ttm_mod.cpp index 8979a30bf4..539b7e1c19 100644 --- a/src/EXTRA-FIX/fix_ttm_mod.cpp +++ b/src/EXTRA-FIX/fix_ttm_mod.cpp @@ -48,11 +48,11 @@ using namespace MathConst; // to spatially average consistent with the TTM grid static const char cite_fix_ttm_mod[] = - "fix ttm/mod command:\n\n" + "fix ttm/mod command: doi:10.1088/0953-8984/26/47/475401, doi:10.1002/ctpp.201310025\n\n" "@article{Pisarev2014,\n" "author = {Pisarev, V. V. and Starikov, S. V.},\n" - "title = {{Atomistic simulation of ion track formation in UO2.}},\n" - "journal = {J.~Phys.:~Condens.~Matter},\n" + "title = {Atomistic Simulation of Ion Track Formation in {UO$_2$}.},\n" + "journal = {J.~Phys.\\ Condens.\\ Matter},\n" "volume = {26},\n" "number = {47},\n" "pages = {475401},\n" @@ -60,8 +60,8 @@ static const char cite_fix_ttm_mod[] = "}\n\n" "@article{Norman2013,\n" "author = {Norman, G. E. and Starikov, S. V. and Stegailov, V. V. and Saitov, I. M. and Zhilyaev, P. A.},\n" - "title = {{Atomistic Modeling of Warm Dense Matter in the Two-Temperature State}},\n" - "journal = {Contrib.~Plasm.~Phys.},\n" + "title = {Atomistic Modeling of Warm Dense Matter in the Two-Temperature State},\n" + "journal = {Contrib.\\ Plasma Phys.},\n" "number = {2},\n" "volume = {53},\n" "pages = {129--139},\n" diff --git a/src/EXTRA-MOLECULE/dihedral_table_cut.cpp b/src/EXTRA-MOLECULE/dihedral_table_cut.cpp index 5ac3ab6ebb..4830516b1d 100644 --- a/src/EXTRA-MOLECULE/dihedral_table_cut.cpp +++ b/src/EXTRA-MOLECULE/dihedral_table_cut.cpp @@ -36,13 +36,13 @@ using namespace LAMMPS_NS; using namespace MathConst; static const char cite_dihedral_tablecut[] = - "dihedral_style table/cut command:\n\n" + "dihedral_style table/cut command: doi:10.1021/acs.jctc.7b01229\n\n" "@Article{Salerno17,\n" " author = {K. M. Salerno and N. Bernstein},\n" " title = {Persistence Length, End-to-End Distance, and Structure of Coarse-Grained Polymers},\n" - " journal = {J.~Chem.~Theory Comput.},\n" + " journal = {J.~Chem.\\ Theory Comput.},\n" " year = 2018,\n" - " DOI = 10.1021/acs.jctc.7b01229" + " DOI = \"10.1021/acs.jctc.7b01229\"\n" "}\n\n"; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-PAIR/pair_e3b.cpp b/src/EXTRA-PAIR/pair_e3b.cpp index 5011cc01e0..ab68b5c729 100644 --- a/src/EXTRA-PAIR/pair_e3b.cpp +++ b/src/EXTRA-PAIR/pair_e3b.cpp @@ -468,40 +468,40 @@ void PairE3B::init_style() } static const char cite_E3B1[] = - "Explicit Three-Body (E3B) potential for water:\n\n" + "Explicit Three-Body (E3B) potential for water: doi:10.1021/jp8009468\n\n" "@article{kumar_water_2008,\n" "title = {Water Simulation Model with Explicit Three-Molecule Interactions},\n" "volume = {112},\n" - "doi = {10.1021/jp8009468},\n" "number = {28},\n" - "journal = {J Phys. Chem. B},\n" + "doi = {10.1021/jp8009468},\n" + "journal = {J.~Phys.\\ Chem.~B},\n" "author = {Kumar, R. and Skinner, J. L.},\n" "year = {2008},\n" "pages = {8311--8318}\n" "}\n\n"; static const char cite_E3B2[] = - "Explicit Three-Body (E3B) potential for water:\n\n" + "Explicit Three-Body (E3B) potential for water: doi:10.1063/1.3587053\n\n" "@article{tainter_robust_2011,\n" - "title = {Robust three-body water simulation model},\n" + "title = {Robust Three-Body Water Simulation Model},\n" "volume = {134},\n" "doi = {10.1063/1.3587053},\n" "number = {18},\n" - "journal = {J. Chem. Phys},\n" + "journal = {J.~Chem.\\ Phys},\n" "author = {Tainter, C. J. and Pieniazek, P. A. and Lin, Y.-S. and Skinner, J. L.},\n" "year = {2011},\n" "pages = {184501}\n" "}\n\n"; static const char cite_E3B3[] = - "Explicit Three-Body (E3B) potential for water:\n\n" + "Explicit Three-Body (E3B) potential for water: doi:10.1021/acs.jctc.5b00117\n\n" "@article{tainter_reparametrized_2015,\n" "title = {Reparametrized {E3B} (Explicit Three-Body) Water Model Using the {TIP4P/2005} Model " "as a Reference},\n" "volume = {11},\n" "doi = {10.1021/acs.jctc.5b00117},\n" "number = {5},\n" - "journal = {J. Chem. Theory Comput.},\n" + "journal = {J.~Chem.\\ Theory Comput.},\n" "author = {Tainter, Craig J. and Shi, Liang and Skinner, James L.},\n" "year = {2015},\n" "pages = {2268--2277}\n" diff --git a/src/EXTRA-PAIR/pair_lj_relres.cpp b/src/EXTRA-PAIR/pair_lj_relres.cpp index 5d1ed4fdf0..88621fe54a 100644 --- a/src/EXTRA-PAIR/pair_lj_relres.cpp +++ b/src/EXTRA-PAIR/pair_lj_relres.cpp @@ -31,18 +31,18 @@ using namespace LAMMPS_NS; static const char cite_relres[] = - "Pair style lj/relres: doi:10.1021/acs.jctc.0c01003\n\n" + "Pair style lj/relres: doi:10.1021/acs.jctc.0c01003, doi:10.1021/acs.jctc.0c01003\n\n" "@Article{Chaimovich1,\n" " author = {A. Chaimovich, C. Peter, K. Kremer},\n" - " title = {Relative resolution: A hybrid formalism for fluid mixtures},\n" - " journal = {J.~Chem.~Phys.},\n" + " title = {Relative Resolution: {A} Hybrid Formalism for Fluid Mixtures},\n" + " journal = {J.~Chem.\\ Phys.},\n" " year = 2015,\n" " volume = 143,\n" " pages = {243107}\n" "@Article{Chaimovich2,\n" - " author = {M. Chaimovich, A. Chaimovich},\n" + " author = {M. Chaimovich and A. Chaimovich},\n" " title = {Relative Resolution: A Computationally Efficient Implementation in LAMMPS},\n" - " journal = {J.~Chem.~Theory~Comput.},\n" + " journal = {J.~Chem.\\ Theory Comput.},\n" " year = 2021,\n" " volume = 17,\n" " pages = {1045--1059}\n" diff --git a/src/EXTRA-PAIR/pair_momb.cpp b/src/EXTRA-PAIR/pair_momb.cpp index 2adb206308..d8b6e04d11 100644 --- a/src/EXTRA-PAIR/pair_momb.cpp +++ b/src/EXTRA-PAIR/pair_momb.cpp @@ -32,16 +32,16 @@ using namespace LAMMPS_NS; static const char cite_momb[] = - "Pair style momb:\n\n" + "Pair style momb: doi:10.1021/jp412098n\n\n" "@Article{pair_momb_2015,\n" - "title = {A force field for describing the polyvinylpyrrolidone-mediated" - " solution-phase synthesis of shape-selective Ag nanoparticles.},\n" + "title = {A Force Field for Describing the Polyvinylpyrrolidone-Mediated\n" + " Solution-Phase Synthesis of Shape-Selective {Ag} Nanoparticles},\n" "volume = {118},\n" "number = {6},\n" "url = {https://doi.org/10.1021/jp412098n},\n" "doi = {10.1021/jp412098n},\n" - "journal = {J. Phys. Chem. C},\n" - "author = {Zhou, Ya, Wissam A. Saidi, and Kristen A. Fichthorn},\n" + "journal = {J.~Phys.\\ Chem.~C},\n" + "author = {Zhou, Ya and Wissam A. Saidi and Kristen A. Fichthorn},\n" "year = {2014},\n" "pages = {3366--3374}\n" "}\n\n"; diff --git a/src/GPU/fix_gpu.cpp b/src/GPU/fix_gpu.cpp index 3ca57133a9..1488900aec 100644 --- a/src/GPU/fix_gpu.cpp +++ b/src/GPU/fix_gpu.cpp @@ -53,51 +53,59 @@ extern double lmp_gpu_update_bin_size(const double subx, const double suby, cons const int nlocal, const double cut); static const char cite_gpu_package[] = - "GPU package (short-range, long-range and three-body potentials):\n\n" + "GPU package (short-range, long-range and three-body potentials): doi:10.1016/j.cpc.2010.12.021, doi:10.1016/j.cpc.2011.10.012, doi:10.1016/j.cpc.2013.08.002, doi:10.1016/j.commatsci.2014.10.068, doi:10.1016/j.cpc.2016.10.020, doi:10.3233/APC200086\n\n" "@Article{Brown11,\n" - " author = {W. M. Brown, P. Wang, S. J. Plimpton, A. N. Tharrington},\n" - " title = {Implementing Molecular Dynamics on Hybrid High Performance Computers - Short Range Forces},\n" - " journal = {Comp.~Phys.~Comm.},\n" + " author = {W. M. Brown and P. Wang and S. J. Plimpton and A. N. Tharrington},\n" + " title = {Implementing Molecular Dynamics on Hybrid High Performance Computers---Short Range Forces},\n" + " journal = {Comput.\\ Phys.\\ Commun.},\n" " year = 2011,\n" " volume = 182,\n" - " pages = {898--911}\n" + " pages = {898--911},\n" + " doi = {10.1016/j.cpc.2010.12.021}\n" "}\n\n" "@Article{Brown12,\n" - " author = {W. M. Brown, A. Kohlmeyer, S. J. Plimpton, A. N. Tharrington},\n" + " author = {W. M. Brown and A. Kohlmeyer and S. J. Plimpton and A. N. Tharrington},\n" " title = {Implementing Molecular Dynamics on Hybrid High Performance Computers - Particle-Particle Particle-Mesh},\n" - " journal = {Comp.~Phys.~Comm.},\n" + " journal = {Comput.\\ Phys.\\ Commun.},\n" " year = 2012,\n" " volume = 183,\n" + " doi = {10.1016/j.cpc.2011.10.012},\n" " pages = {449--459}\n" "}\n\n" "@Article{Brown13,\n" - " author = {W. M. Brown, Y. Masako},\n" - " title = {Implementing Molecular Dynamics on Hybrid High Performance Computers – Three-Body Potentials},\n" - " journal = {Comp.~Phys.~Comm.},\n" + " author = {W. M. Brown and Y. Masako},\n" + " title = {Implementing Molecular Dynamics on Hybrid High Performance Computers---Three-Body Potentials},\n" + " journal = {Comput.\\ Phys.\\ Commun.},\n" " year = 2013,\n" " volume = 184,\n" - " pages = {2785--2793}\n" + " pages = {2785--2793},\n" + " doi = {10.1016/j.cpc.2013.08.002},\n" "}\n\n" "@Article{Trung15,\n" - " author = {T. D. Nguyen, S. J. Plimpton},\n" - " title = {Accelerating dissipative particle dynamics simulations for soft matter systems},\n" - " journal = {Comput.~Mater.~Sci.},\n" + " author = {T. D. Nguyen and S. J. Plimpton},\n" + " title = {Accelerating Dissipative Particle Dynamics Simulations for Soft Matter Systems},\n" + " journal = {Comput.\\ Mater.\\ Sci.},\n" " year = 2015,\n" + " doi = {10.1016/j.commatsci.2014.10.068},\n" " volume = 100,\n" " pages = {173--180}\n" "}\n\n" "@Article{Trung17,\n" " author = {T. D. Nguyen},\n" - " title = {GPU-accelerated Tersoff potentials for massively parallel Molecular Dynamics simulations},\n" - " journal = {Comp.~Phys.~Comm.},\n" + " title = {{GPU}-Accelerated {T}ersoff Potentials for Massively Parallel\n" + " Molecular Dynamics Simulations},\n" + " journal = {Comput.\\ Phys.\\ Commun.},\n" " year = 2017,\n" + " doi = {10.1016/j.cpc.2016.10.020},\n" " volume = 212,\n" " pages = {113--122}\n" "}\n\n" - "@Article{Nikolskiy19,\n" - " author = {V. Nikolskiy, V. Stegailov},\n" - " title = {GPU acceleration of four-site water models in LAMMPS},\n" - " journal = {Proceeding of the International Conference on Parallel Computing (ParCo 2019), Prague, Czech Republic},\n" + "@inproceedings{Nikolskiy19,\n" + " author = {V. Nikolskiy and V. Stegailov},\n" + " title = {{GPU} Acceleration of Four-Site Water Models in {LAMMPS}},\n" + " booktitle = {Proceedings of the International Conference on Parallel\n" + " Computing (ParCo 2019), Prague, Czech Republic},\n" + " doi = {10.3233/APC200086},\n" " year = 2019\n" "}\n\n"; diff --git a/src/GRANULAR/fix_pour.cpp b/src/GRANULAR/fix_pour.cpp index 7a8bf630df..00455096f8 100644 --- a/src/GRANULAR/fix_pour.cpp +++ b/src/GRANULAR/fix_pour.cpp @@ -131,7 +131,7 @@ FixPour::FixPour(LAMMPS *lmp, int narg, char **arg) : if (atom->molecular == Atom::TEMPLATE && onemols != atom->avec->onemols) error->all(FLERR, "Fix pour molecule template ID must be same as atom style template ID"); - onemols[i]->check_attributes(0); + onemols[i]->check_attributes(); // fix pour uses geoemetric center of molecule for insertion diff --git a/src/H5MD/dump_h5md.cpp b/src/H5MD/dump_h5md.cpp index 1ee2bd2a54..2bb5af3043 100644 --- a/src/H5MD/dump_h5md.cpp +++ b/src/H5MD/dump_h5md.cpp @@ -73,7 +73,7 @@ DumpH5MD::DumpH5MD(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg) format_default = nullptr; flush_flag = 0; unwrap_flag = 0; - datafile_from_dump = -1; + other_dump = nullptr; author_name = nullptr; every_dump = utils::inumeric(FLERR,arg[3],false,lmp); @@ -141,11 +141,8 @@ DumpH5MD::DumpH5MD(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg) } if (box_is_set||create_group_is_set) error->all(FLERR, "Cannot set file_from in dump h5md after box or create_group"); - int idump; - for (idump = 0; idump < output->ndump; idump++) - if (strcmp(arg[iarg+1],output->dump[idump]->id) == 0) break; - if (idump == output->ndump) error->all(FLERR,"Cound not find dump_modify ID"); - datafile_from_dump = idump; + other_dump = dynamic_cast(output->get_dump_by_id(arg[iarg+1])); + if (!other_dump) error->all(FLERR,"Cound not find dump_modify H5MD dump ID {}", arg[iarg+1]); do_box=false; create_group=false; iarg+=2; @@ -262,7 +259,7 @@ void DumpH5MD::openfile() } if (me == 0) { - if (datafile_from_dump<0) { + if (!other_dump) { if (author_name==nullptr) { datafile = h5md_create_file(filename, "N/A", nullptr, "lammps", LAMMPS_VERSION); } else { @@ -296,8 +293,6 @@ void DumpH5MD::openfile() h5md_write_string_attribute(particles_data.group, "charge", "type", "effective"); } } else { - DumpH5MD* other_dump; - other_dump=(DumpH5MD*)output->dump[datafile_from_dump]; datafile = other_dump->datafile; group_name_length = strlen(group->names[igroup]); group_name = new char[group_name_length]; diff --git a/src/H5MD/dump_h5md.h b/src/H5MD/dump_h5md.h index 6634cdb8ae..e33f64f54a 100644 --- a/src/H5MD/dump_h5md.h +++ b/src/H5MD/dump_h5md.h @@ -35,9 +35,9 @@ class DumpH5MD : public Dump { int natoms, ntotal; int unwrap_flag; // 1 if atom coords are unwrapped, 0 if no h5md_file datafile; - int datafile_from_dump; h5md_particles_group particles_data; char *author_name; + DumpH5MD *other_dump; bool do_box; bool create_group; diff --git a/src/INTEL/angle_charmm_intel.cpp b/src/INTEL/angle_charmm_intel.cpp index 1bdf2acb29..48e179c997 100644 --- a/src/INTEL/angle_charmm_intel.cpp +++ b/src/INTEL/angle_charmm_intel.cpp @@ -166,10 +166,10 @@ void AngleCharmmIntel::eval(const int vflag, #else for (int n = nfrom; n < nto; n += npl) { #endif - const int i1 = anglelist[n].a; - const int i2 = anglelist[n].b; - const int i3 = anglelist[n].c; - const int type = anglelist[n].t; + const int i1 = IP_PRE_dword_index(anglelist[n].a); + const int i2 = IP_PRE_dword_index(anglelist[n].b); + const int i3 = IP_PRE_dword_index(anglelist[n].c); + const int type = IP_PRE_dword_index(anglelist[n].t); // 1st bond diff --git a/src/INTEL/angle_harmonic_intel.cpp b/src/INTEL/angle_harmonic_intel.cpp index 8d3d44f528..57dc152fbf 100644 --- a/src/INTEL/angle_harmonic_intel.cpp +++ b/src/INTEL/angle_harmonic_intel.cpp @@ -166,10 +166,10 @@ void AngleHarmonicIntel::eval(const int vflag, #else for (int n = nfrom; n < nto; n += npl) { #endif - const int i1 = anglelist[n].a; - const int i2 = anglelist[n].b; - const int i3 = anglelist[n].c; - const int type = anglelist[n].t; + const int i1 = IP_PRE_dword_index(anglelist[n].a); + const int i2 = IP_PRE_dword_index(anglelist[n].b); + const int i3 = IP_PRE_dword_index(anglelist[n].c); + const int type = IP_PRE_dword_index(anglelist[n].t); // 1st bond diff --git a/src/INTEL/bond_fene_intel.cpp b/src/INTEL/bond_fene_intel.cpp index 5cd14dc230..12579372e9 100644 --- a/src/INTEL/bond_fene_intel.cpp +++ b/src/INTEL/bond_fene_intel.cpp @@ -163,9 +163,9 @@ void BondFENEIntel::eval(const int vflag, #else for (int n = nfrom; n < nto; n += npl) { #endif - const int i1 = bondlist[n].a; - const int i2 = bondlist[n].b; - const int type = bondlist[n].t; + const int i1 = IP_PRE_dword_index(bondlist[n].a); + const int i2 = IP_PRE_dword_index(bondlist[n].b); + const int type = IP_PRE_dword_index(bondlist[n].t); const flt_t ir0sq = fc.fc[type].ir0sq; const flt_t k = fc.fc[type].k; diff --git a/src/INTEL/bond_harmonic_intel.cpp b/src/INTEL/bond_harmonic_intel.cpp index 4cb6ba3a8a..b3283f63bc 100644 --- a/src/INTEL/bond_harmonic_intel.cpp +++ b/src/INTEL/bond_harmonic_intel.cpp @@ -159,9 +159,9 @@ void BondHarmonicIntel::eval(const int vflag, #else for (int n = nfrom; n < nto; n += npl) { #endif - const int i1 = bondlist[n].a; - const int i2 = bondlist[n].b; - const int type = bondlist[n].t; + const int i1 = IP_PRE_dword_index(bondlist[n].a); + const int i2 = IP_PRE_dword_index(bondlist[n].b); + const int type = IP_PRE_dword_index(bondlist[n].t); const flt_t delx = x[i1].x - x[i2].x; const flt_t dely = x[i1].y - x[i2].y; diff --git a/src/INTEL/dihedral_charmm_intel.cpp b/src/INTEL/dihedral_charmm_intel.cpp index b36e5ab505..2b3f8e2208 100644 --- a/src/INTEL/dihedral_charmm_intel.cpp +++ b/src/INTEL/dihedral_charmm_intel.cpp @@ -195,11 +195,11 @@ void DihedralCharmmIntel::eval(const int vflag, for (int n = nfrom; n < nto; n++) { #endif for (int n = nfrom; n < nto; n += npl) { - const int i1 = dihedrallist[n].a; - const int i2 = dihedrallist[n].b; - const int i3 = dihedrallist[n].c; - const int i4 = dihedrallist[n].d; - const int type = dihedrallist[n].t; + const int i1 = IP_PRE_dword_index(dihedrallist[n].a); + const int i2 = IP_PRE_dword_index(dihedrallist[n].b); + const int i3 = IP_PRE_dword_index(dihedrallist[n].c); + const int i4 = IP_PRE_dword_index(dihedrallist[n].d); + const int type = IP_PRE_dword_index(dihedrallist[n].t); // 1st bond diff --git a/src/INTEL/dihedral_harmonic_intel.cpp b/src/INTEL/dihedral_harmonic_intel.cpp index 9b504be3ca..831b3a94f4 100644 --- a/src/INTEL/dihedral_harmonic_intel.cpp +++ b/src/INTEL/dihedral_harmonic_intel.cpp @@ -163,11 +163,11 @@ void DihedralHarmonicIntel::eval(const int vflag, #else for (int n = nfrom; n < nto; n += npl) { #endif - const int i1 = dihedrallist[n].a; - const int i2 = dihedrallist[n].b; - const int i3 = dihedrallist[n].c; - const int i4 = dihedrallist[n].d; - const int type = dihedrallist[n].t; + const int i1 = IP_PRE_dword_index(dihedrallist[n].a); + const int i2 = IP_PRE_dword_index(dihedrallist[n].b); + const int i3 = IP_PRE_dword_index(dihedrallist[n].c); + const int i4 = IP_PRE_dword_index(dihedrallist[n].d); + const int type = IP_PRE_dword_index(dihedrallist[n].t); // 1st bond diff --git a/src/INTEL/dihedral_opls_intel.cpp b/src/INTEL/dihedral_opls_intel.cpp index db0618abec..ff54923c34 100644 --- a/src/INTEL/dihedral_opls_intel.cpp +++ b/src/INTEL/dihedral_opls_intel.cpp @@ -167,11 +167,11 @@ void DihedralOPLSIntel::eval(const int vflag, #else for (int n = nfrom; n < nto; n += npl) { #endif - const int i1 = dihedrallist[n].a; - const int i2 = dihedrallist[n].b; - const int i3 = dihedrallist[n].c; - const int i4 = dihedrallist[n].d; - const int type = dihedrallist[n].t; + const int i1 = IP_PRE_dword_index(dihedrallist[n].a); + const int i2 = IP_PRE_dword_index(dihedrallist[n].b); + const int i3 = IP_PRE_dword_index(dihedrallist[n].c); + const int i4 = IP_PRE_dword_index(dihedrallist[n].d); + const int type = IP_PRE_dword_index(dihedrallist[n].t); // 1st bond diff --git a/src/INTEL/fix_nh_intel.cpp b/src/INTEL/fix_nh_intel.cpp index a6f2ec0478..2f10b63922 100644 --- a/src/INTEL/fix_nh_intel.cpp +++ b/src/INTEL/fix_nh_intel.cpp @@ -22,6 +22,7 @@ #include "domain.h" #include "error.h" #include "force.h" +#include "intel_preprocess.h" #include "memory.h" #include "modify.h" #include "neighbor.h" @@ -100,6 +101,7 @@ void FixNHIntel::remap() #pragma vector aligned #endif for (int i = 0; i < nlocal; i++) { + i = IP_PRE_dword_index(i); const double d0 = x[i].x - b0; const double d1 = x[i].y - b1; const double d2 = x[i].z - b2; @@ -118,6 +120,7 @@ void FixNHIntel::remap() #endif for (int i = 0; i < nlocal; i++) { if (mask[i] & dilate_group_bit) { + i = IP_PRE_dword_index(i); const double d0 = x[i].x - b0; const double d1 = x[i].y - b1; const double d2 = x[i].z - b2; @@ -287,6 +290,7 @@ void FixNHIntel::remap() #pragma vector aligned #endif for (int i = 0; i < nlocal; i++) { + i = IP_PRE_dword_index(i); x[i].x = h0*x[i].x + h5*x[i].y + h4*x[i].z + nb0; x[i].y = h1*x[i].y + h3*x[i].z + nb1; x[i].z = h2*x[i].z + nb2; @@ -302,6 +306,7 @@ void FixNHIntel::remap() #endif for (int i = 0; i < nlocal; i++) { if (mask[i] & dilate_group_bit) { + i = IP_PRE_dword_index(i); x[i].x = h0*x[i].x + h5*x[i].y + h4*x[i].z + nb0; x[i].y = h1*x[i].y + h3*x[i].z + nb1; x[i].z = h2*x[i].z + nb2; @@ -432,6 +437,7 @@ void FixNHIntel::nh_v_press() #pragma vector aligned #endif for (int i = 0; i < nlocal; i++) { + i = IP_PRE_dword_index(i); v[i].x *= f0; v[i].y *= f1; v[i].z *= f2; @@ -447,6 +453,7 @@ void FixNHIntel::nh_v_press() #endif for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { + i = IP_PRE_dword_index(i); v[i].x *= f0; v[i].y *= f1; v[i].z *= f2; diff --git a/src/INTEL/improper_cvff_intel.cpp b/src/INTEL/improper_cvff_intel.cpp index bc3c1d06e8..ad0702f7b1 100644 --- a/src/INTEL/improper_cvff_intel.cpp +++ b/src/INTEL/improper_cvff_intel.cpp @@ -168,11 +168,11 @@ void ImproperCvffIntel::eval(const int vflag, #else for (int n = nfrom; n < nto; n += npl) { #endif - const int i1 = improperlist[n].a; - const int i2 = improperlist[n].b; - const int i3 = improperlist[n].c; - const int i4 = improperlist[n].d; - const int type = improperlist[n].t; + const int i1 = IP_PRE_dword_index(improperlist[n].a); + const int i2 = IP_PRE_dword_index(improperlist[n].b); + const int i3 = IP_PRE_dword_index(improperlist[n].c); + const int i4 = IP_PRE_dword_index(improperlist[n].d); + const int type = IP_PRE_dword_index(improperlist[n].t); // geometry of 4-body diff --git a/src/INTEL/improper_harmonic_intel.cpp b/src/INTEL/improper_harmonic_intel.cpp index 615d080446..d71c0bdf10 100644 --- a/src/INTEL/improper_harmonic_intel.cpp +++ b/src/INTEL/improper_harmonic_intel.cpp @@ -170,11 +170,11 @@ void ImproperHarmonicIntel::eval(const int vflag, #else for (int n = nfrom; n < nto; n += npl) { #endif - const int i1 = improperlist[n].a; - const int i2 = improperlist[n].b; - const int i3 = improperlist[n].c; - const int i4 = improperlist[n].d; - const int type = improperlist[n].t; + const int i1 = IP_PRE_dword_index(improperlist[n].a); + const int i2 = IP_PRE_dword_index(improperlist[n].b); + const int i3 = IP_PRE_dword_index(improperlist[n].c); + const int i4 = IP_PRE_dword_index(improperlist[n].d); + const int type = IP_PRE_dword_index(improperlist[n].t); // geometry of 4-body diff --git a/src/INTEL/intel_preprocess.h b/src/INTEL/intel_preprocess.h index c7bd60b00b..7ff8f7d099 100644 --- a/src/INTEL/intel_preprocess.h +++ b/src/INTEL/intel_preprocess.h @@ -16,10 +16,16 @@ Contributing author: W. Michael Brown (Intel) ------------------------------------------------------------------------- */ +#include "lmptype.h" + #ifdef __INTEL_LLVM_COMPILER #define USE_OMP_SIMD #define __INTEL_COMPILER __INTEL_LLVM_COMPILER #define __INTEL_COMPILER_BUILD_DATE __INTEL_LLVM_COMPILER +// Indicate to vectorizer that it is safe to use dword indexed gather +#define IP_PRE_dword_index(i) ((i) & NEIGHMASK) +#else +#define IP_PRE_dword_index(i) i #endif #ifdef __INTEL_COMPILER diff --git a/src/INTEL/npair_full_bin_ghost_intel.cpp b/src/INTEL/npair_full_bin_ghost_intel.cpp index b0c052d35b..e6ca266933 100644 --- a/src/INTEL/npair_full_bin_ghost_intel.cpp +++ b/src/INTEL/npair_full_bin_ghost_intel.cpp @@ -370,7 +370,7 @@ void NPairFullBinGhostIntel::fbi(const int offload, NeighList * list, #pragma vector aligned #endif for (int u = 0; u < ncount; u++) { - const int j = tj[u]; + const int j = IP_PRE_dword_index(tj[u]); tx[u] = x[j].x; ty[u] = x[j].y; tz[u] = x[j].z; diff --git a/src/INTEL/npair_intel.cpp b/src/INTEL/npair_intel.cpp index f6783fce40..cfbea387a0 100644 --- a/src/INTEL/npair_intel.cpp +++ b/src/INTEL/npair_intel.cpp @@ -359,7 +359,7 @@ void NPairIntel::bin_newton(const int offload, NeighList *list, #pragma vector aligned #endif for (int u = 0; u < ncount; u++) { - const int j = tj[u]; + const int j = IP_PRE_dword_index(tj[u]); tx[u] = x[j].x; ty[u] = x[j].y; tz[u] = x[j].z; @@ -387,7 +387,7 @@ void NPairIntel::bin_newton(const int offload, NeighList *list, #endif #endif for (int jj = bstart; jj < bend; jj++) { - const int j = binpacked[jj]; + const int j = IP_PRE_dword_index(binpacked[jj]); itj[icount] = j; itx[icount] = x[j].x; ity[icount] = x[j].y; diff --git a/src/INTEL/pair_buck_coul_cut_intel.cpp b/src/INTEL/pair_buck_coul_cut_intel.cpp index 57608a090c..62d6d02952 100644 --- a/src/INTEL/pair_buck_coul_cut_intel.cpp +++ b/src/INTEL/pair_buck_coul_cut_intel.cpp @@ -265,7 +265,7 @@ void PairBuckCoulCutIntel::eval(const int offload, const int vflag, const flt_t delx = xtmp - x[j].x; const flt_t dely = ytmp - x[j].y; const flt_t delz = ztmp - x[j].z; - const int jtype = x[j].w; + const int jtype = IP_PRE_dword_index(x[j].w); const flt_t rsq = delx * delx + dely * dely + delz * delz; const flt_t r = sqrt(rsq); const flt_t r2inv = (flt_t)1.0 / rsq; diff --git a/src/INTEL/pair_buck_coul_long_intel.cpp b/src/INTEL/pair_buck_coul_long_intel.cpp index b0638ff68d..1425317a0a 100644 --- a/src/INTEL/pair_buck_coul_long_intel.cpp +++ b/src/INTEL/pair_buck_coul_long_intel.cpp @@ -289,7 +289,7 @@ void PairBuckCoulLongIntel::eval(const int offload, const int vflag, const flt_t delx = xtmp - x[j].x; const flt_t dely = ytmp - x[j].y; const flt_t delz = ztmp - x[j].z; - const int jtype = x[j].w; + const int jtype = IP_PRE_dword_index(x[j].w); const flt_t rsq = delx * delx + dely * dely + delz * delz; if (rsq < c_forcei[jtype].cutsq) { diff --git a/src/INTEL/pair_buck_intel.cpp b/src/INTEL/pair_buck_intel.cpp index 7e3da8daf8..46ea291420 100644 --- a/src/INTEL/pair_buck_intel.cpp +++ b/src/INTEL/pair_buck_intel.cpp @@ -253,7 +253,7 @@ void PairBuckIntel::eval(const int offload, const int vflag, const flt_t delx = xtmp - x[j].x; const flt_t dely = ytmp - x[j].y; const flt_t delz = ztmp - x[j].z; - const int jtype = x[j].w; + const int jtype = IP_PRE_dword_index(x[j].w); const flt_t rsq = delx * delx + dely * dely + delz * delz; const flt_t r = sqrt(rsq); const flt_t r2inv = (flt_t)1.0 / rsq; diff --git a/src/INTEL/pair_dpd_intel.cpp b/src/INTEL/pair_dpd_intel.cpp index 06801b0ce0..763bd2fb57 100644 --- a/src/INTEL/pair_dpd_intel.cpp +++ b/src/INTEL/pair_dpd_intel.cpp @@ -312,13 +312,13 @@ void PairDPDIntel::eval(const int offload, const int vflag, sbindex = jlist[jj] >> SBBITS & 3; j = jlist[jj] & NEIGHMASK; } else - j = jlist[jj]; + j = IP_PRE_dword_index(jlist[jj]); const flt_t delx = xtmp - x[j].x; const flt_t dely = ytmp - x[j].y; const flt_t delz = ztmp - x[j].z; if (!ONETYPE) { - jtype = x[j].w; + jtype = IP_PRE_dword_index(x[j].w); icut = parami[jtype].icut; } const flt_t rsq = delx * delx + dely * dely + delz * delz; diff --git a/src/INTEL/pair_eam_intel.cpp b/src/INTEL/pair_eam_intel.cpp index 2a491e66c9..0fff4f0632 100644 --- a/src/INTEL/pair_eam_intel.cpp +++ b/src/INTEL/pair_eam_intel.cpp @@ -347,14 +347,15 @@ void PairEAMIntel::eval(const int offload, const int vflag, p = MIN(p,(flt_t)1.0); if (!ONETYPE) rhor_joff = rhor_ioff + jtype * jstride; - const int joff = rhor_joff + m; + const int joff = IP_PRE_dword_index(rhor_joff + m); flt_t ra; ra = ((rhor_spline_e[joff].a*p + rhor_spline_e[joff].b) * p + rhor_spline_e[joff].c) * p + rhor_spline_e[joff].d; rhoi += ra; if (NEWTON_PAIR) { if (!ONETYPE) { - const int ioff = jtype * istride + itype * jstride + m; + const int ioff = IP_PRE_dword_index(jtype * istride + itype * + jstride + m); ra = ((rhor_spline_e[ioff].a*p + rhor_spline_e[ioff].b)*p + rhor_spline_e[ioff].c) * p + rhor_spline_e[ioff].d; } @@ -439,7 +440,7 @@ void PairEAMIntel::eval(const int offload, const int vflag, #pragma vector aligned #endif for (int ii = iifrom; ii < iito; ++ii) { - const int i = ilist[ii]; + const int i = IP_PRE_dword_index(ilist[ii]); int itype; if (!ONETYPE) itype = x[i].w; flt_t p = rho[i]*frdrho + (flt_t)1.0; @@ -448,7 +449,7 @@ void PairEAMIntel::eval(const int offload, const int vflag, p -= m; p = MIN(p,(flt_t)1.0); if (!ONETYPE) frho_ioff = itype * fstride; - const int ioff = frho_ioff + m; + const int ioff = IP_PRE_dword_index(frho_ioff + m); fp_f[i] = (frho_spline_f[ioff].a*p + frho_spline_f[ioff].b)*p + frho_spline_f[ioff].c; if (EFLAG) { @@ -553,13 +554,14 @@ void PairEAMIntel::eval(const int offload, const int vflag, p = MIN(p,(flt_t)1.0); if (!ONETYPE) rhor_joff = rhor_ioff + jtype * jstride; - const int joff = rhor_joff + m; + const int joff = IP_PRE_dword_index(rhor_joff + m); const flt_t rhojp = (rhor_spline_f[joff].a*p + rhor_spline_f[joff].b)*p + rhor_spline_f[joff].c; flt_t rhoip; if (!ONETYPE) { - const int ioff = jtype * istride + itype * jstride + m; + const int ioff = IP_PRE_dword_index(jtype * istride + + itype * jstride + m); rhoip = (rhor_spline_f[ioff].a*p + rhor_spline_f[ioff].b)*p + rhor_spline_f[ioff].c; } else diff --git a/src/INTEL/pair_gayberne_intel.cpp b/src/INTEL/pair_gayberne_intel.cpp index c3ce8a8d43..1c2cdf0d49 100644 --- a/src/INTEL/pair_gayberne_intel.cpp +++ b/src/INTEL/pair_gayberne_intel.cpp @@ -417,7 +417,7 @@ void PairGayBerneIntel::eval(const int offload, const int vflag, for (int jj = 0; jj < jnum; jj++) { int jm = jlist[jj]; int j = jm & NEIGHMASK; - const int jtype = x[j].w; + const int jtype = IP_PRE_dword_index(x[j].w); if (ijci[jtype].form == ELLIPSE_ELLIPSE) { flt_t delx = x[j].x-xtmp; @@ -473,7 +473,7 @@ void PairGayBerneIntel::eval(const int offload, const int vflag, const int sbindex = jlist_form[jj] >> SBBITS & 3; const int j = jlist_form[jj] & NEIGHMASK; flt_t factor_lj = special_lj[sbindex]; - const int jtype = jtype_form[jj]; + const int jtype = IP_PRE_dword_index(jtype_form[jj]); const flt_t sigma = ijci[jtype].sigma; const flt_t epsilon = ijci[jtype].epsilon; const flt_t shape2_0 = ic[jtype].shape2[0]; diff --git a/src/INTEL/pair_lj_charmm_coul_charmm_intel.cpp b/src/INTEL/pair_lj_charmm_coul_charmm_intel.cpp index e6c528d3a4..9cc76a277c 100644 --- a/src/INTEL/pair_lj_charmm_coul_charmm_intel.cpp +++ b/src/INTEL/pair_lj_charmm_coul_charmm_intel.cpp @@ -318,7 +318,7 @@ void PairLJCharmmCoulCharmmIntel::eval(const int offload, const int vflag, #ifdef INTEL_VMASK if (rsq < cut_ljsq) { #endif - const int jtype = tjtype[jj]; + const int jtype = IP_PRE_dword_index(tjtype[jj]); flt_t r6inv = r2inv * r2inv * r2inv; forcelj = r6inv * (lji[jtype].x * r6inv - lji[jtype].y); if (EFLAG) evdwl = r6inv*(lji[jtype].z * r6inv - lji[jtype].w); diff --git a/src/INTEL/pair_lj_charmm_coul_long_intel.cpp b/src/INTEL/pair_lj_charmm_coul_long_intel.cpp index 3952a7da95..e30c1dec32 100644 --- a/src/INTEL/pair_lj_charmm_coul_long_intel.cpp +++ b/src/INTEL/pair_lj_charmm_coul_long_intel.cpp @@ -324,7 +324,7 @@ void PairLJCharmmCoulLongIntel::eval(const int offload, const int vflag, const int j = tj[jj] & NEIGHMASK; const int sbindex = tj[jj] >> SBBITS & 3; - const int jtype = tjtype[jj]; + const int jtype = IP_PRE_dword_index(tjtype[jj]); const flt_t rsq = trsq[jj]; const flt_t r2inv = (flt_t)1.0 / rsq; diff --git a/src/INTEL/pair_lj_cut_coul_long_intel.cpp b/src/INTEL/pair_lj_cut_coul_long_intel.cpp index 098036c2f1..17e6b6361d 100644 --- a/src/INTEL/pair_lj_cut_coul_long_intel.cpp +++ b/src/INTEL/pair_lj_cut_coul_long_intel.cpp @@ -287,7 +287,7 @@ void PairLJCutCoulLongIntel::eval(const int offload, const int vflag, const flt_t delx = xtmp - x[j].x; const flt_t dely = ytmp - x[j].y; const flt_t delz = ztmp - x[j].z; - const int jtype = x[j].w; + const int jtype = IP_PRE_dword_index(x[j].w); const flt_t rsq = delx * delx + dely * dely + delz * delz; if (rsq < c_forcei[jtype].cutsq) { @@ -316,8 +316,8 @@ void PairLJCutCoulLongIntel::eval(const int offload, const int vflag, forcecoul = forcelj = evdwl = ecoul = (flt_t)0.0; const int j = tj[jj] & NEIGHMASK; - const int sbindex = tj[jj] >> SBBITS & 3; - const int jtype = tjtype[jj]; + const int sbindex = IP_PRE_dword_index(tj[jj] >> SBBITS & 3); + const int jtype = IP_PRE_dword_index(tjtype[jj]); const flt_t rsq = trsq[jj]; const flt_t r2inv = (flt_t)1.0 / rsq; diff --git a/src/INTEL/pair_lj_cut_intel.cpp b/src/INTEL/pair_lj_cut_intel.cpp index 1f3169ab26..c1d9a947f6 100644 --- a/src/INTEL/pair_lj_cut_intel.cpp +++ b/src/INTEL/pair_lj_cut_intel.cpp @@ -262,13 +262,13 @@ void PairLJCutIntel::eval(const int offload, const int vflag, sbindex = jlist[jj] >> SBBITS & 3; j = jlist[jj] & NEIGHMASK; } else - j = jlist[jj]; + j = IP_PRE_dword_index(jlist[jj]); const flt_t delx = xtmp - x[j].x; const flt_t dely = ytmp - x[j].y; const flt_t delz = ztmp - x[j].z; if (!ONETYPE) { - jtype = x[j].w; + jtype = IP_PRE_dword_index(x[j].w); cutsq = ljc12oi[jtype].cutsq; } const flt_t rsq = delx * delx + dely * dely + delz * delz; diff --git a/src/INTEL/pair_sw_intel.cpp b/src/INTEL/pair_sw_intel.cpp index 37fe19260a..6e239afc7d 100644 --- a/src/INTEL/pair_sw_intel.cpp +++ b/src/INTEL/pair_sw_intel.cpp @@ -332,7 +332,7 @@ void PairSWIntel::eval(const int offload, const int vflag, int jtype, ijtype; if (!ONETYPE) { jtype = x[j].w; - ijtype = itype_offset + jtype; + ijtype = IP_PRE_dword_index(itype_offset + jtype); cutsq = p2[ijtype].cutsq; } const flt_t rsq1 = delx * delx + dely * dely + delz * delz; @@ -378,7 +378,7 @@ void PairSWIntel::eval(const int offload, const int vflag, if (EFLAG) fjtmp = (acc_t)0.0; int ijtype; - if (!ONETYPE) ijtype = tjtype[jj] + itype_offset; + if (!ONETYPE) ijtype = IP_PRE_dword_index(tjtype[jj] + itype_offset); const flt_t rsq1 = trsq[jj]; const flt_t rinvsq1 = (flt_t)1.0 / rsq1; @@ -459,8 +459,8 @@ void PairSWIntel::eval(const int offload, const int vflag, int iktype, ijktype; if (!ONETYPE) { iktype = tjtype[kk]; - ijktype = ijkoff + iktype; - iktype += itype_offset; + ijktype = IP_PRE_dword_index(ijkoff + iktype); + iktype = IP_PRE_dword_index(iktype + itype_offset); cut = p2[iktype].cut; sigma_gamma = p2[iktype].sigma_gamma; costheta = p3[ijktype].costheta; @@ -520,7 +520,7 @@ void PairSWIntel::eval(const int offload, const int vflag, } } } // for kk - const int j = tj[jj]; + const int j = IP_PRE_dword_index(tj[jj]); f[j].x += fjxtmp; f[j].y += fjytmp; f[j].z += fjztmp; diff --git a/src/INTEL/pppm_intel.cpp b/src/INTEL/pppm_intel.cpp index 72c5791f75..fc25d64847 100644 --- a/src/INTEL/pppm_intel.cpp +++ b/src/INTEL/pppm_intel.cpp @@ -403,7 +403,6 @@ void PPPMIntel::particle_map(IntelBuffers *buffers) // (nx,ny,nz) = global coords of grid pt to "lower left" of charge // current particle coord can be outside global and local box // add/subtract OFFSET to avoid int(-0.75) = 0 when want it to be -1 - int nx = static_cast ((x[i].x-lo0)*xi+fshift) - OFFSET; int ny = static_cast ((x[i].y-lo1)*yi+fshift) - OFFSET; int nz = static_cast ((x[i].z-lo2)*zi+fshift) - OFFSET; @@ -941,6 +940,7 @@ void PPPMIntel::fieldforce_ad(IntelBuffers *buffers) #endif #endif for (int i = ifrom; i < ito; i++) { + i = IP_PRE_dword_index(i); particle_ekx[i] *= hx_inv; particle_eky[i] *= hy_inv; particle_ekz[i] *= hz_inv; diff --git a/src/INTERLAYER/pair_ilp_graphene_hbn.cpp b/src/INTERLAYER/pair_ilp_graphene_hbn.cpp index 49b2adbd33..17f2260af4 100644 --- a/src/INTERLAYER/pair_ilp_graphene_hbn.cpp +++ b/src/INTERLAYER/pair_ilp_graphene_hbn.cpp @@ -47,11 +47,11 @@ using namespace InterLayer; static const char cite_ilp[] = "ilp/graphene/hbn potential doi:10.1021/acs.nanolett.8b02848\n" "@Article{Ouyang2018\n" - " author = {W. Ouyang, D. Mandelli, M. Urbakh, and O. Hod},\n" + " author = {W. Ouyang and D. Mandelli and M. Urbakh and O. Hod},\n" " title = {Nanoserpents: Graphene Nanoribbon Motion on Two-Dimensional Hexagonal Materials},\n" " journal = {Nano Letters},\n" " volume = 18,\n" - " pages = {6009}\n" + " pages = 6009,\n" " year = 2018,\n" "}\n\n"; diff --git a/src/INTERLAYER/pair_ilp_tmd.cpp b/src/INTERLAYER/pair_ilp_tmd.cpp index 52119cbf12..e80f542716 100644 --- a/src/INTERLAYER/pair_ilp_tmd.cpp +++ b/src/INTERLAYER/pair_ilp_tmd.cpp @@ -42,17 +42,18 @@ using namespace InterLayer; #define DELTA 4 #define PGDELTA 1 -static const char cite_ilp_tmd[] = "ilp/tmd potential doi/10.1021/acs.jctc.1c00782\n" - "@Article{Ouyang2021\n" - " author = {W. Ouyang, R. Sofer, X. Gao, J. Hermann, A. " - "Tkatchenko, L. Kronik, M. Urbakh, and O. Hod},\n" - " title = {Anisotropic Interlayer Force Field for Transition " - "Metal Dichalcogenides: The Case of Molybdenum Disulfide},\n" - " journal = {J. Chem. Theory Comput.},\n" - " volume = 17,\n" - " pages = {7237–7245}\n" - " year = 2021,\n" - "}\n\n"; +static const char cite_ilp_tmd[] = +"ilp/tmd potential doi:10.1021/acs.jctc.1c00782\n" + "@Article{Ouyang2021\n" + " author = {W. Ouyang and R. Sofer and X. Gao and J. Hermann and\n" + " A. Tkatchenko and L. Kronik and M. Urbakh and O. Hod},\n" + " title = {Anisotropic Interlayer Force Field for Transition\n" + " Metal Dichalcogenides: The Case of Molybdenum Disulfide},\n" + " journal = {J.~Chem.\\ Theory Comput.},\n" + " volume = 17,\n" + " pages = {7237--7245}\n" + " year = 2021,\n" + "}\n\n"; /* ---------------------------------------------------------------------- */ diff --git a/src/INTERLAYER/pair_kolmogorov_crespi_full.cpp b/src/INTERLAYER/pair_kolmogorov_crespi_full.cpp index 116018f18a..0f9dd9ec47 100644 --- a/src/INTERLAYER/pair_kolmogorov_crespi_full.cpp +++ b/src/INTERLAYER/pair_kolmogorov_crespi_full.cpp @@ -47,7 +47,7 @@ using namespace InterLayer; static const char cite_kc[] = "kolmogorov/crespi/full potential doi:10.1021/acs.nanolett.8b02848\n" "@Article{Ouyang2018\n" - " author = {W. Ouyang, D. Mandelli, M. Urbakh, and O. Hod},\n" + " author = {W. Ouyang and D. Mandelli and M. Urbakh and O. Hod},\n" " title = {Nanoserpents: Graphene Nanoribbon Motion on Two-Dimensional Hexagonal Materials},\n" " journal = {Nano Letters},\n" " volume = 18,\n" diff --git a/src/INTERLAYER/pair_saip_metal.cpp b/src/INTERLAYER/pair_saip_metal.cpp index bb23cad840..4e768a9168 100644 --- a/src/INTERLAYER/pair_saip_metal.cpp +++ b/src/INTERLAYER/pair_saip_metal.cpp @@ -40,13 +40,13 @@ using namespace InterLayer; #define PGDELTA 1 static const char cite_saip[] = - "saip/metal potential doi.org/10.1021/acs.jctc.1c00622\n" + "saip/metal potential: doi:10.1021/acs.jctc.1c00622\n\n" "@Article{Ouyang2021\n" - " author = {W. Ouyang, O. Hod, and R. Guerra},\n" + " author = {W. Ouyang and O. Hod and R. Guerra},\n" " title = {Registry-Dependent Potential for Interfaces of Gold with Graphitic Systems},\n" - " journal = {J. Chem. Theory Comput.},\n" + " journal = {J.~Chem.\\ Theory Comput.},\n" " volume = 17,\n" - " pages = {7215-7223}\n" + " pages = {7215--7223}\n" " year = 2021,\n" "}\n\n"; diff --git a/src/KIM/kim_command.cpp b/src/KIM/kim_command.cpp index 06b651e377..b93b87fa7c 100644 --- a/src/KIM/kim_command.cpp +++ b/src/KIM/kim_command.cpp @@ -70,7 +70,7 @@ using namespace LAMMPS_NS; static constexpr const char *const cite_openkim = - "OpenKIM: https://doi.org/10.1007/s11837-011-0102-6\n\n" + "OpenKIM Project: doi:10.1007/s11837-011-0102-6\n\n" "@Article{tadmor:elliott:2011,\n" " author = {E. B. Tadmor and R. S. Elliott and J. P. Sethna and R. E. Miller " "and C. A. Becker},\n" @@ -85,7 +85,7 @@ static constexpr const char *const cite_openkim = "}\n\n"; static constexpr const char *const cite_openkim_query = - "OpenKIM query: https://doi.org/10.1063/5.0014267\n\n" + "OpenKIM query: doi:10.1063/5.0014267\n\n" "@Article{karls:bierbaum:2020,\n" " author = {D. S. Karls and M. Bierbaum and A. A. Alemi and R. S. Elliott " "and J. P. Sethna and E. B. Tadmor},\n" diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index f3b53ac71f..d496ffde04 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -77,7 +77,7 @@ using namespace LAMMPS_NS; static constexpr const char *const cite_openkim = - "OpenKIM: https://doi.org/10.1007/s11837-011-0102-6\n\n" + "OpenKIM Project: doi:10.1007/s11837-011-0102-6\n\n" "@Article{tadmor:elliott:2011,\n" " author = {E. B. Tadmor and R. S. Elliott and J. P. Sethna and R. E. Miller " "and C. A. Becker},\n" diff --git a/src/KOKKOS/comm_kokkos.cpp b/src/KOKKOS/comm_kokkos.cpp index fea5864225..527ac2c174 100644 --- a/src/KOKKOS/comm_kokkos.cpp +++ b/src/KOKKOS/comm_kokkos.cpp @@ -125,19 +125,19 @@ void CommKokkos::init() if (force->pair && (force->pair->execution_space == Host)) check_reverse += force->pair->comm_reverse; - for (int i = 0; i < modify->nfix; i++) { - check_forward += modify->fix[i]->comm_forward; - check_reverse += modify->fix[i]->comm_reverse; + for (const auto &fix : modify->get_fix_list()) { + check_forward += fix->comm_forward; + check_reverse += fix->comm_reverse; } - for (int i = 0; i < modify->ncompute; i++) { - check_forward += modify->compute[i]->comm_forward; - check_reverse += modify->compute[i]->comm_reverse; + for (const auto &compute : modify->get_compute_list()) { + check_forward += compute->comm_forward; + check_reverse += compute->comm_reverse; } - for (int i = 0; i < output->ndump; i++) { - check_forward += output->dump[i]->comm_forward; - check_reverse += output->dump[i]->comm_reverse; + for (const auto &dump : output->get_dump_list()) { + check_forward += dump->comm_forward; + check_reverse += dump->comm_reverse; } if (force->newton == 0) check_reverse = 0; diff --git a/src/KOKKOS/fix_shake_kokkos.cpp b/src/KOKKOS/fix_shake_kokkos.cpp index a24c47c1e2..d622da94ec 100644 --- a/src/KOKKOS/fix_shake_kokkos.cpp +++ b/src/KOKKOS/fix_shake_kokkos.cpp @@ -12,12 +12,8 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include -#include -#include -#include -#include #include "fix_shake_kokkos.h" + #include "fix_rattle.h" #include "atom_kokkos.h" #include "atom_vec.h" @@ -38,6 +34,9 @@ #include "kokkos.h" #include "atom_masks.h" +#include +#include + using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; @@ -181,6 +180,16 @@ void FixShakeKokkos::init() } +/* ---------------------------------------------------------------------- + run setup for minimization. +------------------------------------------------------------------------- */ + +template +void FixShakeKokkos::min_setup(int /*vflag*/) +{ + error->all(FLERR, "Cannot yet use fix {} during minimization with Kokkos", style); +} + /* ---------------------------------------------------------------------- build list of SHAKE clusters to constrain if one or more atoms in cluster are on this proc, @@ -193,6 +202,7 @@ void FixShakeKokkos::pre_neighbor() // local copies of atom quantities // used by SHAKE until next re-neighboring + ebond = 0.0; x = atom->x; v = atom->v; f = atom->f; @@ -292,7 +302,7 @@ void FixShakeKokkos::pre_neighbor() if (h_error_flag() == 1) { error->one(FLERR,"Shake atoms missing on proc " - "{} at step {}",me,update->ntimestep); + "{} at step {}",comm->me,update->ntimestep); } } @@ -303,6 +313,7 @@ void FixShakeKokkos::pre_neighbor() template void FixShakeKokkos::post_force(int vflag) { + ebond = 0.0; copymode = 1; d_x = atomKK->k_x.view(); @@ -341,7 +352,7 @@ void FixShakeKokkos::post_force(int vflag) // communicate results if necessary unconstrained_update(); - if (nprocs > 1) comm->forward_comm(this); + if (comm->nprocs > 1) comm->forward_comm(this); k_xshake.sync(); // virial setup @@ -1702,7 +1713,7 @@ void FixShakeKokkos::correct_coordinates(int vflag) { double **xtmp = xshake; xshake = x; - if (nprocs > 1) { + if (comm->nprocs > 1) { forward_comm_device = 0; comm->forward_comm(this); forward_comm_device = 1; diff --git a/src/KOKKOS/fix_shake_kokkos.h b/src/KOKKOS/fix_shake_kokkos.h index 027b36b100..df5256422f 100644 --- a/src/KOKKOS/fix_shake_kokkos.h +++ b/src/KOKKOS/fix_shake_kokkos.h @@ -51,6 +51,7 @@ class FixShakeKokkos : public FixShake, public KokkosBase { FixShakeKokkos(class LAMMPS *, int, char **); ~FixShakeKokkos() override; void init() override; + void min_setup(int) override; void pre_neighbor() override; void post_force(int) override; diff --git a/src/LATBOLTZ/fix_lb_fluid.cpp b/src/LATBOLTZ/fix_lb_fluid.cpp index e3662b338b..049d9ce44e 100644 --- a/src/LATBOLTZ/fix_lb_fluid.cpp +++ b/src/LATBOLTZ/fix_lb_fluid.cpp @@ -45,11 +45,11 @@ using namespace FixConst; static const char cite_fix_lbfluid[] = "fix lb/fluid command: doi:10.1016/j.cpc.2022.108318\n\n" "@Article{Denniston et al.,\n" - " author = {C. Denniston, N. Afrasiabian, M.G. Cole-Andre," - "F.E. Mackay, S.T.T. Ollila, T. Whitehead},\n" - " title = {LAMMPS lb/fluid fix version 2: Improved Hydrodynamic " - "Forces Implemented into LAMMPS through a lattice-Boltzmann fluid}," - " journal = {Comp.~Phys.~Comm.},\n" + " author = {C. Denniston and N. Afrasiabian and M. G. Cole-Andre," + " F. E. Mackay and S. T. T. Ollila and T. Whitehead},\n" + " title = {{LAMMPS} lb/fluid fix version 2: Improved Hydrodynamic " + " Forces Implemented into {LAMMPS} Through a Lattice-{B}oltzmann Fluid}," + " journal = {Comput.\\ Phys.\\ Commun.},\n" " year = 2022,\n" " volume = 275,\n" " pages = {108318}\n" diff --git a/src/MANIFOLD/fix_nve_manifold_rattle.cpp b/src/MANIFOLD/fix_nve_manifold_rattle.cpp index f9a728cb73..1ccf7c2e04 100644 --- a/src/MANIFOLD/fix_nve_manifold_rattle.cpp +++ b/src/MANIFOLD/fix_nve_manifold_rattle.cpp @@ -55,7 +55,7 @@ using namespace user_manifold; enum { CONST, EQUAL }; // For treating the variables. static const char* cite_fix_nve_manifold_rattle = - "fix nve/manifold/rattle command:\n\n" + "fix nve/manifold/rattle command: doi:10.1016/j.bpj.2016.02.017\n\n" "@article{paquay-2016,\n" " author = {Paquay, Stefan and Kusters, Remy},\n" " doi = {10.1016/j.bpj.2016.02.017},\n" diff --git a/src/MANIFOLD/fix_nvt_manifold_rattle.cpp b/src/MANIFOLD/fix_nvt_manifold_rattle.cpp index 6dbd211042..a7b2c5ed37 100644 --- a/src/MANIFOLD/fix_nvt_manifold_rattle.cpp +++ b/src/MANIFOLD/fix_nvt_manifold_rattle.cpp @@ -59,7 +59,7 @@ enum {NOBIAS,BIAS}; static const char* cite_fix_nvt_manifold_rattle = - "fix nvt/manifold/rattle command:\n\n" + "fix nvt/manifold/rattle command: doi:10.1016/j.bpj.2016.02.017\n\n" "@article{paquay-2016,\n" " author = {Paquay, Stefan and Kusters, Remy},\n" " doi = {10.1016/j.bpj.2016.02.017},\n" diff --git a/src/MANYBODY/pair_atm.cpp b/src/MANYBODY/pair_atm.cpp index 4b61e575a3..9e125c3403 100644 --- a/src/MANYBODY/pair_atm.cpp +++ b/src/MANYBODY/pair_atm.cpp @@ -32,13 +32,14 @@ using namespace LAMMPS_NS; static const char cite_atm_package[] = - "ATM package:\n\n" + "ATM package: doi:10.1063/1.4704930\n\n" "@Article{Lishchuk:2012:164501,\n" " author = {S. V. Lishchuk},\n" - " title = {Role of three-body interactions in formation of bulk viscosity in liquid argon},\n" - " journal = {J.~Chem.~Phys.},\n" + " title = {Role of Three-Body Interactions in Formation of Bulk Viscosity in Liquid Argon},\n" + " journal = {J.~Chem.\\ Phys.},\n" " year = 2012,\n" " volume = 136,\n" + " number = 16,\n" " pages = {164501}\n" "}\n\n"; diff --git a/src/MANYBODY/pair_edip_multi.cpp b/src/MANYBODY/pair_edip_multi.cpp index cb50426033..e51e92893d 100644 --- a/src/MANYBODY/pair_edip_multi.cpp +++ b/src/MANYBODY/pair_edip_multi.cpp @@ -42,18 +42,20 @@ using namespace MathExtra; #define DELTA 4 static const char cite_pair_edip[] = + "pair edip/multi: doi:10.1103/PhysRevB.86.144118, doi:10.1088/0953-8984/22/3/035802\n\n" "@article{cjiang2012\n" " author = {Jian, Chao and Morgan, Dane, and Szlufarska, Izabella},\n" - " title = {Carbon tri-interstitial defect: A model for DII center},\n" - " journal = {Physical Review B},\n" + " title = {Carbon Tri-Interstitial Defect: {A} Model for {D$_{\\mathrm{II}}$} Center},\n" + " journal = {Phys.\\ Rev.~B},\n" " volume = {86},\n" " pages = {144118},\n" " year = {2012},\n" "}\n\n" "@article{lpizzagalli2010,\n" - " author = {G. Lucas, M. Bertolus, and L. Pizzagalli},\n" - " journal = {J. Phys. : Condens. Matter 22},\n" + " author = {G. Lucas and M. Bertolus and L. Pizzagalli},\n" + " journal = {J.~Phys.\\ Condens.\\ Matter},\n" " volume = {22},\n" + " number = 3,\n" " pages = {035802},\n" " year = {2010},\n" "}\n\n"; diff --git a/src/MANYBODY/pair_local_density.cpp b/src/MANYBODY/pair_local_density.cpp index d8bfd9d03a..789b1ddad9 100644 --- a/src/MANYBODY/pair_local_density.cpp +++ b/src/MANYBODY/pair_local_density.cpp @@ -37,20 +37,20 @@ using namespace LAMMPS_NS; #define MAXLINE 1024 static const char cite_pair_local_density[] = - "pair_style local/density command:\n\n" + "pair_style local/density command: doi:10.1063/1.4958629, doi:10.1021/acs.jpcb.7b12446\n\n" "@Article{Sanyal16,\n" - " author = {T.Sanyal and M.Scott Shell},\n" - " title = {Coarse-grained models using local-density potentials optimized with the relative entropy: Application to implicit solvation},\n" - " journal = {J.~Chem.~Phys.},\n" + " author = {T. Sanyal and M. Scott Shell},\n" + " title = {Coarse-Grained Models Using Local-Density Potentials Optimized With the Relative Entropy: {A}pplication to Implicit Solvation},\n" + " journal = {J.~Chem.\\ Phys.},\n" " year = 2016,\n" - " DOI = doi.org/10.1063/1.4958629" + " DOI = {10.1063/1.4958629}" "}\n\n" "@Article{Sanyal18,\n" - " author = {T.Sanyal and M.Scott Shell},\n" - " title = {Transferable coarse-grained models of liquid-liquid equilibrium using local density potentials optimized with the relative entropy},\n" - " journal = {J.~Phys.~Chem. B},\n" + " author = {T. Sanyal and M. Scott Shell},\n" + " title = {Transferable Coarse-Grained Models of Liquid-Liquid Equilibrium Using Local Density Potentials Optimized with the Relative Entropy},\n" + " journal = {J.~Phys.\\ Chem.~B},\n" " year = 2018,\n" - " DOI = doi.org/10.1021/acs.jpcb.7b12446" + " DOI = {10.1021/acs.jpcb.7b12446}" "}\n\n"; /* ---------------------------------------------------------------------- */ diff --git a/src/MC/fix_bond_swap.cpp b/src/MC/fix_bond_swap.cpp index 59fabc8ffe..6a7ab6dbb7 100644 --- a/src/MC/fix_bond_swap.cpp +++ b/src/MC/fix_bond_swap.cpp @@ -39,13 +39,14 @@ using namespace LAMMPS_NS; using namespace FixConst; static const char cite_fix_bond_swap[] = - "fix bond/swap command:\n\n" + "fix bond/swap command: doi:10.1063/1.1628670\n\n" "@Article{Auhl03,\n" - " author = {R. Auhl, R. Everaers, G. S. Grest, K. Kremer, S. J. Plimpton},\n" - " title = {Equilibration of long chain polymer melts in computer simulations},\n" - " journal = {J.~Chem.~Phys.},\n" + " author = {R. Auhl and R. Everaers and G. S. Grest and K. Kremer and S. J. Plimpton},\n" + " title = {Equilibration of Long Chain Polymer Melts in Computer Simulations},\n" + " journal = {J.~Chem.\\ Phys.},\n" " year = 2003,\n" " volume = 119,\n" + " number = 12,\n" " pages = {12718--12728}\n" "}\n\n"; diff --git a/src/MC/fix_charge_regulation.cpp b/src/MC/fix_charge_regulation.cpp index 81f722bb6c..795ccb75d1 100644 --- a/src/MC/fix_charge_regulation.cpp +++ b/src/MC/fix_charge_regulation.cpp @@ -54,11 +54,11 @@ using namespace MathConst; using namespace MathSpecial; static const char cite_fix_charge_regulation[] = - "fix charge/regulation: \n\n" + "fix charge/regulation: doi:10.1063/5.0066432\n\n" "@Article{Curk22,\n" - " author = {T. Curk, J. Yuan, E. Luijten},\n" - " title = {Accelerated simulation method for charge regulation effects},\n" - " journal = {The Journal of Chemical Physics},\n" + " author = {T. Curk and J. Yuan and E. Luijten},\n" + " title = {Accelerated Simulation Method for Charge Regulation Effects},\n" + " journal = {Journal of Chemical Physics},\n" " year = 2022,\n" " volume = 156\n" "}\n\n"; diff --git a/src/MC/fix_gcmc.cpp b/src/MC/fix_gcmc.cpp index 835d049bc6..0cc6590d5a 100644 --- a/src/MC/fix_gcmc.cpp +++ b/src/MC/fix_gcmc.cpp @@ -177,7 +177,7 @@ FixGCMC::FixGCMC(LAMMPS *lmp, int narg, char **arg) : if (atom->molecular == Atom::TEMPLATE && onemols != atom->avec->onemols) error->all(FLERR,"Fix gcmc molecule template ID must be same " "as atom_style template ID"); - onemols[imol]->check_attributes(0); + onemols[imol]->check_attributes(); } if (charge_flag && atom->q == nullptr) diff --git a/src/MC/fix_widom.cpp b/src/MC/fix_widom.cpp index 0a20e7adf3..d1bc5dfa58 100644 --- a/src/MC/fix_widom.cpp +++ b/src/MC/fix_widom.cpp @@ -153,7 +153,7 @@ FixWidom::FixWidom(LAMMPS *lmp, int narg, char **arg) : if (atom->molecular == Atom::TEMPLATE && onemols != atom->avec->onemols) error->all(FLERR,"Fix widom molecule template ID must be same " "as atom_style template ID"); - onemols[imol]->check_attributes(0); + onemols[imol]->check_attributes(); } if (charge_flag && atom->q == nullptr) diff --git a/src/MISC/pair_agni.cpp b/src/MISC/pair_agni.cpp index ee744173fc..3c309d578b 100644 --- a/src/MISC/pair_agni.cpp +++ b/src/MISC/pair_agni.cpp @@ -37,13 +37,13 @@ using namespace LAMMPS_NS; using namespace MathSpecial; static const char cite_pair_agni[] = - "pair agni command:\n\n" + "pair agni command: doi:10.1021/acs.jpcc.9b04207\n\n" "@article{huan2019jpc,\n" " author = {Huan, T. and Batra, R. and Chapman, J. and Kim, C. and Chandrasekaran, A. and Ramprasad, Rampi},\n" - " journal = {J. Phys. Chem. C},\n" - " volume = {121},\n" + " journal = {J.~Phys.\\ Chem.~C},\n" + " volume = {123},\n" " number = {34},\n" - " pages = {20715},\n" + " pages = {20715--20722},\n" " year = {2019},\n" "}\n\n"; diff --git a/src/MISC/pair_srp.cpp b/src/MISC/pair_srp.cpp index bb731cdc32..1c95caadc2 100644 --- a/src/MISC/pair_srp.cpp +++ b/src/MISC/pair_srp.cpp @@ -52,10 +52,11 @@ using namespace LAMMPS_NS; #define ONETWOBIT 0x40000000 static const char cite_srp[] = + "pair srp command: doi:10.1063/1.3698476\n\n" "@Article{Sirk2012\n" - " author = {T. Sirk and Y. Sliozberg and J. Brennan and M. Lisal and J. Andzelm},\n" - " title = {An enhanced entangled polymer model for dissipative particle dynamics},\n" - " journal = {J.~Chem.~Phys.},\n" + " author = {T. W. Sirk and Y. R. Sliozberg and J. K. Brennan and M. Lisal and J. W. Andzelm},\n" + " title = {An Enhanced Entangled Polymer Model for Dissipative Particle Dynamics},\n" + " journal = {J.~Chem.\\ Phys.},\n" " year = 2012,\n" " volume = 136,\n" " pages = {134903}\n" diff --git a/src/MISC/pair_srp_react.cpp b/src/MISC/pair_srp_react.cpp index f486aa33b7..25975c7fb0 100644 --- a/src/MISC/pair_srp_react.cpp +++ b/src/MISC/pair_srp_react.cpp @@ -47,13 +47,15 @@ There is an example script for this package in examples/PACKAGES/srp_react/. using namespace LAMMPS_NS; static const char cite_srpreact[] = + "pair srp/react style: doi:10.1021/acs.jpcb.1c09570\n\n" "@Article{palkar2022\n" " author = {Palkar, Vaibhav and Kuksenok, Olga},\n" " title = {Controlling Degradation and Erosion of Polymer Networks: Insights from Mesoscale Modeling},\n" - " journal = {J. Phys. Chem. B},\n" - " year = {2022},\n" - " volume = {126},\n" - " pages = {336-346}\n" + " journal = {J.~Phys.\\ Chem.~B},\n" + " year = 2022,\n" + " volume = 126,\n" + " number = 1,\n" + " pages = {336--346}\n" "}\n\n"; static int srp_instance = 0; diff --git a/src/MISC/pair_srp_react.h b/src/MISC/pair_srp_react.h index 95a8163900..a6e4cebb6f 100644 --- a/src/MISC/pair_srp_react.h +++ b/src/MISC/pair_srp_react.h @@ -34,7 +34,7 @@ class PairSRPREACT : public PairSRP { private: char *idbreak; char *idcreate; - bool bond_create, bond_break; + bool bond_break, bond_create; }; } // namespace LAMMPS_NS #endif diff --git a/src/ML-HDNNP/pair_hdnnp.cpp b/src/ML-HDNNP/pair_hdnnp.cpp index eb79a396b2..6873f76779 100644 --- a/src/ML-HDNNP/pair_hdnnp.cpp +++ b/src/ML-HDNNP/pair_hdnnp.cpp @@ -36,17 +36,17 @@ using namespace LAMMPS_NS; static const char cite_user_hdnnp_package[] = - "ML-HDNNP package: 10.1021/acs.jctc.8b00770\n\n" + "ML-HDNNP package: doi:10.1021/acs.jctc.8b00770\n\n" "@Article{Singraber19,\n" " author = {Singraber, Andreas and Behler, J{\"o}rg and Dellago, Christoph},\n" - " title = {Library-{{Based LAMMPS Implementation}} of {{High}}-{{Dimensional Neural Network " - "Potentials}}},\n" + " title = {Library-Based {LAMMPS} Implementation of High-Dimensional\n" + " Neural Network Potentials},\n" " year = {2019},\n" " month = mar,\n" " volume = {15},\n" " pages = {1827--1840},\n" " doi = {10.1021/acs.jctc.8b00770},\n" - " journal = {J.~Chem.~Theory~Comput.},\n" + " journal = {J.~Chem.\\ Theory Comput.},\n" " number = {3}\n" "}\n\n"; diff --git a/src/ML-RANN/pair_rann.cpp b/src/ML-RANN/pair_rann.cpp index d20a750ff8..8eb95f6dfb 100644 --- a/src/ML-RANN/pair_rann.cpp +++ b/src/ML-RANN/pair_rann.cpp @@ -60,14 +60,14 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 using namespace LAMMPS_NS; static const char cite_ml_rann_package[] = - "ML-RANN package:\n\n" + "ML-RANN package: doi:10.1016/j.commatsci.2020.110207\n\n" "@Article{Nitol2021,\n" " author = {Nitol, Mashroor S and Dickel, Doyl E and Barrett, Christopher D},\n" - " title = {Artificial neural network potential for pure zinc},\n" + " title = {Artificial Neural Network Potential for Pure Zinc},\n" " journal = {Computational Materials Science},\n" " year = 2021,\n" " volume = 188,\n" - " pages = {110207}\n" + " pages = 110207\n" "}\n\n"; diff --git a/src/ML-SNAP/compute_snap.cpp b/src/ML-SNAP/compute_snap.cpp index 5d2f3666bc..11b17ebcb2 100644 --- a/src/ML-SNAP/compute_snap.cpp +++ b/src/ML-SNAP/compute_snap.cpp @@ -539,18 +539,18 @@ void ComputeSnap::compute_array() for (int icoeff = 0; icoeff < ncoeff; icoeff++) snap[irow][k++] += snaptr->blist[icoeff]; - // quadratic contributions + // quadratic contributions - if (quadraticflag) { - for (int icoeff = 0; icoeff < ncoeff; icoeff++) { - double bveci = snaptr->blist[icoeff]; - snap[irow][k++] += 0.5*bveci*bveci; - for (int jcoeff = icoeff+1; jcoeff < ncoeff; jcoeff++) { - double bvecj = snaptr->blist[jcoeff]; - snap[irow][k++] += bveci*bvecj; - } + if (quadraticflag) { + for (int icoeff = 0; icoeff < ncoeff; icoeff++) { + double bveci = snaptr->blist[icoeff]; + snap[irow][k++] += 0.5*bveci*bveci; + for (int jcoeff = icoeff+1; jcoeff < ncoeff; jcoeff++) { + double bvecj = snaptr->blist[jcoeff]; + snap[irow][k++] += bveci*bvecj; } } + } } else { int k = 3; diff --git a/src/MPIIO/dump_custom_mpiio.cpp b/src/MPIIO/dump_custom_mpiio.cpp index f07c1e19d6..678ee3dadd 100644 --- a/src/MPIIO/dump_custom_mpiio.cpp +++ b/src/MPIIO/dump_custom_mpiio.cpp @@ -231,10 +231,12 @@ void DumpCustomMPIIO::init_style() // lo priority = line, medium priority = int/float, hi priority = column auto words = utils::split_words(format); - if ((int) words.size() < nfield) error->all(FLERR, "Dump_modify format line is too short"); + if ((int) words.size() < nfield) + error->all(FLERR, "Dump_modify format line is too short: {}", format); int i = 0; for (const auto &word : words) { + if (i >= nfield) break; delete[] vformat[i]; if (format_column_user[i]) diff --git a/src/OPENMP/pair_reaxff_omp.cpp b/src/OPENMP/pair_reaxff_omp.cpp index f10f5885bd..7112681b06 100644 --- a/src/OPENMP/pair_reaxff_omp.cpp +++ b/src/OPENMP/pair_reaxff_omp.cpp @@ -63,12 +63,14 @@ using namespace LAMMPS_NS; using namespace ReaxFF; static const char cite_pair_reaxff_omp[] = - "pair reaxff/omp and fix qeq/reaxff/omp command:\n\n" + "pair reaxff/omp and fix qeq/reaxff/omp command: doi:10.1177/1094342017746221\n\n" "@Article{Aktulga17,\n" - " author = {H. M. Aktulga, C. Knight, P. Coffman, K. A. OHearn, T. R. Shan, W. Jiang},\n" - " title = {Optimizing the performance of reactive molecular dynamics simulations for multi-core architectures},\n" + " author = {H. M. Aktulga and C. Knight and P. Coffman and\n" + " K. A. O'Hearn and T. R. Shan and W. Jiang},\n" + " title = {Optimizing the Performance of Reactive Molecular Dynamics\n" + " Simulations for Multi-Core Architectures},\n" " journal = {International Journal of High Performance Computing Applications},\n" - " year = to appear\n" + " year = 2018\n" "}\n\n"; /* ---------------------------------------------------------------------- */ diff --git a/src/OPT/pair_ilp_graphene_hbn_opt.cpp b/src/OPT/pair_ilp_graphene_hbn_opt.cpp index 36fac54f52..953340ff5d 100644 --- a/src/OPT/pair_ilp_graphene_hbn_opt.cpp +++ b/src/OPT/pair_ilp_graphene_hbn_opt.cpp @@ -39,10 +39,10 @@ using namespace LAMMPS_NS; using namespace InterLayer; static const char cite_ilp_cur[] = - "ilp/graphene/hbn/opt potential doi:10.1145/3458817.3476137\n" + "ilp/graphene/hbn/opt potential: doi:10.1145/3458817.3476137\n" "@inproceedings{gao2021lmff\n" - " author = {Gao, Ping and Duan, Xiaohui and Others},\n" - " title = {LMFF: Efficient and Scalable Layered Materials Force Field on Heterogeneous " + " author = {Gao, Ping and Duan, Xiaohui and others},\n" + " title = {{LMFF}: Efficient and Scalable Layered Materials Force Field on Heterogeneous " "Many-Core Processors},\n" " year = {2021},\n" " isbn = {9781450384421},\n" @@ -52,9 +52,9 @@ static const char cite_ilp_cur[] = " doi = {10.1145/3458817.3476137},\n" " booktitle = {Proceedings of the International Conference for High Performance Computing, " "Networking, Storage and Analysis},\n" - " articleno = {42},\n" + " pages = {42},\n" " numpages = {14},\n" - " location = {St. Louis, Missouri},\n" + " location = {St.~Louis, Missouri},\n" " series = {SC'21},\n" "}\n\n"; diff --git a/src/ORIENT/fix_orient_bcc.cpp b/src/ORIENT/fix_orient_bcc.cpp index 919927ea07..c8979794e8 100644 --- a/src/ORIENT/fix_orient_bcc.cpp +++ b/src/ORIENT/fix_orient_bcc.cpp @@ -41,14 +41,15 @@ using namespace MathConst; #define BIG 1000000000 static const char cite_fix_orient_bcc[] = - "fix orient/bcc command:\n\n" + "fix orient/bcc command: doi:10.1016/j.commatsci.2016.02.016\n\n" "@Article{Wicaksono16,\n" - " author = {A. T. Wicaksono, C. W. Sinclair, M. Militzer},\n" - " title = {An atomistic study of the correlation between the migration of planar and curved grain boundaries},\n" - " journal = {Computational Materials Science},\n" - " year = 2016,\n" - " volume = 117,\n" - " pages = {397--405}\n" + " author = {A. T. Wicaksono and C. W. Sinclair and M. Militzer},\n" + " title = {An Atomistic Study of the Correlation Between the Migration\n" + " of Planar and Curved Grain Boundaries},\n" + " journal = {Computational Materials Science},\n" + " year = 2016,\n" + " volume = 117,\n" + " pages = {397--405}\n" "}\n\n"; /* ---------------------------------------------------------------------- */ diff --git a/src/ORIENT/fix_orient_eco.cpp b/src/ORIENT/fix_orient_eco.cpp index 7c8ff1f6aa..5f725a9e06 100644 --- a/src/ORIENT/fix_orient_eco.cpp +++ b/src/ORIENT/fix_orient_eco.cpp @@ -38,10 +38,10 @@ using namespace FixConst; using namespace MathConst; static const char cite_fix_orient_eco[] = - "fix orient/eco command:\n\n" + "fix orient/eco command: doi:j.commatsci.2020.109774\n\n" "@Article{Schratt20,\n" - " author = {A. A. Schratt, V. Mohles},\n" - " title = {Efficient calculation of the ECO driving force for atomistic simulations of grain boundary motion},\n" + " author = {A. A. Schratt and V. Mohles},\n" + " title = {Efficient Calculation of the {ECO} Driving Force for Atomistic Simulations of Grain Boundary Motion},\n" " journal = {Computational Materials Science},\n" " volume = {182},\n" " year = {2020},\n" diff --git a/src/ORIENT/fix_orient_fcc.cpp b/src/ORIENT/fix_orient_fcc.cpp index f64889d141..069d4b58fc 100644 --- a/src/ORIENT/fix_orient_fcc.cpp +++ b/src/ORIENT/fix_orient_fcc.cpp @@ -38,7 +38,7 @@ using namespace MathConst; #define BIG 1000000000 static const char cite_fix_orient_fcc[] = - "fix orient/fcc command:\n\n" + "fix orient/fcc command: doi:10.1038/nmat1559\n\n" "@Article{Janssens06,\n" " author = {K. G. F. Janssens, D. Olmsted, E.A. Holm, S. M. Foiles, S. J. Plimpton, and P. M. Derlet},\n" " title = {Computing the Mobility of Grain Boundaries},\n" diff --git a/src/PERI/atom_vec_peri.cpp b/src/PERI/atom_vec_peri.cpp index fd6b47990a..20eeef3042 100644 --- a/src/PERI/atom_vec_peri.cpp +++ b/src/PERI/atom_vec_peri.cpp @@ -26,13 +26,14 @@ using namespace LAMMPS_NS; static const char cite_peri_package[] = - "PERI package for Peridynamics:\n\n" + "PERI package for Peridynamics: doi:10.1016/j.cpc.2008.06.011\n\n" "@Article{Parks08,\n" - " author = {M. L. Parks, R. B. Lehoucq, S. J. Plimpton, S. A. Silling},\n" - " title = {Implementing peridynamics within a molecular dynamics code},\n" - " journal = {Comp.~Phys.~Comm.},\n" + " author = {M. L. Parks and R. B. Lehoucq and S. J. Plimpton and S. A. Silling},\n" + " title = {Implementing Peridynamics Within a Molecular Dynamics Code},\n" + " journal = {Comput.\\ Phys.\\ Commun.},\n" " year = 2008,\n" " volume = 179,\n" + " number = 11,\n" " pages = {777--783}\n" "}\n\n"; diff --git a/src/PHONON/fix_phonon.cpp b/src/PHONON/fix_phonon.cpp index b5774ad97c..3b4f182a16 100644 --- a/src/PHONON/fix_phonon.cpp +++ b/src/PHONON/fix_phonon.cpp @@ -50,11 +50,11 @@ using namespace FixConst; enum{FORWARD=-1,BACKWARD=1}; static const char cite_fix_phonon[] = - "fix phonon command:\n\n" + "fix phonon command: doi:10.1016/j.cpc.2011.04.019\n\n" "@Article{Kong11,\n" " author = {L. T. Kong},\n" - " title = {Phonon dispersion measured directly from molecular dynamics simulations},\n" - " journal = {Comp.~Phys.~Comm.},\n" + " title = {Phonon Dispersion Measured Directly from Molecular Dynamics Simulations},\n" + " journal = {Comput.\\ Phys.\\ Commun.},\n" " year = 2011,\n" " volume = 182,\n" " pages = {2201--2207}\n" diff --git a/src/POEMS/fix_poems.cpp b/src/POEMS/fix_poems.cpp index 20e0b7cc6b..b2b0366b9e 100644 --- a/src/POEMS/fix_poems.cpp +++ b/src/POEMS/fix_poems.cpp @@ -47,14 +47,15 @@ using namespace FixConst; #define EPSILON 1.0e-7 static const char cite_fix_poems[] = - "fix poems command:\n\n" + "fix poems command: doi:10.1016/j.ijnonlinmec.2008.04.003\n\n" "@Article{Mukherjee08,\n" - " author = {R. M. Mukherjee, P. S. Crozier, S. J. Plimpton, K. S. Anderson},\n" - " title = {Substructured molecular dynamics using multibody dynamics algorithms},\n" - " journal = {Intl.~J.~Non-linear Mechanics},\n" + " author = {R. M. Mukherjee and P. S. Crozier and S. J. Plimpton and K. S. Anderson},\n" + " title = {Substructured Molecular Dynamics Using Multibody Dynamics Algorithms},\n" + " journal = {Intl.\\ J.\\ Non-Linear Mechanics},\n" " year = 2008,\n" " volume = 43,\n" - " pages = {1045--1055}\n" + " number = 10,\n" + " pages = {1040--1055}\n" "}\n\n"; /* ---------------------------------------------------------------------- diff --git a/src/PTM/compute_ptm_atom.cpp b/src/PTM/compute_ptm_atom.cpp index 10341d3cd0..676144eb42 100644 --- a/src/PTM/compute_ptm_atom.cpp +++ b/src/PTM/compute_ptm_atom.cpp @@ -47,13 +47,13 @@ under using namespace LAMMPS_NS; static const char cite_user_ptm_package[] = - "PTM package:\n\n" + "PTM package: doi:10.1088/0965-0393/24/5/055007\n\n" "@Article{larsen2016ptm,\n" - " author={Larsen, Peter Mahler and Schmidt, S{\\o}ren and Schi{\\o}tz, " - "Jakob},\n" - " title={Robust structural identification via polyhedral template " - "matching},\n" - " journal={Modelling~Simul.~Mater.~Sci.~Eng.},\n" + " author={Larsen, Peter Mahler and Schmidt, S{\\o}ren and\n" + " Schi{\\o}tz, Jakob},\n" + " title={Robust Structural Identification via Polyhedral Template\n" + " Matching},\n" + " journal={Model.\\ Simulat.\\ Mater.\\ Sci.\\ Eng.},\n" " year={2016},\n" " number={5},\n" " volume={24},\n" diff --git a/src/REACTION/fix_bond_react.cpp b/src/REACTION/fix_bond_react.cpp index 0383449bbd..60bd6fa82d 100644 --- a/src/REACTION/fix_bond_react.cpp +++ b/src/REACTION/fix_bond_react.cpp @@ -57,10 +57,10 @@ using namespace FixConst; using namespace MathConst; static const char cite_fix_bond_react[] = - "fix bond/react: reacter.org\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, B. D. Jensen, K. E. Wise},\n" - " title = {Modeling chemical reactions in classical molecular dynamics simulations},\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" @@ -68,10 +68,11 @@ static const char cite_fix_bond_react[] = "}\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" + " 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"; @@ -471,8 +472,8 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : open(files[i]); onemol = atom->molecules[unreacted_mol[i]]; twomol = atom->molecules[reacted_mol[i]]; - onemol->check_attributes(0); - twomol->check_attributes(0); + onemol->check_attributes(); + twomol->check_attributes(); get_molxspecials(); read(i); fclose(fp); diff --git a/src/REAXFF/fix_acks2_reaxff.cpp b/src/REAXFF/fix_acks2_reaxff.cpp index be71bc761f..9d1775c272 100644 --- a/src/REAXFF/fix_acks2_reaxff.cpp +++ b/src/REAXFF/fix_acks2_reaxff.cpp @@ -38,13 +38,14 @@ using namespace LAMMPS_NS; using namespace FixConst; static const char cite_fix_acks2_reax[] = - "fix acks2/reaxff command:\n\n" + "fix acks2/reaxff command: doi:10.1137/18M1224684\n\n" "@Article{O'Hearn2020,\n" - " author = {K. A. O'Hearn, A. Alperen, and H. M. Aktulga},\n" + " author = {K. A. {O'Hearn} and A. Alperen and H. M. Aktulga},\n" " title = {Fast Solvers for Charge Distribution Models on Shared Memory Platforms},\n" - " journal = {SIAM J. Sci. Comput.},\n" + " journal = {SIAM J.\\ Sci.\\ Comput.},\n" " year = 2020,\n" " volume = 42,\n" + " number = 1,\n" " pages = {1--22}\n" "}\n\n"; diff --git a/src/REAXFF/fix_qeq_reaxff.cpp b/src/REAXFF/fix_qeq_reaxff.cpp index 48e93f682a..6c03683518 100644 --- a/src/REAXFF/fix_qeq_reaxff.cpp +++ b/src/REAXFF/fix_qeq_reaxff.cpp @@ -54,10 +54,10 @@ static constexpr double SMALL = 1.0e-14; static constexpr double QSUMSMALL = 0.00001; static const char cite_fix_qeq_reaxff[] = - "fix qeq/reaxff command:\n\n" + "fix qeq/reaxff command: doi:10.1016/j.parco.2011.08.005\n\n" "@Article{Aktulga12,\n" - " author = {H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama},\n" - " title = {Parallel reactive molecular dynamics: Numerical methods and algorithmic techniques},\n" + " author = {H. M. Aktulga and J. C. Fogarty and S. A. Pandit and A. Y. Grama},\n" + " title = {Parallel Reactive Molecular Dynamics: {N}umerical Methods and Algorithmic Techniques},\n" " journal = {Parallel Computing},\n" " year = 2012,\n" " volume = 38,\n" diff --git a/src/REAXFF/fix_reaxff_species.cpp b/src/REAXFF/fix_reaxff_species.cpp index 0f5af77453..f38b6fb1c5 100644 --- a/src/REAXFF/fix_reaxff_species.cpp +++ b/src/REAXFF/fix_reaxff_species.cpp @@ -827,12 +827,11 @@ void FixReaxFFSpecies::WritePos(int Nmole, int Nspec) void FixReaxFFSpecies::DeleteSpecies(int Nmole, int Nspec) { - int i, j, m, n, k, itype, cid; + int i, j, m, n, itype, cid; int ndel, ndelone, count, count_tmp; int *Nameall; int *mask = atom->mask; double localmass, totalmass; - double **spec_atom = f_SPECBOND->array_atom; std::string species_str; AtomVec *avec = atom->avec; diff --git a/src/REAXFF/pair_reaxff.cpp b/src/REAXFF/pair_reaxff.cpp index e78edea9a9..b08a167431 100644 --- a/src/REAXFF/pair_reaxff.cpp +++ b/src/REAXFF/pair_reaxff.cpp @@ -46,13 +46,14 @@ using namespace LAMMPS_NS; using namespace ReaxFF; static const char cite_pair_reax_c[] = - "pair reaxff command:\n\n" + "pair reaxff command: doi:10.1016/j.parco.2011.08.005\n\n" "@Article{Aktulga12,\n" - " author = {H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama},\n" - " title = {Parallel reactive molecular dynamics: Numerical methods and algorithmic techniques},\n" + " author = {H. M. Aktulga and J. C. Fogarty and S. A. Pandit and A. Y. Grama},\n" + " title = {Parallel Reactive Molecular Dynamics: {N}umerical Methods and Algorithmic Techniques},\n" " journal = {Parallel Computing},\n" " year = 2012,\n" " volume = 38,\n" + " number = {4--5},\n" " pages = {245--259}\n" "}\n\n"; diff --git a/src/REPLICA/hyper.cpp b/src/REPLICA/hyper.cpp index eb739f486f..f13711f213 100644 --- a/src/REPLICA/hyper.cpp +++ b/src/REPLICA/hyper.cpp @@ -39,7 +39,7 @@ enum{NOHYPER,GLOBAL,LOCAL}; /* ---------------------------------------------------------------------- */ -Hyper::Hyper(LAMMPS *lmp) : Command(lmp), dumplist(nullptr) {} +Hyper::Hyper(LAMMPS *_lmp) : Command(_lmp) {} /* ---------------------------------------------------------------------- perform hyperdynamics simulation @@ -177,9 +177,7 @@ void Hyper::command(int narg, char **arg) fix_event->store_state_quench(); quench(1); - if (dumpflag) - for (int idump = 0; idump < ndump; idump++) - output->dump[dumplist[idump]]->write(); + if (dumpflag) for (auto idump : dumplist) idump->write(); fix_event->store_event(); if (hyperenable) fix_hyper->build_bond_list(0); fix_event->restore_state_quench(); @@ -208,9 +206,7 @@ void Hyper::command(int narg, char **arg) nevent++; nevent_atoms += ecount; - if (dumpflag) - for (int idump = 0; idump < ndump; idump++) - output->dump[dumplist[idump]]->write(); + if (dumpflag) for (auto idump : dumplist) idump->write(); fix_event->store_event(); if (hyperenable) fix_hyper->build_bond_list(ecount); @@ -345,7 +341,6 @@ void Hyper::command(int narg, char **arg) delete [] id_fix; delete [] id_compute; - memory->destroy(dumplist); delete finish; modify->delete_fix("hyper_event"); @@ -444,8 +439,6 @@ void Hyper::options(int narg, char **arg) maxiter = 40; maxeval = 50; dumpflag = 0; - ndump = 0; - dumplist = nullptr; rebond = 0; int iarg = 0; @@ -462,11 +455,9 @@ void Hyper::options(int narg, char **arg) } else if (strcmp(arg[iarg],"dump") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal hyper command"); dumpflag = 1; - int idump = output->find_dump(arg[iarg+1]); - if (idump < 0) - error->all(FLERR,"Dump ID in hyper command does not exist"); - memory->grow(dumplist,ndump+1,"hyper:dumplist"); - dumplist[ndump++] = idump; + auto idump = output->get_dump_by_id(arg[iarg+1]); + if (!idump) error->all(FLERR,"Dump ID {} in hyper command does not exist", arg[iarg+1]); + dumplist.emplace_back(idump); iarg += 2; } else if (strcmp(arg[iarg],"rebond") == 0) { diff --git a/src/REPLICA/hyper.h b/src/REPLICA/hyper.h index 1ea7fa0327..28229d819e 100644 --- a/src/REPLICA/hyper.h +++ b/src/REPLICA/hyper.h @@ -35,8 +35,8 @@ class Hyper : public Command { int t_event; double etol, ftol; int maxiter, maxeval; - int stepmode, dumpflag, ndump, rebond; - int *dumplist; + int stepmode, dumpflag, rebond; + std::vector dumplist; int neigh_every, neigh_delay, neigh_dist_check; int quench_reneighbor; diff --git a/src/RIGID/fix_rattle.cpp b/src/RIGID/fix_rattle.cpp index afe08415c3..1d6336712b 100644 --- a/src/RIGID/fix_rattle.cpp +++ b/src/RIGID/fix_rattle.cpp @@ -81,7 +81,7 @@ FixRattle::~FixRattle() { memory->destroy(vp); - if (RATTLE_DEBUG) { +#if RATTLE_DEBUG // communicate maximum distance error @@ -91,13 +91,11 @@ FixRattle::~FixRattle() MPI_Reduce(&derr_max, &global_derr_max, 1 , MPI_DOUBLE, MPI_MAX, 0, world); MPI_Reduce(&verr_max, &global_verr_max, 1 , MPI_DOUBLE, MPI_MAX, 0, world); - MPI_Comm_rank (world, &npid); // Find out process rank - - if (npid == 0 && screen) { + if (comm->me == 0 && screen) { fprintf(screen, "RATTLE: Maximum overall relative position error ( (r_ij-d_ij)/d_ij ): %.10g\n", global_derr_max); fprintf(screen, "RATTLE: Maximum overall absolute velocity error (r_ij * v_ij): %.10g\n", global_verr_max); } - } +#endif } /* ---------------------------------------------------------------------- */ @@ -110,7 +108,10 @@ int FixRattle::setmask() mask |= POST_FORCE_RESPA; mask |= FINAL_INTEGRATE; mask |= FINAL_INTEGRATE_RESPA; - if (RATTLE_DEBUG) mask |= END_OF_STEP; + mask |= MIN_POST_FORCE; +#if RATTLE_DEBUG + mask |= END_OF_STEP; +#endif return mask; } @@ -156,7 +157,7 @@ void FixRattle::post_force(int vflag) // communicate the unconstrained velocities - if (nprocs > 1) { + if (comm->nprocs > 1) { comm_mode = VP; comm->forward_comm(this); } @@ -188,7 +189,7 @@ void FixRattle::post_force_respa(int vflag, int ilevel, int /*iloop*/) // communicate the unconstrained velocities - if (nprocs > 1) { + if (comm->nprocs > 1) { comm_mode = VP; comm->forward_comm(this); } @@ -718,7 +719,7 @@ void FixRattle::unpack_forward_comm(int n, int first, double *buf) void FixRattle::shake_end_of_step(int vflag) { - if (nprocs > 1) { + if (comm->nprocs > 1) { comm_mode = V; comm->forward_comm(this); } @@ -738,7 +739,6 @@ void FixRattle::correct_coordinates(int vflag) { FixShake::correct_coordinates(vflag); } - /* ---------------------------------------------------------------------- Remove the velocity component along any bond. ------------------------------------------------------------------------- */ @@ -759,7 +759,7 @@ void FixRattle::correct_velocities() { // communicate the unconstrained velocities - if (nprocs > 1) { + if (comm->nprocs > 1) { comm_mode = VP; comm->forward_comm(this); } @@ -769,14 +769,13 @@ void FixRattle::correct_velocities() { int m; for (int i = 0; i < nlist; i++) { m = list[i]; - if (shake_flag[m] == 2) vrattle2(m); - else if (shake_flag[m] == 3) vrattle3(m); - else if (shake_flag[m] == 4) vrattle4(m); - else vrattle3angle(m); + if (shake_flag[m] == 2) vrattle2(m); + else if (shake_flag[m] == 3) vrattle3(m); + else if (shake_flag[m] == 4) vrattle4(m); + else vrattle3angle(m); } } - /* ---------------------------------------------------------------------- DEBUGGING methods The functions below allow you to check whether the @@ -788,16 +787,16 @@ void FixRattle::correct_velocities() { void FixRattle::end_of_step() { - if (nprocs > 1) { - comm_mode = V; - comm->forward_comm(this); + if (comm->nprocs > 1) { + comm_mode = V; + comm->forward_comm(this); } - if (!check_constraints(v, RATTLE_TEST_POS, RATTLE_TEST_VEL) && RATTLE_RAISE_ERROR) { +#if RATTLE_RAISE_ERROR + if (!check_constraints(v, RATTLE_TEST_POS, RATTLE_TEST_VEL)) error->one(FLERR, "Rattle failed "); - } +#endif } - /* ---------------------------------------------------------------------- */ bool FixRattle::check_constraints(double **v, bool checkr, bool checkv) @@ -807,12 +806,11 @@ bool FixRattle::check_constraints(double **v, bool checkr, bool checkv) int i=0; while (i < nlist && ret) { m = list[i]; - if (shake_flag[m] == 2) ret = check2(v,m,checkr,checkv); - else if (shake_flag[m] == 3) ret = check3(v,m,checkr,checkv); - else if (shake_flag[m] == 4) ret = check4(v,m,checkr,checkv); - else ret = check3angle(v,m,checkr,checkv); + if (shake_flag[m] == 2) ret = check2(v,m,checkr,checkv); + else if (shake_flag[m] == 3) ret = check3(v,m,checkr,checkv); + else if (shake_flag[m] == 4) ret = check4(v,m,checkr,checkv); + else ret = check3angle(v,m,checkr,checkv); i++; - if (!RATTLE_RAISE_ERROR) ret = true; } return ret; } @@ -834,14 +832,10 @@ bool FixRattle::check2(double **v, int m, bool checkr, bool checkv) MathExtra::sub3(v[i1],v[i0],v01); stat = !(checkr && (fabs(sqrt(MathExtra::dot3(r01,r01)) - bond1) > tol)); - if (!stat) - error->one(FLERR,"Coordinate constraints are not satisfied " - "up to desired tolerance "); + if (!stat) error->one(FLERR,"Coordinate constraints are not satisfied up to desired tolerance "); stat = !(checkv && (fabs(MathExtra::dot3(r01,v01)) > tol)); - if (!stat) - error->one(FLERR,"Velocity constraints are not satisfied " - "up to desired tolerance "); + if (!stat) error->one(FLERR,"Velocity constraints are not satisfied up to desired tolerance "); return stat; } @@ -871,15 +865,11 @@ bool FixRattle::check3(double **v, int m, bool checkr, bool checkv) stat = !(checkr && (fabs(sqrt(MathExtra::dot3(r01,r01)) - bond1) > tol || fabs(sqrt(MathExtra::dot3(r02,r02))-bond2) > tol)); - if (!stat) - error->one(FLERR,"Coordinate constraints are not satisfied " - "up to desired tolerance "); + if (!stat) error->one(FLERR,"Coordinate constraints are not satisfied up to desired tolerance "); stat = !(checkv && (fabs(MathExtra::dot3(r01,v01)) > tol || fabs(MathExtra::dot3(r02,v02)) > tol)); - if (!stat) - error->one(FLERR,"Velocity constraints are not satisfied " - "up to desired tolerance "); + if (!stat) error->one(FLERR,"Velocity constraints are not satisfied up to desired tolerance "); return stat; } @@ -914,16 +904,12 @@ bool FixRattle::check4(double **v, int m, bool checkr, bool checkv) stat = !(checkr && (fabs(sqrt(MathExtra::dot3(r01,r01)) - bond1) > tol || fabs(sqrt(MathExtra::dot3(r02,r02))-bond2) > tol || fabs(sqrt(MathExtra::dot3(r03,r03))-bond3) > tol)); - if (!stat) - error->one(FLERR,"Coordinate constraints are not satisfied " - "up to desired tolerance "); + if (!stat) error->one(FLERR,"Coordinate constraints are not satisfied up to desired tolerance "); stat = !(checkv && (fabs(MathExtra::dot3(r01,v01)) > tol || fabs(MathExtra::dot3(r02,v02)) > tol || fabs(MathExtra::dot3(r03,v03)) > tol)); - if (!stat) - error->one(FLERR,"Velocity constraints are not satisfied " - "up to desired tolerance "); + if (!stat) error->one(FLERR,"Velocity constraints are not satisfied up to desired tolerance "); return stat; } @@ -954,25 +940,19 @@ bool FixRattle::check3angle(double **v, int m, bool checkr, bool checkv) MathExtra::sub3(v[i2],v[i0],v02); MathExtra::sub3(v[i2],v[i1],v12); - - double db1 = fabs(sqrt(MathExtra::dot3(r01,r01)) - bond1); double db2 = fabs(sqrt(MathExtra::dot3(r02,r02))-bond2); double db12 = fabs(sqrt(MathExtra::dot3(r12,r12))-bond12); - - stat = !(checkr && (db1 > tol || - db2 > tol || - db12 > tol)); + stat = !(checkr && (db1 > tol || db2 > tol || db12 > tol)); if (derr_max < db1/bond1) derr_max = db1/bond1; if (derr_max < db2/bond2) derr_max = db2/bond2; if (derr_max < db12/bond12) derr_max = db12/bond12; - - if (!stat && RATTLE_RAISE_ERROR) - error->one(FLERR,"Coordinate constraints are not satisfied " - "up to desired tolerance "); +#if RATTLE_RAISE_ERROR + if (!stat) error->one(FLERR,"Coordinate constraints are not satisfied up to desired tolerance "); +#endif double dv1 = fabs(MathExtra::dot3(r01,v01)); double dv2 = fabs(MathExtra::dot3(r02,v02)); @@ -982,16 +962,10 @@ bool FixRattle::check3angle(double **v, int m, bool checkr, bool checkv) if (verr_max < dv2) verr_max = dv2; if (verr_max < dv12) verr_max = dv12; + stat = !(checkv && (dv1 > tol || dv2 > tol || dv12> tol)); - stat = !(checkv && (dv1 > tol || - dv2 > tol || - dv12> tol)); - - - if (!stat && RATTLE_RAISE_ERROR) - error->one(FLERR,"Velocity constraints are not satisfied " - "up to desired tolerance!"); - - +#if RATTLE_RAISE_ERROR + if (!stat) error->one(FLERR,"Velocity constraints are not satisfied up to desired tolerance!"); +#endif return stat; } diff --git a/src/RIGID/fix_shake.cpp b/src/RIGID/fix_shake.cpp index d74f72fb69..6673472458 100644 --- a/src/RIGID/fix_shake.cpp +++ b/src/RIGID/fix_shake.cpp @@ -41,8 +41,8 @@ using namespace MathConst; #define RVOUS 1 // 0 for irregular, 1 for all2all -#define BIG 1.0e20 -#define MASSDELTA 0.1 +static constexpr double BIG = 1.0e20; +static constexpr double MASSDELTA = 0.1; /* ---------------------------------------------------------------------- */ @@ -52,26 +52,31 @@ FixShake::FixShake(LAMMPS *lmp, int narg, char **arg) : loop_respa(nullptr), step_respa(nullptr), x(nullptr), v(nullptr), f(nullptr), ftmp(nullptr), vtmp(nullptr), mass(nullptr), rmass(nullptr), type(nullptr), shake_flag(nullptr), shake_atom(nullptr), shake_type(nullptr), xshake(nullptr), nshake(nullptr), list(nullptr), - b_count(nullptr), b_count_all(nullptr), b_atom(nullptr), b_atom_all(nullptr), b_ave(nullptr), b_max(nullptr), - b_min(nullptr), b_ave_all(nullptr), b_max_all(nullptr), b_min_all(nullptr), a_count(nullptr), + b_count(nullptr), b_count_all(nullptr), b_ave(nullptr), b_max(nullptr), b_min(nullptr), + b_ave_all(nullptr), b_max_all(nullptr), b_min_all(nullptr), a_count(nullptr), a_count_all(nullptr), a_ave(nullptr), a_max(nullptr), a_min(nullptr), a_ave_all(nullptr), a_max_all(nullptr), a_min_all(nullptr), atommols(nullptr), onemols(nullptr) { - MPI_Comm_rank(world,&me); - MPI_Comm_size(world,&nprocs); - + energy_global_flag = energy_peratom_flag = 1; virial_global_flag = virial_peratom_flag = 1; - thermo_virial = 1; + thermo_energy = thermo_virial = 1; create_attribute = 1; dof_flag = 1; + scalar_flag = 1; stores_ids = 1; centroidstressflag = CENTROID_AVAIL; + next_output = -1; + + // to avoid uninitialized access + vflag_post_force = 0; + eflag_pre_reverse = 0; + ebond = 0.0; // error check molecular = atom->molecular; if (molecular == Atom::ATOMIC) - error->all(FLERR,"Cannot use fix shake with non-molecular system"); + error->all(FLERR,"Cannot use fix {} with non-molecular system", style); // perform initial allocation of atom-based arrays // register with Atom class @@ -92,8 +97,9 @@ FixShake::FixShake(LAMMPS *lmp, int narg, char **arg) : comm_forward = 3; // parse SHAKE args + auto mystyle = fmt::format("fix {}",style); - if (narg < 8) error->all(FLERR,"Illegal fix shake command"); + if (narg < 8) utils::missing_cmd_args(FLERR,mystyle, error); tolerance = utils::numeric(FLERR,arg[3],false,lmp); max_iter = utils::inumeric(FLERR,arg[4],false,lmp); @@ -133,49 +139,55 @@ FixShake::FixShake(LAMMPS *lmp, int narg, char **arg) : else if (mode == 'b') { int i = utils::inumeric(FLERR,arg[next],false,lmp); if (i < 1 || i > atom->nbondtypes) - error->all(FLERR,"Invalid bond type index for fix shake"); + error->all(FLERR,"Invalid bond type index for {}", mystyle); bond_flag[i] = 1; } else if (mode == 'a') { int i = utils::inumeric(FLERR,arg[next],false,lmp); if (i < 1 || i > atom->nangletypes) - error->all(FLERR,"Invalid angle type index for fix shake"); + error->all(FLERR,"Invalid angle type index for {}", mystyle); angle_flag[i] = 1; } else if (mode == 't') { int i = utils::inumeric(FLERR,arg[next],false,lmp); if (i < 1 || i > atom->ntypes) - error->all(FLERR,"Invalid atom type index for fix shake"); + error->all(FLERR,"Invalid atom type index for {}", mystyle); type_flag[i] = 1; } else if (mode == 'm') { double massone = utils::numeric(FLERR,arg[next],false,lmp); - if (massone == 0.0) error->all(FLERR,"Invalid atom mass for fix shake"); + if (massone == 0.0) error->all(FLERR,"Invalid atom mass for {}", mystyle); if (nmass == atom->ntypes) - error->all(FLERR,"Too many masses for fix shake"); + error->all(FLERR,"Too many masses for {}", mystyle); mass_list[nmass++] = massone; - } else error->all(FLERR,"Illegal fix shake command"); + } else error->all(FLERR,"Unknown {} command option: {}", mystyle, arg[next]); next++; } // parse optional args onemols = nullptr; + kbond = 1.0e6*force->boltz; int iarg = next; while (iarg < narg) { - if (strcmp(arg[next],"mol") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix shake command"); + if (strcmp(arg[iarg],"mol") == 0) { + if (iarg+2 > narg) utils::missing_cmd_args(FLERR,mystyle+" mol",error); int imol = atom->find_molecule(arg[iarg+1]); if (imol == -1) - error->all(FLERR,"Molecule template ID for fix shake does not exist"); - if (atom->molecules[imol]->nset > 1 && comm->me == 0) - error->warning(FLERR,"Molecule template for fix shake has multiple molecules"); + error->all(FLERR,"Molecule template ID {} for {} does not exist", mystyle, arg[iarg+1]); + if ((atom->molecules[imol]->nset > 1) && (comm->me == 0)) + error->warning(FLERR,"Molecule template for {} has multiple molecules", mystyle); onemols = &atom->molecules[imol]; nmol = onemols[0]->nset; iarg += 2; - } else error->all(FLERR,"Illegal fix shake command"); + } else if (strcmp(arg[iarg],"kbond") == 0) { + if (iarg+2 > narg) utils::missing_cmd_args(FLERR,mystyle+" kbond",error); + kbond = utils::numeric(FLERR, arg[iarg+1], false, lmp); + if (kbond < 0) error->all(FLERR,"Illegal {} kbond value {}. Must be >= 0.0", mystyle, kbond); + iarg += 2; + } else error->all(FLERR,"Unknown {} command option: {}", mystyle, arg[iarg]); } // error check for Molecule template @@ -183,7 +195,7 @@ FixShake::FixShake(LAMMPS *lmp, int narg, char **arg) : if (onemols) { for (int i = 0; i < nmol; i++) if (onemols[i]->shakeflag == 0) - error->all(FLERR,"Fix shake molecule template must have shake info"); + error->all(FLERR,"Fix {} molecule template must have shake info", style); } // allocate bond and angle distance arrays, indexed from 1 to n @@ -197,8 +209,6 @@ FixShake::FixShake(LAMMPS *lmp, int narg, char **arg) : int nb = atom->nbondtypes + 1; b_count = new int[nb]; b_count_all = new int[nb]; - b_atom = new int[nb]; - b_atom_all = new int[nb]; b_ave = new double[nb]; b_ave_all = new double[nb]; b_max = new double[nb]; @@ -291,8 +301,6 @@ FixShake::~FixShake() if (output_every) { delete[] b_count; delete[] b_count_all; - delete[] b_atom; - delete[] b_atom_all; delete[] b_ave; delete[] b_ave_all; delete[] b_max; @@ -321,6 +329,9 @@ int FixShake::setmask() mask |= PRE_NEIGHBOR; mask |= POST_FORCE; mask |= POST_FORCE_RESPA; + mask |= MIN_PRE_REVERSE; + mask |= MIN_POST_FORCE; + mask |= POST_RUN; return mask; } @@ -335,28 +346,24 @@ void FixShake::init() double rsq,angle; // error if more than one shake fix + auto pattern = fmt::format("^{}",style); - int count = 0; - for (i = 0; i < modify->nfix; i++) - if (strcmp(modify->fix[i]->style,"shake") == 0) count++; - if (count > 1) error->all(FLERR,"More than one fix shake"); + if (modify->get_fix_by_style(pattern).size() > 1) + error->all(FLERR,"More than one fix {} instance",style); // cannot use with minimization since SHAKE turns off bonds // that should contribute to potential energy - if (update->whichflag == 2) - error->all(FLERR,"Fix shake cannot be used with minimization"); + if ((comm->me == 0) && (update->whichflag == 2)) + error->warning(FLERR,"Using fix {} with minimization.\n Substituting constraints with " + "harmonic restraint forces using kbond={:.4g}", style, kbond); - // error if npt,nph fix comes before shake fix - - for (i = 0; i < modify->nfix; i++) { - if (strcmp(modify->fix[i]->style,"npt") == 0) break; - if (strcmp(modify->fix[i]->style,"nph") == 0) break; - } - if (i < modify->nfix) { - for (int j = i; j < modify->nfix; j++) - if (strcmp(modify->fix[j]->style,"shake") == 0) - error->all(FLERR,"Shake fix must come before NPT/NPH fix"); + // error if a fix changing the box comes before shake fix + bool boxflag = false; + for (auto ifix : modify->get_fix_list()) { + if (boxflag && utils::strmatch(ifix->style,pattern)) + error->all(FLERR,"Fix {} must come before any box changing fix", style); + if (ifix->box_change) boxflag = true; } // if rRESPA, find associated fix that must exist @@ -379,7 +386,7 @@ void FixShake::init() // set equilibrium bond distances if (force->bond == nullptr) - error->all(FLERR,"Bond potential must be defined for SHAKE"); + error->all(FLERR,"Bond style must be defined for fix {}",style); for (i = 1; i <= atom->nbondtypes; i++) bond_distance[i] = force->bond->equilibrium_distance(i); @@ -390,7 +397,7 @@ void FixShake::init() for (i = 1; i <= atom->nangletypes; i++) { if (angle_flag[i] == 0) continue; if (force->angle == nullptr) - error->all(FLERR,"Angle potential must be defined for SHAKE"); + error->all(FLERR,"Angle style must be defined for fix {}",style); // scan all atoms for a SHAKE angle cluster // extract bond types for the 2 bonds in the cluster @@ -417,7 +424,7 @@ void FixShake::init() // error check for any bond types that are not the same MPI_Allreduce(&flag,&flag_all,1,MPI_INT,MPI_MAX,world); - if (flag_all) error->all(FLERR,"Shake angles have different bond types"); + if (flag_all) error->all(FLERR,"Fix {} angles have different bond types", style); // insure all procs have bond types @@ -494,6 +501,23 @@ void FixShake::setup(int vflag) shake_end_of_step(vflag); } +/* ---------------------------------------------------------------------- + during minimization fix SHAKE adds strong bond forces +------------------------------------------------------------------------- */ + +void FixShake::min_setup(int vflag) +{ + pre_neighbor(); + min_post_force(vflag); +} + +/* --------------------------------------------------------------------- */ + +void FixShake::setup_pre_reverse(int eflag, int vflag) +{ + min_pre_reverse(eflag,vflag); +} + /* ---------------------------------------------------------------------- build list of SHAKE clusters to constrain if one or more atoms in cluster are on this proc, @@ -502,6 +526,7 @@ void FixShake::setup(int vflag) void FixShake::pre_neighbor() { + ebond = 0.0; int atom1,atom2,atom3,atom4; // local copies of atom quantities @@ -533,19 +558,17 @@ void FixShake::pre_neighbor() atom1 = atom->map(shake_atom[i][0]); atom2 = atom->map(shake_atom[i][1]); if (atom1 == -1 || atom2 == -1) - error->one(FLERR,"Shake atoms {} {} missing on proc " - "{} at step {}",shake_atom[i][0], - shake_atom[i][1],me,update->ntimestep); + error->one(FLERR,"Shake atoms {} {} missing on proc {} at step {}",shake_atom[i][0], + shake_atom[i][1],comm->me,update->ntimestep); if (i <= atom1 && i <= atom2) list[nlist++] = i; } else if (shake_flag[i] % 2 == 1) { atom1 = atom->map(shake_atom[i][0]); atom2 = atom->map(shake_atom[i][1]); atom3 = atom->map(shake_atom[i][2]); if (atom1 == -1 || atom2 == -1 || atom3 == -1) - error->one(FLERR,"Shake atoms {} {} {} missing on proc " - "{} at step {}",shake_atom[i][0], + error->one(FLERR,"Shake atoms {} {} {} missing on proc {} at step {}",shake_atom[i][0], shake_atom[i][1],shake_atom[i][2], - me,update->ntimestep); + comm->me,update->ntimestep); if (i <= atom1 && i <= atom2 && i <= atom3) list[nlist++] = i; } else { atom1 = atom->map(shake_atom[i][0]); @@ -553,10 +576,9 @@ void FixShake::pre_neighbor() atom3 = atom->map(shake_atom[i][2]); atom4 = atom->map(shake_atom[i][3]); if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1) - error->one(FLERR,"Shake atoms {} {} {} {} missing on " - "proc {} at step {}",shake_atom[i][0], + error->one(FLERR,"Shake atoms {} {} {} {} missing on proc {} at step {}",shake_atom[i][0], shake_atom[i][1],shake_atom[i][2], - shake_atom[i][3],me,update->ntimestep); + shake_atom[i][3],comm->me,update->ntimestep); if (i <= atom1 && i <= atom2 && i <= atom3 && i <= atom4) list[nlist++] = i; } @@ -575,11 +597,13 @@ void FixShake::post_force(int vflag) // communicate results if necessary unconstrained_update(); - if (nprocs > 1) comm->forward_comm(this); + if (comm->nprocs > 1) comm->forward_comm(this); // virial setup - v_init(vflag); + int eflag = eflag_pre_reverse; + ev_init(eflag, vflag); + ebond = 0.0; // loop over clusters to add constraint forces @@ -619,7 +643,7 @@ void FixShake::post_force_respa(int vflag, int ilevel, int iloop) // communicate results if necessary unconstrained_update_respa(ilevel); - if (nprocs > 1) comm->forward_comm(this); + if (comm->nprocs > 1) comm->forward_comm(this); // virial setup only needed on last iteration of innermost level // and if pressure is requested @@ -644,6 +668,59 @@ void FixShake::post_force_respa(int vflag, int ilevel, int iloop) vflag_post_force = vflag; } +/* ---------------------------------------------------------------------- + store eflag so it can be used in min_post_force +------------------------------------------------------------------------- */ + +void FixShake::min_pre_reverse(int eflag, int /*vflag*/) +{ + eflag_pre_reverse = eflag; +} + +/* ---------------------------------------------------------------------- + substitute shake constraints with very strong bonds +------------------------------------------------------------------------- */ + +void FixShake::min_post_force(int vflag) +{ + if (output_every) { + bigint ntimestep = update->ntimestep; + if (next_output == ntimestep) stats(); + + next_output = ntimestep + output_every; + if (ntimestep % output_every != 0) + next_output = (ntimestep/output_every)*output_every + output_every; + } else next_output = -1; + + int eflag = eflag_pre_reverse; + ev_init(eflag, vflag); + + x = atom->x; + f = atom->f; + nlocal = atom->nlocal; + ebond = 0.0; + + // loop over shake clusters to add restraint forces + + for (int i = 0; i < nlist; i++) { + int m = list[i]; + if (shake_flag[m] == 2) { + bond_force(shake_atom[m][0], shake_atom[m][1], bond_distance[shake_type[m][0]]); + } else if (shake_flag[m] == 3) { + bond_force(shake_atom[m][0], shake_atom[m][1], bond_distance[shake_type[m][0]]); + bond_force(shake_atom[m][0], shake_atom[m][2], bond_distance[shake_type[m][1]]); + } else if (shake_flag[m] == 4) { + bond_force(shake_atom[m][0], shake_atom[m][1], bond_distance[shake_type[m][0]]); + bond_force(shake_atom[m][0], shake_atom[m][2], bond_distance[shake_type[m][1]]); + bond_force(shake_atom[m][0], shake_atom[m][3], bond_distance[shake_type[m][2]]); + } else { + bond_force(shake_atom[m][0], shake_atom[m][1], bond_distance[shake_type[m][0]]); + bond_force(shake_atom[m][0], shake_atom[m][2], bond_distance[shake_type[m][1]]); + bond_force(shake_atom[m][1], shake_atom[m][2], angle_distance[shake_type[m][2]]); + } + } +} + /* ---------------------------------------------------------------------- count # of degrees-of-freedom removed by SHAKE for atoms in igroup ------------------------------------------------------------------------- */ @@ -690,10 +767,7 @@ void FixShake::find_clusters() tagint tagprev; double massone; - if ((me == 0) && screen) { - if (!rattle) fputs("Finding SHAKE clusters ...\n",screen); - else fputs("Finding RATTLE clusters ...\n",screen); - } + if (comm->me == 0) utils::logmesg(lmp, "Finding {} clusters ...\n",utils::uppercase(style)); atommols = atom->avec->onemols; tagint *tag = atom->tag; @@ -805,7 +879,7 @@ void FixShake::find_clusters() } MPI_Allreduce(&flag,&flag_all,1,MPI_INT,MPI_SUM,world); - if (flag_all) error->all(FLERR,"Did not find fix shake partner info"); + if (flag_all) error->all(FLERR,"Did not find fix {} partner info", style); // ----------------------------------------------------- // identify SHAKEable bonds @@ -1015,7 +1089,7 @@ void FixShake::find_clusters() tmp = count4; MPI_Allreduce(&tmp,&count4,1,MPI_INT,MPI_SUM,world); - if (me == 0) { + if (comm->me == 0) { utils::logmesg(lmp,"{:>8} = # of size 2 clusters\n" "{:>8} = # of size 3 clusters\n" "{:>8} = # of size 4 clusters\n" @@ -1043,8 +1117,8 @@ void FixShake::atom_owners() // one datum for each owned atom: datum = owning proc, atomID for (int i = 0; i < nlocal; i++) { - proclist[i] = tag[i] % nprocs; - idbuf[i].me = me; + proclist[i] = tag[i] % comm->nprocs; + idbuf[i].me = comm->me; idbuf[i].atomID = tag[i]; } @@ -1089,7 +1163,7 @@ void FixShake::partner_info(int *npartner, tagint **partner_tag, // set values in 4 partner arrays for all partner atoms I own // also setup input buf to rendezvous comm // input datums = pair of bonded atoms where I do not own partner - // owning proc for each datum = partner_tag % nprocs + // owning proc for each datum = partner_tag % comm->nprocs // datum: atomID = partner_tag (off-proc), partnerID = tag (on-proc) // 4 values for my owned atom @@ -1127,7 +1201,7 @@ void FixShake::partner_info(int *npartner, tagint **partner_tag, } } else { - proclist[nsend] = partner_tag[i][j] % nprocs; + proclist[nsend] = partner_tag[i][j] % comm->nprocs; inbuf[nsend].atomID = partner_tag[i][j]; inbuf[nsend].partnerID = tag[i]; inbuf[nsend].mask = mask[i]; @@ -1217,7 +1291,7 @@ void FixShake::nshake_info(int *npartner, tagint **partner_tag, // set partner_nshake for all partner atoms I own // also setup input buf to rendezvous comm // input datums = pair of bonded atoms where I do not own partner - // owning proc for each datum = partner_tag % nprocs + // owning proc for each datum = partner_tag % comm->nprocs // datum: atomID = partner_tag (off-proc), partnerID = tag (on-proc) // nshake value for my owned atom @@ -1231,7 +1305,7 @@ void FixShake::nshake_info(int *npartner, tagint **partner_tag, if (m >= 0 && m < nlocal) { partner_nshake[i][j] = nshake[m]; } else { - proclist[nsend] = partner_tag[i][j] % nprocs; + proclist[nsend] = partner_tag[i][j] % comm->nprocs; inbuf[nsend].atomID = partner_tag[i][j]; inbuf[nsend].partnerID = tag[i]; inbuf[nsend].nshake = nshake[i]; @@ -1295,7 +1369,7 @@ void FixShake::shake_info(int *npartner, tagint **partner_tag, // set 3 shake arrays for all partner atoms I own // also setup input buf to rendezvous comm // input datums = partner atom where I do not own partner - // owning proc for each datum = partner_tag % nprocs + // owning proc for each datum = partner_tag % comm->nprocs // datum: atomID = partner_tag (off-proc) // values in 3 shake arrays @@ -1317,7 +1391,7 @@ void FixShake::shake_info(int *npartner, tagint **partner_tag, shake_type[m][2] = shake_type[i][2]; } else { - proclist[nsend] = partner_tag[i][j] % nprocs; + proclist[nsend] = partner_tag[i][j] % comm->nprocs; inbuf[nsend].atomID = partner_tag[i][j]; inbuf[nsend].shake_flag = shake_flag[i]; inbuf[nsend].shake_atom[0] = shake_atom[i][0]; @@ -2451,13 +2525,66 @@ void FixShake::shake3angle(int m) } } +/* ---------------------------------------------------------------------- + apply bond force for minimization +------------------------------------------------------------------------- */ + +void FixShake::bond_force(tagint id1, tagint id2, double length) +{ + int i1 = atom->map(id1); + int i2 = atom->map(id2); + + if ((i1 < 0) || (i2 < 0)) return; + + // distance vec between atoms, with PBC + + double delx = x[i1][0] - x[i2][0]; + double dely = x[i1][1] - x[i2][1]; + double delz = x[i1][2] - x[i2][2]; + domain->minimum_image(delx, dely, delz); + + // compute and apply force + + const double r = sqrt(delx * delx + dely * dely + delz * delz); + const double dr = r - length; + const double rk = kbond * dr; + const double fbond = (r > 0.0) ? -2.0 * rk / r : 0.0; + const double eb = rk*dr; + int list[2]; + int nlist = 0; + + if (i1 < nlocal) { + f[i1][0] += delx * fbond; + f[i1][1] += dely * fbond; + f[i1][2] += delz * fbond; + list[nlist++] = i1; + ebond += 0.5*eb; + } + if (i2 < nlocal) { + f[i2][0] -= delx * fbond; + f[i2][1] -= dely * fbond; + f[i2][2] -= delz * fbond; + list[nlist++] = i2; + ebond += 0.5*eb; + } + if (evflag) { + double v[6]; + v[0] = 0.5 * delx * delx * fbond; + v[1] = 0.5 * dely * dely * fbond; + v[2] = 0.5 * delz * delz * fbond; + v[3] = 0.5 * delx * dely * fbond; + v[4] = 0.5 * delx * delz * fbond; + v[5] = 0.5 * dely * delz * fbond; + ev_tally(nlist, list, 2.0, eb, v); + } +} + /* ---------------------------------------------------------------------- print-out bond & angle statistics ------------------------------------------------------------------------- */ void FixShake::stats() { - int i,j,m,n,iatom,jatom,katom; double delx,dely,delz; double r,r1,r2,r3,angle; @@ -2466,13 +2593,12 @@ void FixShake::stats() int nb = atom->nbondtypes + 1; int na = atom->nangletypes + 1; - for (i = 0; i < nb; i++) { + for (int i = 0; i < nb; i++) { b_count[i] = 0; b_ave[i] = b_max[i] = 0.0; b_min[i] = BIG; - b_atom[i] = -1; } - for (i = 0; i < na; i++) { + for (int i = 0; i < na; i++) { a_count[i] = 0; a_ave[i] = a_max[i] = 0.0; a_min[i] = BIG; @@ -2484,25 +2610,26 @@ void FixShake::stats() double **x = atom->x; int nlocal = atom->nlocal; - for (i = 0; i < nlocal; i++) { - if (shake_flag[i] == 0) continue; + for (int ii = 0; ii < nlist; ++ii) { + int i = list[ii]; + int n = shake_flag[i]; + if (n == 0) continue; // bond stats - n = shake_flag[i]; if (n == 1) n = 3; - iatom = atom->map(shake_atom[i][0]); - for (j = 1; j < n; j++) { - jatom = atom->map(shake_atom[i][j]); + int iatom = atom->map(shake_atom[i][0]); + for (int j = 1; j < n; j++) { + int jatom = atom->map(shake_atom[i][j]); + if (jatom >= nlocal) continue; delx = x[iatom][0] - x[jatom][0]; dely = x[iatom][1] - x[jatom][1]; delz = x[iatom][2] - x[jatom][2]; domain->minimum_image(delx,dely,delz); - r = sqrt(delx*delx + dely*dely + delz*delz); - m = shake_type[i][j-1]; + r = sqrt(delx*delx + dely*dely + delz*delz); + int m = shake_type[i][j-1]; b_count[m]++; - b_atom[m] = n; b_ave[m] += r; b_max[m] = MAX(b_max[m],r); b_min[m] = MIN(b_min[m],r); @@ -2511,9 +2638,13 @@ void FixShake::stats() // angle stats if (shake_flag[i] == 1) { - iatom = atom->map(shake_atom[i][0]); - jatom = atom->map(shake_atom[i][1]); - katom = atom->map(shake_atom[i][2]); + int iatom = atom->map(shake_atom[i][0]); + int jatom = atom->map(shake_atom[i][1]); + int katom = atom->map(shake_atom[i][2]); + int n = 0; + if (iatom < nlocal) ++n; + if (jatom < nlocal) ++n; + if (katom < nlocal) ++n; delx = x[iatom][0] - x[jatom][0]; dely = x[iatom][1] - x[jatom][1]; @@ -2535,9 +2666,9 @@ void FixShake::stats() angle = acos((r1*r1 + r2*r2 - r3*r3) / (2.0*r1*r2)); angle *= 180.0/MY_PI; - m = shake_type[i][2]; - a_count[m]++; - a_ave[m] += angle; + int m = shake_type[i][2]; + a_count[m] += n; + a_ave[m] += n*angle; a_max[m] = MAX(a_max[m],angle); a_min[m] = MIN(a_min[m],angle); } @@ -2546,7 +2677,6 @@ void FixShake::stats() // sum across all procs MPI_Allreduce(b_count,b_count_all,nb,MPI_INT,MPI_SUM,world); - MPI_Allreduce(b_atom,b_atom_all,nb,MPI_INT,MPI_MAX,world); MPI_Allreduce(b_ave,b_ave_all,nb,MPI_DOUBLE,MPI_SUM,world); MPI_Allreduce(b_max,b_max_all,nb,MPI_DOUBLE,MPI_MAX,world); MPI_Allreduce(b_min,b_min_all,nb,MPI_DOUBLE,MPI_MIN,world); @@ -2558,16 +2688,17 @@ void FixShake::stats() // print stats only for non-zero counts - if (me == 0) { + if (comm->me == 0) { const int width = log10((MAX(MAX(1,nb),na)))+2; - auto mesg = fmt::format("SHAKE stats (type/ave/delta/count) on step {}\n", update->ntimestep); - for (i = 1; i < nb; i++) { + auto mesg = fmt::format("{} stats (type/ave/delta/count) on step {}\n", + utils::uppercase(style), update->ntimestep); + for (int i = 1; i < nb; i++) { const auto bcnt = b_count_all[i]; if (bcnt) mesg += fmt::format("Bond: {:>{}d} {:<9.6} {:<11.6} {:>8d}\n",i,width, - b_ave_all[i]/bcnt,b_max_all[i]-b_min_all[i],bcnt/b_atom_all[i]); + b_ave_all[i]/bcnt,b_max_all[i]-b_min_all[i],bcnt); } - for (i = 1; i < na; i++) { + for (int i = 1; i < na; i++) { const auto acnt = a_count_all[i]; if (acnt) mesg += fmt::format("Angle: {:>{}d} {:<9.6} {:<11.6} {:>8d}\n",i,width, @@ -3005,6 +3136,26 @@ void *FixShake::extract(const char *str, int &dim) return nullptr; } +/* ---------------------------------------------------------------------- + energy due to restraint forces +------------------------------------------------------------------------- */ + +double FixShake::compute_scalar() +{ + double all; + MPI_Allreduce(&ebond, &all, 1, MPI_DOUBLE, MPI_SUM, world); + return all; +} + +/* ---------------------------------------------------------------------- + print shake stats at the end of a minimization +------------------------------------------------------------------------- */ +void FixShake::post_run() +{ + if ((update->whichflag == 2) && (output_every > 0)) stats(); +} + + /* ---------------------------------------------------------------------- add coordinate constraining forces this method is called at the end of a timestep @@ -3109,7 +3260,7 @@ void FixShake::correct_coordinates(int vflag) { double **xtmp = xshake; xshake = x; - if (nprocs > 1) { + if (comm->nprocs > 1) { comm->forward_comm(this); } xshake = xtmp; diff --git a/src/RIGID/fix_shake.h b/src/RIGID/fix_shake.h index 12e24fb350..914b73ea34 100644 --- a/src/RIGID/fix_shake.h +++ b/src/RIGID/fix_shake.h @@ -34,9 +34,14 @@ class FixShake : public Fix { int setmask() override; void init() override; void setup(int) override; + void setup_pre_reverse(int, int) override; + void min_setup(int) override; void pre_neighbor() override; void post_force(int) override; void post_force_respa(int, int, int) override; + void min_pre_reverse(int, int) override; + void min_post_force(int) override; + void post_run() override; double memory_usage() override; void grow_arrays(int) override; @@ -57,16 +62,17 @@ class FixShake : public Fix { int dof(int) override; void reset_dt() override; void *extract(const char *, int &) override; + double compute_scalar() override; protected: int vflag_post_force; // store the vflag of last post_force call + int eflag_pre_reverse; // store the eflag of last pre_reverse call int respa; // 0 = vel. Verlet, 1 = respa - int me, nprocs; - int rattle; // 0 = SHAKE, 1 = RATTLE - double tolerance; // SHAKE tolerance - int max_iter; // max # of SHAKE iterations - int output_every; // SHAKE stat output every so often - bigint next_output; // timestep for next output + int rattle; // 0 = SHAKE, 1 = RATTLE + double tolerance; // SHAKE tolerance + int max_iter; // max # of SHAKE iterations + int output_every; // SHAKE stat output every so often + bigint next_output; // timestep for next output // settings from input command int *bond_flag, *angle_flag; // bond/angle types to constrain @@ -76,6 +82,8 @@ class FixShake : public Fix { int molecular; // copy of atom->molecular double *bond_distance, *angle_distance; // constraint distances + double kbond; // force constant for restraint + double ebond; // energy of bond restraints class FixRespa *fix_respa; // rRESPA fix needed by SHAKE int nlevels_respa; // copies of needed rRESPA variables @@ -108,8 +116,7 @@ class FixShake : public Fix { int nlist, maxlist; // size and max-size of list // stat quantities - int *b_count, *b_count_all, *b_atom, - *b_atom_all; // counts for each bond type, atoms in bond cluster + int *b_count, *b_count_all; // counts for each bond type, atoms in bond cluster double *b_ave, *b_max, *b_min; // ave/max/min dist for each bond type double *b_ave_all, *b_max_all, *b_min_all; // MPI summing arrays int *a_count, *a_count_all; // ditto for angle types @@ -133,6 +140,7 @@ class FixShake : public Fix { void shake3(int); void shake4(int); void shake3angle(int); + void bond_force(tagint, tagint, double); void stats(); int bondtype_findset(int, tagint, tagint, int); int angletype_findset(int, tagint, tagint, int); diff --git a/src/SMTBQ/pair_smtbq.cpp b/src/SMTBQ/pair_smtbq.cpp index 60198f062e..988958ca36 100644 --- a/src/SMTBQ/pair_smtbq.cpp +++ b/src/SMTBQ/pair_smtbq.cpp @@ -1232,8 +1232,6 @@ void PairSMTBQ::tabqeq() double aCoeff,bCoeff,rcoupe,nang; int n = atom->ntypes; - int nlocal = atom->nlocal; - int nghost = atom->nghost; nmax = atom->nmax; nntype = int((n+1)*n/2); @@ -1242,7 +1240,7 @@ void PairSMTBQ::tabqeq() #if VERBOSE printf ("kmax %d, ds %f, nmax %d\n",kmax,ds,nmax); - printf ("nlocal = %d, nghost = %d\n",nlocal,nghost); + printf ("nlocal = %d, nghost = %d\n",atom->nlocal,atom->nghost); printf ("nntypes %d, kmax %d, rc %f, n %d\n",nntype,kmax,rc,n); #endif diff --git a/src/SPIN/fix_nve_spin.cpp b/src/SPIN/fix_nve_spin.cpp index 062f3c1b00..b075c2f88b 100644 --- a/src/SPIN/fix_nve_spin.cpp +++ b/src/SPIN/fix_nve_spin.cpp @@ -45,14 +45,14 @@ using namespace LAMMPS_NS; using namespace FixConst; static const char cite_fix_nve_spin[] = - "fix nve/spin command:\n\n" + "fix nve/spin command: doi:10.1016/j.jcp.2018.06.042\n\n" "@article{tranchida2018massively,\n" - "title={Massively parallel symplectic algorithm for coupled magnetic spin " - "dynamics and molecular dynamics},\n" - "author={Tranchida, J and Plimpton, SJ and Thibaudeau, P and Thompson, AP},\n" + "title={Massively Parallel Symplectic Algorithm for Coupled Magnetic Spin " + " Dynamics and Molecular Dynamics},\n" + "author={Tranchida, J and Plimpton, S J and Thibaudeau, P and Thompson, A P},\n" "journal={Journal of Computational Physics},\n" "volume={372},\n" - "pages={406-425},\n" + "pages={406--425},\n" "year={2018},\n" "publisher={Elsevier}\n" "doi={10.1016/j.jcp.2018.06.042}\n" diff --git a/src/SPIN/min_spin_cg.cpp b/src/SPIN/min_spin_cg.cpp index 9867f7aab5..84540a4a7f 100644 --- a/src/SPIN/min_spin_cg.cpp +++ b/src/SPIN/min_spin_cg.cpp @@ -43,7 +43,7 @@ using namespace LAMMPS_NS; using namespace MathConst; static const char cite_minstyle_spin_cg[] = - "min_style spin/cg command:\n\n" + "min_style spin/cg command: doi:10.48550/arXiv.1904.02669\n\n" "@article{ivanov2019fast,\n" "title={Fast and Robust Algorithm for the Minimisation of the Energy of " "Spin Systems},\n" diff --git a/src/SPIN/min_spin_lbfgs.cpp b/src/SPIN/min_spin_lbfgs.cpp index de3b70f01f..9972af0a7a 100644 --- a/src/SPIN/min_spin_lbfgs.cpp +++ b/src/SPIN/min_spin_lbfgs.cpp @@ -43,10 +43,10 @@ using namespace LAMMPS_NS; using namespace MathConst; static const char cite_minstyle_spin_lbfgs[] = - "min_style spin/lbfgs command:\n\n" + "min_style spin/lbfgs command: doi:10.48550/arXiv.1904.02669\n\n" "@article{ivanov2019fast,\n" - "title={Fast and Robust Algorithm for the Minimisation of the Energy of " - "Spin Systems},\n" + "title={Fast and Robust Algorithm for the Minimisation of the Energy of\n" + " Spin Systems},\n" "author={Ivanov, A. V and Uzdin, V. M. and J{\'o}nsson, H.},\n" "journal={arXiv preprint arXiv:1904.02669},\n" "year={2019}\n" diff --git a/src/SPIN/neb_spin.cpp b/src/SPIN/neb_spin.cpp index 692883fc0a..381d1827b3 100644 --- a/src/SPIN/neb_spin.cpp +++ b/src/SPIN/neb_spin.cpp @@ -48,12 +48,12 @@ using namespace LAMMPS_NS; static const char cite_neb_spin[] = - "neb/spin command:\n\n" + "neb/spin command: doi:10.1016/j.cpc.2015.07.001\n\n" "@article{bessarab2015method,\n" - "title={Method for finding mechanism and activation energy of " - "magnetic transitions, applied to skyrmion and antivortex " - "annihilation},\n" - "author={Bessarab, P.F. and Uzdin, V.M. and J{\'o}nsson, H.},\n" + "title={Method for Finding Mechanism and Activation Energy of\n" + " Magnetic Transitions, Applied to Skyrmion and Antivortex\n" + " Annihilation},\n" + "author={Bessarab, P. F. and Uzdin, V. M. and J{\'o}nsson, H.},\n" "journal={Computer Physics Communications},\n" "volume={196},\n" "pages={335--347},\n" diff --git a/src/SRD/fix_srd.cpp b/src/SRD/fix_srd.cpp index 76c5237f2d..0cec6fd794 100644 --- a/src/SRD/fix_srd.cpp +++ b/src/SRD/fix_srd.cpp @@ -60,17 +60,18 @@ enum { SHIFT_NO, SHIFT_YES, SHIFT_POSSIBLE }; #define TOLERANCE 0.00001 #define MAXITER 20 -static const char cite_fix_srd[] = "fix srd command:\n\n" - "@Article{Petersen10,\n" - " author = {M. K. Petersen, J. B. Lechman, S. J. Plimpton, G. " - "S. Grest, P. J. in 't Veld, P. R. Schunk},\n" - " title = {Mesoscale Hydrodynamics via Stochastic Rotation " - "Dynamics: Comparison with Lennard-Jones Fluid}," - " journal = {J.~Chem.~Phys.},\n" - " year = 2010,\n" - " volume = 132,\n" - " pages = {174106}\n" - "}\n\n"; +static const char cite_fix_srd[] = + "fix srd command: doi:10.1063/1.3419070\n\n" + "@Article{Petersen10,\n" + " author = {M. K. Petersen and J. B. Lechman and S. J. Plimpton and\n" + " G. S. Grest and in 't Veld, P. J. and P. R. Schunk},\n" + " title = {Mesoscale Hydrodynamics via Stochastic Rotation\n" + " Dynamics: Comparison with {L}ennard-{J}ones Fluid},\n" + " journal = {J.~Chem.\\ Phys.},\n" + " year = 2010,\n" + " volume = 132,\n" + " pages = 174106\n" + "}\n\n"; //#define SRD_DEBUG 1 //#define SRD_DEBUG_ATOMID 58 diff --git a/src/UEF/fix_nh_uef.cpp b/src/UEF/fix_nh_uef.cpp index 720c960252..71b076bddb 100644 --- a/src/UEF/fix_nh_uef.cpp +++ b/src/UEF/fix_nh_uef.cpp @@ -44,14 +44,16 @@ enum{ISO,ANISO,TRICLINIC}; // citation info static const char cite_user_uef_package[] = - "UEF package:\n\n" + "UEF package: doi:10.1063/1.4972894\n\n" "@Article{NicholsonRutledge16,\n" "author = {David A. Nicholson and Gregory C. Rutledge},\n" - "title = {Molecular simulation of flow-enhanced nucleation in n-eicosane melts under steady shear and uniaxial extension},\n" + "title = {Molecular Simulation of Flow-Enhanced Nucleation in\n" + " {$n$}-Eicosane Melts Under Steady Shear and Uniaxial Extension},\n" "journal = {The Journal of Chemical Physics},\n" "volume = {145},\n" "number = {24},\n" "pages = {244903},\n" + "doi = {10.1063/1.4972894},\n" "year = {2016}\n" "}\n\n"; diff --git a/src/atom.cpp b/src/atom.cpp index 91b72841f0..085b76def5 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -1891,15 +1891,26 @@ void Atom::add_molecule(int narg, char **arg) return -1 if does not exist ------------------------------------------------------------------------- */ -int Atom::find_molecule(char *id) +int Atom::find_molecule(const char *id) { if (id == nullptr) return -1; - int imol; - for (imol = 0; imol < nmolecule; imol++) + for (int imol = 0; imol < nmolecule; imol++) if (strcmp(id,molecules[imol]->id) == 0) return imol; return -1; } +/* ---------------------------------------------------------------------- + return vector of molecules which match template ID +------------------------------------------------------------------------- */ + +std::vectorAtom::get_molecule_by_id(const std::string &id) +{ + std::vector result; + for (int imol = 0; imol < nmolecule; ++imol) + if (id == molecules[imol]->id) result.push_back(molecules[imol]); + return result; +} + /* ---------------------------------------------------------------------- add info to current atom ilocal from molecule template onemol and its iatom offset = atom ID preceding IDs of atoms in this molecule @@ -1912,8 +1923,7 @@ void Atom::add_molecule_atom(Molecule *onemol, int iatom, int ilocal, tagint off if (onemol->radiusflag && radius_flag) radius[ilocal] = onemol->radius[iatom]; if (onemol->rmassflag && rmass_flag) rmass[ilocal] = onemol->rmass[iatom]; else if (rmass_flag) - rmass[ilocal] = 4.0*MY_PI/3.0 * - radius[ilocal]*radius[ilocal]*radius[ilocal]; + rmass[ilocal] = 4.0*MY_PI/3.0 * radius[ilocal]*radius[ilocal]*radius[ilocal]; if (onemol->bodyflag) { body[ilocal] = 0; // as if a body read from data file onemol->avec_body->data_body(ilocal,onemol->nibody,onemol->ndbody, @@ -1923,10 +1933,8 @@ void Atom::add_molecule_atom(Molecule *onemol, int iatom, int ilocal, tagint off // initialize custom per-atom properties to zero if present - for (int i = 0; i < nivector; ++i) - ivector[i][ilocal] = 0; - for (int i = 0; i < ndvector; ++i) - dvector[i][ilocal] = 0.0; + for (int i = 0; i < nivector; ++i) ivector[i][ilocal] = 0; + for (int i = 0; i < ndvector; ++i) dvector[i][ilocal] = 0.0; for (int i = 0; i < niarray; ++i) for (int j = 0; j < icols[i]; ++j) iarray[i][ilocal][j] = 0; diff --git a/src/atom.h b/src/atom.h index df43898dbf..399ad5023c 100644 --- a/src/atom.h +++ b/src/atom.h @@ -344,7 +344,8 @@ class Atom : protected Pointers { int shape_consistency(int, double &, double &, double &); void add_molecule(int, char **); - int find_molecule(char *); + int find_molecule(const char *); + std::vectorget_molecule_by_id(const std::string &); void add_molecule_atom(class Molecule *, int, int, tagint); void first_reorder(); diff --git a/src/comm.cpp b/src/comm.cpp index 9f46031185..5175af28e5 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -222,18 +222,18 @@ void Comm::init() if (force->bond) maxreverse = MAX(maxreverse,force->bond->comm_reverse); for (const auto &fix : fix_list) { - maxforward = MAX(maxforward,fix->comm_forward); - maxreverse = MAX(maxreverse,fix->comm_reverse); + maxforward = MAX(maxforward, fix->comm_forward); + maxreverse = MAX(maxreverse, fix->comm_reverse); } - for (int i = 0; i < modify->ncompute; i++) { - maxforward = MAX(maxforward,modify->compute[i]->comm_forward); - maxreverse = MAX(maxreverse,modify->compute[i]->comm_reverse); + for (const auto &compute : modify->get_compute_list()) { + maxforward = MAX(maxforward,compute->comm_forward); + maxreverse = MAX(maxreverse,compute->comm_reverse); } - for (int i = 0; i < output->ndump; i++) { - maxforward = MAX(maxforward,output->dump[i]->comm_forward); - maxreverse = MAX(maxreverse,output->dump[i]->comm_reverse); + for (const auto &dump: output->get_dump_list()) { + maxforward = MAX(maxforward,dump->comm_forward); + maxreverse = MAX(maxreverse,dump->comm_reverse); } if (force->newton == 0) maxreverse = 0; @@ -247,8 +247,7 @@ void Comm::init() maxexchange_atom = atom->avec->maxexchange; maxexchange_fix_dynamic = 0; - for (const auto &fix : fix_list) - if (fix->maxexchange_dynamic) maxexchange_fix_dynamic = 1; + for (const auto &fix : fix_list) if (fix->maxexchange_dynamic) maxexchange_fix_dynamic = 1; if ((mode == Comm::MULTI) && (neighbor->style != Neighbor::MULTI)) error->all(FLERR,"Cannot use comm mode multi without multi-style neighbor lists"); @@ -270,8 +269,7 @@ void Comm::init() void Comm::init_exchange() { maxexchange_fix = 0; - for (const auto &fix : modify->get_fix_list()) - maxexchange_fix += fix->maxexchange; + for (const auto &fix : modify->get_fix_list()) maxexchange_fix += fix->maxexchange; maxexchange = maxexchange_atom + maxexchange_fix; bufextra = maxexchange + BUFEXTRA; diff --git a/src/compute_angmom_chunk.cpp b/src/compute_angmom_chunk.cpp index 226e0cd646..a44e577de0 100644 --- a/src/compute_angmom_chunk.cpp +++ b/src/compute_angmom_chunk.cpp @@ -185,11 +185,8 @@ void ComputeAngmomChunk::lock_enable() void ComputeAngmomChunk::lock_disable() { - int icompute = modify->find_compute(idchunk); - if (icompute >= 0) { - cchunk = dynamic_cast(modify->compute[icompute]); - cchunk->lockcount--; - } + cchunk = dynamic_cast(modify->get_compute_by_id(idchunk)); + if(cchunk) cchunk->lockcount--; } /* ---------------------------------------------------------------------- diff --git a/src/compute_centroid_stress_atom.cpp b/src/compute_centroid_stress_atom.cpp index ee362927cf..1e11cd0f50 100644 --- a/src/compute_centroid_stress_atom.cpp +++ b/src/compute_centroid_stress_atom.cpp @@ -36,12 +36,12 @@ using namespace LAMMPS_NS; enum { NOBIAS, BIAS }; static const char cite_centroid_angle_improper_dihedral[] = - "compute centroid/stress/atom for angles, impropers and dihedrals:\n\n" - "@article{PhysRevE.99.051301,\n" - " title = {Application of atomic stress to compute heat flux via molecular dynamics for " - "systems with many-body interactions},\n" + "compute centroid/stress/atom for angles, impropers and dihedrals: doi:10.1103/PhysRevE.99.051301\n\n" + "@article{Surblys2019,\n" + " title = {Application of Atomic Stress to Compute Heat Flux via Molecular\n" + " Dynamics for Systems With Many-Body Interactions},\n" " author = {Surblys, Donatas and Matsubara, Hiroki and Kikugawa, Gota and Ohara, Taku},\n" - " journal = {Physical Review E},\n" + " journal = {Physical Review~E},\n" " volume = {99},\n" " issue = {5},\n" " pages = {051301},\n" @@ -51,12 +51,12 @@ static const char cite_centroid_angle_improper_dihedral[] = "}\n\n"; static const char cite_centroid_shake_rigid[] = - "compute centroid/stress/atom for constrained dynamics:\n\n" - "@article{doi:10.1063/5.0070930,\n" + "compute centroid/stress/atom for constrained dynamics: doi:10.1063/5.0070930\n\n" + "@article{Surblys2021,\n" " author = {Surblys, Donatas and Matsubara, Hiroki and Kikugawa, Gota and Ohara, Taku},\n" " journal = {Journal of Applied Physics},\n" - " title = {Methodology and meaning of computing heat flux via atomic stress in systems with " - "constraint dynamics},\n" + " title = {Methodology and Meaning of Computing Heat Flux via Atomic Stress in Systems with\n" + " Constraint Dynamics},\n" " volume = {130},\n" " number = {21},\n" " pages = {215104},\n" diff --git a/src/compute_chunk_spread_atom.cpp b/src/compute_chunk_spread_atom.cpp index 3781e83aa7..a68174e058 100644 --- a/src/compute_chunk_spread_atom.cpp +++ b/src/compute_chunk_spread_atom.cpp @@ -89,21 +89,21 @@ ComputeChunkSpreadAtom(LAMMPS *lmp, int narg, char **arg) : for (int i = 0; i < nvalues; i++) { if (which[i] == ArgInfo::COMPUTE) { - int icompute = modify->find_compute(ids[i]); - if (icompute < 0) - error->all(FLERR,"Compute ID for compute chunk/spread/atom does not exist"); + auto icompute = modify->get_compute_by_id(ids[i]); + if (!icompute) + error->all(FLERR,"Compute ID {} for compute chunk/spread/atom does not exist", ids[i]); - if (!utils::strmatch(modify->compute[icompute]->style,"/chunk$")) + if (!utils::strmatch(icompute->style,"/chunk$")) error->all(FLERR,"Compute for compute chunk/spread/atom " "does not calculate per-chunk values"); if (argindex[i] == 0) { - if (!modify->compute[icompute]->vector_flag) + if (!icompute->vector_flag) error->all(FLERR,"Compute chunk/spread/atom compute does not calculate global vector"); } else { - if (!modify->compute[icompute]->array_flag) + if (!icompute->array_flag) error->all(FLERR,"Compute chunk/spread/atom compute does not calculate global array"); - if (argindex[i] > modify->compute[icompute]->size_array_cols) + if (argindex[i] > icompute->size_array_cols) error->all(FLERR,"Compute chunk/spread/atom compute array is accessed out-of-range"); } @@ -164,14 +164,13 @@ void ComputeChunkSpreadAtom::init() if (which[m] == ArgInfo::COMPUTE) { int icompute = modify->find_compute(ids[m]); if (icompute < 0) - error->all(FLERR,"Compute ID for compute chunk/spread/atom " - "does not exist"); + error->all(FLERR,"Compute ID {} for compute chunk/spread/atom does not exist", ids[m]); value2index[m] = icompute; } else if (which[m] == ArgInfo::FIX) { int ifix = modify->find_fix(ids[m]); if (ifix < 0) - error->all(FLERR,"Fix ID for compute chunk/spread/atom does not exist"); + error->all(FLERR,"Fix ID {} for compute chunk/spread/atom does not exist", ids[m]); value2index[m] = ifix; } } @@ -181,12 +180,11 @@ void ComputeChunkSpreadAtom::init() void ComputeChunkSpreadAtom::init_chunk() { - int icompute = modify->find_compute(idchunk); - if (icompute < 0) - error->all(FLERR,"Chunk/atom compute does not exist for compute chunk/spread/atom"); - cchunk = dynamic_cast( modify->compute[icompute]); + cchunk = dynamic_cast( modify->get_compute_by_id(idchunk)); + if (!cchunk) + error->all(FLERR,"Chunk/atom compute does not exist for compute chunk/spread/atom {}", idchunk); if (strcmp(cchunk->style,"chunk/atom") != 0) - error->all(FLERR,"Compute chunk/spread/atom does not use chunk/atom compute"); + error->all(FLERR,"Compute chunk/spread/atom {} does not use chunk/atom compute", idchunk); } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_msd.cpp b/src/compute_msd.cpp index 7ecb89b4c0..90d8f47b7a 100644 --- a/src/compute_msd.cpp +++ b/src/compute_msd.cpp @@ -27,8 +27,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -ComputeMSD::ComputeMSD(LAMMPS *lmp, int narg, char **arg) - : Compute(lmp, narg, arg), id_fix(nullptr) +ComputeMSD::ComputeMSD(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), id_fix(nullptr) { if (narg < 3) error->all(FLERR, "Illegal compute msd command"); @@ -46,15 +45,15 @@ ComputeMSD::ComputeMSD(LAMMPS *lmp, int narg, char **arg) int iarg = 3; while (iarg < narg) { if (strcmp(arg[iarg], "com") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal compute msd command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "compute msd com", error); comflag = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg], "average") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal compute msd command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "compute msd average", error); avflag = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else - error->all(FLERR, "Illegal compute msd command"); + error->all(FLERR, "Unknown compute msd keyword: {}", arg[iarg]); } if (group->dynamic[igroup]) diff --git a/src/compute_pe_atom.cpp b/src/compute_pe_atom.cpp index a627e133e5..b1b62ec16d 100644 --- a/src/compute_pe_atom.cpp +++ b/src/compute_pe_atom.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -13,30 +12,31 @@ ------------------------------------------------------------------------- */ #include "compute_pe_atom.h" -#include -#include "atom.h" -#include "update.h" -#include "comm.h" -#include "force.h" -#include "pair.h" -#include "bond.h" + #include "angle.h" +#include "atom.h" +#include "bond.h" +#include "comm.h" #include "dihedral.h" +#include "error.h" +#include "force.h" #include "improper.h" #include "kspace.h" -#include "modify.h" #include "memory.h" -#include "error.h" +#include "modify.h" +#include "pair.h" +#include "update.h" + +#include using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ ComputePEAtom::ComputePEAtom(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), - energy(nullptr) + Compute(lmp, narg, arg), energy(nullptr) { - if (narg < 3) error->all(FLERR,"Illegal compute pe/atom command"); + if (narg < 3) error->all(FLERR, "Illegal compute pe/atom command"); peratom_flag = 1; size_peratom_cols = 0; @@ -56,14 +56,22 @@ ComputePEAtom::ComputePEAtom(LAMMPS *lmp, int narg, char **arg) : fixflag = 0; int iarg = 3; while (iarg < narg) { - if (strcmp(arg[iarg],"pair") == 0) pairflag = 1; - else if (strcmp(arg[iarg],"bond") == 0) bondflag = 1; - else if (strcmp(arg[iarg],"angle") == 0) angleflag = 1; - else if (strcmp(arg[iarg],"dihedral") == 0) dihedralflag = 1; - else if (strcmp(arg[iarg],"improper") == 0) improperflag = 1; - else if (strcmp(arg[iarg],"kspace") == 0) kspaceflag = 1; - else if (strcmp(arg[iarg],"fix") == 0) fixflag = 1; - else error->all(FLERR,"Illegal compute pe/atom command"); + if (strcmp(arg[iarg], "pair") == 0) + pairflag = 1; + else if (strcmp(arg[iarg], "bond") == 0) + bondflag = 1; + else if (strcmp(arg[iarg], "angle") == 0) + angleflag = 1; + else if (strcmp(arg[iarg], "dihedral") == 0) + dihedralflag = 1; + else if (strcmp(arg[iarg], "improper") == 0) + improperflag = 1; + else if (strcmp(arg[iarg], "kspace") == 0) + kspaceflag = 1; + else if (strcmp(arg[iarg], "fix") == 0) + fixflag = 1; + else + error->all(FLERR, "Illegal compute pe/atom command"); iarg++; } } @@ -86,7 +94,7 @@ void ComputePEAtom::compute_peratom() invoked_peratom = update->ntimestep; if (update->eflag_atom != invoked_peratom) - error->all(FLERR,"Per-atom energy was not tallied on needed timestep"); + error->all(FLERR, "Per-atom energy was not tallied on needed timestep"); // grow local energy array if necessary // needs to be atom->nmax in length @@ -94,7 +102,7 @@ void ComputePEAtom::compute_peratom() if (atom->nmax > nmax) { memory->destroy(energy); nmax = atom->nmax; - memory->create(energy,nmax,"pe/atom:energy"); + memory->create(energy, nmax, "pe/atom:energy"); vector_atom = energy; } @@ -153,13 +161,11 @@ void ComputePEAtom::compute_peratom() // add in per-atom contributions from relevant fixes // always only for owned atoms, not ghost - if (fixflag && modify->n_energy_atom) - modify->energy_atom(nlocal,energy); + if (fixflag && modify->n_energy_atom) modify->energy_atom(nlocal, energy); // communicate ghost energy between neighbor procs - if (force->newton || (force->kspace && force->kspace->tip4pflag)) - comm->reverse_comm(this); + if (force->newton || (force->kspace && force->kspace->tip4pflag)) comm->reverse_comm(this); // zero energy of atoms not in group // only do this after comm since ghost contributions must be included @@ -174,7 +180,7 @@ void ComputePEAtom::compute_peratom() int ComputePEAtom::pack_reverse_comm(int n, int first, double *buf) { - int i,m,last; + int i, m, last; m = 0; last = first + n; @@ -186,7 +192,7 @@ int ComputePEAtom::pack_reverse_comm(int n, int first, double *buf) void ComputePEAtom::unpack_reverse_comm(int n, int *list, double *buf) { - int i,j,m; + int i, j, m; m = 0; for (i = 0; i < n; i++) { @@ -201,6 +207,6 @@ void ComputePEAtom::unpack_reverse_comm(int n, int *list, double *buf) double ComputePEAtom::memory_usage() { - double bytes = (double)nmax * sizeof(double); + double bytes = (double) nmax * sizeof(double); return bytes; } diff --git a/src/create_atoms.cpp b/src/create_atoms.cpp index da352e3ae5..85e83d694f 100644 --- a/src/create_atoms.cpp +++ b/src/create_atoms.cpp @@ -299,7 +299,7 @@ void CreateAtoms::command(int narg, char **arg) if (onemol->tag_require && !atom->tag_enable) error->all(FLERR, "Create_atoms molecule has atom IDs, but system does not"); - onemol->check_attributes(0); + onemol->check_attributes(); // use geometric center of molecule for insertion // molecule random number generator, different for each proc diff --git a/src/dump.cpp b/src/dump.cpp index 9a8bac052a..c4b4cc02e9 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -1035,31 +1035,31 @@ void Dump::balance() void Dump::modify_params(int narg, char **arg) { - if (narg == 0) error->all(FLERR,"Illegal dump_modify command"); + if (narg == 0) utils::missing_cmd_args(FLERR, "dump_modify", error); int iarg = 0; while (iarg < narg) { if (strcmp(arg[iarg],"append") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify append", error); append_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"buffer") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify buffer", error); buffer_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); if (buffer_flag && buffer_allow == 0) error->all(FLERR,"Dump_modify buffer yes not allowed for this style"); iarg += 2; } else if (strcmp(arg[iarg],"delay") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify delay", error); delaystep = utils::bnumeric(FLERR,arg[iarg+1],false,lmp); if (delaystep >= 0) delay_flag = 1; else delay_flag = 0; iarg += 2; } else if (strcmp(arg[iarg],"every") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify every", error); int idump; for (idump = 0; idump < output->ndump; idump++) if (strcmp(id,output->dump[idump]->id) == 0) break; @@ -1070,14 +1070,14 @@ void Dump::modify_params(int narg, char **arg) n = 0; } else { n = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (n <= 0) error->all(FLERR,"Illegal dump_modify command"); + if (n <= 0) error->all(FLERR, "Invalid dump_modify every argument: {}", n); } output->mode_dump[idump] = 0; output->every_dump[idump] = n; iarg += 2; } else if (strcmp(arg[iarg],"every/time") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify every/time", error); int idump; for (idump = 0; idump < output->ndump; idump++) if (strcmp(id,output->dump[idump]->id) == 0) break; @@ -1088,7 +1088,7 @@ void Dump::modify_params(int narg, char **arg) delta = 0.0; } else { delta = utils::numeric(FLERR,arg[iarg+1],false,lmp); - if (delta <= 0.0) error->all(FLERR,"Illegal dump_modify command"); + if (delta <= 0.0) error->all(FLERR, "Invalid dump_modify every/time argument: {}", delta); } output->mode_dump[idump] = 1; output->every_time_dump[idump] = delta; @@ -1096,11 +1096,11 @@ void Dump::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"fileper") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify fileper", error); if (!multiproc) error->all(FLERR,"Cannot use dump_modify fileper without % in dump file name"); int nper = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (nper <= 0) error->all(FLERR,"Illegal dump_modify command"); + if (nper <= 0) error->all(FLERR, "Invalid dump_modify fileper argument: {}", nper); multiproc = nprocs/nper; if (nprocs % nper) multiproc++; @@ -1122,22 +1122,22 @@ void Dump::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"first") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify first", error); first_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"flush") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify flush", error); flush_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"colname") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify colname", error); if (strcmp(arg[iarg+1],"default") == 0) { for (auto item : keyword_user) item.clear(); iarg += 2; } else { - if (iarg+3 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+3 > narg) utils::missing_cmd_args(FLERR, "dump_modify colname", error); int icol = -1; if (utils::is_integer(arg[iarg + 1])) { icol = utils::inumeric(FLERR,arg[iarg + 1],false,lmp); @@ -1157,7 +1157,7 @@ void Dump::modify_params(int narg, char **arg) iarg += 3; } } else if (strcmp(arg[iarg],"format") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify format", error); if (strcmp(arg[iarg+1],"none") == 0) { delete[] format_line_user; @@ -1175,7 +1175,7 @@ void Dump::modify_params(int narg, char **arg) continue; } - if (iarg+3 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+3 > narg) utils::missing_cmd_args(FLERR, "dump_modify format", error); if (strcmp(arg[iarg+1],"line") == 0) { delete[] format_line_user; @@ -1183,17 +1183,17 @@ void Dump::modify_params(int narg, char **arg) iarg += 3; } else { // pass other format options to child classes int n = modify_param(narg-iarg,&arg[iarg]); - if (n == 0) error->all(FLERR,"Illegal dump_modify command"); + if (n == 0) error->all(FLERR,"Unknown dump_modify format keyword: {}", arg[iarg+1]); iarg += n; } } else if (strcmp(arg[iarg],"header") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify header", error); write_header_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"maxfiles") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify maxfiles", error); if (!multifile) error->all(FLERR,"Cannot use dump_modify maxfiles without * in dump file name"); // wipe out existing storage @@ -1203,7 +1203,7 @@ void Dump::modify_params(int narg, char **arg) delete[] nameslist; } maxfiles = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (maxfiles == 0) error->all(FLERR,"Illegal dump_modify command"); + if (maxfiles == 0) error->all(FLERR, "Invalid dump_modify maxfiles argument: {}", maxfiles); if (maxfiles > 0) { nameslist = new char*[maxfiles]; numfiles = 0; @@ -1213,11 +1213,11 @@ void Dump::modify_params(int narg, char **arg) } iarg += 2; } else if (strcmp(arg[iarg],"nfile") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify nfile", error); if (!multiproc) error->all(FLERR,"Cannot use dump_modify nfile without % in dump file name"); int nfile = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (nfile <= 0) error->all(FLERR,"Illegal dump_modify command"); + if (nfile <= 0) error->all(FLERR, "Invalid dump_modify nfile argument: {}", nfile); nfile = MIN(nfile,nprocs); multiproc = nfile; @@ -1244,18 +1244,18 @@ void Dump::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"pad") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify pad", error); padflag = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (padflag < 0) error->all(FLERR,"Illegal dump_modify command"); + if (padflag < 0) error->all(FLERR, "Invalid dump_modify pad argument: {}", padflag); iarg += 2; } else if (strcmp(arg[iarg],"pbc") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify pbc", error); pbcflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"sort") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify sort", error); if (strcmp(arg[iarg+1],"off") == 0) sort_flag = 0; else if (strcmp(arg[iarg+1],"id") == 0) { sort_flag = 1; @@ -1265,7 +1265,7 @@ void Dump::modify_params(int narg, char **arg) sort_flag = 1; sortcol = utils::inumeric(FLERR,arg[iarg+1],false,lmp); sortorder = ASCEND; - if (sortcol == 0) error->all(FLERR,"Illegal dump_modify command"); + if (sortcol == 0) error->all(FLERR, "Invalid dump_modify sort argument: {}", sortcol); if (sortcol < 0) { sortorder = DESCEND; sortcol = -sortcol; @@ -1275,24 +1275,24 @@ void Dump::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"balance") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify blance", error); if (nprocs > 1) balance_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"time") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify time", error); time_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"units") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "dump_modify units", error); unit_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else { int n = modify_param(narg-iarg,&arg[iarg]); - if (n == 0) error->all(FLERR,"Illegal dump_modify command"); + if (n == 0) error->all(FLERR,"Unknown dump_modify keyword: {}", arg[iarg]); iarg += n; } } diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp index 9389839aca..1e7ad367ec 100644 --- a/src/dump_custom.cpp +++ b/src/dump_custom.cpp @@ -262,10 +262,11 @@ void DumpCustom::init_style() auto words = utils::split_words(format); if ((int) words.size() < nfield) - error->all(FLERR,"Dump_modify format line is too short"); + error->all(FLERR,"Dump_modify format line is too short: {}", format); int i=0; for (const auto &word : words) { + if (i >= nfield) break; delete[] vformat[i]; if (format_column_user[i]) @@ -1673,7 +1674,7 @@ int DumpCustom::modify_param(int narg, char **arg) } if (strcmp(arg[0],"format") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); + if (narg < 2) utils::missing_cmd_args(FLERR, "dump_modify format", error); if (strcmp(arg[1],"none") == 0) { // just clear format_column_user allocated by this dump child class @@ -1684,7 +1685,7 @@ int DumpCustom::modify_param(int narg, char **arg) return 2; } - if (narg < 3) error->all(FLERR,"Illegal dump_modify command"); + if (narg < 3) utils::missing_cmd_args(FLERR, "dump_modify format", error); if (strcmp(arg[1],"int") == 0) { delete[] format_int_user; @@ -1710,7 +1711,7 @@ int DumpCustom::modify_param(int narg, char **arg) } else { int i = utils::inumeric(FLERR,arg[1],false,lmp) - 1; if (i < 0 || i >= nfield) - error->all(FLERR,"Illegal dump_modify command"); + error->all(FLERR,"Unknown dump_modify format ID keyword: {}", arg[1]); delete[] format_column_user[i]; format_column_user[i] = utils::strdup(arg[2]); } @@ -1731,7 +1732,7 @@ int DumpCustom::modify_param(int narg, char **arg) } if (strcmp(arg[0],"refresh") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); + if (narg < 2) utils::missing_cmd_args(FLERR, "dump_modify refresh", error); ArgInfo argi(arg[1],ArgInfo::COMPUTE); if ((argi.get_type() != ArgInfo::COMPUTE) || (argi.get_dim() != 0)) error->all(FLERR,"Illegal dump_modify command"); @@ -1743,7 +1744,7 @@ int DumpCustom::modify_param(int narg, char **arg) } if (strcmp(arg[0],"thresh") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); + if (narg < 2) utils::missing_cmd_args(FLERR, "dump_modify thresh", error); if (strcmp(arg[1],"none") == 0) { if (nthresh) { memory->destroy(thresh_array); @@ -1765,7 +1766,7 @@ int DumpCustom::modify_param(int narg, char **arg) return 2; } - if (narg < 4) error->all(FLERR,"Illegal dump_modify command"); + if (narg < 4) utils::missing_cmd_args(FLERR, "dump_modify thresh", error); // grow threshold arrays diff --git a/src/dump_local.cpp b/src/dump_local.cpp index 5fad243e74..bf26890b05 100644 --- a/src/dump_local.cpp +++ b/src/dump_local.cpp @@ -185,10 +185,11 @@ void DumpLocal::init_style() auto words = utils::split_words(format); if ((int) words.size() < size_one) - error->all(FLERR,"Dump_modify format line is too short"); + error->all(FLERR,"Dump_modify format line is too short: {}", format); int i=0; for (const auto &word : words) { + if (i >= size_one) break; delete[] vformat[i]; if (format_column_user[i]) diff --git a/src/fix_addforce.cpp b/src/fix_addforce.cpp index 48b006eb2d..b4d13ff5fa 100644 --- a/src/fix_addforce.cpp +++ b/src/fix_addforce.cpp @@ -38,7 +38,7 @@ FixAddForce::FixAddForce(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), xstr(nullptr), ystr(nullptr), zstr(nullptr), estr(nullptr), idregion(nullptr), region(nullptr), sforce(nullptr) { - if (narg < 6) error->all(FLERR, "Illegal fix addforce command"); + if (narg < 6) utils::missing_cmd_args(FLERR, "fix addforce", error); dynamic_group_allow = 1; scalar_flag = 1; @@ -77,25 +77,25 @@ FixAddForce::FixAddForce(LAMMPS *lmp, int narg, char **arg) : int iarg = 6; while (iarg < narg) { if (strcmp(arg[iarg], "every") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal fix addforce command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "fix addforce every", error); nevery = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); - if (nevery <= 0) error->all(FLERR, "Illegal fix addforce command"); + if (nevery <= 0) error->all(FLERR, "Invalid fix addforce every argument: {}", nevery); iarg += 2; } else if (strcmp(arg[iarg], "region") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal fix addforce command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "fix addforce region", error); region = domain->get_region_by_id(arg[iarg + 1]); if (!region) error->all(FLERR, "Region {} for fix addforce does not exist", arg[iarg + 1]); idregion = utils::strdup(arg[iarg + 1]); iarg += 2; } else if (strcmp(arg[iarg], "energy") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal fix addforce command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "fix addforce energy", error); if (utils::strmatch(arg[iarg + 1], "^v_")) { estr = utils::strdup(arg[iarg + 1] + 2); } else - error->all(FLERR, "Illegal fix addforce command"); + error->all(FLERR, "Invalid fix addforce energy argument: {}", arg[iarg + 1]); iarg += 2; } else - error->all(FLERR, "Illegal fix addforce command"); + error->all(FLERR, "Unknown fix addforce keyword: {}", arg[iarg]); } force_flag = 0; diff --git a/src/fix_deposit.cpp b/src/fix_deposit.cpp index fd6eb3e36a..be30fbc97b 100644 --- a/src/fix_deposit.cpp +++ b/src/fix_deposit.cpp @@ -117,7 +117,7 @@ FixDeposit::FixDeposit(LAMMPS *lmp, int narg, char **arg) : if (atom->molecular == Atom::TEMPLATE && onemols != atom->avec->onemols) error->all(FLERR,"Fix deposit molecule template ID must be same " "as atom_style template ID"); - onemols[i]->check_attributes(0); + onemols[i]->check_attributes(); // fix deposit uses geoemetric center of molecule for insertion diff --git a/src/fix_indent.cpp b/src/fix_indent.cpp index 3f99d14a8c..f38ab5efa6 100644 --- a/src/fix_indent.cpp +++ b/src/fix_indent.cpp @@ -43,7 +43,7 @@ FixIndent::FixIndent(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), xstr(nullptr), ystr(nullptr), zstr(nullptr), rstr(nullptr), pstr(nullptr) { - if (narg < 4) error->all(FLERR,"Illegal fix indent command"); + if (narg < 4) utils::missing_cmd_args(FLERR, "fix indent", error); scalar_flag = 1; vector_flag = 1; @@ -83,7 +83,7 @@ FixIndent::FixIndent(LAMMPS *lmp, int narg, char **arg) : if (cdim == 0 && !pstr) pvalue *= xscale; else if (cdim == 1 && !pstr) pvalue *= yscale; else if (cdim == 2 && !pstr) pvalue *= zscale; - } else error->all(FLERR,"Illegal fix indent command"); + } else error->all(FLERR,"Unknown fix indent keyword: {}", istyle); varflag = 0; if (xstr || ystr || zstr || rstr || pstr) varflag = 1; @@ -121,37 +121,37 @@ void FixIndent::init() if (xstr) { xvar = input->variable->find(xstr); if (xvar < 0) - error->all(FLERR,"Variable name for fix indent does not exist"); + error->all(FLERR,"Variable {} for fix indent does not exist", xstr); if (!input->variable->equalstyle(xvar)) - error->all(FLERR,"Variable for fix indent is invalid style"); + error->all(FLERR,"Variable {} for fix indent is invalid style", xstr); } if (ystr) { yvar = input->variable->find(ystr); if (yvar < 0) - error->all(FLERR,"Variable name for fix indent does not exist"); + error->all(FLERR,"Variable {} for fix indent does not exist", ystr); if (!input->variable->equalstyle(yvar)) - error->all(FLERR,"Variable for fix indent is not equal style"); + error->all(FLERR,"Variable {} for fix indent is invalid style", ystr); } if (zstr) { zvar = input->variable->find(zstr); if (zvar < 0) - error->all(FLERR,"Variable name for fix indent does not exist"); + error->all(FLERR,"Variable {} for fix indent does not exist", zstr); if (!input->variable->equalstyle(zvar)) - error->all(FLERR,"Variable for fix indent is not equal style"); + error->all(FLERR,"Variable {} for fix indent is invalid style", zstr); } if (rstr) { rvar = input->variable->find(rstr); if (rvar < 0) - error->all(FLERR,"Variable name for fix indent does not exist"); + error->all(FLERR,"Variable {} for fix indent does not exist", rstr); if (!input->variable->equalstyle(rvar)) - error->all(FLERR,"Variable for fix indent is not equal style"); + error->all(FLERR,"Variable {} for fix indent is invalid style", rstr); } if (pstr) { pvar = input->variable->find(pstr); if (pvar < 0) - error->all(FLERR,"Variable name for fix indent does not exist"); + error->all(FLERR,"Variable {} for fix indent does not exist", pstr); if (!input->variable->equalstyle(pvar)) - error->all(FLERR,"Variable for fix indent is not equal style"); + error->all(FLERR,"Variable {} for fix indent is invalid style", pstr); } if (utils::strmatch(update->integrate_style,"^respa")) { @@ -405,7 +405,7 @@ double FixIndent::compute_vector(int n) void FixIndent::options(int narg, char **arg) { - if (narg < 0) error->all(FLERR,"Illegal fix indent command"); + if (narg < 0) utils::missing_cmd_args(FLERR, "fix indent", error); istyle = NONE; xstr = ystr = zstr = rstr = pstr = nullptr; @@ -416,7 +416,7 @@ void FixIndent::options(int narg, char **arg) int iarg = 0; while (iarg < narg) { if (strcmp(arg[iarg],"sphere") == 0) { - if (iarg+5 > narg) error->all(FLERR,"Illegal fix indent command"); + if (iarg+5 > narg) utils::missing_cmd_args(FLERR, "fix indent sphere", error); if (utils::strmatch(arg[iarg+1],"^v_")) { xstr = utils::strdup(arg[iarg+1]+2); @@ -435,7 +435,7 @@ void FixIndent::options(int narg, char **arg) iarg += 5; } else if (strcmp(arg[iarg],"cylinder") == 0) { - if (iarg+5 > narg) error->all(FLERR,"Illegal fix indent command"); + if (iarg+5 > narg) utils::missing_cmd_args(FLERR, "fix indent cylinder", error); if (strcmp(arg[iarg+1],"x") == 0) { cdim = 0; @@ -461,7 +461,7 @@ void FixIndent::options(int narg, char **arg) if (utils::strmatch(arg[iarg+3],"^v_")) { ystr = utils::strdup(arg[iarg+3]+2); } else yvalue = utils::numeric(FLERR,arg[iarg+3],false,lmp); - } else error->all(FLERR,"Illegal fix indent command"); + } else error->all(FLERR,"Unknown fix indent cylinder argument: {}", arg[iarg+1]); if (utils::strmatch(arg[iarg+4],"^v_")) { rstr = utils::strdup(arg[iarg+4]+2); @@ -471,11 +471,11 @@ void FixIndent::options(int narg, char **arg) iarg += 5; } else if (strcmp(arg[iarg],"plane") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix indent command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix indent plane", error); if (strcmp(arg[iarg+1],"x") == 0) cdim = 0; else if (strcmp(arg[iarg+1],"y") == 0) cdim = 1; else if (strcmp(arg[iarg+1],"z") == 0) cdim = 2; - else error->all(FLERR,"Illegal fix indent command"); + else error->all(FLERR,"Unknown fix indent plane argument: {}", arg[iarg+1]); if (utils::strmatch(arg[iarg+2],"^v_")) { pstr = utils::strdup(arg[iarg+2]+2); @@ -483,23 +483,23 @@ void FixIndent::options(int narg, char **arg) if (strcmp(arg[iarg+3],"lo") == 0) planeside = -1; else if (strcmp(arg[iarg+3],"hi") == 0) planeside = 1; - else error->all(FLERR,"Illegal fix indent command"); + else error->all(FLERR,"Unknown fix indent plane argument: {}", arg[iarg+3]); istyle = PLANE; iarg += 4; } else if (strcmp(arg[iarg],"units") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix indent command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix indent units", error); if (strcmp(arg[iarg+1],"box") == 0) scaleflag = 0; else if (strcmp(arg[iarg+1],"lattice") == 0) scaleflag = 1; - else error->all(FLERR,"Illegal fix indent command"); + else error->all(FLERR,"Unknown fix indent units argument: {}", arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"side") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix indent command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix indent side", error); if (strcmp(arg[iarg+1],"in") == 0) side = INSIDE; else if (strcmp(arg[iarg+1],"out") == 0) side = OUTSIDE; - else error->all(FLERR,"Illegal fix indent command"); + else error->all(FLERR,"Unknown fix indent side argument: {}", arg[iarg+1]); iarg += 2; - } else error->all(FLERR,"Illegal fix indent command"); + } else error->all(FLERR,"Unknown fix indent argument: {}", arg[iarg]); } } diff --git a/src/fix_langevin.cpp b/src/fix_langevin.cpp index 98b8f5274a..84a628eefe 100644 --- a/src/fix_langevin.cpp +++ b/src/fix_langevin.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -44,21 +43,20 @@ using namespace LAMMPS_NS; using namespace FixConst; -enum{NOBIAS,BIAS}; -enum{CONSTANT,EQUAL,ATOM}; +enum { NOBIAS, BIAS }; +enum { CONSTANT, EQUAL, ATOM }; -#define SINERTIA 0.4 // moment of inertia prefactor for sphere -#define EINERTIA 0.2 // moment of inertia prefactor for ellipsoid +#define SINERTIA 0.4 // moment of inertia prefactor for sphere +#define EINERTIA 0.2 // moment of inertia prefactor for ellipsoid /* ---------------------------------------------------------------------- */ FixLangevin::FixLangevin(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), - gjfflag(0), gfactor1(nullptr), gfactor2(nullptr), ratio(nullptr), tstr(nullptr), - flangevin(nullptr), tforce(nullptr), franprev(nullptr), - lv(nullptr), id_temp(nullptr), random(nullptr) + Fix(lmp, narg, arg), gjfflag(0), gfactor1(nullptr), gfactor2(nullptr), ratio(nullptr), + tstr(nullptr), flangevin(nullptr), tforce(nullptr), franprev(nullptr), lv(nullptr), + id_temp(nullptr), random(nullptr) { - if (narg < 7) error->all(FLERR,"Illegal fix langevin command"); + if (narg < 7) error->all(FLERR, "Illegal fix langevin command"); dynamic_group_allow = 1; scalar_flag = 1; @@ -67,30 +65,30 @@ FixLangevin::FixLangevin(LAMMPS *lmp, int narg, char **arg) : ecouple_flag = 1; nevery = 1; - if (utils::strmatch(arg[3],"^v_")) { - tstr = utils::strdup(arg[3]+2); + if (utils::strmatch(arg[3], "^v_")) { + tstr = utils::strdup(arg[3] + 2); } else { - t_start = utils::numeric(FLERR,arg[3],false,lmp); + t_start = utils::numeric(FLERR, arg[3], false, lmp); t_target = t_start; tstyle = CONSTANT; } - t_stop = utils::numeric(FLERR,arg[4],false,lmp); - t_period = utils::numeric(FLERR,arg[5],false,lmp); - seed = utils::inumeric(FLERR,arg[6],false,lmp); + t_stop = utils::numeric(FLERR, arg[4], false, lmp); + t_period = utils::numeric(FLERR, arg[5], false, lmp); + seed = utils::inumeric(FLERR, arg[6], false, lmp); - if (t_period <= 0.0) error->all(FLERR,"Fix langevin period must be > 0.0"); - if (seed <= 0) error->all(FLERR,"Illegal fix langevin command"); + if (t_period <= 0.0) error->all(FLERR, "Fix langevin period must be > 0.0"); + if (seed <= 0) error->all(FLERR, "Illegal fix langevin command"); // initialize Marsaglia RNG with processor-unique seed - random = new RanMars(lmp,seed + comm->me); + random = new RanMars(lmp, seed + comm->me); // allocate per-type arrays for force prefactors - gfactor1 = new double[atom->ntypes+1]; - gfactor2 = new double[atom->ntypes+1]; - ratio = new double[atom->ntypes+1]; + gfactor1 = new double[atom->ntypes + 1]; + gfactor2 = new double[atom->ntypes + 1]; + ratio = new double[atom->ntypes + 1]; // optional args @@ -105,48 +103,48 @@ FixLangevin::FixLangevin(LAMMPS *lmp, int narg, char **arg) : int iarg = 7; while (iarg < narg) { - if (strcmp(arg[iarg],"angmom") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix langevin command"); - if (strcmp(arg[iarg+1],"no") == 0) ascale = 0.0; - else ascale = utils::numeric(FLERR,arg[iarg+1],false,lmp); + if (strcmp(arg[iarg], "angmom") == 0) { + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix langevin command"); + if (strcmp(arg[iarg + 1], "no") == 0) + ascale = 0.0; + else + ascale = utils::numeric(FLERR, arg[iarg + 1], false, lmp); iarg += 2; - } else if (strcmp(arg[iarg],"gjf") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix langevin command"); - if (strcmp(arg[iarg+1],"no") == 0) { + } else if (strcmp(arg[iarg], "gjf") == 0) { + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix langevin command"); + if (strcmp(arg[iarg + 1], "no") == 0) { gjfflag = 0; osflag = 0; - } - else if (strcmp(arg[iarg+1],"vfull") == 0) { + } else if (strcmp(arg[iarg + 1], "vfull") == 0) { gjfflag = 1; osflag = 1; - } - else if (strcmp(arg[iarg+1],"vhalf") == 0) { + } else if (strcmp(arg[iarg + 1], "vhalf") == 0) { gjfflag = 1; osflag = 0; - } - else error->all(FLERR,"Illegal fix langevin command"); + } else + error->all(FLERR, "Illegal fix langevin command"); iarg += 2; - } else if (strcmp(arg[iarg],"omega") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix langevin command"); - oflag = utils::logical(FLERR,arg[iarg+1],false,lmp); + } else if (strcmp(arg[iarg], "omega") == 0) { + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix langevin command"); + oflag = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; - } else if (strcmp(arg[iarg],"scale") == 0) { - if (iarg+3 > narg) error->all(FLERR,"Illegal fix langevin command"); - int itype = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - double scale = utils::numeric(FLERR,arg[iarg+2],false,lmp); - if (itype <= 0 || itype > atom->ntypes) - error->all(FLERR,"Illegal fix langevin command"); + } else if (strcmp(arg[iarg], "scale") == 0) { + if (iarg + 3 > narg) error->all(FLERR, "Illegal fix langevin command"); + int itype = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); + double scale = utils::numeric(FLERR, arg[iarg + 2], false, lmp); + if (itype <= 0 || itype > atom->ntypes) error->all(FLERR, "Illegal fix langevin command"); ratio[itype] = scale; iarg += 3; - } else if (strcmp(arg[iarg],"tally") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix langevin command"); - tallyflag = utils::logical(FLERR,arg[iarg+1],false,lmp); + } else if (strcmp(arg[iarg], "tally") == 0) { + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix langevin command"); + tallyflag = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; - } else if (strcmp(arg[iarg],"zero") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix langevin command"); - zeroflag = utils::logical(FLERR,arg[iarg+1],false,lmp); + } else if (strcmp(arg[iarg], "zero") == 0) { + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix langevin command"); + zeroflag = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; - } else error->all(FLERR,"Illegal fix langevin command"); + } else + error->all(FLERR, "Illegal fix langevin command"); } // set temperature = nullptr, user can override via fix_modify if wants bias @@ -175,7 +173,7 @@ FixLangevin::FixLangevin(LAMMPS *lmp, int narg, char **arg) : FixLangevin::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); - // initialize franprev to zero + // initialize franprev to zero int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { @@ -194,18 +192,18 @@ FixLangevin::FixLangevin(LAMMPS *lmp, int narg, char **arg) : FixLangevin::~FixLangevin() { delete random; - delete [] tstr; - delete [] gfactor1; - delete [] gfactor2; - delete [] ratio; - delete [] id_temp; + delete[] tstr; + delete[] gfactor1; + delete[] gfactor2; + delete[] ratio; + delete[] id_temp; memory->destroy(flangevin); memory->destroy(tforce); if (gjfflag) { memory->destroy(franprev); memory->destroy(lv); - atom->delete_callback(id,Atom::GROW); + atom->delete_callback(id, Atom::GROW); } } @@ -226,34 +224,38 @@ int FixLangevin::setmask() void FixLangevin::init() { if (gjfflag) { - if (t_period*2 == update->dt) - error->all(FLERR,"Fix langevin gjf cannot have t_period equal to dt/2"); + if (t_period * 2 == update->dt) + error->all(FLERR, "Fix langevin gjf cannot have t_period equal to dt/2"); // warn if any integrate fix comes after this one int before = 1; int flag = 0; for (int i = 0; i < modify->nfix; i++) { - if (strcmp(id,modify->fix[i]->id) == 0) before = 0; - else if ((modify->fmask[i] && utils::strmatch(modify->fix[i]->style,"^nve")) && before) flag = 1; + auto ifix = modify->get_fix_by_index(i); + if (strcmp(id, ifix->id) == 0) + before = 0; + else if ((modify->fmask[i] && utils::strmatch(ifix->style, "^nve")) && before) + flag = 1; } - if (flag) - error->all(FLERR,"Fix langevin gjf should come before fix nve"); + if (flag) error->all(FLERR, "Fix langevin gjf should come before fix nve"); } if (oflag && !atom->sphere_flag) - error->all(FLERR,"Fix langevin omega requires atom style sphere"); + error->all(FLERR, "Fix langevin omega requires atom style sphere"); if (ascale && !atom->ellipsoid_flag) - error->all(FLERR,"Fix langevin angmom requires atom style ellipsoid"); + error->all(FLERR, "Fix langevin angmom requires atom style ellipsoid"); // check variable if (tstr) { tvar = input->variable->find(tstr); - if (tvar < 0) - error->all(FLERR,"Variable name for fix langevin does not exist"); - if (input->variable->equalstyle(tvar)) tstyle = EQUAL; - else if (input->variable->atomstyle(tvar)) tstyle = ATOM; - else error->all(FLERR,"Variable for fix langevin is invalid style"); + if (tvar < 0) error->all(FLERR, "Variable name {} for fix langevin does not exist", tstr); + if (input->variable->equalstyle(tvar)) + tstyle = EQUAL; + else if (input->variable->atomstyle(tvar)) + tstyle = ATOM; + else + error->all(FLERR, "Variable {} for fix langevin is invalid style", tstr); } // if oflag or ascale set, check that all group particles are finite-size @@ -265,14 +267,12 @@ void FixLangevin::init() for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) - if (radius[i] == 0.0) - error->one(FLERR,"Fix langevin omega requires extended particles"); + if (radius[i] == 0.0) error->one(FLERR, "Fix langevin omega requires extended particles"); } if (ascale) { - avec = dynamic_cast( atom->style_match("ellipsoid")); - if (!avec) - error->all(FLERR,"Fix langevin angmom requires atom style ellipsoid"); + avec = dynamic_cast(atom->style_match("ellipsoid")); + if (!avec) error->all(FLERR, "Fix langevin angmom requires atom style ellipsoid"); int *ellipsoid = atom->ellipsoid; int *mask = atom->mask; @@ -280,8 +280,7 @@ void FixLangevin::init() for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) - if (ellipsoid[i] < 0) - error->one(FLERR,"Fix langevin angmom requires extended particles"); + if (ellipsoid[i] < 0) error->one(FLERR, "Fix langevin angmom requires extended particles"); } // set force prefactors @@ -289,30 +288,30 @@ void FixLangevin::init() if (!atom->rmass) { for (int i = 1; i <= atom->ntypes; i++) { gfactor1[i] = -atom->mass[i] / t_period / force->ftm2v; + gfactor2[i] = sqrt(atom->mass[i]) / force->ftm2v; if (gjfflag) - gfactor2[i] = sqrt(atom->mass[i]) * - sqrt(2.0*force->boltz/t_period/update->dt/force->mvv2e) / - force->ftm2v; + gfactor2[i] *= sqrt(2.0 * force->boltz / t_period / update->dt / force->mvv2e); else - gfactor2[i] = sqrt(atom->mass[i]) * - sqrt(24.0*force->boltz/t_period/update->dt/force->mvv2e) / - force->ftm2v; - gfactor1[i] *= 1.0/ratio[i]; - gfactor2[i] *= 1.0/sqrt(ratio[i]); + gfactor2[i] *= sqrt(24.0 * force->boltz / t_period / update->dt / force->mvv2e); + gfactor1[i] *= 1.0 / ratio[i]; + gfactor2[i] *= 1.0 / sqrt(ratio[i]); } } - if (temperature && temperature->tempbias) tbiasflag = BIAS; - else tbiasflag = NOBIAS; + if (temperature && temperature->tempbias) + tbiasflag = BIAS; + else + tbiasflag = NOBIAS; - if (utils::strmatch(update->integrate_style,"^respa")) - nlevels_respa = (dynamic_cast( update->integrate))->nlevels; + if (utils::strmatch(update->integrate_style, "^respa")) { + nlevels_respa = (static_cast(update->integrate))->nlevels; + if (gjfflag) error->all(FLERR, "Fix langevin gjf and run style respa are not compatible"); + } - if (utils::strmatch(update->integrate_style,"^respa") && gjfflag) - error->all(FLERR,"Fix langevin gjf and respa are not compatible"); - - if (gjfflag) gjfa = (1.0-update->dt/2.0/t_period)/(1.0+update->dt/2.0/t_period); - if (gjfflag) gjfsib = sqrt(1.0+update->dt/2.0/t_period); + if (gjfflag) { + gjfa = (1.0 - update->dt / 2.0 / t_period) / (1.0 + update->dt / 2.0 / t_period); + gjfsib = sqrt(1.0 + update->dt / 2.0 / t_period); + } } /* ---------------------------------------------------------------------- */ @@ -336,13 +335,11 @@ void FixLangevin::setup(int vflag) v[i][0] -= dtfm * f[i][0]; v[i][1] -= dtfm * f[i][1]; v[i][2] -= dtfm * f[i][2]; - if (tbiasflag) - temperature->remove_bias(i,v[i]); - v[i][0] /= gjfa*gjfsib*gjfsib; - v[i][1] /= gjfa*gjfsib*gjfsib; - v[i][2] /= gjfa*gjfsib*gjfsib; - if (tbiasflag) - temperature->restore_bias(i,v[i]); + if (tbiasflag) temperature->remove_bias(i, v[i]); + v[i][0] /= gjfa * gjfsib * gjfsib; + v[i][1] /= gjfa * gjfsib * gjfsib; + v[i][2] /= gjfa * gjfsib * gjfsib; + if (tbiasflag) temperature->restore_bias(i, v[i]); } } else { @@ -352,22 +349,21 @@ void FixLangevin::setup(int vflag) v[i][0] -= dtfm * f[i][0]; v[i][1] -= dtfm * f[i][1]; v[i][2] -= dtfm * f[i][2]; - if (tbiasflag) - temperature->remove_bias(i,v[i]); - v[i][0] /= gjfa*gjfsib*gjfsib; - v[i][1] /= gjfa*gjfsib*gjfsib; - v[i][2] /= gjfa*gjfsib*gjfsib; - if (tbiasflag) - temperature->restore_bias(i,v[i]); + if (tbiasflag) temperature->remove_bias(i, v[i]); + v[i][0] /= gjfa * gjfsib * gjfsib; + v[i][1] /= gjfa * gjfsib * gjfsib; + v[i][2] /= gjfa * gjfsib * gjfsib; + if (tbiasflag) temperature->restore_bias(i, v[i]); } } } - if (utils::strmatch(update->integrate_style,"^verlet")) + if (utils::strmatch(update->integrate_style, "^verlet")) post_force(vflag); else { - (dynamic_cast( update->integrate))->copy_flevel_f(nlevels_respa-1); - post_force_respa(vflag,nlevels_respa-1,0); - (dynamic_cast( update->integrate))->copy_f_flevel(nlevels_respa-1); + auto respa = static_cast(update->integrate); + respa->copy_flevel_f(nlevels_respa - 1); + post_force_respa(vflag, nlevels_respa - 1, 0); + respa->copy_f_flevel(nlevels_respa - 1); } if (gjfflag) { double dtfm; @@ -390,7 +386,7 @@ void FixLangevin::setup(int vflag) lv[i][1] = v[i][1]; lv[i][2] = v[i][2]; } -// + // } else { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { @@ -427,6 +423,7 @@ void FixLangevin::initial_integrate(int /* vflag */) } /* ---------------------------------------------------------------------- */ +// clang-format off void FixLangevin::post_force(int /*vflag*/) { @@ -575,8 +572,7 @@ void FixLangevin::post_force_respa(int vflag, int ilevel, int /*iloop*/) modify forces using one of the many Langevin styles ------------------------------------------------------------------------- */ -template < int Tp_TSTYLEATOM, int Tp_GJF, int Tp_TALLY, - int Tp_BIAS, int Tp_RMASS, int Tp_ZERO > +template void FixLangevin::post_force_templated() { double gamma1,gamma2; @@ -988,6 +984,7 @@ void FixLangevin::end_of_step() energy += energy_onestep*update->dt; } +// clang-format on /* ---------------------------------------------------------------------- */ void FixLangevin::reset_target(double t_new) @@ -1001,20 +998,17 @@ void FixLangevin::reset_dt() { if (atom->mass) { for (int i = 1; i <= atom->ntypes; i++) { + gfactor2[i] = sqrt(atom->mass[i]) / force->ftm2v; if (gjfflag) - gfactor2[i] = sqrt(atom->mass[i]) * - sqrt(2.0*force->boltz/t_period/update->dt/force->mvv2e) / - force->ftm2v; + gfactor2[i] *= sqrt(2.0 * force->boltz / t_period / update->dt / force->mvv2e); else - gfactor2[i] = sqrt(atom->mass[i]) * - sqrt(24.0*force->boltz/t_period/update->dt/force->mvv2e) / - force->ftm2v; - gfactor2[i] *= 1.0/sqrt(ratio[i]); + gfactor2[i] *= sqrt(24.0 * force->boltz / t_period / update->dt / force->mvv2e); + gfactor2[i] *= 1.0 / sqrt(ratio[i]); } } if (gjfflag) { - gjfa = (1.0-update->dt/2.0/t_period)/(1.0+update->dt/2.0/t_period); - gjfsib = sqrt(1.0+update->dt/2.0/t_period); + gjfa = (1.0 - update->dt / 2.0 / t_period) / (1.0 + update->dt / 2.0 / t_period); + gjfsib = sqrt(1.0 + update->dt / 2.0 / t_period); } } @@ -1022,21 +1016,19 @@ void FixLangevin::reset_dt() int FixLangevin::modify_param(int narg, char **arg) { - if (strcmp(arg[0],"temp") == 0) { - if (narg < 2) error->all(FLERR,"Illegal fix_modify command"); - delete [] id_temp; + if (strcmp(arg[0], "temp") == 0) { + if (narg < 2) utils::missing_cmd_args(FLERR, "fix_modify", error); + delete[] id_temp; id_temp = utils::strdup(arg[1]); - - int icompute = modify->find_compute(id_temp); - if (icompute < 0) - error->all(FLERR,"Could not find fix_modify temperature ID"); - temperature = modify->compute[icompute]; + temperature = modify->get_compute_by_id(id_temp); + if (!temperature) + error->all(FLERR, "Could not find fix_modify temperature compute ID: {}", id_temp); if (temperature->tempflag == 0) - error->all(FLERR, - "Fix_modify temperature ID does not compute temperature"); + error->all(FLERR, "Fix_modify temperature compute {} does not compute temperature", id_temp); if (temperature->igroup != igroup && comm->me == 0) - error->warning(FLERR,"Group for fix_modify temp != fix group"); + error->warning(FLERR, "Group for fix_modify temp != fix group: {} vs {}", + group->names[igroup], group->names[temperature->igroup]); return 2; } return 0; @@ -1059,29 +1051,27 @@ double FixLangevin::compute_scalar() if (!gjfflag) { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) - energy_onestep += flangevin[i][0]*v[i][0] + flangevin[i][1]*v[i][1] + - flangevin[i][2]*v[i][2]; - energy = 0.5*energy_onestep*update->dt; + energy_onestep += + flangevin[i][0] * v[i][0] + flangevin[i][1] * v[i][1] + flangevin[i][2] * v[i][2]; + energy = 0.5 * energy_onestep * update->dt; } else { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { - if (tbiasflag) - temperature->remove_bias(i, lv[i]); - energy_onestep += flangevin[i][0]*lv[i][0] + flangevin[i][1]*lv[i][1] + - flangevin[i][2]*lv[i][2]; - if (tbiasflag) - temperature->restore_bias(i, lv[i]); + if (tbiasflag) temperature->remove_bias(i, lv[i]); + energy_onestep += + flangevin[i][0] * lv[i][0] + flangevin[i][1] * lv[i][1] + flangevin[i][2] * lv[i][2]; + if (tbiasflag) temperature->restore_bias(i, lv[i]); } - energy = -0.5*energy_onestep*update->dt; + energy = -0.5 * energy_onestep * update->dt; } } // convert midstep energy back to previous fullstep energy - double energy_me = energy - 0.5*energy_onestep*update->dt; + double energy_me = energy - 0.5 * energy_onestep * update->dt; double energy_all; - MPI_Allreduce(&energy_me,&energy_all,1,MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(&energy_me, &energy_all, 1, MPI_DOUBLE, MPI_SUM, world); return -energy_all; } @@ -1092,9 +1082,7 @@ double FixLangevin::compute_scalar() void *FixLangevin::extract(const char *str, int &dim) { dim = 0; - if (strcmp(str,"t_target") == 0) { - return &t_target; - } + if (strcmp(str, "t_target") == 0) { return &t_target; } return nullptr; } @@ -1105,9 +1093,9 @@ void *FixLangevin::extract(const char *str, int &dim) double FixLangevin::memory_usage() { double bytes = 0.0; - if (gjfflag) bytes += (double)atom->nmax*6 * sizeof(double); - if (tallyflag || osflag) bytes += (double)atom->nmax*3 * sizeof(double); - if (tforce) bytes += (double)atom->nmax * sizeof(double); + if (gjfflag) bytes += (double) atom->nmax * 6 * sizeof(double); + if (tallyflag || osflag) bytes += (double) atom->nmax * 3 * sizeof(double); + if (tforce) bytes += (double) atom->nmax * sizeof(double); return bytes; } @@ -1117,8 +1105,8 @@ double FixLangevin::memory_usage() void FixLangevin::grow_arrays(int nmax) { - memory->grow(franprev,nmax,3,"fix_langevin:franprev"); - memory->grow(lv,nmax,3,"fix_langevin:lv"); + memory->grow(franprev, nmax, 3, "fix_langevin:franprev"); + memory->grow(lv, nmax, 3, "fix_langevin:lv"); } /* ---------------------------------------------------------------------- diff --git a/src/fix_nh.cpp b/src/fix_nh.cpp index cb0408a50c..9f5915cf1e 100644 --- a/src/fix_nh.cpp +++ b/src/fix_nh.cpp @@ -60,7 +60,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : eta_mass(nullptr), etap(nullptr), etap_dot(nullptr), etap_dotdot(nullptr), etap_mass(nullptr) { - if (narg < 4) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (narg < 4) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph", error); restart_global = 1; dynamic_group_allow = 1; @@ -130,7 +130,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"temp") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph temp", error); tstat_flag = 1; t_start = utils::numeric(FLERR,arg[iarg+1],false,lmp); t_target = t_start; @@ -142,7 +142,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : iarg += 4; } else if (strcmp(arg[iarg],"iso") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph iso", error); pcouple = XYZ; p_start[0] = p_start[1] = p_start[2] = utils::numeric(FLERR,arg[iarg+1],false,lmp); p_stop[0] = p_stop[1] = p_stop[2] = utils::numeric(FLERR,arg[iarg+2],false,lmp); @@ -155,7 +155,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : } iarg += 4; } else if (strcmp(arg[iarg],"aniso") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph aniso", error); pcouple = NONE; p_start[0] = p_start[1] = p_start[2] = utils::numeric(FLERR,arg[iarg+1],false,lmp); p_stop[0] = p_stop[1] = p_stop[2] = utils::numeric(FLERR,arg[iarg+2],false,lmp); @@ -168,7 +168,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : } iarg += 4; } else if (strcmp(arg[iarg],"tri") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph tri", error); pcouple = NONE; scalexy = scalexz = scaleyz = 0; p_start[0] = p_start[1] = p_start[2] = utils::numeric(FLERR,arg[iarg+1],false,lmp); @@ -191,7 +191,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : } iarg += 4; } else if (strcmp(arg[iarg],"x") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph x", error); p_start[0] = utils::numeric(FLERR,arg[iarg+1],false,lmp); p_stop[0] = utils::numeric(FLERR,arg[iarg+2],false,lmp); p_period[0] = utils::numeric(FLERR,arg[iarg+3],false,lmp); @@ -199,7 +199,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : deviatoric_flag = 1; iarg += 4; } else if (strcmp(arg[iarg],"y") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph y", error); p_start[1] = utils::numeric(FLERR,arg[iarg+1],false,lmp); p_stop[1] = utils::numeric(FLERR,arg[iarg+2],false,lmp); p_period[1] = utils::numeric(FLERR,arg[iarg+3],false,lmp); @@ -207,7 +207,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : deviatoric_flag = 1; iarg += 4; } else if (strcmp(arg[iarg],"z") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph z", error); p_start[2] = utils::numeric(FLERR,arg[iarg+1],false,lmp); p_stop[2] = utils::numeric(FLERR,arg[iarg+2],false,lmp); p_period[2] = utils::numeric(FLERR,arg[iarg+3],false,lmp); @@ -218,7 +218,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR,"Invalid fix nvt/npt/nph command for a 2d simulation"); } else if (strcmp(arg[iarg],"yz") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph yz", error); p_start[3] = utils::numeric(FLERR,arg[iarg+1],false,lmp); p_stop[3] = utils::numeric(FLERR,arg[iarg+2],false,lmp); p_period[3] = utils::numeric(FLERR,arg[iarg+3],false,lmp); @@ -229,7 +229,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : if (dimension == 2) error->all(FLERR,"Invalid fix nvt/npt/nph command for a 2d simulation"); } else if (strcmp(arg[iarg],"xz") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph xz", error); p_start[4] = utils::numeric(FLERR,arg[iarg+1],false,lmp); p_stop[4] = utils::numeric(FLERR,arg[iarg+2],false,lmp); p_period[4] = utils::numeric(FLERR,arg[iarg+3],false,lmp); @@ -240,7 +240,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : if (dimension == 2) error->all(FLERR,"Invalid fix nvt/npt/nph command for a 2d simulation"); } else if (strcmp(arg[iarg],"xy") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph xy", error); p_start[5] = utils::numeric(FLERR,arg[iarg+1],false,lmp); p_stop[5] = utils::numeric(FLERR,arg[iarg+2],false,lmp); p_period[5] = utils::numeric(FLERR,arg[iarg+3],false,lmp); @@ -250,7 +250,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : iarg += 4; } else if (strcmp(arg[iarg],"couple") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph couple", error); if (strcmp(arg[iarg+1],"xyz") == 0) pcouple = XYZ; else if (strcmp(arg[iarg+1],"xy") == 0) pcouple = XY; else if (strcmp(arg[iarg+1],"yz") == 0) pcouple = YZ; @@ -260,18 +260,18 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"drag") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph drag", error); drag = utils::numeric(FLERR,arg[iarg+1],false,lmp); - if (drag < 0.0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (drag < 0.0) error->all(FLERR, "Invalid fix nvt/npt/nph drag argument: {}", drag); iarg += 2; } else if (strcmp(arg[iarg],"ptemp") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph ptemp", error); p_temp = utils::numeric(FLERR,arg[iarg+1],false,lmp); p_temp_flag = 1; - if (p_temp <= 0.0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (p_temp <= 0.0) error->all(FLERR, "Invalid fix nvt/npt/nph ptemp argument: {}", p_temp); iarg += 2; } else if (strcmp(arg[iarg],"dilate") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph dilate", error); if (strcmp(arg[iarg+1],"all") == 0) allremap = 1; else { allremap = 0; @@ -284,62 +284,62 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"tchain") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph tchain", error); mtchain = utils::inumeric(FLERR,arg[iarg+1],false,lmp); // used by FixNVTSllod to preserve non-default value mtchain_default_flag = 0; - if (mtchain < 1) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (mtchain < 1) error->all(FLERR, "Invalid fix nvt/npt/nph tchain argument: {}", mtchain); iarg += 2; } else if (strcmp(arg[iarg],"pchain") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph pchain", error); mpchain = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (mpchain < 0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (mpchain < 0) error->all(FLERR, "Invalid fix nvt/npt/nph pchain argument: {}", mpchain); iarg += 2; } else if (strcmp(arg[iarg],"mtk") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph mtk", error); mtk_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"tloop") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph tloop", error); nc_tchain = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (nc_tchain < 0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (nc_tchain < 0) error->all(FLERR, "Invalid fix nvt/npt/nph tloop argument: {}", nc_tchain); iarg += 2; } else if (strcmp(arg[iarg],"ploop") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph ploop", error); nc_pchain = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (nc_pchain < 0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (nc_pchain < 0) error->all(FLERR, "Invalid fix nvt/npt/nph ploop argument: {}", nc_pchain); iarg += 2; } else if (strcmp(arg[iarg],"nreset") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph nreset", error); nreset_h0 = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (nreset_h0 < 0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (nreset_h0 < 0) error->all(FLERR, "Invalid fix nvt/npt/nph nreset argument: {}", nreset_h0); iarg += 2; } else if (strcmp(arg[iarg],"scalexy") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph scalexy", error); scalexy = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"scalexz") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph scalexz", error); scalexz = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"scaleyz") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph scaleyz", error); scaleyz = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"flip") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph flip", error); flipflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"update") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph update", error); if (strcmp(arg[iarg+1],"dipole") == 0) dipole_flag = 1; else if (strcmp(arg[iarg+1],"dipole/dlm") == 0) { dipole_flag = 1; dlm_flag = 1; - } else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + } else error->all(FLERR, "Invalid fix nvt/npt/nph update argument: {}", arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"fixedpoint") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix nvt/npt/nph fixedpoint", error); fixedpoint[0] = utils::numeric(FLERR,arg[iarg+1],false,lmp); fixedpoint[1] = utils::numeric(FLERR,arg[iarg+2],false,lmp); fixedpoint[2] = utils::numeric(FLERR,arg[iarg+3],false,lmp); @@ -359,7 +359,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg],"ext") == 0) { iarg += 2; - } else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + } else error->all(FLERR,"Unknown fix nvt/npt/nph keyword: {}", arg[iarg]); } // error checks @@ -658,19 +658,17 @@ void FixNH::init() // set temperature and pressure ptrs - int icompute = modify->find_compute(id_temp); - if (icompute < 0) - error->all(FLERR,"Temperature ID for fix nvt/npt does not exist"); - temperature = modify->compute[icompute]; + temperature = modify->get_compute_by_id(id_temp); + if (!temperature) + error->all(FLERR,"Temperature ID {} for fix nvt/npt does not exist", id_temp); if (temperature->tempbias) which = BIAS; else which = NOBIAS; if (pstat_flag) { - icompute = modify->find_compute(id_press); - if (icompute < 0) - error->all(FLERR,"Pressure ID for fix npt/nph does not exist"); - pressure = modify->compute[icompute]; + pressure = modify->get_compute_by_id(id_press); + if (!pressure) + error->all(FLERR,"Pressure ID {} for fix npt/nph does not exist", id_press); } // set timesteps and frequencies @@ -1411,10 +1409,9 @@ int FixNH::modify_param(int narg, char **arg) delete [] id_temp; id_temp = utils::strdup(arg[1]); - int icompute = modify->find_compute(arg[1]); - if (icompute < 0) - error->all(FLERR,"Could not find fix_modify temperature ID"); - temperature = modify->compute[icompute]; + temperature = modify->get_compute_by_id(arg[1]); + if (!temperature) + error->all(FLERR,"Could not find fix_modify temperature ID {}", arg[1]); if (temperature->tempflag == 0) error->all(FLERR, @@ -1425,10 +1422,10 @@ int FixNH::modify_param(int narg, char **arg) // reset id_temp of pressure to new temperature ID if (pstat_flag) { - icompute = modify->find_compute(id_press); - if (icompute < 0) - error->all(FLERR,"Pressure ID for fix modify does not exist"); - modify->compute[icompute]->reset_extra_compute_fix(id_temp); + auto icompute = modify->get_compute_by_id(id_press); + if (!icompute) + error->all(FLERR,"Pressure ID {} for fix modify does not exist", id_press); + icompute->reset_extra_compute_fix(id_temp); } return 2; @@ -1443,9 +1440,8 @@ int FixNH::modify_param(int narg, char **arg) delete [] id_press; id_press = utils::strdup(arg[1]); - int icompute = modify->find_compute(arg[1]); - if (icompute < 0) error->all(FLERR,"Could not find fix_modify pressure ID"); - pressure = modify->compute[icompute]; + pressure = modify->get_compute_by_id(arg[1]); + if (!pressure) error->all(FLERR,"Could not find fix_modify pressure ID {}", arg[1]); if (pressure->pressflag == 0) error->all(FLERR,"Fix_modify pressure ID does not compute pressure"); diff --git a/src/fix_press_berendsen.cpp b/src/fix_press_berendsen.cpp index f80acce8c4..67802654ba 100644 --- a/src/fix_press_berendsen.cpp +++ b/src/fix_press_berendsen.cpp @@ -21,6 +21,7 @@ #include "error.h" #include "fix_deform.h" #include "force.h" +#include "group.h" #include "kspace.h" #include "modify.h" #include "update.h" @@ -240,14 +241,14 @@ FixPressBerendsen::FixPressBerendsen(LAMMPS *lmp, int narg, char **arg) : FixPressBerendsen::~FixPressBerendsen() { - delete [] rfix; + delete[] rfix; // delete temperature and pressure if fix created them if (tflag) modify->delete_compute(id_temp); if (pflag) modify->delete_compute(id_press); - delete [] id_temp; - delete [] id_press; + delete[] id_temp; + delete[] id_press; } /* ---------------------------------------------------------------------- */ @@ -268,9 +269,9 @@ void FixPressBerendsen::init() // insure no conflict with fix deform - for (int i = 0; i < modify->nfix; i++) - if (strcmp(modify->fix[i]->style,"deform") == 0) { - int *dimflag = (dynamic_cast( modify->fix[i]))->dimflag; + for (const auto &ifix : modify->get_fix_list()) + if (strcmp(ifix->style, "^deform") == 0) { + int *dimflag = static_cast(ifix)->dimflag; if ((p_flag[0] && dimflag[0]) || (p_flag[1] && dimflag[1]) || (p_flag[2] && dimflag[2])) error->all(FLERR,"Cannot use fix press/berendsen and " @@ -279,18 +280,16 @@ void FixPressBerendsen::init() // set temperature and pressure ptrs - int icompute = modify->find_compute(id_temp); - if (icompute < 0) - error->all(FLERR,"Temperature ID for fix press/berendsen does not exist"); - temperature = modify->compute[icompute]; + temperature = modify->get_compute_by_id(id_temp); + if (!temperature) + error->all(FLERR, "Temperature compute ID {} for fix press/berendsen does not exist", id_temp); if (temperature->tempbias) which = BIAS; else which = NOBIAS; - icompute = modify->find_compute(id_press); - if (icompute < 0) - error->all(FLERR,"Pressure ID for fix press/berendsen does not exist"); - pressure = modify->compute[icompute]; + pressure = modify->get_compute_by_id(id_press); + if (!pressure) + error->all(FLERR, "Pressure compute ID {} for fix press/berendsen does not exist", id_press); // Kspace setting @@ -300,13 +299,13 @@ void FixPressBerendsen::init() // detect if any rigid fixes exist so rigid bodies move when box is remapped // rfix[] = indices to each fix rigid - delete [] rfix; + delete[] rfix; nrigid = 0; rfix = nullptr; for (int i = 0; i < modify->nfix; i++) if (modify->fix[i]->rigid_flag) nrigid++; - if (nrigid) { + if (nrigid > 0) { rfix = new int[nrigid]; nrigid = 0; for (int i = 0; i < modify->nfix; i++) @@ -460,24 +459,25 @@ int FixPressBerendsen::modify_param(int narg, char **arg) modify->delete_compute(id_temp); tflag = 0; } - delete [] id_temp; + delete[] id_temp; id_temp = utils::strdup(arg[1]); - int icompute = modify->find_compute(arg[1]); - if (icompute < 0) error->all(FLERR,"Could not find fix_modify temperature ID"); - temperature = modify->compute[icompute]; + temperature = modify->get_compute_by_id(arg[1]); + if (!temperature) + error->all(FLERR,"Could not find fix_modify temperature compute ID: ", arg[1]); if (temperature->tempflag == 0) - error->all(FLERR,"Fix_modify temperature ID does not compute temperature"); + error->all(FLERR,"Fix_modify temperature compute {} does not compute temperature", arg[1]); if (temperature->igroup != 0 && comm->me == 0) - error->warning(FLERR,"Temperature for NPT is not for group all"); + error->warning(FLERR,"Temperature compute {} for fix {} is not for group all: {}", + arg[1], style, group->names[temperature->igroup]); // reset id_temp of pressure to new temperature ID - icompute = modify->find_compute(id_press); - if (icompute < 0) - error->all(FLERR,"Pressure ID for fix press/berendsen does not exist"); - modify->compute[icompute]->reset_extra_compute_fix(id_temp); + auto icompute = modify->get_compute_by_id(id_press); + if (!icompute) + error->all(FLERR,"Pressure compute ID {} for fix {} does not exist", id_press, style); + icompute->reset_extra_compute_fix(id_temp); return 2; @@ -487,15 +487,13 @@ int FixPressBerendsen::modify_param(int narg, char **arg) modify->delete_compute(id_press); pflag = 0; } - delete [] id_press; + delete[] id_press; id_press = utils::strdup(arg[1]); - int icompute = modify->find_compute(arg[1]); - if (icompute < 0) error->all(FLERR,"Could not find fix_modify pressure ID"); - pressure = modify->compute[icompute]; - + pressure = modify->get_compute_by_id(arg[1]); + if (pressure) error->all(FLERR,"Could not find fix_modify pressure compute ID: {}", arg[1]); if (pressure->pressflag == 0) - error->all(FLERR,"Fix_modify pressure ID does not compute pressure"); + error->all(FLERR,"Fix_modify pressure compute {} does not compute pressure", arg[1]); return 2; } return 0; diff --git a/src/fix_restrain.cpp b/src/fix_restrain.cpp index 8b97715ff6..e5440830f5 100644 --- a/src/fix_restrain.cpp +++ b/src/fix_restrain.cpp @@ -19,17 +19,18 @@ #include "fix_restrain.h" -#include -#include #include "atom.h" -#include "force.h" -#include "update.h" -#include "domain.h" #include "comm.h" -#include "respa.h" +#include "domain.h" +#include "error.h" +#include "force.h" #include "math_const.h" #include "memory.h" -#include "error.h" +#include "respa.h" +#include "update.h" + +#include +#include using namespace LAMMPS_NS; using namespace FixConst; @@ -271,14 +272,12 @@ void FixRestrain::restrain_bond(int m) if (newton_bond) { if (i2 == -1 || i2 >= nlocal) return; if (i1 == -1) - error->one(FLERR,"Restrain atoms {} {} missing on " - "proc {} at step {}", ids[m][0],ids[m][1], + error->one(FLERR,"Restrain atoms {} {} missing on proc {} at step {}", ids[m][0],ids[m][1], comm->me,update->ntimestep); } else { if ((i1 == -1 || i1 >= nlocal) && (i2 == -1 || i2 >= nlocal)) return; if (i1 == -1 || i2 == -1) - error->one(FLERR,"Restrain atoms {} {} missing on " - "proc {} at step {}", ids[m][0],ids[m][1], + error->one(FLERR,"Restrain atoms {} {} missing on proc {} at step {}", ids[m][0],ids[m][1], comm->me,update->ntimestep); } diff --git a/src/fix_setforce.cpp b/src/fix_setforce.cpp index 6a88e3ab17..8bd5477f76 100644 --- a/src/fix_setforce.cpp +++ b/src/fix_setforce.cpp @@ -37,7 +37,7 @@ FixSetForce::FixSetForce(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), xstr(nullptr), ystr(nullptr), zstr(nullptr), idregion(nullptr), region(nullptr), sforce(nullptr) { - if (narg < 6) error->all(FLERR, "Illegal fix setforce command"); + if (narg < 6) utils::missing_cmd_args(FLERR, "fix setforce", error); dynamic_group_allow = 1; vector_flag = 1; @@ -77,13 +77,13 @@ FixSetForce::FixSetForce(LAMMPS *lmp, int narg, char **arg) : int iarg = 6; while (iarg < narg) { if (strcmp(arg[iarg], "region") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal fix setforce command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "fix setforce region", error); region = domain->get_region_by_id(arg[iarg + 1]); if (!region) error->all(FLERR, "Region {} for fix setforce does not exist", arg[iarg + 1]); idregion = utils::strdup(arg[iarg + 1]); iarg += 2; } else - error->all(FLERR, "Illegal fix setforce command"); + error->all(FLERR, "Unknown fix setforce keyword: {}", arg[iarg]); } force_flag = 0; diff --git a/src/fix_temp_berendsen.cpp b/src/fix_temp_berendsen.cpp index 26c14e842d..07ad556943 100644 --- a/src/fix_temp_berendsen.cpp +++ b/src/fix_temp_berendsen.cpp @@ -40,7 +40,8 @@ FixTempBerendsen::FixTempBerendsen(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), tstr(nullptr), id_temp(nullptr), tflag(0) { - if (narg != 6) error->all(FLERR,"Illegal fix temp/berendsen command"); + if (narg != 6) + error->all(FLERR,"Illegal fix {} command: expected 6 arguments but found {}", style, narg); // Berendsen thermostat should be applied every step @@ -68,7 +69,7 @@ FixTempBerendsen::FixTempBerendsen(LAMMPS *lmp, int narg, char **arg) : // error checks if (t_period <= 0.0) - error->all(FLERR,"Fix temp/berendsen period must be > 0.0"); + error->all(FLERR,"Fix temp/berendsen Tdamp period must be > 0.0"); // create a new compute temp style // id = fix-ID + temp, compute group = fix group @@ -84,12 +85,12 @@ FixTempBerendsen::FixTempBerendsen(LAMMPS *lmp, int narg, char **arg) : FixTempBerendsen::~FixTempBerendsen() { - delete [] tstr; + delete[] tstr; // delete temperature if fix created it if (tflag) modify->delete_compute(id_temp); - delete [] id_temp; + delete[] id_temp; } /* ---------------------------------------------------------------------- */ @@ -110,18 +111,17 @@ void FixTempBerendsen::init() if (tstr) { tvar = input->variable->find(tstr); if (tvar < 0) - error->all(FLERR,"Variable name for fix temp/berendsen does not exist"); + error->all(FLERR,"Variable name {} for fix temp/berendsen does not exist", tstr); if (input->variable->equalstyle(tvar)) tstyle = EQUAL; - else error->all(FLERR,"Variable for fix temp/berendsen is invalid style"); + else error->all(FLERR,"Variable {} for fix temp/berendsen is invalid style", tstr); } - int icompute = modify->find_compute(id_temp); - if (icompute < 0) - error->all(FLERR,"Temperature ID for fix temp/berendsen does not exist"); - temperature = modify->compute[icompute]; + temperature = modify->get_compute_by_id(id_temp); + if (!temperature) + error->all(FLERR,"Temperature compute ID {} for fix {} does not exist", id_temp, style); if (modify->check_rigid_group_overlap(groupbit)) - error->warning(FLERR,"Cannot thermostat atoms in rigid bodies"); + error->warning(FLERR,"Cannot thermostat atoms in rigid bodies with fix {}", style); if (temperature->tempbias) which = BIAS; else which = NOBIAS; @@ -139,8 +139,7 @@ void FixTempBerendsen::end_of_step() if (tdof < 1) return; if (t_current == 0.0) - error->all(FLERR, - "Computed temperature for fix temp/berendsen cannot be 0.0"); + error->all(FLERR, "Computed current temperature for fix temp/berendsen must not be 0.0"); double delta = update->ntimestep - update->beginstep; if (delta != 0.0) delta /= update->endstep - update->beginstep; @@ -154,8 +153,8 @@ void FixTempBerendsen::end_of_step() modify->clearstep_compute(); t_target = input->variable->compute_equal(tvar); if (t_target < 0.0) - error->one(FLERR, - "Fix temp/berendsen variable returned negative temperature"); + error->one(FLERR, "Fix temp/berendsen variable {} returned negative temperature", + input->variable->names[tvar]); modify->addstep_compute(update->ntimestep + nevery); } @@ -198,24 +197,23 @@ void FixTempBerendsen::end_of_step() int FixTempBerendsen::modify_param(int narg, char **arg) { if (strcmp(arg[0],"temp") == 0) { - if (narg < 2) error->all(FLERR,"Illegal fix_modify command"); + if (narg < 2) utils::missing_cmd_args(FLERR, "fix_modify", error); if (tflag) { modify->delete_compute(id_temp); tflag = 0; } - delete [] id_temp; + delete[] id_temp; id_temp = utils::strdup(arg[1]); - int icompute = modify->find_compute(id_temp); - if (icompute < 0) - error->all(FLERR,"Could not find fix_modify temperature ID"); - temperature = modify->compute[icompute]; + temperature = modify->get_compute_by_id(id_temp); + if (!temperature) + error->all(FLERR,"Could not find fix_modify temperature compute {}", id_temp); if (temperature->tempflag == 0) - error->all(FLERR, - "Fix_modify temperature ID does not compute temperature"); + error->all(FLERR, "Fix_modify temperature compute {} does not compute temperature", id_temp); if (temperature->igroup != igroup && comm->me == 0) - error->warning(FLERR,"Group for fix_modify temp != fix group"); + error->warning(FLERR, "Group for fix_modify temp != fix group: {} vs {}", + group->names[igroup], group->names[temperature->igroup]); return 2; } return 0; diff --git a/src/fix_temp_rescale.cpp b/src/fix_temp_rescale.cpp index 41fb49e3f4..e248dfe92c 100644 --- a/src/fix_temp_rescale.cpp +++ b/src/fix_temp_rescale.cpp @@ -40,10 +40,10 @@ FixTempRescale::FixTempRescale(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), tstr(nullptr), id_temp(nullptr), tflag(0) { - if (narg < 8) error->all(FLERR,"Illegal fix temp/rescale command"); + if (narg < 8) utils::missing_cmd_args(FLERR, "fix temp/rescale", error); nevery = utils::inumeric(FLERR,arg[3],false,lmp); - if (nevery <= 0) error->all(FLERR,"Illegal fix temp/rescale command"); + if (nevery <= 0) error->all(FLERR, "Invalid fix temp/rescale every argument: {}", nevery); restart_global = 1; scalar_flag = 1; @@ -66,6 +66,10 @@ FixTempRescale::FixTempRescale(LAMMPS *lmp, int narg, char **arg) : t_window = utils::numeric(FLERR,arg[6],false,lmp); fraction = utils::numeric(FLERR,arg[7],false,lmp); + if (t_stop < 0) error->all(FLERR, "Invalid fix temp/rescale Tstop argument: {}", t_stop); + if (t_window < 0) error->all(FLERR, "Invalid fix temp/rescale window argument: {}", t_window); + if (fraction <= 0) error->all(FLERR, "Invalid fix temp/rescale fraction argument: {}", fraction); + // create a new compute temp // id = fix-ID + temp, compute group = fix group @@ -80,12 +84,12 @@ FixTempRescale::FixTempRescale(LAMMPS *lmp, int narg, char **arg) : FixTempRescale::~FixTempRescale() { - delete [] tstr; + delete[] tstr; // delete temperature if fix created it if (tflag) modify->delete_compute(id_temp); - delete [] id_temp; + delete[] id_temp; } /* ---------------------------------------------------------------------- */ @@ -106,15 +110,14 @@ void FixTempRescale::init() if (tstr) { tvar = input->variable->find(tstr); if (tvar < 0) - error->all(FLERR,"Variable name for fix temp/rescale does not exist"); + error->all(FLERR,"Variable name {} for fix temp/rescale does not exist", tstr); if (input->variable->equalstyle(tvar)) tstyle = EQUAL; - else error->all(FLERR,"Variable for fix temp/rescale is invalid style"); + else error->all(FLERR,"Variable {} for fix temp/rescale is invalid style", tstr); } - int icompute = modify->find_compute(id_temp); - if (icompute < 0) - error->all(FLERR,"Temperature ID for fix temp/rescale does not exist"); - temperature = modify->compute[icompute]; + temperature = modify->get_compute_by_id(id_temp); + if (!temperature) + error->all(FLERR,"Temperature ID {} for fix temp/rescale does not exist", id_temp); if (temperature->tempbias) which = BIAS; else which = NOBIAS; @@ -147,8 +150,7 @@ void FixTempRescale::end_of_step() modify->clearstep_compute(); t_target = input->variable->compute_equal(tvar); if (t_target < 0.0) - error->one(FLERR, - "Fix temp/rescale variable returned negative temperature"); + error->one(FLERR, "Fix temp/rescale variable returned negative temperature"); modify->addstep_compute(update->ntimestep + nevery); } @@ -195,24 +197,23 @@ void FixTempRescale::end_of_step() int FixTempRescale::modify_param(int narg, char **arg) { if (strcmp(arg[0],"temp") == 0) { - if (narg < 2) error->all(FLERR,"Illegal fix_modify command"); + if (narg < 2) utils::missing_cmd_args(FLERR, "fix_modify temp", error); if (tflag) { modify->delete_compute(id_temp); tflag = 0; } - delete [] id_temp; + delete[] id_temp; id_temp = utils::strdup(arg[1]); - int icompute = modify->find_compute(id_temp); - if (icompute < 0) - error->all(FLERR,"Could not find fix_modify temperature ID"); - temperature = modify->compute[icompute]; + temperature = modify->get_compute_by_id(id_temp); + if (!temperature) + error->all(FLERR,"Could not find fix_modify temperature compute {}", id_temp); if (temperature->tempflag == 0) - error->all(FLERR, - "Fix_modify temperature ID does not compute temperature"); + error->all(FLERR, "Fix_modify temperature compute {} does not compute temperature", id_temp); if (temperature->igroup != igroup && comm->me == 0) - error->warning(FLERR,"Group for fix_modify temp != fix group"); + error->warning(FLERR, "Group for fix_modify temp != fix group: {} vs {}", + group->names[igroup], group->names[temperature->igroup]); return 2; } return 0; diff --git a/src/fix_vector.cpp b/src/fix_vector.cpp index e916b8e9fe..38169bfcff 100644 --- a/src/fix_vector.cpp +++ b/src/fix_vector.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -26,41 +25,34 @@ using namespace LAMMPS_NS; using namespace FixConst; -enum{ONE,RUNNING,WINDOW}; -enum{SCALAR,VECTOR}; - +enum { ONE, RUNNING, WINDOW }; +enum { SCALAR, VECTOR }; /* ---------------------------------------------------------------------- */ FixVector::FixVector(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), - nvalues(0), which(nullptr), argindex(nullptr), value2index(nullptr), ids(nullptr), vector(nullptr), array(nullptr) + Fix(lmp, narg, arg), vector(nullptr), array(nullptr) { - if (narg < 5) error->all(FLERR,"Illegal fix vector command"); + if (narg < 5) utils::missing_cmd_args(FLERR, "fix vector", error); - nevery = utils::inumeric(FLERR,arg[3],false,lmp); - if (nevery <= 0) error->all(FLERR,"Illegal fix vector command"); + nevery = utils::inumeric(FLERR, arg[3], false, lmp); + if (nevery <= 0) error->all(FLERR, "Invalid fix vector every argument: {}", nevery); - nvalues = narg-4; - which = new int[nvalues]; - argindex = new int[nvalues]; - value2index = new int[nvalues]; - ids = new char*[nvalues]; - - nvalues = 0; + values.clear(); for (int iarg = 4; iarg < narg; iarg++) { ArgInfo argi(arg[iarg]); - which[nvalues] = argi.get_type(); - argindex[nvalues] = argi.get_index1(); - ids[nvalues] = argi.copy_name(); + value_t val; + val.which = argi.get_type(); + val.argindex = argi.get_index1(); + val.id = argi.get_name(); + val.val.c = nullptr; - if ((argi.get_type() == ArgInfo::UNKNOWN) - || (argi.get_type() == ArgInfo::NONE) - || (argi.get_dim() > 1)) - error->all(FLERR,"Illegal fix vector command"); + if ((argi.get_type() == ArgInfo::UNKNOWN) || (argi.get_type() == ArgInfo::NONE) || + (argi.get_dim() > 1)) + error->all(FLERR, "Invalid fix vector argument: {}", arg[iarg]); - nvalues++; + values.push_back(val); } // setup and error check @@ -68,59 +60,70 @@ FixVector::FixVector(LAMMPS *lmp, int narg, char **arg) : // this fix produces either a global vector or array // intensive/extensive flags set by compute,fix,variable that produces value - int value,finalvalue; - for (int i = 0; i < nvalues; i++) { - if (which[i] == ArgInfo::COMPUTE) { - auto icompute = modify->get_compute_by_id(ids[i]); - if (!icompute) error->all(FLERR,"Compute ID {} for fix vector does not exist",ids[i]); - if (argindex[i] == 0 && icompute->scalar_flag == 0) - error->all(FLERR,"Fix vector compute {} does not calculate a scalar",ids[i]); - if (argindex[i] && icompute->vector_flag == 0) - error->all(FLERR,"Fix vector compute {} does not calculate a vector",ids[i]); - if (argindex[i] && argindex[i] > icompute->size_vector) - error->all(FLERR,"Fix vector compute {} vector is accessed out-of-range",ids[i]); + int value, finalvalue; + bool first = true; + for (auto &val : values) { + if (val.which == ArgInfo::COMPUTE) { + auto icompute = modify->get_compute_by_id(val.id); + if (!icompute) error->all(FLERR, "Compute ID {} for fix vector does not exist", val.id); + if (val.argindex == 0 && icompute->scalar_flag == 0) + error->all(FLERR, "Fix vector compute {} does not calculate a scalar", val.id); + if (val.argindex && icompute->vector_flag == 0) + error->all(FLERR, "Fix vector compute {} does not calculate a vector", val.id); + if (val.argindex && (val.argindex > icompute->size_vector)) + error->all(FLERR, "Fix vector compute {} vector is accessed out-of-range", val.id); - if (argindex[i] == 0) value = icompute->extscalar; - else if (icompute->extvector >= 0) value = icompute->extvector; - else value = icompute->extlist[argindex[i]-1]; + if (val.argindex == 0) + value = icompute->extscalar; + else if (icompute->extvector >= 0) + value = icompute->extvector; + else + value = icompute->extlist[val.argindex - 1]; + val.val.c = icompute; - } else if (which[i] == ArgInfo::FIX) { - auto ifix = modify->get_fix_by_id(ids[i]); - if (!ifix) error->all(FLERR,"Fix ID {} for fix vector does not exist",ids[i]); - if (argindex[i] == 0 && ifix->scalar_flag == 0) - error->all(FLERR,"Fix vector fix {} does not calculate a scalar",ids[i]); - if (argindex[i] && ifix->vector_flag == 0) - error->all(FLERR,"Fix vector fix {} does not calculate a vector",ids[i]); - if (argindex[i] && argindex[i] > ifix->size_vector) - error->all(FLERR,"Fix vector fix {} vector is accessed out-of-range",ids[i]); + } else if (val.which == ArgInfo::FIX) { + auto ifix = modify->get_fix_by_id(val.id); + if (!ifix) error->all(FLERR, "Fix ID {} for fix vector does not exist", val.id); + if (val.argindex == 0 && ifix->scalar_flag == 0) + error->all(FLERR, "Fix vector fix {} does not calculate a scalar", val.id); + if (val.argindex && ifix->vector_flag == 0) + error->all(FLERR, "Fix vector fix {} does not calculate a vector", val.id); + if (val.argindex && val.argindex > ifix->size_vector) + error->all(FLERR, "Fix vector fix {} vector is accessed out-of-range", val.id); if (nevery % ifix->global_freq) - error->all(FLERR,"Fix for fix {} vector not computed at compatible time",ids[i]); + error->all(FLERR, "Fix for fix {} vector not computed at compatible time", val.id); - if (argindex[i] == 0) value = ifix->extvector; - else value = ifix->extarray; + if (val.argindex == 0) + value = ifix->extvector; + else + value = ifix->extarray; + val.val.f = ifix; - } else if (which[i] == ArgInfo::VARIABLE) { - int ivariable = input->variable->find(ids[i]); + } else if (val.which == ArgInfo::VARIABLE) { + int ivariable = input->variable->find(val.id.c_str()); if (ivariable < 0) - error->all(FLERR,"Variable name {} for fix vector does not exist",ids[i]); - if (argindex[i] == 0 && input->variable->equalstyle(ivariable) == 0) - error->all(FLERR,"Fix vector variable {} is not equal-style variable",ids[i]); - if (argindex[i] && input->variable->vectorstyle(ivariable) == 0) - error->all(FLERR,"Fix vector variable {} is not vector-style variable",ids[i]); + error->all(FLERR, "Variable name {} for fix vector does not exist", val.id); + if (val.argindex == 0 && input->variable->equalstyle(ivariable) == 0) + error->all(FLERR, "Fix vector variable {} is not equal-style variable", val.id); + if (val.argindex && input->variable->vectorstyle(ivariable) == 0) + error->all(FLERR, "Fix vector variable {} is not vector-style variable", val.id); value = 0; + val.val.v = ivariable; } - if (i == 0) finalvalue = value; - else if (value != finalvalue) - error->all(FLERR,"Fix vector cannot set output array intensive/extensive from these inputs"); + if (first) { + finalvalue = value; + first = false; + } else if (value != finalvalue) + error->all(FLERR, "Fix vector cannot set output array intensive/extensive from these inputs"); } - if (nvalues == 1) { + if (values.size() == 1) { vector_flag = 1; extvector = finalvalue; } else { array_flag = 1; - size_array_cols = nvalues; + size_array_cols = values.size(); extarray = finalvalue; } @@ -132,15 +135,17 @@ FixVector::FixVector(LAMMPS *lmp, int narg, char **arg) : vector = nullptr; array = nullptr; ncount = ncountmax = 0; - if (nvalues == 1) size_vector = 0; - else size_array_rows = 0; + if (values.size() == 1) + size_vector = 0; + else + size_array_rows = 0; // nextstep = next step on which end_of_step does something // add nextstep to all computes that store invocation times // since don't know a priori which are invoked by this fix // once in end_of_step() can set timestep for ones actually invoked - nextstep = (update->ntimestep/nevery)*nevery; + nextstep = (update->ntimestep / nevery) * nevery; if (nextstep < update->ntimestep) nextstep += nevery; modify->addstep_compute_all(nextstep); @@ -153,12 +158,7 @@ FixVector::FixVector(LAMMPS *lmp, int narg, char **arg) : FixVector::~FixVector() { - delete [] which; - delete [] argindex; - delete [] value2index; - for (int i = 0; i < nvalues; i++) delete [] ids[i]; - delete [] ids; - + values.clear(); memory->destroy(vector); memory->destroy(array); } @@ -178,22 +178,19 @@ void FixVector::init() { // set current indices for all computes,fixes,variables - for (int i = 0; i < nvalues; i++) { - if (which[i] == ArgInfo::COMPUTE) { - int icompute = modify->find_compute(ids[i]); - if (icompute < 0) error->all(FLERR,"Compute ID {} for fix vector does not exist",id[i]); - value2index[i] = icompute; + for (auto &val : values) { + if (val.which == ArgInfo::COMPUTE) { + val.val.c = modify->get_compute_by_id(val.id); + if (!val.val.c) error->all(FLERR, "Compute ID {} for fix vector does not exist", val.id); - } else if (which[i] == ArgInfo::FIX) { - int ifix = modify->find_fix(ids[i]); - if (ifix < 0) error->all(FLERR,"Fix ID {} for fix vector does not exist",id[i]); - value2index[i] = ifix; + } else if (val.which == ArgInfo::FIX) { + val.val.f = modify->get_fix_by_id(val.id); + if (!val.val.f) error->all(FLERR, "Fix ID {} for fix vector does not exist", val.id); - } else if (which[i] == ArgInfo::VARIABLE) { - int ivariable = input->variable->find(ids[i]); - if (ivariable < 0) - error->all(FLERR,"Variable name for fix vector does not exist"); - value2index[i] = ivariable; + } else if (val.which == ArgInfo::VARIABLE) { + int ivariable = input->variable->find(val.id.c_str()); + if (ivariable < 0) error->all(FLERR, "Variable name for fix vector does not exist"); + val.val.v = ivariable; } } @@ -201,11 +198,13 @@ void FixVector::init() // use endstep to allow for subsequent runs with "pre no" // nsize = # of entries from initialstep to finalstep - bigint finalstep = update->endstep/nevery * nevery; + bigint finalstep = update->endstep / nevery * nevery; if (finalstep > update->endstep) finalstep -= nevery; - ncountmax = (finalstep-initialstep)/nevery + 1; - if (nvalues == 1) memory->grow(vector,ncountmax,"vector:vector"); - else memory->grow(array,ncountmax,nvalues,"vector:array"); + ncountmax = (finalstep - initialstep) / nevery + 1; + if (values.size() == 1) + memory->grow(vector, ncountmax, "vector:vector"); + else + memory->grow(array, ncountmax, values.size(), "vector:array"); } /* ---------------------------------------------------------------------- @@ -224,61 +223,64 @@ void FixVector::end_of_step() // skip if not step which requires doing something if (update->ntimestep != nextstep) return; - if (ncount == ncountmax) - error->all(FLERR,"Overflow of allocated fix vector storage"); + if (ncount == ncountmax) error->all(FLERR, "Overflow of allocated fix vector storage"); // accumulate results of computes,fixes,variables to local copy // compute/fix/variable may invoke computes so wrap with clear/add double *result; - if (nvalues == 1) result = &vector[ncount]; - else result = array[ncount]; + if (values.size() == 1) + result = &vector[ncount]; + else + result = array[ncount]; modify->clearstep_compute(); - for (int i = 0; i < nvalues; i++) { - int m = value2index[i]; + int i = 0; + for (auto &val : values) { // invoke compute if not previously invoked - if (which[i] == ArgInfo::COMPUTE) { - auto compute = modify->get_compute_by_index(m); + if (val.which == ArgInfo::COMPUTE) { - if (argindex[i] == 0) { - if (!(compute->invoked_flag & Compute::INVOKED_SCALAR)) { - compute->compute_scalar(); - compute->invoked_flag |= Compute::INVOKED_SCALAR; + if (val.argindex == 0) { + if (!(val.val.c->invoked_flag & Compute::INVOKED_SCALAR)) { + val.val.c->compute_scalar(); + val.val.c->invoked_flag |= Compute::INVOKED_SCALAR; } - result[i] = compute->scalar; + result[i] = val.val.c->scalar; } else { - if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) { - compute->compute_vector(); - compute->invoked_flag |= Compute::INVOKED_VECTOR; + if (!(val.val.c->invoked_flag & Compute::INVOKED_VECTOR)) { + val.val.c->compute_vector(); + val.val.c->invoked_flag |= Compute::INVOKED_VECTOR; } - result[i] = compute->vector[argindex[i]-1]; + result[i] = val.val.c->vector[val.argindex - 1]; } - // access fix fields, guaranteed to be ready + // access fix fields, guaranteed to be ready - } else if (which[i] == ArgInfo::FIX) { - if (argindex[i] == 0) - result[i] = modify->get_fix_by_index(m)->compute_scalar(); + } else if (val.which == ArgInfo::FIX) { + if (val.argindex == 0) + result[i] = val.val.f->compute_scalar(); else - result[i] = modify->get_fix_by_index(m)->compute_vector(argindex[i]-1); + result[i] = val.val.f->compute_vector(val.argindex - 1); - // evaluate equal-style or vector-style variable + // evaluate equal-style or vector-style variable - } else if (which[i] == ArgInfo::VARIABLE) { - if (argindex[i] == 0) - result[i] = input->variable->compute_equal(m); + } else if (val.which == ArgInfo::VARIABLE) { + if (val.argindex == 0) + result[i] = input->variable->compute_equal(val.val.v); else { double *varvec; - int nvec = input->variable->compute_vector(m,&varvec); - int index = argindex[i]; - if (nvec < index) result[i] = 0.0; - else result[i] = varvec[index-1]; + int nvec = input->variable->compute_vector(val.val.v, &varvec); + int index = val.argindex; + if (nvec < index) + result[i] = 0.0; + else + result[i] = varvec[index - 1]; } } + ++i; } // trigger computes on next needed step @@ -289,8 +291,10 @@ void FixVector::end_of_step() // update size of vector or array ncount++; - if (nvalues == 1) size_vector++; - else size_array_rows++; + if (values.size() == 1) + size_vector++; + else + size_array_rows++; } /* ---------------------------------------------------------------------- diff --git a/src/fix_vector.h b/src/fix_vector.h index 6d0db294c6..3c2f69b21b 100644 --- a/src/fix_vector.h +++ b/src/fix_vector.h @@ -36,9 +36,17 @@ class FixVector : public Fix { double compute_array(int, int) override; private: - int nvalues; - int *which, *argindex, *value2index; - char **ids; + struct value_t { + int which; + int argindex; + std::string id; + union { + class Compute *c; + class Fix *f; + int v; + } val; + }; + std::vector values; bigint nextstep, initialstep; @@ -47,8 +55,6 @@ class FixVector : public Fix { double *vector; double **array; }; - } // namespace LAMMPS_NS - #endif #endif diff --git a/src/fix_wall_reflect.cpp b/src/fix_wall_reflect.cpp index ac5940c513..27f3b41f8b 100644 --- a/src/fix_wall_reflect.cpp +++ b/src/fix_wall_reflect.cpp @@ -35,7 +35,7 @@ FixWallReflect::FixWallReflect(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), nwall(0) { - if (narg < 4) error->all(FLERR,"Illegal fix wall/reflect command"); + if (narg < 4) utils::missing_cmd_args(FLERR, "fix wall/reflect", error); // let child class process all args @@ -53,7 +53,7 @@ FixWallReflect::FixWallReflect(LAMMPS *lmp, int narg, char **arg) : if ((strcmp(arg[iarg],"xlo") == 0) || (strcmp(arg[iarg],"xhi") == 0) || (strcmp(arg[iarg],"ylo") == 0) || (strcmp(arg[iarg],"yhi") == 0) || (strcmp(arg[iarg],"zlo") == 0) || (strcmp(arg[iarg],"zhi") == 0)) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix wall/reflect command"); + if (iarg+2 > narg) error->all(FLERR, "Illegal fix wall/reflect {} command: missing argument(s)", arg[iarg]); int newwall; if (strcmp(arg[iarg],"xlo") == 0) newwall = XLO; @@ -86,26 +86,26 @@ FixWallReflect::FixWallReflect(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"units") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal wall/reflect command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix wall/reflect units", error); if (strcmp(arg[iarg+1],"box") == 0) scaleflag = 0; else if (strcmp(arg[iarg+1],"lattice") == 0) scaleflag = 1; - else error->all(FLERR,"Illegal fix wall/reflect command"); + else error->all(FLERR,"Unknown fix wall/reflect units argument: {}", arg[iarg+1]); iarg += 2; - } else error->all(FLERR,"Illegal fix wall/reflect command"); + } else error->all(FLERR,"Unknown fix wall/reflect keyword: {}", arg[iarg]); } // error check - if (nwall == 0) error->all(FLERR,"Illegal fix wall command"); + if (nwall == 0) utils::missing_cmd_args(FLERR, "fix wall/reflect", error); for (int m = 0; m < nwall; m++) { if ((wallwhich[m] == XLO || wallwhich[m] == XHI) && domain->xperiodic) - error->all(FLERR,"Cannot use fix wall/reflect in periodic dimension"); + error->all(FLERR,"Cannot use fix wall/reflect in periodic dimension x"); if ((wallwhich[m] == YLO || wallwhich[m] == YHI) && domain->yperiodic) - error->all(FLERR,"Cannot use fix wall/reflect in periodic dimension"); + error->all(FLERR,"Cannot use fix wall/reflect in periodic dimension y"); if ((wallwhich[m] == ZLO || wallwhich[m] == ZHI) && domain->zperiodic) - error->all(FLERR,"Cannot use fix wall/reflect in periodic dimension"); + error->all(FLERR,"Cannot use fix wall/reflect in periodic dimension z"); } for (int m = 0; m < nwall; m++) @@ -170,9 +170,9 @@ void FixWallReflect::init() if (wallstyle[m] != VARIABLE) continue; varindex[m] = input->variable->find(varstr[m]); if (varindex[m] < 0) - error->all(FLERR,"Variable name for fix wall/reflect does not exist"); + error->all(FLERR,"Variable {} for fix wall/reflect does not exist", varstr[m]); if (!input->variable->equalstyle(varindex[m])) - error->all(FLERR,"Variable for fix wall/reflect is invalid style"); + error->all(FLERR,"Variable {} for fix wall/reflect is invalid style", varstr[m]); } int nrigid = 0; diff --git a/src/group.cpp b/src/group.cpp index 41c24b8f48..4179797d35 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -101,22 +101,21 @@ void Group::assign(int narg, char **arg) // clear mask of each atom assigned to this group if (strcmp(arg[1],"delete") == 0) { - if (narg != 2) error->all(FLERR,"Illegal group command"); + if (narg != 2) error->all(FLERR,"Illegal group command: too many arguments"); int igroup = find(arg[0]); - if (igroup == -1) error->all(FLERR,"Could not find group delete group ID"); + if (igroup == -1) error->all(FLERR,"Could not find group delete group ID {}",arg[0]); if (igroup == 0) error->all(FLERR,"Cannot delete group all"); - for (const auto &fix : modify->get_fix_list()) - if (fix->igroup == igroup) - error->all(FLERR,"Cannot delete group currently used by a fix"); - for (i = 0; i < modify->ncompute; i++) - if (modify->compute[i]->igroup == igroup) - error->all(FLERR,"Cannot delete group currently used by a compute"); - for (i = 0; i < output->ndump; i++) - if (output->dump[i]->igroup == igroup) - error->all(FLERR,"Cannot delete group currently used by a dump"); + for (const auto &i : modify->get_fix_list()) + if (i->igroup == igroup) + error->all(FLERR,"Cannot delete group {} currently used by fix ID {}",arg[0],i->id); + for (const auto &i : modify->get_compute_list()) + if (i->igroup == igroup) + error->all(FLERR,"Cannot delete group {} currently used by compute ID {}",arg[0],i->id); + for (const auto &i : output->get_dump_list()) + if (i->igroup == igroup) + error->all(FLERR,"Cannot delete group {} currently used by dump ID {}",arg[0],i->id); if (atom->firstgroupname && strcmp(arg[0],atom->firstgroupname) == 0) - error->all(FLERR, - "Cannot delete group currently used by atom_modify first"); + error->all(FLERR,"Cannot delete group {} currently used by atom_modify first",arg[0]); int *mask = atom->mask; int nlocal = atom->nlocal; diff --git a/src/info.cpp b/src/info.cpp index fd8c233868..dc59bdadee 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -887,42 +887,17 @@ bool Info::is_defined(const char *category, const char *name) if ((category == nullptr) || (name == nullptr)) return false; if (strcmp(category,"compute") == 0) { - int ncompute = modify->ncompute; - Compute **compute = modify->compute; - for (int i=0; i < ncompute; ++i) { - if (strcmp(compute[i]->id,name) == 0) - return true; - } + if (modify->get_compute_by_id(name)) return true; } else if (strcmp(category,"dump") == 0) { - int ndump = output->ndump; - Dump **dump = output->dump; - for (int i=0; i < ndump; ++i) { - if (strcmp(dump[i]->id,name) == 0) - return true; - } + if (output->get_dump_by_id(name)) return true; } else if (strcmp(category,"fix") == 0) { - for (const auto &fix : modify->get_fix_list()) { - if (strcmp(fix->id,name) == 0) - return true; - } + if (modify->get_fix_by_id(name)) return true; } else if (strcmp(category,"group") == 0) { - int ngroup = group->ngroup; - char **names = group->names; - for (int i=0; i < ngroup; ++i) { - if (strcmp(names[i],name) == 0) - return true; - } + if (group->find(name) >= 0) return true; } else if (strcmp(category,"region") == 0) { - for (auto ® : domain->get_region_list()) - if (strcmp(reg->id,name) == 0) return true; + if (domain->get_region_by_id(name)) return true; } else if (strcmp(category,"variable") == 0) { - int nvar = input->variable->nvar; - char **names = input->variable->names; - - for (int i=0; i < nvar; ++i) { - if (strcmp(names[i],name) == 0) - return true; - } + if (input->variable->find(name) >= 0) return true; } else error->all(FLERR,"Unknown category for info is_defined(): {}", category); return false; diff --git a/src/library.cpp b/src/library.cpp index 617b9db48c..c9401604f0 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -4761,43 +4761,19 @@ int lammps_has_id(void *handle, const char *category, const char *name) { auto lmp = (LAMMPS *) handle; if (strcmp(category,"compute") == 0) { - int ncompute = lmp->modify->ncompute; - Compute **compute = lmp->modify->compute; - for (int i=0; i < ncompute; ++i) { - if (strcmp(name,compute[i]->id) == 0) return 1; - } + if (lmp->modify->get_compute_by_id(name)) return 1; } else if (strcmp(category,"dump") == 0) { - int ndump = lmp->output->ndump; - Dump **dump = lmp->output->dump; - for (int i=0; i < ndump; ++i) { - if (strcmp(name,dump[i]->id) == 0) return 1; - } + if (lmp->output->get_dump_by_id(name)) return 1; } else if (strcmp(category,"fix") == 0) { - for (auto &ifix : lmp->modify->get_fix_list()) { - if (strcmp(name,ifix->id) == 0) return 1; - } + if (lmp->modify->get_fix_by_id(name)) return 1; } else if (strcmp(category,"group") == 0) { - int ngroup = lmp->group->ngroup; - char **groups = lmp->group->names; - for (int i=0; i < ngroup; ++i) { - if (strcmp(groups[i],name) == 0) return 1; - } + if (lmp->group->find(name) >= 0) return 1; } else if (strcmp(category,"molecule") == 0) { - int nmolecule = lmp->atom->nmolecule; - Molecule **molecule = lmp->atom->molecules; - for (int i=0; i < nmolecule; ++i) { - if (strcmp(name,molecule[i]->id) == 0) return 1; - } + if (lmp->atom->find_molecule(name) >= 0) return 1; } else if (strcmp(category,"region") == 0) { - for (auto ® : lmp->domain->get_region_list()) { - if (strcmp(name,reg->id) == 0) return 1; - } + if (lmp->domain->get_region_by_id(name)) return 1; } else if (strcmp(category,"variable") == 0) { - int nvariable = lmp->input->variable->nvar; - char **varnames = lmp->input->variable->names; - for (int i=0; i < nvariable; ++i) { - if (strcmp(name,varnames[i]) == 0) return 1; - } + if (lmp->input->variable->find(name) >= 0) return 1; } return 0; } @@ -4823,11 +4799,11 @@ categories. int lammps_id_count(void *handle, const char *category) { auto lmp = (LAMMPS *) handle; if (strcmp(category,"compute") == 0) { - return lmp->modify->ncompute; + return lmp->modify->get_compute_list().size(); } else if (strcmp(category,"dump") == 0) { - return lmp->output->ndump; + return lmp->output->get_dump_list().size(); } else if (strcmp(category,"fix") == 0) { - return lmp->modify->nfix; + return lmp->modify->get_fix_list().size(); } else if (strcmp(category,"group") == 0) { return lmp->group->ngroup; } else if (strcmp(category,"molecule") == 0) { @@ -4865,6 +4841,7 @@ set to an empty string, otherwise 1. */ int lammps_id_name(void *handle, const char *category, int idx, char *buffer, int buf_size) { auto lmp = (LAMMPS *) handle; + if (idx < 0) return 0; if (strcmp(category,"compute") == 0) { auto icompute = lmp->modify->get_compute_by_index(idx); @@ -4873,8 +4850,9 @@ int lammps_id_name(void *handle, const char *category, int idx, char *buffer, in return 1; } } else if (strcmp(category,"dump") == 0) { - if ((idx >=0) && (idx < lmp->output->ndump)) { - strncpy(buffer, lmp->output->dump[idx]->id, buf_size); + auto idump = lmp->output->get_dump_by_index(idx); + if (idump) { + strncpy(buffer, idump->id, buf_size); return 1; } } else if (strcmp(category,"fix") == 0) { diff --git a/src/min.cpp b/src/min.cpp index 1adb88184a..d00c0deca4 100644 --- a/src/min.cpp +++ b/src/min.cpp @@ -94,13 +94,13 @@ Min::Min(LAMMPS *lmp) : Pointers(lmp) Min::~Min() { - delete [] elist_global; - delete [] elist_atom; - delete [] vlist_global; - delete [] vlist_atom; - delete [] cvlist_atom; + delete[] elist_global; + delete[] elist_atom; + delete[] vlist_global; + delete[] vlist_atom; + delete[] cvlist_atom; - delete [] fextra; + delete[] fextra; memory->sfree(xextra_atom); memory->sfree(fextra_atom); @@ -128,7 +128,7 @@ void Min::init() // can then add vectors to fix_minimize in setup() nextra_global = 0; - delete [] fextra; + delete[] fextra; fextra = nullptr; nextra_atom = 0; @@ -182,16 +182,15 @@ void Min::init() neigh_delay = neighbor->delay; neigh_dist_check = neighbor->dist_check; - if (neigh_every != 1 || neigh_delay != 0 || neigh_dist_check != 1) { + if ((neigh_every != 1) || (neigh_delay != 0)) { if (comm->me == 0) - error->warning(FLERR, "Using 'neigh_modify every 1 delay 0 check" - " yes' setting during minimization"); + utils::logmesg(lmp, "Switching to 'neigh_modify every 1 delay 0 check yes' " + "setting during minimization\n"); + neighbor->every = 1; + neighbor->delay = 0; + neighbor->dist_check = 1; } - neighbor->every = 1; - neighbor->delay = 0; - neighbor->dist_check = 1; - niter = neval = 0; // store timestep size (important for variable timestep minimizer) @@ -751,11 +750,11 @@ void Min::modify_params(int narg, char **arg) void Min::ev_setup() { - delete [] elist_global; - delete [] elist_atom; - delete [] vlist_global; - delete [] vlist_atom; - delete [] cvlist_atom; + delete[] elist_global; + delete[] elist_atom; + delete[] vlist_global; + delete[] vlist_atom; + delete[] cvlist_atom; elist_global = elist_atom = nullptr; vlist_global = vlist_atom = cvlist_atom = nullptr; diff --git a/src/minimize.cpp b/src/minimize.cpp index e9c6ec25b3..f4743d1815 100644 --- a/src/minimize.cpp +++ b/src/minimize.cpp @@ -31,7 +31,7 @@ Minimize::Minimize(LAMMPS *lmp) : Command(lmp) {} void Minimize::command(int narg, char **arg) { - if (narg != 4) error->all(FLERR, "Illegal minimize command"); + if (narg != 4) error->all(FLERR,"Illegal minimize command: expected 4 arguments but found {}", narg); if (domain->box_exist == 0) error->all(FLERR, "Minimize command before simulation box is defined"); @@ -44,7 +44,8 @@ void Minimize::command(int narg, char **arg) update->nsteps = utils::inumeric(FLERR, arg[2], false, lmp); update->max_eval = utils::inumeric(FLERR, arg[3], false, lmp); - if (update->etol < 0.0 || update->ftol < 0.0) error->all(FLERR, "Illegal minimize command"); + if (update->etol < 0.0) error->all(FLERR, "Illegal minimize energy tolerance: {}", update->etol); + if (update->ftol < 0.0) error->all(FLERR, "Illegal minimize force tolerance: {}", update->ftol); if (lmp->citeme) lmp->citeme->flush(); update->whichflag = 2; diff --git a/src/modify.cpp b/src/modify.cpp index aac08bb31e..90399abec4 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -797,7 +797,7 @@ int Modify::min_reset_ref() Fix *Modify::add_fix(int narg, char **arg, int trysuffix) { - if (narg < 3) error->all(FLERR, "Illegal fix command"); + if (narg < 3) utils::missing_cmd_args(FLERR, "fix", error); // cannot define fix before box exists unless style is in exception list // don't like this way of checking for exceptions by adding fixes to list, @@ -988,7 +988,7 @@ Fix *Modify::replace_fix(const char *replaceID, int narg, char **arg, int trysuf // change ID, igroup, style of fix being replaced to match new fix // requires some error checking on arguments for new fix - if (narg < 3) error->all(FLERR, "Illegal replace_fix invocation"); + if (narg < 3) error->all(FLERR, "Not enough arguments for replace_fix invocation"); if (get_fix_by_id(arg[0])) error->all(FLERR, "Replace_fix ID {} is already in use", arg[0]); delete[] oldfix->id; @@ -1026,16 +1026,11 @@ Fix *Modify::replace_fix(const std::string &oldfix, const std::string &fixcmd, i void Modify::modify_fix(int narg, char **arg) { - if (narg < 2) error->all(FLERR, "Illegal fix_modify command"); + if (narg < 2) utils::missing_cmd_args(FLERR, "fix_modify", error); - // lookup Fix ID - - int ifix; - for (ifix = 0; ifix < nfix; ifix++) - if (strcmp(arg[0], fix[ifix]->id) == 0) break; - if (ifix == nfix) error->all(FLERR, "Could not find fix_modify ID {}", arg[0]); - - fix[ifix]->modify_params(narg - 1, &arg[1]); + auto ifix = get_fix_by_id(arg[0]); + if (!ifix) error->all(FLERR, "Could not find fix_modify ID {}", arg[0]); + ifix->modify_params(narg - 1, &arg[1]); } /* ---------------------------------------------------------------------- @@ -1226,13 +1221,11 @@ int Modify::check_rigid_list_overlap(int *select) Compute *Modify::add_compute(int narg, char **arg, int trysuffix) { - if (narg < 3) error->all(FLERR, "Illegal compute command"); + if (narg < 3) utils::missing_cmd_args(FLERR, "compute", error); // error check - for (int icompute = 0; icompute < ncompute; icompute++) - if (strcmp(arg[0], compute[icompute]->id) == 0) - error->all(FLERR, "Reuse of compute ID '{}'", arg[0]); + if (get_compute_by_id(arg[0])) error->all(FLERR, "Reuse of compute ID '{}'", arg[0]); // extend Compute list if necessary @@ -1299,16 +1292,13 @@ Compute *Modify::add_compute(const std::string &computecmd, int trysuffix) void Modify::modify_compute(int narg, char **arg) { - if (narg < 2) error->all(FLERR, "Illegal compute_modify command"); + if (narg < 2) utils::missing_cmd_args(FLERR, "compute_modify",error); // lookup Compute ID - int icompute; - for (icompute = 0; icompute < ncompute; icompute++) - if (strcmp(arg[0], compute[icompute]->id) == 0) break; - if (icompute == ncompute) error->all(FLERR, "Could not find compute_modify ID {}", arg[0]); - - compute[icompute]->modify_params(narg - 1, &arg[1]); + auto icompute = get_compute_by_id(arg[0]); + if (!icompute) error->all(FLERR, "Could not find compute_modify ID {}", arg[0]); + icompute->modify_params(narg - 1, &arg[1]); } /* ---------------------------------------------------------------------- diff --git a/src/molecule.cpp b/src/molecule.cpp index 816b2686ab..702bee45af 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -1671,64 +1671,48 @@ int Molecule::findfragment(const char *name) /* ---------------------------------------------------------------------- error check molecule attributes and topology against system settings - flag = 0, just check this molecule - flag = 1, check all molecules in set, this is 1st molecule in set ------------------------------------------------------------------------- */ -void Molecule::check_attributes(int flag) +void Molecule::check_attributes() { - int n = 1; - if (flag) n = nset; - int imol = atom->find_molecule(id); + // check per-atom attributes of molecule + // warn if not a match - for (int i = imol; i < imol+n; i++) { - Molecule *onemol = atom->molecules[imol]; + int mismatch = 0; + if (qflag && !atom->q_flag) mismatch = 1; + if (radiusflag && !atom->radius_flag) mismatch = 1; + if (rmassflag && !atom->rmass_flag) mismatch = 1; - // check per-atom attributes of molecule - // warn if not a match + if (mismatch && me == 0) + error->warning(FLERR,"Molecule attributes do not match system attributes"); - int mismatch = 0; - if (onemol->qflag && !atom->q_flag) mismatch = 1; - if (onemol->radiusflag && !atom->radius_flag) mismatch = 1; - if (onemol->rmassflag && !atom->rmass_flag) mismatch = 1; + // for all atom styles, check nbondtype,etc - if (mismatch && me == 0) - error->warning(FLERR,"Molecule attributes do not match system attributes"); + mismatch = 0; + if (atom->nbondtypes < nbondtypes) mismatch = 1; + if (atom->nangletypes < nangletypes) mismatch = 1; + if (atom->ndihedraltypes < ndihedraltypes) mismatch = 1; + if (atom->nimpropertypes < nimpropertypes) mismatch = 1; - // for all atom styles, check nbondtype,etc + if (mismatch) error->all(FLERR,"Molecule topology type exceeds system topology type"); - mismatch = 0; - if (atom->nbondtypes < onemol->nbondtypes) mismatch = 1; - if (atom->nangletypes < onemol->nangletypes) mismatch = 1; - if (atom->ndihedraltypes < onemol->ndihedraltypes) mismatch = 1; - if (atom->nimpropertypes < onemol->nimpropertypes) mismatch = 1; + // for molecular atom styles, check bond_per_atom,etc + maxspecial + // do not check for atom style template, since nothing stored per atom - if (mismatch) - error->all(FLERR,"Molecule topology type exceeds system topology type"); + if (atom->molecular == Atom::MOLECULAR) { + if (atom->avec->bonds_allow && atom->bond_per_atom < bond_per_atom) mismatch = 1; + if (atom->avec->angles_allow && atom->angle_per_atom < angle_per_atom) mismatch = 1; + if (atom->avec->dihedrals_allow && atom->dihedral_per_atom < dihedral_per_atom) mismatch = 1; + if (atom->avec->impropers_allow && atom->improper_per_atom < improper_per_atom) mismatch = 1; + if (atom->maxspecial < maxspecial) mismatch = 1; - // for molecular atom styles, check bond_per_atom,etc + maxspecial - // do not check for atom style template, since nothing stored per atom - - if (atom->molecular == Atom::MOLECULAR) { - if (atom->avec->bonds_allow && - atom->bond_per_atom < onemol->bond_per_atom) mismatch = 1; - if (atom->avec->angles_allow && - atom->angle_per_atom < onemol->angle_per_atom) mismatch = 1; - if (atom->avec->dihedrals_allow && - atom->dihedral_per_atom < onemol->dihedral_per_atom) mismatch = 1; - if (atom->avec->impropers_allow && - atom->improper_per_atom < onemol->improper_per_atom) mismatch = 1; - if (atom->maxspecial < onemol->maxspecial) mismatch = 1; - - if (mismatch) - error->all(FLERR,"Molecule topology/atom exceeds system topology/atom"); - } - - // warn if molecule topology defined but no special settings - - if (onemol->bondflag && !onemol->specialflag) - if (me == 0) error->warning(FLERR,"Molecule has bond topology but no special bond settings"); + if (mismatch) error->all(FLERR,"Molecule topology/atom exceeds system topology/atom"); } + + // warn if molecule topology defined but no special settings + + if (bondflag && !specialflag) + if (me == 0) error->warning(FLERR,"Molecule has bond topology but no special bond settings"); } /* ---------------------------------------------------------------------- diff --git a/src/molecule.h b/src/molecule.h index 69106e5a34..b4a8e642cc 100644 --- a/src/molecule.h +++ b/src/molecule.h @@ -125,7 +125,7 @@ class Molecule : protected Pointers { void compute_com(); void compute_inertia(); int findfragment(const char *); - void check_attributes(int); + void check_attributes(); private: int me; diff --git a/src/neighbor.cpp b/src/neighbor.cpp index b6b095ddf4..ac0c7921d8 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -68,37 +68,31 @@ enum{NONE,ALL,PARTIAL,TEMPLATE}; static const char cite_neigh_multi_old[] = "neighbor multi/old command: doi:10.1016/j.cpc.2008.03.005\n\n" "@Article{Intveld08,\n" - " author = {P.{\\,}J.~in{\\,}'t~Veld and S.{\\,}J.~Plimpton" - " and G.{\\,}S.~Grest},\n" + " author = {in 't Veld, P. J. and S. J. Plimpton and G. S. Grest},\n" " title = {Accurate and Efficient Methods for Modeling Colloidal\n" " Mixtures in an Explicit Solvent using Molecular Dynamics},\n" - " journal = {Comp.~Phys.~Comm.},\n" + " journal = {Comput.\\ Phys.\\ Commun.},\n" " year = 2008,\n" " volume = 179,\n" + " number = 5,\n" " pages = {320--329}\n" "}\n\n"; static const char cite_neigh_multi[] = "neighbor multi command: doi:10.1016/j.cpc.2008.03.005, doi:10.1007/s40571-020-00361-2\n\n" "@Article{Intveld08,\n" - " author = {P.{\\,}J.~in{\\,}'t~Veld and S.{\\,}J.~Plimpton" - " and G.{\\,}S.~Grest},\n" + " author = {in 't Veld, P. J. and S. J.~Plimpton and G. S. Grest},\n" " title = {Accurate and Efficient Methods for Modeling Colloidal\n" " Mixtures in an Explicit Solvent using Molecular Dynamics},\n" - " journal = {Comp.~Phys.~Comm.},\n" + " journal = {Comput.\\ Phys.\\ Commut.},\n" " year = 2008,\n" " volume = 179,\n" " pages = {320--329}\n" "}\n\n" - "@article{Stratford2018,\n" - " author = {Stratford, Kevin and Shire, Tom and Hanley, Kevin},\n" - " title = {Implementation of multi-level contact detection in LAMMPS},\n" - " year = {2018}\n" - "}\n\n" "@article{Shire2020,\n" " author = {Shire, Tom and Hanley, Kevin J. and Stratford, Kevin},\n" - " title = {DEM simulations of polydisperse media: efficient contact\n" - " detection applied to investigate the quasi-static limit},\n" + " title = {{DEM} Simulations of Polydisperse Media: Efficient Contact\n" + " Detection Applied to Investigate the Quasi-Static Limit},\n" " journal = {Computational Particle Mechanics},\n" " year = {2020}\n" "}\n\n"; @@ -1164,7 +1158,6 @@ void Neighbor::morph_unique() if (irq->cutoff != cutneighmax) { irq->unique = 1; - } else { irq->cut = 0; irq->cutoff = 0.0; @@ -1720,7 +1713,7 @@ void Neighbor::print_pairwise_info() } std::string out = "Neighbor list info ...\n"; - out += fmt::format(" update every {} steps, delay {} steps, check {}\n", + out += fmt::format(" update: every = {} steps, delay = {} steps, check = {}\n", every,delay,dist_check ? "yes" : "no"); out += fmt::format(" max neighbors/atom: {}, page size: {}\n", oneatom, pgsize); @@ -1808,7 +1801,6 @@ void Neighbor::print_pairwise_info() out += " "; if (lists[i]->bin_method == 0) out += "bin: none\n"; else out += fmt::format("bin: {}\n",binnames[lists[i]->bin_method-1]); - } utils::logmesg(lmp,out); } @@ -2582,60 +2574,58 @@ void Neighbor::modify_params(int narg, char **arg) int iarg = 0; while (iarg < narg) { if (strcmp(arg[iarg],"every") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "neigh_modify every", error); every = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (every <= 0) error->all(FLERR,"Illegal neigh_modify command"); + if (every <= 0) error->all(FLERR, "Invalid neigh_modify every argument: {}", every); iarg += 2; } else if (strcmp(arg[iarg],"delay") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "neigh_modify delay", error); delay = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (delay < 0) error->all(FLERR,"Illegal neigh_modify command"); + if (delay < 0) error->all(FLERR, "Invalid neigh_modify delay argument: {}", delay); iarg += 2; } else if (strcmp(arg[iarg],"check") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "neigh_modify check", error); dist_check = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"once") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "neigh_modify once", error); build_once = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"page") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "neigh_modify page", error); old_pgsize = pgsize; pgsize = utils::inumeric(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"one") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "neigh_modify one", error); old_oneatom = oneatom; oneatom = utils::inumeric(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"binsize") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "neigh_modify binsize", error); binsize_user = utils::numeric(FLERR,arg[iarg+1],false,lmp); if (binsize_user <= 0.0) binsizeflag = 0; else binsizeflag = 1; iarg += 2; } else if (strcmp(arg[iarg],"cluster") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "neigh_modify cluster", error); cluster_check = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; - } else if (strcmp(arg[iarg],"include") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "neigh_modify include", error); includegroup = group->find(arg[iarg+1]); if (includegroup < 0) - error->all(FLERR,"Invalid group ID in neigh_modify command"); - if (includegroup && (atom->firstgroupname == nullptr || - strcmp(arg[iarg+1],atom->firstgroupname) != 0)) - error->all(FLERR, - "Neigh_modify include group != atom_modify first group"); + error->all(FLERR, "Invalid include keyword: group {} not found", arg[iarg+1]); + if (atom->firstgroupname == nullptr) + error->all(FLERR, "Invalid include keyword: atom_modify first command must be used"); + if (strcmp(arg[iarg+1],atom->firstgroupname) != 0) + error->all(FLERR, "Neigh_modify include group != atom_modify first group: {}", atom->firstgroupname); iarg += 2; - } else if (strcmp(arg[iarg],"exclude") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "neigh_modify exclude", error); if (strcmp(arg[iarg+1],"type") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "neigh_modify exclude type", error); if (nex_type == maxex_type) { maxex_type += EXDELTA; memory->grow(ex1_type,maxex_type,"neigh:ex1_type"); @@ -2645,9 +2635,8 @@ void Neighbor::modify_params(int narg, char **arg) ex2_type[nex_type] = utils::inumeric(FLERR,arg[iarg+3],false,lmp); nex_type++; iarg += 4; - } else if (strcmp(arg[iarg+1],"group") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "neigh_modify exclude group", error); if (nex_group == maxex_group) { maxex_group += EXDELTA; memory->grow(ex1_group,maxex_group,"neigh:ex1_group"); @@ -2655,14 +2644,15 @@ void Neighbor::modify_params(int narg, char **arg) } ex1_group[nex_group] = group->find(arg[iarg+2]); ex2_group[nex_group] = group->find(arg[iarg+3]); - if (ex1_group[nex_group] == -1 || ex2_group[nex_group] == -1) - error->all(FLERR,"Invalid group ID in neigh_modify command"); + if (ex1_group[nex_group] == -1) + error->all(FLERR, "Invalid exclude group keyword: group {} not found", arg[iarg+2]); + if (ex2_group[nex_group] == -1) + error->all(FLERR, "Invalid exclude group keyword: group {} not found", arg[iarg+3]); nex_group++; iarg += 4; - } else if (strcmp(arg[iarg+1],"molecule/inter") == 0 || strcmp(arg[iarg+1],"molecule/intra") == 0) { - if (iarg+3 > narg) error->all(FLERR,"Illegal neigh_modify command"); + if (iarg+3 > narg) utils::missing_cmd_args(FLERR, "neigh_modify exclude molecule", error); if (atom->molecule_flag == 0) error->all(FLERR,"Neigh_modify exclude molecule " "requires atom attribute molecule"); @@ -2676,30 +2666,28 @@ void Neighbor::modify_params(int narg, char **arg) } ex_mol_group[nex_mol] = group->find(arg[iarg+2]); if (ex_mol_group[nex_mol] == -1) - error->all(FLERR,"Invalid group ID in neigh_modify command"); + error->all(FLERR, "Invalid exclude keyword:group {} not found", arg[iarg+2]); if (strcmp(arg[iarg+1],"molecule/intra") == 0) ex_mol_intra[nex_mol] = 1; else ex_mol_intra[nex_mol] = 0; nex_mol++; iarg += 3; - } else if (strcmp(arg[iarg+1],"none") == 0) { nex_type = nex_group = nex_mol = 0; iarg += 2; - - } else error->all(FLERR,"Illegal neigh_modify command"); + } else error->all(FLERR,"Unknown neigh_modify exclude keyword: {}", arg[iarg+1]); } else if (strcmp(arg[iarg],"collection/interval") == 0) { if (style != Neighbor::MULTI) error->all(FLERR,"Cannot use collection/interval command without multi setting"); if (iarg+2 > narg) - error->all(FLERR,"Invalid collection/interval command"); + utils::missing_cmd_args(FLERR, "neigh_modify collection/interval", error); ncollections = utils::inumeric(FLERR,arg[iarg+1],false,lmp); if (ncollections < 1) - error->all(FLERR,"Invalid collection/interval command"); - if (iarg+1+ncollections > narg) - error->all(FLERR,"Invalid collection/interval command"); + error->all(FLERR, "Invalid collection/interval keyword: illegal number of custom collections: {}", ncollections); + if (iarg+2+ncollections > narg) + error->all(FLERR, "Invalid collection/interval keyword: expected {} separate lists of types", ncollections); int i; @@ -2728,12 +2716,12 @@ void Neighbor::modify_params(int narg, char **arg) error->all(FLERR,"Cannot use collection/type command without multi setting"); if (iarg+2 > narg) - error->all(FLERR,"Invalid collection/type command"); + utils::missing_cmd_args(FLERR, "neigh_modify collection/type", error); ncollections = utils::inumeric(FLERR,arg[iarg+1],false,lmp); if (ncollections < 1) - error->all(FLERR,"Invalid collection/interval command"); - if (iarg+1+ncollections > narg) - error->all(FLERR,"Invalid collection/type command"); + error->all(FLERR, "Invalid collection/type keyword: illegal number of custom collections: {}", ncollections); + if (iarg+2+ncollections > narg) + error->all(FLERR, "Invalid collection/type keyword: expected {} separate lists of types", ncollections); int ntypes = atom->ntypes; int nlo, nhi, i, k; @@ -2774,7 +2762,7 @@ void Neighbor::modify_params(int narg, char **arg) } iarg += 2 + ncollections; - } else error->all(FLERR,"Illegal neigh_modify command"); + } else error->all(FLERR,"Unknown neigh_modify keyword: {}", arg[iarg]); } } @@ -2818,7 +2806,6 @@ void Neighbor::exclusion_group_group_delete(int group1, int group2) nex_group--; } - /* ---------------------------------------------------------------------- return the value of exclude - used to check compatibility with GPU ------------------------------------------------------------------------- */ @@ -2881,7 +2868,6 @@ void Neighbor::build_collection(int istart) } } - /* ---------------------------------------------------------------------- for neighbor list statistics in Finish class ------------------------------------------------------------------------- */ diff --git a/src/output.cpp b/src/output.cpp index 7d8188a4c3..4035de3529 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -783,6 +783,7 @@ Dump *Output::add_dump(int narg, char **arg) next_dump[idump] = 0; ndump++; + dump_list = std::vector(dump, dump + ndump); return dump[idump]; } @@ -792,16 +793,13 @@ Dump *Output::add_dump(int narg, char **arg) void Output::modify_dump(int narg, char **arg) { - if (narg < 1) utils::missing_cmd_args(FLERR, "dump_modify",error); + if (narg < 2) utils::missing_cmd_args(FLERR, "dump_modify",error); // find which dump it is - int idump; - for (idump = 0; idump < ndump; idump++) - if (strcmp(arg[0],dump[idump]->id) == 0) break; - if (idump == ndump) error->all(FLERR,"Could not find dump_modify ID: {}", arg[0]); - - dump[idump]->modify_params(narg-1,&arg[1]); + auto idump = get_dump_by_id(arg[0]); + if (!idump) error->all(FLERR,"Could not find dump_modify ID: {}", arg[0]); + idump->modify_params(narg-1,&arg[1]); } /* ---------------------------------------------------------------------- @@ -833,21 +831,7 @@ void Output::delete_dump(const std::string &id) ivar_dump[i-1] = ivar_dump[i]; } ndump--; -} - -/* ---------------------------------------------------------------------- - find a dump by ID - return index of dump or -1 if not found -------------------------------------------------------------------------- */ - -int Output::find_dump(const char *id) -{ - if (id == nullptr) return -1; - int idump; - for (idump = 0; idump < ndump; idump++) - if (strcmp(id,dump[idump]->id) == 0) break; - if (idump == ndump) return -1; - return idump; + dump_list = std::vector(dump, dump + ndump); } /* ---------------------------------------------------------------------- @@ -855,13 +839,23 @@ int Output::find_dump(const char *id) return pointer to dump ------------------------------------------------------------------------- */ -Dump *Output::get_dump_by_id(const std::string &id) +Dump *Output::get_dump_by_id(const std::string &id) const { if (id.empty()) return nullptr; for (int idump = 0; idump < ndump; idump++) if (id == dump[idump]->id) return dump[idump]; return nullptr; } +/* ---------------------------------------------------------------------- + return list of dumps as vector +------------------------------------------------------------------------- */ + +const std::vector &Output::get_dump_list() +{ + dump_list = std::vector(dump, dump + ndump); + return dump_list; +} + /* ---------------------------------------------------------------------- set thermo output frequency from input script ------------------------------------------------------------------------- */ diff --git a/src/output.h b/src/output.h index c35d2728e5..adbfd1b165 100644 --- a/src/output.h +++ b/src/output.h @@ -80,12 +80,17 @@ class Output : protected Pointers { void reset_timestep(bigint); // reset output which depends on timestep void reset_dt(); // reset output which depends on timestep size - Dump *add_dump(int, char **); // add a Dump to Dump list - void modify_dump(int, char **); // modify a Dump - void delete_dump(const std::string &); // delete a Dump from Dump list - int find_dump(const char *); // find a Dump ID - Dump *get_dump_by_id(const std::string &); // find a Dump by ID - int check_time_dumps(bigint); // check if any time dump is output now + Dump *add_dump(int, char **); // add a Dump to Dump list + void modify_dump(int, char **); // modify a Dump + void delete_dump(const std::string &); // delete a Dump from Dump list + Dump *get_dump_by_id(const std::string &) const; // find a Dump by ID + Dump *get_dump_by_index(int idx) const // find a Dump by index in Dump list + { + return ((idx >= 0) && (idx < ndump)) ? dump[idx] : nullptr; + } + + const std::vector &get_dump_list(); // get vector with all dumps + int check_time_dumps(bigint); // check if any time dump is output now void set_thermo(int, char **); // set thermo output freqquency void create_thermo(int, char **); // create a thermo style @@ -94,6 +99,7 @@ class Output : protected Pointers { void memory_usage(); // print out memory usage private: + std::vector dump_list; void calculate_next_dump(int, int, bigint); }; diff --git a/src/read_data.cpp b/src/read_data.cpp index 1ec8210e5e..7f6c153ef6 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -17,6 +17,7 @@ #include "angle.h" #include "atom.h" #include "atom_vec.h" +#include "atom_vec_body.h" #include "atom_vec_ellipsoid.h" #include "atom_vec_line.h" #include "atom_vec_tri.h" @@ -99,30 +100,30 @@ ReadData::ReadData(LAMMPS *lmp) : Command(lmp) // pointers to atom styles that store bonus info nellipsoids = 0; - avec_ellipsoid = dynamic_cast( atom->style_match("ellipsoid")); + avec_ellipsoid = dynamic_cast(atom->style_match("ellipsoid")); nlines = 0; - avec_line = dynamic_cast( atom->style_match("line")); + avec_line = dynamic_cast(atom->style_match("line")); ntris = 0; - avec_tri = dynamic_cast( atom->style_match("tri")); + avec_tri = dynamic_cast(atom->style_match("tri")); nbodies = 0; - avec_body = (AtomVecBody *) atom->style_match("body"); + avec_body = dynamic_cast(atom->style_match("body")); } /* ---------------------------------------------------------------------- */ ReadData::~ReadData() { - delete [] line; - delete [] keyword; - delete [] style; - delete [] buffer; + delete[] line; + delete[] keyword; + delete[] style; + delete[] buffer; memory->sfree(coeffarg); for (int i = 0; i < nfix; i++) { - delete [] fix_header[i]; - delete [] fix_section[i]; + delete[] fix_header[i]; + delete[] fix_section[i]; } - memory->destroy(fix_index); + memory->sfree(fix_index); memory->sfree(fix_header); memory->sfree(fix_section); } @@ -285,16 +286,13 @@ void ReadData::command(int narg, char **arg) } else if (strcmp(arg[iarg],"fix") == 0) { if (iarg+4 > narg) error->all(FLERR,"Illegal read_data command"); - memory->grow(fix_index,nfix+1,"read_data:fix_index"); - fix_header = (char **) memory->srealloc(fix_header,(nfix+1)*sizeof(char *), - "read_data:fix_header"); - fix_section = (char **) memory->srealloc(fix_section,(nfix+1)*sizeof(char *), - "read_data:fix_section"); + fix_index = (Fix **)memory->srealloc(fix_index,(nfix+1)*sizeof(Fix *),"read_data:fix_index"); + fix_header = (char **) memory->srealloc(fix_header,(nfix+1)*sizeof(char *),"read_data:fix_header"); + fix_section = (char **) memory->srealloc(fix_section,(nfix+1)*sizeof(char *),"read_data:fix_section"); if (is_data_section(arg[iarg+3])) - error->all(FLERR,"Custom data section name {} for fix {} collides with existing " - "data section",arg[iarg+3],arg[iarg+1]); - fix_index[nfix] = modify->find_fix(arg[iarg+1]); - if (fix_index[nfix] < 0) error->all(FLERR,"Fix ID for read_data does not exist"); + error->all(FLERR,"Custom data section name {} for fix {} collides with existing data section",arg[iarg+3],arg[iarg+1]); + fix_index[nfix] = modify->get_fix_by_id(arg[iarg+1]); + if (!fix_index[nfix]) error->all(FLERR,"Fix ID {} for read_data does not exist",arg[iarg+1]); if (strcmp(arg[iarg+2],"NULL") == 0) fix_header[nfix] = nullptr; else fix_header[nfix] = utils::strdup(arg[iarg+2]); if (strcmp(arg[iarg+3],"NULL") == 0) fix_section[nfix] = utils::strdup(arg[iarg+1]); @@ -743,8 +741,7 @@ void ReadData::command(int narg, char **arg) for (i = 0; i < nfix; i++) if (strcmp(keyword,fix_section[i]) == 0) { if (firstpass) fix(fix_index[i],keyword); - else skip_lines(modify->fix[fix_index[i]]-> - read_data_skip_lines(keyword)); + else skip_lines(fix_index[i]->read_data_skip_lines(keyword)); break; } if (i == nfix) @@ -866,7 +863,10 @@ void ReadData::command(int narg, char **arg) // insure nbondtypes,etc are still consistent with template molecules, // in case data file re-defined them - if (atom->molecular == Atom::TEMPLATE) atom->avec->onemols[0]->check_attributes(1); + if (atom->molecular == Atom::TEMPLATE) { + int nset = MAX(1, atom->avec->onemols[0]->nset); + for (int i = 0; i < nset; ++i) atom->avec->onemols[i]->check_attributes(); + } // if adding atoms, migrate atoms to new processors // use irregular() b/c box size could have changed dramaticaly @@ -1008,7 +1008,7 @@ void ReadData::header(int firstpass) for (n = 0; n < nfix; n++) { if (!fix_header[n]) continue; if (strstr(line,fix_header[n])) { - modify->fix[fix_index[n]]->read_data_header(line); + fix_index[n]->read_data_header(line); break; } } @@ -1754,7 +1754,7 @@ void ReadData::mass() atom->set_mass(FLERR,buf,toffset); buf = next + 1; } - delete [] original; + delete[] original; } /* ---------------------------------------------------------------------- */ @@ -1777,7 +1777,7 @@ void ReadData::paircoeffs() force->pair->coeff(ncoeffarg,coeffarg); buf = next + 1; } - delete [] original; + delete[] original; } /* ---------------------------------------------------------------------- */ @@ -1804,7 +1804,7 @@ void ReadData::pairIJcoeffs() force->pair->coeff(ncoeffarg,coeffarg); buf = next + 1; } - delete [] original; + delete[] original; } /* ---------------------------------------------------------------------- */ @@ -1829,7 +1829,7 @@ void ReadData::bondcoeffs() force->bond->coeff(ncoeffarg,coeffarg); buf = next + 1; } - delete [] original; + delete[] original; } /* ---------------------------------------------------------------------- */ @@ -1856,7 +1856,7 @@ void ReadData::anglecoeffs(int which) force->angle->coeff(ncoeffarg,coeffarg); buf = next + 1; } - delete [] original; + delete[] original; } /* ---------------------------------------------------------------------- */ @@ -1886,7 +1886,7 @@ void ReadData::dihedralcoeffs(int which) force->dihedral->coeff(ncoeffarg,coeffarg); buf = next + 1; } - delete [] original; + delete[] original; } /* ---------------------------------------------------------------------- */ @@ -1911,7 +1911,7 @@ void ReadData::impropercoeffs(int which) force->improper->coeff(ncoeffarg,coeffarg); buf = next + 1; } - delete [] original; + delete[] original; } /* ---------------------------------------------------------------------- @@ -1919,18 +1919,18 @@ void ReadData::impropercoeffs(int which) n = index of fix ------------------------------------------------------------------------- */ -void ReadData::fix(int ifix, char *keyword) +void ReadData::fix(Fix *ifix, char *keyword) { int nchunk,eof; - bigint nline = modify->fix[ifix]->read_data_skip_lines(keyword); + bigint nline = ifix->read_data_skip_lines(keyword); bigint nread = 0; while (nread < nline) { nchunk = MIN(nline-nread,CHUNK); eof = utils::read_lines_from_file(fp,nchunk,MAXLINE,buffer,me,world); - if (eof) error->all(FLERR,"Unexpected end of data file"); - modify->fix[ifix]->read_data_section(keyword,nchunk,buffer,id_offset); + if (eof) error->all(FLERR,"Unexpected end of data file while reading section {}",keyword); + ifix->read_data_section(keyword,nchunk,buffer,id_offset); nread += nchunk; } } diff --git a/src/read_data.h b/src/read_data.h index 250cdf3178..5002894019 100644 --- a/src/read_data.h +++ b/src/read_data.h @@ -23,7 +23,7 @@ CommandStyle(read_data,ReadData); #include "command.h" namespace LAMMPS_NS { - +class Fix; class ReadData : public Command { public: ReadData(class LAMMPS *); @@ -73,7 +73,7 @@ class ReadData : public Command { int groupbit; int nfix; - int *fix_index; + Fix **fix_index; char **fix_header; char **fix_section; @@ -108,7 +108,7 @@ class ReadData : public Command { void dihedralcoeffs(int); void impropercoeffs(int); - void fix(int, char *); + void fix(Fix *, char *); }; } // namespace LAMMPS_NS diff --git a/src/region.cpp b/src/region.cpp index b533d45ea7..307513add6 100644 --- a/src/region.cpp +++ b/src/region.cpp @@ -302,7 +302,7 @@ void Region::rotate(double &x, double &y, double &z, double angle) void Region::options(int narg, char **arg) { - if (narg < 0) error->all(FLERR, "Illegal region command"); + if (narg < 0) utils::missing_cmd_args(FLERR, "region", error); // option defaults @@ -316,46 +316,46 @@ void Region::options(int narg, char **arg) int iarg = 0; while (iarg < narg) { if (strcmp(arg[iarg], "units") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal region command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "region units", error); if (strcmp(arg[iarg + 1], "box") == 0) scaleflag = 0; else if (strcmp(arg[iarg + 1], "lattice") == 0) scaleflag = 1; else - error->all(FLERR, "Illegal region command"); + error->all(FLERR, "Illegal region units: {}", arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg], "side") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal region command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "region side", error); if (strcmp(arg[iarg + 1], "in") == 0) interior = 1; else if (strcmp(arg[iarg + 1], "out") == 0) interior = 0; else - error->all(FLERR, "Illegal region command"); + error->all(FLERR, "Illegal region side: {}", arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg], "move") == 0) { - if (iarg + 4 > narg) error->all(FLERR, "Illegal region command"); + if (iarg + 4 > narg) utils::missing_cmd_args(FLERR, "region move", error); if (strcmp(arg[iarg + 1], "NULL") != 0) { if (strstr(arg[iarg + 1], "v_") != arg[iarg + 1]) - error->all(FLERR, "Illegal region command"); + error->all(FLERR, "Illegal region move x displacement variable: {}", arg[iarg+1]); xstr = utils::strdup(&arg[iarg + 1][2]); } if (strcmp(arg[iarg + 2], "NULL") != 0) { if (strstr(arg[iarg + 2], "v_") != arg[iarg + 2]) - error->all(FLERR, "Illegal region command"); + error->all(FLERR, "Illegal region move y displacement variable: {}", arg[iarg+2]); ystr = utils::strdup(&arg[iarg + 2][2]); } if (strcmp(arg[iarg + 3], "NULL") != 0) { if (strstr(arg[iarg + 3], "v_") != arg[iarg + 3]) - error->all(FLERR, "Illegal region command"); + error->all(FLERR, "Illegal region move z displacement variable: {}", arg[iarg+3]); zstr = utils::strdup(&arg[iarg + 3][2]); } moveflag = 1; iarg += 4; } else if (strcmp(arg[iarg], "rotate") == 0) { - if (iarg + 8 > narg) error->all(FLERR, "Illegal region command"); + if (iarg + 8 > narg) utils::missing_cmd_args(FLERR, "region rotate", error); if (strstr(arg[iarg + 1], "v_") != arg[iarg + 1]) error->all(FLERR, "Illegal region command"); tstr = utils::strdup(&arg[iarg + 1][2]); point[0] = utils::numeric(FLERR, arg[iarg + 2], false, lmp); @@ -368,15 +368,14 @@ void Region::options(int narg, char **arg) iarg += 8; } else if (strcmp(arg[iarg], "open") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal region command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "region open", error); int iface = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); - if (iface < 1 || iface > 6) error->all(FLERR, "Illegal region command"); + if (iface < 1 || iface > 6) error->all(FLERR, "Illegal region open face index: {}", iface); // additional checks on valid face index are done by region classes open_faces[iface - 1] = 1; openflag = 1; iarg += 2; - } else - error->all(FLERR, "Illegal region command"); + } else error->all(FLERR, "Illegal region command argument: {}", arg[iarg]); } // error check diff --git a/src/region_block.cpp b/src/region_block.cpp index 36dad4ce84..76c27fbd55 100644 --- a/src/region_block.cpp +++ b/src/region_block.cpp @@ -80,8 +80,9 @@ RegBlock::RegBlock(LAMMPS *lmp, int narg, char **arg) : Region(lmp, narg, arg) // error check - if (xlo > xhi || ylo > yhi || zlo > zhi) - error->all(FLERR,"Illegal region block command"); + if (xlo > xhi) error->all(FLERR,"Illegal region block xlo: {} >= xhi: {}", xlo, xhi); + if (ylo > yhi) error->all(FLERR,"Illegal region block ylo: {} >= yhi: {}", ylo, yhi); + if (zlo > zhi) error->all(FLERR,"Illegal region block zlo: {} >= zhi: {}", zlo, zhi); // extent of block diff --git a/src/region_cone.cpp b/src/region_cone.cpp index b838154034..84da1bae56 100644 --- a/src/region_cone.cpp +++ b/src/region_cone.cpp @@ -37,11 +37,12 @@ RegCone::RegCone(LAMMPS *lmp, int narg, char **arg) : // check open face settings - if (openflag && (open_faces[3] || open_faces[4] || open_faces[5])) - error->all(FLERR,"Invalid region cone open setting"); + if (openflag) + for (int i=3; i<6; i++) + if (open_faces[i]) error->all(FLERR,"Illegal region cone open face: {}", i+1); - if (strcmp(arg[2],"x") != 0 && strcmp(arg[2],"y") && strcmp(arg[2],"z") != 0) - error->all(FLERR,"Illegal region cylinder command"); + if (strcmp(arg[2],"x") != 0 && strcmp(arg[2],"y") != 0 && strcmp(arg[2],"z") != 0) + error->all(FLERR,"Illegal region cone axis: {}", arg[2]); axis = arg[2][0]; if (axis == 'x') { diff --git a/src/region_cylinder.cpp b/src/region_cylinder.cpp index c37bcb4be0..0f7df1e3af 100644 --- a/src/region_cylinder.cpp +++ b/src/region_cylinder.cpp @@ -37,11 +37,12 @@ RegCylinder::RegCylinder(LAMMPS *lmp, int narg, char **arg) : // check open face settings - if (openflag && (open_faces[3] || open_faces[4] || open_faces[5])) - error->all(FLERR,"Invalid region cylinder open setting"); + if (openflag) + for (int i=3; i<6; i++) + if (open_faces[i]) error->all(FLERR,"Illegal region cylinder open face: {}", i+1); - if (strcmp(arg[2],"x") != 0 && strcmp(arg[2],"y") && strcmp(arg[2],"z") != 0) - error->all(FLERR,"Illegal region cylinder command"); + if (strcmp(arg[2],"x") != 0 && strcmp(arg[2],"y") != 0 && strcmp(arg[2],"z") != 0) + error->all(FLERR,"Illegal region cylinder axis: {}", arg[2]); axis = arg[2][0]; if (axis == 'x') { @@ -170,7 +171,7 @@ RegCylinder::RegCylinder(LAMMPS *lmp, int narg, char **arg) : // error check - if (radius <= 0.0) error->all(FLERR,"Illegal region cylinder command"); + if (radius <= 0.0) error->all(FLERR,"Illegal radius {} in region cylinder command", radius); // extent of cylinder // for variable radius, uses initial radius diff --git a/src/region_ellipsoid.cpp b/src/region_ellipsoid.cpp index 13b9736f5a..ee622aad85 100644 --- a/src/region_ellipsoid.cpp +++ b/src/region_ellipsoid.cpp @@ -101,7 +101,9 @@ RegEllipsoid::RegEllipsoid(LAMMPS *lmp, int narg, char **arg) : // error check - if (a < 0.0 || b < 0.0 || c < 0.0) error->all(FLERR, "Illegal region ellipsoid command"); + if (a < 0.0) error->all(FLERR, "Illegal region ellipsoid a: {}", a); + if (b < 0.0) error->all(FLERR, "Illegal region ellipsoid b: {}", b); + if (c < 0.0) error->all(FLERR, "Illegal region ellipsoid c: {}", c); // extent of ellipsoid // for variable axes, uses initial axes and origin for variable center diff --git a/src/region_intersect.cpp b/src/region_intersect.cpp index 682dd269c0..9dd624e7be 100644 --- a/src/region_intersect.cpp +++ b/src/region_intersect.cpp @@ -27,9 +27,9 @@ RegIntersect::RegIntersect(LAMMPS *lmp, int narg, char **arg) : { nregion = 0; - if (narg < 5) error->all(FLERR, "Illegal region command"); + if (narg < 5) utils::missing_cmd_args(FLERR, "region intersect", error);; int n = utils::inumeric(FLERR, arg[2], false, lmp); - if (n < 2) error->all(FLERR, "Illegal region command"); + if (n < 2) error->all(FLERR, "Illegal region intersect n: {}", n); options(narg - (n + 3), &arg[n + 3]); // build list of regions to intersect diff --git a/src/region_plane.cpp b/src/region_plane.cpp index 2e99e4a0f9..a5163796d0 100644 --- a/src/region_plane.cpp +++ b/src/region_plane.cpp @@ -37,7 +37,7 @@ RegPlane::RegPlane(LAMMPS *lmp, int narg, char **arg) : // enforce unit normal double rsq = normal[0]*normal[0] + normal[1]*normal[1] + normal[2]*normal[2]; - if (rsq == 0.0) error->all(FLERR,"Illegal region plane command"); + if (rsq == 0.0) error->all(FLERR,"Illegal region plane normal vector: {} {} {}", normal[0], normal[1], normal[2]); normal[0] /= sqrt(rsq); normal[1] /= sqrt(rsq); normal[2] /= sqrt(rsq); diff --git a/src/region_prism.cpp b/src/region_prism.cpp index 375bd5ddab..f83da54e34 100644 --- a/src/region_prism.cpp +++ b/src/region_prism.cpp @@ -84,23 +84,24 @@ RegPrism::RegPrism(LAMMPS *lmp, int narg, char **arg) : Region(lmp, narg, arg) // prism cannot be 0 thickness in any dim, else inverse blows up // non-zero tilt values cannot be used if either dim is INF on both ends - if (xlo >= xhi || ylo >= yhi || zlo >= zhi) - error->all(FLERR,"Illegal region prism command"); + if (xlo >= xhi) error->all(FLERR,"Illegal region prism xlo: {} >= xhi: {}", xlo, xhi); + if (ylo >= yhi) error->all(FLERR,"Illegal region prism ylo: {} >= yhi: {}", ylo, yhi); + if (zlo >= zhi) error->all(FLERR,"Illegal region prism zlo: {} >= zhi: {}", zlo ,zhi); if (xy != 0.0 && xlo == -BIG && xhi == BIG) - error->all(FLERR,"Illegal region prism command"); + error->all(FLERR,"Illegal region prism non-zero xy tilt with infinite x size"); if (xy != 0.0 && ylo == -BIG && yhi == BIG) - error->all(FLERR,"Illegal region prism command"); + error->all(FLERR,"Illegal region prism non-zero xy tilt with infinite y size"); if (xz != 0.0 && xlo == -BIG && xhi == BIG) - error->all(FLERR,"Illegal region prism command"); + error->all(FLERR,"Illegal region prism non-zero xz tilt with infinite x size"); if (xz != 0.0 && zlo == -BIG && zhi == BIG) - error->all(FLERR,"Illegal region prism command"); + error->all(FLERR,"Illegal region prism non-zero xz tilt with infinite z size"); if (yz != 0.0 && ylo == -BIG && yhi == BIG) - error->all(FLERR,"Illegal region prism command"); + error->all(FLERR,"Illegal region prism non-zero yz tilt with infinite y size"); if (yz != 0.0 && zlo == -BIG && zhi == BIG) - error->all(FLERR,"Illegal region prism command"); + error->all(FLERR,"Illegal region prism non-zero yz tilt with infinite z size"); // extent of prism diff --git a/src/region_sphere.cpp b/src/region_sphere.cpp index b2c844c986..bbe8400f90 100644 --- a/src/region_sphere.cpp +++ b/src/region_sphere.cpp @@ -79,7 +79,7 @@ RegSphere::RegSphere(LAMMPS *lmp, int narg, char **arg) : // error check - if (radius < 0.0) error->all(FLERR,"Illegal region sphere command"); + if (radius < 0.0) error->all(FLERR,"Illegal region sphere radius: {}", radius); // extent of sphere // for variable radius, uses initial radius and origin for variable center diff --git a/src/region_union.cpp b/src/region_union.cpp index f4b26ade4d..ebd1197d86 100644 --- a/src/region_union.cpp +++ b/src/region_union.cpp @@ -28,9 +28,9 @@ RegUnion::RegUnion(LAMMPS *lmp, int narg, char **arg) : Region(lmp, narg, arg), { nregion = 0; - if (narg < 5) error->all(FLERR, "Illegal region command"); + if (narg < 5) utils::missing_cmd_args(FLERR, "region union", error);; int n = utils::inumeric(FLERR, arg[2], false, lmp); - if (n < 2) error->all(FLERR, "Illegal region command"); + if (n < 2) error->all(FLERR, "Illegal region union n: {}", n); options(narg - (n + 3), &arg[n + 3]); // build list of region indices to union diff --git a/src/thermo.cpp b/src/thermo.cpp index c3cd5adcf5..c4a914e3a3 100644 --- a/src/thermo.cpp +++ b/src/thermo.cpp @@ -498,14 +498,14 @@ bigint Thermo::lost_check() void Thermo::modify_params(int narg, char **arg) { - if (narg == 0) error->all(FLERR, "Illegal thermo_modify command"); + if (narg == 0) utils::missing_cmd_args(FLERR, "thermo_modify", error); modified = 1; int iarg = 0; while (iarg < narg) { if (strcmp(arg[iarg], "temp") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "thermo_modify temp", error); if (index_temp < 0) error->all(FLERR, "Thermo style does not use temp"); delete[] id_compute[index_temp]; id_compute[index_temp] = utils::strdup(arg[iarg + 1]); @@ -540,7 +540,7 @@ void Thermo::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg], "press") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "thermo_modify press", error); if (index_press_scalar < 0 && index_press_vector < 0) error->all(FLERR, "Thermo style does not use press"); @@ -563,7 +563,7 @@ void Thermo::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg], "lost") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "thermo_modify lost", error); if (strcmp(arg[iarg + 1], "ignore") == 0) lostflag = Thermo::IGNORE; else if (strcmp(arg[iarg + 1], "warn") == 0) @@ -571,11 +571,11 @@ void Thermo::modify_params(int narg, char **arg) else if (strcmp(arg[iarg + 1], "error") == 0) lostflag = Thermo::ERROR; else - error->all(FLERR, "Illegal thermo_modify command"); + error->all(FLERR, "Unknown thermo_modify lost argument: {}", arg[iarg + 1]); iarg += 2; } else if (strcmp(arg[iarg], "lost/bond") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "thermo_modify lost/bond", error); if (strcmp(arg[iarg + 1], "ignore") == 0) lostbond = Thermo::IGNORE; else if (strcmp(arg[iarg + 1], "warn") == 0) @@ -583,11 +583,11 @@ void Thermo::modify_params(int narg, char **arg) else if (strcmp(arg[iarg + 1], "error") == 0) lostbond = Thermo::ERROR; else - error->all(FLERR, "Illegal thermo_modify command"); + error->all(FLERR, "Unknown thermo_modify lost/bond argument: {}", arg[iarg + 1]); iarg += 2; } else if (strcmp(arg[iarg], "warn") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "thermo_modify warn", error); if (strcmp(arg[iarg + 1], "ignore") == 0) error->set_maxwarn(-1); else if (strcmp(arg[iarg + 1], "always") == 0) @@ -604,18 +604,18 @@ void Thermo::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg], "norm") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "thermo_modify norm", error); normuserflag = 1; normuser = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg], "flush") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "thermo_modify flush", error); flushflag = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg], "line") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "thermo_modify line", error); if (strcmp(arg[iarg + 1], "one") == 0) lineflag = ONELINE; else if (strcmp(arg[iarg + 1], "multi") == 0) @@ -623,16 +623,16 @@ void Thermo::modify_params(int narg, char **arg) else if (strcmp(arg[iarg + 1], "yaml") == 0) lineflag = YAMLLINE; else - error->all(FLERR, "Illegal thermo_modify command"); + error->all(FLERR, "Unknown thermo_modify line argument: {}", arg[iarg + 1]); iarg += 2; } else if (strcmp(arg[iarg], "colname") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "thermo_modify colname", error); if (strcmp(arg[iarg + 1], "default") == 0) { for (auto item : keyword_user) item.clear(); iarg += 2; } else { - if (iarg + 3 > narg) error->all(FLERR, "Illegal thermo_modify command"); + if (iarg + 3 > narg) utils::missing_cmd_args(FLERR, "thermo_modify colname", error); int icol = -1; if (utils::is_integer(arg[iarg + 1])) { icol = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); @@ -646,12 +646,12 @@ void Thermo::modify_params(int narg, char **arg) } } if ((icol < 0) || (icol >= nfield_initial)) - error->all(FLERR, "Illegal thermo_modify command"); + error->all(FLERR, "Invalid thermo_modify colname argument: {}", arg[iarg + 1]); keyword_user[icol] = arg[iarg + 2]; iarg += 3; } } else if (strcmp(arg[iarg], "format") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "thermo_modify format", error); if (strcmp(arg[iarg + 1], "none") == 0) { format_line_user.clear(); @@ -663,7 +663,7 @@ void Thermo::modify_params(int narg, char **arg) continue; } - if (iarg + 3 > narg) error->all(FLERR, "Illegal thermo_modify command"); + if (iarg + 3 > narg) utils::missing_cmd_args(FLERR, "thermo_modify format", error); if (strcmp(arg[iarg + 1], "line") == 0) { format_line_user = arg[iarg + 2]; @@ -692,13 +692,13 @@ void Thermo::modify_params(int narg, char **arg) } } if (icol < 0 || icol >= nfield_initial + 1) - error->all(FLERR, "Illegal thermo_modify command"); + error->all(FLERR, "Invalid thermo_modify format argument: {}", arg[iarg + 1]); format_column_user[icol] = arg[iarg + 2]; } iarg += 3; } else - error->all(FLERR, "Illegal thermo_modify command"); + error->all(FLERR, "Unknown thermo_modify keyword: {}", arg[iarg]); } } diff --git a/src/velocity.cpp b/src/velocity.cpp index 34b8d5a700..e11317dd09 100644 --- a/src/velocity.cpp +++ b/src/velocity.cpp @@ -49,7 +49,7 @@ Velocity::Velocity(LAMMPS *lmp) : Command(lmp), rigid_fix(nullptr), temperature( void Velocity::command(int narg, char **arg) { - if (narg < 2) error->all(FLERR,"Illegal velocity command"); + if (narg < 2) utils::missing_cmd_args(FLERR, "velocity", error); if (domain->box_exist == 0) error->all(FLERR,"Velocity command before simulation box is defined"); @@ -63,7 +63,7 @@ void Velocity::command(int narg, char **arg) // identify group igroup = group->find(arg[0]); - if (igroup == -1) error->all(FLERR,"Could not find velocity group ID"); + if (igroup == -1) error->all(FLERR, "Could not find velocity group ID {}", arg[0]); groupbit = group->bitmask[igroup]; // check if velocities of atoms in rigid bodies are updated @@ -79,7 +79,7 @@ void Velocity::command(int narg, char **arg) else if (strcmp(arg[1],"scale") == 0) style = SCALE; else if (strcmp(arg[1],"ramp") == 0) style = RAMP; else if (strcmp(arg[1],"zero") == 0) style = ZERO; - else error->all(FLERR,"Illegal velocity command"); + else error->all(FLERR,"Unknown velocity keyword: {}", arg[1]); // set defaults @@ -163,7 +163,7 @@ void Velocity::create(double t_desired, int seed) int i; double **vhold; - if (seed <= 0) error->all(FLERR,"Illegal velocity create command"); + if (seed <= 0) error->all(FLERR, "Illegal velocity create seed argument: {}", seed); // if sum_flag set, store a copy of current velocities @@ -816,58 +816,58 @@ void Velocity::zero_rotation() void Velocity::options(int narg, char **arg) { - if (narg < 0) error->all(FLERR,"Illegal velocity command"); + if (narg < 0) utils::missing_cmd_args(FLERR, "velocity", error); int iarg = 0; while (iarg < narg) { if (strcmp(arg[iarg],"dist") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "velocity dist", error); if (strcmp(arg[iarg+1],"uniform") == 0) dist_flag = UNIFORM; else if (strcmp(arg[iarg+1],"gaussian") == 0) dist_flag = GAUSSIAN; - else error->all(FLERR,"Illegal velocity command"); + else error->all(FLERR,"Unknown velocity dist argument: {}", arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"sum") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "velocity sum", error); sum_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"mom") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "velocity mom", error); momentum_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"rot") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "velocity rot", error); rotation_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"temp") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "velocity temp", error); temperature = modify->get_compute_by_id(arg[iarg+1]); - if (!temperature) error->all(FLERR,"Could not find velocity temperature compute ID"); + if (!temperature) error->all(FLERR,"Could not find velocity temperature compute ID: {}", arg[iarg+1]); if (temperature->tempflag == 0) error->all(FLERR,"Velocity temperature compute {} does not compute temperature", arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"bias") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "velocity bias", error); bias_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"loop") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "velocity loop", error); if (strcmp(arg[iarg+1],"all") == 0) loop_flag = ALL; else if (strcmp(arg[iarg+1],"local") == 0) loop_flag = LOCAL; else if (strcmp(arg[iarg+1],"geom") == 0) loop_flag = GEOM; - else error->all(FLERR,"Illegal velocity command"); + else error->all(FLERR,"Unknown velocity loop argument: {}", arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"rigid") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "velocity rigid", error); rigid_fix = modify->get_fix_by_id(arg[iarg+1]); if (!rigid_fix) error->all(FLERR,"Fix ID {} for velocity does not exist", arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"units") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "velocity units", error); if (strcmp(arg[iarg+1],"box") == 0) scale_flag = 0; else if (strcmp(arg[iarg+1],"lattice") == 0) scale_flag = 1; - else error->all(FLERR,"Illegal velocity command"); + else error->all(FLERR,"Unknown velocity units argument: {}", arg[iarg+1]); iarg += 2; - } else error->all(FLERR,"Illegal velocity command"); + } else error->all(FLERR,"Unknown velocity keyword: {}", arg[iarg]); } // error check diff --git a/tools/vim/README.txt b/tools/vim/README.txt index 29ce1822b8..9f4fdac67e 100644 --- a/tools/vim/README.txt +++ b/tools/vim/README.txt @@ -3,50 +3,50 @@ The files provided in this directory will enable syntax highlighting for the lammps script syntax in vim. The simulation scripts have to -end on *.lmp or start with in.* (see mysyntax.vim). -By far not all commands are included -in the syntax file (lammps.vim). You can easily add new ones. +end on .lmp or .in or start with in. (see mysyntax.vim or filetype.vim). +By far not all commands are included in the syntax file (lammps.vim). +You can easily add new ones. =To enable the highlighting (compatible with old versions of VIM): ============================ -(0) Create a ~/.vimrc +(1) Create a ~/.vimrc You can have a look in /usr/share/vim/vim*/vimrc_example.vim -(1) Insert in ~/.vimrc +(2) Insert in ~/.vimrc let mysyntaxfile = "~/.vim/mysyntax.vim" just before syntax on -(2) Create directory ~/.vim and place mysyntax.vim and lammps.vim there +(3) Create directory ~/.vim and place mysyntax.vim and lammps.vim there =Here is an alternate method for VIM Version 7.2 and later: =========================================================== -(0) Create/edit ~/.vimrc to contain: +(1) Create/edit ~/.vimrc to contain: syntax on -(1) Create directories ~/.vim/syntax and ~/.vim/ftdetect -(2) Copy lammps.vim to ~/.vim/syntax/lammps.vim -(3) Copy filetype.vim to ~/.vim/ftdetect/lammps.vim - - -Gerolf Ziegenhain 2007 +(2) Create directories ~/.vim/syntax and ~/.vim/ftdetect +(3) Copy lammps.vim to ~/.vim/syntax/lammps.vim +(4) Copy filetype.vim to ~/.vim/ftdetect/lammps.vim Distribution Packaging guidelines: ================================== -(0) Copy lammps.vim to ${VIMFILES}/syntax/lammps.vim -(1) Copy filetype.vim as ${VIMFILES}/ftdetect/lammps.vim +(1) Copy lammps.vim to ${VIMFILES}/syntax/lammps.vim +(2) Copy filetype.vim as ${VIMFILES}/ftdetect/lammps.vim ${VIMFILES} is typically /usr/share/vim/vimfiles Consult your packaging guidlines for exact location. +Gerolf Ziegenhain 2007 + +=Disable insertion of characters +======================================== + +(1) The LAMMPS developers strongly discourage writing + files (input and C++ source code) with characters. + To change the default behavior of vim use in your vimrc: + set expandtab + --------------- updated by Sam Bateman, 11/2010 updated by Aidan Thompson, 12/2010 - -Sam Bateman -Naval Research Laboratory -Code 7434 -1005 Balch Blvd. -Stennis Space Center, MS 39529 -Phone: (228) 688-4328 -Email: sam.bateman@nrlssc.navy.mil +updated by Axel Kohlmeyer, 08/2022 diff --git a/tools/vim/filetype.vim b/tools/vim/filetype.vim index 8bc2315144..227a531e8a 100644 --- a/tools/vim/filetype.vim +++ b/tools/vim/filetype.vim @@ -1,4 +1,5 @@ augroup filetypedetect au! BufRead,BufNewFile in.* setfiletype lammps au! BufRead,BufNewFile *.lmp setfiletype lammps + au! BufRead,BufNewFile *.in setfiletype lammps augroup END diff --git a/tools/vim/lammps.vim b/tools/vim/lammps.vim index 69676ba451..a34fa53cbc 100644 --- a/tools/vim/lammps.vim +++ b/tools/vim/lammps.vim @@ -1,64 +1,64 @@ " Vim syntax file -" Language: Lammps Simulation Script File +" Language: Lammps Simulation Script File " Maintainer: Gerolf Ziegenhain -" Updates: Axel Kohlmeyer , Sam Bateman , Daniel Möller Montull -" Latest Revision: 2019-06-11 +" Updates: Axel Kohlmeyer , Sam Bateman , Daniel Möller Montull , Eryk Skalinski +" Latest Revision: 2022-08-17 syn clear -syn keyword lammpsOutput log write_data write_dump info shell write_restart restart dump undump thermo thermo_modify thermo_style print timer -syn keyword lammpsRead include read_restart read_data read_dump molecule -syn keyword lammpsLattice boundary units atom_style lattice region create_box create_atoms dielectric -syn keyword lammpsLattice delete_atoms displace_atoms change_box dimension replicate -syn keyword lammpsParticle pair_coeff pair_style pair_modify pair_write mass velocity angle_coeff angle_style -syn keyword lammpsParticle atom_modify atom_style bond_coeff bond_style bond_write create_bonds delete_bonds kspace_style -syn keyword lammpsParticle kspace_modify dihedral_style dihedral_coeff improper_style improper_coeff -syn keyword lammpsSetup min_style fix_modify run_style timestep neighbor neigh_modify fix unfix suffix special_bonds -syn keyword lammpsSetup balance box clear comm_modify comm_style newton package processors reset_ids reset_timestep -syn keyword lammpsRun minimize run rerun tad neb prd quit server temper temper/grem temper/npt -syn keyword lammpsRun min/spin message hyper dynamical_matrix -syn keyword lammpsDefine variable group compute python set uncompute kim_query +syn keyword lammpsOutput log write_data write_dump info shell write_restart restart dump undump thermo thermo_modify thermo_style print timer +syn keyword lammpsRead include read_restart read_data read_dump molecule +syn keyword lammpsLattice boundary units atom_style lattice region create_box create_atoms dielectric +syn keyword lammpsLattice delete_atoms displace_atoms change_box dimension replicate +syn keyword lammpsParticle pair_coeff pair_style pair_modify pair_write mass velocity angle_coeff angle_style +syn keyword lammpsParticle atom_modify atom_style bond_coeff bond_style bond_write create_bonds delete_bonds kspace_style +syn keyword lammpsParticle kspace_modify dihedral_style dihedral_coeff improper_style improper_coeff +syn keyword lammpsSetup min_style fix_modify run_style timestep neighbor neigh_modify fix unfix suffix special_bonds +syn keyword lammpsSetup balance box clear comm_modify comm_style newton package processors reset_ids reset_timestep +syn keyword lammpsRun minimize run rerun tad neb prd quit server temper temper/grem temper/npt +syn keyword lammpsRun min/spin message hyper dynamical_matrix +syn keyword lammpsDefine variable group compute python set uncompute kim_query -syn keyword lammpsRepeat jump next loop +syn keyword lammpsRepeat jump next loop -syn keyword lammpsOperator equal add sub mult div +syn keyword lammpsOperator equal add sub mult div -syn keyword lammpsConditional if then elif else +syn keyword lammpsConditional if then elif else -syn keyword lammpsSpecial EDGE NULL & +syn keyword lammpsSpecial EDGE NULL & -syn region lammpsString start=+'+ end=+'+ oneline -syn region lammpsString start=+"+ end=+"+ oneline +syn region lammpsString start=+'+ end=+'+ oneline +syn region lammpsString start=+"+ end=+"+ oneline -syn match lammpsNumber "\<[0-9]\+[ij]\=\>" -syn match lammpsFloat "\<[0-9]\+\.[0-9]*\([edED][-+]\=[0-9]\+\)\=[ij]\=\>" -syn match lammpsFloat "\.[0-9]\+\([edED][-+]\=[0-9]\+\)\=[ij]\=\>" -syn match lammpsFloat "\<[0-9]\+[edED][-+]\=[0-9]\+[ij]\=\>" +syn match lammpsNumber "\<[0-9]\+[ij]\=\>" +syn match lammpsFloat "\<[0-9]\+\.[0-9]*\([edED][-+]\=[0-9]\+\)\=[ij]\=\>" +syn match lammpsFloat "\.[0-9]\+\([edED][-+]\=[0-9]\+\)\=[ij]\=\>" +syn match lammpsFloat "\<[0-9]\+[edED][-+]\=[0-9]\+[ij]\=\>" -syn match lammpsComment "#\(.*&\s*\n\)*.*$" +syn match lammpsComment "#\(.*&\s*\n\)*.*$" -syn match lammpsVariable "\$\({[a-zA-Z0-9_]\+}\)" -syn match lammpsVariable "\$[A-Za-z]" +syn match lammpsVariable "\$\({[a-zA-Z0-9_]\+}\)" +syn match lammpsVariable "\$[A-Za-z]" if !exists("did_lammps_syntax_inits") let did_lammps_syntax_inits = 1 - hi link lammpsOutput Function - hi link lammpsRepeat Repeat - hi link lammpsRead Include - hi link lammpsLattice Typedef - hi link lammpsParticle Typedef - hi link lammpsSetup Typedef - hi link lammpsDefine Define - hi link lammpsRun Statement - hi link lammpsNumber Number - hi link lammpsFloat Float - hi link lammpsString String - hi link lammpsComment Comment - hi link lammpsLoop Repeat - hi link lammpsVariable Identifier - hi link lammpsConditional Conditional - hi link lammpsOperator Operator - hi link lammpsSpecial Number + hi def link lammpsOutput Function + hi def link lammpsRepeat Repeat + hi def link lammpsRead Include + hi def link lammpsLattice Typedef + hi def link lammpsParticle Typedef + hi def link lammpsSetup Typedef + hi def link lammpsDefine Define + hi def link lammpsRun Statement + hi def link lammpsNumber Number + hi def link lammpsFloat Float + hi def link lammpsString String + hi def link lammpsComment Comment + hi def link lammpsLoop Repeat + hi def link lammpsVariable Identifier + hi def link lammpsConditional Conditional + hi def link lammpsOperator Operator + hi def link lammpsSpecial Number endif let b:current_syntax = "lammps" diff --git a/tools/vim/mysyntax.vim b/tools/vim/mysyntax.vim index 9fe9071b3a..71b8bf8598 100644 --- a/tools/vim/mysyntax.vim +++ b/tools/vim/mysyntax.vim @@ -1,4 +1,5 @@ augroup syntax au BufNewFile,BufReadPost *.lmp so ~/.vim/lammps.vim au BufNewFile,BufReadPost in.* so ~/.vim/lammps.vim +au BufNewFile,BufReadPost *.in so ~/.vim/lammps.vim augroup END diff --git a/tools/vim/vimrc b/tools/vim/vimrc index 724e077eac..3498b779c6 100644 --- a/tools/vim/vimrc +++ b/tools/vim/vimrc @@ -1,2 +1,4 @@ let mysyntaxfile = "~/.vim/mysyntax.vim" syntax on +" do not create characters +set expandtab diff --git a/unittest/commands/test_groups.cpp b/unittest/commands/test_groups.cpp index b0706ea775..a5c1a50f41 100644 --- a/unittest/commands/test_groups.cpp +++ b/unittest/commands/test_groups.cpp @@ -122,13 +122,13 @@ TEST_F(GroupTest, EmptyDelete) TEST_FAILURE(".*ERROR: Illegal group command.*", command("group new2 delete xxx");); TEST_FAILURE(".*ERROR: Cannot delete group all.*", command("group all delete");); TEST_FAILURE(".*ERROR: Could not find group delete.*", command("group new0 delete");); - TEST_FAILURE(".*ERROR: Cannot delete group currently used by a fix.*", + TEST_FAILURE(".*ERROR: Cannot delete group new2 currently used by fix.*", command("group new2 delete");); - TEST_FAILURE(".*ERROR: Cannot delete group currently used by a compute.*", + TEST_FAILURE(".*ERROR: Cannot delete group new3 currently used by compute.*", command("group new3 delete");); - TEST_FAILURE(".*ERROR: Cannot delete group currently used by a dump.*", + TEST_FAILURE(".*ERROR: Cannot delete group new4 currently used by dump.*", command("group new4 delete");); - TEST_FAILURE(".*ERROR: Cannot delete group currently used by atom_modify.*", + TEST_FAILURE(".*ERROR: Cannot delete group new5 currently used by atom_modify.*", command("group new5 delete");); } diff --git a/unittest/commands/test_regions.cpp b/unittest/commands/test_regions.cpp index 3b614aa6ad..36d251e542 100644 --- a/unittest/commands/test_regions.cpp +++ b/unittest/commands/test_regions.cpp @@ -77,9 +77,10 @@ TEST_F(RegionTest, NoBox) command("region reg6 union 3 reg1 reg2 reg3"); command("region reg7 intersect 3 reg1 reg2 reg4"); command("region reg8 ellipsoid 0 0 0 2 1 2"); + command("region reg9 cylinder y 0 0 1 0 1 open 1 units box"); END_HIDE_OUTPUT(); list = domain->get_region_list(); - EXPECT_EQ(list.size(), 8); + EXPECT_EQ(list.size(), 9); auto reg = domain->get_region_by_id("reg1"); EXPECT_EQ(reg->interior, 1); @@ -161,21 +162,50 @@ TEST_F(RegionTest, NoBox) EXPECT_EQ(reg->rotateflag, 0); EXPECT_EQ(reg->openflag, 0); + reg = domain->get_region_by_id("reg9"); + EXPECT_EQ(reg->interior, 1); + EXPECT_EQ(reg->scaleflag, 0); + EXPECT_EQ(reg->bboxflag, 1); + EXPECT_EQ(reg->varshape, 0); + EXPECT_EQ(reg->dynamic, 0); + EXPECT_EQ(reg->moveflag, 0); + EXPECT_EQ(reg->rotateflag, 0); + EXPECT_EQ(reg->openflag, 1); + BEGIN_HIDE_OUTPUT(); command("region reg3 delete"); command("region reg5 delete"); command("region reg6 delete"); command("region reg1 delete"); + command("region reg9 delete"); END_HIDE_OUTPUT(); list = domain->get_region_list(); EXPECT_EQ(list.size(), 4); reg = domain->get_region_by_id("reg7"); TEST_FAILURE(".*ERROR: Region intersect region reg1 does not exist.*", reg->init();); + TEST_FAILURE(".*ERROR: Delete region reg3 does not exist.*", command("region reg3 delete");); +} + +TEST_F(RegionTest, DeathTests) +{ + atomic_system(); + + auto list = domain->get_region_list(); + ASSERT_EQ(list.size(), 1); + + TEST_FAILURE(".*ERROR: Illegal region block xlo: 1 >= xhi: 0.*", command("region reg1 block 1 0 0 1 0 1");); + TEST_FAILURE(".*ERROR: Illegal region cone open face: 4.*", command("region reg2 cone x 0 0 2 1 0 1 open 4");); + TEST_FAILURE(".*ERROR: Illegal region plane normal vector: 0 0 0.*", command("region reg3 plane 0 0 0 0 0 0 side out");); + TEST_FAILURE(".*ERROR: Illegal region prism non-zero xy tilt with infinite x size.*", command("region reg4 prism INF INF 0 1 0 1 0.1 0.2 0.3");); + TEST_FAILURE(".*ERROR: Illegal region sphere radius: -1.*", command("region reg5 sphere 0 0 0 -1");); + TEST_FAILURE(".*ERROR: Illegal region ellipsoid c: -2.*", command("region reg8 ellipsoid 0 0 0 2 1 -2");); + TEST_FAILURE(".*ERROR: Illegal region cylinder axis: xx.*", command("region reg9 cylinder xx 0 0 1 0 1 open 1 units box");); TEST_FAILURE(".*ERROR: Unrecognized region style 'xxx'.*", command("region new1 xxx");); - TEST_FAILURE(".*ERROR: Illegal region command.*", command("region new1 block 0 1");); - TEST_FAILURE(".*ERROR: Delete region reg3 does not exist.*", command("region reg3 delete");); + //TEST_FAILURE(".*ERROR: Illegal region command.*", command("region new1 block 0 1");); + TEST_FAILURE(".*ERROR: Illegal region command: missing argument\\(s\\).*", command("region new1 block 0 1");); + TEST_FAILURE(".*ERROR: Delete region new3 does not exist.*", command("region new3 delete");); } TEST_F(RegionTest, Counts) diff --git a/unittest/force-styles/tests/fix-timestep-wall_region_harmonic_const.yaml b/unittest/force-styles/tests/fix-timestep-wall_region_harmonic_const.yaml new file mode 100644 index 0000000000..3564dabf02 --- /dev/null +++ b/unittest/force-styles/tests/fix-timestep-wall_region_harmonic_const.yaml @@ -0,0 +1,84 @@ +--- +lammps_version: 3 Aug 2022 +tags: generated +date_generated: Mon Aug 15 01:14:02 2022 +epsilon: 4e-14 +skip_tests: +prerequisites: ! | + atom full + fix wall/region +pre_commands: ! | + boundary f f f +post_commands: ! | + fix move all nve + region box block EDGE EDGE EDGE EDGE EDGE EDGE + fix test solute wall/region box harmonic 0.1 1.0 1.0 + fix_modify test virial yes +input_file: in.fourmol +natoms: 29 +run_stress: ! |2- + 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 +global_scalar: 0 +global_vector: ! |- + 3 0 0 0 +run_pos: ! |2 + 1 -2.7045559775384026e-01 2.4912159905679729e+00 -1.6695851791541885e-01 + 2 3.1004029573899528e-01 2.9612354631094391e+00 -8.5466363037021464e-01 + 3 -7.0398551400789466e-01 1.2305509955830618e+00 -6.2777526944456274e-01 + 4 -1.5818159336499285e+00 1.4837407818929933e+00 -1.2538710836062004e+00 + 5 -9.0719763672789266e-01 9.2652103885675297e-01 3.9954210488374786e-01 + 6 2.4831720524855988e-01 2.8313021497871271e-01 -1.2314233331711453e+00 + 7 3.4143527641386412e-01 -2.2646551041391422e-02 -2.5292291414903052e+00 + 8 1.1743552229100009e+00 -4.8863228565853944e-01 -6.3783432910825522e-01 + 9 1.3800524229500313e+00 -2.5274721030406683e-01 2.8353985887095157e-01 + 10 2.0510765220543883e+00 -1.4604063740302866e+00 -9.8323745081712954e-01 + 11 1.7878031944442556e+00 -1.9921863272948861e+00 -1.8890602447625777e+00 + 12 3.0063007039340053e+00 -4.9013350496963298e-01 -1.6231898107386231e+00 + 13 4.0515402959192999e+00 -8.9202011606653986e-01 -1.6400005529924957e+00 + 14 2.6066963345543819e+00 -4.1789253965514156e-01 -2.6634003608794394e+00 + 15 2.9695287185712913e+00 5.5422613165234036e-01 -1.2342022021790127e+00 + 16 2.6747029695228521e+00 -2.4124119054564295e+00 -2.3435746150616152e-02 + 17 2.2153577785283796e+00 -2.0897985186907717e+00 1.1963150794479436e+00 + 18 2.1369701704094664e+00 3.0158507413593139e+00 -3.5179348337135590e+00 + 19 1.5355837135395243e+00 2.6255292354730009e+00 -4.2353987771401354e+00 + 20 2.7727573003748263e+00 3.6923910441179069e+00 -3.9330842453167185e+00 + 21 4.9040128073837339e+00 -4.0752348170758461e+00 -3.6210314709795299e+00 + 22 4.3582355554510048e+00 -4.2126119427061379e+00 -4.4612844196307497e+00 + 23 5.7439382849366911e+00 -3.5821957939240279e+00 -3.8766361295959513e+00 + 24 2.0689243582454213e+00 3.1513346907303501e+00 3.1550389751128463e+00 + 25 1.3045351331414130e+00 3.2665125705869009e+00 2.5111855257365274e+00 + 26 2.5809237402714267e+00 4.0117602605512728e+00 3.2212060528800821e+00 + 27 -1.9611343130357228e+00 -4.3563411931359752e+00 2.1098293115523705e+00 + 28 -2.7473562684513411e+00 -4.0200819932379330e+00 1.5830052163433954e+00 + 29 -1.3126000191359855e+00 -3.5962518039482929e+00 2.2746342468737835e+00 +run_vel: ! |2 + 1 8.1705744183262832e-03 1.6516406176274298e-02 4.7902264318913212e-03 + 2 5.4501493445687828e-03 5.1791699408496412e-03 -1.4372931530376577e-03 + 3 -8.2298292722385591e-03 -1.2926551614621364e-02 -4.0984181178163734e-03 + 4 -3.7699042590093506e-03 -6.5722892098813894e-03 -1.1184640360133316e-03 + 5 -1.1021961004346575e-02 -9.8906780939336039e-03 -2.8410737829284390e-03 + 6 -3.9676663166400027e-02 4.6817061464710263e-02 3.7148491979476131e-02 + 7 9.1033953013898753e-04 -1.0128524411938794e-02 -5.1568251805019748e-02 + 8 7.9064712058855742e-03 -3.3507254552631585e-03 3.4557098492564643e-02 + 9 1.5644176117320938e-03 3.7365546102722208e-03 1.5047408822037651e-02 + 10 2.9201446820573192e-02 -2.9249578745486140e-02 -1.5018077424322544e-02 + 11 -4.7835961513517542e-03 -3.7481385134185211e-03 -2.3464104142290089e-03 + 12 2.2696451841920672e-03 -3.4774154398129641e-04 -3.0640770327796966e-03 + 13 2.7531740451953164e-03 5.8171061612840502e-03 -7.9467454022160669e-04 + 14 3.5246182371994205e-03 -5.7939995585585538e-03 -3.9478431172751361e-03 + 15 -1.8547943640122950e-03 -5.8554729942777778e-03 6.2938485140538675e-03 + 16 1.8681499973445252e-02 -1.3262466204585332e-02 -4.5638651457003250e-02 + 17 -1.2896269981100378e-02 9.7527665265956451e-03 3.7296535360836762e-02 + 18 -8.0065795274987550e-04 -8.6270473974390637e-04 -1.4483040536385791e-03 + 19 1.2452390067376827e-03 -2.5061097800836321e-03 7.2998639311871857e-03 + 20 3.5930058460518109e-03 3.6938852051849871e-03 3.2322738480194727e-03 + 21 -1.4689219756961610e-03 -2.7352107824530291e-04 7.0581625180892197e-04 + 22 -7.0694199165145105e-03 -4.2577148692717545e-03 2.8079117911323598e-04 + 23 6.0446963236685230e-03 -1.4000131545098772e-03 2.5819754799379716e-03 + 24 3.1926368451268083e-04 -9.9445664487428820e-04 1.4999960207062409e-04 + 25 1.3789752933078488e-04 -4.4335894831520756e-03 -8.1808138106080120e-04 + 26 2.0485904023409989e-03 2.7813358660936129e-03 4.3245726853349256e-03 + 27 4.5604120293369840e-04 -1.0305523026921111e-03 2.1188058381358413e-04 + 28 -6.2544520861855151e-03 1.4127711176146879e-03 -1.8429821884794260e-03 + 29 6.4110631534402174e-04 3.1273432719593824e-03 3.7253671105656736e-03 +... diff --git a/unittest/formats/test_dump_atom.cpp b/unittest/formats/test_dump_atom.cpp index 702325f2fb..762a01e648 100644 --- a/unittest/formats/test_dump_atom.cpp +++ b/unittest/formats/test_dump_atom.cpp @@ -624,7 +624,7 @@ TEST_F(DumpAtomTest, dump_modify_invalid) command("dump id all atom 1 dump.txt"); END_HIDE_OUTPUT(); - TEST_FAILURE(".*Illegal dump_modify command.*", command("dump_modify id true");); + TEST_FAILURE(".*Unknown dump_modify keyword: true.*", command("dump_modify id true");); } TEST_F(DumpAtomTest, write_dump) diff --git a/unittest/formats/test_molecule_file.cpp b/unittest/formats/test_molecule_file.cpp index 17bd30a349..d84aa1c960 100644 --- a/unittest/formats/test_molecule_file.cpp +++ b/unittest/formats/test_molecule_file.cpp @@ -216,6 +216,9 @@ TEST_F(MoleculeFileTest, twomols) auto output = END_CAPTURE_OUTPUT(); ASSERT_THAT(output, ContainsRegex(".*Read molecule template.*\n.*2 molecules.*\n" ".*0 fragments.*\n.*2 atoms with max type 2.*\n.*0 bonds.*")); + ASSERT_EQ(lmp->atom->nmolecule, 1); + auto mols = lmp->atom->get_molecule_by_id(test_name); + ASSERT_EQ(mols.size(), 1); } TEST_F(MoleculeFileTest, twofiles) @@ -231,6 +234,17 @@ TEST_F(MoleculeFileTest, twofiles) ".*Read molecule template twomols:.*\n.*1 molecules.*\n" ".*0 fragments.*\n.*3 atoms with max type 4.*\n.*2 bonds with max type 2.*\n" ".*1 angles with max type 2.*\n.*0 dihedrals.*")); + BEGIN_CAPTURE_OUTPUT(); + command("molecule h2o moltest.h2o.mol"); + command("molecule co2 moltest.co2.mol"); + output = END_CAPTURE_OUTPUT(); + ASSERT_EQ(lmp->atom->nmolecule, 4); + auto mols = lmp->atom->get_molecule_by_id("twomols"); + ASSERT_EQ(mols.size(), 2); + mols = lmp->atom->get_molecule_by_id("h2o"); + ASSERT_EQ(mols.size(), 1); + mols = lmp->atom->get_molecule_by_id("co2"); + ASSERT_EQ(mols.size(), 1); } TEST_F(MoleculeFileTest, bonds)