Skip to content

Commit f0bc9dd

Browse files
authored
Merge pull request lammps#4473 from akohlmey/collected-small-changes
Collected small changes and fixes
2 parents 36e739b + c19389a commit f0bc9dd

28 files changed

+547
-183
lines changed

doc/src/Commands_compute.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ KOKKOS, o = OPENMP, t = OPT.
178178
* :doc:`ti <compute_ti>`
179179
* :doc:`torque/chunk <compute_torque_chunk>`
180180
* :doc:`vacf <compute_vacf>`
181+
* :doc:`vacf/chunk <compute_vacf_chunk>`
181182
* :doc:`vcm/chunk <compute_vcm_chunk>`
182183
* :doc:`viscosity/cos <compute_viscosity_cos>`
183184
* :doc:`voronoi/atom <compute_voronoi_atom>`

doc/src/compute.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ The individual style names on the :doc:`Commands compute <Commands_compute>` pag
356356
* :doc:`ti <compute_ti>` - thermodynamic integration free energy values
357357
* :doc:`torque/chunk <compute_torque_chunk>` - torque applied on each chunk
358358
* :doc:`vacf <compute_vacf>` - velocity auto-correlation function of group of atoms
359+
* :doc:`vacf/chunk <compute_vacf_chunk>` - velocity auto-correlation for the center of mass velocities of chunks of atoms
359360
* :doc:`vcm/chunk <compute_vcm_chunk>` - velocity of center-of-mass for each chunk
360361
* :doc:`viscosity/cos <compute_viscosity_cos>` - velocity profile under cosine-shaped acceleration
361362
* :doc:`voronoi/atom <compute_voronoi_atom>` - Voronoi volume and neighbors for each atom

doc/src/compute_msd.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ Compute *msd* cannot be used with a dynamic group.
116116
Related commands
117117
""""""""""""""""
118118

119-
: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>`
119+
:doc:`compute msd/nongauss <compute_msd_nongauss>`,
120+
:doc:`compute displace_atom <compute_displace_atom>`, :doc:`fix store/state <fix_store_state>`,
121+
:doc:`compute msd/chunk <compute_msd_chunk>`
120122

121123
Default
122124
"""""""

doc/src/compute_msd_chunk.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ Restrictions
131131
Related commands
132132
""""""""""""""""
133133

134-
:doc:`compute msd <compute_msd>`
134+
:doc:`compute msd <compute_msd>`, :doc:`compute vacf/chunk <compute_vacf_chunk>`
135135

136136
Default
137137
"""""""

