diff --git a/cmake/Modules/Packages/KIM.cmake b/cmake/Modules/Packages/KIM.cmake index 83a96d02b8..5482d3071c 100644 --- a/cmake/Modules/Packages/KIM.cmake +++ b/cmake/Modules/Packages/KIM.cmake @@ -69,14 +69,14 @@ if(DOWNLOAD_KIM) BUILD_RPATH "${_rpath_prefix}/kim_build-prefix/lib" ) else() - if(KIM-API_FOUND AND KIM_API_VERSION VERSION_GREATER_EQUAL 2.2.0) + if(KIM-API_FOUND AND KIM-API_VERSION VERSION_GREATER_EQUAL 2.2.0) # For kim-api >= 2.2.0 - find_package(KIM-API ${KIM-API_MIN_VERSION} CONFIG REQUIRED) + find_package(KIM-API 2.2.0 CONFIG REQUIRED) target_link_libraries(lammps PRIVATE KIM-API::kim-api) else() # For kim-api 2.1.3 (consistent with previous version of this file) find_package(PkgConfig REQUIRED) - pkg_check_modules(KIM-API REQUIRED IMPORTED_TARGET libkim-api>=KIM-API_MIN_VERSION) + pkg_check_modules(KIM-API REQUIRED IMPORTED_TARGET libkim-api>=${KIM-API_MIN_VERSION}) target_link_libraries(lammps PRIVATE PkgConfig::KIM-API) endif() endif() diff --git a/doc/src/Python_atoms.rst b/doc/src/Python_atoms.rst index 92b9677d16..be0d4ff800 100644 --- a/doc/src/Python_atoms.rst +++ b/doc/src/Python_atoms.rst @@ -50,7 +50,7 @@ against invalid accesses. **Numpy Methods**: - * :py:meth:`numpy.extract_atom() `: extract a per-atom quantity as numpy array + * :py:meth:`numpy.extract_atom() `: extract a per-atom quantity as numpy array .. tab:: PyLammps/IPyLammps API diff --git a/doc/src/Python_module.rst b/doc/src/Python_module.rst index 59be645cbd..d2564986de 100644 --- a/doc/src/Python_module.rst +++ b/doc/src/Python_module.rst @@ -61,7 +61,7 @@ functions. Below is a detailed documentation of the API. .. autoclass:: lammps.lammps :members: -.. autoclass:: lammps.numpy::numpy_wrapper +.. autoclass:: lammps.numpy_wrapper::numpy_wrapper :members: ---------- @@ -134,8 +134,8 @@ Style Constants to request from computes or fixes. See :cpp:enum:`_LMP_STYLE_CONST` for the equivalent constants in the C library interface. Used in :py:func:`lammps.extract_compute`, :py:func:`lammps.extract_fix`, and their NumPy variants - :py:func:`lammps.numpy.extract_compute() ` and - :py:func:`lammps.numpy.extract_fix() `. + :py:func:`lammps.numpy.extract_compute() ` and + :py:func:`lammps.numpy.extract_fix() `. .. _py_type_constants: @@ -149,8 +149,8 @@ Type Constants to request from computes or fixes. See :cpp:enum:`_LMP_TYPE_CONST` for the equivalent constants in the C library interface. Used in :py:func:`lammps.extract_compute`, :py:func:`lammps.extract_fix`, and their NumPy variants - :py:func:`lammps.numpy.extract_compute() ` and - :py:func:`lammps.numpy.extract_fix() `. + :py:func:`lammps.numpy.extract_compute() ` and + :py:func:`lammps.numpy.extract_fix() `. .. _py_vartype_constants: @@ -170,6 +170,6 @@ Classes representing internal objects :members: :no-undoc-members: -.. autoclass:: lammps.numpy::NumPyNeighList +.. autoclass:: lammps.numpy_wrapper::NumPyNeighList :members: :no-undoc-members: diff --git a/doc/src/Python_neighbor.rst b/doc/src/Python_neighbor.rst index 80651b608f..cba117ad20 100644 --- a/doc/src/Python_neighbor.rst +++ b/doc/src/Python_neighbor.rst @@ -14,5 +14,5 @@ Neighbor list access **NumPy Methods:** -* :py:meth:`lammps.numpy.get_neighlist() `: Get neighbor list for given index, which uses NumPy arrays for its element neighbor arrays -* :py:meth:`lammps.numpy.get_neighlist_element_neighbors() `: Get element in neighbor list and its neighbors (as numpy array) +* :py:meth:`lammps.numpy.get_neighlist() `: Get neighbor list for given index, which uses NumPy arrays for its element neighbor arrays +* :py:meth:`lammps.numpy.get_neighlist_element_neighbors() `: Get element in neighbor list and its neighbors (as numpy array) diff --git a/doc/src/Python_objects.rst b/doc/src/Python_objects.rst index ec29863d38..4c8161b8bd 100644 --- a/doc/src/Python_objects.rst +++ b/doc/src/Python_objects.rst @@ -36,9 +36,9 @@ computes, fixes, or variables in LAMMPS using the :py:mod:`lammps` module. Python subscripting. The values will be zero for atoms not in the specified group. - :py:meth:`lammps.numpy.extract_compute() `, - :py:meth:`lammps.numpy.extract_fix() `, and - :py:meth:`lammps.numpy.extract_variable() ` are + :py:meth:`lammps.numpy.extract_compute() `, + :py:meth:`lammps.numpy.extract_fix() `, and + :py:meth:`lammps.numpy.extract_variable() ` are equivalent NumPy implementations that return NumPy arrays instead of ``ctypes`` pointers. The :py:meth:`lammps.set_variable() ` method sets an @@ -54,9 +54,9 @@ computes, fixes, or variables in LAMMPS using the :py:mod:`lammps` module. **NumPy Methods**: - * :py:meth:`lammps.numpy.extract_compute() `: extract value(s) from a compute, return arrays as numpy arrays - * :py:meth:`lammps.numpy.extract_fix() `: extract value(s) from a fix, return arrays as numpy arrays - * :py:meth:`lammps.numpy.extract_variable() `: extract value(s) from a variable, return arrays as numpy arrays + * :py:meth:`lammps.numpy.extract_compute() `: extract value(s) from a compute, return arrays as numpy arrays + * :py:meth:`lammps.numpy.extract_fix() `: extract value(s) from a fix, return arrays as numpy arrays + * :py:meth:`lammps.numpy.extract_variable() `: extract value(s) from a variable, return arrays as numpy arrays .. tab:: PyLammps/IPyLammps API diff --git a/python/lammps/core.py b/python/lammps/core.py index d1bc7bc138..1a4650c285 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -1612,7 +1612,7 @@ class lammps(object): def get_neighlist(self, idx): """Returns an instance of :class:`NeighList` which wraps access to the neighbor list with the given index - See :py:meth:`lammps.numpy.get_neighlist() ` if you want to use + See :py:meth:`lammps.numpy.get_neighlist() ` if you want to use NumPy arrays instead of ``c_int`` pointers. :param idx: index of neighbor list diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index 3098a1bd67..1ec29efacd 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -1031,23 +1031,28 @@ void FixBondReact::post_integrate() if (finalpartner[i] == 0) continue; j = atom->map(finalpartner[i]); - // if (j < 0 || tag[i] < tag[j]) { - if (tag[i] < tag[j]) { //atom->map(std::min(tag[i],tag[j])) <= nlocal && - if (nattempt[rxnID] == maxattempt) { + if (tag[i] < tag[j]) { + if (nattempt[rxnID] > maxattempt-2) { maxattempt += DELTA; - // third column of 'attempt': bond/react integer ID + // third dim of 'attempt': bond/react integer ID memory->grow(attempt,maxattempt,2,nreacts,"bond/react:attempt"); } // to ensure types remain in same order - // unnecessary now taken from reaction map file if (iatomtype[rxnID] == type[i]) { attempt[nattempt[rxnID]][0][rxnID] = tag[i]; attempt[nattempt[rxnID]][1][rxnID] = finalpartner[i]; + nattempt[rxnID]++; + // add another attempt if initiator atoms are same type + if (iatomtype[rxnID] == jatomtype[rxnID]) { + attempt[nattempt[rxnID]][0][rxnID] = finalpartner[i]; + attempt[nattempt[rxnID]][1][rxnID] = tag[i]; + nattempt[rxnID]++; + } } else { attempt[nattempt[rxnID]][0][rxnID] = finalpartner[i]; attempt[nattempt[rxnID]][1][rxnID] = tag[i]; + nattempt[rxnID]++; } - nattempt[rxnID]++; } } } @@ -2705,7 +2710,7 @@ update molecule IDs, charges, types, special lists and all topology void FixBondReact::update_everything() { - int nlocal; // must be defined after create_atoms + int nlocal = atom->nlocal; // must be redefined after create atoms int *type = atom->type; int **nspecial = atom->nspecial; tagint **special = atom->special; @@ -2717,6 +2722,9 @@ void FixBondReact::update_everything() // used when deleting atoms int ndel,ndelone; int *mark; + int nmark = nlocal; + memory->create(mark,nmark,"bond/react:mark"); + for (int i = 0; i < nmark; i++) mark[i] = 0; tagint *tag = atom->tag; AtomVec *avec = atom->avec; @@ -2778,8 +2786,11 @@ void FixBondReact::update_everything() // mark to-delete atoms nlocal = atom->nlocal; - mark = new int[nlocal]; - for (int i = 0; i < nlocal; i++) mark[i] = 0; + if (nlocal > nmark) { + memory->grow(mark,nlocal,"bond/react:mark"); + for (int i = nmark; i < nlocal; i++) mark[i] = 0; + nmark = nlocal; + } for (int i = 0; i < update_num_mega; i++) { rxnID = update_mega_glove[0][i]; onemol = atom->molecules[unreacted_mol[rxnID]]; @@ -3228,7 +3239,7 @@ void FixBondReact::update_everything() } } } - delete [] mark; + memory->destroy(mark); MPI_Allreduce(&ndelone,&ndel,1,MPI_INT,MPI_SUM,world);