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

Collected small changes and fixes
This commit is contained in:
Axel Kohlmeyer
2025-02-18 12:58:28 -05:00
committed by GitHub
28 changed files with 547 additions and 183 deletions

View File

@ -178,6 +178,7 @@ KOKKOS, o = OPENMP, t = OPT.
* :doc:`ti <compute_ti>`
* :doc:`torque/chunk <compute_torque_chunk>`
* :doc:`vacf <compute_vacf>`
* :doc:`vacf/chunk <compute_vacf_chunk>`
* :doc:`vcm/chunk <compute_vcm_chunk>`
* :doc:`viscosity/cos <compute_viscosity_cos>`
* :doc:`voronoi/atom <compute_voronoi_atom>`

View File

@ -356,6 +356,7 @@ The individual style names on the :doc:`Commands compute <Commands_compute>` pag
* :doc:`ti <compute_ti>` - thermodynamic integration free energy values
* :doc:`torque/chunk <compute_torque_chunk>` - torque applied on each chunk
* :doc:`vacf <compute_vacf>` - velocity auto-correlation function of group of atoms
* :doc:`vacf/chunk <compute_vacf_chunk>` - velocity auto-correlation for the center of mass velocities of chunks of atoms
* :doc:`vcm/chunk <compute_vcm_chunk>` - velocity of center-of-mass for each chunk
* :doc:`viscosity/cos <compute_viscosity_cos>` - velocity profile under cosine-shaped acceleration
* :doc:`voronoi/atom <compute_voronoi_atom>` - Voronoi volume and neighbors for each atom

View File

@ -116,7 +116,9 @@ Compute *msd* cannot be used with a dynamic group.
Related commands
""""""""""""""""
:doc:`compute msd/nongauss <compute_msd_nongauss>`, :doc:`compute displace_atom <compute_displace_atom>`, :doc:`fix store/state <fix_store_state>`, :doc:`compute msd/chunk <compute_msd_chunk>`
:doc:`compute msd/nongauss <compute_msd_nongauss>`,
:doc:`compute displace_atom <compute_displace_atom>`, :doc:`fix store/state <fix_store_state>`,
:doc:`compute msd/chunk <compute_msd_chunk>`
Default
"""""""

View File

@ -131,7 +131,7 @@ Restrictions
Related commands
""""""""""""""""
:doc:`compute msd <compute_msd>`
:doc:`compute msd <compute_msd>`, :doc:`compute vacf/chunk <compute_vacf_chunk>`
Default
"""""""

View File

@ -76,7 +76,7 @@ Restrictions
Related commands
""""""""""""""""
:doc:`compute msd <compute_msd>`
:doc:`compute msd <compute_msd>`, :doc:`compute vacf/chunk <compute_vacf_chunk>`
Default
"""""""

View File

@ -0,0 +1,124 @@
.. index:: compute vacf/chunk
compute vacf/chunk command
==========================
Syntax
""""""
.. code-block:: LAMMPS
compute ID group-ID vacf/chunk chunkID
* ID, group-ID are documented in :doc:`compute <compute>` command
* vacf/chunk = style name of this compute command
* chunkID = ID of :doc:`compute chunk/atom <compute_chunk_atom>` command
Examples
""""""""
.. code-block:: LAMMPS
compute 1 all vacf/chunk molchunk
Description
"""""""""""
.. versionadded:: TBD
Define a computation that calculates the velocity auto-correlation
function (VACF) for multiple chunks of atoms.
In LAMMPS, chunks are collections of atoms defined by a :doc:`compute
chunk/atom <compute_chunk_atom>` command, which assigns each atom to a
single chunk (or no chunk). The ID for this command is specified as
chunkID. For example, a single chunk could be the atoms in a molecule
or atoms in a spatial bin. See the :doc:`compute chunk/atom
<compute_chunk_atom>` and :doc:`Howto chunk <Howto_chunk>` doc pages for
details of how chunks can be defined and examples of how they can be
used to measure properties of a system.
Four quantities are calculated by this compute for each chunk. The
first 3 quantities are the product of the initial center of mass
velocity (VCM) for each chunk in *x*, *y*, and *z* direction with the
current center of mass velocity in the same direction. The fourth
component is the total VACF, i.e. the sum of the three components.
Note that only atoms in the specified group contribute to the
calculation. The :doc:`compute chunk/atom <compute_chunk_atom>` command
defines its own group; atoms will have a chunk ID = 0 if they are not in
that group, signifying they are not assigned to a chunk, and will thus
also not contribute to this calculation. You can specify the "all"
group for this command if you simply want to include atoms with non-zero
chunk IDs.
The integral of the VACF versus time is proportional to the diffusion
coefficient of the diffusing chunks.
.. note::
The number of chunks *Nchunk* calculated by the
:doc:`compute chunk/atom <compute_chunk_atom>` command must remain constant
each time this compute is invoked, so that the dot product for each chunk
from its original position can be computed consistently. If *Nchunk*
does not remain constant, an error will be generated. If needed, you
can enforce a constant *Nchunk* by using the *nchunk once* or *ids once*
options when specifying the :doc:`compute chunk/atom <compute_chunk_atom>`
command.
.. note::
This compute stores the original center-of-mass velocities of each
chunk. When a VACF is calculated on a later timestep, it is assumed
that the same atoms are assigned to the same chunk ID. However
LAMMPS has no simple way to ensure this is the case, though you can
use the *ids once* option when specifying the :doc:`compute
chunk/atom <compute_chunk_atom>` command. Note that if this is not
the case, the VACF calculation does not have a sensible meaning.
.. note::
If you want the quantities calculated by this compute to be
continuous when running from a :doc:`restart file <read_restart>`, then
you should use the same ID for this compute, as in the original run.
This is so that the fix this compute creates to store per-chunk
quantities will also have the same ID, and thus be initialized
correctly with chunk reference positions from the restart file.
The simplest way to output the results of the compute vacf/chunk
calculation to a file is to use the :doc:`fix ave/time <fix_ave_time>`
command, for example:
.. code-block:: LAMMPS
compute cc1 all chunk/atom molecule
compute myChunk all vacf/chunk cc1
fix 1 all ave/time 100 1 100 c_myChunk[*] file tmp.out mode vector
Output info
"""""""""""
This compute calculates a global array where the number of rows = the
number of chunks *Nchunk* as calculated by the specified :doc:`compute
chunk/atom <compute_chunk_atom>` command. The number of columns = 4 for
the *x*, *y*, *z*, component and the total VACF. These values can be
accessed by any command that uses global array values from a compute as
input. See the :doc:`Howto output <Howto_output>` page for an overview
of LAMMPS output options.
The array values are "intensive". The array values will be in
distance\ :math:`^2` divided by time\ :math:`^2` :doc:`units <units>`.
Restrictions
""""""""""""
none
Related commands
""""""""""""""""
:doc:`compute vacf <compute_vacf>`, :doc:`compute msd/chunk <compute_msd_chunk>`
Default
"""""""
none

View File