doc/src/compute_vacf.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Restrictions
7676
Related commands
7777
""""""""""""""""
7878

79-
:doc:`compute msd <compute_msd>`
79+
:doc:`compute msd <compute_msd>`, :doc:`compute vacf/chunk <compute_vacf_chunk>`
8080

8181
Default
8282
"""""""

doc/src/compute_vacf_chunk.rst

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
.. index:: compute vacf/chunk
2+
3+
compute vacf/chunk command
4+
==========================
5+
6+
Syntax
7+
""""""
8+
9+
.. code-block:: LAMMPS
10+
11+
compute ID group-ID vacf/chunk chunkID
12+
13+
* ID, group-ID are documented in :doc:`compute <compute>` command
14+
* vacf/chunk = style name of this compute command
15+
* chunkID = ID of :doc:`compute chunk/atom <compute_chunk_atom>` command
16+
17+
Examples
18+
""""""""
19+
20+
.. code-block:: LAMMPS
21+
22+
compute 1 all vacf/chunk molchunk
23+
24+
Description
25+
"""""""""""
26+
27+
.. versionadded:: TBD
28+
29+
Define a computation that calculates the velocity auto-correlation
30+
function (VACF) for multiple chunks of atoms.
31+
32+
In LAMMPS, chunks are collections of atoms defined by a :doc:`compute
33+
chunk/atom <compute_chunk_atom>` command, which assigns each atom to a
34+
single chunk (or no chunk). The ID for this command is specified as
35+
chunkID. For example, a single chunk could be the atoms in a molecule
36+
or atoms in a spatial bin. See the :doc:`compute chunk/atom
37+
<compute_chunk_atom>` and :doc:`Howto chunk <Howto_chunk>` doc pages for
38+
details of how chunks can be defined and examples of how they can be
39+
used to measure properties of a system.
40+
41+
Four quantities are calculated by this compute for each chunk. The
42+
first 3 quantities are the product of the initial center of mass
43+
velocity (VCM) for each chunk in *x*, *y*, and *z* direction with the
44+
current center of mass velocity in the same direction. The fourth
45+
component is the total VACF, i.e. the sum of the three components.
46+
47+
Note that only atoms in the specified group contribute to the
48+
calculation. The :doc:`compute chunk/atom <compute_chunk_atom>` command
49+
defines its own group; atoms will have a chunk ID = 0 if they are not in
50+
that group, signifying they are not assigned to a chunk, and will thus
51+
also not contribute to this calculation. You can specify the "all"
52+
group for this command if you simply want to include atoms with non-zero
53+
chunk IDs.
54+
55+
The integral of the VACF versus time is proportional to the diffusion
56+
coefficient of the diffusing chunks.
57+
58+
.. note::
59+
60+
The number of chunks *Nchunk* calculated by the
61+
:doc:`compute chunk/atom <compute_chunk_atom>` command must remain constant
62+
each time this compute is invoked, so that the dot product for each chunk
63+
from its original position can be computed consistently. If *Nchunk*
64+
does not remain constant, an error will be generated. If needed, you
65+
can enforce a constant *Nchunk* by using the *nchunk once* or *ids once*
66+
options when specifying the :doc:`compute chunk/atom <compute_chunk_atom>`
67+
command.
68+
69+
.. note::
70+
71+
This compute stores the original center-of-mass velocities of each
72+
chunk. When a VACF is calculated on a later timestep, it is assumed
73+
that the same atoms are assigned to the same chunk ID. However
74+
LAMMPS has no simple way to ensure this is the case, though you can
75+
use the *ids once* option when specifying the :doc:`compute
76+
chunk/atom <compute_chunk_atom>` command. Note that if this is not
77+
the case, the VACF calculation does not have a sensible meaning.
78+
79+
.. note::
80+
81+
If you want the quantities calculated by this compute to be
82+
continuous when running from a :doc:`restart file <read_restart>`, then
83+
you should use the same ID for this compute, as in the original run.
84+
This is so that the fix this compute creates to store per-chunk
85+
quantities will also have the same ID, and thus be initialized
86+
correctly with chunk reference positions from the restart file.
87+
88+
The simplest way to output the results of the compute vacf/chunk
89+
calculation to a file is to use the :doc:`fix ave/time <fix_ave_time>`
90+
command, for example:
91+
92+
.. code-block:: LAMMPS
93+
94+
compute cc1 all chunk/atom molecule
95+
compute myChunk all vacf/chunk cc1
96+
fix 1 all ave/time 100 1 100 c_myChunk[*] file tmp.out mode vector
97+
98+
Output info
99+
"""""""""""
100+
101+
This compute calculates a global array where the number of rows = the
102+
number of chunks *Nchunk* as calculated by the specified :doc:`compute
103+
chunk/atom <compute_chunk_atom>` command. The number of columns = 4 for
104+
the *x*, *y*, *z*, component and the total VACF. These values can be
105+
accessed by any command that uses global array values from a compute as
106+
input. See the :doc:`Howto output <Howto_output>` page for an overview
107+
of LAMMPS output options.
108+
109+
The array values are "intensive". The array values will be in
110+
distance\ :math:`^2` divided by time\ :math:`^2` :doc:`units <units>`.
111+
112+
Restrictions
113+
""""""""""""
114+
none
115+
116+
Related commands
117+
""""""""""""""""
118+
119+
:doc:`compute vacf <compute_vacf>`, :doc:`compute msd/chunk <compute_msd_chunk>`
120+
121+
Default
122+
"""""""
123+
124+
none

python/lammps/core.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from __future__ import print_function
1818

1919
import os
20-
import sys
2120
from ctypes import CDLL, POINTER, RTLD_GLOBAL, CFUNCTYPE, py_object, byref, cast, sizeof, \
2221
create_string_buffer, c_int, c_int32, c_int64, c_double, c_void_p, c_char_p, c_char, \
2322
pythonapi

