diff --git a/doc/src/Commands_compute.rst b/doc/src/Commands_compute.rst index 2f9c8b03fb..755000c976 100644 --- a/doc/src/Commands_compute.rst +++ b/doc/src/Commands_compute.rst @@ -46,6 +46,7 @@ KOKKOS, o = OPENMP, t = OPT. * :doc:`com/chunk ` * :doc:`contact/atom ` * :doc:`coord/atom (k) ` + * :doc:`count/type ` * :doc:`damage/atom ` * :doc:`dihedral ` * :doc:`dihedral/local ` diff --git a/doc/src/bond_style.rst b/doc/src/bond_style.rst index b33d0a9e9a..95f463e695 100644 --- a/doc/src/bond_style.rst +++ b/doc/src/bond_style.rst @@ -32,13 +32,13 @@ Set the formula(s) LAMMPS uses to compute bond interactions between pairs of atoms. In LAMMPS, a bond differs from a pairwise interaction, which are set via the :doc:`pair_style ` command. Bonds are defined between specified pairs of atoms and -remain in force for the duration of the simulation (unless the bond -breaks which is possible in some bond potentials). The list of bonded -atoms is read in by a :doc:`read_data ` or -:doc:`read_restart ` command from a data or restart file. -By contrast, pair potentials are typically defined between all pairs -of atoms within a cutoff distance and the set of active interactions -changes over time. +remain in force for the duration of the simulation (unless new bonds +are created or existing bonds break, which is possible in some fixes +and bond potentials). The list of bonded atoms is read in by a +:doc:`read_data ` or :doc:`read_restart ` +command from a data or restart file. By contrast, pair potentials are +typically defined between all pairs of atoms within a cutoff distance +and the set of active interactions changes over time. Hybrid models where bonds are computed using different bond potentials can be setup using the *hybrid* bond style. diff --git a/doc/src/compute.rst b/doc/src/compute.rst index 880f60a8a6..950487cb72 100644 --- a/doc/src/compute.rst +++ b/doc/src/compute.rst @@ -200,6 +200,7 @@ The individual style names on the :doc:`Commands compute ` pag * :doc:`com/chunk ` - center of mass for each chunk * :doc:`contact/atom ` - contact count for each spherical particle * :doc:`coord/atom ` - coordination number for each atom +* :doc:`count/type ` - count of atoms or bonds by type * :doc:`damage/atom ` - Peridynamic damage for each atom * :doc:`dihedral ` - energy of each dihedral sub-style * :doc:`dihedral/local ` - angle of each dihedral diff --git a/doc/src/compute_count_type.rst b/doc/src/compute_count_type.rst new file mode 100644 index 0000000000..17fd9ed784 --- /dev/null +++ b/doc/src/compute_count_type.rst @@ -0,0 +1,89 @@ +.. index:: compute count/type + +compute count/type command +==================== + +Syntax +"""""" + +.. code-block:: LAMMPS + + compute ID group-ID count/type mode + +* ID, group-ID are documented in :doc:`compute ` command +* count/type = style name of this compute command +* mode = {atom} or {bond} + +Examples +"""""""" + +.. code-block:: LAMMPS + + compute 1 all count/type atom + compute 1 flowmols count/type bond + +Description +""""""""""" + +Define a computation that counts the current number of atoms by atom +type or the number of bonds by bond type. The latter can be useful in +reactive simulations where bonds are broken or created. + +Note that for this command, bonds are the topological kind enumerated +in a data file, initially read by the :doc:`read_data ` +command. They do not refer to bonds defined on-the-fly by bond-order +or reactive pair styles. + +These commands can create and break toplogical bonds: + +* :doc:`fix bond/react ` +* :doc:`fix bond/create ` +* :doc:`fix bond/break ` +* :doc:`bond_style quartic ` +* :doc:`BPM package ` bond styles + +If the {mode} setting is {atom} then the count of atoms for each atom +type is tallied. Only atoms in the specified group are counted. + +If the {mode} setting is {bond} then the count of bonds for each bond +type is tallied. Only bonds with both atoms in the specified group +are counted. + +For {mode} = {bond}, broken bonds with a bond type or zero are also +counted. Some commands flag broken bonds by setting their bond type +to zero. See the :doc:`Howto broken bonds ` doc +page for details. Note that the group setting is ignored for broken +bonds; all broken bonds in the system are counted. + +---------- + +Output info +""""""""""" + +This compute calculates a global vector of counts. If the mode is +{atom}, the vector length is the number of atom types. If the mode is +{bond}, the vector length is the number of bond types. + +If the mode is {bond} this compute also calculates a global scalar which +counts the number of broken bonds. + +These values can be used by any command that uses global scalar or +vector values from a compute as input. See the :doc:`Howto output +` page for an overview of LAMMPS output options. + +The scalar and vector values calculated by this compute are "extensive". + +Restrictions +"""""""""""" + +none + +Related commands +"""""""""""""""" + +none + +Default +""""""" + +none diff --git a/src/compute_count_type.cpp b/src/compute_count_type.cpp index 707a4bb943..c3014394d8 100644 --- a/src/compute_count_type.cpp +++ b/src/compute_count_type.cpp @@ -82,6 +82,8 @@ double ComputeCountType::compute_scalar() int nbond; int count = 0; + + // NOTE: respect group setting for (int i = 0; i < nlocal; i++) { nbond = num_bond[i]; @@ -113,6 +115,8 @@ void ComputeCountType::compute_vector() // count atoms by type + // NOTE: respect group setting + if (mode == ATOM) { int *type = atom->type; int nlocal = atom->nlocal; @@ -127,7 +131,9 @@ void ComputeCountType::compute_vector() // count bonds by type // skip type = 0 bonds, they are counted by compute_scalar // bond types can be negative for SHAKE - + + // NOTE: respect group setting + else if (mode == BOND) { int *num_bond = atom->num_bond; int **bond_type = atom->bond_type;