@ -17,7 +17,6 @@
from __future__ import print_function
import os
import sys
from ctypes import CDLL, POINTER, RTLD_GLOBAL, CFUNCTYPE, py_object, byref, cast, sizeof, \
create_string_buffer, c_int, c_int32, c_int64, c_double, c_void_p, c_char_p, c_char, \
pythonapi

View File

@ -43,7 +43,7 @@ ComputePressureBocs::ComputePressureBocs(LAMMPS *lmp, int narg, char **arg) :
vptr(nullptr), id_temp(nullptr)
{
if (narg < 4) utils::missing_cmd_args(FLERR,"compute pressure/bocs", error);
if (igroup) error->all(FLERR,"Compute pressure/bocs must use group all");
if (igroup) error->all(FLERR, 1, "Compute pressure/bocs must use group all");
scalar_flag = vector_flag = 1;
size_vector = 6;
@ -64,9 +64,9 @@ ComputePressureBocs::ComputePressureBocs(LAMMPS *lmp, int narg, char **arg) :
temperature = modify->get_compute_by_id(id_temp);
if (!temperature)
error->all(FLERR,"Could not find compute pressure/bocs temperature compute {}", id_temp);
error->all(FLERR, 3, "Could not find compute pressure/bocs temperature compute {}", id_temp);
if (temperature->tempflag == 0)
error->all(FLERR,"Compute pressure/bocs temperature compute {} does not compute "
error->all(FLERR, 3, "Compute pressure/bocs temperature compute {} does not compute "
"temperature", id_temp);
}
@ -104,8 +104,8 @@ ComputePressureBocs::ComputePressureBocs(LAMMPS *lmp, int narg, char **arg) :
// error check
if (keflag && id_temp == nullptr)
error->all(FLERR,"Compute pressure/bocs requires temperature ID "
"to include kinetic energy");
error->all(FLERR, 3,
"Compute pressure/bocs requires temperature ID to include kinetic energy");
vector = new double[size_vector];
nvirial = 0;
@ -119,9 +119,9 @@ ComputePressureBocs::ComputePressureBocs(LAMMPS *lmp, int narg, char **arg) :
ComputePressureBocs::~ComputePressureBocs()
{
delete [] id_temp;
delete [] vector;
delete [] vptr;
delete[] id_temp;
delete[] vector;
delete[] vptr;
if (phi_coeff) free(phi_coeff);
}
@ -139,7 +139,8 @@ void ComputePressureBocs::init()
if (keflag) {
temperature = modify->get_compute_by_id(id_temp);
if (!temperature)
error->all(FLERR,"Could not find compute pressure/bocs temperature compute {}", id_temp);
error->all(FLERR, Error::NOLASTLINE,
"Could not find compute pressure/bocs temperature compute {}", id_temp);
}
// detect contributions to virial
@ -214,10 +215,10 @@ double ComputePressureBocs::find_index(double * grid, double value)
if (value >= grid[i] && value <= (grid[i] + spacing)) { return i; }
error->all(FLERR,"find_index could not find value in grid for value: {}", value);
for (int i = 0; i < gridsize; ++i)
{
fprintf(stderr, "grid %d: %f\n",i,grid[i]);
error->all(FLERR, Error::NOLASTLINE,
"find_index could not find value in grid for value: {}", value);
for (int i = 0; i < gridsize; ++i) {
fprintf(stderr, "grid %d: %f\n", i, grid[i]);
}
exit(1);
@ -237,7 +238,7 @@ double ComputePressureBocs::get_cg_p_corr(double ** grid, int basis_type,
return grid[1][i] + (deltax) * ( grid[1][i+1] - grid[1][i] ) / ( grid[0][i+1] - grid[0][i] );
else if (basis_type == BASIS_CUBIC_SPLINE)
return grid[1][i] + (grid[2][i] * deltax) + (grid[3][i] * pow(deltax,2)) + (grid[4][i] * pow(deltax,3));
else error->all(FLERR,"bad spline type passed to get_cg_p_corr()\n");
else error->all(FLERR, Error::NOLASTLINE, "bad spline type passed to get_cg_p_corr()");
return 0.0;
}
@ -251,7 +252,7 @@ void ComputePressureBocs::send_cg_info(int basis_type, int sent_N_basis,
double sent_vavg)
{
if (basis_type == BASIS_ANALYTIC) p_basis_type = BASIS_ANALYTIC;
else error->all(FLERR,"Incorrect basis type passed to ComputePressureBocs\n");
else error->all(FLERR, Error::NOLASTLINE, "Incorrect basis type passed to ComputePressureBocs");
p_match_flag = 1;
@ -276,7 +277,7 @@ void ComputePressureBocs::send_cg_info(int basis_type,
else if (basis_type == BASIS_CUBIC_SPLINE) { p_basis_type = BASIS_CUBIC_SPLINE; }
else
{
error->all(FLERR,"Incorrect basis type passed to ComputePressureBocs\n");
error->all(FLERR, Error::NOLASTLINE, "Incorrect basis type passed to ComputePressureBocs");
}
splines = in_splines;
spline_length = gridsize;
@ -293,7 +294,7 @@ double ComputePressureBocs::compute_scalar()
{
invoked_scalar = update->ntimestep;
if (update->vflag_global != invoked_scalar)
error->all(FLERR,"Virial was not tallied on needed timestep");
error->all(FLERR, Error::NOLASTLINE, "Virial was not tallied on needed timestep");
// invoke temperature if it hasn't been already
@ -328,9 +329,8 @@ double ComputePressureBocs::compute_scalar()
scalar = (virial[0] + virial[1] + virial[2]) / 3.0 *
inv_volume * nktv2p + (correction);
} else {
if (p_match_flag)
{
error->all(FLERR,"Pressure matching not implemented in 2-d.\n");
if (p_match_flag) {
error->all(FLERR, Error::NOLASTLINE, "Pressure matching not implemented in 2-d.");
exit(1);
} // The rest of this can probably be deleted.
inv_volume = 1.0 / (domain->xprd * domain->yprd);
@ -354,10 +354,10 @@ void ComputePressureBocs::compute_vector()
{
invoked_vector = update->ntimestep;
if (update->vflag_global != invoked_vector)
error->all(FLERR,"Virial was not tallied on needed timestep");
error->all(FLERR, Error::NOLASTLINE, "Virial was not tallied on needed timestep");
if (force->kspace && kspace_virial && force->kspace->scalar_pressure_flag)
error->all(FLERR,"Must use 'kspace_modify pressure/scalar no' for "
error->all(FLERR, Error::NOLASTLINE, "Must use 'kspace_modify pressure/scalar no' for "
"tensor components with kspace_style msm");
// invoke temperature if it hasn't been already

View File

@ -765,85 +765,6 @@ void Region2VMD::write_region(FILE *fp, Region *region)
ellipsoid->c);
}
} else if (regstyle == "plane") {
const auto plane = dynamic_cast<RegPlane *>(region);
if (!plane) {
error->one(FLERR, Error::NOLASTLINE, "Region {} is not of style 'plane'", region->id);
} else {
double v1[3], v2[3], v3[3], v4[3], v5[3], v6[3];
MathExtra::copy3(plane->normal, v1);
MathExtra::norm3(v1);
v2[0] = plane->xp + dx;
v2[1] = plane->yp + dy;
v2[2] = plane->zp + dz;
// determine the largest component of the plane normal and use that to determine the triangle edges
int dim1, dim2, dim3;
if (fabs(v1[0]) > fabs(v1[1])) { // x > y
if (fabs(v1[0]) > fabs(v1[2])) { // x > z => x is largest
dim3 = 0;
dim1 = 1;
dim2 = 2;
} else { // z is largest
dim3 = 2;
dim1 = 0;
dim2 = 1;
}
} else { // x < y
if (fabs(v1[1]) > fabs(v1[2])) { // y > z => y is largest
dim3 = 1;
dim1 = 0;
dim2 = 2;
} else { // z is largest
dim3 = 2;
dim1 = 0;
dim2 = 1;
}
}
MathExtra::scale3(2.0, domain->boxlo, v3);
v3[dim3] = 0.0;
MathExtra::cross3(v1, v3, v4);
MathExtra::add3(v4, v2, v5);
v3[dim1] = domain->boxhi[dim1];
v3[dim2] = domain->boxlo[dim2];
v3[dim3] = 0.0;
MathExtra::scale3(2.0, v3);
MathExtra::cross3(v1, v3, v4);
MathExtra::add3(v4, v2, v6);
utils::print(fp, "draw triangle {{{} {} {}}} {{{} {} {}}} {{{} {} {}}}\n", v2[dim1], v2[dim2],
v2[dim3], v5[dim1], v5[dim2], v5[dim3], v6[dim1], v6[dim2], v6[dim3]);
v3[dim1] = domain->boxlo[dim1];
v3[dim2] = domain->boxhi[dim2];
v3[dim3] = 0.0;
MathExtra::scale3(2.0, v3);
MathExtra::cross3(v1, v3, v4);
MathExtra::add3(v4, v2, v6);
utils::print(fp, "draw triangle {{{} {} {}}} {{{} {} {}}} {{{} {} {}}}\n", v2[dim1], v2[dim2],
v2[dim3], v5[dim1], v5[dim2], v5[dim3], v6[dim1], v6[dim2], v6[dim3]);
v3[dim1] = domain->boxhi[dim1];
v3[dim2] = domain->boxhi[dim2];
v3[dim3] = 0.0;
MathExtra::scale3(2.0, v3);
MathExtra::cross3(v1, v3, v4);
MathExtra::add3(v4, v2, v5);
v3[dim1] = domain->boxhi[dim1];
v3[dim2] = domain->boxlo[dim2];
v3[dim3] = 0.0;
MathExtra::scale3(2.0, v3);
MathExtra::cross3(v1, v3, v4);
MathExtra::add3(v4, v2, v6);
utils::print(fp, "draw triangle {{{} {} {}}} {{{} {} {}}} {{{} {} {}}}\n", v2[dim1], v2[dim2],
v2[dim3], v5[dim1], v5[dim2], v5[dim3], v6[dim1], v6[dim2], v6[dim3]);
v3[dim1] = domain->boxlo[dim1];
v3[dim2] = domain->boxhi[dim2];
v3[dim3] = 0.0;
MathExtra::scale3(2.0, v3);
MathExtra::cross3(v1, v3, v4);
MathExtra::add3(v4, v2, v6);
utils::print(fp, "draw triangle {{{} {} {}}} {{{} {} {}}} {{{} {} {}}}\n", v2[dim1], v2[dim2],
v2[dim3], v5[dim1], v5[dim2], v5[dim3], v6[dim1], v6[dim2], v6[dim3]);
}
} else if (regstyle == "prism") {
const auto prism = dynamic_cast<RegPrism *>(region);
if (!prism) {

View File

@ -75,10 +75,10 @@ using namespace LAMMPS_NS;
ComputeHMA::ComputeHMA(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg), id_temp(nullptr), deltaR(nullptr)
{
if (narg < 4) error->all(FLERR,"Illegal compute hma command");
if (igroup) error->all(FLERR,"Compute hma must use group all");
if (narg < 4) utils::missing_cmd_args(FLERR,"compute hma", error);
if (igroup) error->all(FLERR, 1, "Compute hma must use group all");
if (strcmp(arg[3],"NULL") == 0)
error->all(FLERR,"fix ID specifying the set temperature of canonical simulation is required");
error->all(FLERR, 3, "fix ID specifying the set temperature of canonical simulation is required");
else id_temp = utils::strdup(arg[3]);
create_attribute = 1;
@ -139,7 +139,7 @@ ComputeHMA::ComputeHMA(LAMMPS *lmp, int narg, char **arg) :
// the first time we're called, we'll grab lattice pressure and energy
returnAnharmonic = -1;
} else {
error->all(FLERR,"Illegal compute hma command");
error->all(FLERR, iarg, "Unknown compute hma keyword {}", arg[iarg]);
}
}
@ -172,9 +172,9 @@ ComputeHMA::~ComputeHMA()
void ComputeHMA::init() {
if (computeCv>-1) {
if (force->pair == nullptr)
error->all(FLERR,"No pair style is defined for compute hma cv");
error->all(FLERR, Error::NOLASTLINE, "No pair style is defined for compute hma cv");
if (force->pair->single_enable == 0)
error->all(FLERR,"Pair style does not support compute hma cv");
error->all(FLERR, Error::NOLASTLINE, "Pair style does not support compute hma cv");
}
neighbor->add_request(this, NeighConst::REQ_OCCASIONAL);
@ -189,15 +189,19 @@ void ComputeHMA::setup()
{
int dummy=0;
Fix *ifix = modify->get_fix_by_id(id_temp);
if (!ifix) error->all(FLERR,"Could not find compute hma temperature fix ID {}", id_temp);
if (!ifix)
error->all(FLERR, Error::NOLASTLINE, "Could not find compute hma temperature fix ID {}",
id_temp);
auto temperat = (double *) ifix->extract("t_target",dummy);
if (temperat == nullptr) error->all(FLERR,"Fix ID {} is not a thermostat {}", id_temp);
if (temperat == nullptr)
error->all(FLERR, Error::NOLASTLINE, "Fix ID {} is not a thermostat {}", id_temp);
finaltemp = *temperat;
// set fix which stores original atom coords
fix = dynamic_cast<FixStoreAtom *>(modify->get_fix_by_id(id_fix));
if (!fix) error->all(FLERR,"Could not find hma per-atom store fix ID {}", id_fix);
if (!fix)
error->all(FLERR, Error::NOLASTLINE, "Could not find hma per-atom store fix ID {}", id_fix);
}
/* ---------------------------------------------------------------------- */

View File

@ -41,8 +41,8 @@ using namespace FixConst;
FixNumDiffVirial::FixNumDiffVirial(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg), id_pe(nullptr), pe(nullptr), temp_x(nullptr), temp_f(nullptr)
{
if (narg < 5) error->all(FLERR, "Illegal fix numdiff/virial command");
if (igroup) error->all(FLERR, "Compute numdiff/virial must use group all");
if (narg < 5) utils::missing_cmd_args(FLERR, "numdiff/virial", error);
if (igroup) error->all(FLERR, 1, "Compute numdiff/virial must use group all");
peratom_freq = nevery;
respa_level_support = 1;
@ -121,10 +121,12 @@ void FixNumDiffVirial::init()
pe = modify->get_compute_by_id(id_pe);
if (!pe) {
error->all(FLERR, "Potential energy compute ID {} for fix {} does not exist", id_pe, style);
error->all(FLERR, Error::NOLASTLINE, "Potential energy compute ID {} for fix {} does not exist",
id_pe, style);
} else {
if (pe->peflag == 0)
error->all(FLERR, "Compute ID {} for fix {} does not compute potential energy", id_pe, style);
error->all(FLERR, Error::NOLASTLINE,
"Compute ID {} for fix {} does not compute potential energy", id_pe, style);
}
if (force->pair && force->pair->compute_flag)

View File

@ -109,7 +109,7 @@ void NBinKokkos<DeviceType>::bin_atoms()
if (h_resize()) {
atoms_per_bin += 16;
k_bins = DAT::tdual_int_2d("bins", mbins, atoms_per_bin);
k_bins = DAT::tdual_int_2d("Neighbor::bins", mbins, atoms_per_bin);
bins = k_bins.view<DeviceType>();
c_bins = bins;
}

View File

@ -27,7 +27,7 @@ ComputePressureAlchemy::ComputePressureAlchemy(LAMMPS *lmp, int narg, char **arg
Compute(lmp, narg, arg), fix(nullptr)
{
if (narg != 4) error->all(FLERR, "Illegal compute pressure/alchemy command");
if (igroup) error->all(FLERR, "Compute pressure/alchemy must use group all");
if (igroup) error->all(FLERR, 1, "Compute pressure/alchemy must use group all");
scalar_flag = vector_flag = 1;
size_vector = 6;
@ -38,7 +38,8 @@ ComputePressureAlchemy::ComputePressureAlchemy(LAMMPS *lmp, int narg, char **arg
id_fix = arg[3];
if (!modify->get_fix_by_id(id_fix))
error->all(FLERR, "Could not find compute pressure/alchemy fix ID {} for fix alchemy", id_fix);
error->all(FLERR, 3, "Could not find compute pressure/alchemy fix ID {} for fix alchemy",
id_fix);
vector = new double[size_vector];
}
@ -57,11 +58,13 @@ void ComputePressureAlchemy::init()
fix = modify->get_fix_by_id(id_fix);
if (!fix)
error->all(FLERR, "Could not find compute pressure/alchemy fix ID {} for fix alchemy", id_fix);
error->all(FLERR, Error::NOLASTLINE,
"Could not find compute pressure/alchemy fix ID {} for fix alchemy", id_fix);
int dim = 0;
void *ptr = fix->extract("pressure", dim);
if (!ptr || (dim != 1)) error->all(FLERR, "Could not extract pressure from fix alchemy");
if (!ptr || (dim != 1))
error->all(FLERR, Error::NOLASTLINE, "Could not extract pressure from fix alchemy");
}
/* ----------------------------------------------------------------------
@ -72,7 +75,7 @@ double ComputePressureAlchemy::compute_scalar()
{
invoked_scalar = update->ntimestep;
if (update->vflag_global != invoked_scalar)
error->all(FLERR, "Virial was not tallied on needed timestep");
error->all(FLERR, Error::NOLASTLINE, "Virial was not tallied on needed timestep");
compute_vector();
@ -92,11 +95,12 @@ void ComputePressureAlchemy::compute_vector()
{
invoked_vector = update->ntimestep;
if (update->vflag_global != invoked_vector)
error->all(FLERR, "Virial was not tallied on needed timestep");
error->all(FLERR, Error::NOLASTLINE, "Virial was not tallied on needed timestep");
int dim = 0;
double *pressure = (double *) fix->extract("pressure", dim);
if (!pressure || (dim != 1)) error->all(FLERR, "Could not extract pressure from fix alchemy");
if (!pressure || (dim != 1))
error->all(FLERR, Error::NOLASTLINE, "Could not extract pressure from fix alchemy");
for (int i = 0; i < 6; i++) vector[i] = pressure[i];
}

View File

@ -767,7 +767,7 @@ void Atom::init()
if (firstgroupname) {
firstgroup = group->find(firstgroupname);
if (firstgroup < 0)
error->all(FLERR,"Could not find atom_modify first group ID {}", firstgroupname);
error->all(FLERR, Error::NOLASTLINE, "Could not find atom_modify first group ID {}", firstgroupname);
} else firstgroup = -1;
// init AtomVec
@ -830,21 +830,23 @@ void Atom::modify_params(int narg, char **arg)
if (narg == 0) utils::missing_cmd_args(FLERR, "atom_modify", error);
int iarg = 0;
int idx;
while (iarg < narg) {
idx = iarg ? iarg : Error::ARGZERO;
if (strcmp(arg[iarg],"id") == 0) {
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "atom_modify id", error);
if (domain->box_exist)
error->all(FLERR,"Atom_modify id command after simulation box is defined");
error->all(FLERR, idx, "Atom_modify id command after simulation box is defined");
tag_enable = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"map") == 0) {
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "atom_modify map", error);
if (domain->box_exist)
error->all(FLERR,"Atom_modify map command after simulation box is defined");
error->all(FLERR, idx, "Atom_modify map command after simulation box is defined");
if (strcmp(arg[iarg+1],"array") == 0) map_user = MAP_ARRAY;
else if (strcmp(arg[iarg+1],"hash") == 0) map_user = MAP_HASH;
else if (strcmp(arg[iarg+1],"yes") == 0) map_user = MAP_YES;
else error->all(FLERR,"Illegal atom_modify map command argument {}", arg[iarg+1]);
else error->all(FLERR, iarg + 1, "Illegal atom_modify map command argument {}", arg[iarg+1]);
map_style = map_user;
iarg += 2;
} else if (strcmp(arg[iarg],"first") == 0) {
@ -861,12 +863,12 @@ void Atom::modify_params(int narg, char **arg)
if (iarg+3 > narg) utils::missing_cmd_args(FLERR, "atom_modify sort", error);
sortfreq = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
userbinsize = utils::numeric(FLERR,arg[iarg+2],false,lmp);
if (sortfreq < 0) error->all(FLERR,"Illegal atom_modify sort frequency {}", sortfreq);
if (userbinsize < 0.0) error->all(FLERR,"Illegal atom_modify sort bin size {}", userbinsize);
if (sortfreq < 0) error->all(FLERR, iarg + 1, "Illegal atom_modify sort frequency {}", sortfreq);
if (userbinsize < 0.0) error->all(FLERR, iarg + 2, "Illegal atom_modify sort bin size {}", userbinsize);
if ((sortfreq >= 0) && firstgroupname)
error->all(FLERR,"Atom_modify sort and first options cannot be used together");
error->all(FLERR, idx, "Atom_modify sort and first options cannot be used together");
iarg += 3;
} else error->all(FLERR,"Illegal atom_modify command argument: {}", arg[iarg]);
} else error->all(FLERR, idx, "Illegal atom_modify command argument: {}", arg[iarg]);
}
}

View File

@ -41,7 +41,7 @@ Compute::Compute(LAMMPS *lmp, int narg, char **arg) :
{
instance_me = instance_total++;
if (narg < 3) error->all(FLERR,"Illegal compute command");
if (narg < 3) utils::missing_cmd_args(FLERR,"compute", error);
// compute ID, group, and style
// ID must be all alphanumeric chars or underscores

View File

@ -21,6 +21,7 @@
#include "group.h"
#include "memory.h"
#include "modify.h"
#include "update.h"
using namespace LAMMPS_NS;
@ -30,7 +31,7 @@ ComputeMSDChunk::ComputeMSDChunk(LAMMPS *lmp, int narg, char **arg) :
ComputeChunk(lmp, narg, arg), id_fix(nullptr), fix(nullptr), massproc(nullptr),
masstotal(nullptr), com(nullptr), comall(nullptr), msd(nullptr)
{
if (narg != 4) error->all(FLERR, "Illegal compute msd/chunk command");
if (narg != 4) error->all(FLERR, "Incorrect number of arguments for compute msd/chunk");
msdnchunk = 0;
array_flag = 1;
@ -114,6 +115,8 @@ void ComputeMSDChunk::setup()
void ComputeMSDChunk::compute_array()
{
invoked_array = update->ntimestep;
int index;
double massone;
double unwrap[3];
@ -127,7 +130,7 @@ void ComputeMSDChunk::compute_array()
if (firstflag)
msdnchunk = nchunk;
else if (msdnchunk != nchunk)
error->all(FLERR, "Compute msd/chunk nchunk is not static");
error->all(FLERR, Error::NOLASTLINE, "Compute msd/chunk nchunk is not static");
// zero local per-chunk values

View File

@ -35,8 +35,8 @@ using namespace LAMMPS_NS;
ComputePE::ComputePE(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg)
{
if (narg < 3) error->all(FLERR, "Illegal compute pe command");
if (igroup) error->all(FLERR, "Compute pe must use group all");
if (narg < 3) utils::missing_cmd_args(FLERR, "compute pe", error);
if (igroup) error->all(FLERR, 1, "Compute pe must use group all");
scalar_flag = 1;
extscalar = 1;
@ -70,7 +70,7 @@ ComputePE::ComputePE(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg
else if (strcmp(arg[iarg], "fix") == 0)
fixflag = 1;
else
error->all(FLERR, "Illegal compute pe command");
error->all(FLERR, iarg, "Unknown compute pe keyword {}", arg[iarg]);
iarg++;
}
}
@ -85,7 +85,7 @@ double ComputePE::compute_scalar()
{
invoked_scalar = update->ntimestep;
if (update->eflag_global != invoked_scalar)
error->all(FLERR, "Energy was not tallied on needed timestep");
error->all(FLERR, Error::NOLASTLINE, "Energy was not tallied on needed timestep");
double one = 0.0;
if (pairflag && force->pair) one += force->pair->eng_vdwl + force->pair->eng_coul;

View File

@ -40,7 +40,7 @@ ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg), vptr(nullptr), id_temp(nullptr), pstyle(nullptr)
{
if (narg < 4) utils::missing_cmd_args(FLERR,"compute pressure", error);
if (igroup) error->all(FLERR,"Compute pressure must use group all");
if (igroup) error->all(FLERR, 1, "Compute pressure must use group all");
scalar_flag = vector_flag = 1;
size_vector = 6;
@ -58,9 +58,9 @@ ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) :
id_temp = utils::strdup(arg[3]);
auto icompute = modify->get_compute_by_id(id_temp);
if (!icompute)
error->all(FLERR,"Could not find compute pressure temperature ID {}", id_temp);
error->all(FLERR, 3, "Could not find compute pressure temperature ID {}", id_temp);
if (!icompute->tempflag)
error->all(FLERR,"Compute pressure temperature ID {} does not compute temperature", id_temp);
error->all(FLERR, 3, "Compute pressure temperature ID {} does not compute temperature", id_temp);
}
// process optional args

View File

@ -27,7 +27,7 @@ using namespace LAMMPS_NS;
ComputeVACF::ComputeVACF(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg), id_fix(nullptr)
{
if (narg < 3) error->all(FLERR, "Illegal compute vacf command");
if (narg > 3) error->all(FLERR, 3, "Compute vacf does not accept any arguments");
vector_flag = 1;
size_vector = 4;

225
src/compute_vacf_chunk.cpp Normal file
View File

@ -0,0 +1,225 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
LAMMPS development team: developers@lammps.org
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "compute_vacf_chunk.h"
#include "atom.h"
#include "compute_chunk_atom.h"
#include "error.h"
#include "fix_store_global.h"
#include "group.h"
#include "memory.h"
#include "modify.h"
#include "update.h"
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
ComputeVACFChunk::ComputeVACFChunk(LAMMPS *lmp, int narg, char **arg) :
ComputeChunk(lmp, narg, arg), id_fix(nullptr), fix(nullptr), massproc(nullptr),
masstotal(nullptr), vcm(nullptr), vcmall(nullptr), vacf(nullptr)
{
if (narg != 4) error->all(FLERR, "Incorrect number of arguments for compute vacf/chunk");
vacfnchunk = 0;
array_flag = 1;
size_array_cols = 4;
size_array_rows = 0;
size_array_rows_variable = 1;
extarray = 0;
ComputeVACFChunk::init();
// create a new fix STORE style for reference velocities
// id = compute-ID + COMPUTE_STORE, fix group = compute group
// do not know size of array at this point, just allocate 1x1 array
// fix creation must be done now so that a restart run can
// potentially re-populate the fix array (and change it to correct size)
// otherwise size reset and init will be done in setup()
id_fix = utils::strdup(std::string(id) + "_COMPUTE_STORE");
fix = dynamic_cast<FixStoreGlobal *>(
modify->add_fix(fmt::format("{} {} STORE/GLOBAL 1 1", id_fix, group->names[igroup])));
}
/* ---------------------------------------------------------------------- */
ComputeVACFChunk::~ComputeVACFChunk()
{
// check nfix in case all fixes have already been deleted
if (modify->nfix) modify->delete_fix(id_fix);
delete[] id_fix;
memory->destroy(massproc);
memory->destroy(masstotal);
memory->destroy(vcm);
memory->destroy(vcmall);
memory->destroy(vacf);
}
/* ---------------------------------------------------------------------- */
void ComputeVACFChunk::init()
{
ComputeChunk::init();
// set fix which stores reference atom coords
// if firstflag, will be created in setup()
if (!firstflag) {
fix = dynamic_cast<FixStoreGlobal *>(modify->get_fix_by_id(id_fix));
if (!fix) error->all(FLERR, "Could not find compute vacf/chunk fix with ID {}", id_fix);
}
}
/* ----------------------------------------------------------------------
compute initial VCM for each chunk
only once on timestep compute is defined, when firstflag = 1
------------------------------------------------------------------------- */
void ComputeVACFChunk::setup()
{
if (!firstflag) return;
compute_array();
firstflag = 0;
// if fix->astore is already correct size, restart file set it up
// otherwise reset its size now and initialize to current VCM
if (fix->nrow == nchunk && fix->ncol == 3) return;
fix->reset_global(nchunk, 3);
double **vcminit = fix->astore;
for (int i = 0; i < nchunk; i++) {
vcminit[i][0] = vcmall[i][0];
vcminit[i][1] = vcmall[i][1];
vcminit[i][2] = vcmall[i][2];
vacf[i][0] = vacf[i][1] = vacf[i][2] = vacf[i][3] = 1.0;
}
}
/* ---------------------------------------------------------------------- */
void ComputeVACFChunk::compute_array()
{
invoked_array = update->ntimestep;
int index;
double massone;
ComputeChunk::compute_array();
int *ichunk = cchunk->ichunk;
// first time call, allocate per-chunk arrays
// thereafter, require nchunk remain the same
if (firstflag)
vacfnchunk = nchunk;
else if (vacfnchunk != nchunk)
error->all(FLERR, Error::NOLASTLINE, "Compute vacf/chunk nchunk is not static");
// zero local per-chunk values
for (int i = 0; i < nchunk; i++) {
massproc[i] = 0.0;
vcm[i][0] = vcm[i][1] = vcm[i][2] = 0.0;
}
// compute current VCM for each chunk
double **v = atom->v;
int *mask = atom->mask;
int *type = atom->type;
double *mass = atom->mass;
double *rmass = atom->rmass;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
index = ichunk[i] - 1;
if (index < 0) continue;
if (rmass)
massone = rmass[i];
else
massone = mass[type[i]];
massproc[index] += massone;
vcm[index][0] += v[i][0] * massone;
vcm[index][1] += v[i][1] * massone;
vcm[index][2] += v[i][2] * massone;
}
MPI_Allreduce(massproc, masstotal, nchunk, MPI_DOUBLE, MPI_SUM, world);
MPI_Allreduce(&vcm[0][0], &vcmall[0][0], 3 * nchunk, MPI_DOUBLE, MPI_SUM, world);
for (int i = 0; i < nchunk; i++) {
if (masstotal[i] > 0.0) {
vcmall[i][0] /= masstotal[i];
vcmall[i][1] /= masstotal[i];
vcmall[i][2] /= masstotal[i];
}
}
// VACF is dot product between current and initial VCM
// vcminit is initilialized by setup() when firstflag is set
if (firstflag) return;
double vxsq, vysq, vzsq;
double **vcminit = fix->astore;
for (int i = 0; i < nchunk; i++) {
vxsq = vcmall[i][0] * vcminit[i][0];
vysq = vcmall[i][1] * vcminit[i][1];
vzsq = vcmall[i][2] * vcminit[i][2];
vacf[i][0] = vxsq;
vacf[i][1] = vysq;
vacf[i][2] = vzsq;
vacf[i][3] = vxsq + vysq + vzsq;
}
}
/* ----------------------------------------------------------------------
one-time allocate of per-chunk arrays
------------------------------------------------------------------------- */
void ComputeVACFChunk::allocate()
{
ComputeChunk::allocate();
memory->destroy(massproc);
memory->destroy(masstotal);
memory->destroy(vcm);
memory->destroy(vcmall);
memory->destroy(vacf);
memory->create(massproc, nchunk, "vacf/chunk:massproc");
memory->create(masstotal, nchunk, "vacf/chunk:masstotal");
memory->create(vcm, nchunk, 3, "vacf/chunk:vcm");
memory->create(vcmall, nchunk, 3, "vacf/chunk:vcmall");
memory->create(vacf, nchunk, 4, "vacf/chunk:vacf");
array = vacf;
}
/* ----------------------------------------------------------------------
memory usage of local data
------------------------------------------------------------------------- */
double ComputeVACFChunk::memory_usage()
{
double bytes = ComputeChunk::memory_usage();
bytes += (bigint) nchunk * 2 * sizeof(double);
bytes += (double) nchunk * 2 * 3 * sizeof(double);
bytes += (double) nchunk * 4 * sizeof(double);
return bytes;
}

52
src/compute_vacf_chunk.h Normal file
View File

@ -0,0 +1,52 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
LAMMPS development team: developers@lammps.org
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifdef COMPUTE_CLASS
// clang-format off
ComputeStyle(vacf/chunk,ComputeVACFChunk);
// clang-format on
#else
#ifndef LMP_COMPUTE_VACF_CHUNK_H
#define LMP_COMPUTE_VACF_CHUNK_H
#include "compute_chunk.h"
namespace LAMMPS_NS {
class ComputeVACFChunk : public ComputeChunk {
public:
ComputeVACFChunk(class LAMMPS *, int, char **);
~ComputeVACFChunk() override;
void init() override;
void setup() override;
void compute_array() override;
double memory_usage() override;
protected:
bigint vacfnchunk;
char *id_fix;
class FixStoreGlobal *fix;
double *massproc, *masstotal;
double **vcm, **vcmall;
double **vacf;
void allocate() override;
};
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -33,7 +33,7 @@ FixNVE::FixNVE(LAMMPS *lmp, int narg, char **arg) :
auto plain_style = utils::strip_style_suffix(style, lmp);
if (utils::strmatch(plain_style, "^nve$") && narg > 3)
error->all(FLERR, "Unsupported additional arguments for fix {}", style);
error->all(FLERR, 3, "Unsupported additional arguments for fix {}", style);
dynamic_group_allow = 1;
time_integrate = 1;

View File

@ -262,11 +262,13 @@ void Modify::init()
for (i = 0; i < nfix; i++)
if (!fix[i]->dynamic_group_allow && group->dynamic[fix[i]->igroup])
error->all(FLERR, "Fix {} does not allow use with a dynamic group", fix[i]->style);
error->all(FLERR, Error::NOLASTLINE, "Fix {} does not allow use with a dynamic group",
fix[i]->style);
for (i = 0; i < ncompute; i++)
if (!compute[i]->dynamic_group_allow && group->dynamic[compute[i]->igroup])
error->all(FLERR, "Compute {} does not allow use with a dynamic group", compute[i]->style);
error->all(FLERR, Error::NOLASTLINE, "Compute {} does not allow use with a dynamic group",
compute[i]->style);
// warn if any particle is time integrated more than once
@ -834,13 +836,13 @@ Fix *Modify::add_fix(int narg, char **arg, int trysuffix)
for (m = 0; exceptions[m] != nullptr; m++)
if (strcmp(arg[2], exceptions[m]) == 0) break;
if (exceptions[m] == nullptr)
error->all(FLERR, "Fix {} command before simulation box is defined", arg[2]);
error->all(FLERR, 2, "Fix {} command before simulation box is defined", arg[2]);
}
// check group ID
int igroup = group->find(arg[1]);
if (igroup == -1) error->all(FLERR, "Could not find fix group ID {}", arg[1]);
if (igroup == -1) error->all(FLERR, 1, "Could not find fix group ID {}", arg[1]);
// if fix ID exists:
// set newflag = 0 so create new fix in same location in fix list
@ -874,7 +876,7 @@ Fix *Modify::add_fix(int narg, char **arg, int trysuffix)
if (estyle == fix[ifix]->style) match = 1;
}
}
if (!match) error->all(FLERR, "Replacing a fix, but new style != old style");
if (!match) error->all(FLERR, 2, "Replacing a fix, but new style != old style");
if (fix[ifix]->igroup != igroup && comm->me == 0)
error->warning(FLERR, "Replacing a fix, but new group != old group");
@ -921,7 +923,8 @@ Fix *Modify::add_fix(int narg, char **arg, int trysuffix)
fix[ifix] = fix_creator(lmp, narg, arg);
}
if (fix[ifix] == nullptr) error->all(FLERR, utils::check_packages_for_style("fix", arg[2], lmp));
if (fix[ifix] == nullptr)
error->all(FLERR, 2, utils::check_packages_for_style("fix", arg[2], lmp));
// increment nfix and update fix_list vector (if new)
@ -1244,7 +1247,8 @@ Compute *Modify::add_compute(int narg, char **arg, int trysuffix)
// error check
if (get_compute_by_id(arg[0])) error->all(FLERR, "Reuse of compute ID '{}'", arg[0]);
if (get_compute_by_id(arg[0]))
error->all(FLERR, Error::ARGZERO, "Reuse of compute ID '{}'", arg[0]);
// extend Compute list if necessary

View File

@ -392,6 +392,13 @@ void Neighbor::init()
}
cutneighmaxsq = cutneighmax * cutneighmax;
// update cutneighmin based on individual neighbor list requests
for (i = 0; i < nrequest; ++i) {
if (requests[i]->cut) cutneighmin = MIN(cutneighmin, requests[i]->cutoff +
(requests[i]->occasional ? 0.0 : skin));
}
// Define cutoffs for multi
if (style == Neighbor::MULTI) {
int icollection, jcollection;

View File

@ -47,7 +47,7 @@ class Region : protected Pointers {
double delx, dely, delz; // vector from surface pt to particle
double radius; // curvature of region at contact point
int iwall; // unique id of wall for storing shear history
int varflag; // 1 if wall can be variable-controlled
int varflag = 0; // 1 if wall can be variable-controlled
};
Contact *contact; // list of contacts
int cmax; // max # of contacts possible with region

View File

@ -17,7 +17,6 @@
// collection of smart pointers for specific purposes
#include <cstdio>
#include <utility>
namespace LAMMPS_NS {
@ -37,7 +36,7 @@ class SafeFilePtr {
SafeFilePtr(FILE *_fp) : fp(_fp) {};
SafeFilePtr(const SafeFilePtr &) = delete;
SafeFilePtr(SafeFilePtr &&o) noexcept : fp(std::exchange(o.fp, nullptr)) {}
SafeFilePtr(SafeFilePtr &&o) noexcept : fp(o.fp) { o.fp = nullptr; }
SafeFilePtr &operator=(const SafeFilePtr &) = delete;
~SafeFilePtr()

View File

@ -88,7 +88,7 @@ static constexpr char YAML[] = "step temp ke pe ebond eangle edihed eimp evdwl e
#define FORMAT_INT_YAML_DEFAULT "%d"
static constexpr char FORMAT_MULTI_HEADER[] =
"------------ Step {:14} ----- CPU = {:12.7g} (sec) -------------";
"------------ Step {:14} ----- CPU = {:12.7g} (sec) -------------";
enum { SCALAR, VECTOR, ARRAY };
@ -136,7 +136,7 @@ Thermo::Thermo(LAMMPS *_lmp, int narg, char **arg) :
lineflag = YAMLLINE;
} else if (strcmp(style, "custom") == 0) {
if (narg == 1) error->all(FLERR, "Illegal thermo style custom command");
if (narg == 1) error->all(FLERR, Error::ARGZERO, "Illegal thermo style custom command");
// expand args if any have wildcard character "*"
@ -159,7 +159,7 @@ Thermo::Thermo(LAMMPS *_lmp, int narg, char **arg) :
}
} else
error->all(FLERR, "Illegal thermo style command");
error->all(FLERR, Error::ARGZERO, "Illegal thermo style {}", style);
index_temp = index_press_scalar = index_press_vector = index_pe = -1;
@ -297,7 +297,9 @@ void Thermo::init()
for (int i = 0; i < ncompute; i++) {
computes[i] = modify->get_compute_by_id(id_compute[i]);
if (!computes[i]) error->all(FLERR, "Could not find thermo compute with ID {}", id_compute[i]);
if (!computes[i])
error->all(FLERR, Error::NOLASTLINE, "Could not find thermo compute with ID {}",
id_compute[i]);
}
// find current ptr for each Fix ID
@ -305,17 +307,20 @@ void Thermo::init()
for (int i = 0; i < nfix; i++) {
fixes[i] = modify->get_fix_by_id(id_fix[i]);
if (!fixes[i]) error->all(FLERR, "Could not find thermo fix ID {}", id_fix[i]);
if (!fixes[i])
error->all(FLERR, Error::NOLASTLINE, "Could not find thermo fix ID {}", id_fix[i]);
if (output->thermo_every % fixes[i]->global_freq)
error->all(FLERR, "Thermo and fix {} not computed at compatible times", id_fix[i]);
error->all(FLERR, Error::NOLASTLINE, "Thermo and fix {} not computed at compatible times",
id_fix[i]);
}
// find current ptr for each Variable ID
for (int i = 0; i < nvariable; i++) {
variables[i] = input->variable->find(id_variable[i]);
if (variables[i] < 0) error->all(FLERR, "Could not find thermo variable {}", id_variable[i]);
if (variables[i] < 0)
error->all(FLERR, Error::NOLASTLINE, "Could not find thermo variable {}", id_variable[i]);
}
// set ptrs to keyword-specific Compute objects
@ -486,7 +491,7 @@ bigint Thermo::lost_check()
nlocal[0] = atom->nlocal;
nlocal[1] = error->get_numwarn();
MPI_Allreduce(nlocal, ntotal, 2, MPI_LMP_BIGINT, MPI_SUM, world);
if (ntotal[0] < 0) error->all(FLERR, "Too many total atoms");
if (ntotal[0] < 0) error->all(FLERR, Error::NOLASTLINE, "Too many total atoms");
// print notification, if future warnings will be ignored
bigint maxwarn = error->get_maxwarn();
@ -494,7 +499,8 @@ bigint Thermo::lost_check()
warnbefore = 1;
if (comm->me == 0)
error->message(FLERR,
"WARNING: Too many warnings: {} vs {}. All future warnings will be suppressed",
"WARNING: Too many warnings: {} vs {}. "
"All future warnings will be suppressed",
ntotal[1], maxwarn);
}
error->set_allwarn(MIN(MAXSMALLINT, ntotal[1]));
@ -509,7 +515,8 @@ bigint Thermo::lost_check()
// error message
if (lostflag == Thermo::ERROR)
error->all(FLERR, "Lost atoms: original {} current {}", atom->natoms, ntotal[0]);
error->all(FLERR, Error::NOLASTLINE, "Lost atoms: original {} current {}", atom->natoms,
ntotal[0]);
// warning message
@ -537,16 +544,18 @@ void Thermo::modify_params(int narg, char **arg)
while (iarg < narg) {
if (strcmp(arg[iarg], "temp") == 0) {
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");
if (index_temp < 0) error->all(FLERR, iarg + 1, "Thermo style does not use temp");
delete[] id_compute[index_temp];
id_compute[index_temp] = utils::strdup(arg[iarg + 1]);
temperature = modify->get_compute_by_id(arg[iarg + 1]);
if (!temperature)
error->all(FLERR, "Could not find thermo_modify temperature compute {}", arg[iarg + 1]);
error->all(FLERR, iarg + 1, "Could not find thermo_modify temperature compute {}",
arg[iarg + 1]);
if (temperature->tempflag == 0)
error->all(FLERR, "Thermo_modify compute {} does not compute temperature", arg[iarg + 1]);
error->all(FLERR, iarg + 1, "Thermo_modify compute {} does not compute temperature",
arg[iarg + 1]);
if (temperature->igroup != 0 && comm->me == 0)
error->warning(FLERR, "Temperature for thermo pressure is not for group all");
@ -557,12 +566,16 @@ void Thermo::modify_params(int narg, char **arg)
if (index_press_scalar >= 0) {
pcompute = modify->get_compute_by_id(id_compute[index_press_scalar]);
if (!pcompute)
error->all(FLERR, "Pressure compute {} for thermo output does not exist",
error->all(FLERR, Error::NOPOINTER,
"Pressure compute {} for thermo output does "
"not exist",
id_compute[index_press_scalar]);
} else if (index_press_vector >= 0) {
pcompute = modify->get_compute_by_id(id_compute[index_press_vector]);
if (!pcompute)
error->all(FLERR, "Pressure compute {} for thermo output does not exist",
error->all(FLERR, Error::NOPOINTER,
"Pressure compute {} for thermo output does "
"not exist",
id_compute[index_press_vector]);
} else
pcompute = modify->get_compute_by_id("thermo_press");
@ -594,10 +607,10 @@ void Thermo::modify_params(int narg, char **arg)
iarg += 2;
} else if (strcmp(arg[iarg], "triclinic/general") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command");
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "thermo_modify tricinic/general", error);
triclinic_general = utils::logical(FLERR, arg[iarg + 1], false, lmp);
if (triclinic_general && !domain->triclinic_general)
error->all(FLERR,
error->all(FLERR, iarg,
"Thermo_modify triclinic/general cannot be used "
"if simulation box is not general triclinic");
iarg += 2;
@ -611,7 +624,7 @@ void Thermo::modify_params(int narg, char **arg)
else if (strcmp(arg[iarg + 1], "error") == 0)
lostflag = Thermo::ERROR;
else
error->all(FLERR, "Unknown thermo_modify lost argument: {}", arg[iarg + 1]);
error->all(FLERR, iarg + 1, "Unknown thermo_modify lost argument: {}", arg[iarg + 1]);
iarg += 2;
} else if (strcmp(arg[iarg], "lost/bond") == 0) {
@ -623,7 +636,7 @@ void Thermo::modify_params(int narg, char **arg)
else if (strcmp(arg[iarg + 1], "error") == 0)
lostbond = Thermo::ERROR;
else
error->all(FLERR, "Unknown thermo_modify lost/bond argument: {}", arg[iarg + 1]);
error->all(FLERR, iarg + 1, "Unknown thermo_modify lost/bond argument: {}", arg[iarg + 1]);
iarg += 2;
} else if (strcmp(arg[iarg], "warn") == 0) {
@ -663,7 +676,7 @@ void Thermo::modify_params(int narg, char **arg)
else if (strcmp(arg[iarg + 1], "yaml") == 0)
lineflag = YAMLLINE;
else
error->all(FLERR, "Unknown thermo_modify line argument: {}", arg[iarg + 1]);
error->all(FLERR, iarg + 1, "Unknown thermo_modify line argument: {}", arg[iarg + 1]);
iarg += 2;
} else if (strcmp(arg[iarg], "colname") == 0) {
@ -686,7 +699,7 @@ void Thermo::modify_params(int narg, char **arg)
}
}
if ((icol < 0) || (icol >= nfield_initial))
error->all(FLERR, "Invalid thermo_modify colname argument: {}", arg[iarg + 1]);
error->all(FLERR, iarg + 1, "Invalid thermo_modify colname argument: {}", arg[iarg + 1]);
keyword_user[icol] = arg[iarg + 2];
iarg += 3;
}
@ -713,7 +726,8 @@ void Thermo::modify_params(int narg, char **arg)
auto found = format_int_user.find('%');
found = format_int_user.find('d', found);
if (found == std::string::npos)
error->all(FLERR, "Thermo_modify int format does not contain a d conversion character");
error->all(FLERR, iarg + 2,
"Thermo_modify int format does not contain a d conversion character");
format_bigint_user =
format_int_user.replace(found, 1, std::string(BIGINT_FORMAT).substr(1));
} else if (strcmp(arg[iarg + 1], "float") == 0) {
@ -729,7 +743,7 @@ void Thermo::modify_params(int narg, char **arg)
else
icol = i;
if (icol < 0 || (icol >= nfield_initial))
error->all(FLERR, "Invalid thermo_modify format argument: {}", arg[iarg + 1]);
error->all(FLERR, iarg + 1, "Invalid thermo_modify format argument: {}", arg[iarg + 1]);
format_column_user[icol] = arg[iarg + 2];
}
} else {
@ -746,13 +760,13 @@ void Thermo::modify_params(int narg, char **arg)
}
}
if ((icol < 0) || (icol >= nfield_initial))
error->all(FLERR, "Invalid thermo_modify format argument: {}", arg[iarg + 1]);
error->all(FLERR, iarg + 1, "Invalid thermo_modify format argument: {}", arg[iarg + 1]);
format_column_user[icol] = arg[iarg + 2];
}
iarg += 3;
} else
error->all(FLERR, "Unknown thermo_modify keyword: {}", arg[iarg]);
error->all(FLERR, iarg, "Unknown thermo_modify keyword: {}", arg[iarg]);
}
}

View File

@ -234,9 +234,9 @@ std::string utils::point_to_error(Input *input, int failed)
// construct and append error indicator line
cmdline += '\n';
cmdline += std::string(indicator, ' ');
cmdline += std::string(strlen(input->arg[failed]) + quoted, '^');
cmdline += std::string(strlen((failed < 0) ? input->command : input->arg[failed])
+ quoted, '^');
cmdline += '\n';
} else {
cmdline += lastline;
cmdline += '\n';