src/BOCS/compute_pressure_bocs.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ ComputePressureBocs::ComputePressureBocs(LAMMPS *lmp, int narg, char **arg) :
4343
vptr(nullptr), id_temp(nullptr)
4444
{
4545
if (narg < 4) utils::missing_cmd_args(FLERR,"compute pressure/bocs", error);
46-
if (igroup) error->all(FLERR,"Compute pressure/bocs must use group all");
46+
if (igroup) error->all(FLERR, 1, "Compute pressure/bocs must use group all");
4747

4848
scalar_flag = vector_flag = 1;
4949
size_vector = 6;
@@ -64,9 +64,9 @@ ComputePressureBocs::ComputePressureBocs(LAMMPS *lmp, int narg, char **arg) :
6464

6565
temperature = modify->get_compute_by_id(id_temp);
6666
if (!temperature)
67-
error->all(FLERR,"Could not find compute pressure/bocs temperature compute {}", id_temp);
67+
error->all(FLERR, 3, "Could not find compute pressure/bocs temperature compute {}", id_temp);
6868
if (temperature->tempflag == 0)
69-
error->all(FLERR,"Compute pressure/bocs temperature compute {} does not compute "
69+
error->all(FLERR, 3, "Compute pressure/bocs temperature compute {} does not compute "
7070
"temperature", id_temp);
7171
}
7272

@@ -104,8 +104,8 @@ ComputePressureBocs::ComputePressureBocs(LAMMPS *lmp, int narg, char **arg) :
104104
// error check
105105

106106
if (keflag && id_temp == nullptr)
107-
error->all(FLERR,"Compute pressure/bocs requires temperature ID "
108-
"to include kinetic energy");
107+
error->all(FLERR, 3,
108+
"Compute pressure/bocs requires temperature ID to include kinetic energy");
109109

110110
vector = new double[size_vector];
111111
nvirial = 0;
@@ -119,9 +119,9 @@ ComputePressureBocs::ComputePressureBocs(LAMMPS *lmp, int narg, char **arg) :
119119

120120
ComputePressureBocs::~ComputePressureBocs()
121121
{
122-
delete [] id_temp;
123-
delete [] vector;
124-
delete [] vptr;
122+
delete[] id_temp;
123+
delete[] vector;
124+
delete[] vptr;
125125
if (phi_coeff) free(phi_coeff);
126126
}
127127

@@ -139,7 +139,8 @@ void ComputePressureBocs::init()
139139
if (keflag) {
140140
temperature = modify->get_compute_by_id(id_temp);
141141
if (!temperature)
142-
error->all(FLERR,"Could not find compute pressure/bocs temperature compute {}", id_temp);
142+
error->all(FLERR, Error::NOLASTLINE,
143+
"Could not find compute pressure/bocs temperature compute {}", id_temp);
143144
}
144145

145146
// detect contributions to virial
@@ -214,10 +215,10 @@ double ComputePressureBocs::find_index(double * grid, double value)
214215

215216
if (value >= grid[i] && value <= (grid[i] + spacing)) { return i; }
216217

217-
error->all(FLERR,"find_index could not find value in grid for value: {}", value);
218-
for (int i = 0; i < gridsize; ++i)
219-
{
220-
fprintf(stderr, "grid %d: %f\n",i,grid[i]);
218+
error->all(FLERR, Error::NOLASTLINE,
219+
"find_index could not find value in grid for value: {}", value);
220+
for (int i = 0; i < gridsize; ++i) {
221+
fprintf(stderr, "grid %d: %f\n", i, grid[i]);
221222
}
222223

223224
exit(1);
@@ -237,7 +238,7 @@ double ComputePressureBocs::get_cg_p_corr(double ** grid, int basis_type,
237238
return grid[1][i] + (deltax) * ( grid[1][i+1] - grid[1][i] ) / ( grid[0][i+1] - grid[0][i] );
238239
else if (basis_type == BASIS_CUBIC_SPLINE)
239240
return grid[1][i] + (grid[2][i] * deltax) + (grid[3][i] * pow(deltax,2)) + (grid[4][i] * pow(deltax,3));
240-
else error->all(FLERR,"bad spline type passed to get_cg_p_corr()\n");
241+
else error->all(FLERR, Error::NOLASTLINE, "bad spline type passed to get_cg_p_corr()");
241242
return 0.0;
242243
}
243244

@@ -251,7 +252,7 @@ void ComputePressureBocs::send_cg_info(int basis_type, int sent_N_basis,
251252
double sent_vavg)
252253
{
253254
if (basis_type == BASIS_ANALYTIC) p_basis_type = BASIS_ANALYTIC;
254-
else error->all(FLERR,"Incorrect basis type passed to ComputePressureBocs\n");
255+
else error->all(FLERR, Error::NOLASTLINE, "Incorrect basis type passed to ComputePressureBocs");
255256

256257
p_match_flag = 1;
257258

@@ -276,7 +277,7 @@ void ComputePressureBocs::send_cg_info(int basis_type,
276277
else if (basis_type == BASIS_CUBIC_SPLINE) { p_basis_type = BASIS_CUBIC_SPLINE; }
277278
else
278279
{
279-
error->all(FLERR,"Incorrect basis type passed to ComputePressureBocs\n");
280+
error->all(FLERR, Error::NOLASTLINE, "Incorrect basis type passed to ComputePressureBocs");
280281
}
281282
splines = in_splines;
282283
spline_length = gridsize;
@@ -293,7 +294,7 @@ double ComputePressureBocs::compute_scalar()
293294
{
294295
invoked_scalar = update->ntimestep;
295296
if (update->vflag_global != invoked_scalar)
296-
error->all(FLERR,"Virial was not tallied on needed timestep");
297+
error->all(FLERR, Error::NOLASTLINE, "Virial was not tallied on needed timestep");
297298

298299
// invoke temperature if it hasn't been already
299300

@@ -328,9 +329,8 @@ double ComputePressureBocs::compute_scalar()
328329
scalar = (virial[0] + virial[1] + virial[2]) / 3.0 *
329330
inv_volume * nktv2p + (correction);
330331
} else {
331-
if (p_match_flag)
332-
{
333-
error->all(FLERR,"Pressure matching not implemented in 2-d.\n");
332+
if (p_match_flag) {
333+
error->all(FLERR, Error::NOLASTLINE, "Pressure matching not implemented in 2-d.");
334334
exit(1);
335335
} // The rest of this can probably be deleted.
336336
inv_volume = 1.0 / (domain->xprd * domain->yprd);
@@ -354,10 +354,10 @@ void ComputePressureBocs::compute_vector()
354354
{
355355
invoked_vector = update->ntimestep;
356356
if (update->vflag_global != invoked_vector)
357-
error->all(FLERR,"Virial was not tallied on needed timestep");
357+
error->all(FLERR, Error::NOLASTLINE, "Virial was not tallied on needed timestep");
358358

359359
if (force->kspace && kspace_virial && force->kspace->scalar_pressure_flag)
360-
error->all(FLERR,"Must use 'kspace_modify pressure/scalar no' for "
360+
error->all(FLERR, Error::NOLASTLINE, "Must use 'kspace_modify pressure/scalar no' for "
361361
"tensor components with kspace_style msm");
362362

363363
// invoke temperature if it hasn't been already

src/EXTRA-COMMAND/region2vmd.cpp

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -765,85 +765,6 @@ void Region2VMD::write_region(FILE *fp, Region *region)
765765
ellipsoid->c);
766766
}
767767

768-
} else if (regstyle == "plane") {
769-
const auto plane = dynamic_cast<RegPlane *>(region);
770-
if (!plane) {
771-
error->one(FLERR, Error::NOLASTLINE, "Region {} is not of style 'plane'", region->id);
772-
} else {
773-
double v1[3], v2[3], v3[3], v4[3], v5[3], v6[3];
774-
MathExtra::copy3(plane->normal, v1);
775-
MathExtra::norm3(v1);
776-
v2[0] = plane->xp + dx;
777-
v2[1] = plane->yp + dy;
778-
v2[2] = plane->zp + dz;
779-
// determine the largest component of the plane normal and use that to determine the triangle edges
780-
int dim1, dim2, dim3;
781-
if (fabs(v1[0]) > fabs(v1[1])) { // x > y
782-
if (fabs(v1[0]) > fabs(v1[2])) { // x > z => x is largest
783-
dim3 = 0;
784-
dim1 = 1;
785-
dim2 = 2;
786-
} else { // z is largest
787-
dim3 = 2;
788-
dim1 = 0;
789-
dim2 = 1;
790-
}
791-
} else { // x < y
792-
if (fabs(v1[1]) > fabs(v1[2])) { // y > z => y is largest
793-
dim3 = 1;
794-
dim1 = 0;
795-
dim2 = 2;
796-
} else { // z is largest
797-
dim3 = 2;
798-
dim1 = 0;
799-
dim2 = 1;
800-
}
801-
}
802-
803-
MathExtra::scale3(2.0, domain->boxlo, v3);
804-
v3[dim3] = 0.0;
805-
MathExtra::cross3(v1, v3, v4);
806-
MathExtra::add3(v4, v2, v5);
807-
v3[dim1] = domain->boxhi[dim1];
808-
v3[dim2] = domain->boxlo[dim2];
809-
v3[dim3] = 0.0;
810-
MathExtra::scale3(2.0, v3);
811-
MathExtra::cross3(v1, v3, v4);
812-
MathExtra::add3(v4, v2, v6);
813-
utils::print(fp, "draw triangle {{{} {} {}}} {{{} {} {}}} {{{} {} {}}}\n", v2[dim1], v2[dim2],
814-
v2[dim3], v5[dim1], v5[dim2], v5[dim3], v6[dim1], v6[dim2], v6[dim3]);
815-
v3[dim1] = domain->boxlo[dim1];
816-
v3[dim2] = domain->boxhi[dim2];
817-
v3[dim3] = 0.0;
818-
MathExtra::scale3(2.0, v3);
819-
MathExtra::cross3(v1, v3, v4);
820-
MathExtra::add3(v4, v2, v6);
821-
utils::print(fp, "draw triangle {{{} {} {}}} {{{} {} {}}} {{{} {} {}}}\n", v2[dim1], v2[dim2],
822-
v2[dim3], v5[dim1], v5[dim2], v5[dim3], v6[dim1], v6[dim2], v6[dim3]);
823-
v3[dim1] = domain->boxhi[dim1];
824-
v3[dim2] = domain->boxhi[dim2];
825-
v3[dim3] = 0.0;
826-
MathExtra::scale3(2.0, v3);
827-
MathExtra::cross3(v1, v3, v4);
828-
MathExtra::add3(v4, v2, v5);
829-
v3[dim1] = domain->boxhi[dim1];
830-
v3[dim2] = domain->boxlo[dim2];
831-
v3[dim3] = 0.0;
832-
MathExtra::scale3(2.0, v3);
833-
MathExtra::cross3(v1, v3, v4);
834-
MathExtra::add3(v4, v2, v6);
835-
utils::print(fp, "draw triangle {{{} {} {}}} {{{} {} {}}} {{{} {} {}}}\n", v2[dim1], v2[dim2],
836-
v2[dim3], v5[dim1], v5[dim2], v5[dim3], v6[dim1], v6[dim2], v6[dim3]);
837-
v3[dim1] = domain->boxlo[dim1];
838-
v3[dim2] = domain->boxhi[dim2];
839-
v3[dim3] = 0.0;
840-
MathExtra::scale3(2.0, v3);
841-
MathExtra::cross3(v1, v3, v4);
842-
MathExtra::add3(v4, v2, v6);
843-
utils::print(fp, "draw triangle {{{} {} {}}} {{{} {} {}}} {{{} {} {}}}\n", v2[dim1], v2[dim2],
844-
v2[dim3], v5[dim1], v5[dim2], v5[dim3], v6[dim1], v6[dim2], v6[dim3]);
845-
}
846-
847768
} else if (regstyle == "prism") {
848769
const auto prism = dynamic_cast<RegPrism *>(region);
849770
if (!prism) {

0 commit comments

Comments
 (0)