Merge branch 'develop' into region-lookup-refactor
This commit is contained in:
@ -105,8 +105,28 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# silence excessive warnings for new Intel Compilers
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
|
||||
set(CMAKE_TUNE_DEFAULT "-Wno-tautological-constant-compare")
|
||||
endif()
|
||||
|
||||
# silence excessive warnings for PGI/NVHPC compilers
|
||||
if((CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC") OR (CMAKE_CXX_COMPILER_ID STREQUAL "PGI"))
|
||||
set(CMAKE_TUNE_DEFAULT "-Minform=severe")
|
||||
endif()
|
||||
|
||||
# silence nvcc warnings
|
||||
if((PKG_KOKKOS) AND (Kokkos_ENABLE_CUDA))
|
||||
set(CMAKE_TUNE_DEFAULT "${CMAKE_TUNE_DEFAULT} -Xcudafe --diag_suppress=unrecognized_pragma")
|
||||
endif()
|
||||
|
||||
# we require C++11 without extensions. Kokkos requires at least C++14 (currently)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
if(NOT CMAKE_CXX_STANDARD)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
endif()
|
||||
if(CMAKE_CXX_STANDARD LESS 11)
|
||||
message(FATAL_ERROR "C++ standard must be set to at least 11")
|
||||
endif()
|
||||
if(PKG_KOKKOS AND (CMAKE_CXX_STANDARD LESS 14))
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
endif()
|
||||
@ -468,6 +488,7 @@ set(CMAKE_TUNE_FLAGS "${CMAKE_TUNE_DEFAULT}" CACHE STRING "Compiler and machine
|
||||
separate_arguments(CMAKE_TUNE_FLAGS)
|
||||
foreach(_FLAG ${CMAKE_TUNE_FLAGS})
|
||||
target_compile_options(lammps PRIVATE ${_FLAG})
|
||||
target_compile_options(lmp PRIVATE ${_FLAG})
|
||||
endforeach()
|
||||
########################################################################
|
||||
# Basic system tests (standard libraries, headers, functions, types) #
|
||||
|
||||
@ -7,13 +7,13 @@ if(BUILD_DOC)
|
||||
# Sphinx 3.x requires at least Python 3.5
|
||||
if(CMAKE_VERSION VERSION_LESS 3.12)
|
||||
find_package(PythonInterp 3.5 REQUIRED)
|
||||
set(VIRTUALENV ${PYTHON_EXECUTABLE} -m virtualenv -p ${PYTHON_EXECUTABLE})
|
||||
set(VIRTUALENV ${PYTHON_EXECUTABLE} -m venv)
|
||||
else()
|
||||
find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
||||
if(Python3_VERSION VERSION_LESS 3.5)
|
||||
message(FATAL_ERROR "Python 3.5 and up is required to build the HTML documentation")
|
||||
endif()
|
||||
set(VIRTUALENV ${Python3_EXECUTABLE} -m virtualenv -p ${Python3_EXECUTABLE})
|
||||
set(VIRTUALENV ${Python3_EXECUTABLE} -m venv)
|
||||
endif()
|
||||
find_package(Doxygen 1.8.10 REQUIRED)
|
||||
|
||||
|
||||
@ -19,6 +19,10 @@ endif()
|
||||
|
||||
add_library(colvars STATIC ${COLVARS_SOURCES})
|
||||
target_compile_definitions(colvars PRIVATE -DCOLVARS_LAMMPS)
|
||||
separate_arguments(CMAKE_TUNE_FLAGS)
|
||||
foreach(_FLAG ${CMAKE_TUNE_FLAGS})
|
||||
target_compile_options(colvars PRIVATE ${_FLAG})
|
||||
endforeach()
|
||||
set_target_properties(colvars PROPERTIES OUTPUT_NAME lammps_colvars${LAMMPS_MACHINE})
|
||||
target_include_directories(colvars PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/colvars)
|
||||
# The line below is needed to locate math_eigen_impl.h
|
||||
|
||||
@ -36,3 +36,5 @@ endif()
|
||||
if((CMAKE_CXX_COMPILER_ID STREQUAL "PGI") OR (CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC"))
|
||||
target_compile_definitions(lammps PRIVATE -DEIGEN_DONT_VECTORIZE)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(lammps PRIVATE -DEIGEN_NO_CUDA)
|
||||
|
||||
@ -5,7 +5,5 @@ set(PKG_KOKKOS ON CACHE BOOL "" FORCE)
|
||||
set(Kokkos_ENABLE_SERIAL ON CACHE BOOL "" FORCE)
|
||||
set(Kokkos_ENABLE_OPENMP ON CACHE BOOL "" FORCE)
|
||||
set(Kokkos_ENABLE_CUDA ON CACHE BOOL "" FORCE)
|
||||
set(Kokkos_ARCH_MAXWELL50 on CACHE BOOL "" FORCE)
|
||||
set(Kokkos_ARCH_PASCAL60 ON CACHE BOOL "" FORCE)
|
||||
set(BUILD_OMP ON CACHE BOOL "" FORCE)
|
||||
get_filename_component(NVCC_WRAPPER_CMD ${CMAKE_CURRENT_SOURCE_DIR}/../lib/kokkos/bin/nvcc_wrapper ABSOLUTE)
|
||||
set(CMAKE_CXX_COMPILER ${NVCC_WRAPPER_CMD} CACHE FILEPATH "" FORCE)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
# preset that will enable clang/clang++ with support for MPI and OpenMP (on Linux boxes)
|
||||
# preset that will enable PGI (Nvidia) compilers with support for MPI and OpenMP (on Linux boxes)
|
||||
|
||||
set(CMAKE_CXX_COMPILER "pgc++" CACHE STRING "" FORCE)
|
||||
set(CMAKE_C_COMPILER "pgcc" CACHE STRING "" FORCE)
|
||||
|
||||
2
doc/.gitignore
vendored
2
doc/.gitignore
vendored
@ -1,6 +1,6 @@
|
||||
/old
|
||||
/html
|
||||
/html-offline
|
||||
/fasthtml
|
||||
/epub
|
||||
/latex
|
||||
/mathjax
|
||||
|
||||
51
doc/Makefile
51
doc/Makefile
@ -14,34 +14,22 @@ ANCHORCHECK = $(VENV)/bin/rst_anchor_check
|
||||
SPHINXCONFIG = $(BUILDDIR)/utils/sphinx-config
|
||||
MATHJAX = $(SPHINXCONFIG)/_static/mathjax
|
||||
|
||||
PYTHON = $(shell which python3)
|
||||
DOXYGEN = $(shell which doxygen)
|
||||
VIRTUALENV = virtualenv
|
||||
PYTHON = $(word 3,$(shell type python3))
|
||||
DOXYGEN = $(word 3,$(shell type doxygen))
|
||||
HAS_PYTHON3 = NO
|
||||
HAS_VIRTUALENV = NO
|
||||
HAS_DOXYGEN = NO
|
||||
HAS_PDFLATEX = NO
|
||||
|
||||
ifeq ($(shell which python3 >/dev/null 2>&1; echo $$?), 0)
|
||||
ifeq ($(shell type python3 >/dev/null 2>&1; echo $$?), 0)
|
||||
HAS_PYTHON3 = YES
|
||||
endif
|
||||
|
||||
ifeq ($(shell which doxygen >/dev/null 2>&1; echo $$?), 0)
|
||||
ifeq ($(shell type doxygen >/dev/null 2>&1; echo $$?), 0)
|
||||
HAS_DOXYGEN = YES
|
||||
endif
|
||||
|
||||
ifeq ($(shell which virtualenv-3 >/dev/null 2>&1; echo $$?), 0)
|
||||
VIRTUALENV = virtualenv-3
|
||||
HAS_VIRTUALENV = YES
|
||||
endif
|
||||
|
||||
ifeq ($(shell which virtualenv >/dev/null 2>&1; echo $$?), 0)
|
||||
VIRTUALENV = virtualenv
|
||||
HAS_VIRTUALENV = YES
|
||||
endif
|
||||
|
||||
ifeq ($(shell which pdflatex >/dev/null 2>&1; echo $$?), 0)
|
||||
ifeq ($(shell which latexmk >/dev/null 2>&1; echo $$?), 0)
|
||||
ifeq ($(shell type pdflatex >/dev/null 2>&1; echo $$?), 0)
|
||||
ifeq ($(shell type latexmk >/dev/null 2>&1; echo $$?), 0)
|
||||
HAS_PDFLATEX = YES
|
||||
endif
|
||||
endif
|
||||
@ -58,7 +46,7 @@ SPHINXEXTRA = -E -j $(shell $(PYTHON) -c 'import multiprocessing;print(multiproc
|
||||
# we only want to use explicitly listed files.
|
||||
DOXYFILES = $(shell sed -n -e 's/\#.*$$//' -e '/^ *INPUT \+=/,/^[A-Z_]\+ \+=/p' doxygen/Doxyfile.in | sed -e 's/@LAMMPS_SOURCE_DIR@/..\/src/g' -e 's/\\//g' -e 's/ \+/ /' -e 's/[A-Z_]\+ \+= *\(YES\|NO\|\)//')
|
||||
|
||||
.PHONY: help clean-all clean clean-spelling epub mobi rst html pdf spelling anchor_check style_check char_check xmlgen
|
||||
.PHONY: help clean-all clean clean-spelling epub mobi rst html pdf spelling anchor_check style_check char_check xmlgen fasthtml
|
||||
|
||||
# ------------------------------------------
|
||||
|
||||
@ -70,7 +58,8 @@ help:
|
||||
@echo " epub create ePUB format manual for e-book readers"
|
||||
@echo " mobi convert ePUB to MOBI format manual for e-book readers (e.g. Kindle)"
|
||||
@echo " (requires ebook-convert tool from calibre)"
|
||||
@echo " clean remove all intermediate RST files"
|
||||
@echo " fasthtml approximate HTML page creation in fasthtml dir (for development)"
|
||||
@echo " clean remove all intermediate files"
|
||||
@echo " clean-all reset the entire build environment"
|
||||
@echo " anchor_check scan for duplicate anchor labels"
|
||||
@echo " style_check check for complete and consistent style lists"
|
||||
@ -83,7 +72,7 @@ clean-all: clean
|
||||
rm -rf $(BUILDDIR)/docenv $(MATHJAX) $(BUILDDIR)/LAMMPS.mobi $(BUILDDIR)/LAMMPS.epub $(BUILDDIR)/Manual.pdf
|
||||
|
||||
clean: clean-spelling
|
||||
rm -rf $(BUILDDIR)/html $(BUILDDIR)/epub $(BUILDDIR)/latex $(BUILDDIR)/doctrees $(BUILDDIR)/doxygen/xml $(BUILDDIR)/doxygen-warn.log $(BUILDDIR)/doxygen/Doxyfile $(SPHINXCONFIG)/conf.py
|
||||
rm -rf $(BUILDDIR)/html $(BUILDDIR)/epub $(BUILDDIR)/latex $(BUILDDIR)/doctrees $(BUILDDIR)/doxygen/xml $(BUILDDIR)/doxygen-warn.log $(BUILDDIR)/doxygen/Doxyfile $(SPHINXCONFIG)/conf.py $(BUILDDIR)/fasthtml
|
||||
|
||||
clean-spelling:
|
||||
rm -rf $(BUILDDIR)/spelling
|
||||
@ -118,6 +107,23 @@ html: xmlgen $(VENV) $(SPHINXCONFIG)/conf.py $(ANCHORCHECK) $(MATHJAX)
|
||||
@rm -rf html/PDF/.[sg]*
|
||||
@echo "Build finished. The HTML pages are in doc/html."
|
||||
|
||||
fasthtml: xmlgen $(VENV) $(SPHINXCONFIG)/conf.py $(ANCHORCHECK) $(MATHJAX)
|
||||
@if [ "$(HAS_BASH)" == "NO" ] ; then echo "bash was not found at $(OSHELL)! Please use: $(MAKE) SHELL=/path/to/bash" 1>&2; exit 1; fi
|
||||
@$(MAKE) $(MFLAGS) -C graphviz all
|
||||
@mkdir -p fasthtml
|
||||
@(\
|
||||
. $(VENV)/bin/activate ; env PYTHONWARNINGS= \
|
||||
sphinx-build -j 4 -b html -c $(SPHINXCONFIG) -d $(BUILDDIR)/fasthtml/doctrees $(RSTDIR) fasthtml ;\
|
||||
deactivate ;\
|
||||
)
|
||||
@rm -rf fasthtml/_sources
|
||||
@rm -rf fasthtml/PDF
|
||||
@rm -rf fasthtml/USER
|
||||
@rm -rf fasthtml/JPG
|
||||
@cp -r src/PDF fasthtml/PDF
|
||||
@rm -rf fasthtml/PDF/.[sg]*
|
||||
@echo "Fast HTML build finished. The HTML pages are in doc/fasthtml."
|
||||
|
||||
spelling: xmlgen $(SPHINXCONFIG)/conf.py $(VENV) $(SPHINXCONFIG)/false_positives.txt
|
||||
@if [ "$(HAS_BASH)" == "NO" ] ; then echo "bash was not found at $(OSHELL)! Please use: $(MAKE) SHELL=/path/to/bash" 1>&2; exit 1; fi
|
||||
@(\
|
||||
@ -220,9 +226,8 @@ $(VENV):
|
||||
@if [ "$(HAS_BASH)" == "NO" ] ; then echo "bash was not found at $(OSHELL)! Please use: $(MAKE) SHELL=/path/to/bash" 1>&2; exit 1; fi
|
||||
@if [ "$(HAS_PYTHON3)" == "NO" ] ; then echo "python3 was not found! Please see README for further instructions" 1>&2; exit 1; fi
|
||||
@if [ "$(HAS_DOXYGEN)" == "NO" ] ; then echo "doxygen was not found! Please see README for further instructions" 1>&2; exit 1; fi
|
||||
@if [ "$(HAS_VIRTUALENV)" == "NO" ] ; then echo "virtualenv was not found! Please see README for further instructions" 1>&2; exit 1; fi
|
||||
@( \
|
||||
$(VIRTUALENV) -p $(PYTHON) $(VENV); \
|
||||
$(PYTHON) -m venv $(VENV); \
|
||||
. $(VENV)/bin/activate; \
|
||||
pip $(PIP_OPTIONS) install --upgrade pip; \
|
||||
pip $(PIP_OPTIONS) install -r $(BUILDDIR)/utils/requirements.txt; \
|
||||
|
||||
@ -78,11 +78,12 @@ folder. The following ``make`` commands are available:
|
||||
|
||||
make html # generate HTML in html dir using Sphinx
|
||||
make pdf # generate PDF as Manual.pdf using Sphinx and PDFLaTeX
|
||||
make fetch # fetch HTML pages and PDF files from LAMMPS website
|
||||
# and unpack into the html_www folder and Manual_www.pdf
|
||||
make epub # generate LAMMPS.epub in ePUB format using Sphinx
|
||||
make mobi # generate LAMMPS.mobi in MOBI format using ebook-convert
|
||||
|
||||
make fasthtml # generate approximate HTML in fasthtml dir using Sphinx
|
||||
# some Sphinx extensions do not work correctly with this
|
||||
|
||||
make clean # remove intermediate RST files created by HTML build
|
||||
make clean-all # remove entire build folder and any cached data
|
||||
|
||||
@ -193,8 +194,13 @@ folder need to be updated or new files added. These files are written in
|
||||
`reStructuredText <rst_>`_ markup for translation with the Sphinx tool.
|
||||
|
||||
Before contributing any documentation, please check that both the HTML
|
||||
and the PDF format documentation can translate without errors. Please also
|
||||
check the output to the console for any warnings or problems. There will
|
||||
and the PDF format documentation can translate without errors. During
|
||||
testing the html translation, you may use the ``make fasthtml`` command
|
||||
which does an approximate translation (i.e. not all Sphinx features and
|
||||
extensions will work), but runs very fast because it will only translate
|
||||
files that have been changed since the last ``make fasthtml`` command.
|
||||
|
||||
Please also check the output to the console for any warnings or problems. There will
|
||||
be multiple tests run automatically:
|
||||
|
||||
- A test for correctness of all anchor labels and their references
|
||||
|
||||
@ -152,7 +152,7 @@ OPT.
|
||||
* :doc:`lj/cut/coul/cut/dielectric (o) <pair_dielectric>`
|
||||
* :doc:`lj/cut/coul/cut/soft (o) <pair_fep_soft>`
|
||||
* :doc:`lj/cut/coul/debye (gko) <pair_lj_cut_coul>`
|
||||
* :doc:`lj/cut/coul/debye/dielectric <pair_dielectric>`
|
||||
* :doc:`lj/cut/coul/debye/dielectric (o) <pair_dielectric>`
|
||||
* :doc:`lj/cut/coul/dsf (gko) <pair_lj_cut_coul>`
|
||||
* :doc:`lj/cut/coul/long (gikot) <pair_lj_cut_coul>`
|
||||
* :doc:`lj/cut/coul/long/cs <pair_cs>`
|
||||
|
||||
@ -9,34 +9,34 @@ A new atom style can be created if one of the existing atom styles
|
||||
does not define all the attributes you need to store and communicate
|
||||
with atoms.
|
||||
|
||||
Atom_vec_atomic.cpp is the simplest example of an atom style.
|
||||
The file ``atom_vec_atomic.cpp`` is the simplest example of an atom style.
|
||||
Examining the code for others will make these instructions more clear.
|
||||
|
||||
Note that the :doc:`atom style hybrid <atom_style>` command can be
|
||||
used to define atoms or particles which have the union of properties
|
||||
of individual styles. Also the :doc:`fix property/atom <fix_property_atom>`
|
||||
command can be used to add a single property (e.g. charge
|
||||
or a molecule ID) to a style that does not have it. It can also be
|
||||
used to add custom properties to an atom, with options to communicate
|
||||
them with ghost atoms or read them from a data file. Other LAMMPS
|
||||
commands can access these custom properties, as can new pair, fix,
|
||||
compute styles that are written to work with these properties. For
|
||||
Note that the :doc:`atom style hybrid <atom_style>` command can be used
|
||||
to define atoms or particles which have the union of properties of
|
||||
individual styles. Also the :doc:`fix property/atom
|
||||
<fix_property_atom>` command can be used to add a single property
|
||||
(e.g. charge or a molecule ID) to a style that does not have it. It can
|
||||
also be used to add custom properties to an atom, with options to
|
||||
communicate them with ghost atoms or read them from a data file. Other
|
||||
LAMMPS commands can access these custom properties, as can new pair,
|
||||
fix, compute styles that are written to work with these properties. For
|
||||
example, the :doc:`set <set>` command can be used to set the values of
|
||||
custom per-atom properties from an input script. All of these methods
|
||||
are less work than writing code for a new atom style.
|
||||
are less work than writing and testing(!) code for a new atom style.
|
||||
|
||||
If you follow these directions your new style will automatically work
|
||||
in tandem with others via the :doc:`atom_style hybrid <atom_style>`
|
||||
command.
|
||||
|
||||
The first step is to define a set of strings in the constructor of the
|
||||
new derived class. Each string will have zero or more space-separated
|
||||
variable names which are identical to those used in the atom.h header
|
||||
file for per-atom properties. Note that some represent per-atom
|
||||
The first step is to define a set of string lists in the constructor of
|
||||
the new derived class. Each list will have zero or more comma-separated
|
||||
strings that correspond to the variable names used in the ``atom.h``
|
||||
header file for per-atom properties. Note that some represent per-atom
|
||||
vectors (q, molecule) while other are per-atom arrays (x,v). For all
|
||||
but the last 2 strings you do not need to specify any of
|
||||
but the last two lists you do not need to specify any of
|
||||
(id,type,x,v,f). Those are included automatically as needed in the
|
||||
other strings.
|
||||
other lists.
|
||||
|
||||
.. list-table::
|
||||
|
||||
@ -65,16 +65,16 @@ other strings.
|
||||
* - fields_data_vel
|
||||
- list of properties (in order) in the Velocities section of a data file, as read by :doc:`read_data <read_data>`
|
||||
|
||||
In these strings you can list variable names which LAMMPS already
|
||||
defines (in some other atom style), or you can create new variable
|
||||
names. You should not re-use a LAMMPS variable for something with
|
||||
different meaning in your atom style. If the meaning is related, but
|
||||
interpreted differently by your atom style, then using the same
|
||||
variable name means a user should not use your style and the other
|
||||
style together in a :doc:`atom_style hybrid <atom_style>` command.
|
||||
Because there will only be one value of the variable and different
|
||||
parts of LAMMPS will then likely use it differently. LAMMPS has
|
||||
no way of checking for this.
|
||||
In these lists you can list variable names which LAMMPS already defines
|
||||
(in some other atom style), or you can create new variable names. You
|
||||
should not re-use a LAMMPS variable in your atom style that is used for
|
||||
something with a different meaning in another atom style. If the
|
||||
meaning is related, but interpreted differently by your atom style, then
|
||||
using the same variable name means a user must not use your style and
|
||||
the other style together in a :doc:`atom_style hybrid <atom_style>`
|
||||
command. Because there will only be one value of the variable and
|
||||
different parts of LAMMPS will then likely use it differently. LAMMPS
|
||||
has no way of checking for this.
|
||||
|
||||
If you are defining new variable names then make them descriptive and
|
||||
unique to your new atom style. For example choosing "e" for energy is
|
||||
@ -85,32 +85,31 @@ If any of the variable names in your new atom style do not exist in
|
||||
LAMMPS, you need to add them to the src/atom.h and atom.cpp files.
|
||||
|
||||
Search for the word "customize" or "customization" in these 2 files to
|
||||
see where to add your variable. Adding a flag to the 2nd
|
||||
customization section in atom.h is only necessary if your code (e.g. a
|
||||
pair style) needs to check that a per-atom property is defined. These
|
||||
flags should also be set in the constructor of the atom style child
|
||||
class.
|
||||
see where to add your variable. Adding a flag to the 2nd customization
|
||||
section in ``atom.h`` is only necessary if your code (e.g. a pair style)
|
||||
needs to check that a per-atom property is defined. These flags should
|
||||
also be set in the constructor of the atom style child class.
|
||||
|
||||
In atom.cpp, aside from the constructor and destructor, there are 3
|
||||
In ``atom.cpp``, aside from the constructor and destructor, there are 3
|
||||
methods that a new variable name or flag needs to be added to.
|
||||
|
||||
In Atom::peratom_create() when using the add_peratom() method, a
|
||||
final length argument of 0 is for per-atom vectors, a length > 1 is
|
||||
for per-atom arrays. Note the use of an extra per-thread flag and the
|
||||
add_peratom_vary() method when last dimension of the array is
|
||||
In ``Atom::peratom_create()`` when using the ``Atom::add_peratom()``
|
||||
method, a cols argument of 0 is for per-atom vectors, a length >
|
||||
1 is for per-atom arrays. Note the use of the extra per-thread flag and
|
||||
the add_peratom_vary() method when last dimension of the array is
|
||||
variable-length.
|
||||
|
||||
Adding the variable name to Atom::extract() enable the per-atom data
|
||||
Adding the variable name to Atom::extract() enables the per-atom data
|
||||
to be accessed through the :doc:`LAMMPS library interface
|
||||
<Howto_library>` by a calling code, including from :doc:`Python
|
||||
<Python_head>`.
|
||||
|
||||
The constructor of the new atom style will also typically set a few
|
||||
flags which are defined at the top of atom_vec.h. If these are
|
||||
flags which are defined at the top of ``atom_vec.h``. If these are
|
||||
unclear, see how other atom styles use them.
|
||||
|
||||
The grow_pointers() method is also required to make
|
||||
a copy of peratom data pointers, as explained in the code.
|
||||
The grow_pointers() method is also required to make a copy of peratom
|
||||
data pointers, as explained in the code.
|
||||
|
||||
There are a number of other optional methods which your atom style can
|
||||
implement. These are only needed if you need to do something
|
||||
|
||||
@ -556,8 +556,20 @@ To use this package, also the :ref:`KSPACE <PKG-KSPACE>` and
|
||||
**Supporting info:**
|
||||
|
||||
* src/DIELECTRIC: filenames -> commands
|
||||
* :doc:`atom_style dielectric <atom_style>`
|
||||
* :doc:`pair_style coul/cut/dielectric <pair_dielectric>`
|
||||
* :doc:`pair_style coul/long/dielectric <pair_dielectric>`
|
||||
* :doc:`pair_style lj/cut/coul/cut/dielectric <pair_dielectric>`
|
||||
* :doc:`pair_style lj/cut/coul/debye/dielectric <pair_dielectric>`
|
||||
* :doc:`pair_style lj/cut/coul/long/dielectric <pair_dielectric>`
|
||||
* :doc:`pair_style lj/cut/coul/msm/dielectric <pair_dielectric>`
|
||||
* :doc:`pair_style pppm/dielectric <kspace_style>`
|
||||
* :doc:`pair_style pppm/disp/dielectric <kspace_style>`
|
||||
* :doc:`pair_style msm/dielectric <kspace_style>`
|
||||
* :doc:`fix_style polarize/bem/icc <fix_polarize>`
|
||||
* :doc:`fix_style polarize/bem/gmres <fix_polarize>`
|
||||
* :doc:`fix_style polarize/functional <fix_polarize>`
|
||||
* :doc:`compute efield/atom <compute_efield_atom>`
|
||||
* TODO: add all styles
|
||||
* examples/PACKAGES/dielectric
|
||||
|
||||
----------
|
||||
|
||||
@ -127,19 +127,16 @@ The *vx*, *vy*, *vz*, *fx*, *fy*, *fz* attributes are components of
|
||||
the COM velocity and force on the COM of the body.
|
||||
|
||||
The *omegax*, *omegay*, and *omegaz* attributes are the angular
|
||||
velocity components of the body around its COM.
|
||||
velocity components of the body in the system frame around its COM.
|
||||
|
||||
The *angmomx*, *angmomy*, and *angmomz* attributes are the angular
|
||||
momentum components of the body around its COM.
|
||||
momentum components of the body in the system frame around its COM.
|
||||
|
||||
The *quatw*, *quati*, *quatj*, and *quatk* attributes are the
|
||||
components of the 4-vector quaternion representing the orientation of
|
||||
the rigid body. See the :doc:`set <set>` command for an explanation of
|
||||
the quaternion vector.
|
||||
|
||||
The *angmomx*, *angmomy*, and *angmomz* attributes are the angular
|
||||
momentum components of the body around its COM.
|
||||
|
||||
The *tqx*, *tqy*, *tqz* attributes are components of the torque acting
|
||||
on the body around its COM.
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@ It is assumed that the particles cannot pass through the interface during the si
|
||||
so that its local dielectric constant value does not change.
|
||||
|
||||
There are some example scripts for using these fixes
|
||||
with LAMMPS in the ``examples/PACKAGES/dielectric directory``. The README file
|
||||
with LAMMPS in the ``examples/PACKAGES/dielectric`` directory. The README file
|
||||
therein contains specific details on the system setup. Note that the example data files
|
||||
show the additional fields (columns) needed for :doc:`atom_style dielectric <atom_style>`
|
||||
beyond the conventional fields *id*, *mol*, *type*, *q*, *x*, *y*, and *z*.
|
||||
@ -91,7 +91,7 @@ For fix *polarize/bem/gmres* and fix *polarize/bem/icc* the induced
|
||||
charges of the atoms in the specified group, which are the vertices on
|
||||
the interface, are computed using the equation:
|
||||
|
||||
..math::
|
||||
.. math::
|
||||
|
||||
\sigma_b(\mathbf{s}) = \dfrac{1 - \bar{\epsilon}}{\bar{\epsilon}}
|
||||
\sigma_f(\mathbf{s}) - \epsilon_0 \dfrac{\Delta \epsilon}{\bar{\epsilon}}
|
||||
@ -154,6 +154,9 @@ if LAMMPS was built with that package, which requires that also the
|
||||
KSPACE package is installed. See the :doc:`Build package
|
||||
<Build_package>` page for more info.
|
||||
|
||||
Note that the *polarize/bem/gmres* and *polarize/bem/icc* fixes only support
|
||||
:doc:`units <units>` *lj*, *real*, *metal*, *si* and *nano* at the moment.
|
||||
|
||||
|
||||
Related commands
|
||||
""""""""""""""""
|
||||
|
||||
@ -304,13 +304,15 @@ uninterrupted fashion.
|
||||
.. warning::
|
||||
|
||||
When reading data from a restart file, this fix command has to be
|
||||
specified **exactly** the same was in the input script that created
|
||||
the restart file. LAMMPS will only check whether a fix is of the
|
||||
same style and has the same fix ID and in case of a match will then
|
||||
try to initialize the fix with the data stored in the binary
|
||||
restart file. If the names and associated date types in the new
|
||||
fix property/atom command do not match the old one exactly, data
|
||||
can be corrupted or LAMMPS may crash.
|
||||
specified **after** the *read_restart* command and **exactly** the
|
||||
same was in the input script that created the restart file. LAMMPS
|
||||
will only check whether a fix is of the same style and has the same
|
||||
fix ID and in case of a match will then try to initialize the fix
|
||||
with the data stored in the binary restart file. If the names and
|
||||
associated date types in the new fix property/atom command do not
|
||||
match the old one exactly, data can be corrupted or LAMMPS may crash.
|
||||
If the fix is specified **before** the *read_restart* command its
|
||||
data will not be restored.
|
||||
|
||||
None of the :doc:`fix_modify <fix_modify>` options are relevant to
|
||||
this fix. No global or per-atom quantities are stored by this fix for
|
||||
|
||||
@ -214,10 +214,10 @@ generate an error. LAMMPS will check if a "UNITS:" tag is in the first
|
||||
line and stop with an error, if there is a mismatch with the current
|
||||
units used.
|
||||
|
||||
..note::
|
||||
.. note::
|
||||
|
||||
The electronic temperature at each grid point must be a non-zero
|
||||
positive value, both initially, and as the temperature evovles over
|
||||
positive value, both initially, and as the temperature evolves over
|
||||
time. Thus you must use either the *set* or *infile* keyword or be
|
||||
restarting a simulation that used this fix previously.
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
.. index:: pair_style lj/cut/coul/cut/dielectric
|
||||
.. index:: pair_style lj/cut/coul/cut/dielectric/omp
|
||||
.. index:: pair_style lj/cut/coul/debye/dielectric
|
||||
.. index:: pair_style lj/cut/coul/debye/dielectric/omp
|
||||
.. index:: pair_style lj/cut/coul/long/dielectric
|
||||
.. index:: pair_style lj/cut/coul/long/dielectric/omp
|
||||
.. index:: pair_style lj/cut/coul/msm/dielectric
|
||||
@ -22,6 +23,8 @@ Accelerator Variants: *lj/cut/coul/cut/dielectric/omp*
|
||||
pair_style lj/cut/coul/debye/dielectric command
|
||||
===============================================
|
||||
|
||||
Accelerator Variants: *lj/cut/coul/debye/dielectric/omp*
|
||||
|
||||
pair_style lj/cut/coul/long/dielectric command
|
||||
==============================================
|
||||
|
||||
|
||||
161
doc/src/set.rst
161
doc/src/set.rst
@ -22,7 +22,7 @@ Syntax
|
||||
*volume* or *image* or *bond* or *angle* or *dihedral* or
|
||||
*improper* or *sph/e* or *sph/cv* or *sph/rho* or
|
||||
*smd/contact/radius* or *smd/mass/density* or *dpd/theta* or
|
||||
*edpd/temp* or *edpd/cv* or *cc* or
|
||||
*edpd/temp* or *edpd/cv* or *cc* or *epsilon* or
|
||||
*i_name* or *d_name* or *i2_name* or *d2_name*
|
||||
|
||||
.. parsed-literal::
|
||||
@ -124,6 +124,7 @@ Syntax
|
||||
*cc* values = index cc
|
||||
index = index of a chemical species (1 to Nspecies)
|
||||
cc = chemical concentration of tDPD particles for a species (mole/volume units)
|
||||
*epsilon* value = dielectric constant of the medium where the atoms reside
|
||||
*i_name* value = custom integer vector with name
|
||||
*d_name* value = custom floating-point vector with name
|
||||
*i2_name* value = column of a custom integer array with name
|
||||
@ -372,13 +373,13 @@ vector of the particles is set to the 3 specified components.
|
||||
|
||||
Keyword *omega* sets the angular velocity of selected atoms. The
|
||||
particles must be spheres as defined by the :doc:`atom_style sphere
|
||||
<atom_style>` command. The angular velocity vector of the particles
|
||||
is set to the 3 specified components.
|
||||
<atom_style>` command. The angular velocity vector of the particles is
|
||||
set to the 3 specified components.
|
||||
|
||||
Keyword *mass* sets the mass of all selected particles. The particles
|
||||
must have a per-atom mass attribute, as defined by the
|
||||
:doc:`atom_style <atom_style>` command. See the "mass" command for
|
||||
how to set mass values on a per-type basis.
|
||||
must have a per-atom mass attribute, as defined by the :doc:`atom_style
|
||||
<atom_style>` command. See the "mass" command for how to set mass
|
||||
values on a per-type basis.
|
||||
|
||||
Keyword *density* or *density/disc* also sets the mass of all selected
|
||||
particles, but in a different way. The particles must have a per-atom
|
||||
@ -387,22 +388,21 @@ command. If the atom has a radius attribute (see :doc:`atom_style
|
||||
sphere <atom_style>`) and its radius is non-zero, its mass is set from
|
||||
the density and particle volume for 3d systems (the input density is
|
||||
assumed to be in mass/distance\^3 units). For 2d, the default is for
|
||||
LAMMPS to model particles with a radius attribute as spheres.
|
||||
However, if the *density/disc* keyword is used, then they can be
|
||||
modeled as 2d discs (circles). Their mass is set from the density and
|
||||
particle area (the input density is assumed to be in mass/distance\^2
|
||||
units).
|
||||
LAMMPS to model particles with a radius attribute as spheres. However,
|
||||
if the *density/disc* keyword is used, then they can be modeled as 2d
|
||||
discs (circles). Their mass is set from the density and particle area
|
||||
(the input density is assumed to be in mass/distance\^2 units).
|
||||
|
||||
If the atom has a shape attribute (see :doc:`atom_style ellipsoid
|
||||
<atom_style>`) and its 3 shape parameters are non-zero, then its mass
|
||||
is set from the density and particle volume (the input density is
|
||||
assumed to be in mass/distance\^3 units). The *density/disc* keyword
|
||||
has no effect; it does not (yet) treat 3d ellipsoids as 2d ellipses.
|
||||
<atom_style>`) and its 3 shape parameters are non-zero, then its mass is
|
||||
set from the density and particle volume (the input density is assumed
|
||||
to be in mass/distance\^3 units). The *density/disc* keyword has no
|
||||
effect; it does not (yet) treat 3d ellipsoids as 2d ellipses.
|
||||
|
||||
If the atom has a length attribute (see :doc:`atom_style line
|
||||
<atom_style>`) and its length is non-zero, then its mass is set from
|
||||
the density and line segment length (the input density is assumed to
|
||||
be in mass/distance units). If the atom has an area attribute (see
|
||||
<atom_style>`) and its length is non-zero, then its mass is set from the
|
||||
density and line segment length (the input density is assumed to be in
|
||||
mass/distance units). If the atom has an area attribute (see
|
||||
:doc:`atom_style tri <atom_style>`) and its area is non-zero, then its
|
||||
mass is set from the density and triangle area (the input density is
|
||||
assumed to be in mass/distance\^2 units).
|
||||
@ -410,84 +410,91 @@ assumed to be in mass/distance\^2 units).
|
||||
If none of these cases are valid, then the mass is set to the density
|
||||
value directly (the input density is assumed to be in mass units).
|
||||
|
||||
Keyword *volume* sets the volume of all selected particles.
|
||||
Currently, only the :doc:`atom_style peri <atom_style>` command defines
|
||||
particles with a volume attribute. Note that this command does not
|
||||
adjust the particle mass.
|
||||
Keyword *volume* sets the volume of all selected particles. Currently,
|
||||
only the :doc:`atom_style peri <atom_style>` command defines particles
|
||||
with a volume attribute. Note that this command does not adjust the
|
||||
particle mass.
|
||||
|
||||
Keyword *image* sets which image of the simulation box the atom is
|
||||
considered to be in. An image of 0 means it is inside the box as
|
||||
defined. A value of 2 means add 2 box lengths to get the true value.
|
||||
A value of -1 means subtract 1 box length to get the true value.
|
||||
LAMMPS updates these flags as atoms cross periodic boundaries during
|
||||
the simulation. The flags can be output with atom snapshots via the
|
||||
:doc:`dump <dump>` command. If a value of NULL is specified for any
|
||||
of nx,ny,nz, then the current image value for that dimension is
|
||||
unchanged. For non-periodic dimensions only a value of 0 can be
|
||||
specified. This command can be useful after a system has been
|
||||
equilibrated and atoms have diffused one or more box lengths in
|
||||
various directions. This command can then reset the image values for
|
||||
atoms so that they are effectively inside the simulation box, e.g if a
|
||||
diffusion coefficient is about to be measured via the :doc:`compute
|
||||
msd <compute_msd>` command. Care should be taken not to reset the
|
||||
image flags of two atoms in a bond to the same value if the bond
|
||||
straddles a periodic boundary (rather they should be different by +/-
|
||||
1). This will not affect the dynamics of a simulation, but may mess
|
||||
up analysis of the trajectories if a LAMMPS diagnostic or your own
|
||||
analysis relies on the image flags to unwrap a molecule which
|
||||
straddles the periodic box.
|
||||
defined. A value of 2 means add 2 box lengths to get the true value. A
|
||||
value of -1 means subtract 1 box length to get the true value. LAMMPS
|
||||
updates these flags as atoms cross periodic boundaries during the
|
||||
simulation. The flags can be output with atom snapshots via the
|
||||
:doc:`dump <dump>` command. If a value of NULL is specified for any of
|
||||
nx,ny,nz, then the current image value for that dimension is unchanged.
|
||||
For non-periodic dimensions only a value of 0 can be specified. This
|
||||
command can be useful after a system has been equilibrated and atoms
|
||||
have diffused one or more box lengths in various directions. This
|
||||
command can then reset the image values for atoms so that they are
|
||||
effectively inside the simulation box, e.g if a diffusion coefficient is
|
||||
about to be measured via the :doc:`compute msd <compute_msd>` command.
|
||||
Care should be taken not to reset the image flags of two atoms in a bond
|
||||
to the same value if the bond straddles a periodic boundary (rather they
|
||||
should be different by +/- 1). This will not affect the dynamics of a
|
||||
simulation, but may mess up analysis of the trajectories if a LAMMPS
|
||||
diagnostic or your own analysis relies on the image flags to unwrap a
|
||||
molecule which straddles the periodic box.
|
||||
|
||||
Keywords *bond*, *angle*, *dihedral*, and *improper*, set the bond
|
||||
type (angle type, etc) of all bonds (angles, etc) of selected atoms to
|
||||
the specified value from 1 to nbondtypes (nangletypes, etc). All
|
||||
atoms in a particular bond (angle, etc) must be selected atoms in
|
||||
order for the change to be made. The value of nbondtype (nangletypes,
|
||||
etc) was set by the *bond types* (\ *angle types*, etc) field in the
|
||||
header of the data file read by the :doc:`read_data <read_data>`
|
||||
command. These keywords do not allow use of an atom-style variable.
|
||||
Keywords *bond*, *angle*, *dihedral*, and *improper*, set the bond type
|
||||
(angle type, etc) of all bonds (angles, etc) of selected atoms to the
|
||||
specified value from 1 to nbondtypes (nangletypes, etc). All atoms in a
|
||||
particular bond (angle, etc) must be selected atoms in order for the
|
||||
change to be made. The value of nbondtype (nangletypes, etc) was set by
|
||||
the *bond types* (\ *angle types*, etc) field in the header of the data
|
||||
file read by the :doc:`read_data <read_data>` command. These keywords
|
||||
do not allow use of an atom-style variable.
|
||||
|
||||
Keywords *sph/e*, *sph/cv*, and *sph/rho* set the energy, heat
|
||||
capacity, and density of smoothed particle hydrodynamics (SPH)
|
||||
particles. See `this PDF guide <PDF/SPH_LAMMPS_userguide.pdf>`_
|
||||
to using SPH in LAMMPS.
|
||||
Keywords *sph/e*, *sph/cv*, and *sph/rho* set the energy, heat capacity,
|
||||
and density of smoothed particle hydrodynamics (SPH) particles. See
|
||||
`this PDF guide <PDF/SPH_LAMMPS_userguide.pdf>`_ to using SPH in LAMMPS.
|
||||
|
||||
Keyword *smd/mass/density* sets the mass of all selected particles,
|
||||
but it is only applicable to the Smooth Mach Dynamics package
|
||||
MACHDYN. It assumes that the particle volume has already been
|
||||
correctly set and calculates particle mass from the provided mass
|
||||
density value.
|
||||
Keyword *smd/mass/density* sets the mass of all selected particles, but
|
||||
it is only applicable to the Smooth Mach Dynamics package MACHDYN. It
|
||||
assumes that the particle volume has already been correctly set and
|
||||
calculates particle mass from the provided mass density value.
|
||||
|
||||
Keyword *smd/contact/radius* only applies to simulations with the
|
||||
Smooth Mach Dynamics package MACHDYN. Itsets an interaction radius
|
||||
for computing short-range interactions, e.g. repulsive forces to
|
||||
prevent different individual physical bodies from penetrating each
|
||||
other. Note that the SPH smoothing kernel diameter used for computing
|
||||
long range, nonlocal interactions, is set using the *diameter*
|
||||
keyword.
|
||||
Keyword *smd/contact/radius* only applies to simulations with the Smooth
|
||||
Mach Dynamics package MACHDYN. Itsets an interaction radius for
|
||||
computing short-range interactions, e.g. repulsive forces to prevent
|
||||
different individual physical bodies from penetrating each other. Note
|
||||
that the SPH smoothing kernel diameter used for computing long range,
|
||||
nonlocal interactions, is set using the *diameter* keyword.
|
||||
|
||||
Keyword *dpd/theta* sets the internal temperature of a DPD particle as
|
||||
defined by the DPD-REACT package. If the specified value is a number
|
||||
it must be >= 0.0. If the specified value is NULL, then the kinetic
|
||||
temperature Tkin of each particle is computed as 3/2 k Tkin = KE = 1/2
|
||||
m v\^2 = 1/2 m (vx\*vx+vy\*vy+vz\*vz). Each particle's internal
|
||||
defined by the DPD-REACT package. If the specified value is a number it
|
||||
must be >= 0.0. If the specified value is NULL, then the kinetic
|
||||
temperature Tkin of each particle is computed as 3/2 k Tkin = KE = 1/2 m
|
||||
v\^2 = 1/2 m (vx\*vx+vy\*vy+vz\*vz). Each particle's internal
|
||||
temperature is set to Tkin. If the specified value is an atom-style
|
||||
variable, then the variable is evaluated for each particle. If a
|
||||
value >= 0.0, the internal temperature is set to that value. If it is
|
||||
< 0.0, the computation of Tkin is performed and the internal
|
||||
temperature is set to that value.
|
||||
variable, then the variable is evaluated for each particle. If a value
|
||||
>= 0.0, the internal temperature is set to that value. If it is < 0.0,
|
||||
the computation of Tkin is performed and the internal temperature is set
|
||||
to that value.
|
||||
|
||||
Keywords *edpd/temp* and *edpd/cv* set the temperature and volumetric
|
||||
heat capacity of an eDPD particle as defined by the DPD-MESO package.
|
||||
Currently, only :doc:`atom_style edpd <atom_style>` defines particles
|
||||
with these attributes. The values for the temperature and heat
|
||||
capacity must be positive.
|
||||
with these attributes. The values for the temperature and heat capacity
|
||||
must be positive.
|
||||
|
||||
Keyword *cc* sets the chemical concentration of a tDPD particle for a
|
||||
specified species as defined by the DPD-MESO package. Currently, only
|
||||
:doc:`atom_style tdpd <atom_style>` defines particles with this
|
||||
attribute. An integer for "index" selects a chemical species (1 to
|
||||
Nspecies) where Nspecies is set by the atom_style command. The value
|
||||
for the chemical concentration must be >= 0.0.
|
||||
Nspecies) where Nspecies is set by the atom_style command. The value for
|
||||
the chemical concentration must be >= 0.0.
|
||||
|
||||
Keyword *epsilon* sets the dielectric constant of a particle, precisely
|
||||
of the medium where the particle resides as defined by the DIELECTRIC
|
||||
package. Currently, only :doc:`atom_style dielectric <atom_style>`
|
||||
defines particles with this attribute. The value for the dielectric
|
||||
constant must be >= 0.0. Note that the set command with this keyword
|
||||
will rescale the particle charge accordingly so that the real charge
|
||||
(e.g., as read from a data file) stays intact. To change the real
|
||||
charges, one needs to use the set command with the *charge*
|
||||
keyword. Care must be taken to ensure that the real and scaled charges,
|
||||
and dielectric constants are consistent.
|
||||
|
||||
Keywords *i_name*, *d_name*, *i2_name*, *d2_name* refer to custom
|
||||
per-atom integer and floating-point vectors or arrays that have been
|
||||
|
||||
@ -252,6 +252,6 @@ flush = no, and temp/press = compute IDs defined by thermo_style.
|
||||
|
||||
The defaults for the line and format options depend on the thermo style.
|
||||
For styles "one" and "custom", the line and format defaults are "one",
|
||||
"%10d", and "%12.8g". For style "multi", the line and format defaults
|
||||
"%10d", and "%14.8g". For style "multi", the line and format defaults
|
||||
are "multi", "%14d", and "%14.4f". For style "yaml", the line and format
|
||||
defaults are "%d" and "%.15g".
|
||||
|
||||
@ -10,7 +10,7 @@ Syntax
|
||||
|
||||
thermo_style style args
|
||||
|
||||
* style = *one* or *multi* *yaml* or *custom*
|
||||
* style = *one* or *multi* or *yaml* or *custom*
|
||||
* args = list of arguments for a particular style
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
@ -6,3 +6,4 @@ breathe
|
||||
Pygments
|
||||
six
|
||||
pyyaml
|
||||
wheel
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
LAMMPS data file: two oppositely charged ions confined between two walls
|
||||
LAMMPS data file: two oppositely charged ions confined between two walls epsilon1=2 | epsilon2=10 | epsilon1=2
|
||||
|
||||
4002 atoms
|
||||
3 atom types
|
||||
@ -4015,5 +4015,5 @@ Atoms # dielectric: id mol type q x y z normx normy normz area_per_patch ed em e
|
||||
3998 0 1 0 38.5078 42.4438 30.002 0 0 -1 0.866 8 6 6 0
|
||||
3999 0 1 0 39.0079 41.5776 30.002 0 0 -1 0.866 8 6 6 0
|
||||
4000 0 1 0 39.508 42.4438 30.002 0 0 -1 0.866 8 6 6 0
|
||||
4001 0 2 1 15 20 15 0 0 1 0.866 8 6 10 0
|
||||
4002 0 3 -1 25 20 25 0 0 1 0.866 8 6 10 0
|
||||
4001 0 2 1 15 20 15 0 0 1 1.0 8 6 10 0
|
||||
4002 0 3 -1 25 20 25 0 0 1 1.0 8 6 10 0
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
# top interface: n = (0, 0, -1)
|
||||
# so that ed's are the same for both interfaces
|
||||
|
||||
# Dielectric constants can be set to be different from the input data file
|
||||
|
||||
variable epsilon1 index 20
|
||||
variable epsilon2 index 8
|
||||
|
||||
@ -21,6 +23,8 @@ variable method index gmres # gmres = BEM/GMRES
|
||||
# dof = Direct optimization of the functional
|
||||
# none
|
||||
|
||||
# compute the relevant values for the interface particles
|
||||
|
||||
variable ed equal "v_epsilon2 - v_epsilon1"
|
||||
variable em equal "(v_epsilon2 + v_epsilon1)/2"
|
||||
variable epsilon equal 1.0 # epsilon at the patch, not used for now
|
||||
@ -34,12 +38,10 @@ group ions type 2 3
|
||||
group cations type 2
|
||||
group anions type 3
|
||||
|
||||
# 1.0 = q * epsilon2 = qreal for cations
|
||||
# -1.0 = q * epsilon2 = qreal for anions
|
||||
variable qscale equal "1.0 / v_epsilon2"
|
||||
set group cations charge ${qscale}
|
||||
variable qscale equal "-1.0 / v_epsilon2"
|
||||
set group anions charge ${qscale}
|
||||
# set the dielectric constant of the medium where the ions reside
|
||||
|
||||
set group cations epsilon ${epsilon2}
|
||||
set group anions epsilon ${epsilon2}
|
||||
|
||||
pair_style lj/cut/coul/long/dielectric 1.122 10.0
|
||||
pair_coeff * * 1.0 1.0
|
||||
@ -59,6 +61,8 @@ dump 3 ions custom 100 ions.dump id mol type q x y z fx fy fz #c_ef[1
|
||||
|
||||
fix 1 ions nve
|
||||
|
||||
# fix modify is used to set the properties of the interface particle group
|
||||
|
||||
if "${method} == gmres" then &
|
||||
"fix 3 interface polarize/bem/gmres 1 1.0e-4" &
|
||||
"fix_modify 3 itr_max 50 dielectrics ${ed} ${em} ${epsilon} ${area} NULL" &
|
||||
|
||||
1
examples/ttm/Si.sw
Symbolic link
1
examples/ttm/Si.sw
Symbolic link
@ -0,0 +1 @@
|
||||
../../potentials/Si.sw
|
||||
44
examples/ttm/Si.ttm_mod
Normal file
44
examples/ttm/Si.ttm_mod
Normal file
@ -0,0 +1,44 @@
|
||||
a_0, energy/(temperature*electron) units
|
||||
-0.00012899
|
||||
a_1, energy/(temperature^2*electron) units
|
||||
-0.0000000293276
|
||||
a_2, energy/(temperature^3*electron) units
|
||||
-0.0000229991
|
||||
a_3, energy/(temperature^4*electron) units
|
||||
-0.000000927036
|
||||
a_4, energy/(temperature^5*electron) units
|
||||
-0.0000011747
|
||||
C_0, energy/(temperature*electron) units
|
||||
0.000129
|
||||
A, 1/temperature units
|
||||
0.180501
|
||||
rho_e, electrons/volume units
|
||||
0.05
|
||||
D_e, length^2/time units
|
||||
20000
|
||||
gamma_p, mass/time units
|
||||
39.235
|
||||
gamma_s, mass/time units
|
||||
24.443
|
||||
v_0, length/time units
|
||||
79.76
|
||||
I_0, energy/(time*length^2) units
|
||||
0
|
||||
lsurface, electron grid units (positive integer)
|
||||
0
|
||||
rsurface, electron grid units (positive integer)
|
||||
1
|
||||
l_skin, length units
|
||||
1
|
||||
tau, time units
|
||||
0
|
||||
B, dimensionless
|
||||
0
|
||||
lambda, length units
|
||||
0
|
||||
n_ion, ions/volume units
|
||||
0.05
|
||||
surface_movement: 0 to disable tracking of surface motion, 1 to enable
|
||||
0
|
||||
T_e_min, temperature units
|
||||
0
|
||||
29
examples/ttm/in.ttm.mod
Normal file
29
examples/ttm/in.ttm.mod
Normal file
@ -0,0 +1,29 @@
|
||||
units metal
|
||||
atom_style atomic
|
||||
boundary p p p
|
||||
|
||||
lattice diamond 5.4309
|
||||
region box block 0 10 0 10 0 10
|
||||
create_box 1 box
|
||||
mass 1 28.0855
|
||||
create_atoms 1 box basis 1 1 basis 2 1 basis 3 1 basis 4 1 basis 5 1 basis 6 1 basis 7 1 basis 8 1
|
||||
|
||||
pair_style sw
|
||||
pair_coeff * * Si.sw Si
|
||||
|
||||
neighbor 2.0 bin
|
||||
neigh_modify every 5 delay 0 check yes
|
||||
|
||||
fix 1 all nve
|
||||
fix twotemp all ttm/mod 1354684 Si.ttm_mod 10 10 10 set 1000.0 # outfile 100 T_out.txt
|
||||
|
||||
compute pe all pe/atom
|
||||
compute ke all ke/atom
|
||||
|
||||
timestep 0.0001
|
||||
thermo 100
|
||||
|
||||
thermo_style custom step temp etotal f_twotemp[1] f_twotemp[2]
|
||||
thermo_modify format float "%20.16g"
|
||||
|
||||
run 1000
|
||||
122
examples/ttm/log.20Apr22.ttm.mod.g++.1
Normal file
122
examples/ttm/log.20Apr22.ttm.mod.g++.1
Normal file
@ -0,0 +1,122 @@
|
||||
LAMMPS (24 Mar 2022)
|
||||
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98)
|
||||
using 1 OpenMP thread(s) per MPI task
|
||||
units metal
|
||||
atom_style atomic
|
||||
boundary p p p
|
||||
|
||||
lattice diamond 5.4309
|
||||
Lattice spacing in x,y,z = 5.4309 5.4309 5.4309
|
||||
region box block 0 10 0 10 0 10
|
||||
create_box 1 box
|
||||
Created orthogonal box = (0 0 0) to (54.309 54.309 54.309)
|
||||
1 by 1 by 1 MPI processor grid
|
||||
mass 1 28.0855
|
||||
create_atoms 1 box basis 1 1 basis 2 1 basis 3 1 basis 4 1 basis 5 1 basis 6 1 basis 7 1 basis 8 1
|
||||
Created 8000 atoms
|
||||
using lattice units in orthogonal box = (0 0 0) to (54.309 54.309 54.309)
|
||||
create_atoms CPU = 0.001 seconds
|
||||
|
||||
pair_style sw
|
||||
pair_coeff * * Si.sw Si
|
||||
Reading sw potential file Si.sw with DATE: 2007-06-11
|
||||
|
||||
neighbor 2.0 bin
|
||||
neigh_modify every 5 delay 0 check yes
|
||||
|
||||
fix 1 all nve
|
||||
fix twotemp all ttm/mod 1354684 Si.ttm_mod 10 10 10 set 1000.0 # outfile 100 T_out.txt
|
||||
|
||||
compute pe all pe/atom
|
||||
compute ke all ke/atom
|
||||
|
||||
timestep 0.0001
|
||||
thermo 100
|
||||
|
||||
thermo_style custom step temp etotal f_twotemp[1] f_twotemp[2]
|
||||
thermo_modify format float "%20.16g"
|
||||
|
||||
run 1000
|
||||
|
||||
CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE
|
||||
|
||||
Your simulation uses code contributions which should be cited:
|
||||
|
||||
- fix ttm/mod command:
|
||||
|
||||
@article{Pisarev2014,
|
||||
author = {Pisarev, V. V. and Starikov, S. V.},
|
||||
title = {{Atomistic simulation of ion track formation in UO2.}},
|
||||
journal = {J.~Phys.:~Condens.~Matter},
|
||||
volume = {26},
|
||||
number = {47},
|
||||
pages = {475401},
|
||||
year = {2014}
|
||||
}
|
||||
|
||||
@article{Norman2013,
|
||||
author = {Norman, G. E. and Starikov, S. V. and Stegailov, V. V. and Saitov, I. M. and Zhilyaev, P. A.},
|
||||
title = {{Atomistic Modeling of Warm Dense Matter in the Two-Temperature State}},
|
||||
journal = {Contrib.~Plasm.~Phys.},
|
||||
number = {2},
|
||||
volume = {53},
|
||||
pages = {129--139},
|
||||
year = {2013}
|
||||
}
|
||||
|
||||
CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE
|
||||
|
||||
Neighbor list info ...
|
||||
update every 5 steps, delay 0 steps, check yes
|
||||
max neighbors/atom: 2000, page size: 100000
|
||||
master list distance cutoff = 5.77118
|
||||
ghost atom cutoff = 5.77118
|
||||
binsize = 2.88559, bins = 19 19 19
|
||||
1 neighbor lists, perpetual/occasional/extra = 1 0 0
|
||||
(1) pair sw, perpetual
|
||||
attributes: full, newton on
|
||||
pair build: full/bin/atomonly
|
||||
stencil: full/bin/3d
|
||||
bin: standard
|
||||
Per MPI rank memory allocation (min/avg/max) = 4.433 | 4.433 | 4.433 Mbytes
|
||||
Step Temp TotEng f_twotemp[1] f_twotemp[2]
|
||||
0 0 -34692.79996100604 -52.79390940511979 0
|
||||
100 2.004897156140836 -34690.27961013186 -55.34997305431884 0.01301140393178354
|
||||
200 2.837118035232607 -34687.74741132015 -57.93445748841878 0.02696025968760173
|
||||
300 4.263087164947482 -34684.98084093686 -60.75945453846786 0.02175636603841567
|
||||
400 5.568003854939066 -34682.25271040963 -63.56896518300501 0.0300061848347275
|
||||
500 6.225602451570786 -34679.49948952029 -66.40897551884576 0.02768827702656702
|
||||
600 7.608847536264781 -34676.69728436362 -69.32060611557266 0.05579466731854093
|
||||
700 9.049471241531297 -34674.00093206036 -72.10055094219446 0.004335980559879027
|
||||
800 9.826796099683211 -34671.27720242751 -74.9501061086213 0.02371649678091513
|
||||
900 11.8609224958918 -34668.35091308811 -77.98544170794551 0.004658649791374929
|
||||
1000 13.88037467640968 -34665.35025858006 -81.16445160194114 0.07684078334464739
|
||||
Loop time of 4.85247 on 1 procs for 1000 steps with 8000 atoms
|
||||
|
||||
Performance: 1.781 ns/day, 13.479 hours/ns, 206.081 timesteps/s
|
||||
99.8% CPU use with 1 MPI tasks x 1 OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 4.1286 | 4.1286 | 4.1286 | 0.0 | 85.08
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0.030972 | 0.030972 | 0.030972 | 0.0 | 0.64
|
||||
Output | 0.0026351 | 0.0026351 | 0.0026351 | 0.0 | 0.05
|
||||
Modify | 0.67848 | 0.67848 | 0.67848 | 0.0 | 13.98
|
||||
Other | | 0.01182 | | | 0.24
|
||||
|
||||
Nlocal: 8000 ave 8000 max 8000 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Nghost: 6725 ave 6725 max 6725 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
Neighs: 0 ave 0 max 0 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
FullNghs: 272000 ave 272000 max 272000 min
|
||||
Histogram: 1 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Total # of neighbors = 272000
|
||||
Ave neighs/atom = 34
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds = 0
|
||||
Total wall time: 0:00:04
|
||||
122
examples/ttm/log.20Apr22.ttm.mod.g++.4
Normal file
122
examples/ttm/log.20Apr22.ttm.mod.g++.4
Normal file
@ -0,0 +1,122 @@
|
||||
LAMMPS (24 Mar 2022)
|
||||
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98)
|
||||
using 1 OpenMP thread(s) per MPI task
|
||||
units metal
|
||||
atom_style atomic
|
||||
boundary p p p
|
||||
|
||||
lattice diamond 5.4309
|
||||
Lattice spacing in x,y,z = 5.4309 5.4309 5.4309
|
||||
region box block 0 10 0 10 0 10
|
||||
create_box 1 box
|
||||
Created orthogonal box = (0 0 0) to (54.309 54.309 54.309)
|
||||
1 by 2 by 2 MPI processor grid
|
||||
mass 1 28.0855
|
||||
create_atoms 1 box basis 1 1 basis 2 1 basis 3 1 basis 4 1 basis 5 1 basis 6 1 basis 7 1 basis 8 1
|
||||
Created 8000 atoms
|
||||
using lattice units in orthogonal box = (0 0 0) to (54.309 54.309 54.309)
|
||||
create_atoms CPU = 0.000 seconds
|
||||
|
||||
pair_style sw
|
||||
pair_coeff * * Si.sw Si
|
||||
Reading sw potential file Si.sw with DATE: 2007-06-11
|
||||
|
||||
neighbor 2.0 bin
|
||||
neigh_modify every 5 delay 0 check yes
|
||||
|
||||
fix 1 all nve
|
||||
fix twotemp all ttm/mod 1354684 Si.ttm_mod 10 10 10 set 1000.0 # outfile 100 T_out.txt
|
||||
|
||||
compute pe all pe/atom
|
||||
compute ke all ke/atom
|
||||
|
||||
timestep 0.0001
|
||||
thermo 100
|
||||
|
||||
thermo_style custom step temp etotal f_twotemp[1] f_twotemp[2]
|
||||
thermo_modify format float "%20.16g"
|
||||
|
||||
run 1000
|
||||
|
||||
CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE
|
||||
|
||||
Your simulation uses code contributions which should be cited:
|
||||
|
||||
- fix ttm/mod command:
|
||||
|
||||
@article{Pisarev2014,
|
||||
author = {Pisarev, V. V. and Starikov, S. V.},
|
||||
title = {{Atomistic simulation of ion track formation in UO2.}},
|
||||
journal = {J.~Phys.:~Condens.~Matter},
|
||||
volume = {26},
|
||||
number = {47},
|
||||
pages = {475401},
|
||||
year = {2014}
|
||||
}
|
||||
|
||||
@article{Norman2013,
|
||||
author = {Norman, G. E. and Starikov, S. V. and Stegailov, V. V. and Saitov, I. M. and Zhilyaev, P. A.},
|
||||
title = {{Atomistic Modeling of Warm Dense Matter in the Two-Temperature State}},
|
||||
journal = {Contrib.~Plasm.~Phys.},
|
||||
number = {2},
|
||||
volume = {53},
|
||||
pages = {129--139},
|
||||
year = {2013}
|
||||
}
|
||||
|
||||
CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE
|
||||
|
||||
Neighbor list info ...
|
||||
update every 5 steps, delay 0 steps, check yes
|
||||
max neighbors/atom: 2000, page size: 100000
|
||||
master list distance cutoff = 5.77118
|
||||
ghost atom cutoff = 5.77118
|
||||
binsize = 2.88559, bins = 19 19 19
|
||||
1 neighbor lists, perpetual/occasional/extra = 1 0 0
|
||||
(1) pair sw, perpetual
|
||||
attributes: full, newton on
|
||||
pair build: full/bin/atomonly
|
||||
stencil: full/bin/3d
|
||||
bin: standard
|
||||
Per MPI rank memory allocation (min/avg/max) = 3.436 | 3.436 | 3.436 Mbytes
|
||||
Step Temp TotEng f_twotemp[1] f_twotemp[2]
|
||||
0 0 -34692.79996100361 -52.79390940511979 0
|
||||
100 1.852689977101411 -34690.49204900486 -55.14271612882062 0.027261886765771
|
||||
200 2.735750477179192 -34688.11139028054 -57.57110998717796 0.03387986355513582
|
||||
300 3.931848271449558 -34685.54667417785 -60.18684521127226 0.02261256315262404
|
||||
400 5.462009198576365 -34682.74455105668 -63.05420336037231 0.002402241637719583
|
||||
500 6.267811692893873 -34679.96493887379 -65.93304222280049 0.02448378880218699
|
||||
600 7.21148216150661 -34677.41455784726 -68.58391420045932 0.04114045759945373
|
||||
700 8.84660534187052 -34674.40610468235 -71.68798344296847 0.0237298402743454
|
||||
800 10.1748456457686 -34671.08749605772 -75.11943618276236 0.007538225788030298
|
||||
900 11.27479036162859 -34668.4118066423 -77.92921692176769 0.02537529314475071
|
||||
1000 13.26881394868076 -34665.56617589539 -80.91544540266329 0.03112665440209921
|
||||
Loop time of 1.60214 on 4 procs for 1000 steps with 8000 atoms
|
||||
|
||||
Performance: 5.393 ns/day, 4.450 hours/ns, 624.165 timesteps/s
|
||||
99.7% CPU use with 4 MPI tasks x 1 OpenMP threads
|
||||
|
||||
MPI task timing breakdown:
|
||||
Section | min time | avg time | max time |%varavg| %total
|
||||
---------------------------------------------------------------
|
||||
Pair | 1.0424 | 1.0558 | 1.0696 | 1.0 | 65.90
|
||||
Neigh | 0 | 0 | 0 | 0.0 | 0.00
|
||||
Comm | 0.05072 | 0.063773 | 0.079458 | 4.9 | 3.98
|
||||
Output | 0.0024362 | 0.0024703 | 0.0025297 | 0.1 | 0.15
|
||||
Modify | 0.47018 | 0.47332 | 0.48004 | 0.6 | 29.54
|
||||
Other | | 0.006786 | | | 0.42
|
||||
|
||||
Nlocal: 2000 ave 2000 max 2000 min
|
||||
Histogram: 4 0 0 0 0 0 0 0 0 0
|
||||
Nghost: 3165 ave 3165 max 3165 min
|
||||
Histogram: 4 0 0 0 0 0 0 0 0 0
|
||||
Neighs: 0 ave 0 max 0 min
|
||||
Histogram: 4 0 0 0 0 0 0 0 0 0
|
||||
FullNghs: 68000 ave 68000 max 68000 min
|
||||
Histogram: 4 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Total # of neighbors = 272000
|
||||
Ave neighs/atom = 34
|
||||
Neighbor list builds = 0
|
||||
Dangerous builds = 0
|
||||
Total wall time: 0:00:01
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -20,8 +19,6 @@
|
||||
|
||||
#include "atom.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -32,33 +29,29 @@ AtomVecWavepacket::AtomVecWavepacket(LAMMPS *lmp) : AtomVec(lmp)
|
||||
molecular = Atom::ATOMIC;
|
||||
forceclearflag = 1;
|
||||
|
||||
atom->wavepacket_flag = 1;
|
||||
|
||||
atom->electron_flag = 1; // compatible with eff
|
||||
atom->q_flag = atom->spin_flag = atom->eradius_flag =
|
||||
atom->ervel_flag = atom->erforce_flag = 1;
|
||||
atom->cs_flag = atom->csforce_flag =
|
||||
atom->vforce_flag = atom->ervelforce_flag = atom->etag_flag = 1;
|
||||
atom->wavepacket_flag = atom->q_flag = atom->spin_flag = atom->eradius_flag = 1;
|
||||
atom->ervel_flag = atom->erforce_flag = atom->cs_flag = atom->csforce_flag = 1;
|
||||
atom->vforce_flag = atom->ervelforce_flag = atom->etag_flag = 1;
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *)
|
||||
"q spin eradius ervel erforce cs csforce "
|
||||
"vforce ervelforce etag";
|
||||
fields_copy = (char *) "q spin eradius ervel cs etag";
|
||||
fields_comm = (char *) "eradius";
|
||||
fields_comm_vel = (char *) "eradius ervel cs";
|
||||
fields_reverse = (char *) "erforce ervelforce vforce csforce";
|
||||
fields_border = (char *) "q spin eradius etag";
|
||||
fields_border_vel = (char *) "q spin eradius etag ervel cs";
|
||||
fields_exchange = (char *) "q spin eradius ervel etag cs";
|
||||
fields_restart = (char *) "q spin eradius ervel etag cs";
|
||||
fields_create = (char *) "q spin eradius ervel etag cs";
|
||||
fields_data_atom = (char *) "id type q spin eradius etag cs x";
|
||||
fields_data_vel = (char *) "id v ervel";
|
||||
fields_grow = {"q", "spin", "eradius", "ervel", "erforce",
|
||||
"cs", "csforce", "vforce", "ervelforce", "etag"};
|
||||
fields_copy = {"q", "spin", "eradius", "ervel", "cs", "etag"};
|
||||
fields_comm = {"eradius"};
|
||||
fields_comm_vel = {"eradius", "ervel", "cs"};
|
||||
fields_reverse = {"erforce", "ervelforce", "vforce", "csforce"};
|
||||
fields_border = {"q", "spin", "eradius", "etag"};
|
||||
fields_border_vel = {"q", "spin", "eradius", "etag", "ervel", "cs"};
|
||||
fields_exchange = {"q", "spin", "eradius", "ervel", "etag", "cs"};
|
||||
fields_restart = {"q", "spin", "eradius", "ervel", "etag", "cs"};
|
||||
fields_create = {"q", "spin", "eradius", "ervel", "etag", "cs"};
|
||||
fields_data_atom = {"id", "type", "q", "spin", "eradius", "etag", "cs", "x"};
|
||||
fields_data_vel = {"id", "v", "ervel"};
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
@ -84,7 +77,7 @@ void AtomVecWavepacket::grow_pointers()
|
||||
|
||||
void AtomVecWavepacket::force_clear(int n, size_t nbytes)
|
||||
{
|
||||
memset(&erforce[n],0,nbytes);
|
||||
memset(&erforce[n], 0, nbytes);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -112,12 +105,12 @@ void AtomVecWavepacket::data_atom_post(int ilocal)
|
||||
return -1 if name is unknown to this atom style
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecWavepacket::property_atom(char *name)
|
||||
int AtomVecWavepacket::property_atom(const std::string &name)
|
||||
{
|
||||
if (strcmp(name,"spin") == 0) return 0;
|
||||
if (strcmp(name,"eradius") == 0) return 1;
|
||||
if (strcmp(name,"ervel") == 0) return 2;
|
||||
if (strcmp(name,"erforce") == 0) return 3;
|
||||
if (name == "spin") return 0;
|
||||
if (name == "eradius") return 1;
|
||||
if (name == "ervel") return 2;
|
||||
if (name == "erforce") return 3;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -126,34 +119,41 @@ int AtomVecWavepacket::property_atom(char *name)
|
||||
index maps to data specific to this atom style
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecWavepacket::pack_property_atom(int index, double *buf,
|
||||
int nvalues, int groupbit)
|
||||
void AtomVecWavepacket::pack_property_atom(int index, double *buf, int nvalues, int groupbit)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
int n = 0;
|
||||
if (index == 0) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = spin[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = spin[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
} else if (index == 1) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = eradius[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = eradius[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
} else if (index == 2) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = ervel[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = ervel[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
} else if (index == 3) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = erforce[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = erforce[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ class AtomVecWavepacket : public AtomVec {
|
||||
void force_clear(int, size_t) override;
|
||||
void create_atom_post(int) override;
|
||||
void data_atom_post(int) override;
|
||||
int property_atom(char *) override;
|
||||
int property_atom(const std::string &) override;
|
||||
void pack_property_atom(int, double *, int, int) override;
|
||||
|
||||
private:
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include "atom_vec_bpm_sphere.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "comm.h"
|
||||
#include "error.h"
|
||||
#include "fix.h"
|
||||
#include "fix_adapt.h"
|
||||
@ -43,23 +44,21 @@ AtomVecBPMSphere::AtomVecBPMSphere(LAMMPS *_lmp) : AtomVec(_lmp)
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
// clang-format off
|
||||
fields_grow = (char *) "molecule num_bond bond_type bond_atom nspecial special radius rmass "
|
||||
"omega torque quat";
|
||||
fields_copy = (char *) "molecule num_bond bond_type bond_atom nspecial special radius rmass "
|
||||
"omega quat";
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "omega quat";
|
||||
fields_reverse = (char *) "torque";
|
||||
fields_border = (char *) "molecule radius rmass";
|
||||
fields_border_vel = (char *) "molecule radius rmass omega quat";
|
||||
fields_exchange = (char *) "molecule num_bond bond_type bond_atom nspecial special radius rmass "
|
||||
"omega quat";
|
||||
fields_restart = (char *) "molecule num_bond bond_type bond_atom radius rmass omega quat";
|
||||
fields_create = (char *) "molecule num_bond nspecial radius rmass omega quat";
|
||||
fields_data_atom = (char *) "id molecule type radius rmass x";
|
||||
fields_data_vel = (char *) "id v omega";
|
||||
// clang-format on
|
||||
fields_grow = {"molecule", "num_bond", "bond_type", "bond_atom", "nspecial", "special",
|
||||
"radius", "rmass", "omega", "torque", "quat"};
|
||||
fields_copy = {"molecule", "num_bond", "bond_type", "bond_atom", "nspecial",
|
||||
"special", "radius", "rmass", "omega", "quat"};
|
||||
fields_comm_vel = {"omega", "quat"};
|
||||
fields_reverse = {"torque"};
|
||||
fields_border = {"molecule", "radius", "rmass"};
|
||||
fields_border_vel = {"molecule", "radius", "rmass", "omega", "quat"};
|
||||
fields_exchange = {"molecule", "num_bond", "bond_type", "bond_atom", "nspecial",
|
||||
"special", "radius", "rmass", "omega", "quat"};
|
||||
fields_restart = {"molecule", "num_bond", "bond_type", "bond_atom",
|
||||
"radius", "rmass", "omega", "quat"};
|
||||
fields_create = {"molecule", "num_bond", "nspecial", "radius", "rmass", "omega", "quat"};
|
||||
fields_data_atom = {"id", "molecule", "type", "radius", "rmass", "x"};
|
||||
fields_data_vel = {"id", "v", "omega"};
|
||||
|
||||
bond_per_atom = 0;
|
||||
bond_negative = NULL;
|
||||
@ -83,8 +82,8 @@ void AtomVecBPMSphere::process_args(int narg, char **arg)
|
||||
// dynamic particle radius and mass must be communicated every step
|
||||
|
||||
if (radvary) {
|
||||
fields_comm = (char *) "radius rmass";
|
||||
fields_comm_vel = (char *) "radius rmass omega";
|
||||
fields_comm = {"radius", "rmass"};
|
||||
fields_comm_vel = {"radius", "rmass", "omega"};
|
||||
}
|
||||
|
||||
// delay setting up of fields until now
|
||||
@ -100,12 +99,16 @@ void AtomVecBPMSphere::init()
|
||||
|
||||
// check if optional radvary setting should have been set to 1
|
||||
|
||||
for (int i = 0; i < modify->nfix; i++)
|
||||
if (strcmp(modify->fix[i]->style, "adapt") == 0) {
|
||||
FixAdapt *fix = (FixAdapt *) modify->fix[i];
|
||||
if (fix->diamflag && radvary == 0)
|
||||
for (auto ifix : modify->get_fix_by_style("^adapt")) {
|
||||
if (radvary == 0) {
|
||||
if ((strcmp(ifix->style, "adapt") == 0) && (dynamic_cast<FixAdapt *>(ifix)->diamflag))
|
||||
error->all(FLERR, "Fix adapt changes atom radii but atom_style bpm/sphere is not dynamic");
|
||||
// cannot properly check for fix adapt/fep since its header is optional
|
||||
if ((strcmp(ifix->style, "adapt/fep") == 0) && (comm->me == 0))
|
||||
error->warning(
|
||||
FLERR, "Fix adapt/fep may change atom radii but atom_style bpm/sphere is not dynamic");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
@ -45,7 +45,7 @@ class AtomVecBPMSphere : public AtomVec {
|
||||
int **nspecial;
|
||||
|
||||
double *radius, *rmass;
|
||||
double **omega, **torque, **quat;
|
||||
double **omega, **quat;
|
||||
|
||||
int any_bond_negative;
|
||||
int bond_per_atom;
|
||||
|
||||
@ -253,13 +253,13 @@ void PairBPMSpring::read_restart(FILE *fp)
|
||||
int me = comm->me;
|
||||
for (i = 1; i <= atom->ntypes; i++)
|
||||
for (j = i; j <= atom->ntypes; j++) {
|
||||
if (me == 0) fread(&setflag[i][j], sizeof(int), 1, fp);
|
||||
if (me == 0) utils::sfread(FLERR, &setflag[i][j], sizeof(int), 1, fp, nullptr, error);
|
||||
MPI_Bcast(&setflag[i][j], 1, MPI_INT, 0, world);
|
||||
if (setflag[i][j]) {
|
||||
if (me == 0) {
|
||||
fread(&k[i][j], sizeof(double), 1, fp);
|
||||
fread(&cut[i][j], sizeof(double), 1, fp);
|
||||
fread(&gamma[i][j], sizeof(double), 1, fp);
|
||||
utils::sfread(FLERR, &k[i][j], sizeof(double), 1, fp, nullptr, error);
|
||||
utils::sfread(FLERR, &cut[i][j], sizeof(double), 1, fp, nullptr, error);
|
||||
utils::sfread(FLERR, &gamma[i][j], sizeof(double), 1, fp, nullptr, error);
|
||||
}
|
||||
MPI_Bcast(&k[i][j], 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&cut[i][j], 1, MPI_DOUBLE, 0, world);
|
||||
|
||||
@ -33,18 +33,13 @@ AtomVecOxdna::AtomVecOxdna(LAMMPS *lmp) : AtomVec(lmp)
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "id5p";
|
||||
fields_copy = (char *) "id5p";
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "";
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "id5p";
|
||||
fields_border_vel = (char *) "";
|
||||
fields_exchange = (char *) "id5p";
|
||||
fields_restart = (char *) "id5p";
|
||||
fields_create = (char *) "";
|
||||
fields_data_atom = (char *) "id type x";
|
||||
fields_data_vel = (char *) "id v";
|
||||
fields_grow = {"id5p"};
|
||||
fields_copy = {"id5p"};
|
||||
fields_border = {"id5p"};
|
||||
fields_exchange = {"id5p"};
|
||||
fields_restart = {"id5p"};
|
||||
fields_data_atom = {"id", "type", "x"};
|
||||
fields_data_vel = {"id", "v"};
|
||||
|
||||
setup_fields();
|
||||
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/ Sandia National Laboratories
|
||||
@ -18,27 +17,25 @@
|
||||
#include "citeme.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
static const char cite_user_dielectric_package[] =
|
||||
"DIELECTRIC package:\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"
|
||||
" year = 2019,\n"
|
||||
" volume = 241,\n"
|
||||
" pages = {80--91}\n"
|
||||
"}\n\n"
|
||||
;
|
||||
"DIELECTRIC package:\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"
|
||||
" year = 2019,\n"
|
||||
" volume = 241,\n"
|
||||
" pages = {80--91}\n"
|
||||
"}\n\n";
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
AtomVecDielectric::AtomVecDielectric(LAMMPS *lmp) : AtomVec(lmp)
|
||||
AtomVecDielectric::AtomVecDielectric(LAMMPS *_lmp) : AtomVec(_lmp)
|
||||
{
|
||||
if (lmp->citeme) lmp->citeme->add(cite_user_dielectric_package);
|
||||
|
||||
@ -47,61 +44,46 @@ AtomVecDielectric::AtomVecDielectric(LAMMPS *lmp) : AtomVec(lmp)
|
||||
mass_type = PER_TYPE;
|
||||
|
||||
atom->molecule_flag = atom->q_flag = atom->mu_flag = 1;
|
||||
atom->dielectric_flag = 1;
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *)
|
||||
"q molecule num_bond bond_type bond_atom "
|
||||
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 "
|
||||
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 "
|
||||
"dihedral_atom3 dihedral_atom4 "
|
||||
"num_improper improper_type improper_atom1 improper_atom2 "
|
||||
"improper_atom3 improper_atom4 "
|
||||
"nspecial special "
|
||||
"mu area ed em epsilon curvature q_unscaled";
|
||||
fields_copy = (char *)
|
||||
"q molecule num_bond bond_type bond_atom "
|
||||
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 "
|
||||
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 "
|
||||
"dihedral_atom3 dihedral_atom4 "
|
||||
"num_improper improper_type improper_atom1 improper_atom2 "
|
||||
"improper_atom3 improper_atom4 "
|
||||
"nspecial special "
|
||||
"mu area ed em epsilon curvature q_unscaled";
|
||||
fields_comm = (char *) "q mu area ed em epsilon curvature q_unscaled";
|
||||
fields_comm_vel = (char *) "";
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "q molecule mu area ed em epsilon curvature q_unscaled";
|
||||
fields_border_vel = (char *) "q molecule mu area ed em epsilon curvature q_unscaled";
|
||||
fields_exchange = (char *)
|
||||
"q molecule num_bond bond_type bond_atom "
|
||||
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 "
|
||||
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 "
|
||||
"dihedral_atom3 dihedral_atom4 "
|
||||
"num_improper improper_type improper_atom1 improper_atom2 "
|
||||
"improper_atom3 improper_atom4 "
|
||||
"nspecial special "
|
||||
"mu area ed em epsilon curvature q_unscaled";
|
||||
fields_restart = (char *)
|
||||
"q molecule num_bond bond_type bond_atom "
|
||||
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 "
|
||||
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 "
|
||||
"dihedral_atom3 dihedral_atom4 "
|
||||
"num_improper improper_type improper_atom1 improper_atom2 "
|
||||
"improper_atom3 improper_atom4 "
|
||||
"mu area ed em epsilon curvature q_unscaled";
|
||||
fields_create = (char *)
|
||||
"q molecule num_bond num_angle num_dihedral num_improper nspecial "
|
||||
"mu area ed em epsilon curvature q_unscaled";
|
||||
fields_data_atom = (char *) "id molecule type q x "
|
||||
"mu3 area ed em epsilon curvature";
|
||||
fields_data_vel = (char *) "id v";
|
||||
// clang-format off
|
||||
fields_grow = {"q", "molecule", "num_bond", "bond_type", "bond_atom", "num_angle", "angle_type",
|
||||
"angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type", "dihedral_atom1",
|
||||
"dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper", "improper_type",
|
||||
"improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4", "nspecial", "special",
|
||||
"mu", "area", "ed", "em", "epsilon", "curvature", "q_unscaled"};
|
||||
fields_copy = {"q", "molecule", "num_bond", "bond_type", "bond_atom", "num_angle", "angle_type",
|
||||
"angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type", "dihedral_atom1",
|
||||
"dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper", "improper_type",
|
||||
"improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4", "nspecial", "special",
|
||||
"mu", "area", "ed", "em", "epsilon", "curvature", "q_unscaled"};
|
||||
fields_comm = {"q", "mu", "area", "ed", "em", "epsilon", "curvature", "q_unscaled"};
|
||||
fields_border = {"q", "molecule", "mu", "area", "ed", "em", "epsilon", "curvature", "q_unscaled"};
|
||||
fields_border_vel = {"q", "molecule", "mu", "area", "ed", "em", "epsilon", "curvature",
|
||||
"q_unscaled"};
|
||||
fields_exchange = {"q", "molecule", "num_bond", "bond_type", "bond_atom", "num_angle",
|
||||
"angle_type", "angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type",
|
||||
"dihedral_atom1", "dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper",
|
||||
"improper_type", "improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4",
|
||||
"nspecial", "special", "mu", "area", "ed", "em", "epsilon", "curvature", "q_unscaled"};
|
||||
fields_restart = {"q", "molecule", "num_bond", "bond_type", "bond_atom", "num_angle",
|
||||
"angle_type", "angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type",
|
||||
"dihedral_atom1", "dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper",
|
||||
"improper_type", "improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4",
|
||||
"mu", "area", "ed", "em", "epsilon", "curvature", "q_unscaled"};
|
||||
fields_create = {"q", "molecule", "num_bond", "num_angle", "num_dihedral", "num_improper",
|
||||
"nspecial", "mu", "area", "ed", "em", "epsilon", "curvature", "q_unscaled"};
|
||||
fields_data_atom = { "id", "molecule", "type", "q", "x", "mu3", "area", "ed", "em", "epsilon",
|
||||
"curvature"};
|
||||
fields_data_vel = {"id v"};
|
||||
// clang-format on
|
||||
|
||||
setup_fields();
|
||||
|
||||
bond_per_atom = angle_per_atom = dihedral_per_atom = improper_per_atom = 0;
|
||||
}
|
||||
|
||||
@ -157,13 +139,12 @@ void AtomVecDielectric::data_atom_post(int ilocal)
|
||||
nspecial[ilocal][1] = 0;
|
||||
nspecial[ilocal][2] = 0;
|
||||
|
||||
double* q = atom->q;
|
||||
double *q = atom->q;
|
||||
q_unscaled[ilocal] = q[ilocal];
|
||||
q[ilocal] /= epsilon[ilocal];
|
||||
|
||||
double *mu_one = mu[ilocal];
|
||||
mu_one[3] =
|
||||
sqrt(mu_one[0]*mu_one[0] + mu_one[1]*mu_one[1] + mu_one[2]*mu_one[2]);
|
||||
mu_one[3] = sqrt(mu_one[0] * mu_one[0] + mu_one[1] * mu_one[1] + mu_one[2] * mu_one[2]);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -182,14 +163,14 @@ void AtomVecDielectric::unpack_restart_init(int ilocal)
|
||||
return -1 if name is unknown to this atom style
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecDielectric::property_atom(char *name)
|
||||
int AtomVecDielectric::property_atom(const std::string &name)
|
||||
{
|
||||
if (strcmp(name,"area") == 0) return 0;
|
||||
if (strcmp(name,"ed") == 0) return 1;
|
||||
if (strcmp(name,"em") == 0) return 2;
|
||||
if (strcmp(name,"epsilon") == 0) return 3;
|
||||
if (strcmp(name,"curvature") == 0) return 4;
|
||||
if (strcmp(name,"q_unscaled") == 0) return 5;
|
||||
if (name == "area") return 0;
|
||||
if (name == "ed") return 1;
|
||||
if (name == "em") return 2;
|
||||
if (name == "epsilon") return 3;
|
||||
if (name == "curvature") return 4;
|
||||
if (name == "q_unscaled") return 5;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -198,8 +179,7 @@ int AtomVecDielectric::property_atom(char *name)
|
||||
index maps to data specific to this atom style
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecDielectric::pack_property_atom(int index, double *buf,
|
||||
int nvalues, int groupbit)
|
||||
void AtomVecDielectric::pack_property_atom(int index, double *buf, int nvalues, int groupbit)
|
||||
{
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
@ -207,38 +187,50 @@ void AtomVecDielectric::pack_property_atom(int index, double *buf,
|
||||
|
||||
if (index == 0) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = area[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = area[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
} else if (index == 1) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = ed[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = ed[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
} else if (index == 2) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = em[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = em[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
} else if (index == 3) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = epsilon[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = epsilon[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
} else if (index == 4) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = curvature[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = curvature[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
} else if (index == 5) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = q_unscaled[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = q_unscaled[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ class AtomVecDielectric : public AtomVec {
|
||||
void create_atom_post(int) override;
|
||||
void data_atom_post(int) override;
|
||||
void unpack_restart_init(int) override;
|
||||
int property_atom(char *) override;
|
||||
int property_atom(const std::string &) override;
|
||||
void pack_property_atom(int, double *, int, int) override;
|
||||
|
||||
protected:
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/ Sandia National Laboratories
|
||||
@ -39,10 +38,10 @@ using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeEfieldAtom::ComputeEfieldAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg), efield(nullptr)
|
||||
ComputeEfieldAtom::ComputeEfieldAtom(LAMMPS *_lmp, int narg, char **arg) :
|
||||
Compute(_lmp, narg, arg), efield(nullptr)
|
||||
{
|
||||
if (narg < 3) error->all(FLERR,"Illegal compute efield/atom command");
|
||||
if (narg < 3) error->all(FLERR, "Illegal compute efield/atom command");
|
||||
|
||||
peratom_flag = 1;
|
||||
size_peratom_cols = 3;
|
||||
@ -58,9 +57,12 @@ ComputeEfieldAtom::ComputeEfieldAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
} else {
|
||||
int iarg = 3;
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg],"pair") == 0) pairflag = 1;
|
||||
else if (strcmp(arg[iarg],"kspace") == 0) kspaceflag = 1;
|
||||
else error->all(FLERR,"Illegal compute efield/atom command");
|
||||
if (strcmp(arg[iarg], "pair") == 0)
|
||||
pairflag = 1;
|
||||
else if (strcmp(arg[iarg], "kspace") == 0)
|
||||
kspaceflag = 1;
|
||||
else
|
||||
error->all(FLERR, "Illegal compute efield/atom command");
|
||||
iarg++;
|
||||
}
|
||||
}
|
||||
@ -81,7 +83,7 @@ ComputeEfieldAtom::~ComputeEfieldAtom()
|
||||
|
||||
void ComputeEfieldAtom::init()
|
||||
{
|
||||
if (!atom->q_flag) error->all(FLERR,"compute efield/atom requires atom attribute q");
|
||||
if (!atom->q_flag) error->all(FLERR, "compute efield/atom requires atom attribute q");
|
||||
if (!force->kspace) kspaceflag = 0;
|
||||
}
|
||||
|
||||
@ -89,28 +91,30 @@ void ComputeEfieldAtom::init()
|
||||
|
||||
void ComputeEfieldAtom::setup()
|
||||
{
|
||||
if (strcmp(force->pair_style,"lj/cut/coul/long/dielectric") == 0)
|
||||
efield_pair = (dynamic_cast<PairLJCutCoulLongDielectric*>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style,"lj/cut/coul/long/dielectric/omp") == 0)
|
||||
efield_pair = (dynamic_cast<PairLJCutCoulMSMDielectric*>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style,"lj/cut/coul/msm/dielectric") == 0)
|
||||
efield_pair = (dynamic_cast<PairLJCutCoulMSMDielectric*>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style,"lj/cut/coul/cut/dielectric") == 0)
|
||||
efield_pair = (dynamic_cast<PairLJCutCoulCutDielectric*>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style,"lj/cut/coul/cut/dielectric/omp") == 0)
|
||||
efield_pair = (dynamic_cast<PairLJCutCoulCutDielectric*>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style,"coul/long/dielectric") == 0)
|
||||
efield_pair = (dynamic_cast<PairCoulLongDielectric*>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style,"coul/cut/dielectric") == 0)
|
||||
efield_pair = (dynamic_cast<PairCoulCutDielectric*>(force->pair))->efield;
|
||||
else error->all(FLERR,"Compute efield/atom not supported by pair style");
|
||||
if (strcmp(force->pair_style, "lj/cut/coul/long/dielectric") == 0)
|
||||
efield_pair = (dynamic_cast<PairLJCutCoulLongDielectric *>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style, "lj/cut/coul/long/dielectric/omp") == 0)
|
||||
efield_pair = (dynamic_cast<PairLJCutCoulMSMDielectric *>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style, "lj/cut/coul/msm/dielectric") == 0)
|
||||
efield_pair = (dynamic_cast<PairLJCutCoulMSMDielectric *>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style, "lj/cut/coul/cut/dielectric") == 0)
|
||||
efield_pair = (dynamic_cast<PairLJCutCoulCutDielectric *>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style, "lj/cut/coul/cut/dielectric/omp") == 0)
|
||||
efield_pair = (dynamic_cast<PairLJCutCoulCutDielectric *>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style, "coul/long/dielectric") == 0)
|
||||
efield_pair = (dynamic_cast<PairCoulLongDielectric *>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style, "coul/cut/dielectric") == 0)
|
||||
efield_pair = (dynamic_cast<PairCoulCutDielectric *>(force->pair))->efield;
|
||||
else
|
||||
error->all(FLERR, "Compute efield/atom not supported by pair style");
|
||||
|
||||
if (force->kspace) {
|
||||
if (strcmp(force->kspace_style,"pppm/dielectric") == 0)
|
||||
efield_kspace = (dynamic_cast<PPPMDielectric*>(force->kspace))->efield;
|
||||
else if (strcmp(force->kspace_style,"msm/dielectric") == 0)
|
||||
efield_kspace = (dynamic_cast<MSMDielectric*>(force->kspace))->efield;
|
||||
else error->all(FLERR,"Compute efield/atom not supported by kspace style");
|
||||
if (strcmp(force->kspace_style, "pppm/dielectric") == 0)
|
||||
efield_kspace = (dynamic_cast<PPPMDielectric *>(force->kspace))->efield;
|
||||
else if (strcmp(force->kspace_style, "msm/dielectric") == 0)
|
||||
efield_kspace = (dynamic_cast<MSMDielectric *>(force->kspace))->efield;
|
||||
else
|
||||
error->all(FLERR, "Compute efield/atom not supported by kspace style");
|
||||
kspaceflag = 1;
|
||||
}
|
||||
|
||||
@ -122,11 +126,11 @@ void ComputeEfieldAtom::setup()
|
||||
|
||||
void ComputeEfieldAtom::compute_peratom()
|
||||
{
|
||||
int i,j;
|
||||
int i, j;
|
||||
|
||||
invoked_peratom = update->ntimestep;
|
||||
if (update->vflag_atom != invoked_peratom)
|
||||
error->all(FLERR,"Per-atom virial was not tallied on needed timestep");
|
||||
error->all(FLERR, "Per-atom virial was not tallied on needed timestep");
|
||||
|
||||
// grow local stress array if necessary
|
||||
// needs to be atom->nmax in length
|
||||
@ -134,7 +138,7 @@ void ComputeEfieldAtom::compute_peratom()
|
||||
if (atom->nmax > nmax) {
|
||||
memory->destroy(efield);
|
||||
nmax = atom->nmax;
|
||||
memory->create(efield,nmax,3,"stress/atom:efield");
|
||||
memory->create(efield, nmax, 3, "stress/atom:efield");
|
||||
array_atom = efield;
|
||||
}
|
||||
|
||||
@ -144,7 +148,7 @@ void ComputeEfieldAtom::compute_peratom()
|
||||
// ntotal includes ghosts if either newton flag is set
|
||||
// KSpace includes ghosts if tip4pflag is set
|
||||
|
||||
double* q = atom->q;
|
||||
double *q = atom->q;
|
||||
int nlocal = atom->nlocal;
|
||||
int npair = nlocal;
|
||||
int ntotal = nlocal;
|
||||
@ -156,8 +160,7 @@ void ComputeEfieldAtom::compute_peratom()
|
||||
// clear local stress array
|
||||
|
||||
for (i = 0; i < ntotal; i++)
|
||||
for (j = 0; j < 3; j++)
|
||||
efield[i][j] = 0.0;
|
||||
for (j = 0; j < 3; j++) efield[i][j] = 0.0;
|
||||
|
||||
// add in per-atom contributions from each force
|
||||
|
||||
@ -170,14 +173,12 @@ void ComputeEfieldAtom::compute_peratom()
|
||||
|
||||
if (kspaceflag && force->kspace) {
|
||||
for (i = 0; i < nkspace; i++)
|
||||
for (j = 0; j < 3; j++)
|
||||
efield[i][j] += efield_kspace[i][j];
|
||||
for (j = 0; j < 3; j++) efield[i][j] += efield_kspace[i][j];
|
||||
}
|
||||
|
||||
// communicate ghost efield 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 efield of atoms not in group
|
||||
// only do this after comm since ghost contributions must be included
|
||||
@ -192,12 +193,11 @@ void ComputeEfieldAtom::compute_peratom()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int ComputeEfieldAtom::pack_reverse_comm(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
int i, m, last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
@ -213,7 +213,7 @@ int ComputeEfieldAtom::pack_reverse_comm(int n, int first, double *buf)
|
||||
|
||||
void ComputeEfieldAtom::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++) {
|
||||
@ -230,6 +230,6 @@ void ComputeEfieldAtom::unpack_reverse_comm(int n, int *list, double *buf)
|
||||
|
||||
double ComputeEfieldAtom::memory_usage()
|
||||
{
|
||||
double bytes = nmax*3 * sizeof(double);
|
||||
double bytes = nmax * 3 * sizeof(double);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
@ -48,6 +48,7 @@
|
||||
#include "pair_coul_cut_dielectric.h"
|
||||
#include "pair_coul_long_dielectric.h"
|
||||
#include "pair_lj_cut_coul_cut_dielectric.h"
|
||||
#include "pair_lj_cut_coul_debye_dielectric.h"
|
||||
#include "pair_lj_cut_coul_long_dielectric.h"
|
||||
#include "pair_lj_cut_coul_msm_dielectric.h"
|
||||
#include "pppm_dielectric.h"
|
||||
@ -59,14 +60,12 @@
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
using namespace MathConst;
|
||||
|
||||
//#define _POLARIZE_DEBUG
|
||||
using MathConst::MY_PI;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
FixPolarizeBEMGMRES::FixPolarizeBEMGMRES(LAMMPS *lmp, int narg, char **arg) :
|
||||
Fix(lmp, narg, arg), q_backup(nullptr), c(nullptr), g(nullptr), h(nullptr), r(nullptr),
|
||||
FixPolarizeBEMGMRES::FixPolarizeBEMGMRES(LAMMPS *_lmp, int narg, char **arg) :
|
||||
Fix(_lmp, narg, arg), q_backup(nullptr), c(nullptr), g(nullptr), h(nullptr), r(nullptr),
|
||||
s(nullptr), v(nullptr), y(nullptr)
|
||||
{
|
||||
if (narg < 5) error->all(FLERR, "Illegal fix polarize/bem/gmres command");
|
||||
@ -235,9 +234,7 @@ void FixPolarizeBEMGMRES::init()
|
||||
}
|
||||
|
||||
if (comm->me == 0)
|
||||
utils::logmesg(lmp,
|
||||
"GMRES solver for {} induced charges "
|
||||
"using maximum {} q-vectors\n",
|
||||
utils::logmesg(lmp, "GMRES solver for {} induced charges using maximum {} q-vectors\n",
|
||||
num_induced_charges, mr);
|
||||
}
|
||||
|
||||
@ -257,12 +254,16 @@ void FixPolarizeBEMGMRES::setup(int /*vflag*/)
|
||||
efield_pair = (dynamic_cast<PairLJCutCoulCutDielectric *>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style, "lj/cut/coul/cut/dielectric/omp") == 0)
|
||||
efield_pair = (dynamic_cast<PairLJCutCoulCutDielectric *>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style, "lj/cut/coul/debye/dielectric") == 0)
|
||||
efield_pair = (dynamic_cast<PairLJCutCoulDebyeDielectric *>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style, "lj/cut/coul/debye/dielectric/omp") == 0)
|
||||
efield_pair = (dynamic_cast<PairLJCutCoulDebyeDielectric *>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style, "coul/long/dielectric") == 0)
|
||||
efield_pair = (dynamic_cast<PairCoulLongDielectric *>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style, "coul/cut/dielectric") == 0)
|
||||
efield_pair = (dynamic_cast<PairCoulCutDielectric *>(force->pair))->efield;
|
||||
else
|
||||
error->all(FLERR, "Pair style not compatible with fix polarize");
|
||||
error->all(FLERR, "Pair style not compatible with fix polarize/bem/gmres");
|
||||
|
||||
if (kspaceflag) {
|
||||
if (force->kspace) {
|
||||
@ -276,6 +277,44 @@ void FixPolarizeBEMGMRES::setup(int /*vflag*/)
|
||||
error->all(FLERR, "No Kspace style available for fix polarize/bem/gmres");
|
||||
}
|
||||
|
||||
// NOTE: epsilon0e2q converts (epsilon0 * efield) to the unit of (charge unit / squared distance unit)
|
||||
// efield is computed by pair and kspace styles in the unit of energy unit / charge unit / distance unit
|
||||
// for units real efield is in the unit of kcal/mol/e/A
|
||||
// converting from (F/m) (kcal/mol/e/A) to e/A^2 (1 e = 1.6e-19 C, 1 m = 1e+10 A)
|
||||
// epsilon0e2q = 8.854187812813e-12 (C^2/N/m^2) * (4184 Nm/6.023e+23) /e/A
|
||||
// = 8.854187812813e-12 * (4184/6.023e+23) * (1/1.6e-19)^2 e^2 / (1e+10 A) /e/A
|
||||
// = 0.000240263377163643 e/A^2
|
||||
|
||||
// for units metal efield is in the unit of eV/e/A
|
||||
// converting from (F/m) (eV/e/A) to e/A^2 (1 V = 1 Nm/C)
|
||||
// epsilon0e2q = 8.854187812813e-12 (C^2/N/m^2) * (1 e Nm/C) /e/A
|
||||
// = 8.854187812813e-12 * 1/1.6e-19 e^2 / (1e+10 A) /e/A
|
||||
// = 0.00553386738300813 e/A^2
|
||||
|
||||
// for units si efield is in the unit of J/C/m
|
||||
// converting from (F/m) (J/C/m) to C/m^2
|
||||
// epsilon0e2q = 8.854187812813e-12 (C^2/N/m^2) * (1 Nm/C/m)
|
||||
// = 8.854187812813e-12 C/m^2
|
||||
|
||||
// for units nano efield is in the unit of attogram nm^2/ns^2/e/nm
|
||||
// converting from (F/m) (attogram nm^2/ns^2/e/nm) to e/nm^2
|
||||
// epsilon0e2q = 8.854187812813e-12 (C^2/N/m^2) * (1e-21 kg nm^2 / (1e-18s^2) / e / nm)
|
||||
// = 8.854187812813e-12 (C^2/N/m^2) * (1e-21 kg 1e-9 m / (1e-18s^2) / e)
|
||||
// = 8.854187812813e-12 (1/1.6e-19)^2 (1e-21 * 1e-9 / (1e-18)) e / (1e+18 nm^2)
|
||||
// = 0.000345866711328125 e/nm^2
|
||||
|
||||
epsilon0e2q = 1.0;
|
||||
if (strcmp(update->unit_style, "real") == 0)
|
||||
epsilon0e2q = 0.000240263377163643;
|
||||
else if (strcmp(update->unit_style, "metal") == 0)
|
||||
epsilon0e2q = 0.00553386738300813;
|
||||
else if (strcmp(update->unit_style, "si") == 0)
|
||||
epsilon0e2q = 8.854187812813e-12;
|
||||
else if (strcmp(update->unit_style, "nano") == 0)
|
||||
epsilon0e2q = 0.000345866711328125;
|
||||
else if (strcmp(update->unit_style, "lj") != 0)
|
||||
error->all(FLERR, "Only unit styles 'lj', 'real', 'metal', 'si' and 'nano' are supported");
|
||||
|
||||
first = 1;
|
||||
compute_induced_charges();
|
||||
}
|
||||
@ -306,7 +345,6 @@ void FixPolarizeBEMGMRES::compute_induced_charges()
|
||||
double *em = atom->em;
|
||||
double *epsilon = atom->epsilon;
|
||||
int nlocal = atom->nlocal;
|
||||
double epsilon0 = force->dielectric;
|
||||
int eflag = 0;
|
||||
int vflag = 0;
|
||||
|
||||
@ -354,9 +392,9 @@ void FixPolarizeBEMGMRES::compute_induced_charges()
|
||||
Ey += efield_kspace[i][1];
|
||||
Ez += efield_kspace[i][2];
|
||||
}
|
||||
double dot = (Ex * norm[i][0] + Ey * norm[i][1] + Ez * norm[i][2]) / epsilon[i];
|
||||
double ndotE = epsilon0e2q * (Ex * norm[i][0] + Ey * norm[i][1] + Ez * norm[i][2]) / epsilon[i];
|
||||
double sigma_f = q_real[i] / area[i];
|
||||
buffer[idx] = (1 - em[i]) * sigma_f - epsilon0 * ed[i] * dot / (4 * MY_PI);
|
||||
buffer[idx] = (1 - em[i]) * sigma_f - ed[i] * ndotE / (4 * MY_PI);
|
||||
}
|
||||
|
||||
MPI_Allreduce(buffer, rhs, num_induced_charges, MPI_DOUBLE, MPI_SUM, world);
|
||||
@ -519,10 +557,6 @@ void FixPolarizeBEMGMRES::gmres_solve(double *x, double *r)
|
||||
|
||||
rho = fabs(g[k]);
|
||||
|
||||
#ifdef _POLARIZE_DEBUG
|
||||
if (comm->me == 0)
|
||||
error->warning(FLERR, "itr = {}: k = {}, norm(r) = {} norm(b) = {}", itr, k, rho, normb);
|
||||
#endif
|
||||
if (rho <= rho_tol && rho <= tol_abs) break;
|
||||
}
|
||||
|
||||
@ -552,11 +586,6 @@ void FixPolarizeBEMGMRES::gmres_solve(double *x, double *r)
|
||||
|
||||
rho = sqrt(vec_dot(r, r, n));
|
||||
|
||||
#ifdef _POLARIZE_DEBUG
|
||||
if (comm->me == 0)
|
||||
error->warning(FLERR, "itr = {}: norm(r) = {} norm(b) = {}", itr, rho, normb);
|
||||
#endif
|
||||
|
||||
// Barros et al. suggested the condition: norm(r) < EPSILON norm(b)
|
||||
|
||||
if (rho < tol_rel * normb) break;
|
||||
@ -584,7 +613,6 @@ void FixPolarizeBEMGMRES::apply_operator(double *w, double *Aw, int /*n*/)
|
||||
double *em = atom->em;
|
||||
double *epsilon = atom->epsilon;
|
||||
int nlocal = atom->nlocal;
|
||||
double epsilon0 = force->dielectric;
|
||||
int eflag = 0;
|
||||
int vflag = 0;
|
||||
|
||||
@ -629,8 +657,8 @@ void FixPolarizeBEMGMRES::apply_operator(double *w, double *Aw, int /*n*/)
|
||||
Ey += efield_kspace[i][1];
|
||||
Ez += efield_kspace[i][2];
|
||||
}
|
||||
double dot = (Ex * norm[i][0] + Ey * norm[i][1] + Ez * norm[i][2]) / epsilon[i];
|
||||
buffer[idx] = em[i] * w[idx] + epsilon0 * ed[i] * dot / (4 * MY_PI);
|
||||
double ndotE = epsilon0e2q * (Ex * norm[i][0] + Ey * norm[i][1] + Ez * norm[i][2]) / epsilon[i];
|
||||
buffer[idx] = em[i] * w[idx] + ed[i] * ndotE / (4 * MY_PI);
|
||||
}
|
||||
|
||||
MPI_Allreduce(buffer, Aw, num_induced_charges, MPI_DOUBLE, MPI_SUM, world);
|
||||
@ -654,7 +682,6 @@ void FixPolarizeBEMGMRES::update_residual(double *w, double *r, int /*n*/)
|
||||
double *em = atom->em;
|
||||
double *epsilon = atom->epsilon;
|
||||
int nlocal = atom->nlocal;
|
||||
double epsilon0 = force->dielectric;
|
||||
int eflag = 0;
|
||||
int vflag = 0;
|
||||
|
||||
@ -701,9 +728,10 @@ void FixPolarizeBEMGMRES::update_residual(double *w, double *r, int /*n*/)
|
||||
Ey += efield_kspace[i][1];
|
||||
Ez += efield_kspace[i][2];
|
||||
}
|
||||
double dot = (Ex * norm[i][0] + Ey * norm[i][1] + Ez * norm[i][2]) / epsilon[i];
|
||||
double ndotE = epsilon0e2q * (Ex * norm[i][0] + Ey * norm[i][1] + Ez * norm[i][2]) /
|
||||
epsilon[i] / (4 * MY_PI);
|
||||
double sigma_f = q_real[i] / area[i];
|
||||
buffer[idx] = (1 - em[i]) * sigma_f - em[i] * w[idx] - epsilon0 * ed[i] * dot / (4 * MY_PI);
|
||||
buffer[idx] = (1 - em[i]) * sigma_f - em[i] * w[idx] - ed[i] * ndotE;
|
||||
}
|
||||
|
||||
MPI_Allreduce(buffer, r, num_induced_charges, MPI_DOUBLE, MPI_SUM, world);
|
||||
|
||||
@ -81,6 +81,7 @@ class FixPolarizeBEMGMRES : public Fix {
|
||||
int randomized; // 1 if generating random induced charges, 0 otherwise
|
||||
double ave_charge; // average random charge
|
||||
int seed_charge;
|
||||
double epsilon0e2q; // convert epsilon0 times efield to unit of charge per area
|
||||
|
||||
double *c, *g, *h, *r, *s, *v, *y; // vectors used by the solver
|
||||
double *rhs; // right-hand side vector of the equation Ax = b
|
||||
|
||||
@ -37,6 +37,7 @@
|
||||
#include "pair_coul_cut_dielectric.h"
|
||||
#include "pair_coul_long_dielectric.h"
|
||||
#include "pair_lj_cut_coul_cut_dielectric.h"
|
||||
#include "pair_lj_cut_coul_debye_dielectric.h"
|
||||
#include "pair_lj_cut_coul_long_dielectric.h"
|
||||
#include "pair_lj_cut_coul_msm_dielectric.h"
|
||||
#include "pppm_dielectric.h"
|
||||
@ -48,13 +49,11 @@
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
using namespace MathConst;
|
||||
|
||||
//#define _POLARIZE_DEBUG
|
||||
using MathConst::MY_PI;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
FixPolarizeBEMICC::FixPolarizeBEMICC(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
|
||||
FixPolarizeBEMICC::FixPolarizeBEMICC(LAMMPS *_lmp, int narg, char **arg) : Fix(_lmp, narg, arg)
|
||||
{
|
||||
if (narg < 5) error->all(FLERR, "Illegal fix polarize/bem/icc command");
|
||||
|
||||
@ -155,6 +154,10 @@ void FixPolarizeBEMICC::setup(int /*vflag*/)
|
||||
efield_pair = (dynamic_cast<PairLJCutCoulCutDielectric *>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style, "lj/cut/coul/cut/dielectric/omp") == 0)
|
||||
efield_pair = (dynamic_cast<PairLJCutCoulCutDielectric *>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style, "lj/cut/coul/debye/dielectric") == 0)
|
||||
efield_pair = (dynamic_cast<PairLJCutCoulDebyeDielectric *>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style, "lj/cut/coul/debye/dielectric/omp") == 0)
|
||||
efield_pair = (dynamic_cast<PairLJCutCoulDebyeDielectric *>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style, "coul/long/dielectric") == 0)
|
||||
efield_pair = (dynamic_cast<PairCoulLongDielectric *>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style, "coul/cut/dielectric") == 0)
|
||||
@ -165,7 +168,6 @@ void FixPolarizeBEMICC::setup(int /*vflag*/)
|
||||
// check if kspace is used for force computation
|
||||
|
||||
if (force->kspace) {
|
||||
|
||||
kspaceflag = 1;
|
||||
if (strcmp(force->kspace_style, "pppm/dielectric") == 0)
|
||||
efield_kspace = (dynamic_cast<PPPMDielectric *>(force->kspace))->efield;
|
||||
@ -175,13 +177,50 @@ void FixPolarizeBEMICC::setup(int /*vflag*/)
|
||||
error->all(FLERR, "Kspace style not compatible with fix polarize/bem/icc");
|
||||
|
||||
} else {
|
||||
|
||||
if (kspaceflag == 1) { // users specified kspace yes
|
||||
error->warning(FLERR, "No Kspace style available for fix polarize/bem/icc");
|
||||
kspaceflag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: epsilon0e2q converts (epsilon0 * efield) to the unit of (charge unit / squared distance unit)
|
||||
// efield is computed by pair and kspace styles in the unit of energy unit / charge unit / distance unit
|
||||
// for units real efield is in the unit of kcal/mol/e/A
|
||||
// converting from (F/m) (kcal/mol/e/A) to e/A^2 (1 e = 1.6e-19 C, 1 m = 1e+10 A)
|
||||
// epsilon0e2q = 8.854187812813e-12 (C^2/N/m^2) * (4184 Nm/6.023e+23) /e/A
|
||||
// = 8.854187812813e-12 * (4184/6.023e+23) * (1/1.6e-19)^2 e^2 / (1e+10 A) /e/A
|
||||
// = 0.000240263377163643 e/A^2
|
||||
|
||||
// for units metal efield is in the unit of eV/e/A
|
||||
// converting from (F/m) (eV/e/A) to e/A^2 (1 V = 1 Nm/C)
|
||||
// epsilon0e2q = 8.854187812813e-12 (C^2/N/m^2) * (1 e Nm/C) /e/A
|
||||
// = 8.854187812813e-12 * 1/1.6e-19 e^2 / (1e+10 A) /e/A
|
||||
// = 0.00553386738300813 e/A^2
|
||||
|
||||
// for units si efield is in the unit of J/C/m
|
||||
// converting from (F/m) (J/C/m) to C/m^2
|
||||
// epsilon0e2q = 8.854187812813e-12 (C^2/N/m^2) * (1 Nm/C/m)
|
||||
// = 8.854187812813e-12 C/m^2
|
||||
|
||||
// for units nano efield is in the unit of attogram nm^2/ns^2/e/nm
|
||||
// converting from (F/m) (attogram nm^2/ns^2/e/nm) to e/nm^2
|
||||
// epsilon0e2q = 8.854187812813e-12 (C^2/N/m^2) * (1e-21 kg nm^2 / (1e-18s^2) / e / nm)
|
||||
// = 8.854187812813e-12 (C^2/N/m^2) * (1e-21 kg 1e-9 m / (1e-18s^2) / e)
|
||||
// = 8.854187812813e-12 (1/1.6e-19)^2 (1e-21 * 1e-9 / (1e-18)) e / (1e+18 nm^2)
|
||||
// = 0.000345866711328125 e/nm^2
|
||||
|
||||
epsilon0e2q = 1.0;
|
||||
if (strcmp(update->unit_style, "real") == 0)
|
||||
epsilon0e2q = 0.000240263377163643;
|
||||
else if (strcmp(update->unit_style, "metal") == 0)
|
||||
epsilon0e2q = 0.00553386738300813;
|
||||
else if (strcmp(update->unit_style, "si") == 0)
|
||||
epsilon0e2q = 8.854187812813e-12;
|
||||
else if (strcmp(update->unit_style, "nano") == 0)
|
||||
epsilon0e2q = 0.000345866711328125;
|
||||
else if (strcmp(update->unit_style, "lj") != 0)
|
||||
error->all(FLERR, "Only unit styles 'lj', 'real', 'metal', 'si' and 'nano' are supported");
|
||||
|
||||
compute_induced_charges();
|
||||
}
|
||||
|
||||
@ -212,7 +251,6 @@ void FixPolarizeBEMICC::compute_induced_charges()
|
||||
double *epsilon = atom->epsilon;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
double epsilon0 = force->dielectric;
|
||||
int eflag = 1;
|
||||
int vflag = 0;
|
||||
int itr;
|
||||
@ -244,10 +282,11 @@ void FixPolarizeBEMICC::compute_induced_charges()
|
||||
}
|
||||
|
||||
// divide (Ex,Ey,Ez) by epsilon[i] here
|
||||
double dot = (Ex * norm[i][0] + Ey * norm[i][1] + Ez * norm[i][2]) / (2 * MY_PI) / epsilon[i];
|
||||
double ndotE = epsilon0e2q * (Ex * norm[i][0] + Ey * norm[i][1] + Ez * norm[i][2]) /
|
||||
epsilon[i] / (2 * MY_PI);
|
||||
double q_free = q_real[i];
|
||||
double q_bound = 0;
|
||||
q_bound = (1.0 / em[i] - 1) * q_free - epsilon0 * (ed[i] / (2 * em[i])) * dot * area[i];
|
||||
q_bound = (1.0 / em[i] - 1) * q_free - (ed[i] / (2 * em[i])) * ndotE * area[i];
|
||||
q[i] = q_free + q_bound;
|
||||
}
|
||||
|
||||
@ -281,10 +320,11 @@ void FixPolarizeBEMICC::compute_induced_charges()
|
||||
// note the area[i] is included here to ensure correct charge unit
|
||||
// for direct use in force/efield compute
|
||||
|
||||
double dot = (Ex * norm[i][0] + Ey * norm[i][1] + Ez * norm[i][2]) / (4 * MY_PI) / epsilon[i];
|
||||
double ndotE = epsilon0e2q * (Ex * norm[i][0] + Ey * norm[i][1] + Ez * norm[i][2]) /
|
||||
(4 * MY_PI) / epsilon[i];
|
||||
double q_bound = q[i] - q_free;
|
||||
q_bound = (1 - omega) * q_bound +
|
||||
omega * ((1.0 / em[i] - 1) * q_free - epsilon0 * (ed[i] / em[i]) * dot * area[i]);
|
||||
omega * ((1.0 / em[i] - 1) * q_free - (ed[i] / em[i]) * ndotE * area[i]);
|
||||
q[i] = q_free + q_bound;
|
||||
|
||||
// Eq. (11) in Tyagi et al., with f from Eq. (6)
|
||||
@ -303,18 +343,11 @@ void FixPolarizeBEMICC::compute_induced_charges()
|
||||
double delta = fabs(qtmp - q_bound);
|
||||
double r = (fabs(qtmp) > 0) ? delta / fabs(qtmp) : 0;
|
||||
if (tol < r) tol = r;
|
||||
|
||||
#ifdef _POLARIZE_DEBUG
|
||||
//printf("i = %d: q_bound = %f \n", i, q_bound);
|
||||
#endif
|
||||
}
|
||||
|
||||
comm->forward_comm(this);
|
||||
|
||||
MPI_Allreduce(&tol, &rho, 1, MPI_DOUBLE, MPI_MAX, world);
|
||||
#ifdef _POLARIZE_DEBUG
|
||||
printf("itr = %d: rho = %f\n", itr, rho);
|
||||
#endif
|
||||
if (itr > 0 && rho < tol_rel) break;
|
||||
}
|
||||
|
||||
|
||||
@ -60,6 +60,7 @@ class FixPolarizeBEMICC : public Fix {
|
||||
int randomized; // 1 if generating random induced charges, 0 otherwise
|
||||
double ave_charge; // average random charge
|
||||
int seed_charge;
|
||||
double epsilon0e2q; // convert epsilon0 times efield to unit of charge per area
|
||||
};
|
||||
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
@ -44,6 +44,7 @@
|
||||
#include "pair_coul_cut_dielectric.h"
|
||||
#include "pair_coul_long_dielectric.h"
|
||||
#include "pair_lj_cut_coul_cut_dielectric.h"
|
||||
#include "pair_lj_cut_coul_debye_dielectric.h"
|
||||
#include "pair_lj_cut_coul_long_dielectric.h"
|
||||
#include "pair_lj_cut_coul_msm_dielectric.h"
|
||||
#include "pppm_dielectric.h"
|
||||
@ -60,14 +61,12 @@ using namespace MathSpecial;
|
||||
|
||||
enum { REAL2SCALED = 0, SCALED2REAL = 1 };
|
||||
|
||||
#define EPSILON 1e-6
|
||||
|
||||
//#define _POLARIZE_DEBUG
|
||||
static constexpr double EPSILON = 1.0e-6;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
FixPolarizeFunctional::FixPolarizeFunctional(LAMMPS *lmp, int narg, char **arg) :
|
||||
Fix(lmp, narg, arg)
|
||||
FixPolarizeFunctional::FixPolarizeFunctional(LAMMPS *_lmp, int narg, char **arg) :
|
||||
Fix(_lmp, narg, arg)
|
||||
{
|
||||
if (narg < 4) error->all(FLERR, "Illegal fix polarize/functional command");
|
||||
|
||||
@ -299,6 +298,10 @@ void FixPolarizeFunctional::setup(int /*vflag*/)
|
||||
efield_pair = (dynamic_cast<PairLJCutCoulCutDielectric *>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style, "lj/cut/coul/cut/dielectric/omp") == 0)
|
||||
efield_pair = (dynamic_cast<PairLJCutCoulCutDielectric *>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style, "lj/cut/coul/debye/dielectric") == 0)
|
||||
efield_pair = (dynamic_cast<PairLJCutCoulDebyeDielectric *>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style, "lj/cut/coul/debye/dielectric/omp") == 0)
|
||||
efield_pair = (dynamic_cast<PairLJCutCoulDebyeDielectric *>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style, "coul/long/dielectric") == 0)
|
||||
efield_pair = (dynamic_cast<PairCoulLongDielectric *>(force->pair))->efield;
|
||||
else if (strcmp(force->pair_style, "coul/cut/dielectric") == 0)
|
||||
@ -804,16 +807,6 @@ void FixPolarizeFunctional::calculate_Rww_cutoff()
|
||||
|
||||
MPI_Allreduce(buffer1[0], Rww[0], num_induced_charges * num_induced_charges, MPI_DOUBLE, MPI_SUM,
|
||||
world);
|
||||
|
||||
#ifdef _POLARIZE_DEBUG
|
||||
if (comm->me == 0) {
|
||||
FILE *fp = fopen("Rww-functional.txt", "w");
|
||||
for (int i = 0; i < num_induced_charges; i++)
|
||||
fprintf(fp, "%d %g %g %g\n", i, Rww[i][i], Rww[i][num_induced_charges / 2],
|
||||
Rww[num_induced_charges / 2][i]);
|
||||
fclose(fp);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -34,7 +34,7 @@ enum{REVERSE_RHO,REVERSE_AD,REVERSE_AD_PERATOM};
|
||||
enum{FORWARD_RHO,FORWARD_AD,FORWARD_AD_PERATOM};
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
MSMDielectric::MSMDielectric(LAMMPS *lmp) : MSM(lmp)
|
||||
MSMDielectric::MSMDielectric(LAMMPS *_lmp) : MSM(_lmp)
|
||||
{
|
||||
efield = nullptr;
|
||||
phi = nullptr;
|
||||
|
||||
@ -29,13 +29,13 @@
|
||||
#include <cmath>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
using MathConst::MY_PIS;
|
||||
|
||||
#define EPSILON 1e-6
|
||||
static constexpr double EPSILON = 1.0e-6;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PairCoulCutDielectric::PairCoulCutDielectric(LAMMPS *lmp) : PairCoulCut(lmp)
|
||||
PairCoulCutDielectric::PairCoulCutDielectric(LAMMPS *_lmp) : PairCoulCut(_lmp)
|
||||
{
|
||||
efield = nullptr;
|
||||
nmax = 0;
|
||||
@ -124,7 +124,7 @@ void PairCoulCutDielectric::compute(int eflag, int vflag)
|
||||
if (rsq < cutsq[itype][jtype] && rsq > EPSILON) {
|
||||
r2inv = 1.0 / rsq;
|
||||
rinv = sqrt(r2inv);
|
||||
efield_i = scale[itype][jtype] * q[j] * rinv;
|
||||
efield_i = qqrd2e * scale[itype][jtype] * q[j] * rinv;
|
||||
forcecoul = qtmp * efield_i;
|
||||
|
||||
fpair_i = factor_coul * etmp * forcecoul * r2inv;
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
#include "atom.h"
|
||||
#include "atom_vec_dielectric.h"
|
||||
#include "error.h"
|
||||
#include "ewald_const.h"
|
||||
#include "force.h"
|
||||
#include "kspace.h"
|
||||
#include "math_const.h"
|
||||
@ -30,19 +31,12 @@
|
||||
#include <cmath>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
|
||||
#define EWALD_F 1.12837917
|
||||
#define EWALD_P 0.3275911
|
||||
#define A1 0.254829592
|
||||
#define A2 -0.284496736
|
||||
#define A3 1.421413741
|
||||
#define A4 -1.453152027
|
||||
#define A5 1.061405429
|
||||
using namespace EwaldConst;
|
||||
using MathConst::MY_PIS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PairCoulLongDielectric::PairCoulLongDielectric(LAMMPS *lmp) : PairCoulLong(lmp)
|
||||
PairCoulLongDielectric::PairCoulLongDielectric(LAMMPS *_lmp) : PairCoulLong(_lmp)
|
||||
{
|
||||
efield = nullptr;
|
||||
nmax = 0;
|
||||
|
||||
@ -29,13 +29,13 @@
|
||||
#include <cmath>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
using MathConst::MY_PIS;
|
||||
|
||||
#define EPSILON 1e-6
|
||||
static constexpr double EPSILON = 1.0e-6;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PairLJCutCoulCutDielectric::PairLJCutCoulCutDielectric(LAMMPS *lmp) : PairLJCutCoulCut(lmp)
|
||||
PairLJCutCoulCutDielectric::PairLJCutCoulCutDielectric(LAMMPS *_lmp) : PairLJCutCoulCut(_lmp)
|
||||
{
|
||||
efield = nullptr;
|
||||
epot = nullptr;
|
||||
@ -132,8 +132,8 @@ void PairLJCutCoulCutDielectric::compute(int eflag, int vflag)
|
||||
r2inv = 1.0 / rsq;
|
||||
|
||||
if (rsq < cut_coulsq[itype][jtype] && rsq > EPSILON) {
|
||||
efield_i = q[j] * sqrt(r2inv);
|
||||
forcecoul = qqrd2e * qtmp * efield_i;
|
||||
efield_i = qqrd2e * q[j] * sqrt(r2inv);
|
||||
forcecoul = qtmp * efield_i;
|
||||
epot_i = efield_i;
|
||||
} else
|
||||
epot_i = efield_i = forcecoul = 0.0;
|
||||
|
||||
@ -29,13 +29,13 @@
|
||||
#include <cmath>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
using MathConst::MY_PIS;
|
||||
|
||||
#define EPSILON 1e-6
|
||||
static constexpr double EPSILON = 1.0e-6;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PairLJCutCoulDebyeDielectric::PairLJCutCoulDebyeDielectric(LAMMPS *lmp) : PairLJCutCoulDebye(lmp)
|
||||
PairLJCutCoulDebyeDielectric::PairLJCutCoulDebyeDielectric(LAMMPS *_lmp) : PairLJCutCoulDebye(_lmp)
|
||||
{
|
||||
efield = nullptr;
|
||||
epot = nullptr;
|
||||
@ -75,10 +75,10 @@ void PairLJCutCoulDebyeDielectric::compute(int eflag, int vflag)
|
||||
double **x = atom->x;
|
||||
double **f = atom->f;
|
||||
double *q = atom->q;
|
||||
double *eps = avec->epsilon;
|
||||
double **norm = avec->mu;
|
||||
double *curvature = avec->curvature;
|
||||
double *area = avec->area;
|
||||
double *eps = atom->epsilon;
|
||||
double **norm = atom->mu;
|
||||
double *curvature = atom->curvature;
|
||||
double *area = atom->area;
|
||||
int *type = atom->type;
|
||||
int nlocal = atom->nlocal;
|
||||
double *special_coul = force->special_coul;
|
||||
@ -140,7 +140,7 @@ void PairLJCutCoulDebyeDielectric::compute(int eflag, int vflag)
|
||||
forcecoul = qtmp * efield_i;
|
||||
epot_i = efield_i;
|
||||
} else
|
||||
efield_i = forcecoul = 0.0;
|
||||
epot_i = efield_i = forcecoul = 0.0;
|
||||
|
||||
if (rsq < cut_ljsq[itype][jtype]) {
|
||||
r6inv = r2inv * r2inv * r2inv;
|
||||
@ -157,7 +157,6 @@ void PairLJCutCoulDebyeDielectric::compute(int eflag, int vflag)
|
||||
efield[i][0] += delx * efield_i;
|
||||
efield[i][1] += dely * efield_i;
|
||||
efield[i][2] += delz * efield_i;
|
||||
|
||||
epot[i] += epot_i;
|
||||
|
||||
if (newton_pair && j >= nlocal) {
|
||||
@ -207,7 +206,7 @@ double PairLJCutCoulDebyeDielectric::single(int i, int j, int itype, int jtype,
|
||||
{
|
||||
double r2inv, r6inv, forcecoul, forcelj, phicoul, ei, ej, philj;
|
||||
double r, rinv, screening;
|
||||
double *eps = avec->epsilon;
|
||||
double *eps = atom->epsilon;
|
||||
|
||||
r2inv = 1.0 / rsq;
|
||||
if (rsq < cut_coulsq[itype][jtype]) {
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
#include "atom.h"
|
||||
#include "atom_vec_dielectric.h"
|
||||
#include "error.h"
|
||||
#include "ewald_const.h"
|
||||
#include "force.h"
|
||||
#include "kspace.h"
|
||||
#include "math_const.h"
|
||||
@ -30,21 +31,14 @@
|
||||
#include <cmath>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
using namespace EwaldConst;
|
||||
using MathConst::MY_PIS;
|
||||
|
||||
#define EWALD_F 1.12837917
|
||||
#define EWALD_P 0.3275911
|
||||
#define A1 0.254829592
|
||||
#define A2 -0.284496736
|
||||
#define A3 1.421413741
|
||||
#define A4 -1.453152027
|
||||
#define A5 1.061405429
|
||||
|
||||
#define EPSILON 1e-6
|
||||
static constexpr double EPSILON = 1.0e-6;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PairLJCutCoulLongDielectric::PairLJCutCoulLongDielectric(LAMMPS *lmp) : PairLJCutCoulLong(lmp)
|
||||
PairLJCutCoulLongDielectric::PairLJCutCoulLongDielectric(LAMMPS *_lmp) : PairLJCutCoulLong(_lmp)
|
||||
{
|
||||
respa_enable = 0;
|
||||
cut_respa = nullptr;
|
||||
@ -158,7 +152,7 @@ void PairLJCutCoulLongDielectric::compute(int eflag, int vflag)
|
||||
forcecoul = prefactor * (erfc + EWALD_F * grij * expm2);
|
||||
if (factor_coul < 1.0) forcecoul -= (1.0 - factor_coul) * prefactor;
|
||||
|
||||
prefactorE = q[j] / r;
|
||||
prefactorE = qqrd2e * q[j] / r;
|
||||
efield_i = prefactorE * (erfc + EWALD_F * grij * expm2);
|
||||
if (factor_coul < 1.0) efield_i -= (1.0 - factor_coul) * prefactorE;
|
||||
epot_i = efield_i;
|
||||
@ -170,13 +164,13 @@ void PairLJCutCoulLongDielectric::compute(int eflag, int vflag)
|
||||
fraction = (rsq_lookup.f - rtable[itable]) * drtable[itable];
|
||||
table = ftable[itable] + fraction * dftable[itable];
|
||||
forcecoul = qtmp * q[j] * table;
|
||||
efield_i = q[j] * table / qqrd2e;
|
||||
efield_i = q[j] * table;
|
||||
if (factor_coul < 1.0) {
|
||||
table = ctable[itable] + fraction * dctable[itable];
|
||||
prefactor = qtmp * q[j] * table;
|
||||
forcecoul -= (1.0 - factor_coul) * prefactor;
|
||||
|
||||
prefactorE = q[j] * table / qqrd2e;
|
||||
prefactorE = q[j] * table;
|
||||
efield_i -= (1.0 - factor_coul) * prefactorE;
|
||||
}
|
||||
epot_i = efield_i;
|
||||
|
||||
@ -31,13 +31,13 @@
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
using MathConst::MY_PIS;
|
||||
|
||||
#define EPSILON 1e-6
|
||||
static constexpr double EPSILON = 1.0e-6;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PairLJCutCoulMSMDielectric::PairLJCutCoulMSMDielectric(LAMMPS *lmp) : PairLJCutCoulLong(lmp)
|
||||
PairLJCutCoulMSMDielectric::PairLJCutCoulMSMDielectric(LAMMPS *_lmp) : PairLJCutCoulLong(_lmp)
|
||||
{
|
||||
ewaldflag = pppmflag = 0;
|
||||
msmflag = 1;
|
||||
@ -165,7 +165,7 @@ void PairLJCutCoulMSMDielectric::compute(int eflag, int vflag)
|
||||
forcecoul = prefactor * fgamma;
|
||||
if (factor_coul < 1.0) forcecoul -= (1.0 - factor_coul) * prefactor;
|
||||
|
||||
prefactorE = q[j] / r;
|
||||
prefactorE = qqrd2e * q[j] / r;
|
||||
efield_i = prefactorE * fgamma;
|
||||
if (factor_coul < 1.0) efield_i -= (1.0 - factor_coul) * prefactorE;
|
||||
|
||||
@ -177,13 +177,13 @@ void PairLJCutCoulMSMDielectric::compute(int eflag, int vflag)
|
||||
fraction = (rsq_lookup.f - rtable[itable]) * drtable[itable];
|
||||
table = ftable[itable] + fraction * dftable[itable];
|
||||
forcecoul = qtmp * q[j] * table;
|
||||
efield_i = q[j] * table / qqrd2e;
|
||||
efield_i = q[j] * table;
|
||||
if (factor_coul < 1.0) {
|
||||
table = ctable[itable] + fraction * dctable[itable];
|
||||
prefactor = qtmp * q[j] * table;
|
||||
forcecoul -= (1.0 - factor_coul) * prefactor;
|
||||
|
||||
prefactorE = q[j] * table / qqrd2e;
|
||||
prefactorE = q[j] * table;
|
||||
efield_i -= (1.0 - factor_coul) * prefactorE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
#include "atom.h"
|
||||
#include "atom_vec_dielectric.h"
|
||||
#include "error.h"
|
||||
#include "ewald_const.h"
|
||||
#include "force.h"
|
||||
#include "math_const.h"
|
||||
#include "math_extra.h"
|
||||
@ -31,20 +32,13 @@
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
using namespace EwaldConst;
|
||||
using MathConst::MY_PIS;
|
||||
using namespace MathExtra;
|
||||
|
||||
#define EWALD_F 1.12837917
|
||||
#define EWALD_P 0.3275911
|
||||
#define A1 0.254829592
|
||||
#define A2 -0.284496736
|
||||
#define A3 1.421413741
|
||||
#define A4 -1.453152027
|
||||
#define A5 1.061405429
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PairLJLongCoulLongDielectric::PairLJLongCoulLongDielectric(LAMMPS *lmp) : PairLJLongCoulLong(lmp)
|
||||
PairLJLongCoulLongDielectric::PairLJLongCoulLongDielectric(LAMMPS *_lmp) : PairLJLongCoulLong(_lmp)
|
||||
{
|
||||
respa_enable = 0;
|
||||
cut_respa = nullptr;
|
||||
|
||||
@ -50,7 +50,7 @@ enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PPPMDielectric::PPPMDielectric(LAMMPS *lmp) : PPPM(lmp)
|
||||
PPPMDielectric::PPPMDielectric(LAMMPS *_lmp) : PPPM(_lmp)
|
||||
{
|
||||
group_group_enable = 0;
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM,
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PPPMDispDielectric::PPPMDispDielectric(LAMMPS *lmp) : PPPMDisp(lmp)
|
||||
PPPMDispDielectric::PPPMDispDielectric(LAMMPS *_lmp) : PPPMDisp(_lmp)
|
||||
{
|
||||
dipoleflag = 0; // turned off for now, until dipole works
|
||||
group_group_enable = 0;
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -34,18 +33,17 @@ AtomVecDipole::AtomVecDipole(LAMMPS *lmp) : AtomVec(lmp)
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "q mu";
|
||||
fields_copy = (char *) "q mu";
|
||||
fields_comm = (char *) "mu3";
|
||||
fields_comm_vel = (char *) "mu3";
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "q mu";
|
||||
fields_border_vel = (char *) "q mu";
|
||||
fields_exchange = (char *) "q mu";
|
||||
fields_restart = (char *) "q mu";
|
||||
fields_create = (char *) "q mu";
|
||||
fields_data_atom = (char *) "id type q x mu3";
|
||||
fields_data_vel = (char *) "id v";
|
||||
fields_grow = {"q", "mu"};
|
||||
fields_copy = {"q", "mu"};
|
||||
fields_comm = {"mu3"};
|
||||
fields_comm_vel = {"mu3"};
|
||||
fields_border = {"q", "mu"};
|
||||
fields_border_vel = {"q", "mu"};
|
||||
fields_exchange = {"q", "mu"};
|
||||
fields_restart = {"q", "mu"};
|
||||
fields_create = {"q", "mu"};
|
||||
fields_data_atom = {"id", "type", "q", "x", "mu3"};
|
||||
fields_data_vel = {"id", "v"};
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
@ -68,6 +66,5 @@ void AtomVecDipole::grow_pointers()
|
||||
void AtomVecDipole::data_atom_post(int ilocal)
|
||||
{
|
||||
double *mu_one = mu[ilocal];
|
||||
mu_one[3] =
|
||||
sqrt(mu_one[0]*mu_one[0] + mu_one[1]*mu_one[1] + mu_one[2]*mu_one[2]);
|
||||
mu_one[3] = sqrt(mu_one[0] * mu_one[0] + mu_one[1] * mu_one[1] + mu_one[2] * mu_one[2]);
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -38,18 +37,18 @@ AtomVecEDPD::AtomVecEDPD(LAMMPS *lmp) : AtomVec(lmp)
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "edpd_cv edpd_temp edpd_flux vest vest_temp";
|
||||
fields_copy = (char *) "edpd_cv edpd_temp edpd_flux vest vest_temp";
|
||||
fields_comm = (char *) "edpd_temp vest vest_temp";
|
||||
fields_comm_vel = (char *) "edpd_temp vest vest_temp";
|
||||
fields_reverse = (char *) "edpd_flux";
|
||||
fields_border = (char *) "edpd_cv edpd_temp vest vest_temp";
|
||||
fields_border_vel = (char *) "edpd_cv edpd_temp vest vest_temp";
|
||||
fields_exchange = (char *) "edpd_cv edpd_temp vest vest_temp";
|
||||
fields_restart = (char * ) "edpd_cv edpd_temp vest vest_temp";
|
||||
fields_create = (char *) "edpd_cv edpd_temp edpd_flux vest vest_temp";
|
||||
fields_data_atom = (char *) "id type edpd_temp edpd_cv x";
|
||||
fields_data_vel = (char *) "id v";
|
||||
fields_grow = {"edpd_cv", "edpd_temp", "edpd_flux", "vest", "vest_temp"};
|
||||
fields_copy = {"edpd_cv", "edpd_temp", "edpd_flux", "vest", "vest_temp"};
|
||||
fields_comm = {"edpd_temp", "vest", "vest_temp"};
|
||||
fields_comm_vel = {"edpd_temp", "vest", "vest_temp"};
|
||||
fields_reverse = {"edpd_flux"};
|
||||
fields_border = {"edpd_cv", "edpd_temp", "vest", "vest_temp"};
|
||||
fields_border_vel = {"edpd_cv", "edpd_temp", "vest", "vest_temp"};
|
||||
fields_exchange = {"edpd_cv", "edpd_temp", "vest", "vest_temp"};
|
||||
fields_restart = {"edpd_cv", "edpd_temp", "vest", "vest_temp"};
|
||||
fields_create = {"edpd_cv", "edpd_temp", "edpd_flux", "vest", "vest_temp"};
|
||||
fields_data_atom = {"id", "type", "edpd_temp", "edpd_cv", "x"};
|
||||
fields_data_vel = {"id", "v"};
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
@ -60,8 +59,7 @@ void AtomVecEDPD::init()
|
||||
{
|
||||
AtomVec::init();
|
||||
|
||||
if (strcmp(update->unit_style,"lj") != 0)
|
||||
error->all(FLERR,"Atom style edpd requires lj units");
|
||||
if (strcmp(update->unit_style, "lj") != 0) error->all(FLERR, "Atom style edpd requires lj units");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -85,7 +83,7 @@ void AtomVecEDPD::grow_pointers()
|
||||
|
||||
void AtomVecEDPD::force_clear(int n, size_t nbytes)
|
||||
{
|
||||
memset(&edpd_flux[n],0,nbytes);
|
||||
memset(&edpd_flux[n], 0, nbytes);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -95,7 +93,7 @@ void AtomVecEDPD::force_clear(int n, size_t nbytes)
|
||||
void AtomVecEDPD::create_atom_post(int ilocal)
|
||||
{
|
||||
edpd_temp[ilocal] = 1.0;
|
||||
edpd_cv[ilocal]= 1.0e5;
|
||||
edpd_cv[ilocal] = 1.0e5;
|
||||
vest_temp[ilocal] = edpd_temp[ilocal];
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -13,10 +12,12 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "atom_vec_mdpd.h"
|
||||
#include <cstring>
|
||||
|
||||
#include "atom.h"
|
||||
#include "update.h"
|
||||
#include "error.h"
|
||||
#include "update.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
@ -36,18 +37,18 @@ AtomVecMDPD::AtomVecMDPD(LAMMPS *lmp) : AtomVec(lmp)
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "rho drho vest";
|
||||
fields_copy = (char *) "rho drho vest";
|
||||
fields_comm = (char *) "rho vest";
|
||||
fields_comm_vel = (char *) "rho vest";
|
||||
fields_reverse = (char *) "drho";
|
||||
fields_border = (char *) "rho vest";
|
||||
fields_border_vel = (char *) "rho vest";
|
||||
fields_exchange = (char *) "rho vest";
|
||||
fields_restart = (char * ) "rho vest";
|
||||
fields_create = (char *) "rho drho vest";
|
||||
fields_data_atom = (char *) "id type rho x";
|
||||
fields_data_vel = (char *) "id v";
|
||||
fields_grow = {"rho", "drho", "vest"};
|
||||
fields_copy = {"rho", "drho", "vest"};
|
||||
fields_comm = {"rho", "vest"};
|
||||
fields_comm_vel = {"rho", "vest"};
|
||||
fields_reverse = {"drho"};
|
||||
fields_border = {"rho", "vest"};
|
||||
fields_border_vel = {"rho", "vest"};
|
||||
fields_exchange = {"rho", "vest"};
|
||||
fields_restart = {"rho", "vest"};
|
||||
fields_create = {"rho", "drho", "vest"};
|
||||
fields_data_atom = {"id", "type", "rho", "x"};
|
||||
fields_data_vel = {"id", "v"};
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
@ -58,8 +59,7 @@ void AtomVecMDPD::init()
|
||||
{
|
||||
AtomVec::init();
|
||||
|
||||
if (strcmp(update->unit_style,"lj") != 0)
|
||||
error->all(FLERR,"Atom style mdpd requires lj units");
|
||||
if (strcmp(update->unit_style, "lj") != 0) error->all(FLERR, "Atom style mdpd requires lj units");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -81,7 +81,7 @@ void AtomVecMDPD::grow_pointers()
|
||||
|
||||
void AtomVecMDPD::force_clear(int n, size_t nbytes)
|
||||
{
|
||||
memset(&drho[n],0,nbytes);
|
||||
memset(&drho[n], 0, nbytes);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -102,10 +102,10 @@ void AtomVecMDPD::data_atom_post(int ilocal)
|
||||
return -1 if name is unknown to this atom style
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecMDPD::property_atom(char *name)
|
||||
int AtomVecMDPD::property_atom(const std::string &name)
|
||||
{
|
||||
if (strcmp(name,"rho") == 0) return 0;
|
||||
if (strcmp(name,"drho") == 0) return 1;
|
||||
if (name == "rho") return 0;
|
||||
if (name == "drho") return 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -114,8 +114,7 @@ int AtomVecMDPD::property_atom(char *name)
|
||||
index maps to data specific to this atom style
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecMDPD::pack_property_atom(int index, double *buf,
|
||||
int nvalues, int groupbit)
|
||||
void AtomVecMDPD::pack_property_atom(int index, double *buf, int nvalues, int groupbit)
|
||||
{
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
@ -123,14 +122,18 @@ void AtomVecMDPD::pack_property_atom(int index, double *buf,
|
||||
int n = 0;
|
||||
if (index == 0) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = rho[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = rho[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
} else if (index == 1) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = drho[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = drho[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ class AtomVecMDPD : public AtomVec {
|
||||
void grow_pointers() override;
|
||||
void force_clear(int, size_t) override;
|
||||
void data_atom_post(int) override;
|
||||
int property_atom(char *) override;
|
||||
int property_atom(const std::string &) override;
|
||||
void pack_property_atom(int, double *, int, int) override;
|
||||
|
||||
private:
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -13,11 +12,12 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "atom_vec_tdpd.h"
|
||||
#include <cstring>
|
||||
#include "atom.h"
|
||||
#include "update.h"
|
||||
#include "error.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "error.h"
|
||||
#include "update.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
@ -37,18 +37,18 @@ AtomVecTDPD::AtomVecTDPD(LAMMPS *lmp) : AtomVec(lmp)
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "cc cc_flux vest";
|
||||
fields_copy = (char *) "cc vest";
|
||||
fields_comm = (char *) "cc vest";
|
||||
fields_comm_vel = (char *) "cc vest";
|
||||
fields_reverse = (char *) "cc_flux";
|
||||
fields_border = (char *) "cc vest";
|
||||
fields_border_vel = (char *) "cc vest";
|
||||
fields_exchange = (char *) "cc vest";
|
||||
fields_restart = (char * ) "cc vest";
|
||||
fields_create = (char *) "cc vest";
|
||||
fields_data_atom = (char *) "id type x cc";
|
||||
fields_data_vel = (char *) "id v";
|
||||
fields_grow = {"cc", "cc_flux", "vest"};
|
||||
fields_copy = {"cc", "vest"};
|
||||
fields_comm = {"cc", "vest"};
|
||||
fields_comm_vel = {"cc", "vest"};
|
||||
fields_reverse = {"cc_flux"};
|
||||
fields_border = {"cc", "vest"};
|
||||
fields_border_vel = {"cc", "vest"};
|
||||
fields_exchange = {"cc", "vest"};
|
||||
fields_restart = {"cc", "vest"};
|
||||
fields_create = {"cc", "vest"};
|
||||
fields_data_atom = {"id", "type", "x", "cc"};
|
||||
fields_data_vel = {"id", "v"};
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -58,13 +58,13 @@ AtomVecTDPD::AtomVecTDPD(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
void AtomVecTDPD::process_args(int narg, char **arg)
|
||||
{
|
||||
if (narg < 1) error->all(FLERR,"Invalid atom_style tdpd command");
|
||||
if (narg < 1) error->all(FLERR, "Invalid atom_style tdpd command");
|
||||
|
||||
atom->cc_species = utils::inumeric(FLERR,arg[0],false,lmp);
|
||||
atom->cc_species = utils::inumeric(FLERR, arg[0], false, lmp);
|
||||
cc_species = atom->cc_species;
|
||||
|
||||
atom->add_peratom_change_columns("cc",cc_species);
|
||||
atom->add_peratom_change_columns("cc_flux",cc_species);
|
||||
atom->add_peratom_change_columns("cc", cc_species);
|
||||
atom->add_peratom_change_columns("cc_flux", cc_species);
|
||||
|
||||
// delay setting up of fields until now
|
||||
|
||||
@ -77,8 +77,7 @@ void AtomVecTDPD::init()
|
||||
{
|
||||
AtomVec::init();
|
||||
|
||||
if (strcmp(update->unit_style,"lj") != 0)
|
||||
error->all(FLERR,"Atom style tdpd requires lj units");
|
||||
if (strcmp(update->unit_style, "lj") != 0) error->all(FLERR, "Atom style tdpd requires lj units");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -92,7 +91,6 @@ void AtomVecTDPD::grow_pointers()
|
||||
vest = atom->vest;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
clear extra forces starting at atom N
|
||||
nbytes = # of bytes to clear for a per-atom vector
|
||||
@ -100,7 +98,7 @@ void AtomVecTDPD::grow_pointers()
|
||||
|
||||
void AtomVecTDPD::force_clear(int n, size_t nbytes)
|
||||
{
|
||||
memset(&cc_flux[n][0],0,cc_species*nbytes);
|
||||
memset(&cc_flux[n][0], 0, cc_species * nbytes);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -17,6 +16,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "atom_vec_dpd.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "error.h"
|
||||
|
||||
@ -37,18 +37,17 @@ AtomVecDPD::AtomVecDPD(LAMMPS *lmp) : AtomVec(lmp)
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "rho dpdTheta uCond uMech uChem uCG uCGnew duChem";
|
||||
fields_copy = (char *) "dpdTheta uCond uMech uChem uCG uCGnew";
|
||||
fields_comm = (char *) "dpdTheta uCond uMech uChem";
|
||||
fields_comm_vel = (char *) "dpdTheta uCond uMech uChem";
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "dpdTheta uCond uMech uChem uCG uCGnew";
|
||||
fields_border_vel = (char *) "dpdTheta uCond uMech uChem uCG uCGnew";
|
||||
fields_exchange = (char *) "dpdTheta uCond uMech uChem uCG uCGnew";
|
||||
fields_restart = (char *) "dpdTheta uCond uMech uChem";
|
||||
fields_create = (char *) "rho dpdTheta uCond uMech uChem uCG uCGnew duChem";
|
||||
fields_data_atom = (char *) "id type dpdTheta x";
|
||||
fields_data_vel = (char *) "id v";
|
||||
fields_grow = {"rho", "dpdTheta", "uCond", "uMech", "uChem", "uCG", "uCGnew", "duChem"};
|
||||
fields_copy = {"dpdTheta", "uCond", "uMech", "uChem", "uCG", "uCGnew"};
|
||||
fields_comm = {"dpdTheta", "uCond", "uMech", "uChem"};
|
||||
fields_comm_vel = {"dpdTheta", "uCond", "uMech", "uChem"};
|
||||
fields_border = {"dpdTheta", "uCond", "uMech", "uChem", "uCG", "uCGnew"};
|
||||
fields_border_vel = {"dpdTheta", "uCond", "uMech", "uChem", "uCG", "uCGnew"};
|
||||
fields_exchange = {"dpdTheta", "uCond", "uMech", "uChem", "uCG", "uCGnew"};
|
||||
fields_restart = {"dpdTheta", "uCond", "uMech", "uChem"};
|
||||
fields_create = {"rho", "dpdTheta", "uCond", "uMech", "uChem", "uCG", "uCGnew", "duChem"};
|
||||
fields_data_atom = {"id", "type", "dpdTheta", "x"};
|
||||
fields_data_vel = {"id", "v"};
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
@ -94,6 +93,5 @@ void AtomVecDPD::data_atom_post(int ilocal)
|
||||
uCGnew[ilocal] = 0.0;
|
||||
|
||||
if (dpdTheta[ilocal] <= 0)
|
||||
error->one(FLERR,"Internal temperature in Atoms section of date file "
|
||||
"must be > zero");
|
||||
error->one(FLERR, "Internal temperature in Atoms section of date file must be > zero");
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -21,20 +20,19 @@
|
||||
#include "atom.h"
|
||||
#include "citeme.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
static const char cite_user_eff_package[] =
|
||||
"EFF package:\n\n"
|
||||
"@Article{Jaramillo-Botero11,\n"
|
||||
" author = {A. Jaramillo-Botero, J. Su, A. Qi, W. A. Goddard III},\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"
|
||||
" year = 2011,\n"
|
||||
" volume = 32,\n"
|
||||
" pages = {497--512}\n"
|
||||
"}\n\n";
|
||||
"EFF package:\n\n"
|
||||
"@Article{Jaramillo-Botero11,\n"
|
||||
" author = {A. Jaramillo-Botero, J. Su, A. Qi, W. A. Goddard III},\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"
|
||||
" year = 2011,\n"
|
||||
" volume = 32,\n"
|
||||
" pages = {497--512}\n"
|
||||
"}\n\n";
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -47,26 +45,25 @@ AtomVecElectron::AtomVecElectron(LAMMPS *lmp) : AtomVec(lmp)
|
||||
forceclearflag = 1;
|
||||
|
||||
atom->electron_flag = 1;
|
||||
atom->q_flag = atom->spin_flag = atom->eradius_flag =
|
||||
atom->ervel_flag = atom->erforce_flag = 1;
|
||||
atom->q_flag = atom->spin_flag = atom->eradius_flag = atom->ervel_flag = atom->erforce_flag = 1;
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "q spin eradius ervel erforce";
|
||||
fields_copy = (char *) "q spin eradius ervel";
|
||||
fields_comm = (char *) "eradius";
|
||||
fields_comm_vel = (char *) "eradius";
|
||||
fields_reverse = (char *) "erforce";
|
||||
fields_border = (char *) "q spin eradius";
|
||||
fields_border_vel = (char *) "q spin eradius";
|
||||
fields_exchange = (char *) "q spin eradius ervel";
|
||||
fields_restart = (char *) "q spin eradius ervel";
|
||||
fields_create = (char *) "q spin eradius ervel";
|
||||
fields_data_atom = (char *) "id type q spin eradius x";
|
||||
fields_data_vel = (char *) "id v ervel";
|
||||
fields_grow = {"q", "spin", "eradius", "ervel", "erforce"};
|
||||
fields_copy = {"q", "spin", "eradius", "ervel"};
|
||||
fields_comm = {"eradius"};
|
||||
fields_comm_vel = {"eradius"};
|
||||
fields_reverse = {"erforce"};
|
||||
fields_border = {"q", "spin", "eradius"};
|
||||
fields_border_vel = {"q", "spin", "eradius"};
|
||||
fields_exchange = {"q", "spin", "eradius", "ervel"};
|
||||
fields_restart = {"q", "spin", "eradius", "ervel"};
|
||||
fields_create = {"q", "spin", "eradius", "ervel"};
|
||||
fields_data_atom = {"id", "type", "q", "spin", "eradius", "x"};
|
||||
fields_data_vel = {"id", "v", "ervel"};
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
@ -91,7 +88,7 @@ void AtomVecElectron::grow_pointers()
|
||||
|
||||
void AtomVecElectron::force_clear(int n, size_t nbytes)
|
||||
{
|
||||
memset(&erforce[n],0,nbytes);
|
||||
memset(&erforce[n], 0, nbytes);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -119,12 +116,12 @@ void AtomVecElectron::data_atom_post(int ilocal)
|
||||
return -1 if name is unknown to this atom style
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecElectron::property_atom(char *name)
|
||||
int AtomVecElectron::property_atom(const std::string &name)
|
||||
{
|
||||
if (strcmp(name,"spin") == 0) return 0;
|
||||
if (strcmp(name,"eradius") == 0) return 1;
|
||||
if (strcmp(name,"ervel") == 0) return 2;
|
||||
if (strcmp(name,"erforce") == 0) return 3;
|
||||
if (name == "spin") return 0;
|
||||
if (name == "eradius") return 1;
|
||||
if (name == "ervel") return 2;
|
||||
if (name == "erforce") return 3;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -133,8 +130,7 @@ int AtomVecElectron::property_atom(char *name)
|
||||
index maps to data specific to this atom style
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecElectron::pack_property_atom(int index, double *buf,
|
||||
int nvalues, int groupbit)
|
||||
void AtomVecElectron::pack_property_atom(int index, double *buf, int nvalues, int groupbit)
|
||||
{
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
@ -142,26 +138,34 @@ void AtomVecElectron::pack_property_atom(int index, double *buf,
|
||||
|
||||
if (index == 0) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = spin[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = spin[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
} else if (index == 1) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = eradius[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = eradius[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
} else if (index == 2) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = ervel[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = ervel[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
} else if (index == 3) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = erforce[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = erforce[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ class AtomVecElectron : public AtomVec {
|
||||
void force_clear(int, size_t) override;
|
||||
void create_atom_post(int) override;
|
||||
void data_atom_post(int) override;
|
||||
int property_atom(char *) override;
|
||||
int property_atom(const std::string &) override;
|
||||
void pack_property_atom(int, double *, int, int) override;
|
||||
|
||||
private:
|
||||
|
||||
@ -435,121 +435,146 @@ void FixTTMMod::reset_dt()
|
||||
|
||||
void FixTTMMod::read_parameters(const std::string &filename)
|
||||
{
|
||||
try {
|
||||
PotentialFileReader reader(lmp, filename, "ttm/mod parameter");
|
||||
if (comm->me == 0) {
|
||||
|
||||
// C0 (metal)
|
||||
try {
|
||||
PotentialFileReader reader(lmp, filename, "ttm/mod parameter");
|
||||
|
||||
reader.next_line();
|
||||
esheat_0 = reader.next_values(1).next_double();
|
||||
// C0 (metal)
|
||||
|
||||
// C1 (metal*10^3)
|
||||
reader.next_line();
|
||||
esheat_0 = reader.next_values(1).next_double();
|
||||
|
||||
reader.next_line();
|
||||
esheat_1 = reader.next_values(1).next_double();
|
||||
// C1 (metal*10^3)
|
||||
|
||||
// C2 (metal*10^6)
|
||||
reader.next_line();
|
||||
esheat_1 = reader.next_values(1).next_double();
|
||||
|
||||
reader.next_line();
|
||||
esheat_2 = reader.next_values(1).next_double();
|
||||
// C2 (metal*10^6)
|
||||
|
||||
// C3 (metal*10^9)
|
||||
reader.next_line();
|
||||
esheat_2 = reader.next_values(1).next_double();
|
||||
|
||||
reader.next_line();
|
||||
esheat_3 = reader.next_values(1).next_double();
|
||||
// C3 (metal*10^9)
|
||||
|
||||
// C4 (metal*10^12)
|
||||
reader.next_line();
|
||||
esheat_3 = reader.next_values(1).next_double();
|
||||
|
||||
reader.next_line();
|
||||
esheat_4 = reader.next_values(1).next_double();
|
||||
// C4 (metal*10^12)
|
||||
|
||||
// C_limit
|
||||
reader.next_line();
|
||||
esheat_4 = reader.next_values(1).next_double();
|
||||
|
||||
reader.next_line();
|
||||
C_limit = reader.next_values(1).next_double();
|
||||
// C_limit
|
||||
|
||||
// Temperature damping factor
|
||||
reader.next_line();
|
||||
C_limit = reader.next_values(1).next_double();
|
||||
|
||||
reader.next_line();
|
||||
T_damp = reader.next_values(1).next_double();
|
||||
// Temperature damping factor
|
||||
|
||||
// rho_e
|
||||
reader.next_line();
|
||||
T_damp = reader.next_values(1).next_double();
|
||||
|
||||
reader.next_line();
|
||||
electronic_density = reader.next_values(1).next_double();
|
||||
// rho_e
|
||||
|
||||
// thermal_diffusion
|
||||
reader.next_line();
|
||||
electronic_density = reader.next_values(1).next_double();
|
||||
|
||||
reader.next_line();
|
||||
el_th_diff = reader.next_values(1).next_double();
|
||||
// thermal_diffusion
|
||||
|
||||
// gamma_p
|
||||
reader.next_line();
|
||||
el_th_diff = reader.next_values(1).next_double();
|
||||
|
||||
reader.next_line();
|
||||
gamma_p = reader.next_values(1).next_double();
|
||||
// gamma_p
|
||||
|
||||
// gamma_s
|
||||
reader.next_line();
|
||||
gamma_p = reader.next_values(1).next_double();
|
||||
|
||||
reader.next_line();
|
||||
gamma_s = reader.next_values(1).next_double();
|
||||
// gamma_s
|
||||
|
||||
// v0
|
||||
reader.next_line();
|
||||
gamma_s = reader.next_values(1).next_double();
|
||||
|
||||
reader.next_line();
|
||||
v_0 = reader.next_values(1).next_double();
|
||||
// v0
|
||||
|
||||
// average intensity of pulse (source of energy) (metal units)
|
||||
reader.next_line();
|
||||
v_0 = reader.next_values(1).next_double();
|
||||
|
||||
reader.next_line();
|
||||
intensity = reader.next_values(1).next_double();
|
||||
// average intensity of pulse (source of energy) (metal units)
|
||||
|
||||
// coordinate of 1st surface in x-direction (in box units) - constant
|
||||
reader.next_line();
|
||||
intensity = reader.next_values(1).next_double();
|
||||
|
||||
reader.next_line();
|
||||
surface_l = reader.next_values(1).next_int();
|
||||
// coordinate of 1st surface in x-direction (in box units) - constant
|
||||
|
||||
// coordinate of 2nd surface in x-direction (in box units) - constant
|
||||
reader.next_line();
|
||||
surface_l = reader.next_values(1).next_int();
|
||||
|
||||
reader.next_line();
|
||||
surface_r = reader.next_values(1).next_int();
|
||||
// coordinate of 2nd surface in x-direction (in box units) - constant
|
||||
|
||||
// skin_layer = intensity is reduced (I=I0*exp[-x/skin_layer])
|
||||
reader.next_line();
|
||||
surface_r = reader.next_values(1).next_int();
|
||||
|
||||
reader.next_line();
|
||||
skin_layer = reader.next_values(1).next_int();
|
||||
// skin_layer = intensity is reduced (I=I0*exp[-x/skin_layer])
|
||||
|
||||
// width of pulse (picoseconds)
|
||||
reader.next_line();
|
||||
skin_layer = reader.next_values(1).next_int();
|
||||
|
||||
reader.next_line();
|
||||
width = reader.next_values(1).next_double();
|
||||
// width of pulse (picoseconds)
|
||||
|
||||
// factor of electronic pressure (PF) Pe = PF*Ce*Te
|
||||
reader.next_line();
|
||||
width = reader.next_values(1).next_double();
|
||||
|
||||
reader.next_line();
|
||||
pres_factor = reader.next_values(1).next_double();
|
||||
// factor of electronic pressure (PF) Pe = PF*Ce*Te
|
||||
|
||||
// effective free path of electrons (angstrom)
|
||||
reader.next_line();
|
||||
pres_factor = reader.next_values(1).next_double();
|
||||
|
||||
reader.next_line();
|
||||
free_path = reader.next_values(1).next_double();
|
||||
// effective free path of electrons (angstrom)
|
||||
|
||||
// ionic density (ions*angstrom^{-3})
|
||||
reader.next_line();
|
||||
free_path = reader.next_values(1).next_double();
|
||||
|
||||
reader.next_line();
|
||||
ionic_density = reader.next_values(1).next_double();
|
||||
// ionic density (ions*angstrom^{-3})
|
||||
|
||||
// if movsur = 0: surface is frozen
|
||||
reader.next_line();
|
||||
ionic_density = reader.next_values(1).next_double();
|
||||
|
||||
reader.next_line();
|
||||
movsur = reader.next_values(1).next_int();
|
||||
// if movsur = 0: surface is frozen
|
||||
|
||||
// electron_temperature_min
|
||||
reader.next_line();
|
||||
movsur = reader.next_values(1).next_int();
|
||||
|
||||
reader.next_line();
|
||||
electron_temperature_min = reader.next_values(1).next_double();
|
||||
} catch (std::exception &e) {
|
||||
error->one(FLERR,e.what());
|
||||
// electron_temperature_min
|
||||
|
||||
reader.next_line();
|
||||
electron_temperature_min = reader.next_values(1).next_double();
|
||||
} catch (std::exception &e) {
|
||||
error->one(FLERR,e.what());
|
||||
}
|
||||
}
|
||||
MPI_Bcast(&esheat_0, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&esheat_1, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&esheat_2, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&esheat_3, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&esheat_4, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&C_limit, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&T_damp, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&electronic_density, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&el_th_diff, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&gamma_p, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&gamma_s, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&v_0, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&intensity, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&surface_l, 1, MPI_INT, 0, world);
|
||||
MPI_Bcast(&surface_r, 1, MPI_INT, 0, world);
|
||||
MPI_Bcast(&skin_layer, 1, MPI_INT, 0, world);
|
||||
MPI_Bcast(&width, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&pres_factor, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&free_path, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&ionic_density, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&movsur, 1, MPI_INT, 0, world);
|
||||
MPI_Bcast(&electron_temperature_min, 1, MPI_DOUBLE, 0, world);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
@ -45,7 +45,6 @@ using namespace LAMMPS_NS;
|
||||
PairCoulSlaterLong::PairCoulSlaterLong(LAMMPS *lmp) : Pair(lmp)
|
||||
{
|
||||
ewaldflag = pppmflag = 1;
|
||||
//ftable = nullptr;
|
||||
qdist = 0.0;
|
||||
}
|
||||
|
||||
@ -117,7 +116,6 @@ void PairCoulSlaterLong::compute(int eflag, int vflag)
|
||||
|
||||
if (rsq < cut_coulsq) {
|
||||
r2inv = 1.0/rsq;
|
||||
// if (!ncoultablebits || rsq <= tabinnersq) {
|
||||
r = sqrt(rsq);
|
||||
grij = g_ewald * r;
|
||||
expm2 = exp(-grij*grij);
|
||||
@ -127,22 +125,6 @@ void PairCoulSlaterLong::compute(int eflag, int vflag)
|
||||
prefactor = qqrd2e * scale[itype][jtype] * qtmp*q[j]/r;
|
||||
forcecoul = prefactor * (erfc + EWALD_F*grij*expm2 - slater_term);
|
||||
if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor;
|
||||
/*
|
||||
} else {
|
||||
union_int_float_t rsq_lookup;
|
||||
rsq_lookup.f = rsq;
|
||||
itable = rsq_lookup.i & ncoulmask;
|
||||
itable >>= ncoulshiftbits;
|
||||
fraction = (rsq_lookup.f - rtable[itable]) * drtable[itable];
|
||||
table = ftable[itable] + fraction*dftable[itable];
|
||||
forcecoul = scale[itype][jtype] * qtmp*q[j] * table;
|
||||
if (factor_coul < 1.0) {
|
||||
table = ctable[itable] + fraction*dctable[itable];
|
||||
prefactor = scale[itype][jtype] * qtmp*q[j] * table;
|
||||
forcecoul -= (1.0-factor_coul)*prefactor;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
fpair = forcecoul * r2inv;
|
||||
|
||||
@ -156,14 +138,7 @@ void PairCoulSlaterLong::compute(int eflag, int vflag)
|
||||
}
|
||||
|
||||
if (eflag) {
|
||||
// if (!ncoultablebits || rsq <= tabinnersq)
|
||||
ecoul = prefactor*(erfc - (1 + r/lamda)*exp(-2*r/lamda));
|
||||
/*
|
||||
else {
|
||||
table = etable[itable] + fraction*detable[itable];
|
||||
ecoul = scale[itype][jtype] * qtmp*q[j] * table;
|
||||
}
|
||||
*/
|
||||
if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor;
|
||||
}
|
||||
|
||||
@ -296,10 +271,10 @@ void PairCoulSlaterLong::read_restart(FILE *fp)
|
||||
int me = comm->me;
|
||||
for (i = 1; i <= atom->ntypes; i++)
|
||||
for (j = i; j <= atom->ntypes; j++) {
|
||||
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp);
|
||||
if (me == 0) utils::sfread(FLERR, &setflag[i][j],sizeof(int),1,fp, nullptr, error);
|
||||
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
|
||||
if (setflag[i][j]) {
|
||||
if (me == 0) fread(&scale[i][j],sizeof(double),1,fp);
|
||||
if (me == 0) utils::sfread(FLERR, &scale[i][j],sizeof(double),1,fp, nullptr, error);
|
||||
MPI_Bcast(&scale[i][j],1,MPI_DOUBLE,0,world);
|
||||
}
|
||||
}
|
||||
@ -315,8 +290,6 @@ void PairCoulSlaterLong::write_restart_settings(FILE *fp)
|
||||
fwrite(&lamda,sizeof(double),1,fp);
|
||||
fwrite(&offset_flag,sizeof(int),1,fp);
|
||||
fwrite(&mix_flag,sizeof(int),1,fp);
|
||||
//fwrite(&ncoultablebits,sizeof(int),1,fp);
|
||||
//fwrite(&tabinner,sizeof(double),1,fp);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -326,71 +299,39 @@ void PairCoulSlaterLong::write_restart_settings(FILE *fp)
|
||||
void PairCoulSlaterLong::read_restart_settings(FILE *fp)
|
||||
{
|
||||
if (comm->me == 0) {
|
||||
fread(&cut_coul,sizeof(double),1,fp);
|
||||
fread(&lamda,sizeof(double),1,fp);
|
||||
fread(&offset_flag,sizeof(int),1,fp);
|
||||
fread(&mix_flag,sizeof(int),1,fp);
|
||||
//fread(&ncoultablebits,sizeof(int),1,fp);
|
||||
//fread(&tabinner,sizeof(double),1,fp);
|
||||
utils::sfread(FLERR, &cut_coul,sizeof(double),1,fp,nullptr,error);
|
||||
utils::sfread(FLERR, &lamda,sizeof(double),1,fp,nullptr,error);
|
||||
utils::sfread(FLERR, &offset_flag,sizeof(int),1,fp,nullptr,error);
|
||||
utils::sfread(FLERR, &mix_flag,sizeof(int),1,fp,nullptr,error);
|
||||
}
|
||||
MPI_Bcast(&cut_coul,1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&lamda,1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&offset_flag,1,MPI_INT,0,world);
|
||||
MPI_Bcast(&mix_flag,1,MPI_INT,0,world);
|
||||
//MPI_Bcast(&ncoultablebits,1,MPI_INT,0,world);
|
||||
//MPI_Bcast(&tabinner,1,MPI_DOUBLE,0,world);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
double PairCoulSlaterLong::single(int i, int j, int /*itype*/, int /*jtype*/,
|
||||
double rsq,
|
||||
double factor_coul, double /*factor_lj*/,
|
||||
double &fforce)
|
||||
double PairCoulSlaterLong::single(int i, int j, int /*itype*/, int /*jtype*/, double rsq,
|
||||
double factor_coul, double /*factor_lj*/, double &fforce)
|
||||
{
|
||||
double r2inv,r,grij,expm2,t,erfc,prefactor;
|
||||
double slater_term;
|
||||
// double fraction,table;
|
||||
double forcecoul,phicoul;
|
||||
// int itable;
|
||||
|
||||
r2inv = 1.0/rsq;
|
||||
// if (!ncoultablebits || rsq <= tabinnersq) {
|
||||
r = sqrt(rsq);
|
||||
grij = g_ewald * r;
|
||||
expm2 = exp(-grij*grij);
|
||||
t = 1.0 / (1.0 + EWALD_P*grij);
|
||||
erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2;
|
||||
slater_term = exp(-2*r/lamda)*(1 + (2*r/lamda*(1+r/lamda)));
|
||||
prefactor = force->qqrd2e * atom->q[i]*atom->q[j]/r;
|
||||
forcecoul = prefactor * (erfc + EWALD_F*grij*expm2 - slater_term);
|
||||
if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor;
|
||||
/*
|
||||
} else {
|
||||
union_int_float_t rsq_lookup;
|
||||
rsq_lookup.f = rsq;
|
||||
itable = rsq_lookup.i & ncoulmask;
|
||||
itable >>= ncoulshiftbits;
|
||||
fraction = (rsq_lookup.f - rtable[itable]) * drtable[itable];
|
||||
table = ftable[itable] + fraction*dftable[itable];
|
||||
forcecoul = atom->q[i]*atom->q[j] * table;
|
||||
if (factor_coul < 1.0) {
|
||||
table = ctable[itable] + fraction*dctable[itable];
|
||||
prefactor = atom->q[i]*atom->q[j] * table;
|
||||
forcecoul -= (1.0-factor_coul)*prefactor;
|
||||
}
|
||||
}
|
||||
*/
|
||||
r = sqrt(rsq);
|
||||
grij = g_ewald * r;
|
||||
expm2 = exp(-grij*grij);
|
||||
t = 1.0 / (1.0 + EWALD_P*grij);
|
||||
erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2;
|
||||
slater_term = exp(-2*r/lamda)*(1 + (2*r/lamda*(1+r/lamda)));
|
||||
prefactor = force->qqrd2e * atom->q[i]*atom->q[j]/r;
|
||||
forcecoul = prefactor * (erfc + EWALD_F*grij*expm2 - slater_term);
|
||||
if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor;
|
||||
fforce = forcecoul * r2inv;
|
||||
|
||||
// if (!ncoultablebits || rsq <= tabinnersq)
|
||||
phicoul = prefactor*(erfc - (1 + r/lamda)*exp(-2*r/lamda));
|
||||
/*
|
||||
else {
|
||||
table = etable[itable] + fraction*detable[itable];
|
||||
phicoul = atom->q[i]*atom->q[j] * table;
|
||||
}
|
||||
*/
|
||||
phicoul = prefactor*(erfc - (1 + r/lamda)*exp(-2*r/lamda));
|
||||
if (factor_coul < 1.0) phicoul -= (1.0-factor_coul)*prefactor;
|
||||
|
||||
return phicoul;
|
||||
|
||||
@ -43,7 +43,6 @@ class PairCoulSlaterLong : public Pair {
|
||||
protected:
|
||||
double cut_coul, cut_coulsq, qdist;
|
||||
double lamda;
|
||||
//double *cut_respa;
|
||||
double g_ewald;
|
||||
double **scale;
|
||||
|
||||
|
||||
@ -294,15 +294,15 @@ void PairWFCut::read_restart(FILE *fp)
|
||||
int me = comm->me;
|
||||
for (i = 1; i <= atom->ntypes; i++)
|
||||
for (j = i; j <= atom->ntypes; j++) {
|
||||
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp);
|
||||
if (me == 0) utils::sfread(FLERR, &setflag[i][j],sizeof(int),1,fp, nullptr, error);
|
||||
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
|
||||
if (setflag[i][j]) {
|
||||
if (me == 0) {
|
||||
fread(&epsilon[i][j],sizeof(double),1,fp);
|
||||
fread(&sigma[i][j],sizeof(double),1,fp);
|
||||
fread(&nu[i][j],sizeof(int),1,fp);
|
||||
fread(&mu[i][j],sizeof(int),1,fp);
|
||||
fread(&cut[i][j],sizeof(double),1,fp);
|
||||
utils::sfread(FLERR, &epsilon[i][j],sizeof(double),1,fp, nullptr, error);
|
||||
utils::sfread(FLERR, &sigma[i][j],sizeof(double),1,fp, nullptr, error);
|
||||
utils::sfread(FLERR, &nu[i][j],sizeof(int),1,fp, nullptr, error);
|
||||
utils::sfread(FLERR, &mu[i][j],sizeof(int),1,fp, nullptr, error);
|
||||
utils::sfread(FLERR, &cut[i][j],sizeof(double),1,fp, nullptr, error);
|
||||
}
|
||||
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
|
||||
@ -331,9 +331,9 @@ void PairWFCut::write_restart_settings(FILE *fp)
|
||||
void PairWFCut::read_restart_settings(FILE *fp)
|
||||
{
|
||||
if (comm->me == 0) {
|
||||
fread(&cut_global,sizeof(double),1,fp);
|
||||
fread(&offset_flag,sizeof(int),1,fp);
|
||||
fread(&mix_flag,sizeof(int),1,fp);
|
||||
utils::sfread(FLERR, &cut_global,sizeof(double),1,fp,nullptr,error);
|
||||
utils::sfread(FLERR, &offset_flag,sizeof(int),1,fp,nullptr,error);
|
||||
utils::sfread(FLERR, &mix_flag,sizeof(int),1,fp,nullptr,error);
|
||||
}
|
||||
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&offset_flag,1,MPI_INT,0,world);
|
||||
|
||||
@ -1073,17 +1073,14 @@ void AtomVecHybridKokkos::write_data(FILE *fp, int n, double **buf)
|
||||
int k,m;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
fprintf(fp,TAGINT_FORMAT " %d %-1.16e %-1.16e %-1.16e",
|
||||
(tagint) ubuf(buf[i][0]).i,(int) ubuf(buf[i][1]).i,
|
||||
buf[i][2],buf[i][3],buf[i][4]);
|
||||
fmt::print(fp,"{} {} {:.16e} {:.16e} {:.16e}", ubuf(buf[i][0]).i, ubuf(buf[i][1]).i,
|
||||
buf[i][2], buf[i][3], buf[i][4]);
|
||||
|
||||
m = 5;
|
||||
for (k = 0; k < nstyles; k++)
|
||||
m += styles[k]->write_data_hybrid(fp,&buf[i][m]);
|
||||
|
||||
fprintf(fp," %d %d %d\n",
|
||||
(int) ubuf(buf[i][m]).i,(int) ubuf(buf[i][m+1]).i,
|
||||
(int) ubuf(buf[i][m+2]).i);
|
||||
fmt::print(fp," {} {} {}\n", ubuf(buf[i][m]).i, ubuf(buf[i][m+1]).i, ubuf(buf[i][m+2]).i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1119,8 +1116,7 @@ void AtomVecHybridKokkos::write_vel(FILE *fp, int n, double **buf)
|
||||
int k,m;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
fprintf(fp,TAGINT_FORMAT " %g %g %g",
|
||||
(tagint) ubuf(buf[i][0]).i,buf[i][1],buf[i][2],buf[i][3]);
|
||||
fmt::print(fp,"{} {} {} {}", (tagint) ubuf(buf[i][0]).i,buf[i][1],buf[i][2],buf[i][3]);
|
||||
|
||||
m = 4;
|
||||
for (k = 0; k < nstyles; k++)
|
||||
@ -1136,7 +1132,7 @@ void AtomVecHybridKokkos::write_vel(FILE *fp, int n, double **buf)
|
||||
return -1 if name is unknown to any sub-styles
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybridKokkos::property_atom(char *name)
|
||||
int AtomVecHybridKokkos::property_atom(const std::string &name)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++) {
|
||||
int index = styles[k]->property_atom(name);
|
||||
@ -1150,8 +1146,7 @@ int AtomVecHybridKokkos::property_atom(char *name)
|
||||
index maps to data specific to this atom style
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybridKokkos::pack_property_atom(int multiindex, double *buf,
|
||||
int nvalues, int groupbit)
|
||||
void AtomVecHybridKokkos::pack_property_atom(int multiindex, double *buf, int nvalues, int groupbit)
|
||||
{
|
||||
int k = multiindex % nstyles;
|
||||
int index = multiindex/nstyles;
|
||||
|
||||
@ -64,7 +64,7 @@ class AtomVecHybridKokkos : public AtomVecKokkos {
|
||||
void write_data(FILE *, int, double **) override;
|
||||
void pack_vel(double **) override;
|
||||
void write_vel(FILE *, int, double **) override;
|
||||
int property_atom(char *) override;
|
||||
int property_atom(const std::string &) override;
|
||||
void pack_property_atom(int, double *, int, int) override;
|
||||
double memory_usage() override;
|
||||
|
||||
|
||||
29
src/KSPACE/ewald_const.h
Normal file
29
src/KSPACE/ewald_const.h
Normal file
@ -0,0 +1,29 @@
|
||||
/* -*- c++ -*- ----------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef LMP_EWALD_CONST_H
|
||||
#define LMP_EWALD_CONST_H
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
namespace EwaldConst {
|
||||
static constexpr double EWALD_F = 1.12837917;
|
||||
static constexpr double EWALD_P = 0.3275911;
|
||||
static constexpr double A1 = 0.254829592;
|
||||
static constexpr double A2 = -0.284496736;
|
||||
static constexpr double A3 = 1.421413741;
|
||||
static constexpr double A4 = -1.453152027;
|
||||
static constexpr double A5 = 1.061405429;
|
||||
} // namespace EwaldConst
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
*
|
||||
* *** Smooth Mach Dynamics ***
|
||||
@ -27,8 +26,6 @@
|
||||
|
||||
#include "atom.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define NMAT_FULL 9
|
||||
@ -63,42 +60,33 @@ AtomVecSMD::AtomVecSMD(LAMMPS *lmp) : AtomVec(lmp)
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *)
|
||||
"esph desph vfrac rmass x0 radius contact_radius molecule "
|
||||
"smd_data_9 vest smd_stress "
|
||||
"eff_plastic_strain eff_plastic_strain_rate damage";
|
||||
fields_copy = (char *)
|
||||
"esph vfrac rmass x0 radius contact_radius molecule "
|
||||
"eff_plastic_strain eff_plastic_strain_rate vest "
|
||||
"smd_data_9 smd_stress damage";
|
||||
fields_comm = (char *) "radius vfrac vest esph";
|
||||
fields_comm_vel = (char *) "radius vfrac vest esph";
|
||||
fields_reverse = (char *) "desph";
|
||||
fields_border = (char *)
|
||||
"x0 molecule radius rmass vfrac contact_radius esph "
|
||||
"eff_plastic_strain smd_data_9 smd_stress";
|
||||
fields_border_vel = (char *)
|
||||
"x0 molecule radius rmass vfrac contact_radius esph "
|
||||
"eff_plastic_strain smd_data_9 smd_stress vest";
|
||||
fields_exchange = (char *)
|
||||
"x0 molecule radius rmass vfrac contact_radius esph "
|
||||
"eff_plastic_strain eff_plastic_strain_rate smd_data_9 smd_stress "
|
||||
"vest damage";
|
||||
fields_restart = (char *)
|
||||
"x0 molecule radius rmass vfrac contact_radius esph "
|
||||
"eff_plastic_strain eff_plastic_strain_rate smd_data_9 smd_stress "
|
||||
"vest damage";
|
||||
fields_create = (char *)
|
||||
"x0 vest vfrac rmass radius contact_radius molecule esph "
|
||||
"eff_plastic_strain eff_plastic_strain_rate smd_data_9 smd_stress damage";
|
||||
fields_data_atom = (char *)
|
||||
"id type molecule vfrac rmass radius contact_radius x0 x";
|
||||
fields_data_vel = (char *) "id v";
|
||||
// clang-format off
|
||||
fields_grow = {"esph", "desph", "vfrac", "rmass", "x0", "radius", "contact_radius", "molecule",
|
||||
"smd_data_9", "vest", "smd_stress", "eff_plastic_strain", "eff_plastic_strain_rate", "damage"};
|
||||
fields_copy = {"esph", "vfrac", "rmass", "x0", "radius", "contact_radius", "molecule",
|
||||
"eff_plastic_strain", "eff_plastic_strain_rate", "vest", "smd_data_9", "smd_stress", "damage"};
|
||||
fields_comm = {"radius", "vfrac", "vest", "esph"};
|
||||
fields_comm_vel = {"radius", "vfrac", "vest", "esph"};
|
||||
fields_reverse = {"desph"};
|
||||
fields_border = {"x0", "molecule", "radius", "rmass", "vfrac", "contact_radius", "esph",
|
||||
"eff_plastic_strain", "smd_data_9", "smd_stress"};
|
||||
fields_border_vel = {"x0", "molecule", "radius", "rmass", "vfrac", "contact_radius", "esph",
|
||||
"eff_plastic_strain", "smd_data_9", "smd_stress", "vest"};
|
||||
fields_exchange = {"x0", "molecule", "radius", "rmass", "vfrac", "contact_radius", "esph",
|
||||
"eff_plastic_strain", "eff_plastic_strain_rate", "smd_data_9", "smd_stress", "vest", "damage"};
|
||||
fields_restart ={"x0", "molecule", "radius", "rmass", "vfrac", "contact_radius", "esph",
|
||||
"eff_plastic_strain", "eff_plastic_strain_rate", "smd_data_9", "smd_stress", "vest", "damage"};
|
||||
fields_create = {"x0", "vest", "vfrac", "rmass", "radius", "contact_radius", "molecule",
|
||||
"esph", "eff_plastic_strain", "eff_plastic_strain_rate", "smd_data_9", "smd_stress", "damage"};
|
||||
fields_data_atom = {"id", "type", "molecule", "vfrac", "rmass", "radius", "contact_radius",
|
||||
"x0", "x"};
|
||||
fields_data_vel = {"id", "v"};
|
||||
// clang-format on
|
||||
|
||||
// set these array sizes based on defines
|
||||
|
||||
atom->add_peratom_change_columns("smd_data_9",NMAT_FULL);
|
||||
atom->add_peratom_change_columns("smd_stress",NMAT_SYMM);
|
||||
atom->add_peratom_change_columns("smd_data_9", NMAT_FULL);
|
||||
atom->add_peratom_change_columns("smd_stress", NMAT_SYMM);
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
@ -134,7 +122,7 @@ void AtomVecSMD::grow_pointers()
|
||||
|
||||
void AtomVecSMD::force_clear(int n, size_t nbytes)
|
||||
{
|
||||
memset(&desph[n],0,nbytes);
|
||||
memset(&desph[n], 0, nbytes);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -153,9 +141,9 @@ void AtomVecSMD::create_atom_post(int ilocal)
|
||||
contact_radius[ilocal] = 0.5;
|
||||
molecule[ilocal] = 1;
|
||||
|
||||
smd_data_9[ilocal][0] = 1.0; // xx
|
||||
smd_data_9[ilocal][4] = 1.0; // yy
|
||||
smd_data_9[ilocal][8] = 1.0; // zz
|
||||
smd_data_9[ilocal][0] = 1.0; // xx
|
||||
smd_data_9[ilocal][4] = 1.0; // yy
|
||||
smd_data_9[ilocal][8] = 1.0; // zz
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -179,13 +167,11 @@ void AtomVecSMD::data_atom_post(int ilocal)
|
||||
eff_plastic_strain[ilocal] = 0.0;
|
||||
eff_plastic_strain_rate[ilocal] = 0.0;
|
||||
|
||||
for (int k = 0; k < NMAT_FULL; k++)
|
||||
smd_data_9[ilocal][k] = 0.0;
|
||||
for (int k = 0; k < NMAT_FULL; k++) smd_data_9[ilocal][k] = 0.0;
|
||||
|
||||
for (int k = 0; k < NMAT_SYMM; k++)
|
||||
smd_stress[ilocal][k] = 0.0;
|
||||
for (int k = 0; k < NMAT_SYMM; k++) smd_stress[ilocal][k] = 0.0;
|
||||
|
||||
smd_data_9[ilocal][0] = 1.0; // xx
|
||||
smd_data_9[ilocal][4] = 1.0; // yy
|
||||
smd_data_9[ilocal][8] = 1.0; // zz
|
||||
smd_data_9[ilocal][0] = 1.0; // xx
|
||||
smd_data_9[ilocal][4] = 1.0; // yy
|
||||
smd_data_9[ilocal][8] = 1.0; // zz
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ SHELL = /bin/sh
|
||||
KOKKOS_ABSOLUTE_PATH = $(shell cd $(KOKKOS_PATH); pwd)
|
||||
|
||||
CC = $(KOKKOS_ABSOLUTE_PATH)/bin/nvcc_wrapper
|
||||
CCFLAGS = -g -O3 -DNDEBUG
|
||||
CCFLAGS = -g -O3 -DNDEBUG -Xcudafe --diag_suppress=unrecognized_pragma
|
||||
SHFLAGS = -fPIC
|
||||
DEPFLAGS = -M
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ KOKKOS_ABSOLUTE_PATH = $(shell cd $(KOKKOS_PATH); pwd)
|
||||
export MPICH_CXX = $(KOKKOS_ABSOLUTE_PATH)/bin/nvcc_wrapper
|
||||
export OMPI_CXX = $(KOKKOS_ABSOLUTE_PATH)/bin/nvcc_wrapper
|
||||
CC = mpicxx
|
||||
CCFLAGS = -g -O3 -DNDEBUG
|
||||
CCFLAGS = -g -O3 -DNDEBUG -Xcudafe --diag_suppress=unrecognized_pragma
|
||||
SHFLAGS = -fPIC
|
||||
DEPFLAGS = -M
|
||||
|
||||
@ -55,7 +55,7 @@ MPI_LIB =
|
||||
# PATH = path for FFT library
|
||||
# LIB = name of FFT library
|
||||
|
||||
FFT_INC = -DFFT_CUFFT
|
||||
FFT_INC = -DFFT_CUFFT
|
||||
FFT_PATH =
|
||||
FFT_LIB = -lcufft
|
||||
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -33,18 +32,16 @@ AtomVecMesoNT::AtomVecMesoNT(LAMMPS *lmp) : AtomVec(lmp)
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "rmass radius length buckling bond_nt molecule";
|
||||
fields_copy = (char *) "rmass radius length buckling bond_nt molecule";
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "";
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "rmass radius length buckling bond_nt molecule";
|
||||
fields_border_vel = (char *) "rmass radius length buckling bond_nt molecule";
|
||||
fields_exchange = (char *) "rmass radius length buckling bond_nt molecule";
|
||||
fields_restart = (char *) "rmass radius length buckling bond_nt molecule";
|
||||
fields_create = (char *) "rmass radius length buckling bond_nt molecule";
|
||||
fields_data_atom = (char *) "id molecule type bond_nt rmass radius length buckling x";
|
||||
fields_data_vel = (char *) "id v";
|
||||
fields_grow = {"rmass", "radius", "length", "buckling", "bond_nt", "molecule"};
|
||||
fields_copy = {"rmass", "radius", "length", "buckling", "bond_nt", "molecule"};
|
||||
fields_border = {"rmass", "radius", "length", "buckling", "bond_nt", "molecule"};
|
||||
fields_border_vel = {"rmass", "radius", "length", "buckling", "bond_nt", "molecule"};
|
||||
fields_exchange = {"rmass", "radius", "length", "buckling", "bond_nt", "molecule"};
|
||||
fields_restart = {"rmass", "radius", "length", "buckling", "bond_nt", "molecule"};
|
||||
fields_create = {"rmass", "radius", "length", "buckling", "bond_nt", "molecule"};
|
||||
fields_data_atom = {"id", "molecule", "type", "bond_nt", "rmass",
|
||||
"radius", "length", "buckling", "x"};
|
||||
fields_data_vel = {"id", "v"};
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
|
||||
@ -703,7 +703,6 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename)
|
||||
if (keywd == "rinner") {
|
||||
keyval = words[iword];
|
||||
for (int ielem = 0; ielem < nelements; ielem++) {
|
||||
printf("rinnerelem = %p ielem = %d nelements = %d iword = %d nwords = %d\n",rinnerelem, ielem, nelements, iword, nwords);
|
||||
rinnerelem[ielem] = utils::numeric(FLERR,keyval,false,lmp);
|
||||
iword++;
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -32,26 +31,22 @@ AtomVecAngle::AtomVecAngle(LAMMPS *lmp) : AtomVec(lmp)
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *)
|
||||
"molecule num_bond bond_type bond_atom "
|
||||
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 nspecial special";
|
||||
fields_copy = (char *)
|
||||
"molecule num_bond bond_type bond_atom "
|
||||
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 nspecial special";
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "";
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "molecule";
|
||||
fields_border_vel = (char *) "molecule";
|
||||
fields_exchange = (char *)
|
||||
"molecule num_bond bond_type bond_atom "
|
||||
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 nspecial special";
|
||||
fields_restart = (char *)
|
||||
"molecule num_bond bond_type bond_atom "
|
||||
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3";
|
||||
fields_create = (char *) "molecule num_bond num_angle nspecial";
|
||||
fields_data_atom = (char *) "id molecule type x";
|
||||
fields_data_vel = (char *) "id v";
|
||||
fields_grow = {"molecule", "num_bond", "bond_type", "bond_atom",
|
||||
"num_angle", "angle_type", "angle_atom1", "angle_atom2",
|
||||
"angle_atom3", "nspecial", "special"};
|
||||
fields_copy = {"molecule", "num_bond", "bond_type", "bond_atom",
|
||||
"num_angle", "angle_type", "angle_atom1", "angle_atom2",
|
||||
"angle_atom3", "nspecial", "special"};
|
||||
fields_border = {"molecule"};
|
||||
fields_border_vel = {"molecule"};
|
||||
fields_exchange = {"molecule", "num_bond", "bond_type", "bond_atom",
|
||||
"num_angle", "angle_type", "angle_atom1", "angle_atom2",
|
||||
"angle_atom3", "nspecial", "special"};
|
||||
fields_restart = {"molecule", "num_bond", "bond_type", "bond_atom", "num_angle",
|
||||
"angle_type", "angle_atom1", "angle_atom2", "angle_atom3"};
|
||||
fields_create = {"molecule", "num_bond", "num_angle", "nspecial"};
|
||||
fields_data_atom = {"id", "molecule", "type", "x"};
|
||||
fields_data_vel = {"id", "v"};
|
||||
|
||||
setup_fields();
|
||||
|
||||
@ -63,8 +58,8 @@ AtomVecAngle::AtomVecAngle(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
AtomVecAngle::~AtomVecAngle()
|
||||
{
|
||||
delete [] bond_negative;
|
||||
delete [] angle_negative;
|
||||
delete[] bond_negative;
|
||||
delete[] angle_negative;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -90,12 +85,12 @@ void AtomVecAngle::pack_restart_pre(int ilocal)
|
||||
// insure negative vectors are needed length
|
||||
|
||||
if (bond_per_atom < atom->bond_per_atom) {
|
||||
delete [] bond_negative;
|
||||
delete[] bond_negative;
|
||||
bond_per_atom = atom->bond_per_atom;
|
||||
bond_negative = new int[bond_per_atom];
|
||||
}
|
||||
if (angle_per_atom < atom->angle_per_atom) {
|
||||
delete [] angle_negative;
|
||||
delete[] angle_negative;
|
||||
angle_per_atom = atom->angle_per_atom;
|
||||
angle_negative = new int[angle_per_atom];
|
||||
}
|
||||
@ -108,7 +103,8 @@ void AtomVecAngle::pack_restart_pre(int ilocal)
|
||||
bond_negative[m] = 1;
|
||||
bond_type[ilocal][m] = -bond_type[ilocal][m];
|
||||
any_bond_negative = 1;
|
||||
} else bond_negative[m] = 0;
|
||||
} else
|
||||
bond_negative[m] = 0;
|
||||
}
|
||||
|
||||
any_angle_negative = 0;
|
||||
@ -117,7 +113,8 @@ void AtomVecAngle::pack_restart_pre(int ilocal)
|
||||
angle_negative[m] = 1;
|
||||
angle_type[ilocal][m] = -angle_type[ilocal][m];
|
||||
any_angle_negative = 1;
|
||||
} else angle_negative[m] = 0;
|
||||
} else
|
||||
angle_negative[m] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -32,21 +31,15 @@ AtomVecBond::AtomVecBond(LAMMPS *lmp) : AtomVec(lmp)
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *)
|
||||
"molecule num_bond bond_type bond_atom nspecial special";
|
||||
fields_copy = (char *)
|
||||
"molecule num_bond bond_type bond_atom nspecial special";
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "";
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "molecule";
|
||||
fields_border_vel = (char *) "molecule";
|
||||
fields_exchange = (char *)
|
||||
"molecule num_bond bond_type bond_atom nspecial special";
|
||||
fields_restart = (char *) "molecule num_bond bond_type bond_atom";
|
||||
fields_create = (char *) "molecule num_bond nspecial";
|
||||
fields_data_atom = (char *) "id molecule type x";
|
||||
fields_data_vel = (char *) "id v";
|
||||
fields_grow = {"molecule", "num_bond", "bond_type", "bond_atom", "nspecial", "special"};
|
||||
fields_copy = {"molecule", "num_bond", "bond_type", "bond_atom", "nspecial", "special"};
|
||||
fields_border = {"molecule"};
|
||||
fields_border_vel = {"molecule"};
|
||||
fields_exchange = {"molecule", "num_bond", "bond_type", "bond_atom", "nspecial", "special"};
|
||||
fields_restart = {"molecule", "num_bond", "bond_type", "bond_atom"};
|
||||
fields_create = {"molecule", "num_bond", "nspecial"};
|
||||
fields_data_atom = {"id", "molecule", "type", "x"};
|
||||
fields_data_vel = {"id", "v"};
|
||||
|
||||
setup_fields();
|
||||
|
||||
@ -58,7 +51,7 @@ AtomVecBond::AtomVecBond(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
AtomVecBond::~AtomVecBond()
|
||||
{
|
||||
delete [] bond_negative;
|
||||
delete[] bond_negative;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -82,7 +75,7 @@ void AtomVecBond::pack_restart_pre(int ilocal)
|
||||
// insure bond_negative vector is needed length
|
||||
|
||||
if (bond_per_atom < atom->bond_per_atom) {
|
||||
delete [] bond_negative;
|
||||
delete[] bond_negative;
|
||||
bond_per_atom = atom->bond_per_atom;
|
||||
bond_negative = new int[bond_per_atom];
|
||||
}
|
||||
@ -95,7 +88,8 @@ void AtomVecBond::pack_restart_pre(int ilocal)
|
||||
bond_negative[m] = 1;
|
||||
bond_type[ilocal][m] = -bond_type[ilocal][m];
|
||||
any_bond_negative = 1;
|
||||
} else bond_negative[m] = 0;
|
||||
} else
|
||||
bond_negative[m] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -32,47 +31,31 @@ AtomVecFull::AtomVecFull(LAMMPS *lmp) : AtomVec(lmp)
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *)
|
||||
"q molecule num_bond bond_type bond_atom "
|
||||
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 "
|
||||
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 "
|
||||
"dihedral_atom3 dihedral_atom4 "
|
||||
"num_improper improper_type improper_atom1 improper_atom2 "
|
||||
"improper_atom3 improper_atom4 "
|
||||
"nspecial special";
|
||||
fields_copy = (char *)
|
||||
"q molecule num_bond bond_type bond_atom "
|
||||
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 "
|
||||
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 "
|
||||
"dihedral_atom3 dihedral_atom4 "
|
||||
"num_improper improper_type improper_atom1 improper_atom2 "
|
||||
"improper_atom3 improper_atom4 "
|
||||
"nspecial special";
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "";
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "q molecule";
|
||||
fields_border_vel = (char *) "q molecule";
|
||||
fields_exchange = (char *)
|
||||
"q molecule num_bond bond_type bond_atom "
|
||||
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 "
|
||||
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 "
|
||||
"dihedral_atom3 dihedral_atom4 "
|
||||
"num_improper improper_type improper_atom1 improper_atom2 "
|
||||
"improper_atom3 improper_atom4 "
|
||||
"nspecial special";
|
||||
fields_restart = (char *)
|
||||
"q molecule num_bond bond_type bond_atom "
|
||||
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 "
|
||||
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 "
|
||||
"dihedral_atom3 dihedral_atom4 "
|
||||
"num_improper improper_type improper_atom1 improper_atom2 "
|
||||
"improper_atom3 improper_atom4";
|
||||
fields_create = (char *)
|
||||
"q molecule num_bond num_angle num_dihedral num_improper nspecial";
|
||||
fields_data_atom = (char *) "id molecule type q x";
|
||||
fields_data_vel = (char *) "id v";
|
||||
|
||||
// clang-format off
|
||||
fields_grow = {"q", "molecule", "num_bond", "bond_type", "bond_atom", "num_angle", "angle_type",
|
||||
"angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type", "dihedral_atom1",
|
||||
"dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper", "improper_type",
|
||||
"improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4", "nspecial", "special"};
|
||||
fields_copy = {"q", "molecule", "num_bond", "bond_type", "bond_atom", "num_angle", "angle_type",
|
||||
"angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type", "dihedral_atom1",
|
||||
"dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper", "improper_type",
|
||||
"improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4", "nspecial", "special"};
|
||||
fields_border = {"q", "molecule"};
|
||||
fields_border_vel = {"q", "molecule"};
|
||||
fields_exchange = {"q", "molecule", "num_bond", "bond_type", "bond_atom",
|
||||
"num_angle", "angle_type", "angle_atom1", "angle_atom2", "angle_atom3",
|
||||
"num_dihedral", "dihedral_type", "dihedral_atom1", "dihedral_atom2",
|
||||
"dihedral_atom3", "dihedral_atom4", "num_improper", "improper_type", "improper_atom1",
|
||||
"improper_atom2", "improper_atom3", "improper_atom4", "nspecial", "special"};
|
||||
fields_restart = {"q", "molecule", "num_bond", "bond_type", "bond_atom", "num_angle",
|
||||
"angle_type", "angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type",
|
||||
"dihedral_atom1", "dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper",
|
||||
"improper_type", "improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4"};
|
||||
fields_create = {"q", "molecule", "num_bond", "num_angle",
|
||||
"num_dihedral", "num_improper", "nspecial"};
|
||||
fields_data_atom = {"id", "molecule", "type", "q", "x"};
|
||||
fields_data_vel = {"id", "v"};
|
||||
// clang-format on
|
||||
setup_fields();
|
||||
|
||||
bond_per_atom = angle_per_atom = dihedral_per_atom = improper_per_atom = 0;
|
||||
@ -83,10 +66,10 @@ AtomVecFull::AtomVecFull(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
AtomVecFull::~AtomVecFull()
|
||||
{
|
||||
delete [] bond_negative;
|
||||
delete [] angle_negative;
|
||||
delete [] dihedral_negative;
|
||||
delete [] improper_negative;
|
||||
delete[] bond_negative;
|
||||
delete[] angle_negative;
|
||||
delete[] dihedral_negative;
|
||||
delete[] improper_negative;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -116,22 +99,22 @@ void AtomVecFull::pack_restart_pre(int ilocal)
|
||||
// insure negative vectors are needed length
|
||||
|
||||
if (bond_per_atom < atom->bond_per_atom) {
|
||||
delete [] bond_negative;
|
||||
delete[] bond_negative;
|
||||
bond_per_atom = atom->bond_per_atom;
|
||||
bond_negative = new int[bond_per_atom];
|
||||
}
|
||||
if (angle_per_atom < atom->angle_per_atom) {
|
||||
delete [] angle_negative;
|
||||
delete[] angle_negative;
|
||||
angle_per_atom = atom->angle_per_atom;
|
||||
angle_negative = new int[angle_per_atom];
|
||||
}
|
||||
if (dihedral_per_atom < atom->dihedral_per_atom) {
|
||||
delete [] dihedral_negative;
|
||||
delete[] dihedral_negative;
|
||||
dihedral_per_atom = atom->dihedral_per_atom;
|
||||
dihedral_negative = new int[dihedral_per_atom];
|
||||
}
|
||||
if (improper_per_atom < atom->improper_per_atom) {
|
||||
delete [] improper_negative;
|
||||
delete[] improper_negative;
|
||||
improper_per_atom = atom->improper_per_atom;
|
||||
improper_negative = new int[improper_per_atom];
|
||||
}
|
||||
@ -144,7 +127,8 @@ void AtomVecFull::pack_restart_pre(int ilocal)
|
||||
bond_negative[m] = 1;
|
||||
bond_type[ilocal][m] = -bond_type[ilocal][m];
|
||||
any_bond_negative = 1;
|
||||
} else bond_negative[m] = 0;
|
||||
} else
|
||||
bond_negative[m] = 0;
|
||||
}
|
||||
|
||||
any_angle_negative = 0;
|
||||
@ -153,7 +137,8 @@ void AtomVecFull::pack_restart_pre(int ilocal)
|
||||
angle_negative[m] = 1;
|
||||
angle_type[ilocal][m] = -angle_type[ilocal][m];
|
||||
any_angle_negative = 1;
|
||||
} else angle_negative[m] = 0;
|
||||
} else
|
||||
angle_negative[m] = 0;
|
||||
}
|
||||
|
||||
any_dihedral_negative = 0;
|
||||
@ -162,7 +147,8 @@ void AtomVecFull::pack_restart_pre(int ilocal)
|
||||
dihedral_negative[m] = 1;
|
||||
dihedral_type[ilocal][m] = -dihedral_type[ilocal][m];
|
||||
any_dihedral_negative = 1;
|
||||
} else dihedral_negative[m] = 0;
|
||||
} else
|
||||
dihedral_negative[m] = 0;
|
||||
}
|
||||
|
||||
any_improper_negative = 0;
|
||||
@ -171,7 +157,8 @@ void AtomVecFull::pack_restart_pre(int ilocal)
|
||||
improper_negative[m] = 1;
|
||||
improper_type[ilocal][m] = -improper_type[ilocal][m];
|
||||
any_improper_negative = 1;
|
||||
} else improper_negative[m] = 0;
|
||||
} else
|
||||
improper_negative[m] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,14 +182,12 @@ void AtomVecFull::pack_restart_post(int ilocal)
|
||||
|
||||
if (any_dihedral_negative) {
|
||||
for (int m = 0; m < num_dihedral[ilocal]; m++)
|
||||
if (dihedral_negative[m])
|
||||
dihedral_type[ilocal][m] = -dihedral_type[ilocal][m];
|
||||
if (dihedral_negative[m]) dihedral_type[ilocal][m] = -dihedral_type[ilocal][m];
|
||||
}
|
||||
|
||||
if (any_improper_negative) {
|
||||
for (int m = 0; m < num_improper[ilocal]; m++)
|
||||
if (improper_negative[m])
|
||||
improper_type[ilocal][m] = -improper_type[ilocal][m];
|
||||
if (improper_negative[m]) improper_type[ilocal][m] = -improper_type[ilocal][m];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -32,46 +31,29 @@ AtomVecMolecular::AtomVecMolecular(LAMMPS *lmp) : AtomVec(lmp)
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *)
|
||||
"molecule num_bond bond_type bond_atom "
|
||||
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 "
|
||||
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 "
|
||||
"dihedral_atom3 dihedral_atom4 "
|
||||
"num_improper improper_type improper_atom1 improper_atom2 "
|
||||
"improper_atom3 improper_atom4 "
|
||||
"nspecial special";
|
||||
fields_copy = (char *)
|
||||
"molecule num_bond bond_type bond_atom "
|
||||
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 "
|
||||
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 "
|
||||
"dihedral_atom3 dihedral_atom4 "
|
||||
"num_improper improper_type improper_atom1 improper_atom2 "
|
||||
"improper_atom3 improper_atom4 "
|
||||
"nspecial special";
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "";
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "molecule";
|
||||
fields_border_vel = (char *) "molecule";
|
||||
fields_exchange = (char *)
|
||||
"molecule num_bond bond_type bond_atom "
|
||||
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 "
|
||||
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 "
|
||||
"dihedral_atom3 dihedral_atom4 "
|
||||
"num_improper improper_type improper_atom1 improper_atom2 "
|
||||
"improper_atom3 improper_atom4 "
|
||||
"nspecial special";
|
||||
fields_restart = (char *)
|
||||
"molecule num_bond bond_type bond_atom "
|
||||
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 "
|
||||
"num_dihedral dihedral_type dihedral_atom1 dihedral_atom2 "
|
||||
"dihedral_atom3 dihedral_atom4 "
|
||||
"num_improper improper_type improper_atom1 improper_atom2 "
|
||||
"improper_atom3 improper_atom4";
|
||||
fields_create = (char *)
|
||||
"molecule num_bond num_angle num_dihedral num_improper nspecial";
|
||||
fields_data_atom = (char *) "id molecule type x";
|
||||
fields_data_vel = (char *) "id v";
|
||||
// clang-format off
|
||||
fields_grow = {"molecule", "num_bond", "bond_type", "bond_atom", "num_angle", "angle_type",
|
||||
"angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type", "dihedral_atom1",
|
||||
"dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper", "improper_type",
|
||||
"improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4", "nspecial", "special"};
|
||||
fields_copy = {"molecule", "num_bond", "bond_type", "bond_atom", "num_angle", "angle_type",
|
||||
"angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type", "dihedral_atom1",
|
||||
"dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper", "improper_type",
|
||||
"improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4", "nspecial", "special"};
|
||||
fields_border = {"molecule"};
|
||||
fields_border_vel = {"molecule"};
|
||||
fields_exchange = {"molecule", "num_bond", "bond_type", "bond_atom", "num_angle", "angle_type",
|
||||
"angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type", "dihedral_atom1",
|
||||
"dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper", "improper_type",
|
||||
"improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4", "nspecial", "special"};
|
||||
fields_restart = {"molecule", "num_bond", "bond_type", "bond_atom", "num_angle", "angle_type",
|
||||
"angle_atom1", "angle_atom2", "angle_atom3", "num_dihedral", "dihedral_type", "dihedral_atom1",
|
||||
"dihedral_atom2", "dihedral_atom3", "dihedral_atom4", "num_improper", "improper_type",
|
||||
"improper_atom1", "improper_atom2", "improper_atom3", "improper_atom4"};
|
||||
fields_create = {"molecule", "num_bond", "num_angle", "num_dihedral", "num_improper", "nspecial"};
|
||||
fields_data_atom = {"id", "molecule", "type", "x"};
|
||||
fields_data_vel = {"id", "v"};
|
||||
// clang-format on
|
||||
|
||||
setup_fields();
|
||||
|
||||
@ -83,10 +65,10 @@ AtomVecMolecular::AtomVecMolecular(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
AtomVecMolecular::~AtomVecMolecular()
|
||||
{
|
||||
delete [] bond_negative;
|
||||
delete [] angle_negative;
|
||||
delete [] dihedral_negative;
|
||||
delete [] improper_negative;
|
||||
delete[] bond_negative;
|
||||
delete[] angle_negative;
|
||||
delete[] dihedral_negative;
|
||||
delete[] improper_negative;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -116,22 +98,22 @@ void AtomVecMolecular::pack_restart_pre(int ilocal)
|
||||
// insure negative vectors are needed length
|
||||
|
||||
if (bond_per_atom < atom->bond_per_atom) {
|
||||
delete [] bond_negative;
|
||||
delete[] bond_negative;
|
||||
bond_per_atom = atom->bond_per_atom;
|
||||
bond_negative = new int[bond_per_atom];
|
||||
}
|
||||
if (angle_per_atom < atom->angle_per_atom) {
|
||||
delete [] angle_negative;
|
||||
delete[] angle_negative;
|
||||
angle_per_atom = atom->angle_per_atom;
|
||||
angle_negative = new int[angle_per_atom];
|
||||
}
|
||||
if (dihedral_per_atom < atom->dihedral_per_atom) {
|
||||
delete [] dihedral_negative;
|
||||
delete[] dihedral_negative;
|
||||
dihedral_per_atom = atom->dihedral_per_atom;
|
||||
dihedral_negative = new int[dihedral_per_atom];
|
||||
}
|
||||
if (improper_per_atom < atom->improper_per_atom) {
|
||||
delete [] improper_negative;
|
||||
delete[] improper_negative;
|
||||
improper_per_atom = atom->improper_per_atom;
|
||||
improper_negative = new int[improper_per_atom];
|
||||
}
|
||||
@ -144,7 +126,8 @@ void AtomVecMolecular::pack_restart_pre(int ilocal)
|
||||
bond_negative[m] = 1;
|
||||
bond_type[ilocal][m] = -bond_type[ilocal][m];
|
||||
any_bond_negative = 1;
|
||||
} else bond_negative[m] = 0;
|
||||
} else
|
||||
bond_negative[m] = 0;
|
||||
}
|
||||
|
||||
any_angle_negative = 0;
|
||||
@ -153,7 +136,8 @@ void AtomVecMolecular::pack_restart_pre(int ilocal)
|
||||
angle_negative[m] = 1;
|
||||
angle_type[ilocal][m] = -angle_type[ilocal][m];
|
||||
any_angle_negative = 1;
|
||||
} else angle_negative[m] = 0;
|
||||
} else
|
||||
angle_negative[m] = 0;
|
||||
}
|
||||
|
||||
any_dihedral_negative = 0;
|
||||
@ -162,7 +146,8 @@ void AtomVecMolecular::pack_restart_pre(int ilocal)
|
||||
dihedral_negative[m] = 1;
|
||||
dihedral_type[ilocal][m] = -dihedral_type[ilocal][m];
|
||||
any_dihedral_negative = 1;
|
||||
} else dihedral_negative[m] = 0;
|
||||
} else
|
||||
dihedral_negative[m] = 0;
|
||||
}
|
||||
|
||||
any_improper_negative = 0;
|
||||
@ -171,7 +156,8 @@ void AtomVecMolecular::pack_restart_pre(int ilocal)
|
||||
improper_negative[m] = 1;
|
||||
improper_type[ilocal][m] = -improper_type[ilocal][m];
|
||||
any_improper_negative = 1;
|
||||
} else improper_negative[m] = 0;
|
||||
} else
|
||||
improper_negative[m] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,14 +181,12 @@ void AtomVecMolecular::pack_restart_post(int ilocal)
|
||||
|
||||
if (any_dihedral_negative) {
|
||||
for (int m = 0; m < num_dihedral[ilocal]; m++)
|
||||
if (dihedral_negative[m])
|
||||
dihedral_type[ilocal][m] = -dihedral_type[ilocal][m];
|
||||
if (dihedral_negative[m]) dihedral_type[ilocal][m] = -dihedral_type[ilocal][m];
|
||||
}
|
||||
|
||||
if (any_improper_negative) {
|
||||
for (int m = 0; m < num_improper[ilocal]; m++)
|
||||
if (improper_negative[m])
|
||||
improper_type[ilocal][m] = -improper_type[ilocal][m];
|
||||
if (improper_negative[m]) improper_type[ilocal][m] = -improper_type[ilocal][m];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -36,18 +35,15 @@ AtomVecTemplate::AtomVecTemplate(LAMMPS *lmp) : AtomVec(lmp)
|
||||
// order of fields in the string does not matter
|
||||
// except fields_data_atom and fields_data_vel which must match data file
|
||||
|
||||
fields_grow = (char *) "molecule molindex molatom";
|
||||
fields_copy = (char *) "molecule molindex molatom";
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "";
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "molecule molindex molatom";
|
||||
fields_border_vel = (char *) "molecule molindex molatom";
|
||||
fields_exchange = (char *) "molecule molindex molatom";
|
||||
fields_restart = (char *) "molecule molindex molatom";
|
||||
fields_create = (char *) "molecule molindex molatom";
|
||||
fields_data_atom = (char *) "id molecule molindex molatom type x";
|
||||
fields_data_vel = (char *) "id v";
|
||||
fields_grow = {"molecule", "molindex", "molatom"};
|
||||
fields_copy = {"molecule", "molindex", "molatom"};
|
||||
fields_border = {"molecule", "molindex", "molatom"};
|
||||
fields_border_vel = {"molecule", "molindex", "molatom"};
|
||||
fields_exchange = {"molecule", "molindex", "molatom"};
|
||||
fields_restart = {"molecule", "molindex", "molatom"};
|
||||
fields_create = {"molecule", "molindex", "molatom"};
|
||||
fields_data_atom = {"id", "molecule", "molindex", "molatom", "type", "x"};
|
||||
fields_data_vel = {"id", "v"};
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
@ -58,11 +54,10 @@ AtomVecTemplate::AtomVecTemplate(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
void AtomVecTemplate::process_args(int narg, char **arg)
|
||||
{
|
||||
if (narg != 1) error->all(FLERR,"Illegal atom_style template command");
|
||||
if (narg != 1) error->all(FLERR, "Illegal atom_style template command");
|
||||
|
||||
int imol = atom->find_molecule(arg[0]);
|
||||
if (imol == -1) error->all(FLERR,"Molecule template ID for "
|
||||
"atom_style template does not exist");
|
||||
if (imol == -1) error->all(FLERR, "Molecule template ID for atom_style template does not exist");
|
||||
|
||||
onemols = &atom->molecules[imol];
|
||||
nset = atom->molecules[imol]->nset;
|
||||
@ -81,10 +76,10 @@ void AtomVecTemplate::process_args(int narg, char **arg)
|
||||
// do this here b/c data file will typically not contain these settings
|
||||
|
||||
for (int i = 0; i < nset; i++) {
|
||||
atom->nbondtypes = MAX(atom->nbondtypes,onemols[i]->nbondtypes);
|
||||
atom->nangletypes = MAX(atom->nangletypes,onemols[i]->nangletypes);
|
||||
atom->ndihedraltypes = MAX(atom->ndihedraltypes,onemols[i]->ndihedraltypes);
|
||||
atom->nimpropertypes = MAX(atom->nimpropertypes,onemols[i]->nimpropertypes);
|
||||
atom->nbondtypes = MAX(atom->nbondtypes, onemols[i]->nbondtypes);
|
||||
atom->nangletypes = MAX(atom->nangletypes, onemols[i]->nangletypes);
|
||||
atom->ndihedraltypes = MAX(atom->ndihedraltypes, onemols[i]->ndihedraltypes);
|
||||
atom->nimpropertypes = MAX(atom->nimpropertypes, onemols[i]->nimpropertypes);
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,7 +124,6 @@ void AtomVecTemplate::pack_data_post(int ilocal)
|
||||
molatom[ilocal]--;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
modify what AtomVec::data_atom() just unpacked
|
||||
or initialize other atom quantities
|
||||
@ -141,7 +135,7 @@ void AtomVecTemplate::data_atom_post(int ilocal)
|
||||
int molatom_one = --molatom[ilocal];
|
||||
|
||||
if ((molindex_one < -1) || (molindex_one >= nset))
|
||||
error->one(FLERR,"Invalid template index in Atoms section of data file");
|
||||
error->one(FLERR, "Invalid template index in Atoms section of data file");
|
||||
if ((molatom_one < -1) || ((molindex_one >= 0) && (molatom_one >= onemols[molindex_one]->natoms)))
|
||||
error->one(FLERR,"Invalid template atom in Atoms section of data file");
|
||||
error->one(FLERR, "Invalid template atom in Atoms section of data file");
|
||||
}
|
||||
|
||||
@ -28,14 +28,14 @@
|
||||
|
||||
#include "omp_compat.h"
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
using MathConst::MY_PIS;
|
||||
|
||||
#define EPSILON 1e-6
|
||||
static constexpr double EPSILON = 1.0e-6;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PairLJCutCoulCutDielectricOMP::PairLJCutCoulCutDielectricOMP(LAMMPS *lmp) :
|
||||
PairLJCutCoulCutDielectric(lmp), ThrOMP(lmp, THR_PAIR)
|
||||
PairLJCutCoulCutDielectricOMP::PairLJCutCoulCutDielectricOMP(LAMMPS *_lmp) :
|
||||
PairLJCutCoulCutDielectric(_lmp), ThrOMP(_lmp, THR_PAIR)
|
||||
{
|
||||
}
|
||||
|
||||
@ -169,8 +169,8 @@ void PairLJCutCoulCutDielectricOMP::eval(int iifrom, int iito, ThrData *const th
|
||||
r2inv = 1.0 / rsq;
|
||||
|
||||
if (rsq < cut_coulsq[itype][jtype] && rsq > EPSILON) {
|
||||
efield_i = q[j] * sqrt(r2inv);
|
||||
forcecoul = qqrd2e * qtmp * efield_i;
|
||||
efield_i = qqrd2e * q[j] * sqrt(r2inv);
|
||||
forcecoul = qtmp * efield_i;
|
||||
epot_i = efield_i;
|
||||
} else
|
||||
epot_i = efield_i = forcecoul = 0.0;
|
||||
|
||||
231
src/OPENMP/pair_lj_cut_coul_debye_dielectric_omp.cpp
Normal file
231
src/OPENMP/pair_lj_cut_coul_debye_dielectric_omp.cpp
Normal file
@ -0,0 +1,231 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/ Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing author: Trung Nguyen (U Chicago)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "pair_lj_cut_coul_debye_dielectric_omp.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "comm.h"
|
||||
#include "force.h"
|
||||
#include "math_const.h"
|
||||
#include "memory.h"
|
||||
#include "neigh_list.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "omp_compat.h"
|
||||
using namespace LAMMPS_NS;
|
||||
using MathConst::MY_PIS;
|
||||
|
||||
static constexpr double EPSILON = 1.0e-6;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PairLJCutCoulDebyeDielectricOMP::PairLJCutCoulDebyeDielectricOMP(LAMMPS *_lmp) :
|
||||
PairLJCutCoulDebyeDielectric(_lmp), ThrOMP(_lmp, THR_PAIR)
|
||||
{
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void PairLJCutCoulDebyeDielectricOMP::compute(int eflag, int vflag)
|
||||
{
|
||||
ev_init(eflag, vflag);
|
||||
|
||||
if (atom->nmax > nmax) {
|
||||
memory->destroy(efield);
|
||||
memory->destroy(epot);
|
||||
nmax = atom->nmax;
|
||||
memory->create(efield, nmax, 3, "pair:efield");
|
||||
memory->create(epot, nmax, "pair:epot");
|
||||
}
|
||||
|
||||
const int nall = atom->nlocal + atom->nghost;
|
||||
const int nthreads = comm->nthreads;
|
||||
const int inum = list->inum;
|
||||
|
||||
#if defined(_OPENMP)
|
||||
#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(eflag, vflag)
|
||||
#endif
|
||||
{
|
||||
int ifrom, ito, tid;
|
||||
|
||||
loop_setup_thr(ifrom, ito, tid, inum, nthreads);
|
||||
ThrData *thr = fix->get_thr(tid);
|
||||
thr->timer(Timer::START);
|
||||
ev_setup_thr(eflag, vflag, nall, eatom, vatom, nullptr, thr);
|
||||
|
||||
if (evflag) {
|
||||
if (eflag) {
|
||||
if (force->newton_pair)
|
||||
eval<1, 1, 1>(ifrom, ito, thr);
|
||||
else
|
||||
eval<1, 1, 0>(ifrom, ito, thr);
|
||||
} else {
|
||||
if (force->newton_pair)
|
||||
eval<1, 0, 1>(ifrom, ito, thr);
|
||||
else
|
||||
eval<1, 0, 0>(ifrom, ito, thr);
|
||||
}
|
||||
} else {
|
||||
if (force->newton_pair)
|
||||
eval<0, 0, 1>(ifrom, ito, thr);
|
||||
else
|
||||
eval<0, 0, 0>(ifrom, ito, thr);
|
||||
}
|
||||
|
||||
thr->timer(Timer::PAIR);
|
||||
reduce_thr(this, eflag, vflag, thr);
|
||||
} // end of omp parallel region
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
template <int EVFLAG, int EFLAG, int NEWTON_PAIR>
|
||||
void PairLJCutCoulDebyeDielectricOMP::eval(int iifrom, int iito, ThrData *const thr)
|
||||
{
|
||||
int i, j, ii, jj, jnum, itype, jtype;
|
||||
double qtmp, etmp, xtmp, ytmp, ztmp, delx, dely, delz, evdwl, ecoul;
|
||||
double fpair_i, fpair_j;
|
||||
double rsq, r2inv, r6inv, forcecoul, forcelj, factor_coul, factor_lj, efield_i, epot_i;
|
||||
double r, rinv, screening;
|
||||
int *ilist, *jlist, *numneigh, **firstneigh;
|
||||
|
||||
evdwl = ecoul = 0.0;
|
||||
|
||||
const dbl3_t *_noalias const x = (dbl3_t *) atom->x[0];
|
||||
dbl3_t *_noalias const f = (dbl3_t *) thr->get_f()[0];
|
||||
const double *_noalias const q = atom->q;
|
||||
const double *_noalias const eps = atom->epsilon;
|
||||
const dbl3_t *_noalias const norm = (dbl3_t *) atom->mu[0];
|
||||
const double *_noalias const curvature = atom->curvature;
|
||||
const double *_noalias const area = atom->area;
|
||||
const int *_noalias const type = atom->type;
|
||||
const int nlocal = atom->nlocal;
|
||||
const double *_noalias const special_coul = force->special_coul;
|
||||
const double *_noalias const special_lj = force->special_lj;
|
||||
const double qqrd2e = force->qqrd2e;
|
||||
double fxtmp, fytmp, fztmp, extmp, eytmp, eztmp;
|
||||
|
||||
ilist = list->ilist;
|
||||
numneigh = list->numneigh;
|
||||
firstneigh = list->firstneigh;
|
||||
|
||||
// loop over neighbors of my atoms
|
||||
|
||||
for (ii = iifrom; ii < iito; ++ii) {
|
||||
|
||||
i = ilist[ii];
|
||||
qtmp = q[i];
|
||||
xtmp = x[i].x;
|
||||
ytmp = x[i].y;
|
||||
ztmp = x[i].z;
|
||||
etmp = eps[i];
|
||||
itype = type[i];
|
||||
jlist = firstneigh[i];
|
||||
jnum = numneigh[i];
|
||||
fxtmp = fytmp = fztmp = 0.0;
|
||||
extmp = eytmp = eztmp = 0.0;
|
||||
|
||||
// self term Eq. (55) for I_{ii} and Eq. (52) and in Barros et al
|
||||
double curvature_threshold = sqrt(area[i]);
|
||||
if (curvature[i] < curvature_threshold) {
|
||||
double sf = curvature[i] / (4.0 * MY_PIS * curvature_threshold) * area[i] * q[i];
|
||||
efield[i][0] = sf * norm[i].x;
|
||||
efield[i][1] = sf * norm[i].y;
|
||||
efield[i][2] = sf * norm[i].z;
|
||||
} else {
|
||||
efield[i][0] = efield[i][1] = efield[i][2] = 0;
|
||||
}
|
||||
|
||||
epot[i] = 0;
|
||||
|
||||
for (jj = 0; jj < jnum; jj++) {
|
||||
j = jlist[jj];
|
||||
factor_lj = special_lj[sbmask(j)];
|
||||
factor_coul = special_coul[sbmask(j)];
|
||||
j &= NEIGHMASK;
|
||||
|
||||
delx = xtmp - x[j].x;
|
||||
dely = ytmp - x[j].y;
|
||||
delz = ztmp - x[j].z;
|
||||
rsq = delx * delx + dely * dely + delz * delz;
|
||||
jtype = type[j];
|
||||
|
||||
if (rsq < cutsq[itype][jtype]) {
|
||||
r2inv = 1.0 / rsq;
|
||||
|
||||
if (rsq < cut_coulsq[itype][jtype] && rsq > EPSILON) {
|
||||
r = sqrt(rsq);
|
||||
rinv = 1.0 / r;
|
||||
screening = exp(-kappa * r);
|
||||
efield_i = qqrd2e * q[j] * screening * (kappa + rinv);
|
||||
forcecoul = qtmp * efield_i;
|
||||
epot_i = efield_i;
|
||||
} else
|
||||
epot_i = efield_i = forcecoul = 0.0;
|
||||
|
||||
if (rsq < cut_ljsq[itype][jtype]) {
|
||||
r6inv = r2inv * r2inv * r2inv;
|
||||
forcelj = r6inv * (lj1[itype][jtype] * r6inv - lj2[itype][jtype]);
|
||||
} else
|
||||
forcelj = 0.0;
|
||||
|
||||
fpair_i = (factor_coul * etmp * forcecoul + factor_lj * forcelj) * r2inv;
|
||||
|
||||
fxtmp += delx * fpair_i;
|
||||
fytmp += dely * fpair_i;
|
||||
fztmp += delz * fpair_i;
|
||||
|
||||
efield_i *= (factor_coul * etmp * r2inv);
|
||||
extmp += delx * efield_i;
|
||||
eytmp += dely * efield_i;
|
||||
eztmp += delz * efield_i;
|
||||
epot[i] += epot_i;
|
||||
|
||||
if (NEWTON_PAIR || j >= nlocal) {
|
||||
fpair_j = (factor_coul * eps[j] * forcecoul + factor_lj * forcelj) * r2inv;
|
||||
f[j].x -= delx * fpair_j;
|
||||
f[j].y -= dely * fpair_j;
|
||||
f[j].z -= delz * fpair_j;
|
||||
}
|
||||
|
||||
if (EFLAG) {
|
||||
if (rsq < cut_coulsq[itype][jtype]) {
|
||||
ecoul = factor_coul * qqrd2e * qtmp * q[j] * (etmp + eps[j]) * rinv * screening;
|
||||
} else
|
||||
ecoul = 0.0;
|
||||
ecoul *= 0.5;
|
||||
if (rsq < cut_ljsq[itype][jtype]) {
|
||||
evdwl = r6inv * (lj3[itype][jtype] * r6inv - lj4[itype][jtype]) - offset[itype][jtype];
|
||||
evdwl *= factor_lj;
|
||||
} else
|
||||
evdwl = 0.0;
|
||||
}
|
||||
|
||||
if (EVFLAG)
|
||||
ev_tally_thr(this, i, j, nlocal, NEWTON_PAIR, evdwl, ecoul, fpair_i, delx, dely, delz,
|
||||
thr);
|
||||
}
|
||||
}
|
||||
f[i].x += fxtmp;
|
||||
f[i].y += fytmp;
|
||||
f[i].z += fztmp;
|
||||
efield[i][0] += extmp;
|
||||
efield[i][1] += eytmp;
|
||||
efield[i][2] += eztmp;
|
||||
}
|
||||
}
|
||||
60
src/OPENMP/pair_lj_cut_coul_debye_dielectric_omp.h
Normal file
60
src/OPENMP/pair_lj_cut_coul_debye_dielectric_omp.h
Normal file
@ -0,0 +1,60 @@
|
||||
/* -*- c++ -*- ----------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/ Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
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 PAIR_CLASS
|
||||
// clang-format off
|
||||
PairStyle(lj/cut/coul/debye/dielectric/omp,PairLJCutCoulDebyeDielectricOMP);
|
||||
// clang-format on
|
||||
#else
|
||||
|
||||
#ifndef LMP_PAIR_LJ_CUT_COUL_DEBYE_DIELECTRIC_OMP_H
|
||||
#define LMP_PAIR_LJ_CUT_COUL_DEBYE_DIELECTRIC_OMP_H
|
||||
|
||||
#include "pair_lj_cut_coul_debye_dielectric.h"
|
||||
#include "thr_omp.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class PairLJCutCoulDebyeDielectricOMP : public PairLJCutCoulDebyeDielectric, public ThrOMP {
|
||||
public:
|
||||
PairLJCutCoulDebyeDielectricOMP(class LAMMPS *);
|
||||
~PairLJCutCoulDebyeDielectricOMP() override = default;
|
||||
void compute(int, int) override;
|
||||
|
||||
protected:
|
||||
template <int EVFLAG, int EFLAG, int NEWTON_PAIR>
|
||||
void eval(int ifrom, int ito, ThrData *const thr);
|
||||
};
|
||||
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ERROR/WARNING messages:
|
||||
|
||||
E: Illegal ... command
|
||||
|
||||
Self-explanatory. Check the input script syntax and compare to the
|
||||
documentation for the command. You can use -echo screen as a
|
||||
command-line option when running LAMMPS to see the offending line.
|
||||
|
||||
E: Incorrect args for pair coefficients
|
||||
|
||||
Self-explanatory. Check the input script or data file.
|
||||
|
||||
E: Pair style lj/cut/coul/debye/dielectric requires atom attribute q
|
||||
|
||||
The atom style defined does not have this attribute.
|
||||
|
||||
*/
|
||||
@ -19,6 +19,7 @@
|
||||
|
||||
#include "atom.h"
|
||||
#include "comm.h"
|
||||
#include "ewald_const.h"
|
||||
#include "force.h"
|
||||
#include "math_const.h"
|
||||
#include "memory.h"
|
||||
@ -28,20 +29,13 @@
|
||||
|
||||
#include "omp_compat.h"
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
|
||||
#define EWALD_F 1.12837917
|
||||
#define EWALD_P 0.3275911
|
||||
#define A1 0.254829592
|
||||
#define A2 -0.284496736
|
||||
#define A3 1.421413741
|
||||
#define A4 -1.453152027
|
||||
#define A5 1.061405429
|
||||
using namespace EwaldConst;
|
||||
using MathConst::MY_PIS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PairLJCutCoulLongDielectricOMP::PairLJCutCoulLongDielectricOMP(LAMMPS *lmp) :
|
||||
PairLJCutCoulLongDielectric(lmp), ThrOMP(lmp, THR_PAIR)
|
||||
PairLJCutCoulLongDielectricOMP::PairLJCutCoulLongDielectricOMP(LAMMPS *_lmp) :
|
||||
PairLJCutCoulLongDielectric(_lmp), ThrOMP(_lmp, THR_PAIR)
|
||||
{
|
||||
}
|
||||
|
||||
@ -184,7 +178,7 @@ void PairLJCutCoulLongDielectricOMP::eval(int iifrom, int iito, ThrData *const t
|
||||
forcecoul = prefactor * (erfc + EWALD_F * grij * expm2);
|
||||
if (factor_coul < 1.0) forcecoul -= (1.0 - factor_coul) * prefactor;
|
||||
|
||||
prefactorE = q[j] / r;
|
||||
prefactorE = qqrd2e * q[j] / r;
|
||||
efield_i = prefactorE * (erfc + EWALD_F * grij * expm2);
|
||||
if (factor_coul < 1.0) efield_i -= (1.0 - factor_coul) * prefactorE;
|
||||
epot_i = efield_i;
|
||||
@ -203,7 +197,7 @@ void PairLJCutCoulLongDielectricOMP::eval(int iifrom, int iito, ThrData *const t
|
||||
prefactor = qtmp * q[j] * table;
|
||||
forcecoul -= (1.0 - factor_coul) * prefactor;
|
||||
|
||||
prefactorE = q[j] * table / qqrd2e;
|
||||
prefactorE = q[j] * table;
|
||||
efield_i -= (1.0 - factor_coul) * prefactorE;
|
||||
}
|
||||
epot_i = efield_i;
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -23,20 +22,19 @@
|
||||
#include "error.h"
|
||||
|
||||
#include <cfloat>
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
static const char cite_peri_package[] =
|
||||
"PERI package for Peridynamics:\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"
|
||||
" year = 2008,\n"
|
||||
" volume = 179,\n"
|
||||
" pages = {777--783}\n"
|
||||
"}\n\n";
|
||||
"PERI package for Peridynamics:\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"
|
||||
" year = 2008,\n"
|
||||
" volume = 179,\n"
|
||||
" pages = {777--783}\n"
|
||||
"}\n\n";
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -55,18 +53,17 @@ AtomVecPeri::AtomVecPeri(LAMMPS *lmp) : AtomVec(lmp)
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "rmass vfrac s0 x0";
|
||||
fields_copy = (char *) "rmass vfrac s0 x0";
|
||||
fields_comm = (char *) "s0";
|
||||
fields_comm_vel = (char *) "s0";
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "rmass vfrac s0 x0";
|
||||
fields_border_vel = (char *) "rmass vfrac s0 x0";
|
||||
fields_exchange = (char *) "rmass vfrac s0 x0";
|
||||
fields_restart = (char *) "rmass vfrac s0 x0";
|
||||
fields_create = (char *) "rmass vfrac s0 x0";
|
||||
fields_data_atom = (char *) "id type vfrac rmass x";
|
||||
fields_data_vel = (char *) "id v";
|
||||
fields_grow = {"rmass", "vfrac", "s0", "x0"};
|
||||
fields_copy = {"rmass", "vfrac", "s0", "x0"};
|
||||
fields_comm = {"s0"};
|
||||
fields_comm_vel = {"s0"};
|
||||
fields_border = {"rmass", "vfrac", "s0", "x0"};
|
||||
fields_border_vel = {"rmass", "vfrac", "s0", "x0"};
|
||||
fields_exchange = {"rmass", "vfrac", "s0", "x0"};
|
||||
fields_restart = {"rmass", "vfrac", "s0", "x0"};
|
||||
fields_create = {"rmass", "vfrac", "s0", "x0"};
|
||||
fields_data_atom = {"id", "type", "vfrac", "rmass", "x"};
|
||||
fields_data_vel = {"id", "v"};
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
@ -110,8 +107,7 @@ void AtomVecPeri::data_atom_post(int ilocal)
|
||||
x0[ilocal][1] = x[ilocal][1];
|
||||
x0[ilocal][2] = x[ilocal][2];
|
||||
|
||||
if (rmass[ilocal] <= 0.0)
|
||||
error->one(FLERR,"Invalid mass in Atoms section of data file");
|
||||
if (rmass[ilocal] <= 0.0) error->one(FLERR, "Invalid mass in Atoms section of data file");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -119,10 +115,10 @@ void AtomVecPeri::data_atom_post(int ilocal)
|
||||
return -1 if name is unknown to this atom style
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecPeri::property_atom(char *name)
|
||||
int AtomVecPeri::property_atom(const std::string &name)
|
||||
{
|
||||
if (strcmp(name,"vfrac") == 0) return 0;
|
||||
if (strcmp(name,"s0") == 0) return 1;
|
||||
if (name == "vfrac") return 0;
|
||||
if (name == "s0") return 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -131,8 +127,7 @@ int AtomVecPeri::property_atom(char *name)
|
||||
index maps to data specific to this atom style
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecPeri::pack_property_atom(int index, double *buf,
|
||||
int nvalues, int groupbit)
|
||||
void AtomVecPeri::pack_property_atom(int index, double *buf, int nvalues, int groupbit)
|
||||
{
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
@ -140,14 +135,18 @@ void AtomVecPeri::pack_property_atom(int index, double *buf,
|
||||
|
||||
if (index == 0) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = vfrac[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = vfrac[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
} else if (index == 1) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = s0[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = s0[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ class AtomVecPeri : public AtomVec {
|
||||
void grow_pointers() override;
|
||||
void create_atom_post(int) override;
|
||||
void data_atom_post(int) override;
|
||||
int property_atom(char *) override;
|
||||
int property_atom(const std::string &) override;
|
||||
void pack_property_atom(int, double *, int, int) override;
|
||||
|
||||
private:
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -16,8 +15,6 @@
|
||||
|
||||
#include "atom.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -38,18 +35,18 @@ AtomVecSPH::AtomVecSPH(LAMMPS *lmp) : AtomVec(lmp)
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "rho drho esph desph cv vest";
|
||||
fields_copy = (char *) "rho drho esph desph cv vest";
|
||||
fields_comm = (char *) "rho esph vest";
|
||||
fields_comm_vel = (char *) "rho esph vest";
|
||||
fields_reverse = (char *) "drho desph";
|
||||
fields_border = (char *) "rho esph cv vest";
|
||||
fields_border_vel = (char *) "rho esph cv vest";
|
||||
fields_exchange = (char *) "rho esph cv vest";
|
||||
fields_restart = (char * ) "rho esph cv vest";
|
||||
fields_create = (char *) "rho esph cv vest desph drho";
|
||||
fields_data_atom = (char *) "id type rho esph cv x";
|
||||
fields_data_vel = (char *) "id v";
|
||||
fields_grow = {"rho", "drho", "esph", "desph", "cv", "vest"};
|
||||
fields_copy = {"rho", "drho", "esph", "desph", "cv", "vest"};
|
||||
fields_comm = {"rho", "esph", "vest"};
|
||||
fields_comm_vel = {"rho", "esph", "vest"};
|
||||
fields_reverse = {"drho", "desph"};
|
||||
fields_border = {"rho", "esph", "cv", "vest"};
|
||||
fields_border_vel = {"rho", "esph", "cv", "vest"};
|
||||
fields_exchange = {"rho", "esph", "cv", "vest"};
|
||||
fields_restart = {"rho", "esph", "cv", "vest"};
|
||||
fields_create = {"rho", "esph", "cv", "vest", "desph", "drho"};
|
||||
fields_data_atom = {"id", "type", "rho", "esph", "cv", "x"};
|
||||
fields_data_vel = {"id", "v"};
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
@ -76,8 +73,8 @@ void AtomVecSPH::grow_pointers()
|
||||
|
||||
void AtomVecSPH::force_clear(int n, size_t nbytes)
|
||||
{
|
||||
memset(&desph[n],0,nbytes);
|
||||
memset(&drho[n],0,nbytes);
|
||||
memset(&desph[n], 0, nbytes);
|
||||
memset(&drho[n], 0, nbytes);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -108,13 +105,13 @@ void AtomVecSPH::data_atom_post(int ilocal)
|
||||
return -1 if name is unknown to this atom style
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecSPH::property_atom(char *name)
|
||||
int AtomVecSPH::property_atom(const std::string &name)
|
||||
{
|
||||
if (strcmp(name,"rho") == 0) return 0;
|
||||
if (strcmp(name,"drho") == 0) return 1;
|
||||
if (strcmp(name,"esph") == 0) return 2;
|
||||
if (strcmp(name,"desph") == 0) return 3;
|
||||
if (strcmp(name,"cv") == 0) return 4;
|
||||
if (name == "rho") return 0;
|
||||
if (name == "drho") return 1;
|
||||
if (name == "esph") return 2;
|
||||
if (name == "desph") return 3;
|
||||
if (name == "cv") return 4;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -123,8 +120,7 @@ int AtomVecSPH::property_atom(char *name)
|
||||
index maps to data specific to this atom style
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecSPH::pack_property_atom(int index, double *buf,
|
||||
int nvalues, int groupbit)
|
||||
void AtomVecSPH::pack_property_atom(int index, double *buf, int nvalues, int groupbit)
|
||||
{
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
@ -132,32 +128,42 @@ void AtomVecSPH::pack_property_atom(int index, double *buf,
|
||||
|
||||
if (index == 0) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = rho[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = rho[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
} else if (index == 1) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = drho[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = drho[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
} else if (index == 2) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = esph[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = esph[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
} else if (index == 3) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = desph[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = desph[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
} else if (index == 4) {
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) buf[n] = cv[i];
|
||||
else buf[n] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
buf[n] = cv[i];
|
||||
else
|
||||
buf[n] = 0.0;
|
||||
n += nvalues;
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ class AtomVecSPH : public AtomVec {
|
||||
void force_clear(int, size_t) override;
|
||||
void create_atom_post(int) override;
|
||||
void data_atom_post(int) override;
|
||||
int property_atom(char *) override;
|
||||
int property_atom(const std::string &) override;
|
||||
void pack_property_atom(int, double *, int, int) override;
|
||||
|
||||
private:
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
@ -25,10 +24,11 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "atom_vec_spin.h"
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
#include "atom.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -46,18 +46,18 @@ AtomVecSpin::AtomVecSpin(LAMMPS *lmp) : AtomVec(lmp)
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "sp fm fm_long";
|
||||
fields_copy = (char *) "sp";
|
||||
fields_comm = (char *) "sp";
|
||||
fields_comm_vel = (char *) "sp";
|
||||
fields_reverse = (char *) "fm fm_long";
|
||||
fields_border = (char *) "sp";
|
||||
fields_border_vel = (char *) "sp";
|
||||
fields_exchange = (char *) "sp";
|
||||
fields_restart = (char *) "sp";
|
||||
fields_create = (char *) "sp";
|
||||
fields_data_atom = (char *) "id type x sp";
|
||||
fields_data_vel = (char *) "id v";
|
||||
fields_grow = {"sp", "fm", "fm_long"};
|
||||
fields_copy = {"sp"};
|
||||
fields_comm = {"sp"};
|
||||
fields_comm_vel = {"sp"};
|
||||
fields_reverse = {"fm", "fm_long"};
|
||||
fields_border = {"sp"};
|
||||
fields_border_vel = {"sp"};
|
||||
fields_exchange = {"sp"};
|
||||
fields_restart = {"sp"};
|
||||
fields_create = {"sp"};
|
||||
fields_data_atom = {"id", "type", "x", "sp"};
|
||||
fields_data_vel = {"id", "v"};
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
@ -82,8 +82,8 @@ void AtomVecSpin::grow_pointers()
|
||||
|
||||
void AtomVecSpin::force_clear(int n, size_t nbytes)
|
||||
{
|
||||
memset(&fm[n][0],0,3*nbytes);
|
||||
memset(&fm_long[n][0],0,3*nbytes);
|
||||
memset(&fm[n][0], 0, 3 * nbytes);
|
||||
memset(&fm_long[n][0], 0, 3 * nbytes);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -94,8 +94,7 @@ void AtomVecSpin::force_clear(int n, size_t nbytes)
|
||||
void AtomVecSpin::data_atom_post(int ilocal)
|
||||
{
|
||||
double *sp_one = sp[ilocal];
|
||||
double norm =
|
||||
1.0/sqrt(sp_one[0]*sp_one[0] + sp_one[1]*sp_one[1] + sp_one[2]*sp_one[2]);
|
||||
double norm = 1.0 / sqrt(sp_one[0] * sp_one[0] + sp_one[1] * sp_one[1] + sp_one[2] * sp_one[2]);
|
||||
sp_one[0] *= norm;
|
||||
sp_one[1] *= norm;
|
||||
sp_one[2] *= norm;
|
||||
|
||||
76
src/atom.cpp
76
src/atom.cpp
@ -47,7 +47,6 @@ using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
|
||||
#define DELTA 1
|
||||
#define DELTA_PERATOM 64
|
||||
#define EPSILON 1.0e-6
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -105,11 +104,6 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
|
||||
binhead = nullptr;
|
||||
next = permute = nullptr;
|
||||
|
||||
// data structure with info on per-atom vectors/arrays
|
||||
|
||||
nperatom = maxperatom = 0;
|
||||
peratom = nullptr;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// 1st customization section: customize by adding new per-atom variables
|
||||
|
||||
@ -286,11 +280,11 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
|
||||
|
||||
Atom::~Atom()
|
||||
{
|
||||
delete [] atom_style;
|
||||
delete[] atom_style;
|
||||
delete avec;
|
||||
delete avec_map;
|
||||
|
||||
delete [] firstgroupname;
|
||||
delete[] firstgroupname;
|
||||
memory->destroy(binhead);
|
||||
memory->destroy(next);
|
||||
memory->destroy(permute);
|
||||
@ -303,12 +297,6 @@ Atom::~Atom()
|
||||
memory->destroy(v);
|
||||
memory->destroy(f);
|
||||
|
||||
// delete peratom data struct
|
||||
|
||||
for (int i = 0; i < nperatom; i++)
|
||||
delete [] peratom[i].name;
|
||||
memory->sfree(peratom);
|
||||
|
||||
// delete custom atom arrays
|
||||
|
||||
for (int i = 0; i < nivector; i++) {
|
||||
@ -385,12 +373,7 @@ void Atom::settings(Atom *old)
|
||||
|
||||
void Atom::peratom_create()
|
||||
{
|
||||
for (int i = 0; i < nperatom; i++)
|
||||
delete [] peratom[i].name;
|
||||
memory->sfree(peratom);
|
||||
|
||||
peratom = nullptr;
|
||||
nperatom = maxperatom = 0;
|
||||
peratom.clear();
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// 2nd customization section: add peratom variables here, order does not matter
|
||||
@ -571,23 +554,11 @@ void Atom::peratom_create()
|
||||
use add_peratom_vary() when column count varies per atom
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Atom::add_peratom(const char *name, void *address,
|
||||
void Atom::add_peratom(const std::string &name, void *address,
|
||||
int datatype, int cols, int threadflag)
|
||||
{
|
||||
if (nperatom == maxperatom) {
|
||||
maxperatom += DELTA_PERATOM;
|
||||
peratom = (PerAtom *)
|
||||
memory->srealloc(peratom,maxperatom*sizeof(PerAtom),"atom:peratom");
|
||||
}
|
||||
|
||||
peratom[nperatom].name = utils::strdup(name);
|
||||
peratom[nperatom].address = address;
|
||||
peratom[nperatom].datatype = datatype;
|
||||
peratom[nperatom].cols = cols;
|
||||
peratom[nperatom].threadflag = threadflag;
|
||||
peratom[nperatom].address_length = nullptr;
|
||||
|
||||
nperatom++;
|
||||
PerAtom item = {name, address, nullptr, nullptr, datatype, cols, 0, threadflag};
|
||||
peratom.push_back(item);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -596,15 +567,13 @@ void Atom::add_peratom(const char *name, void *address,
|
||||
see atom_style tdpd as an example
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Atom::add_peratom_change_columns(const char *name, int cols)
|
||||
void Atom::add_peratom_change_columns(const std::string &name, int cols)
|
||||
{
|
||||
for (int i = 0; i < nperatom; i++) {
|
||||
if (strcmp(name,peratom[i].name) == 0) {
|
||||
peratom[i].cols = cols;
|
||||
return;
|
||||
}
|
||||
}
|
||||
error->all(FLERR,"Could not find name of peratom array for column change");
|
||||
auto match = std::find_if(peratom.begin(), peratom.end(),
|
||||
[&name] (const PerAtom &p) { return p.name == name; });
|
||||
|
||||
if (match != peratom.end()) (*match).cols = cols;
|
||||
else error->all(FLERR,"Could not find per-atom array name {} for column change", name);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -619,25 +588,11 @@ void Atom::add_peratom_change_columns(const char *name, int cols)
|
||||
e.g. nspecial
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Atom::add_peratom_vary(const char *name, void *address,
|
||||
void Atom::add_peratom_vary(const std::string &name, void *address,
|
||||
int datatype, int *cols, void *length, int collength)
|
||||
{
|
||||
if (nperatom == maxperatom) {
|
||||
maxperatom += DELTA_PERATOM;
|
||||
peratom = (PerAtom *)
|
||||
memory->srealloc(peratom,maxperatom*sizeof(PerAtom),"atom:peratom");
|
||||
}
|
||||
|
||||
peratom[nperatom].name = utils::strdup(name);
|
||||
peratom[nperatom].address = address;
|
||||
peratom[nperatom].datatype = datatype;
|
||||
peratom[nperatom].cols = -1;
|
||||
peratom[nperatom].threadflag = 0;
|
||||
peratom[nperatom].address_maxcols = cols;
|
||||
peratom[nperatom].address_length = length;
|
||||
peratom[nperatom].collength = collength;
|
||||
|
||||
nperatom++;
|
||||
PerAtom item = {name, address, length, cols, datatype, -1, collength, 0};
|
||||
peratom.push_back(item);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -2917,4 +2872,3 @@ double Atom::memory_usage()
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
||||
15
src/atom.h
15
src/atom.h
@ -203,13 +203,17 @@ class Atom : protected Pointers {
|
||||
|
||||
double pdscale;
|
||||
|
||||
// DIELECTRIC package
|
||||
|
||||
int dielectric_flag;
|
||||
|
||||
// end of customization section
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// per-atom data struct describing all per-atom vectors/arrays
|
||||
|
||||
struct PerAtom {
|
||||
char *name;
|
||||
std::string name;
|
||||
void *address;
|
||||
void *address_length;
|
||||
int *address_maxcols;
|
||||
@ -219,8 +223,7 @@ class Atom : protected Pointers {
|
||||
int threadflag;
|
||||
};
|
||||
|
||||
PerAtom *peratom;
|
||||
int nperatom, maxperatom;
|
||||
std::vector<PerAtom> peratom;
|
||||
|
||||
// custom vectors and arrays used by fix property/atom
|
||||
|
||||
@ -289,9 +292,9 @@ class Atom : protected Pointers {
|
||||
|
||||
void settings(class Atom *);
|
||||
void peratom_create();
|
||||
void add_peratom(const char *, void *, int, int, int threadflag = 0);
|
||||
void add_peratom_change_columns(const char *, int);
|
||||
void add_peratom_vary(const char *, void *, int, int *, void *, int collength = 0);
|
||||
void add_peratom(const std::string &, void *, int, int, int threadflag = 0);
|
||||
void add_peratom_change_columns(const std::string &, int);
|
||||
void add_peratom_vary(const std::string &, void *, int, int *, void *, int collength = 0);
|
||||
void create_avec(const std::string &, int, char **, int);
|
||||
virtual AtomVec *new_avec(const std::string &, int, int &);
|
||||
|
||||
|
||||
967
src/atom_vec.cpp
967
src/atom_vec.cpp
File diff suppressed because it is too large
Load Diff
@ -59,11 +59,10 @@ class AtomVec : protected Pointers {
|
||||
// additional list of peratom fields operated on by different methods
|
||||
// set or created by child styles
|
||||
|
||||
char *fields_grow, *fields_copy;
|
||||
char *fields_comm, *fields_comm_vel, *fields_reverse;
|
||||
char *fields_border, *fields_border_vel;
|
||||
char *fields_exchange, *fields_restart;
|
||||
char *fields_create, *fields_data_atom, *fields_data_vel;
|
||||
std::vector<std::string> fields_grow, fields_copy, fields_comm, fields_comm_vel;
|
||||
std::vector<std::string> fields_reverse, fields_border, fields_border_vel;
|
||||
std::vector<std::string> fields_exchange, fields_restart, fields_create;
|
||||
std::vector<std::string> fields_data_atom, fields_data_vel;
|
||||
|
||||
// methods
|
||||
|
||||
@ -152,7 +151,7 @@ class AtomVec : protected Pointers {
|
||||
virtual int pack_data_bonus(double *, int) { return 0; }
|
||||
virtual void write_data_bonus(FILE *, int, double *, int) {}
|
||||
|
||||
virtual int property_atom(char *) { return -1; }
|
||||
virtual int property_atom(const std::string &) { return -1; }
|
||||
virtual void pack_property_atom(int, double *, int, int) {}
|
||||
|
||||
virtual double memory_usage();
|
||||
@ -187,11 +186,10 @@ class AtomVec : protected Pointers {
|
||||
// standard list of peratom fields always operated on by different methods
|
||||
// common to all styles, so not listed in field strings
|
||||
|
||||
const char *default_grow, *default_copy;
|
||||
const char *default_comm, *default_comm_vel, *default_reverse;
|
||||
const char *default_border, *default_border_vel;
|
||||
const char *default_exchange, *default_restart;
|
||||
const char *default_create, *default_data_atom, *default_data_vel;
|
||||
static const std::vector<std::string> default_grow, default_copy, default_comm, default_comm_vel;
|
||||
static const std::vector<std::string> default_reverse, default_border, default_border_vel;
|
||||
static const std::vector<std::string> default_exchange, default_restart, default_create;
|
||||
static const std::vector<std::string> default_data_atom, default_data_vel;
|
||||
|
||||
struct Method {
|
||||
std::vector<void *> pdata;
|
||||
@ -223,7 +221,7 @@ class AtomVec : protected Pointers {
|
||||
void grow_nmax();
|
||||
int grow_nmax_bonus(int);
|
||||
void setup_fields();
|
||||
int process_fields(char *, const char *, Method *);
|
||||
int process_fields(const std::vector<std::string> &, const std::vector<std::string> &, Method *);
|
||||
void init_method(int, Method *);
|
||||
};
|
||||
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -30,18 +29,8 @@ AtomVecAtomic::AtomVecAtomic(LAMMPS *lmp) : AtomVec(lmp)
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "";
|
||||
fields_copy = (char *) "";
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "";
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "";
|
||||
fields_border_vel = (char *) "";
|
||||
fields_exchange = (char *) "";
|
||||
fields_restart = (char *) "";
|
||||
fields_create = (char *) "";
|
||||
fields_data_atom = (char *) "id type x";
|
||||
fields_data_vel = (char *) "id v";
|
||||
fields_data_atom = {"id", "type", "x"};
|
||||
fields_data_vel = {"id", "v"};
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -23,8 +22,6 @@
|
||||
#include "modify.h"
|
||||
#include "my_pool_chunk.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -54,27 +51,29 @@ AtomVecBody::AtomVecBody(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
bptr = nullptr;
|
||||
|
||||
if (sizeof(double) == sizeof(int)) intdoubleratio = 1;
|
||||
else if (sizeof(double) == 2*sizeof(int)) intdoubleratio = 2;
|
||||
else error->all(FLERR,"Internal error in atom_style body");
|
||||
if (sizeof(double) == sizeof(int))
|
||||
intdoubleratio = 1;
|
||||
else if (sizeof(double) == 2 * sizeof(int))
|
||||
intdoubleratio = 2;
|
||||
else
|
||||
error->all(FLERR, "Internal error in atom_style body");
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "radius rmass angmom torque body";
|
||||
fields_copy = (char *) "radius rmass angmom";
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "angmom";
|
||||
fields_reverse = (char *) "torque";
|
||||
fields_border = (char *) "radius rmass";
|
||||
fields_border_vel = (char *) "radius rmass angmom";
|
||||
fields_exchange = (char *) "radius rmass angmom";
|
||||
fields_restart = (char *) "radius rmass angmom";
|
||||
fields_create = (char *) "radius rmass angmom body";
|
||||
fields_data_atom = (char *) "id type body rmass x";
|
||||
fields_data_vel = (char *) "id v angmom";
|
||||
fields_grow = {"radius", "rmass", "angmom", "torque", "body"};
|
||||
fields_copy = {"radius", "rmass", "angmom"};
|
||||
fields_comm_vel = {"angmom"};
|
||||
fields_reverse = {"torque"};
|
||||
fields_border = {"radius", "rmass"};
|
||||
fields_border_vel = {"radius", "rmass", "angmom"};
|
||||
fields_exchange = {"radius", "rmass", "angmom"};
|
||||
fields_restart = {"radius", "rmass", "angmom"};
|
||||
fields_create = {"radius", "rmass", "angmom", "body"};
|
||||
fields_data_atom = {"id", "type", "body", "rmass", "x"};
|
||||
fields_data_vel = {"id", "v", "angmom"};
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -101,23 +100,25 @@ void AtomVecBody::process_args(int narg, char **arg)
|
||||
{
|
||||
// suppress unused parameter warning dependent on style_body.h
|
||||
|
||||
(void)(arg);
|
||||
(void) (arg);
|
||||
|
||||
if (narg < 1) error->all(FLERR,"Invalid atom_style body command");
|
||||
if (narg < 1) error->all(FLERR, "Invalid atom_style body command");
|
||||
|
||||
if (false) { // NOLINT
|
||||
if (false) { // NOLINT
|
||||
bptr = nullptr;
|
||||
|
||||
#define BODY_CLASS
|
||||
#define BodyStyle(key,Class) \
|
||||
} else if (strcmp(arg[0],#key) == 0) { \
|
||||
bptr = new Class(lmp,narg,arg);
|
||||
#include "style_body.h" // IWYU pragma: keep
|
||||
#define BodyStyle(key, Class) \
|
||||
} \
|
||||
else if (strcmp(arg[0], #key) == 0) \
|
||||
{ \
|
||||
bptr = new Class(lmp, narg, arg);
|
||||
#include "style_body.h" // IWYU pragma: keep
|
||||
#undef BodyStyle
|
||||
#undef BODY_CLASS
|
||||
|
||||
} else error->all(FLERR,utils::
|
||||
check_packages_for_style("body",arg[0],lmp).c_str());
|
||||
} else
|
||||
error->all(FLERR, utils::check_packages_for_style("body", arg[0], lmp).c_str());
|
||||
|
||||
bptr->avec = this;
|
||||
icp = bptr->icp;
|
||||
@ -153,11 +154,9 @@ void AtomVecBody::grow_pointers()
|
||||
void AtomVecBody::grow_bonus()
|
||||
{
|
||||
nmax_bonus = grow_nmax_bonus(nmax_bonus);
|
||||
if (nmax_bonus < 0)
|
||||
error->one(FLERR,"Per-processor system is too big");
|
||||
if (nmax_bonus < 0) error->one(FLERR, "Per-processor system is too big");
|
||||
|
||||
bonus = (Bonus *) memory->srealloc(bonus,nmax_bonus*sizeof(Bonus),
|
||||
"atom:bonus");
|
||||
bonus = (Bonus *) memory->srealloc(bonus, nmax_bonus * sizeof(Bonus), "atom:bonus");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -173,7 +172,7 @@ void AtomVecBody::copy_bonus(int i, int j, int delflag)
|
||||
int k = body[j];
|
||||
icp->put(bonus[k].iindex);
|
||||
dcp->put(bonus[k].dindex);
|
||||
copy_bonus_all(nlocal_bonus-1,k);
|
||||
copy_bonus_all(nlocal_bonus - 1, k);
|
||||
nlocal_bonus--;
|
||||
}
|
||||
|
||||
@ -192,7 +191,7 @@ void AtomVecBody::copy_bonus(int i, int j, int delflag)
|
||||
void AtomVecBody::copy_bonus_all(int i, int j)
|
||||
{
|
||||
body[bonus[i].ilocal] = j;
|
||||
memcpy(&bonus[j],&bonus[i],sizeof(Bonus));
|
||||
memcpy(&bonus[j], &bonus[i], sizeof(Bonus));
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -218,7 +217,7 @@ void AtomVecBody::clear_bonus()
|
||||
|
||||
int AtomVecBody::pack_comm_bonus(int n, int *list, double *buf)
|
||||
{
|
||||
int i,j,m;
|
||||
int i, j, m;
|
||||
double *quat;
|
||||
|
||||
m = 0;
|
||||
@ -230,7 +229,7 @@ int AtomVecBody::pack_comm_bonus(int n, int *list, double *buf)
|
||||
buf[m++] = quat[1];
|
||||
buf[m++] = quat[2];
|
||||
buf[m++] = quat[3];
|
||||
m += bptr->pack_comm_body(&bonus[body[j]],&buf[m]);
|
||||
m += bptr->pack_comm_body(&bonus[body[j]], &buf[m]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,7 +240,7 @@ int AtomVecBody::pack_comm_bonus(int n, int *list, double *buf)
|
||||
|
||||
void AtomVecBody::unpack_comm_bonus(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
int i, m, last;
|
||||
double *quat;
|
||||
|
||||
m = 0;
|
||||
@ -253,7 +252,7 @@ void AtomVecBody::unpack_comm_bonus(int n, int first, double *buf)
|
||||
quat[1] = buf[m++];
|
||||
quat[2] = buf[m++];
|
||||
quat[3] = buf[m++];
|
||||
m += bptr->unpack_comm_body(&bonus[body[i]],&buf[m]);
|
||||
m += bptr->unpack_comm_body(&bonus[body[i]], &buf[m]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -262,13 +261,14 @@ void AtomVecBody::unpack_comm_bonus(int n, int first, double *buf)
|
||||
|
||||
int AtomVecBody::pack_border_bonus(int n, int *list, double *buf)
|
||||
{
|
||||
int i,j,m;
|
||||
double *quat,*inertia;
|
||||
int i, j, m;
|
||||
double *quat, *inertia;
|
||||
|
||||
m = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
if (body[j] < 0) buf[m++] = ubuf(0).d;
|
||||
if (body[j] < 0)
|
||||
buf[m++] = ubuf(0).d;
|
||||
else {
|
||||
buf[m++] = ubuf(1).d;
|
||||
quat = bonus[body[j]].quat;
|
||||
@ -282,7 +282,7 @@ int AtomVecBody::pack_border_bonus(int n, int *list, double *buf)
|
||||
buf[m++] = inertia[2];
|
||||
buf[m++] = ubuf(bonus[body[j]].ninteger).d;
|
||||
buf[m++] = ubuf(bonus[body[j]].ndouble).d;
|
||||
m += bptr->pack_border_body(&bonus[body[j]],&buf[m]);
|
||||
m += bptr->pack_border_body(&bonus[body[j]], &buf[m]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -293,14 +293,15 @@ int AtomVecBody::pack_border_bonus(int n, int *list, double *buf)
|
||||
|
||||
int AtomVecBody::unpack_border_bonus(int n, int first, double *buf)
|
||||
{
|
||||
int i,j,m,last;
|
||||
double *quat,*inertia;
|
||||
int i, j, m, last;
|
||||
double *quat, *inertia;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
body[i] = (int) ubuf(buf[m++]).i;
|
||||
if (body[i] == 0) body[i] = -1;
|
||||
if (body[i] == 0)
|
||||
body[i] = -1;
|
||||
else {
|
||||
j = nlocal_bonus + nghost_bonus;
|
||||
if (j == nmax_bonus) grow_bonus();
|
||||
@ -316,9 +317,9 @@ int AtomVecBody::unpack_border_bonus(int n, int first, double *buf)
|
||||
bonus[j].ninteger = (int) ubuf(buf[m++]).i;
|
||||
bonus[j].ndouble = (int) ubuf(buf[m++]).i;
|
||||
// corresponding put() calls are in clear_bonus()
|
||||
bonus[j].ivalue = icp->get(bonus[j].ninteger,bonus[j].iindex);
|
||||
bonus[j].dvalue = dcp->get(bonus[j].ndouble,bonus[j].dindex);
|
||||
m += bptr->unpack_border_body(&bonus[j],&buf[m]);
|
||||
bonus[j].ivalue = icp->get(bonus[j].ninteger, bonus[j].iindex);
|
||||
bonus[j].dvalue = dcp->get(bonus[j].ndouble, bonus[j].dindex);
|
||||
m += bptr->unpack_border_body(&bonus[j], &buf[m]);
|
||||
bonus[j].ilocal = i;
|
||||
body[i] = j;
|
||||
nghost_bonus++;
|
||||
@ -337,7 +338,8 @@ int AtomVecBody::pack_exchange_bonus(int i, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
|
||||
if (body[i] < 0) buf[m++] = ubuf(0).d;
|
||||
if (body[i] < 0)
|
||||
buf[m++] = ubuf(0).d;
|
||||
else {
|
||||
buf[m++] = ubuf(1).d;
|
||||
int j = body[i];
|
||||
@ -352,10 +354,12 @@ int AtomVecBody::pack_exchange_bonus(int i, double *buf)
|
||||
buf[m++] = inertia[2];
|
||||
buf[m++] = ubuf(bonus[j].ninteger).d;
|
||||
buf[m++] = ubuf(bonus[j].ndouble).d;
|
||||
memcpy(&buf[m],bonus[j].ivalue,bonus[j].ninteger*sizeof(int));
|
||||
if (intdoubleratio == 1) m += bonus[j].ninteger;
|
||||
else m += (bonus[j].ninteger+1)/2;
|
||||
memcpy(&buf[m],bonus[j].dvalue,bonus[j].ndouble*sizeof(double));
|
||||
memcpy(&buf[m], bonus[j].ivalue, bonus[j].ninteger * sizeof(int));
|
||||
if (intdoubleratio == 1)
|
||||
m += bonus[j].ninteger;
|
||||
else
|
||||
m += (bonus[j].ninteger + 1) / 2;
|
||||
memcpy(&buf[m], bonus[j].dvalue, bonus[j].ndouble * sizeof(double));
|
||||
m += bonus[j].ndouble;
|
||||
}
|
||||
|
||||
@ -369,7 +373,8 @@ int AtomVecBody::unpack_exchange_bonus(int ilocal, double *buf)
|
||||
int m = 0;
|
||||
|
||||
body[ilocal] = (int) ubuf(buf[m++]).i;
|
||||
if (body[ilocal] == 0) body[ilocal] = -1;
|
||||
if (body[ilocal] == 0)
|
||||
body[ilocal] = -1;
|
||||
else {
|
||||
if (nlocal_bonus == nmax_bonus) grow_bonus();
|
||||
double *quat = bonus[nlocal_bonus].quat;
|
||||
@ -384,16 +389,14 @@ int AtomVecBody::unpack_exchange_bonus(int ilocal, double *buf)
|
||||
bonus[nlocal_bonus].ninteger = (int) ubuf(buf[m++]).i;
|
||||
bonus[nlocal_bonus].ndouble = (int) ubuf(buf[m++]).i;
|
||||
// corresponding put() calls are in copy()
|
||||
bonus[nlocal_bonus].ivalue = icp->get(bonus[nlocal_bonus].ninteger,
|
||||
bonus[nlocal_bonus].iindex);
|
||||
bonus[nlocal_bonus].dvalue = dcp->get(bonus[nlocal_bonus].ndouble,
|
||||
bonus[nlocal_bonus].dindex);
|
||||
memcpy(bonus[nlocal_bonus].ivalue,&buf[m],
|
||||
bonus[nlocal_bonus].ninteger*sizeof(int));
|
||||
if (intdoubleratio == 1) m += bonus[nlocal_bonus].ninteger;
|
||||
else m += (bonus[nlocal_bonus].ninteger+1)/2;
|
||||
memcpy(bonus[nlocal_bonus].dvalue,&buf[m],
|
||||
bonus[nlocal_bonus].ndouble*sizeof(double));
|
||||
bonus[nlocal_bonus].ivalue = icp->get(bonus[nlocal_bonus].ninteger, bonus[nlocal_bonus].iindex);
|
||||
bonus[nlocal_bonus].dvalue = dcp->get(bonus[nlocal_bonus].ndouble, bonus[nlocal_bonus].dindex);
|
||||
memcpy(bonus[nlocal_bonus].ivalue, &buf[m], bonus[nlocal_bonus].ninteger * sizeof(int));
|
||||
if (intdoubleratio == 1)
|
||||
m += bonus[nlocal_bonus].ninteger;
|
||||
else
|
||||
m += (bonus[nlocal_bonus].ninteger + 1) / 2;
|
||||
memcpy(bonus[nlocal_bonus].dvalue, &buf[m], bonus[nlocal_bonus].ndouble * sizeof(double));
|
||||
m += bonus[nlocal_bonus].ndouble;
|
||||
|
||||
bonus[nlocal_bonus].ilocal = ilocal;
|
||||
@ -416,10 +419,13 @@ int AtomVecBody::size_restart_bonus()
|
||||
for (i = 0; i < nlocal; i++) {
|
||||
if (body[i] >= 0) {
|
||||
n += size_restart_bonus_one;
|
||||
if (intdoubleratio == 1) n += bonus[body[i]].ninteger;
|
||||
else n += (bonus[body[i]].ninteger+1)/2;
|
||||
if (intdoubleratio == 1)
|
||||
n += bonus[body[i]].ninteger;
|
||||
else
|
||||
n += (bonus[body[i]].ninteger + 1) / 2;
|
||||
n += bonus[body[i]].ndouble;
|
||||
} else n++;
|
||||
} else
|
||||
n++;
|
||||
}
|
||||
|
||||
return n;
|
||||
@ -435,7 +441,8 @@ int AtomVecBody::pack_restart_bonus(int i, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
|
||||
if (body[i] < 0) buf[m++] = ubuf(0).d;
|
||||
if (body[i] < 0)
|
||||
buf[m++] = ubuf(0).d;
|
||||
else {
|
||||
buf[m++] = ubuf(1).d;
|
||||
int j = body[i];
|
||||
@ -450,10 +457,12 @@ int AtomVecBody::pack_restart_bonus(int i, double *buf)
|
||||
buf[m++] = inertia[2];
|
||||
buf[m++] = ubuf(bonus[j].ninteger).d;
|
||||
buf[m++] = ubuf(bonus[j].ndouble).d;
|
||||
memcpy(&buf[m],bonus[j].ivalue,bonus[j].ninteger*sizeof(int));
|
||||
if (intdoubleratio == 1) m += bonus[j].ninteger;
|
||||
else m += (bonus[j].ninteger+1)/2;
|
||||
memcpy(&buf[m],bonus[j].dvalue,bonus[j].ndouble*sizeof(double));
|
||||
memcpy(&buf[m], bonus[j].ivalue, bonus[j].ninteger * sizeof(int));
|
||||
if (intdoubleratio == 1)
|
||||
m += bonus[j].ninteger;
|
||||
else
|
||||
m += (bonus[j].ninteger + 1) / 2;
|
||||
memcpy(&buf[m], bonus[j].dvalue, bonus[j].ndouble * sizeof(double));
|
||||
m += bonus[j].ndouble;
|
||||
}
|
||||
|
||||
@ -469,7 +478,8 @@ int AtomVecBody::unpack_restart_bonus(int ilocal, double *buf)
|
||||
int m = 0;
|
||||
|
||||
body[ilocal] = (int) ubuf(buf[m++]).i;
|
||||
if (body[ilocal] == 0) body[ilocal] = -1;
|
||||
if (body[ilocal] == 0)
|
||||
body[ilocal] = -1;
|
||||
else {
|
||||
if (nlocal_bonus == nmax_bonus) grow_bonus();
|
||||
double *quat = bonus[nlocal_bonus].quat;
|
||||
@ -483,16 +493,14 @@ int AtomVecBody::unpack_restart_bonus(int ilocal, double *buf)
|
||||
inertia[2] = buf[m++];
|
||||
bonus[nlocal_bonus].ninteger = (int) ubuf(buf[m++]).i;
|
||||
bonus[nlocal_bonus].ndouble = (int) ubuf(buf[m++]).i;
|
||||
bonus[nlocal_bonus].ivalue = icp->get(bonus[nlocal_bonus].ninteger,
|
||||
bonus[nlocal_bonus].iindex);
|
||||
bonus[nlocal_bonus].dvalue = dcp->get(bonus[nlocal_bonus].ndouble,
|
||||
bonus[nlocal_bonus].dindex);
|
||||
memcpy(bonus[nlocal_bonus].ivalue,&buf[m],
|
||||
bonus[nlocal_bonus].ninteger*sizeof(int));
|
||||
if (intdoubleratio == 1) m += bonus[nlocal_bonus].ninteger;
|
||||
else m += (bonus[nlocal_bonus].ninteger+1)/2;
|
||||
memcpy(bonus[nlocal_bonus].dvalue,&buf[m],
|
||||
bonus[nlocal_bonus].ndouble*sizeof(double));
|
||||
bonus[nlocal_bonus].ivalue = icp->get(bonus[nlocal_bonus].ninteger, bonus[nlocal_bonus].iindex);
|
||||
bonus[nlocal_bonus].dvalue = dcp->get(bonus[nlocal_bonus].ndouble, bonus[nlocal_bonus].dindex);
|
||||
memcpy(bonus[nlocal_bonus].ivalue, &buf[m], bonus[nlocal_bonus].ninteger * sizeof(int));
|
||||
if (intdoubleratio == 1)
|
||||
m += bonus[nlocal_bonus].ninteger;
|
||||
else
|
||||
m += (bonus[nlocal_bonus].ninteger + 1) / 2;
|
||||
memcpy(bonus[nlocal_bonus].dvalue, &buf[m], bonus[nlocal_bonus].ndouble * sizeof(double));
|
||||
m += bonus[nlocal_bonus].ndouble;
|
||||
bonus[nlocal_bonus].ilocal = ilocal;
|
||||
body[ilocal] = nlocal_bonus++;
|
||||
@ -521,13 +529,15 @@ void AtomVecBody::create_atom_post(int ilocal)
|
||||
void AtomVecBody::data_atom_post(int ilocal)
|
||||
{
|
||||
body_flag = body[ilocal];
|
||||
if (body_flag == 0) body_flag = -1;
|
||||
else if (body_flag == 1) body_flag = 0;
|
||||
else error->one(FLERR,"Invalid body flag in Atoms section of data file");
|
||||
if (body_flag == 0)
|
||||
body_flag = -1;
|
||||
else if (body_flag == 1)
|
||||
body_flag = 0;
|
||||
else
|
||||
error->one(FLERR, "Invalid body flag in Atoms section of data file");
|
||||
body[ilocal] = body_flag;
|
||||
|
||||
if (rmass[ilocal] <= 0.0)
|
||||
error->one(FLERR,"Invalid density in Atoms section of data file");
|
||||
if (rmass[ilocal] <= 0.0) error->one(FLERR, "Invalid density in Atoms section of data file");
|
||||
|
||||
radius[ilocal] = 0.5;
|
||||
angmom[ilocal][0] = 0.0;
|
||||
@ -539,14 +549,12 @@ void AtomVecBody::data_atom_post(int ilocal)
|
||||
unpack one body from Bodies section of data file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecBody::data_body(int m, int ninteger, int ndouble,
|
||||
int *ivalues, double *dvalues)
|
||||
void AtomVecBody::data_body(int m, int ninteger, int ndouble, int *ivalues, double *dvalues)
|
||||
{
|
||||
if (body[m])
|
||||
error->one(FLERR,"Assigning body parameters to non-body atom");
|
||||
if (body[m]) error->one(FLERR, "Assigning body parameters to non-body atom");
|
||||
if (nlocal_bonus == nmax_bonus) grow_bonus();
|
||||
bonus[nlocal_bonus].ilocal = m;
|
||||
bptr->data_body(nlocal_bonus,ninteger,ndouble,ivalues,dvalues);
|
||||
bptr->data_body(nlocal_bonus, ninteger, ndouble, ivalues, dvalues);
|
||||
body[m] = nlocal_bonus++;
|
||||
}
|
||||
|
||||
@ -557,14 +565,14 @@ void AtomVecBody::data_body(int m, int ninteger, int ndouble,
|
||||
double AtomVecBody::memory_usage_bonus()
|
||||
{
|
||||
double bytes = 0;
|
||||
bytes += (double)nmax_bonus*sizeof(Bonus);
|
||||
bytes += (double) nmax_bonus * sizeof(Bonus);
|
||||
bytes += icp->size() + dcp->size();
|
||||
|
||||
int nall = nlocal_bonus + nghost_bonus;
|
||||
for (int i = 0; i < nall; i++) {
|
||||
if (body[i] >= 0) {
|
||||
bytes += (double)bonus[body[i]].ninteger * sizeof(int);
|
||||
bytes += (double)bonus[body[i]].ndouble * sizeof(double);
|
||||
bytes += (double) bonus[body[i]].ninteger * sizeof(int);
|
||||
bytes += (double) bonus[body[i]].ndouble * sizeof(double);
|
||||
}
|
||||
}
|
||||
|
||||
@ -579,8 +587,10 @@ void AtomVecBody::pack_data_pre(int ilocal)
|
||||
{
|
||||
body_flag = body[ilocal];
|
||||
|
||||
if (body_flag < 0) body[ilocal] = 0;
|
||||
else body[ilocal] = 1;
|
||||
if (body_flag < 0)
|
||||
body[ilocal] = 0;
|
||||
else
|
||||
body[ilocal] = 1;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -598,7 +608,7 @@ int AtomVecBody::pack_data_bonus(double *buf, int /*flag*/)
|
||||
int m = 0;
|
||||
for (i = 0; i < nlocal; i++) {
|
||||
if (body[i] < 0) continue;
|
||||
int n = bptr->pack_data_body(tag[i],body[i],buf);
|
||||
int n = bptr->pack_data_body(tag[i], body[i], buf);
|
||||
m += n;
|
||||
if (buf) buf += n;
|
||||
}
|
||||
@ -613,9 +623,7 @@ int AtomVecBody::pack_data_bonus(double *buf, int /*flag*/)
|
||||
void AtomVecBody::write_data_bonus(FILE *fp, int n, double *buf, int /*flag*/)
|
||||
{
|
||||
int i = 0;
|
||||
while (i < n) {
|
||||
i += bptr->write_data_body(fp,&buf[i]);
|
||||
}
|
||||
while (i < n) { i += bptr->write_data_body(fp, &buf[i]); }
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -631,10 +639,9 @@ void AtomVecBody::pack_data_post(int ilocal)
|
||||
body computes its size based on ivalues/dvalues and returns it
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double AtomVecBody::radius_body(int ninteger, int ndouble,
|
||||
int *ivalues, double *dvalues)
|
||||
double AtomVecBody::radius_body(int ninteger, int ndouble, int *ivalues, double *dvalues)
|
||||
{
|
||||
return bptr->radius_body(ninteger,ndouble,ivalues,dvalues);
|
||||
return bptr->radius_body(ninteger, ndouble, ivalues, dvalues);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -644,10 +651,12 @@ double AtomVecBody::radius_body(int ninteger, int ndouble,
|
||||
|
||||
void AtomVecBody::set_quat(int m, double *quat_external)
|
||||
{
|
||||
if (body[m] < 0) error->one(FLERR,"Assigning quat to non-body atom");
|
||||
if (body[m] < 0) error->one(FLERR, "Assigning quat to non-body atom");
|
||||
double *quat = bonus[body[m]].quat;
|
||||
quat[0] = quat_external[0]; quat[1] = quat_external[1];
|
||||
quat[2] = quat_external[2]; quat[3] = quat_external[3];
|
||||
quat[0] = quat_external[0];
|
||||
quat[1] = quat_external[1];
|
||||
quat[2] = quat_external[2];
|
||||
quat[3] = quat_external[3];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -31,18 +30,15 @@ AtomVecCharge::AtomVecCharge(LAMMPS *lmp) : AtomVec(lmp)
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "q";
|
||||
fields_copy = (char *) "q";
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "";
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "q";
|
||||
fields_border_vel = (char *) "q";
|
||||
fields_exchange = (char *) "q";
|
||||
fields_restart = (char *) "q";
|
||||
fields_create = (char *) "q";
|
||||
fields_data_atom = (char *) "id type q x";
|
||||
fields_data_vel = (char *) "id v";
|
||||
fields_grow = {"q"};
|
||||
fields_copy = {"q"};
|
||||
fields_border = {"q"};
|
||||
fields_border_vel = {"q"};
|
||||
fields_exchange = {"q"};
|
||||
fields_restart = {"q"};
|
||||
fields_create = {"q"};
|
||||
fields_data_atom = {"id", "type", "q", "x"};
|
||||
fields_data_vel = {"id", "v"};
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -26,10 +25,8 @@
|
||||
#include "memory.h"
|
||||
#include "modify.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
using MathConst::MY_PI;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -54,18 +51,17 @@ AtomVecEllipsoid::AtomVecEllipsoid(LAMMPS *lmp) : AtomVec(lmp)
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "rmass angmom torque ellipsoid";
|
||||
fields_copy = (char *) "rmass angmom";
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "angmom";
|
||||
fields_reverse = (char *) "torque";
|
||||
fields_border = (char *) "rmass";
|
||||
fields_border_vel = (char *) "rmass angmom";
|
||||
fields_exchange = (char *) "rmass angmom";
|
||||
fields_restart = (char *) "rmass angmom";
|
||||
fields_create = (char *) "rmass angmom ellipsoid";
|
||||
fields_data_atom = (char *) "id type ellipsoid rmass x";
|
||||
fields_data_vel = (char *) "id v angmom";
|
||||
fields_grow = {"rmass", "angmom", "torque", "ellipsoid"};
|
||||
fields_copy = {"rmass", "angmom"};
|
||||
fields_comm_vel = {"angmom"};
|
||||
fields_reverse = {"torque"};
|
||||
fields_border = {"rmass"};
|
||||
fields_border_vel = {"rmass", "angmom"};
|
||||
fields_exchange = {"rmass", "angmom"};
|
||||
fields_restart = {"rmass", "angmom"};
|
||||
fields_create = {"rmass", "angmom", "ellipsoid"};
|
||||
fields_data_atom = {"id", "type", "ellipsoid", "rmass", "x"};
|
||||
fields_data_vel = {"id", "v", "angmom"};
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
@ -96,11 +92,9 @@ void AtomVecEllipsoid::grow_pointers()
|
||||
void AtomVecEllipsoid::grow_bonus()
|
||||
{
|
||||
nmax_bonus = grow_nmax_bonus(nmax_bonus);
|
||||
if (nmax_bonus < 0)
|
||||
error->one(FLERR,"Per-processor system is too big");
|
||||
if (nmax_bonus < 0) error->one(FLERR, "Per-processor system is too big");
|
||||
|
||||
bonus = (Bonus *) memory->srealloc(bonus,nmax_bonus*sizeof(Bonus),
|
||||
"atom:bonus");
|
||||
bonus = (Bonus *) memory->srealloc(bonus, nmax_bonus * sizeof(Bonus), "atom:bonus");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -112,7 +106,7 @@ void AtomVecEllipsoid::copy_bonus(int i, int j, int delflag)
|
||||
// if deleting atom J via delflag and J has bonus data, then delete it
|
||||
|
||||
if (delflag && ellipsoid[j] >= 0) {
|
||||
copy_bonus_all(nlocal_bonus-1,ellipsoid[j]);
|
||||
copy_bonus_all(nlocal_bonus - 1, ellipsoid[j]);
|
||||
nlocal_bonus--;
|
||||
}
|
||||
|
||||
@ -131,7 +125,7 @@ void AtomVecEllipsoid::copy_bonus(int i, int j, int delflag)
|
||||
void AtomVecEllipsoid::copy_bonus_all(int i, int j)
|
||||
{
|
||||
ellipsoid[bonus[i].ilocal] = j;
|
||||
memcpy(&bonus[j],&bonus[i],sizeof(Bonus));
|
||||
memcpy(&bonus[j], &bonus[i], sizeof(Bonus));
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -152,7 +146,7 @@ void AtomVecEllipsoid::clear_bonus()
|
||||
|
||||
int AtomVecEllipsoid::pack_comm_bonus(int n, int *list, double *buf)
|
||||
{
|
||||
int i,j,m;
|
||||
int i, j, m;
|
||||
double *quat;
|
||||
|
||||
m = 0;
|
||||
@ -174,7 +168,7 @@ int AtomVecEllipsoid::pack_comm_bonus(int n, int *list, double *buf)
|
||||
|
||||
void AtomVecEllipsoid::unpack_comm_bonus(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
int i, m, last;
|
||||
double *quat;
|
||||
|
||||
m = 0;
|
||||
@ -194,13 +188,14 @@ void AtomVecEllipsoid::unpack_comm_bonus(int n, int first, double *buf)
|
||||
|
||||
int AtomVecEllipsoid::pack_border_bonus(int n, int *list, double *buf)
|
||||
{
|
||||
int i,j,m;
|
||||
double *shape,*quat;
|
||||
int i, j, m;
|
||||
double *shape, *quat;
|
||||
|
||||
m = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
if (ellipsoid[j] < 0) buf[m++] = ubuf(0).d;
|
||||
if (ellipsoid[j] < 0)
|
||||
buf[m++] = ubuf(0).d;
|
||||
else {
|
||||
buf[m++] = ubuf(1).d;
|
||||
shape = bonus[ellipsoid[j]].shape;
|
||||
@ -222,14 +217,15 @@ int AtomVecEllipsoid::pack_border_bonus(int n, int *list, double *buf)
|
||||
|
||||
int AtomVecEllipsoid::unpack_border_bonus(int n, int first, double *buf)
|
||||
{
|
||||
int i,j,m,last;
|
||||
double *shape,*quat;
|
||||
int i, j, m, last;
|
||||
double *shape, *quat;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
ellipsoid[i] = (int) ubuf(buf[m++]).i;
|
||||
if (ellipsoid[i] == 0) ellipsoid[i] = -1;
|
||||
if (ellipsoid[i] == 0)
|
||||
ellipsoid[i] = -1;
|
||||
else {
|
||||
j = nlocal_bonus + nghost_bonus;
|
||||
if (j == nmax_bonus) grow_bonus();
|
||||
@ -260,7 +256,8 @@ int AtomVecEllipsoid::pack_exchange_bonus(int i, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
|
||||
if (ellipsoid[i] < 0) buf[m++] = ubuf(0).d;
|
||||
if (ellipsoid[i] < 0)
|
||||
buf[m++] = ubuf(0).d;
|
||||
else {
|
||||
buf[m++] = ubuf(1).d;
|
||||
int j = ellipsoid[i];
|
||||
@ -285,7 +282,8 @@ int AtomVecEllipsoid::unpack_exchange_bonus(int ilocal, double *buf)
|
||||
int m = 0;
|
||||
|
||||
ellipsoid[ilocal] = (int) ubuf(buf[m++]).i;
|
||||
if (ellipsoid[ilocal] == 0) ellipsoid[ilocal] = -1;
|
||||
if (ellipsoid[ilocal] == 0)
|
||||
ellipsoid[ilocal] = -1;
|
||||
else {
|
||||
if (nlocal_bonus == nmax_bonus) grow_bonus();
|
||||
double *shape = bonus[nlocal_bonus].shape;
|
||||
@ -316,8 +314,10 @@ int AtomVecEllipsoid::size_restart_bonus()
|
||||
int n = 0;
|
||||
int nlocal = atom->nlocal;
|
||||
for (i = 0; i < nlocal; i++) {
|
||||
if (ellipsoid[i] >= 0) n += size_restart_bonus_one;
|
||||
else n++;
|
||||
if (ellipsoid[i] >= 0)
|
||||
n += size_restart_bonus_one;
|
||||
else
|
||||
n++;
|
||||
}
|
||||
|
||||
return n;
|
||||
@ -333,7 +333,8 @@ int AtomVecEllipsoid::pack_restart_bonus(int i, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
|
||||
if (ellipsoid[i] < 0) buf[m++] = ubuf(0).d;
|
||||
if (ellipsoid[i] < 0)
|
||||
buf[m++] = ubuf(0).d;
|
||||
else {
|
||||
buf[m++] = ubuf(1).d;
|
||||
int j = ellipsoid[i];
|
||||
@ -358,7 +359,8 @@ int AtomVecEllipsoid::unpack_restart_bonus(int ilocal, double *buf)
|
||||
int m = 0;
|
||||
|
||||
ellipsoid[ilocal] = (int) ubuf(buf[m++]).i;
|
||||
if (ellipsoid[ilocal] == 0) ellipsoid[ilocal] = -1;
|
||||
if (ellipsoid[ilocal] == 0)
|
||||
ellipsoid[ilocal] = -1;
|
||||
else {
|
||||
if (nlocal_bonus == nmax_bonus) grow_bonus();
|
||||
double *shape = bonus[nlocal_bonus].shape;
|
||||
@ -381,32 +383,31 @@ int AtomVecEllipsoid::unpack_restart_bonus(int ilocal, double *buf)
|
||||
unpack one line from Ellipsoids section of data file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecEllipsoid::data_atom_bonus(int m, const std::vector<std::string> & values)
|
||||
void AtomVecEllipsoid::data_atom_bonus(int m, const std::vector<std::string> &values)
|
||||
{
|
||||
if (ellipsoid[m])
|
||||
error->one(FLERR,"Assigning ellipsoid parameters to non-ellipsoid atom");
|
||||
if (ellipsoid[m]) error->one(FLERR, "Assigning ellipsoid parameters to non-ellipsoid atom");
|
||||
|
||||
if (nlocal_bonus == nmax_bonus) grow_bonus();
|
||||
|
||||
double *shape = bonus[nlocal_bonus].shape;
|
||||
int ivalue = 1;
|
||||
shape[0] = 0.5 * utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
shape[1] = 0.5 * utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
shape[2] = 0.5 * utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
shape[0] = 0.5 * utils::numeric(FLERR, values[ivalue++], true, lmp);
|
||||
shape[1] = 0.5 * utils::numeric(FLERR, values[ivalue++], true, lmp);
|
||||
shape[2] = 0.5 * utils::numeric(FLERR, values[ivalue++], true, lmp);
|
||||
if (shape[0] <= 0.0 || shape[1] <= 0.0 || shape[2] <= 0.0)
|
||||
error->one(FLERR,"Invalid shape in Ellipsoids section of data file");
|
||||
error->one(FLERR, "Invalid shape in Ellipsoids section of data file");
|
||||
|
||||
double *quat = bonus[nlocal_bonus].quat;
|
||||
quat[0] = utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
quat[1] = utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
quat[2] = utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
quat[3] = utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
quat[0] = utils::numeric(FLERR, values[ivalue++], true, lmp);
|
||||
quat[1] = utils::numeric(FLERR, values[ivalue++], true, lmp);
|
||||
quat[2] = utils::numeric(FLERR, values[ivalue++], true, lmp);
|
||||
quat[3] = utils::numeric(FLERR, values[ivalue++], true, lmp);
|
||||
MathExtra::qnormalize(quat);
|
||||
|
||||
// reset ellipsoid mass
|
||||
// previously stored density in rmass
|
||||
|
||||
rmass[m] *= 4.0*MY_PI/3.0 * shape[0]*shape[1]*shape[2];
|
||||
rmass[m] *= 4.0 * MY_PI / 3.0 * shape[0] * shape[1] * shape[2];
|
||||
|
||||
bonus[nlocal_bonus].ilocal = m;
|
||||
ellipsoid[m] = nlocal_bonus++;
|
||||
@ -419,7 +420,7 @@ void AtomVecEllipsoid::data_atom_bonus(int m, const std::vector<std::string> & v
|
||||
double AtomVecEllipsoid::memory_usage_bonus()
|
||||
{
|
||||
double bytes = 0;
|
||||
bytes += nmax_bonus*sizeof(Bonus);
|
||||
bytes += nmax_bonus * sizeof(Bonus);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
@ -441,13 +442,15 @@ void AtomVecEllipsoid::create_atom_post(int ilocal)
|
||||
void AtomVecEllipsoid::data_atom_post(int ilocal)
|
||||
{
|
||||
ellipsoid_flag = ellipsoid[ilocal];
|
||||
if (ellipsoid_flag == 0) ellipsoid_flag = -1;
|
||||
else if (ellipsoid_flag == 1) ellipsoid_flag = 0;
|
||||
else error->one(FLERR,"Invalid ellipsoid flag in Atoms section of data file");
|
||||
if (ellipsoid_flag == 0)
|
||||
ellipsoid_flag = -1;
|
||||
else if (ellipsoid_flag == 1)
|
||||
ellipsoid_flag = 0;
|
||||
else
|
||||
error->one(FLERR, "Invalid ellipsoid flag in Atoms section of data file");
|
||||
ellipsoid[ilocal] = ellipsoid_flag;
|
||||
|
||||
if (rmass[ilocal] <= 0.0)
|
||||
error->one(FLERR,"Invalid density in Atoms section of data file");
|
||||
if (rmass[ilocal] <= 0.0) error->one(FLERR, "Invalid density in Atoms section of data file");
|
||||
|
||||
angmom[ilocal][0] = 0.0;
|
||||
angmom[ilocal][1] = 0.0;
|
||||
@ -465,12 +468,14 @@ void AtomVecEllipsoid::pack_data_pre(int ilocal)
|
||||
ellipsoid_flag = atom->ellipsoid[ilocal];
|
||||
rmass_one = atom->rmass[ilocal];
|
||||
|
||||
if (ellipsoid_flag < 0) ellipsoid[ilocal] = 0;
|
||||
else ellipsoid[ilocal] = 1;
|
||||
if (ellipsoid_flag < 0)
|
||||
ellipsoid[ilocal] = 0;
|
||||
else
|
||||
ellipsoid[ilocal] = 1;
|
||||
|
||||
if (ellipsoid_flag >= 0) {
|
||||
shape = bonus[ellipsoid_flag].shape;
|
||||
rmass[ilocal] /= 4.0*MY_PI/3.0 * shape[0]*shape[1]*shape[2];
|
||||
rmass[ilocal] /= 4.0 * MY_PI / 3.0 * shape[0] * shape[1] * shape[2];
|
||||
}
|
||||
}
|
||||
|
||||
@ -491,7 +496,7 @@ void AtomVecEllipsoid::pack_data_post(int ilocal)
|
||||
|
||||
int AtomVecEllipsoid::pack_data_bonus(double *buf, int /*flag*/)
|
||||
{
|
||||
int i,j;
|
||||
int i, j;
|
||||
|
||||
tagint *tag = atom->tag;
|
||||
int nlocal = atom->nlocal;
|
||||
@ -502,14 +507,15 @@ int AtomVecEllipsoid::pack_data_bonus(double *buf, int /*flag*/)
|
||||
if (buf) {
|
||||
buf[m++] = ubuf(tag[i]).d;
|
||||
j = ellipsoid[i];
|
||||
buf[m++] = 2.0*bonus[j].shape[0];
|
||||
buf[m++] = 2.0*bonus[j].shape[1];
|
||||
buf[m++] = 2.0*bonus[j].shape[2];
|
||||
buf[m++] = 2.0 * bonus[j].shape[0];
|
||||
buf[m++] = 2.0 * bonus[j].shape[1];
|
||||
buf[m++] = 2.0 * bonus[j].shape[2];
|
||||
buf[m++] = bonus[j].quat[0];
|
||||
buf[m++] = bonus[j].quat[1];
|
||||
buf[m++] = bonus[j].quat[2];
|
||||
buf[m++] = bonus[j].quat[3];
|
||||
} else m += size_data_bonus;
|
||||
} else
|
||||
m += size_data_bonus;
|
||||
}
|
||||
|
||||
return m;
|
||||
@ -523,8 +529,8 @@ void AtomVecEllipsoid::write_data_bonus(FILE *fp, int n, double *buf, int /*flag
|
||||
{
|
||||
int i = 0;
|
||||
while (i < n) {
|
||||
fmt::print(fp,"{} {} {} {} {} {} {} {}\n",ubuf(buf[i]).i,
|
||||
buf[i+1],buf[i+2],buf[i+3],buf[i+4],buf[i+5],buf[i+6],buf[i+7]);
|
||||
fmt::print(fp, "{} {} {} {} {} {} {} {}\n", ubuf(buf[i]).i, buf[i + 1], buf[i + 2], buf[i + 3],
|
||||
buf[i + 4], buf[i + 5], buf[i + 6], buf[i + 7]);
|
||||
i += size_data_bonus;
|
||||
}
|
||||
}
|
||||
@ -552,7 +558,7 @@ void AtomVecEllipsoid::set_shape(int i, double shapex, double shapey, double sha
|
||||
bonus[nlocal_bonus].ilocal = i;
|
||||
ellipsoid[i] = nlocal_bonus++;
|
||||
} else if (shapex == 0.0 && shapey == 0.0 && shapez == 0.0) {
|
||||
copy_bonus_all(nlocal_bonus-1,ellipsoid[i]);
|
||||
copy_bonus_all(nlocal_bonus - 1, ellipsoid[i]);
|
||||
nlocal_bonus--;
|
||||
ellipsoid[i] = -1;
|
||||
} else {
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -19,12 +18,12 @@
|
||||
#include "error.h"
|
||||
#include "tokenizer.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define NFIELDSTRINGS 12 // # of field strings
|
||||
enum{ELLIPSOID,LINE,TRIANGLE,BODY}; // also in WriteData
|
||||
enum { ELLIPSOID, LINE, TRIANGLE, BODY }; // also in WriteData
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -33,22 +32,16 @@ AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp) : AtomVec(lmp)
|
||||
nstyles = 0;
|
||||
styles = nullptr;
|
||||
keywords = nullptr;
|
||||
fieldstrings = nullptr;
|
||||
|
||||
bonus_flag = 0;
|
||||
nstyles_bonus = 0;
|
||||
styles_bonus = nullptr;
|
||||
|
||||
// these strings will be concatenated from sub-style strings
|
||||
// field strings will be concatenated from sub-style strings
|
||||
// fields_data_atom & fields_data_vel start with fields common to all styles
|
||||
|
||||
fields_grow = fields_copy = fields_comm = fields_comm_vel = (char *) "";
|
||||
fields_reverse = fields_border = fields_border_vel = (char *) "";
|
||||
fields_exchange = fields_restart = fields_create = (char *) "";
|
||||
fields_data_atom = (char *) "id type x";
|
||||
fields_data_vel = (char *) "id v";
|
||||
|
||||
fields_allocated = 0;
|
||||
fields_data_atom = {"id", "type", "x"};
|
||||
fields_data_vel = {"id", "v"};
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -56,28 +49,10 @@ AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp) : AtomVec(lmp)
|
||||
AtomVecHybrid::~AtomVecHybrid()
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++) delete styles[k];
|
||||
delete [] styles;
|
||||
for (int k = 0; k < nstyles; k++) delete [] keywords[k];
|
||||
delete [] keywords;
|
||||
delete [] styles_bonus;
|
||||
|
||||
if (!fields_allocated) return;
|
||||
|
||||
delete [] fields_grow;
|
||||
delete [] fields_copy;
|
||||
delete [] fields_comm;
|
||||
delete [] fields_comm_vel;
|
||||
delete [] fields_reverse;
|
||||
delete [] fields_border;
|
||||
delete [] fields_border_vel;
|
||||
delete [] fields_exchange;
|
||||
delete [] fields_restart;
|
||||
delete [] fields_create;
|
||||
delete [] fields_data_atom;
|
||||
delete [] fields_data_vel;
|
||||
|
||||
for (int k = 0; k < nstyles; k++) delete [] fieldstrings[k].fstr;
|
||||
delete [] fieldstrings;
|
||||
delete[] styles;
|
||||
for (int k = 0; k < nstyles; k++) delete[] keywords[k];
|
||||
delete[] keywords;
|
||||
delete[] styles_bonus;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -92,28 +67,27 @@ void AtomVecHybrid::process_args(int narg, char **arg)
|
||||
|
||||
// allocate list of sub-styles as big as possibly needed if no extra args
|
||||
|
||||
styles = new AtomVec*[narg];
|
||||
keywords = new char*[narg];
|
||||
styles = new AtomVec *[narg];
|
||||
keywords = new char *[narg];
|
||||
|
||||
// allocate each sub-style
|
||||
// call process_args() with set of args that are not atom style names
|
||||
// use known_style() to determine which args these are
|
||||
|
||||
int i,k,jarg,dummy;
|
||||
|
||||
int dummy;
|
||||
int iarg = 0;
|
||||
nstyles = 0;
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg],"hybrid") == 0)
|
||||
error->all(FLERR,"Atom style hybrid cannot have hybrid as an argument");
|
||||
for (i = 0; i < nstyles; i++)
|
||||
if (strcmp(arg[iarg],keywords[i]) == 0)
|
||||
error->all(FLERR,"Atom style hybrid cannot use same atom style twice");
|
||||
styles[nstyles] = atom->new_avec(arg[iarg],1,dummy);
|
||||
if (strcmp(arg[iarg], "hybrid") == 0)
|
||||
error->all(FLERR, "Atom style hybrid cannot have hybrid as an argument");
|
||||
for (int i = 0; i < nstyles; i++)
|
||||
if (strcmp(arg[iarg], keywords[i]) == 0)
|
||||
error->all(FLERR, "Atom style hybrid cannot use same atom style twice");
|
||||
styles[nstyles] = atom->new_avec(arg[iarg], 1, dummy);
|
||||
keywords[nstyles] = utils::strdup(arg[iarg]);
|
||||
jarg = iarg + 1;
|
||||
int jarg = iarg + 1;
|
||||
while (jarg < narg && !known_style(arg[jarg])) jarg++;
|
||||
styles[nstyles]->process_args(jarg-iarg-1,&arg[iarg+1]);
|
||||
styles[nstyles]->process_args(jarg - iarg - 1, &arg[iarg + 1]);
|
||||
iarg = jarg;
|
||||
nstyles++;
|
||||
}
|
||||
@ -124,20 +98,19 @@ void AtomVecHybrid::process_args(int narg, char **arg)
|
||||
molecular = Atom::ATOMIC;
|
||||
maxexchange = 0;
|
||||
|
||||
for (k = 0; k < nstyles; k++) {
|
||||
for (int k = 0; k < nstyles; k++) {
|
||||
if ((styles[k]->molecular == Atom::MOLECULAR && molecular == Atom::TEMPLATE) ||
|
||||
(styles[k]->molecular == Atom::TEMPLATE && molecular == Atom::MOLECULAR))
|
||||
error->all(FLERR,
|
||||
"Cannot mix molecular and molecule template atom styles");
|
||||
molecular = MAX(molecular,styles[k]->molecular);
|
||||
error->all(FLERR, "Cannot mix molecular and molecule template atom styles");
|
||||
molecular = MAX(molecular, styles[k]->molecular);
|
||||
|
||||
bonds_allow = MAX(bonds_allow,styles[k]->bonds_allow);
|
||||
angles_allow = MAX(angles_allow,styles[k]->angles_allow);
|
||||
dihedrals_allow = MAX(dihedrals_allow,styles[k]->dihedrals_allow);
|
||||
impropers_allow = MAX(impropers_allow,styles[k]->impropers_allow);
|
||||
mass_type = MAX(mass_type,styles[k]->mass_type);
|
||||
dipole_type = MAX(dipole_type,styles[k]->dipole_type);
|
||||
forceclearflag = MAX(forceclearflag,styles[k]->forceclearflag);
|
||||
bonds_allow = MAX(bonds_allow, styles[k]->bonds_allow);
|
||||
angles_allow = MAX(angles_allow, styles[k]->angles_allow);
|
||||
dihedrals_allow = MAX(dihedrals_allow, styles[k]->dihedrals_allow);
|
||||
impropers_allow = MAX(impropers_allow, styles[k]->impropers_allow);
|
||||
mass_type = MAX(mass_type, styles[k]->mass_type);
|
||||
dipole_type = MAX(dipole_type, styles[k]->dipole_type);
|
||||
forceclearflag = MAX(forceclearflag, styles[k]->forceclearflag);
|
||||
maxexchange += styles[k]->maxexchange;
|
||||
|
||||
if (styles[k]->molecular == Atom::TEMPLATE) onemols = styles[k]->onemols;
|
||||
@ -148,95 +121,71 @@ void AtomVecHybrid::process_args(int narg, char **arg)
|
||||
int mass_pertype = 0;
|
||||
int mass_peratom = 0;
|
||||
|
||||
for (k = 0; k < nstyles; k++) {
|
||||
for (int k = 0; k < nstyles; k++) {
|
||||
if (styles[k]->mass_type == 0) mass_peratom = 1;
|
||||
if (styles[k]->mass_type == 1) mass_pertype = 1;
|
||||
}
|
||||
|
||||
if (mass_pertype && mass_peratom && comm->me == 0)
|
||||
error->warning(FLERR, "Atom style hybrid defines both, per-type "
|
||||
error->warning(FLERR,
|
||||
"Atom style hybrid defines both, per-type "
|
||||
"and per-atom masses; both must be set, but only "
|
||||
"per-atom masses will be used");
|
||||
|
||||
// free allstyles created by build_styles()
|
||||
|
||||
for (i = 0; i < nallstyles; i++) delete [] allstyles[i];
|
||||
delete [] allstyles;
|
||||
|
||||
// set field strings from all substyles
|
||||
|
||||
fieldstrings = new FieldStrings[nstyles];
|
||||
|
||||
for (k = 0; k < nstyles; k++) {
|
||||
fieldstrings[k].fstr = new char*[NFIELDSTRINGS];
|
||||
fieldstrings[k].fstr[0] = styles[k]->fields_grow;
|
||||
fieldstrings[k].fstr[1] = styles[k]->fields_copy;
|
||||
fieldstrings[k].fstr[2] = styles[k]->fields_comm;
|
||||
fieldstrings[k].fstr[3] = styles[k]->fields_comm_vel;
|
||||
fieldstrings[k].fstr[4] = styles[k]->fields_reverse;
|
||||
fieldstrings[k].fstr[5] = styles[k]->fields_border;
|
||||
fieldstrings[k].fstr[6] = styles[k]->fields_border_vel;
|
||||
fieldstrings[k].fstr[7] = styles[k]->fields_exchange;
|
||||
fieldstrings[k].fstr[8] = styles[k]->fields_restart;
|
||||
fieldstrings[k].fstr[9] = styles[k]->fields_create;
|
||||
fieldstrings[k].fstr[10] = styles[k]->fields_data_atom;
|
||||
fieldstrings[k].fstr[11] = styles[k]->fields_data_vel;
|
||||
}
|
||||
for (int i = 0; i < nallstyles; i++) delete[] allstyles[i];
|
||||
delete[] allstyles;
|
||||
|
||||
// merge field strings from all sub-styles
|
||||
// save concat_grow to check for duplicates of special-case fields
|
||||
|
||||
char *concat_grow;;
|
||||
char *dummyptr = nullptr;
|
||||
std::vector<std::string> concat_grow;
|
||||
std::vector<std::string> concat_dummy;
|
||||
|
||||
fields_grow = merge_fields(0,fields_grow,1,concat_grow);
|
||||
fields_copy = merge_fields(1,fields_copy,0,dummyptr);
|
||||
fields_comm = merge_fields(2,fields_comm,0,dummyptr);
|
||||
fields_comm_vel = merge_fields(3,fields_comm_vel,0,dummyptr);
|
||||
fields_reverse = merge_fields(4,fields_reverse,0,dummyptr);
|
||||
fields_border = merge_fields(5,fields_border,0,dummyptr);
|
||||
fields_border_vel = merge_fields(6,fields_border_vel,0,dummyptr);
|
||||
fields_exchange = merge_fields(7,fields_exchange,0,dummyptr);
|
||||
fields_restart = merge_fields(8,fields_restart,0,dummyptr);
|
||||
fields_create = merge_fields(9,fields_create,0,dummyptr);
|
||||
fields_data_atom = merge_fields(10,fields_data_atom,0,dummyptr);
|
||||
fields_data_vel = merge_fields(11,fields_data_vel,0,dummyptr);
|
||||
|
||||
fields_allocated = 1;
|
||||
for (int k = 0; k < nstyles; k++) {
|
||||
merge_fields(fields_grow, styles[k]->fields_grow, 1, concat_grow);
|
||||
merge_fields(fields_copy, styles[k]->fields_copy, 0, concat_dummy);
|
||||
merge_fields(fields_comm, styles[k]->fields_comm, 0, concat_dummy);
|
||||
merge_fields(fields_comm_vel, styles[k]->fields_comm_vel, 0, concat_dummy);
|
||||
merge_fields(fields_reverse, styles[k]->fields_reverse, 0, concat_dummy);
|
||||
merge_fields(fields_border, styles[k]->fields_border, 0, concat_dummy);
|
||||
merge_fields(fields_border_vel, styles[k]->fields_border_vel, 0, concat_dummy);
|
||||
merge_fields(fields_exchange, styles[k]->fields_exchange, 0, concat_dummy);
|
||||
merge_fields(fields_restart, styles[k]->fields_restart, 0, concat_dummy);
|
||||
merge_fields(fields_create, styles[k]->fields_create, 0, concat_dummy);
|
||||
merge_fields(fields_data_atom, styles[k]->fields_data_atom, 0, concat_dummy);
|
||||
merge_fields(fields_data_vel, styles[k]->fields_data_vel, 0, concat_dummy);
|
||||
}
|
||||
|
||||
// check concat_grow for multiple special-case fields
|
||||
// may cause issues with style-specific create_atom() and data_atom() methods
|
||||
// issue warnings if appear in multiple sub-styles
|
||||
|
||||
const char *dupfield[] = {"radius","rmass"};
|
||||
int ndupfield = 2;
|
||||
char *ptr;
|
||||
std::vector<std::string> dupfield = {"radius", "rmass"};
|
||||
|
||||
for (int idup = 0; idup < ndupfield; idup++) {
|
||||
auto dup = (char *) dupfield[idup];
|
||||
ptr = strstr(concat_grow,dup);
|
||||
if ((ptr && strstr(ptr+1,dup)) && (comm->me == 0))
|
||||
error->warning(FLERR,fmt::format("Per-atom {} is used in multiple sub-"
|
||||
"styles; must be used consistently",dup));
|
||||
for (const auto &idup : dupfield) {
|
||||
if ((comm->me == 0) && (std::count(concat_grow.begin(), concat_grow.end(), idup) > 1))
|
||||
error->warning(FLERR,
|
||||
"Per-atom field {} is used in multiple sub-styles; must be used consistently",
|
||||
idup);
|
||||
}
|
||||
|
||||
delete [] concat_grow;
|
||||
|
||||
// set bonus_flag if any substyle has bonus data
|
||||
// set nstyles_bonus & styles_bonus
|
||||
// sum two sizes over contributions from each substyle with bonus data.
|
||||
|
||||
nstyles_bonus = 0;
|
||||
for (k = 0; k < nstyles; k++)
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
if (styles[k]->bonus_flag) nstyles_bonus++;
|
||||
|
||||
if (nstyles_bonus) {
|
||||
bonus_flag = 1;
|
||||
styles_bonus = new AtomVec*[nstyles_bonus];
|
||||
styles_bonus = new AtomVec *[nstyles_bonus];
|
||||
nstyles_bonus = 0;
|
||||
size_forward_bonus = 0;
|
||||
size_border_bonus = 0;
|
||||
for (k = 0; k < nstyles; k++) {
|
||||
for (int k = 0; k < nstyles; k++) {
|
||||
if (styles[k]->bonus_flag) {
|
||||
styles_bonus[nstyles_bonus++] = styles[k];
|
||||
size_forward_bonus += styles[k]->size_forward_bonus;
|
||||
@ -270,23 +219,21 @@ void AtomVecHybrid::grow_pointers()
|
||||
void AtomVecHybrid::force_clear(int n, size_t nbytes)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
if (styles[k]->forceclearflag) styles[k]->force_clear(n,nbytes);
|
||||
if (styles[k]->forceclearflag) styles[k]->force_clear(n, nbytes);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::copy_bonus(int i, int j, int delflag)
|
||||
{
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
styles_bonus[k]->copy_bonus(i,j,delflag);
|
||||
for (int k = 0; k < nstyles_bonus; k++) styles_bonus[k]->copy_bonus(i, j, delflag);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::clear_bonus()
|
||||
{
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
styles_bonus[k]->clear_bonus();
|
||||
for (int k = 0; k < nstyles_bonus; k++) styles_bonus[k]->clear_bonus();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -294,8 +241,7 @@ void AtomVecHybrid::clear_bonus()
|
||||
int AtomVecHybrid::pack_comm_bonus(int n, int *list, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
m += styles_bonus[k]->pack_comm_bonus(n,list,buf);
|
||||
for (int k = 0; k < nstyles_bonus; k++) m += styles_bonus[k]->pack_comm_bonus(n, list, buf);
|
||||
return m;
|
||||
}
|
||||
|
||||
@ -303,8 +249,7 @@ int AtomVecHybrid::pack_comm_bonus(int n, int *list, double *buf)
|
||||
|
||||
void AtomVecHybrid::unpack_comm_bonus(int n, int first, double *buf)
|
||||
{
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
styles_bonus[k]->unpack_comm_bonus(n,first,buf);
|
||||
for (int k = 0; k < nstyles_bonus; k++) styles_bonus[k]->unpack_comm_bonus(n, first, buf);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -312,8 +257,7 @@ void AtomVecHybrid::unpack_comm_bonus(int n, int first, double *buf)
|
||||
int AtomVecHybrid::pack_border_bonus(int n, int *list, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
m += styles_bonus[k]->pack_border_bonus(n,list,buf);
|
||||
for (int k = 0; k < nstyles_bonus; k++) m += styles_bonus[k]->pack_border_bonus(n, list, buf);
|
||||
return m;
|
||||
}
|
||||
|
||||
@ -322,8 +266,7 @@ int AtomVecHybrid::pack_border_bonus(int n, int *list, double *buf)
|
||||
int AtomVecHybrid::unpack_border_bonus(int n, int first, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
m += styles_bonus[k]->unpack_border_bonus(n,first,buf);
|
||||
for (int k = 0; k < nstyles_bonus; k++) m += styles_bonus[k]->unpack_border_bonus(n, first, buf);
|
||||
return m;
|
||||
}
|
||||
|
||||
@ -332,8 +275,7 @@ int AtomVecHybrid::unpack_border_bonus(int n, int first, double *buf)
|
||||
int AtomVecHybrid::pack_exchange_bonus(int i, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
m += styles_bonus[k]->pack_exchange_bonus(i,buf);
|
||||
for (int k = 0; k < nstyles_bonus; k++) m += styles_bonus[k]->pack_exchange_bonus(i, buf);
|
||||
return m;
|
||||
}
|
||||
|
||||
@ -342,8 +284,7 @@ int AtomVecHybrid::pack_exchange_bonus(int i, double *buf)
|
||||
int AtomVecHybrid::unpack_exchange_bonus(int ilocal, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
m += styles_bonus[k]->unpack_exchange_bonus(ilocal,buf);
|
||||
for (int k = 0; k < nstyles_bonus; k++) m += styles_bonus[k]->unpack_exchange_bonus(ilocal, buf);
|
||||
return m;
|
||||
}
|
||||
|
||||
@ -352,8 +293,7 @@ int AtomVecHybrid::unpack_exchange_bonus(int ilocal, double *buf)
|
||||
int AtomVecHybrid::size_restart_bonus()
|
||||
{
|
||||
int n = 0;
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
n += styles_bonus[k]->size_restart_bonus();
|
||||
for (int k = 0; k < nstyles_bonus; k++) n += styles_bonus[k]->size_restart_bonus();
|
||||
return n;
|
||||
}
|
||||
|
||||
@ -362,8 +302,7 @@ int AtomVecHybrid::size_restart_bonus()
|
||||
int AtomVecHybrid::pack_restart_bonus(int i, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
m += styles_bonus[k]->pack_restart_bonus(i,buf);
|
||||
for (int k = 0; k < nstyles_bonus; k++) m += styles_bonus[k]->pack_restart_bonus(i, buf);
|
||||
return m;
|
||||
}
|
||||
|
||||
@ -372,8 +311,7 @@ int AtomVecHybrid::pack_restart_bonus(int i, double *buf)
|
||||
int AtomVecHybrid::unpack_restart_bonus(int ilocal, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
m += styles_bonus[k]->unpack_restart_bonus(ilocal,buf);
|
||||
for (int k = 0; k < nstyles_bonus; k++) m += styles_bonus[k]->unpack_restart_bonus(ilocal, buf);
|
||||
return m;
|
||||
}
|
||||
|
||||
@ -382,8 +320,7 @@ int AtomVecHybrid::unpack_restart_bonus(int ilocal, double *buf)
|
||||
double AtomVecHybrid::memory_usage_bonus()
|
||||
{
|
||||
double bytes = 0;
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
bytes += styles_bonus[k]->memory_usage_bonus();
|
||||
for (int k = 0; k < nstyles_bonus; k++) bytes += styles_bonus[k]->memory_usage_bonus();
|
||||
return bytes;
|
||||
}
|
||||
|
||||
@ -393,8 +330,7 @@ double AtomVecHybrid::memory_usage_bonus()
|
||||
|
||||
void AtomVecHybrid::pack_restart_pre(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->pack_restart_pre(ilocal);
|
||||
for (int k = 0; k < nstyles; k++) styles[k]->pack_restart_pre(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -403,8 +339,7 @@ void AtomVecHybrid::pack_restart_pre(int ilocal)
|
||||
|
||||
void AtomVecHybrid::pack_restart_post(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->pack_restart_post(ilocal);
|
||||
for (int k = 0; k < nstyles; k++) styles[k]->pack_restart_post(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -413,8 +348,7 @@ void AtomVecHybrid::pack_restart_post(int ilocal)
|
||||
|
||||
void AtomVecHybrid::unpack_restart_init(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->unpack_restart_init(ilocal);
|
||||
for (int k = 0; k < nstyles; k++) styles[k]->unpack_restart_init(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -423,8 +357,7 @@ void AtomVecHybrid::unpack_restart_init(int ilocal)
|
||||
|
||||
void AtomVecHybrid::create_atom_post(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->create_atom_post(ilocal);
|
||||
for (int k = 0; k < nstyles; k++) styles[k]->create_atom_post(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -434,16 +367,15 @@ void AtomVecHybrid::create_atom_post(int ilocal)
|
||||
|
||||
void AtomVecHybrid::data_atom_post(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->data_atom_post(ilocal);
|
||||
for (int k = 0; k < nstyles; k++) styles[k]->data_atom_post(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
modify what AtomVec::data_bonds() just unpacked
|
||||
or initialize other bond quantities
|
||||
------------------------------------------------------------------------- */
|
||||
void AtomVecHybrid::data_bonds_post(int m, int num_bond, tagint atom1,
|
||||
tagint atom2, tagint id_offset)
|
||||
void AtomVecHybrid::data_bonds_post(int m, int num_bond, tagint atom1, tagint atom2,
|
||||
tagint id_offset)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->data_bonds_post(m, num_bond, atom1, atom2, id_offset);
|
||||
@ -455,8 +387,7 @@ void AtomVecHybrid::data_bonds_post(int m, int num_bond, tagint atom1,
|
||||
|
||||
void AtomVecHybrid::pack_data_pre(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->pack_data_pre(ilocal);
|
||||
for (int k = 0; k < nstyles; k++) styles[k]->pack_data_pre(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -465,8 +396,7 @@ void AtomVecHybrid::pack_data_pre(int ilocal)
|
||||
|
||||
void AtomVecHybrid::pack_data_post(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->pack_data_post(ilocal);
|
||||
for (int k = 0; k < nstyles; k++) styles[k]->pack_data_post(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -476,12 +406,12 @@ void AtomVecHybrid::pack_data_post(int ilocal)
|
||||
int AtomVecHybrid::pack_data_bonus(double *buf, int flag)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++) {
|
||||
if (flag == ELLIPSOID && strcmp(keywords[k],"ellipsoid") != 0) continue;
|
||||
if (flag == LINE && strcmp(keywords[k],"line") != 0) continue;
|
||||
if (flag == TRIANGLE && strcmp(keywords[k],"tri") != 0) continue;
|
||||
if (flag == BODY && strcmp(keywords[k],"body") != 0) continue;
|
||||
if (flag == ELLIPSOID && strcmp(keywords[k], "ellipsoid") != 0) continue;
|
||||
if (flag == LINE && strcmp(keywords[k], "line") != 0) continue;
|
||||
if (flag == TRIANGLE && strcmp(keywords[k], "tri") != 0) continue;
|
||||
if (flag == BODY && strcmp(keywords[k], "body") != 0) continue;
|
||||
|
||||
return styles[k]->pack_data_bonus(buf,flag);
|
||||
return styles[k]->pack_data_bonus(buf, flag);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -493,12 +423,12 @@ int AtomVecHybrid::pack_data_bonus(double *buf, int flag)
|
||||
void AtomVecHybrid::write_data_bonus(FILE *fp, int n, double *buf, int flag)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++) {
|
||||
if (flag == ELLIPSOID && strcmp(keywords[k],"ellipsoid") != 0) continue;
|
||||
if (flag == LINE && strcmp(keywords[k],"line") != 0) continue;
|
||||
if (flag == TRIANGLE && strcmp(keywords[k],"tri") != 0) continue;
|
||||
if (flag == BODY && strcmp(keywords[k],"body") != 0) continue;
|
||||
if (flag == ELLIPSOID && strcmp(keywords[k], "ellipsoid") != 0) continue;
|
||||
if (flag == LINE && strcmp(keywords[k], "line") != 0) continue;
|
||||
if (flag == TRIANGLE && strcmp(keywords[k], "tri") != 0) continue;
|
||||
if (flag == BODY && strcmp(keywords[k], "body") != 0) continue;
|
||||
|
||||
styles[k]->write_data_bonus(fp,n,buf,flag);
|
||||
styles[k]->write_data_bonus(fp, n, buf, flag);
|
||||
}
|
||||
}
|
||||
|
||||
@ -508,11 +438,11 @@ void AtomVecHybrid::write_data_bonus(FILE *fp, int n, double *buf, int flag)
|
||||
return -1 if name is unknown to any sub-styles
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::property_atom(char *name)
|
||||
int AtomVecHybrid::property_atom(const std::string &name)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++) {
|
||||
int index = styles[k]->property_atom(name);
|
||||
if (index >= 0) return index*nstyles + k;
|
||||
if (index >= 0) return index * nstyles + k;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@ -522,12 +452,11 @@ int AtomVecHybrid::property_atom(char *name)
|
||||
index maps to data specific to this atom style
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::pack_property_atom(int multiindex, double *buf,
|
||||
int nvalues, int groupbit)
|
||||
void AtomVecHybrid::pack_property_atom(int multiindex, double *buf, int nvalues, int groupbit)
|
||||
{
|
||||
int k = multiindex % nstyles;
|
||||
int index = multiindex/nstyles;
|
||||
styles[k]->pack_property_atom(index,buf,nvalues,groupbit);
|
||||
int index = multiindex / nstyles;
|
||||
styles[k]->pack_property_atom(index, buf, nvalues, groupbit);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@ -535,48 +464,21 @@ void AtomVecHybrid::pack_property_atom(int multiindex, double *buf,
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
merge fields and remove duplicate fields
|
||||
concat = root + Inum fields string from all substyles
|
||||
return dedup = concat with duplicate fields removed
|
||||
merge fields into root vector and remove duplicate fields
|
||||
if concat_flag set, also return concat (w/ duplicates)
|
||||
so caller can check for problematic fields, call will free it
|
||||
so caller can check for problematic fields
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
char *AtomVecHybrid::merge_fields(int inum, char *root,
|
||||
int concat_flag, char *&concat_str)
|
||||
void AtomVecHybrid::merge_fields(std::vector<std::string> &root,
|
||||
const std::vector<std::string> &fields, int concat_flag,
|
||||
std::vector<std::string> &concat)
|
||||
{
|
||||
// create vector with all words combined
|
||||
// grow vector with all words combined with dedup and
|
||||
|
||||
std::string concat;
|
||||
if (root) concat += root;
|
||||
for (int k = 0; k < nstyles; k++) {
|
||||
if (concat.size() > 0) concat += " ";
|
||||
concat += fieldstrings[k].fstr[inum];
|
||||
for (const auto &field : fields) {
|
||||
if (concat_flag) concat.push_back(field);
|
||||
if (std::find(root.begin(), root.end(), field) == root.end()) root.push_back(field);
|
||||
}
|
||||
if (concat_flag) concat_str = utils::strdup(concat);
|
||||
|
||||
// remove duplicate words without changing the order
|
||||
|
||||
auto words = Tokenizer(concat, " ").as_vector();
|
||||
std::vector<std::string> dedup;
|
||||
for (auto &w : words) {
|
||||
bool found = false;
|
||||
for (auto &d : dedup) {
|
||||
if (w == d) found = true;
|
||||
}
|
||||
if (!found) dedup.push_back(w);
|
||||
}
|
||||
|
||||
// create final concatenated, deduped string
|
||||
concat.clear();
|
||||
for (auto &d : dedup) {
|
||||
concat += d;
|
||||
concat += " ";
|
||||
}
|
||||
|
||||
// remove trailing blank
|
||||
if (concat.size() > 0) concat.pop_back();
|
||||
return utils::strdup(concat);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -587,19 +489,19 @@ void AtomVecHybrid::build_styles()
|
||||
{
|
||||
nallstyles = 0;
|
||||
#define ATOM_CLASS
|
||||
#define AtomStyle(key,Class) nallstyles++;
|
||||
#include "style_atom.h" // IWYU pragma: keep
|
||||
#define AtomStyle(key, Class) nallstyles++;
|
||||
#include "style_atom.h" // IWYU pragma: keep
|
||||
#undef AtomStyle
|
||||
#undef ATOM_CLASS
|
||||
|
||||
allstyles = new char*[nallstyles];
|
||||
allstyles = new char *[nallstyles];
|
||||
|
||||
nallstyles = 0;
|
||||
#define ATOM_CLASS
|
||||
#define AtomStyle(key,Class) \
|
||||
#define AtomStyle(key, Class) \
|
||||
allstyles[nallstyles] = utils::strdup(#key); \
|
||||
nallstyles++;
|
||||
#include "style_atom.h" // IWYU pragma: keep
|
||||
#include "style_atom.h" // IWYU pragma: keep
|
||||
#undef AtomStyle
|
||||
#undef ATOM_CLASS
|
||||
}
|
||||
@ -611,6 +513,6 @@ void AtomVecHybrid::build_styles()
|
||||
int AtomVecHybrid::known_style(char *str)
|
||||
{
|
||||
for (int i = 0; i < nallstyles; i++)
|
||||
if (strcmp(str,allstyles[i]) == 0) return 1;
|
||||
if (strcmp(str, allstyles[i]) == 0) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -64,23 +64,18 @@ class AtomVecHybrid : public AtomVec {
|
||||
int pack_data_bonus(double *, int) override;
|
||||
void write_data_bonus(FILE *, int, double *, int) override;
|
||||
|
||||
int property_atom(char *) override;
|
||||
int property_atom(const std::string &) override;
|
||||
void pack_property_atom(int, double *, int, int) override;
|
||||
|
||||
private:
|
||||
int nallstyles;
|
||||
char **allstyles;
|
||||
int fields_allocated;
|
||||
|
||||
struct FieldStrings {
|
||||
char **fstr;
|
||||
};
|
||||
FieldStrings *fieldstrings;
|
||||
|
||||
int nstyles_bonus;
|
||||
class AtomVec **styles_bonus;
|
||||
|
||||
char *merge_fields(int, char *, int, char *&);
|
||||
void merge_fields(std::vector<std::string> &, const std::vector<std::string> &,
|
||||
int, std::vector<std::string> &);
|
||||
void build_styles();
|
||||
int known_style(char *);
|
||||
};
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -23,12 +22,11 @@
|
||||
#include "modify.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
using MathConst::MY_PI;
|
||||
|
||||
#define EPSILON 0.001
|
||||
static constexpr double EPSILON = 0.001;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -55,18 +53,17 @@ AtomVecLine::AtomVecLine(LAMMPS *lmp) : AtomVec(lmp)
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "molecule radius rmass omega torque line";
|
||||
fields_copy = (char *) "molecule radius rmass omega";
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "omega";
|
||||
fields_reverse = (char *) "torque";
|
||||
fields_border = (char *) "molecule radius rmass";
|
||||
fields_border_vel = (char *) "molecule radius rmass omega";
|
||||
fields_exchange = (char *) "molecule radius rmass omega";
|
||||
fields_restart = (char *) "molecule radius rmass omega";
|
||||
fields_create = (char *) "molecule radius rmass omega line";
|
||||
fields_data_atom = (char *) "id molecule type line rmass x";
|
||||
fields_data_vel = (char *) "id v omega";
|
||||
fields_grow = {"molecule", "radius", "rmass", "omega", "torque", "line"};
|
||||
fields_copy = {"molecule", "radius", "rmass", "omega"};
|
||||
fields_comm_vel = {"omega"};
|
||||
fields_reverse = {"torque"};
|
||||
fields_border = {"molecule", "radius", "rmass"};
|
||||
fields_border_vel = {"molecule", "radius", "rmass", "omega"};
|
||||
fields_exchange = {"molecule", "radius", "rmass", "omega"};
|
||||
fields_restart = {"molecule", "radius", "rmass", "omega"};
|
||||
fields_create = {"molecule", "radius", "rmass", "omega", "line"};
|
||||
fields_data_atom = {"id", "molecule", "type", "line", "rmass", "x"};
|
||||
fields_data_vel = {"id", "v", "omega"};
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
@ -85,7 +82,7 @@ void AtomVecLine::init()
|
||||
AtomVec::init();
|
||||
|
||||
if (domain->dimension != 2)
|
||||
error->all(FLERR,"Atom_style line can only be used in 2d simulations");
|
||||
error->all(FLERR, "Atom_style line can only be used in 2d simulations");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -108,11 +105,9 @@ void AtomVecLine::grow_pointers()
|
||||
void AtomVecLine::grow_bonus()
|
||||
{
|
||||
nmax_bonus = grow_nmax_bonus(nmax_bonus);
|
||||
if (nmax_bonus < 0)
|
||||
error->one(FLERR,"Per-processor system is too big");
|
||||
if (nmax_bonus < 0) error->one(FLERR, "Per-processor system is too big");
|
||||
|
||||
bonus = (Bonus *) memory->srealloc(bonus,nmax_bonus*sizeof(Bonus),
|
||||
"atom:bonus");
|
||||
bonus = (Bonus *) memory->srealloc(bonus, nmax_bonus * sizeof(Bonus), "atom:bonus");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -124,7 +119,7 @@ void AtomVecLine::copy_bonus(int i, int j, int delflag)
|
||||
// if deleting atom J via delflag and J has bonus data, then delete it
|
||||
|
||||
if (delflag && line[j] >= 0) {
|
||||
copy_bonus_all(nlocal_bonus-1,line[j]);
|
||||
copy_bonus_all(nlocal_bonus - 1, line[j]);
|
||||
nlocal_bonus--;
|
||||
}
|
||||
|
||||
@ -143,7 +138,7 @@ void AtomVecLine::copy_bonus(int i, int j, int delflag)
|
||||
void AtomVecLine::copy_bonus_all(int i, int j)
|
||||
{
|
||||
line[bonus[i].ilocal] = j;
|
||||
memcpy(&bonus[j],&bonus[i],sizeof(Bonus));
|
||||
memcpy(&bonus[j], &bonus[i], sizeof(Bonus));
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -164,7 +159,7 @@ void AtomVecLine::clear_bonus()
|
||||
|
||||
int AtomVecLine::pack_comm_bonus(int n, int *list, double *buf)
|
||||
{
|
||||
int i,j,m;
|
||||
int i, j, m;
|
||||
|
||||
m = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
@ -179,7 +174,7 @@ int AtomVecLine::pack_comm_bonus(int n, int *list, double *buf)
|
||||
|
||||
void AtomVecLine::unpack_comm_bonus(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
int i, m, last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
@ -192,12 +187,13 @@ void AtomVecLine::unpack_comm_bonus(int n, int first, double *buf)
|
||||
|
||||
int AtomVecLine::pack_border_bonus(int n, int *list, double *buf)
|
||||
{
|
||||
int i,j,m;
|
||||
int i, j, m;
|
||||
|
||||
m = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
if (line[j] < 0) buf[m++] = ubuf(0).d;
|
||||
if (line[j] < 0)
|
||||
buf[m++] = ubuf(0).d;
|
||||
else {
|
||||
buf[m++] = ubuf(1).d;
|
||||
buf[m++] = bonus[line[j]].length;
|
||||
@ -212,13 +208,14 @@ int AtomVecLine::pack_border_bonus(int n, int *list, double *buf)
|
||||
|
||||
int AtomVecLine::unpack_border_bonus(int n, int first, double *buf)
|
||||
{
|
||||
int i,j,m,last;
|
||||
int i, j, m, last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
line[i] = (int) ubuf(buf[m++]).i;
|
||||
if (line[i] == 0) line[i] = -1;
|
||||
if (line[i] == 0)
|
||||
line[i] = -1;
|
||||
else {
|
||||
j = nlocal_bonus + nghost_bonus;
|
||||
if (j == nmax_bonus) grow_bonus();
|
||||
@ -242,7 +239,8 @@ int AtomVecLine::pack_exchange_bonus(int i, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
|
||||
if (line[i] < 0) buf[m++] = ubuf(0).d;
|
||||
if (line[i] < 0)
|
||||
buf[m++] = ubuf(0).d;
|
||||
else {
|
||||
buf[m++] = ubuf(1).d;
|
||||
int j = line[i];
|
||||
@ -260,7 +258,8 @@ int AtomVecLine::unpack_exchange_bonus(int ilocal, double *buf)
|
||||
int m = 0;
|
||||
|
||||
line[ilocal] = (int) ubuf(buf[m++]).i;
|
||||
if (line[ilocal] == 0) line[ilocal] = -1;
|
||||
if (line[ilocal] == 0)
|
||||
line[ilocal] = -1;
|
||||
else {
|
||||
if (nlocal_bonus == nmax_bonus) grow_bonus();
|
||||
bonus[nlocal_bonus].length = buf[m++];
|
||||
@ -284,8 +283,10 @@ int AtomVecLine::size_restart_bonus()
|
||||
int n = 0;
|
||||
int nlocal = atom->nlocal;
|
||||
for (i = 0; i < nlocal; i++) {
|
||||
if (line[i] >= 0) n += size_restart_bonus_one;
|
||||
else n++;
|
||||
if (line[i] >= 0)
|
||||
n += size_restart_bonus_one;
|
||||
else
|
||||
n++;
|
||||
}
|
||||
|
||||
return n;
|
||||
@ -301,7 +302,8 @@ int AtomVecLine::pack_restart_bonus(int i, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
|
||||
if (line[i] < 0) buf[m++] = ubuf(0).d;
|
||||
if (line[i] < 0)
|
||||
buf[m++] = ubuf(0).d;
|
||||
else {
|
||||
buf[m++] = ubuf(1).d;
|
||||
int j = line[i];
|
||||
@ -321,7 +323,8 @@ int AtomVecLine::unpack_restart_bonus(int ilocal, double *buf)
|
||||
int m = 0;
|
||||
|
||||
line[ilocal] = (int) ubuf(buf[m++]).i;
|
||||
if (line[ilocal] == 0) line[ilocal] = -1;
|
||||
if (line[ilocal] == 0)
|
||||
line[ilocal] = -1;
|
||||
else {
|
||||
if (nlocal_bonus == nmax_bonus) grow_bonus();
|
||||
bonus[nlocal_bonus].length = buf[m++];
|
||||
@ -339,31 +342,32 @@ int AtomVecLine::unpack_restart_bonus(int ilocal, double *buf)
|
||||
|
||||
void AtomVecLine::data_atom_bonus(int m, const std::vector<std::string> &values)
|
||||
{
|
||||
if (line[m]) error->one(FLERR,"Assigning line parameters to non-line atom");
|
||||
if (line[m]) error->one(FLERR, "Assigning line parameters to non-line atom");
|
||||
|
||||
if (nlocal_bonus == nmax_bonus) grow_bonus();
|
||||
|
||||
int ivalue = 1;
|
||||
double x1 = utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
double y1 = utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
double x2 = utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
double y2 = utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
double x1 = utils::numeric(FLERR, values[ivalue++], true, lmp);
|
||||
double y1 = utils::numeric(FLERR, values[ivalue++], true, lmp);
|
||||
double x2 = utils::numeric(FLERR, values[ivalue++], true, lmp);
|
||||
double y2 = utils::numeric(FLERR, values[ivalue++], true, lmp);
|
||||
double dx = x2 - x1;
|
||||
double dy = y2 - y1;
|
||||
double length = sqrt(dx*dx + dy*dy);
|
||||
double length = sqrt(dx * dx + dy * dy);
|
||||
|
||||
bonus[nlocal_bonus].length = length;
|
||||
if (dy >= 0.0) bonus[nlocal_bonus].theta = acos(dx/length);
|
||||
else bonus[nlocal_bonus].theta = -acos(dx/length);
|
||||
if (dy >= 0.0)
|
||||
bonus[nlocal_bonus].theta = acos(dx / length);
|
||||
else
|
||||
bonus[nlocal_bonus].theta = -acos(dx / length);
|
||||
|
||||
double xc = 0.5*(x1+x2);
|
||||
double yc = 0.5*(y1+y2);
|
||||
double xc = 0.5 * (x1 + x2);
|
||||
double yc = 0.5 * (y1 + y2);
|
||||
dx = xc - x[m][0];
|
||||
dy = yc - x[m][1];
|
||||
double delta = sqrt(dx*dx + dy*dy);
|
||||
double delta = sqrt(dx * dx + dy * dy);
|
||||
|
||||
if (delta/length > EPSILON)
|
||||
error->one(FLERR,"Inconsistent line segment in data file");
|
||||
if (delta / length > EPSILON) error->one(FLERR, "Inconsistent line segment in data file");
|
||||
|
||||
x[m][0] = xc;
|
||||
x[m][1] = yc;
|
||||
@ -385,7 +389,7 @@ void AtomVecLine::data_atom_bonus(int m, const std::vector<std::string> &values)
|
||||
double AtomVecLine::memory_usage_bonus()
|
||||
{
|
||||
double bytes = 0;
|
||||
bytes += (double)nmax_bonus*sizeof(Bonus);
|
||||
bytes += (double) nmax_bonus * sizeof(Bonus);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
@ -398,7 +402,7 @@ void AtomVecLine::create_atom_post(int ilocal)
|
||||
{
|
||||
double radius_one = 0.5;
|
||||
radius[ilocal] = radius_one;
|
||||
rmass[ilocal] = 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one;
|
||||
rmass[ilocal] = 4.0 * MY_PI / 3.0 * radius_one * radius_one * radius_one;
|
||||
line[ilocal] = -1;
|
||||
}
|
||||
|
||||
@ -410,19 +414,22 @@ void AtomVecLine::create_atom_post(int ilocal)
|
||||
void AtomVecLine::data_atom_post(int ilocal)
|
||||
{
|
||||
line_flag = line[ilocal];
|
||||
if (line_flag == 0) line_flag = -1;
|
||||
else if (line_flag == 1) line_flag = 0;
|
||||
else error->one(FLERR,"Invalid line flag in Atoms section of data file");
|
||||
if (line_flag == 0)
|
||||
line_flag = -1;
|
||||
else if (line_flag == 1)
|
||||
line_flag = 0;
|
||||
else
|
||||
error->one(FLERR, "Invalid line flag in Atoms section of data file");
|
||||
line[ilocal] = line_flag;
|
||||
|
||||
if (rmass[ilocal] <= 0.0)
|
||||
error->one(FLERR,"Invalid density in Atoms section of data file");
|
||||
if (rmass[ilocal] <= 0.0) error->one(FLERR, "Invalid density in Atoms section of data file");
|
||||
|
||||
if (line_flag < 0) {
|
||||
double radius_one = 0.5;
|
||||
radius[ilocal] = radius_one;
|
||||
rmass[ilocal] *= 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one;
|
||||
} else radius[ilocal] = 0.0;
|
||||
rmass[ilocal] *= 4.0 * MY_PI / 3.0 * radius_one * radius_one * radius_one;
|
||||
} else
|
||||
radius[ilocal] = 0.0;
|
||||
|
||||
omega[ilocal][0] = 0.0;
|
||||
omega[ilocal][1] = 0.0;
|
||||
@ -438,13 +445,16 @@ void AtomVecLine::pack_data_pre(int ilocal)
|
||||
line_flag = line[ilocal];
|
||||
rmass_one = rmass[ilocal];
|
||||
|
||||
if (line_flag < 0) line[ilocal] = 0;
|
||||
else line[ilocal] = 1;
|
||||
if (line_flag < 0)
|
||||
line[ilocal] = 0;
|
||||
else
|
||||
line[ilocal] = 1;
|
||||
|
||||
if (line_flag < 0) {
|
||||
double radius_one = radius[ilocal];
|
||||
rmass[ilocal] /= 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one;
|
||||
} else rmass[ilocal] /= bonus[line_flag].length;
|
||||
rmass[ilocal] /= 4.0 * MY_PI / 3.0 * radius_one * radius_one * radius_one;
|
||||
} else
|
||||
rmass[ilocal] /= bonus[line_flag].length;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -464,9 +474,9 @@ void AtomVecLine::pack_data_post(int ilocal)
|
||||
|
||||
int AtomVecLine::pack_data_bonus(double *buf, int /*flag*/)
|
||||
{
|
||||
int i,j;
|
||||
double length,theta;
|
||||
double xc,yc,x1,x2,y1,y2;
|
||||
int i, j;
|
||||
double length, theta;
|
||||
double xc, yc, x1, x2, y1, y2;
|
||||
|
||||
double **x = atom->x;
|
||||
tagint *tag = atom->tag;
|
||||
@ -482,15 +492,16 @@ int AtomVecLine::pack_data_bonus(double *buf, int /*flag*/)
|
||||
theta = bonus[j].theta;
|
||||
xc = x[i][0];
|
||||
yc = x[i][1];
|
||||
x1 = xc - 0.5*cos(theta)*length;
|
||||
y1 = yc - 0.5*sin(theta)*length;
|
||||
x2 = xc + 0.5*cos(theta)*length;
|
||||
y2 = yc + 0.5*sin(theta)*length;
|
||||
x1 = xc - 0.5 * cos(theta) * length;
|
||||
y1 = yc - 0.5 * sin(theta) * length;
|
||||
x2 = xc + 0.5 * cos(theta) * length;
|
||||
y2 = yc + 0.5 * sin(theta) * length;
|
||||
buf[m++] = x1;
|
||||
buf[m++] = y1;
|
||||
buf[m++] = x2;
|
||||
buf[m++] = y2;
|
||||
} else m += size_data_bonus;
|
||||
} else
|
||||
m += size_data_bonus;
|
||||
}
|
||||
return m;
|
||||
}
|
||||
@ -503,8 +514,8 @@ void AtomVecLine::write_data_bonus(FILE *fp, int n, double *buf, int /*flag*/)
|
||||
{
|
||||
int i = 0;
|
||||
while (i < n) {
|
||||
fmt::print(fp,"{} {} {} {} {}\n",ubuf(buf[i]).i,
|
||||
buf[i+1],buf[i+2],buf[i+3],buf[i+4]);
|
||||
fmt::print(fp, "{} {} {} {} {}\n", ubuf(buf[i]).i, buf[i + 1], buf[i + 2], buf[i + 3],
|
||||
buf[i + 4]);
|
||||
i += size_data_bonus;
|
||||
}
|
||||
}
|
||||
@ -525,10 +536,11 @@ void AtomVecLine::set_length(int i, double value)
|
||||
bonus[nlocal_bonus].ilocal = i;
|
||||
line[i] = nlocal_bonus++;
|
||||
} else if (value == 0.0) {
|
||||
copy_bonus_all(nlocal_bonus-1,line[i]);
|
||||
copy_bonus_all(nlocal_bonus - 1, line[i]);
|
||||
nlocal_bonus--;
|
||||
line[i] = -1;
|
||||
} else bonus[line[i]].length = value;
|
||||
} else
|
||||
bonus[line[i]].length = value;
|
||||
|
||||
// also set radius = half of length
|
||||
// unless value = 0.0, then set diameter = 1.0
|
||||
@ -536,40 +548,3 @@ void AtomVecLine::set_length(int i, double value)
|
||||
radius[i] = 0.5 * value;
|
||||
if (value == 0.0) radius[i] = 0.5;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
check consistency of internal Bonus data structure
|
||||
n = # of atoms in regular structure to check against
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
void AtomVecLine::consistency_check(int n, char *str)
|
||||
{
|
||||
int iflag = 0;
|
||||
int count = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
|
||||
if (line[i] >= 0) {
|
||||
count++;
|
||||
if (line[i] >= nlocal_bonus) iflag++;
|
||||
if (bonus[line[i]].ilocal != i) iflag++;
|
||||
//if (comm->me == 1 && update->ntimestep == 873)
|
||||
// printf("CCHK %s: %d %d: %d %d: %d %d\n",
|
||||
// str,i,n,line[i],nlocal_bonus,bonus[line[i]].ilocal,iflag);
|
||||
}
|
||||
}
|
||||
|
||||
if (iflag) {
|
||||
printf("BAD vecline ptrs: %s: %d %d: %d\n",str,comm->me,
|
||||
update->ntimestep,iflag);
|
||||
MPI_Abort(world,1);
|
||||
}
|
||||
|
||||
if (count != nlocal_bonus) {
|
||||
char msg[128];
|
||||
printf("BAD vecline count: %s: %d %d: %d %d\n",
|
||||
str,comm->me,update->ntimestep,count,nlocal_bonus);
|
||||
MPI_Abort(world,1);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -21,8 +20,6 @@
|
||||
#include "math_const.h"
|
||||
#include "modify.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
|
||||
@ -34,26 +31,24 @@ AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp)
|
||||
molecular = Atom::ATOMIC;
|
||||
|
||||
atom->sphere_flag = 1;
|
||||
atom->radius_flag = atom->rmass_flag = atom->omega_flag =
|
||||
atom->torque_flag = 1;
|
||||
atom->radius_flag = atom->rmass_flag = atom->omega_flag = atom->torque_flag = 1;
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "radius rmass omega torque";
|
||||
fields_copy = (char *) "radius rmass omega";
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "omega";
|
||||
fields_reverse = (char *) "torque";
|
||||
fields_border = (char *) "radius rmass";
|
||||
fields_border_vel = (char *) "radius rmass omega";
|
||||
fields_exchange = (char *) "radius rmass omega";
|
||||
fields_restart = (char *) "radius rmass omega";
|
||||
fields_create = (char *) "radius rmass omega";
|
||||
fields_data_atom = (char *) "id type radius rmass x";
|
||||
fields_data_vel = (char *) "id v omega";
|
||||
fields_grow = {"radius", "rmass", "omega", "torque"};
|
||||
fields_copy = {"radius", "rmass", "omega"};
|
||||
fields_comm_vel = {"omega"};
|
||||
fields_reverse = {"torque"};
|
||||
fields_border = {"radius", "rmass"};
|
||||
fields_border_vel = {"radius", "rmass", "omega"};
|
||||
fields_exchange = {"radius", "rmass", "omega"};
|
||||
fields_restart = {"radius", "rmass", "omega"};
|
||||
fields_create = {"radius", "rmass", "omega"};
|
||||
fields_data_atom = {"id", "type", "radius", "rmass", "x"};
|
||||
fields_data_vel = {"id", "v", "omega"};
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -63,21 +58,19 @@ AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
void AtomVecSphere::process_args(int narg, char **arg)
|
||||
{
|
||||
if (narg != 0 && narg != 1)
|
||||
error->all(FLERR,"Illegal atom_style sphere command");
|
||||
if (narg != 0 && narg != 1) error->all(FLERR, "Illegal atom_style sphere command");
|
||||
|
||||
radvary = 0;
|
||||
if (narg == 1) {
|
||||
radvary = utils::numeric(FLERR,arg[0],true,lmp);
|
||||
if (radvary < 0 || radvary > 1)
|
||||
error->all(FLERR,"Illegal atom_style sphere command");
|
||||
radvary = utils::numeric(FLERR, arg[0], true, lmp);
|
||||
if (radvary < 0 || radvary > 1) error->all(FLERR, "Illegal atom_style sphere command");
|
||||
}
|
||||
|
||||
// dynamic particle radius and mass must be communicated every step
|
||||
|
||||
if (radvary) {
|
||||
fields_comm = (char *) "radius rmass";
|
||||
fields_comm_vel = (char *) "radius rmass omega";
|
||||
fields_comm = {"radius", "rmass"};
|
||||
fields_comm_vel = {"radius", "rmass", "omega"};
|
||||
}
|
||||
|
||||
// delay setting up of fields until now
|
||||
@ -94,11 +87,10 @@ void AtomVecSphere::init()
|
||||
// check if optional radvary setting should have been set to 1
|
||||
|
||||
for (int i = 0; i < modify->nfix; i++)
|
||||
if (strcmp(modify->fix[i]->style,"adapt") == 0) {
|
||||
auto fix = dynamic_cast<FixAdapt *>( modify->fix[i]);
|
||||
if (strcmp(modify->fix[i]->style, "adapt") == 0) {
|
||||
auto fix = dynamic_cast<FixAdapt *>(modify->fix[i]);
|
||||
if (fix->diamflag && radvary == 0)
|
||||
error->all(FLERR,"Fix adapt changes particle radii "
|
||||
"but atom_style sphere is not dynamic");
|
||||
error->all(FLERR, "Fix adapt changes particle radii but atom_style sphere is not dynamic");
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,7 +113,7 @@ void AtomVecSphere::grow_pointers()
|
||||
void AtomVecSphere::create_atom_post(int ilocal)
|
||||
{
|
||||
radius[ilocal] = 0.5;
|
||||
rmass[ilocal] = 4.0*MY_PI/3.0 * 0.5*0.5*0.5;
|
||||
rmass[ilocal] = 4.0 * MY_PI / 3.0 * 0.5 * 0.5 * 0.5;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -133,11 +125,9 @@ void AtomVecSphere::data_atom_post(int ilocal)
|
||||
{
|
||||
radius_one = 0.5 * atom->radius[ilocal];
|
||||
radius[ilocal] = radius_one;
|
||||
if (radius_one > 0.0)
|
||||
rmass[ilocal] *= 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one;
|
||||
if (radius_one > 0.0) rmass[ilocal] *= 4.0 * MY_PI / 3.0 * radius_one * radius_one * radius_one;
|
||||
|
||||
if (rmass[ilocal] <= 0.0)
|
||||
error->one(FLERR,"Invalid density in Atoms section of data file");
|
||||
if (rmass[ilocal] <= 0.0) error->one(FLERR, "Invalid density in Atoms section of data file");
|
||||
|
||||
omega[ilocal][0] = 0.0;
|
||||
omega[ilocal][1] = 0.0;
|
||||
@ -154,9 +144,8 @@ void AtomVecSphere::pack_data_pre(int ilocal)
|
||||
rmass_one = rmass[ilocal];
|
||||
|
||||
radius[ilocal] *= 2.0;
|
||||
if (radius_one!= 0.0)
|
||||
rmass[ilocal] =
|
||||
rmass_one / (4.0*MY_PI/3.0 * radius_one*radius_one*radius_one);
|
||||
if (radius_one != 0.0)
|
||||
rmass[ilocal] = rmass_one / (4.0 * MY_PI / 3.0 * radius_one * radius_one * radius_one);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -19,18 +18,17 @@
|
||||
#include "error.h"
|
||||
#include "fix.h"
|
||||
#include "math_const.h"
|
||||
#include "math_extra.h"
|
||||
#include "math_eigen.h"
|
||||
#include "math_extra.h"
|
||||
#include "memory.h"
|
||||
#include "modify.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
using MathConst::MY_PI;
|
||||
|
||||
#define EPSILON 0.001
|
||||
static constexpr double EPSILON = 0.001;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -58,18 +56,17 @@ AtomVecTri::AtomVecTri(LAMMPS *lmp) : AtomVec(lmp)
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "molecule radius rmass omega angmom torque tri";
|
||||
fields_copy = (char *) "molecule radius rmass omega angmom";
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "omega angmom";
|
||||
fields_reverse = (char *) "torque";
|
||||
fields_border = (char *) "molecule radius rmass";
|
||||
fields_border_vel = (char *) "molecule radius rmass omega";
|
||||
fields_exchange = (char *) "molecule radius rmass omega angmom";
|
||||
fields_restart = (char *) "molecule radius rmass omega angmom";
|
||||
fields_create = (char *) "molecule radius rmass omega angmom tri";
|
||||
fields_data_atom = (char *) "id molecule type tri rmass x";
|
||||
fields_data_vel = (char *) "id v omega angmom";
|
||||
fields_grow = {"molecule", "radius", "rmass", "omega", "angmom", "torque", "tri"};
|
||||
fields_copy = {"molecule", "radius", "rmass", "omega", "angmom"};
|
||||
fields_comm_vel = {"omega", "angmom"};
|
||||
fields_reverse = {"torque"};
|
||||
fields_border = {"molecule", "radius", "rmass"};
|
||||
fields_border_vel = {"molecule", "radius", "rmass", "omega"};
|
||||
fields_exchange = {"molecule", "radius", "rmass", "omega", "angmom"};
|
||||
fields_restart = {"molecule", "radius", "rmass", "omega", "angmom"};
|
||||
fields_create = {"molecule", "radius", "rmass", "omega", "angmom", "tri"};
|
||||
fields_data_atom = {"id", "molecule", "type", "tri", "rmass", "x"};
|
||||
fields_data_vel = {"id", "v", "omega", "angmom"};
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
@ -88,7 +85,7 @@ void AtomVecTri::init()
|
||||
AtomVec::init();
|
||||
|
||||
if (domain->dimension != 3)
|
||||
error->all(FLERR,"Atom_style tri can only be used in 3d simulations");
|
||||
error->all(FLERR, "Atom_style tri can only be used in 3d simulations");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -112,11 +109,9 @@ void AtomVecTri::grow_pointers()
|
||||
void AtomVecTri::grow_bonus()
|
||||
{
|
||||
nmax_bonus = grow_nmax_bonus(nmax_bonus);
|
||||
if (nmax_bonus < 0)
|
||||
error->one(FLERR,"Per-processor system is too big");
|
||||
if (nmax_bonus < 0) error->one(FLERR, "Per-processor system is too big");
|
||||
|
||||
bonus = (Bonus *) memory->srealloc(bonus,nmax_bonus*sizeof(Bonus),
|
||||
"atom:bonus");
|
||||
bonus = (Bonus *) memory->srealloc(bonus, nmax_bonus * sizeof(Bonus), "atom:bonus");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -129,7 +124,7 @@ void AtomVecTri::copy_bonus(int i, int j, int delflag)
|
||||
// if deleting atom J via delflag and J has bonus data, then delete it
|
||||
|
||||
if (delflag && tri[j] >= 0) {
|
||||
copy_bonus_all(nlocal_bonus-1,tri[j]);
|
||||
copy_bonus_all(nlocal_bonus - 1, tri[j]);
|
||||
nlocal_bonus--;
|
||||
}
|
||||
|
||||
@ -148,7 +143,7 @@ void AtomVecTri::copy_bonus(int i, int j, int delflag)
|
||||
void AtomVecTri::copy_bonus_all(int i, int j)
|
||||
{
|
||||
tri[bonus[i].ilocal] = j;
|
||||
memcpy(&bonus[j],&bonus[i],sizeof(Bonus));
|
||||
memcpy(&bonus[j], &bonus[i], sizeof(Bonus));
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -169,7 +164,7 @@ void AtomVecTri::clear_bonus()
|
||||
|
||||
int AtomVecTri::pack_comm_bonus(int n, int *list, double *buf)
|
||||
{
|
||||
int i,j,m;
|
||||
int i, j, m;
|
||||
double *quat;
|
||||
|
||||
m = 0;
|
||||
@ -191,7 +186,7 @@ int AtomVecTri::pack_comm_bonus(int n, int *list, double *buf)
|
||||
|
||||
void AtomVecTri::unpack_comm_bonus(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
int i, m, last;
|
||||
double *quat;
|
||||
|
||||
m = 0;
|
||||
@ -211,13 +206,14 @@ void AtomVecTri::unpack_comm_bonus(int n, int first, double *buf)
|
||||
|
||||
int AtomVecTri::pack_border_bonus(int n, int *list, double *buf)
|
||||
{
|
||||
int i,j,m;
|
||||
double *quat,*c1,*c2,*c3,*inertia;
|
||||
int i, j, m;
|
||||
double *quat, *c1, *c2, *c3, *inertia;
|
||||
|
||||
m = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
if (tri[j] < 0) buf[m++] = ubuf(0).d;
|
||||
if (tri[j] < 0)
|
||||
buf[m++] = ubuf(0).d;
|
||||
else {
|
||||
buf[m++] = ubuf(1).d;
|
||||
quat = bonus[tri[j]].quat;
|
||||
@ -251,14 +247,15 @@ int AtomVecTri::pack_border_bonus(int n, int *list, double *buf)
|
||||
|
||||
int AtomVecTri::unpack_border_bonus(int n, int first, double *buf)
|
||||
{
|
||||
int i,j,m,last;
|
||||
double *quat,*c1,*c2,*c3,*inertia;
|
||||
int i, j, m, last;
|
||||
double *quat, *c1, *c2, *c3, *inertia;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
tri[i] = (int) ubuf(buf[m++]).i;
|
||||
if (tri[i] == 0) tri[i] = -1;
|
||||
if (tri[i] == 0)
|
||||
tri[i] = -1;
|
||||
else {
|
||||
j = nlocal_bonus + nghost_bonus;
|
||||
if (j == nmax_bonus) grow_bonus();
|
||||
@ -301,7 +298,8 @@ int AtomVecTri::pack_exchange_bonus(int i, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
|
||||
if (tri[i] < 0) buf[m++] = ubuf(0).d;
|
||||
if (tri[i] < 0)
|
||||
buf[m++] = ubuf(0).d;
|
||||
else {
|
||||
buf[m++] = ubuf(1).d;
|
||||
int j = tri[i];
|
||||
@ -338,7 +336,8 @@ int AtomVecTri::unpack_exchange_bonus(int ilocal, double *buf)
|
||||
int m = 0;
|
||||
|
||||
tri[ilocal] = (int) ubuf(buf[m++]).i;
|
||||
if (tri[ilocal] == 0) tri[ilocal] = -1;
|
||||
if (tri[ilocal] == 0)
|
||||
tri[ilocal] = -1;
|
||||
else {
|
||||
if (nlocal_bonus == nmax_bonus) grow_bonus();
|
||||
double *quat = bonus[nlocal_bonus].quat;
|
||||
@ -381,8 +380,10 @@ int AtomVecTri::size_restart_bonus()
|
||||
int n = 0;
|
||||
int nlocal = atom->nlocal;
|
||||
for (i = 0; i < nlocal; i++) {
|
||||
if (tri[i] >= 0) n += size_restart_bonus_one;
|
||||
else n++;
|
||||
if (tri[i] >= 0)
|
||||
n += size_restart_bonus_one;
|
||||
else
|
||||
n++;
|
||||
}
|
||||
|
||||
return n;
|
||||
@ -396,7 +397,8 @@ int AtomVecTri::pack_restart_bonus(int i, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
|
||||
if (tri[i] < 0) buf[m++] = ubuf(0).d;
|
||||
if (tri[i] < 0)
|
||||
buf[m++] = ubuf(0).d;
|
||||
else {
|
||||
buf[m++] = ubuf(1).d;
|
||||
int j = tri[i];
|
||||
@ -435,7 +437,8 @@ int AtomVecTri::unpack_restart_bonus(int ilocal, double *buf)
|
||||
int m = 0;
|
||||
|
||||
tri[ilocal] = (int) ubuf(buf[m++]).i;
|
||||
if (tri[ilocal] == 0) tri[ilocal] = -1;
|
||||
if (tri[ilocal] == 0)
|
||||
tri[ilocal] = -1;
|
||||
else {
|
||||
if (nlocal_bonus == nmax_bonus) grow_bonus();
|
||||
double *quat = bonus[nlocal_bonus].quat;
|
||||
@ -472,52 +475,51 @@ int AtomVecTri::unpack_restart_bonus(int ilocal, double *buf)
|
||||
|
||||
void AtomVecTri::data_atom_bonus(int m, const std::vector<std::string> &values)
|
||||
{
|
||||
if (tri[m]) error->one(FLERR,"Assigning tri parameters to non-tri atom");
|
||||
if (tri[m]) error->one(FLERR, "Assigning tri parameters to non-tri atom");
|
||||
|
||||
if (nlocal_bonus == nmax_bonus) grow_bonus();
|
||||
|
||||
double c1[3],c2[3],c3[3];
|
||||
double c1[3], c2[3], c3[3];
|
||||
int ivalue = 1;
|
||||
c1[0] = utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
c1[1] = utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
c1[2] = utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
c2[0] = utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
c2[1] = utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
c2[2] = utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
c3[0] = utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
c3[1] = utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
c3[2] = utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
c1[0] = utils::numeric(FLERR, values[ivalue++], true, lmp);
|
||||
c1[1] = utils::numeric(FLERR, values[ivalue++], true, lmp);
|
||||
c1[2] = utils::numeric(FLERR, values[ivalue++], true, lmp);
|
||||
c2[0] = utils::numeric(FLERR, values[ivalue++], true, lmp);
|
||||
c2[1] = utils::numeric(FLERR, values[ivalue++], true, lmp);
|
||||
c2[2] = utils::numeric(FLERR, values[ivalue++], true, lmp);
|
||||
c3[0] = utils::numeric(FLERR, values[ivalue++], true, lmp);
|
||||
c3[1] = utils::numeric(FLERR, values[ivalue++], true, lmp);
|
||||
c3[2] = utils::numeric(FLERR, values[ivalue++], true, lmp);
|
||||
|
||||
// check for duplicate points
|
||||
|
||||
if (c1[0] == c2[0] && c1[1] == c2[1] && c1[2] == c2[2])
|
||||
error->one(FLERR,"Invalid shape in Triangles section of data file");
|
||||
error->one(FLERR, "Invalid shape in Triangles section of data file");
|
||||
if (c1[0] == c3[0] && c1[1] == c3[1] && c1[2] == c3[2])
|
||||
error->one(FLERR,"Invalid shape in Triangles section of data file");
|
||||
error->one(FLERR, "Invalid shape in Triangles section of data file");
|
||||
if (c2[0] == c3[0] && c2[1] == c3[1] && c2[2] == c3[2])
|
||||
error->one(FLERR,"Invalid shape in Triangles section of data file");
|
||||
error->one(FLERR, "Invalid shape in Triangles section of data file");
|
||||
|
||||
// size = length of one edge
|
||||
|
||||
double c2mc1[3],c3mc1[3];
|
||||
MathExtra::sub3(c2,c1,c2mc1);
|
||||
MathExtra::sub3(c3,c1,c3mc1);
|
||||
double size = MAX(MathExtra::len3(c2mc1),MathExtra::len3(c3mc1));
|
||||
double c2mc1[3], c3mc1[3];
|
||||
MathExtra::sub3(c2, c1, c2mc1);
|
||||
MathExtra::sub3(c3, c1, c3mc1);
|
||||
double size = MAX(MathExtra::len3(c2mc1), MathExtra::len3(c3mc1));
|
||||
|
||||
// centroid = 1/3 of sum of vertices
|
||||
|
||||
double centroid[3];
|
||||
centroid[0] = (c1[0]+c2[0]+c3[0]) / 3.0;
|
||||
centroid[1] = (c1[1]+c2[1]+c3[1]) / 3.0;
|
||||
centroid[2] = (c1[2]+c2[2]+c3[2]) / 3.0;
|
||||
centroid[0] = (c1[0] + c2[0] + c3[0]) / 3.0;
|
||||
centroid[1] = (c1[1] + c2[1] + c3[1]) / 3.0;
|
||||
centroid[2] = (c1[2] + c2[2] + c3[2]) / 3.0;
|
||||
|
||||
double dx = centroid[0] - x[m][0];
|
||||
double dy = centroid[1] - x[m][1];
|
||||
double dz = centroid[2] - x[m][2];
|
||||
double delta = sqrt(dx*dx + dy*dy + dz*dz);
|
||||
double delta = sqrt(dx * dx + dy * dy + dz * dz);
|
||||
|
||||
if (delta/size > EPSILON)
|
||||
error->one(FLERR,"Inconsistent triangle in data file");
|
||||
if (delta / size > EPSILON) error->one(FLERR, "Inconsistent triangle in data file");
|
||||
|
||||
x[m][0] = centroid[0];
|
||||
x[m][1] = centroid[1];
|
||||
@ -528,29 +530,29 @@ void AtomVecTri::data_atom_bonus(int m, const std::vector<std::string> &values)
|
||||
// tri area = 0.5 len(U x V), where U,V are edge vectors from one vertex
|
||||
|
||||
double c4[3];
|
||||
MathExtra::sub3(c1,centroid,c4);
|
||||
MathExtra::sub3(c1, centroid, c4);
|
||||
radius[m] = MathExtra::lensq3(c4);
|
||||
MathExtra::sub3(c2,centroid,c4);
|
||||
radius[m] = MAX(radius[m],MathExtra::lensq3(c4));
|
||||
MathExtra::sub3(c3,centroid,c4);
|
||||
radius[m] = MAX(radius[m],MathExtra::lensq3(c4));
|
||||
MathExtra::sub3(c2, centroid, c4);
|
||||
radius[m] = MAX(radius[m], MathExtra::lensq3(c4));
|
||||
MathExtra::sub3(c3, centroid, c4);
|
||||
radius[m] = MAX(radius[m], MathExtra::lensq3(c4));
|
||||
radius[m] = sqrt(radius[m]);
|
||||
|
||||
double norm[3];
|
||||
MathExtra::cross3(c2mc1,c3mc1,norm);
|
||||
MathExtra::cross3(c2mc1, c3mc1, norm);
|
||||
double area = 0.5 * MathExtra::len3(norm);
|
||||
rmass[m] *= area;
|
||||
|
||||
// inertia = inertia tensor of triangle as 6-vector in Voigt ordering
|
||||
|
||||
double inertia[6];
|
||||
MathExtra::inertia_triangle(c1,c2,c3,rmass[m],inertia);
|
||||
MathExtra::inertia_triangle(c1, c2, c3, rmass[m], inertia);
|
||||
|
||||
// diagonalize inertia tensor via Jacobi rotations
|
||||
// bonus[].inertia = 3 eigenvalues = principal moments of inertia
|
||||
// evectors and exzy_space = 3 evectors = principal axes of triangle
|
||||
|
||||
double tensor[3][3],evectors[3][3];
|
||||
double tensor[3][3], evectors[3][3];
|
||||
tensor[0][0] = inertia[0];
|
||||
tensor[1][1] = inertia[1];
|
||||
tensor[2][2] = inertia[2];
|
||||
@ -558,10 +560,10 @@ void AtomVecTri::data_atom_bonus(int m, const std::vector<std::string> &values)
|
||||
tensor[0][2] = tensor[2][0] = inertia[4];
|
||||
tensor[0][1] = tensor[1][0] = inertia[5];
|
||||
|
||||
int ierror = MathEigen::jacobi3(tensor,bonus[nlocal_bonus].inertia,evectors);
|
||||
if (ierror) error->one(FLERR,"Insufficient Jacobi rotations for triangle");
|
||||
int ierror = MathEigen::jacobi3(tensor, bonus[nlocal_bonus].inertia, evectors);
|
||||
if (ierror) error->one(FLERR, "Insufficient Jacobi rotations for triangle");
|
||||
|
||||
double ex_space[3],ey_space[3],ez_space[3];
|
||||
double ex_space[3], ey_space[3], ez_space[3];
|
||||
ex_space[0] = evectors[0][0];
|
||||
ex_space[1] = evectors[1][0];
|
||||
ex_space[2] = evectors[2][0];
|
||||
@ -575,26 +577,23 @@ void AtomVecTri::data_atom_bonus(int m, const std::vector<std::string> &values)
|
||||
// enforce 3 orthogonal vectors as a right-handed coordinate system
|
||||
// flip 3rd vector if needed
|
||||
|
||||
MathExtra::cross3(ex_space,ey_space,norm);
|
||||
if (MathExtra::dot3(norm,ez_space) < 0.0) MathExtra::negate3(ez_space);
|
||||
MathExtra::cross3(ex_space, ey_space, norm);
|
||||
if (MathExtra::dot3(norm, ez_space) < 0.0) MathExtra::negate3(ez_space);
|
||||
|
||||
// create initial quaternion
|
||||
|
||||
MathExtra::exyz_to_q(ex_space,ey_space,ez_space,bonus[nlocal_bonus].quat);
|
||||
MathExtra::exyz_to_q(ex_space, ey_space, ez_space, bonus[nlocal_bonus].quat);
|
||||
|
||||
// bonus c1,c2,c3 = displacement of c1,c2,c3 from centroid
|
||||
// in basis of principal axes
|
||||
|
||||
double disp[3];
|
||||
MathExtra::sub3(c1,centroid,disp);
|
||||
MathExtra::transpose_matvec(ex_space,ey_space,ez_space,
|
||||
disp,bonus[nlocal_bonus].c1);
|
||||
MathExtra::sub3(c2,centroid,disp);
|
||||
MathExtra::transpose_matvec(ex_space,ey_space,ez_space,
|
||||
disp,bonus[nlocal_bonus].c2);
|
||||
MathExtra::sub3(c3,centroid,disp);
|
||||
MathExtra::transpose_matvec(ex_space,ey_space,ez_space,
|
||||
disp,bonus[nlocal_bonus].c3);
|
||||
MathExtra::sub3(c1, centroid, disp);
|
||||
MathExtra::transpose_matvec(ex_space, ey_space, ez_space, disp, bonus[nlocal_bonus].c1);
|
||||
MathExtra::sub3(c2, centroid, disp);
|
||||
MathExtra::transpose_matvec(ex_space, ey_space, ez_space, disp, bonus[nlocal_bonus].c2);
|
||||
MathExtra::sub3(c3, centroid, disp);
|
||||
MathExtra::transpose_matvec(ex_space, ey_space, ez_space, disp, bonus[nlocal_bonus].c3);
|
||||
|
||||
bonus[nlocal_bonus].ilocal = m;
|
||||
tri[m] = nlocal_bonus++;
|
||||
@ -607,7 +606,7 @@ void AtomVecTri::data_atom_bonus(int m, const std::vector<std::string> &values)
|
||||
double AtomVecTri::memory_usage_bonus()
|
||||
{
|
||||
double bytes = 0;
|
||||
bytes += (double)nmax_bonus*sizeof(Bonus);
|
||||
bytes += (double) nmax_bonus * sizeof(Bonus);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
@ -620,7 +619,7 @@ void AtomVecTri::create_atom_post(int ilocal)
|
||||
{
|
||||
double radius_one = 0.5;
|
||||
radius[ilocal] = radius_one;
|
||||
rmass[ilocal] = 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one;
|
||||
rmass[ilocal] = 4.0 * MY_PI / 3.0 * radius_one * radius_one * radius_one;
|
||||
tri[ilocal] = -1;
|
||||
}
|
||||
|
||||
@ -632,19 +631,22 @@ void AtomVecTri::create_atom_post(int ilocal)
|
||||
void AtomVecTri::data_atom_post(int ilocal)
|
||||
{
|
||||
tri_flag = tri[ilocal];
|
||||
if (tri_flag == 0) tri_flag = -1;
|
||||
else if (tri_flag == 1) tri_flag = 0;
|
||||
else error->one(FLERR,"Invalid tri flag in Atoms section of data file");
|
||||
if (tri_flag == 0)
|
||||
tri_flag = -1;
|
||||
else if (tri_flag == 1)
|
||||
tri_flag = 0;
|
||||
else
|
||||
error->one(FLERR, "Invalid tri flag in Atoms section of data file");
|
||||
tri[ilocal] = tri_flag;
|
||||
|
||||
if (rmass[ilocal] <= 0.0)
|
||||
error->one(FLERR,"Invalid density in Atoms section of data file");
|
||||
if (rmass[ilocal] <= 0.0) error->one(FLERR, "Invalid density in Atoms section of data file");
|
||||
|
||||
if (tri_flag < 0) {
|
||||
double radius_one = 0.5;
|
||||
radius[ilocal] = radius_one;
|
||||
rmass[ilocal] *= 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one;
|
||||
} else radius[ilocal] = 0.0;
|
||||
rmass[ilocal] *= 4.0 * MY_PI / 3.0 * radius_one * radius_one * radius_one;
|
||||
} else
|
||||
radius[ilocal] = 0.0;
|
||||
|
||||
omega[ilocal][0] = 0.0;
|
||||
omega[ilocal][1] = 0.0;
|
||||
@ -663,17 +665,19 @@ void AtomVecTri::pack_data_pre(int ilocal)
|
||||
tri_flag = tri[ilocal];
|
||||
rmass_one = rmass[ilocal];
|
||||
|
||||
if (tri_flag < 0) tri[ilocal] = 0;
|
||||
else tri[ilocal] = 1;
|
||||
if (tri_flag < 0)
|
||||
tri[ilocal] = 0;
|
||||
else
|
||||
tri[ilocal] = 1;
|
||||
|
||||
if (tri_flag < 0) {
|
||||
double radius_one = radius[ilocal];
|
||||
rmass[ilocal] /= 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one;
|
||||
rmass[ilocal] /= 4.0 * MY_PI / 3.0 * radius_one * radius_one * radius_one;
|
||||
} else {
|
||||
double c2mc1[3],c3mc1[3],norm[3];
|
||||
MathExtra::sub3(bonus[tri_flag].c2,bonus[tri_flag].c1,c2mc1);
|
||||
MathExtra::sub3(bonus[tri_flag].c3,bonus[tri_flag].c1,c3mc1);
|
||||
MathExtra::cross3(c2mc1,c3mc1,norm);
|
||||
double c2mc1[3], c3mc1[3], norm[3];
|
||||
MathExtra::sub3(bonus[tri_flag].c2, bonus[tri_flag].c1, c2mc1);
|
||||
MathExtra::sub3(bonus[tri_flag].c3, bonus[tri_flag].c1, c3mc1);
|
||||
MathExtra::cross3(c2mc1, c3mc1, norm);
|
||||
double area = 0.5 * MathExtra::len3(norm);
|
||||
rmass[ilocal] /= area;
|
||||
}
|
||||
@ -696,9 +700,9 @@ void AtomVecTri::pack_data_post(int ilocal)
|
||||
|
||||
int AtomVecTri::pack_data_bonus(double *buf, int /*flag*/)
|
||||
{
|
||||
int i,j;
|
||||
double xc,yc,zc;
|
||||
double dc1[3],dc2[3],dc3[3];
|
||||
int i, j;
|
||||
double xc, yc, zc;
|
||||
double dc1[3], dc2[3], dc3[3];
|
||||
double p[3][3];
|
||||
|
||||
double **x = atom->x;
|
||||
@ -711,10 +715,10 @@ int AtomVecTri::pack_data_bonus(double *buf, int /*flag*/)
|
||||
if (buf) {
|
||||
buf[m++] = ubuf(tag[i]).d;
|
||||
j = tri[i];
|
||||
MathExtra::quat_to_mat(bonus[j].quat,p);
|
||||
MathExtra::matvec(p,bonus[j].c1,dc1);
|
||||
MathExtra::matvec(p,bonus[j].c2,dc2);
|
||||
MathExtra::matvec(p,bonus[j].c3,dc3);
|
||||
MathExtra::quat_to_mat(bonus[j].quat, p);
|
||||
MathExtra::matvec(p, bonus[j].c1, dc1);
|
||||
MathExtra::matvec(p, bonus[j].c2, dc2);
|
||||
MathExtra::matvec(p, bonus[j].c3, dc3);
|
||||
xc = x[i][0];
|
||||
yc = x[i][1];
|
||||
zc = x[i][2];
|
||||
@ -727,7 +731,8 @@ int AtomVecTri::pack_data_bonus(double *buf, int /*flag*/)
|
||||
buf[m++] = xc + dc3[0];
|
||||
buf[m++] = yc + dc3[1];
|
||||
buf[m++] = zc + dc3[2];
|
||||
} else m += size_data_bonus;
|
||||
} else
|
||||
m += size_data_bonus;
|
||||
}
|
||||
return m;
|
||||
}
|
||||
@ -740,9 +745,8 @@ void AtomVecTri::write_data_bonus(FILE *fp, int n, double *buf, int /*flag*/)
|
||||
{
|
||||
int i = 0;
|
||||
while (i < n) {
|
||||
fmt::print(fp,"{} {} {} {} {} {} {} {} {} {}\n", ubuf(buf[i]).i,
|
||||
buf[i+1],buf[i+2],buf[i+3],buf[i+4],buf[i+5],buf[i+6],
|
||||
buf[i+7],buf[i+8],buf[i+9]);
|
||||
fmt::print(fp, "{} {} {} {} {} {} {} {} {} {}\n", ubuf(buf[i]).i, buf[i + 1], buf[i + 2],
|
||||
buf[i + 3], buf[i + 4], buf[i + 5], buf[i + 6], buf[i + 7], buf[i + 8], buf[i + 9]);
|
||||
i += size_data_bonus;
|
||||
}
|
||||
}
|
||||
@ -770,24 +774,24 @@ void AtomVecTri::set_equilateral(int i, double size)
|
||||
quat[1] = 0.0;
|
||||
quat[2] = 0.0;
|
||||
quat[3] = 0.0;
|
||||
c1[0] = -size/2.0;
|
||||
c1[1] = -sqrt(3.0)/2.0 * size / 3.0;
|
||||
c1[0] = -size / 2.0;
|
||||
c1[1] = -sqrt(3.0) / 2.0 * size / 3.0;
|
||||
c1[2] = 0.0;
|
||||
c2[0] = size/2.0;
|
||||
c2[1] = -sqrt(3.0)/2.0 * size / 3.0;
|
||||
c2[0] = size / 2.0;
|
||||
c2[1] = -sqrt(3.0) / 2.0 * size / 3.0;
|
||||
c2[2] = 0.0;
|
||||
c3[0] = 0.0;
|
||||
c3[1] = sqrt(3.0)/2.0 * size * 2.0/3.0;
|
||||
c3[1] = sqrt(3.0) / 2.0 * size * 2.0 / 3.0;
|
||||
c3[2] = 0.0;
|
||||
inertia[0] = sqrt(3.0)/96.0 * size*size*size*size;
|
||||
inertia[1] = sqrt(3.0)/96.0 * size*size*size*size;
|
||||
inertia[2] = sqrt(3.0)/48.0 * size*size*size*size;
|
||||
inertia[0] = sqrt(3.0) / 96.0 * size * size * size * size;
|
||||
inertia[1] = sqrt(3.0) / 96.0 * size * size * size * size;
|
||||
inertia[2] = sqrt(3.0) / 48.0 * size * size * size * size;
|
||||
radius[i] = MathExtra::len3(c1);
|
||||
bonus[nlocal_bonus].ilocal = i;
|
||||
tri[i] = nlocal_bonus++;
|
||||
} else if (size == 0.0) {
|
||||
radius[i] = 0.5;
|
||||
copy_bonus_all(nlocal_bonus-1,tri[i]);
|
||||
copy_bonus_all(nlocal_bonus - 1, tri[i]);
|
||||
nlocal_bonus--;
|
||||
tri[i] = -1;
|
||||
} else {
|
||||
@ -795,18 +799,18 @@ void AtomVecTri::set_equilateral(int i, double size)
|
||||
double *c2 = bonus[tri[i]].c2;
|
||||
double *c3 = bonus[tri[i]].c3;
|
||||
double *inertia = bonus[tri[i]].inertia;
|
||||
c1[0] = -size/2.0;
|
||||
c1[1] = -sqrt(3.0)/2.0 * size / 3.0;
|
||||
c1[0] = -size / 2.0;
|
||||
c1[1] = -sqrt(3.0) / 2.0 * size / 3.0;
|
||||
c1[2] = 0.0;
|
||||
c2[0] = size/2.0;
|
||||
c2[1] = -sqrt(3.0)/2.0 * size / 3.0;
|
||||
c2[0] = size / 2.0;
|
||||
c2[1] = -sqrt(3.0) / 2.0 * size / 3.0;
|
||||
c2[2] = 0.0;
|
||||
c3[0] = 0.0;
|
||||
c3[1] = sqrt(3.0)/2.0 * size * 2.0/3.0;
|
||||
c3[1] = sqrt(3.0) / 2.0 * size * 2.0 / 3.0;
|
||||
c3[2] = 0.0;
|
||||
inertia[0] = sqrt(3.0)/96.0 * size*size*size*size;
|
||||
inertia[1] = sqrt(3.0)/96.0 * size*size*size*size;
|
||||
inertia[2] = sqrt(3.0)/48.0 * size*size*size*size;
|
||||
inertia[0] = sqrt(3.0) / 96.0 * size * size * size * size;
|
||||
inertia[1] = sqrt(3.0) / 96.0 * size * size * size * size;
|
||||
inertia[2] = sqrt(3.0) / 48.0 * size * size * size * size;
|
||||
radius[i] = MathExtra::len3(c1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ class FixBondHistory : public Fix {
|
||||
double memory_usage() override;
|
||||
void write_restart(FILE *fp) override;
|
||||
void restart(char *buf) override;
|
||||
void set_arrays(int);
|
||||
void set_arrays(int) override;
|
||||
|
||||
void update_atom_value(int, int, int, double);
|
||||
double get_atom_value(int, int, int);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user