Merge branch 'master' into lammps-icms
Resolved Conflicts: src/REPLICA/verlet_split.cpp src/USER-OMP/fix_omp.cpp
This commit is contained in:
@ -32,7 +32,7 @@ lammps_spparks grain-growth Monte Carlo with strain via MD,
|
|||||||
coupling to SPPARKS kinetic MC code
|
coupling to SPPARKS kinetic MC code
|
||||||
library collection of useful inter-code communication routines
|
library collection of useful inter-code communication routines
|
||||||
simple simple example of driver code calling LAMMPS as library
|
simple simple example of driver code calling LAMMPS as library
|
||||||
fortran a wrapper on the LAMMPS library API that
|
fortran a simple wrapper on the LAMMPS library API that
|
||||||
can be called from Fortran
|
can be called from Fortran
|
||||||
fortran2 a more sophisticated wrapper on the LAMMPS library API that
|
fortran2 a more sophisticated wrapper on the LAMMPS library API that
|
||||||
can be called from Fortran
|
can be called from Fortran
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,221 +1,265 @@
|
|||||||
LAMMPS.F90 defines a Fortran 2003 module, LAMMPS, which wraps all functions in
|
LAMMPS.F90 defines a Fortran 2003 module, LAMMPS, which wraps all functions in
|
||||||
src/library.h so they can be used directly from Fortran-encoded programs.
|
src/library.h so they can be used directly from Fortran-encoded programs.
|
||||||
|
|
||||||
All functions in src/library.h that use and/or return C-style pointers have
|
All functions in src/library.h that use and/or return C-style pointers have
|
||||||
Fortran wrapper functions that use Fortran-style arrays, pointers, and
|
Fortran wrapper functions that use Fortran-style arrays, pointers, and
|
||||||
strings; all C-style memory management is handled internally with no user
|
strings; all C-style memory management is handled internally with no user
|
||||||
intervention.
|
intervention. See --USE-- for notes on how this interface differs from the
|
||||||
|
C interface (and the Python interface).
|
||||||
This interface was created by Karl Hammond who you can contact with
|
|
||||||
questions:
|
This interface was created by Karl Hammond who you can contact with
|
||||||
|
questions:
|
||||||
Karl D. Hammond
|
|
||||||
University of Tennessee, Knoxville
|
Karl D. Hammond
|
||||||
karlh at ugcs.caltech.edu
|
University of Tennessee, Knoxville
|
||||||
karlh at utk.edu
|
karlh at ugcs.caltech.edu
|
||||||
|
karlh at utk.edu
|
||||||
-------------------------------------
|
|
||||||
|
-------------------------------------
|
||||||
--COMPILATION--
|
|
||||||
|
--COMPILATION--
|
||||||
First, be advised that mixed-language programming is not trivial. It requires
|
|
||||||
you to link in the required libraries of all languages you use (in this case,
|
First, be advised that mixed-language programming is not trivial. It requires
|
||||||
those for Fortran, C, and C++), as well as any other libraries required.
|
you to link in the required libraries of all languages you use (in this case,
|
||||||
You are also advised to read the --USE-- section below before trying to
|
those for Fortran, C, and C++), as well as any other libraries required.
|
||||||
compile.
|
You are also advised to read the --USE-- section below before trying to
|
||||||
|
compile.
|
||||||
The following steps will work to compile this module (replace ${LAMMPS_SRC}
|
|
||||||
with the path to your LAMMPS source directory):
|
The following steps will work to compile this module (replace ${LAMMPS_SRC}
|
||||||
(1) Compile LAMMPS as a static library. Call the resulting file ${LAMMPS_LIB},
|
with the path to your LAMMPS source directory).
|
||||||
which will have an actual name lake liblmp_openmpi.a. If compiling
|
|
||||||
using the MPI stubs in ${LAMMPS_SRC}/STUBS, you will need to know where
|
Steps 3-5 are accomplished, possibly after some modifications to
|
||||||
libmpi.a is as well (I'll call it ${MPI_STUBS} hereafter)
|
the makefile, by make using the attached makefile. Said makefile also builds
|
||||||
(2) Copy said library to your Fortran program's source directory or include
|
the dynamically-linkable library (liblammps_fortran.so).
|
||||||
its location in a -L${LAMMPS_SRC} flag to your compiler.
|
|
||||||
(3) Compile (but don't link!) LAMMPS.F90. Example:
|
** STATIC LIBRARY INSTRUCTIONS **
|
||||||
mpif90 -c LAMMPS.f90
|
(1) Compile LAMMPS as a static library.
|
||||||
OR
|
Call the resulting file ${LAMMPS_LIB}, which will have an actual name
|
||||||
gfortran -c LAMMPS.F90
|
like liblmp_openmpi.a. If compiling using the MPI stubs in
|
||||||
Copy the LAMMPS.o and lammps.mod (or whatever your compiler calls module
|
${LAMMPS_SRC}/STUBS, you will need to know where libmpi_stubs.a
|
||||||
files) to your Fortran program's source directory.
|
is as well (I'll call it ${MPI_STUBS} hereafter)
|
||||||
NOTE: you may get a warning such as,
|
(2) Copy said library to your Fortran program's source directory or replace
|
||||||
subroutine lammps_open_wrapper (argc, argv, communicator, ptr) &
|
${LAMMPS_LIB} with its full path in the instructions below.
|
||||||
Variable 'communicator' at (1) is a parameter to the BIND(C)
|
(3) Compile (but don't link!) LAMMPS.F90. Example:
|
||||||
procedure 'lammps_open_wrapper' but may not be C interoperable
|
mpif90 -c LAMMPS.f90
|
||||||
This is normal (see --IMPLEMENTATION NOTES--).
|
OR
|
||||||
(4) Compile (but don't link) LAMMPS-wrapper.cpp. You will need its header
|
gfortran -c LAMMPS.F90
|
||||||
file as well. You will have to provide the locations of LAMMPS's
|
NOTE: you may get a warning such as,
|
||||||
header files. For example,
|
subroutine lammps_open_wrapper (argc, argv, communicator, ptr) &
|
||||||
mpicxx -c -I${LAMMPS_SRC} LAMMPS-wrapper.cpp
|
Variable 'communicator' at (1) is a parameter to the BIND(C)
|
||||||
OR
|
procedure 'lammps_open_wrapper' but may not be C interoperable
|
||||||
g++ -c -I${LAMMPS_SRC} -I${LAMMPS_SRC}/STUBS LAMMPS-wrapper.cpp
|
This is normal (see --IMPLEMENTATION NOTES--).
|
||||||
OR
|
|
||||||
icpc -c -I${LAMMPS_SRC} -I${LAMMPS_SRC}/STUBS LAMMPS-wrapper.cpp
|
(4) Compile (but don't link) LAMMPS-wrapper.cpp. You will need its header
|
||||||
Copy the resulting object file LAMMPS-wrapper.o to your Fortran program's
|
file as well. You will have to provide the locations of LAMMPS's
|
||||||
source directory.
|
header files. For example,
|
||||||
(4b) OPTIONAL: Make a library so you can carry around two files instead of
|
mpicxx -c -I${LAMMPS_SRC} LAMMPS-wrapper.cpp
|
||||||
three. Example:
|
OR
|
||||||
ar rs liblammps_fortran.a LAMMPS.o LAMMPS-wrapper.o
|
g++ -c -I${LAMMPS_SRC} -I${LAMMPS_SRC}/STUBS LAMMPS-wrapper.cpp
|
||||||
This will create the file liblammps_fortran.a that you can use in place
|
OR
|
||||||
of "LAMMPS.o LAMMPS-wrapper.o" in part (6). Note that you will still
|
icpc -c -I${LAMMPS_SRC} -I${LAMMPS_SRC}/STUBS LAMMPS-wrapper.cpp
|
||||||
need to have the .mod file from part (3).
|
(5) OPTIONAL: Make a library from the object files so you can carry around
|
||||||
|
two files instead of three. Example:
|
||||||
It is also possible to add LAMMPS.o and LAMMPS-wrapper.o into the
|
ar rs liblammps_fortran.a LAMMPS.o LAMMPS-wrapper.o
|
||||||
LAMMPS library (e.g., liblmp_openmpi.a) instead of creating a separate
|
This will create the file liblammps_fortran.a that you can use in place
|
||||||
library, like so:
|
of "LAMMPS.o LAMMPS-wrapper.o" later. Note that you will still
|
||||||
ar rs ${LAMMPS_LIB} LAMMPS.o LAMMPS-wrapper.o
|
need to have the .mod file from part (3).
|
||||||
In this case, you can now use the Fortran wrapper functions as if they
|
|
||||||
were part of the usual LAMMPS library interface (if you have the module
|
It is also possible to add LAMMPS.o and LAMMPS-wrapper.o into the
|
||||||
file visible to the compiler, that is).
|
LAMMPS library (e.g., liblmp_openmpi.a) instead of creating a separate
|
||||||
(5) Compile your Fortran program. Example:
|
library, like so:
|
||||||
mpif90 -c myfreeformatfile.f90
|
ar rs ${LAMMPS_LIB} LAMMPS.o LAMMPS-wrapper.o
|
||||||
mpif90 -c myfixedformatfile.f
|
In this case, you can now use the Fortran wrapper functions as if they
|
||||||
OR
|
were part of the usual LAMMPS library interface (if you have the module
|
||||||
gfortran -c myfreeformatfile.f90
|
file visible to the compiler, that is).
|
||||||
gfortran -c myfixedformatfile.f
|
(6) Compile (but don't link) your Fortran program. Example:
|
||||||
The object files generated by these steps are collectively referred to
|
mpif90 -c myfreeformatfile.f90
|
||||||
as ${my_object_files} in the next step(s).
|
mpif90 -c myfixedformatfile.f
|
||||||
|
OR
|
||||||
IMPORTANT: If the Fortran module from part (3) is not in the current
|
gfortran -c myfreeformatfile.f90
|
||||||
directory or in one searched by the compiler for module files, you will
|
gfortran -c myfixedformatfile.f
|
||||||
need to include that location via the -I flag to the compiler.
|
The object files generated by these steps are collectively referred to
|
||||||
(6) Link everything together, including any libraries needed by LAMMPS (such
|
as ${my_object_files} in the next step(s).
|
||||||
as the C++ standard library, the C math library, the JPEG library, fftw,
|
|
||||||
etc.) For example,
|
IMPORTANT: If the Fortran module from part (3) is not in the current
|
||||||
mpif90 LAMMPS.o LAMMPS-wrapper.o ${my_object_files} \
|
directory or in one searched by the compiler for module files, you will
|
||||||
${LAMMPS_LIB} -lstdc++ -lm
|
need to include that location via the -I flag to the compiler, like so:
|
||||||
OR
|
mpif90 -I${LAMMPS_SRC}/examples/COUPLE/fortran2 -c myfreeformatfile.f90
|
||||||
gfortran LAMMPS.o LAMMPS-wrapper.o ${my_object_files} \
|
|
||||||
${LAMMPS_LIB} ${MPI_STUBS} -lstdc++ -lm
|
(7) Link everything together, including any libraries needed by LAMMPS (such
|
||||||
OR
|
as the C++ standard library, the C math library, the JPEG library, fftw,
|
||||||
ifort LAMMPS.o LAMMPS-wrapper.o ${my_object_files} \
|
etc.) For example,
|
||||||
${LAMMPS_LIB} ${MPI_STUBS} -cxxlib -limf -lm
|
mpif90 LAMMPS.o LAMMPS-wrapper.o ${my_object_files} \
|
||||||
Any other required libraries (e.g. -ljpeg, -lfftw) should be added to
|
${LAMMPS_LIB} -lmpi_cxx -lstdc++ -lm
|
||||||
the end of this line.
|
OR
|
||||||
|
gfortran LAMMPS.o LAMMPS-wrapper.o ${my_object_files} \
|
||||||
You should now have a working executable.
|
${LAMMPS_LIB} ${MPI_STUBS} -lstdc++ -lm
|
||||||
|
OR
|
||||||
Steps 3 and 4 above are accomplished, possibly after some modifications to
|
ifort LAMMPS.o LAMMPS-wrapper.o ${my_object_files} \
|
||||||
the makefile, by make using the attached makefile.
|
${LAMMPS_LIB} ${MPI_STUBS} -cxxlib -lm
|
||||||
|
Any other required libraries (e.g. -ljpeg, -lfftw) should be added to
|
||||||
-------------------------------------
|
the end of this line.
|
||||||
|
|
||||||
--USAGE--
|
You should now have a working executable.
|
||||||
|
|
||||||
To use this API, your program unit (PROGRAM/SUBROUTINE/FUNCTION/MODULE/etc.)
|
** DYNAMIC LIBRARY INSTRUCTIONS **
|
||||||
should look something like this:
|
(1) Compile LAMMPS as a dynamic library
|
||||||
program call_lammps
|
(make makeshlib && make -f Makefile.shlib [targetname]).
|
||||||
use LAMMPS
|
(2) Compile, but don't link, LAMMPS.F90 using the -fPIC flag, such as
|
||||||
! Other modules, etc.
|
mpif90 -fPIC -c LAMMPS.f90
|
||||||
implicit none
|
(3) Compile, but don't link, LAMMPS-wrapper.cpp in the same manner, e.g.
|
||||||
type (lammps_instance) :: lmp ! This is a pointer to your LAMMPS instance
|
mpicxx -fPIC -c LAMMPS-wrapper.cpp
|
||||||
double precision :: fix
|
(4) Make the dynamic library, like so:
|
||||||
double precision, dimension(:), allocatable :: fix2
|
mpif90 -fPIC -shared -o liblammps_fortran.so LAMMPS.o LAMMPS-wrapper.o
|
||||||
! Rest of declarations
|
(5) Compile your program, such as,
|
||||||
call lammps_open_no_mpi ('lmp -in /dev/null -screen out.lammps',lmp)
|
mpif90 -I${LAMMPS_SRC}/examples/COUPLE/fortran2 -c myfreeformatfile.f90
|
||||||
! Set up rest of program here
|
where ${LAMMPS_SRC}/examples/COUPLE/fortran2 contains the .mod file from
|
||||||
call lammps_file (lmp, 'in.example')
|
step (3)
|
||||||
call lammps_extract_fix (fix, lmp, '2', 0, 1, 1, 1)
|
(6) Link everything together, such as
|
||||||
call lammps_extract_fix (fix2, lmp, '4', 0, 2, 1, 1)
|
mpif90 ${my_object_files} -L${LAMMPS_SRC} \
|
||||||
call lammps_close (lmp)
|
-L${LAMMPS_SRC}/examples/COUPLE/fortran2 -llammps_fortran \
|
||||||
end program call_lammps
|
-llammps_openmpi -lmpi_cxx -lstdc++ -lm
|
||||||
|
|
||||||
Important notes:
|
If you wish to avoid the -L flags, add the directories containing your
|
||||||
* All arguments which are char* variables in library.cpp are character (len=*)
|
shared libraries to the LIBRARY_PATH environment variable. At run time, you
|
||||||
variables here. For example,
|
will have to add these directories to LD_LIBRARY_PATH as well; otherwise,
|
||||||
call lammps_command (lmp, 'units metal')
|
your executable will not find the libraries it needs.
|
||||||
will work as expected.
|
|
||||||
* The public functions (the only ones you can use) have interfaces as
|
-------------------------------------
|
||||||
described in the comments at the top of LAMMPS.F90. They are not always
|
|
||||||
the same as those in library.h, since C strings are replaced by Fortran
|
--USAGE--
|
||||||
strings and the like.
|
|
||||||
* The module attempts to check whether you have done something stupid (such
|
To use this API, your program unit (PROGRAM/SUBROUTINE/FUNCTION/MODULE/etc.)
|
||||||
as assign a 2D array to a scalar), but it's not perfect. For example, the
|
should look something like this:
|
||||||
command
|
program call_lammps
|
||||||
call lammps_extract_global (nlocal, ptr, 'nlocal')
|
use LAMMPS
|
||||||
will give nlocal correctly if nlocal is of type INTEGER, but it will give
|
! Other modules, etc.
|
||||||
the wrong answer if nlocal is of type REAL or DOUBLE PRECISION. This is a
|
implicit none
|
||||||
feature of the (void*) type cast in library.cpp. There is no way I can
|
type (lammps_instance) :: lmp ! This is a pointer to your LAMMPS instance
|
||||||
check this for you!
|
real (C_double) :: fix
|
||||||
* You are allowed to use REAL or DOUBLE PRECISION floating-point numbers.
|
real (C_double), dimension(:), pointer :: fix2
|
||||||
All LAMMPS data (which are of type REAL(C_double)) are rounded off if
|
! Rest of declarations
|
||||||
placed in single precision variables. It is tacitly assumed that NO C++
|
call lammps_open_no_mpi ('lmp -in /dev/null -screen out.lammps',lmp)
|
||||||
variables are of type float; everything is int or double (since this is
|
! Set up rest of program here
|
||||||
all library.cpp currently handles).
|
call lammps_file (lmp, 'in.example')
|
||||||
* An example of a complete program is offered at the end of this file.
|
call lammps_extract_fix (fix, lmp, '2', 0, 1, 1, 1)
|
||||||
|
call lammps_extract_fix (fix2, lmp, '4', 0, 2, 1, 1)
|
||||||
-------------------------------------
|
call lammps_close (lmp)
|
||||||
|
end program call_lammps
|
||||||
--TROUBLESHOOTING--
|
|
||||||
|
Important notes:
|
||||||
Compile-time errors probably indicate that your compiler is not new enough to
|
* Though I dislike the use of pointers, they are necessary when communicating
|
||||||
support Fortran 2003 features. For example, GCC 4.1.2 will not compile this
|
with C and C++, which do not support Fortran's ALLOCATABLE attribute.
|
||||||
module, but GCC 4.4.0 will.
|
* There is no need to deallocate C-allocated memory; this is done for you in
|
||||||
|
the cases when it is done (which are all cases when pointers are not
|
||||||
If your compiler balks at 'use, intrinsic :: ISO_C_binding,' try removing the
|
accepted, such as global fix data)
|
||||||
intrinsic part so it looks like an ordinary module. However, it is likely
|
* All arguments which are char* variables in library.cpp are character (len=*)
|
||||||
that such a compiler will also have problems with everything else in the
|
variables here. For example,
|
||||||
file as well.
|
call lammps_command (lmp, 'units metal')
|
||||||
|
will work as expected.
|
||||||
If you get a segfault as soon as the lammps_open call is made, check that you
|
* The public functions (the only ones you can use) have interfaces as
|
||||||
compiled your program AND LAMMPS-header.cpp using the same MPI headers. Using
|
described in the comments at the top of LAMMPS.F90. They are not always
|
||||||
the stubs for one and the actual MPI library for the other will cause major
|
the same as those in library.h, since C strings are replaced by Fortran
|
||||||
problems.
|
strings and the like.
|
||||||
|
* The module attempts to check whether you have done something stupid (such
|
||||||
If you find run-time errors, please pass them along via the LAMMPS Users
|
as assign a 2D array to a scalar), but it's not perfect. For example, the
|
||||||
mailing list. Please provide a minimal working example along with the names
|
command
|
||||||
and versions of the compilers you are using. Please make sure the error is
|
call lammps_extract_global (nlocal, ptr, 'nlocal')
|
||||||
repeatable and is in MY code, not yours (generating a minimal working example
|
will give nlocal correctly if nlocal is a pointer to type INTEGER, but it
|
||||||
will usually ensure this anyway).
|
will give the wrong answer if nlocal is a pointer to type REAL. This is a
|
||||||
|
feature of the (void*) type cast in library.cpp. There is no way I can
|
||||||
-------------------------------------
|
check this for you! It WILL catch you if you pass it an allocatable or
|
||||||
|
fixed-size array when it expects a pointer.
|
||||||
--IMPLEMENTATION NOTES--
|
* Arrays constructed from temporary data from LAMMPS are ALLOCATABLE, and
|
||||||
|
represent COPIES of data, not the originals. Functions like
|
||||||
The Fortran procedures have the same names as the C procedures, and
|
lammps_extract_atom, which return actual LAMMPS data, are pointers.
|
||||||
their purpose is the same, but they may take different arguments. Here are
|
* IMPORTANT: Due to the differences between C and Fortran arrays (C uses
|
||||||
some of the important differences:
|
row-major vectors, Fortran uses column-major vectors), all arrays returned
|
||||||
* lammps_open and lammps_open_no_mpi take a string instead of argc and
|
from LAMMPS have their indices swapped.
|
||||||
argv. This is necessary because C and C++ have a very different way
|
* An example of a complete program, simple.f90, is included with this
|
||||||
of treating strings than Fortran.
|
package.
|
||||||
* All C++ functions that accept char* pointers now accept Fortran-style
|
|
||||||
strings within this interface instead.
|
-------------------------------------
|
||||||
* All of the lammps_extract_[something] functions, which return void*
|
|
||||||
C-style pointers, have been replaced by generic subroutines that return
|
--TROUBLESHOOTING--
|
||||||
Fortran variables (which may be arrays). The first argument houses the
|
|
||||||
variable to be returned; all other arguments are identical except as
|
Compile-time errors (when compiling LAMMPS.F90, that is) probably indicate
|
||||||
stipulated above. Note that it is not possible to declare generic
|
that your compiler is not new enough to support Fortran 2003 features. For
|
||||||
functions that are selected based solely on the type/kind/rank (TKR)
|
example, GCC 4.1.2 will not compile this module, but GCC 4.4.0 will.
|
||||||
signature of the return value, only based on the TKR of the arguments.
|
|
||||||
* The SHAPE of the first argument to lammps_extract_[something] is checked
|
If your compiler balks at 'use, intrinsic :: ISO_C_binding,' try removing the
|
||||||
against the "shape" of the C array (e.g., double vs. double* vs. double**).
|
intrinsic part so it looks like an ordinary module. However, it is likely
|
||||||
Calling a subroutine with arguments of inappropriate rank will result in an
|
that such a compiler will also have problems with everything else in the
|
||||||
error at run time.
|
file as well.
|
||||||
* All arrays passed to subroutines must be ALLOCATABLE and are REALLOCATED
|
|
||||||
to fit the shape of the array LAMMPS will be returning.
|
If you get a segfault as soon as the lammps_open call is made, check that you
|
||||||
* The indices i and j in lammps_extract_fix are used the same way they
|
compiled your program AND LAMMPS-wrapper.cpp using the same MPI headers. Using
|
||||||
are in f_ID[i][j] references in LAMMPS (i.e., starting from 1). This is
|
the stubs for one and the actual MPI library for the other will cause Bad
|
||||||
different than the way library.cpp uses these numbers, but is more
|
Things to happen.
|
||||||
consistent with the way arrays are accessed in LAMMPS and in Fortran.
|
|
||||||
* The char* pointer normally returned by lammps_command is thrown away
|
If you find run-time errors, please pass them along via the LAMMPS Users
|
||||||
in this version; note also that lammps_command is now a subroutine
|
mailing list (please CC me as well; address above). Please provide a minimal
|
||||||
instead of a function.
|
working example along with the names and versions of the compilers you are
|
||||||
* The pointer to LAMMPS itself is of type(lammps_instance), which is itself
|
using. Please make sure the error is repeatable and is in MY code, not yours
|
||||||
a synonym for type(C_ptr), part of ISO_C_BINDING. Type (C_ptr) is
|
(generating a minimal working example will usually ensure this anyway).
|
||||||
C's void* data type. This should be the only C data type that needs to
|
|
||||||
be used by the end user.
|
-------------------------------------
|
||||||
* This module will almost certainly generate a compile-time warning,
|
|
||||||
such as,
|
--IMPLEMENTATION NOTES--
|
||||||
subroutine lammps_open_wrapper (argc, argv, communicator, ptr) &
|
|
||||||
Variable 'communicator' at (1) is a parameter to the BIND(C)
|
The Fortran procedures have the same names as the C procedures, and
|
||||||
procedure 'lammps_open_wrapper' but may not be C interoperable
|
their purpose is the same, but they may take different arguments. Here are
|
||||||
This happens because lammps_open_wrapper actually takes a Fortran
|
some of the important differences:
|
||||||
INTEGER argument, whose type is defined by the MPI library itself. The
|
* lammps_open and lammps_open_no_mpi take a string instead of argc and
|
||||||
Fortran integer is converted to a C integer by the MPI library (if such
|
argv. This is necessary because C and C++ have a very different way
|
||||||
conversion is actually necessary).
|
of treating strings than Fortran. If you want the command line to be
|
||||||
* Unlike library.cpp, this module returns COPIES of the data LAMMPS actually
|
passed to lammps_open (as it often would be from C/C++), use the
|
||||||
uses. This is done for safety reasons, as you should, in general, not be
|
GET_COMMAND intrinsic to obtain it.
|
||||||
overwriting LAMMPS data directly from Fortran. If you require this
|
* All C++ functions that accept char* pointers now accept Fortran-style
|
||||||
functionality, it is possible to write another function that, for example,
|
strings within this interface instead.
|
||||||
returns a Fortran pointer that resolves to the C/C++ data instead of
|
* All of the lammps_extract_[something] functions, which return void*
|
||||||
copying the contents of that pointer to the original array as is done now.
|
C-style pointers, have been replaced by generic subroutines that return
|
||||||
|
Fortran variables (which may be arrays). The first argument houses the
|
||||||
|
variable/pointer to be returned (pretend it's on the left-hand side); all
|
||||||
|
other arguments are identical except as stipulated above.
|
||||||
|
Note that it is not possible to declare generic functions that are selected
|
||||||
|
based solely on the type/kind/rank (TKR) signature of the return value,
|
||||||
|
only based on the TKR of the arguments.
|
||||||
|
* The SHAPE of the first argument to lammps_extract_[something] is checked
|
||||||
|
against the "shape" of the C array (e.g., double vs. double* vs. double**).
|
||||||
|
Calling a subroutine with arguments of inappropriate rank will result in an
|
||||||
|
error at run time.
|
||||||
|
* The indices i and j in lammps_extract_fix are used the same way they
|
||||||
|
are in f_ID[i][j] references in LAMMPS (i.e., starting from 1). This is
|
||||||
|
different than the way library.cpp uses these numbers, but is more
|
||||||
|
consistent with the way arrays are accessed in LAMMPS and in Fortran.
|
||||||
|
* The char* pointer normally returned by lammps_command is thrown away
|
||||||
|
in this version; note also that lammps_command is now a subroutine
|
||||||
|
instead of a function.
|
||||||
|
* The pointer to LAMMPS itself is of type(lammps_instance), which is itself
|
||||||
|
a synonym for type(C_ptr), part of ISO_C_BINDING. Type (C_ptr) is
|
||||||
|
C's void* data type.
|
||||||
|
* This module will almost certainly generate a compile-time warning,
|
||||||
|
such as,
|
||||||
|
subroutine lammps_open_wrapper (argc, argv, communicator, ptr) &
|
||||||
|
Variable 'communicator' at (1) is a parameter to the BIND(C)
|
||||||
|
procedure 'lammps_open_wrapper' but may not be C interoperable
|
||||||
|
This happens because lammps_open_wrapper actually takes a Fortran
|
||||||
|
INTEGER argument, whose type is defined by the MPI library itself. The
|
||||||
|
Fortran integer is converted to a C integer by the MPI library (if such
|
||||||
|
conversion is actually necessary).
|
||||||
|
* lammps_extract_global returns COPIES of the (scalar) data, as does the
|
||||||
|
C version.
|
||||||
|
* lammps_extract_atom, lammps_extract_compute, and lammps_extract_fix
|
||||||
|
have a first argument that will be associated with ACTUAL LAMMPS DATA.
|
||||||
|
This means the first argument must be:
|
||||||
|
* The right rank (via the DIMENSION modifier)
|
||||||
|
* A C-interoperable POINTER type (i.e., INTEGER (C_int) or
|
||||||
|
REAL (C_double)).
|
||||||
|
* lammps_extract_variable returns COPIES of the data, as the C library
|
||||||
|
interface does. There is no need to deallocate using lammps_free.
|
||||||
|
* The 'data' argument to lammps_gather_atoms and lammps_scatter atoms must
|
||||||
|
be ALLOCATABLE. It should be of type INTEGER or DOUBLE PRECISION. It
|
||||||
|
does NOT need to be C inter-operable (and indeed should not be).
|
||||||
|
* The 'count' argument of lammps_scatter_atoms is unnecessary; the shape of
|
||||||
|
the array determines the number of elements LAMMPS will read.
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
units metal
|
units lj
|
||||||
lattice bcc 3.1656
|
atom_modify map array
|
||||||
|
lattice bcc 1.0
|
||||||
region simbox block 0 10 0 10 0 10
|
region simbox block 0 10 0 10 0 10
|
||||||
create_box 2 simbox
|
create_box 2 simbox
|
||||||
create_atoms 1 region simbox
|
create_atoms 1 region simbox
|
||||||
pair_style eam/fs
|
pair_style lj/cut 2.5
|
||||||
pair_coeff * * path/to/my_potential.eam.fs A1 A2
|
pair_coeff * * 1.0 1.0
|
||||||
mass 1 58.2 # These are made-up numbers
|
mass 1 58.2 # These are made-up numbers
|
||||||
mass 2 28.3
|
mass 2 28.3
|
||||||
velocity all create 1200.0 7474848 dist gaussian
|
velocity all create 1200.0 7474848 dist gaussian
|
||||||
|
|||||||
@ -1,44 +1,111 @@
|
|||||||
program simple
|
program simple
|
||||||
|
|
||||||
|
use MPI
|
||||||
use LAMMPS
|
use LAMMPS
|
||||||
|
|
||||||
|
! The following line is unnecessary, as I have included these three entities
|
||||||
|
! with the LAMMPS module, but I leave them in anyway to remind people where
|
||||||
|
! they came from
|
||||||
|
use, intrinsic :: ISO_C_binding, only : C_double, C_ptr, C_int
|
||||||
|
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
type (lammps_instance) :: lmp
|
! Notes:
|
||||||
double precision :: compute, fix, fix2
|
! * If LAMMPS returns a scalar that is allocated by the library interface
|
||||||
double precision, dimension(:), allocatable :: compute_v, mass, r
|
! (see library.cpp), then that memory is deallocated automatically and
|
||||||
double precision, dimension(:,:), allocatable :: x
|
! the argument to lammps_extract_fix must be a SCALAR.
|
||||||
real, dimension(:,:), allocatable :: x_r
|
! * If LAMMPS returns a pointer to an array, consisting of internal LAMMPS
|
||||||
|
! data, then the argument must be an interoperable Fortran pointer.
|
||||||
|
! Interoperable means it is of type INTEGER (C_INT) or of type
|
||||||
|
! REAL (C_DOUBLE) in this context.
|
||||||
|
! * Pointers should NEVER be deallocated, as that would deallocate internal
|
||||||
|
! LAMMPS data!
|
||||||
|
! * Note that just because you can read the values of, say, a compute at
|
||||||
|
! any time does not mean those values represent the "correct" values.
|
||||||
|
! LAMMPS will abort you if you try to grab a pointer to a non-current
|
||||||
|
! entity, but once it's bound, it's your responsibility to check that
|
||||||
|
! it's current before evaluating.
|
||||||
|
! * IMPORTANT: Two-dimensional arrays (such as 'x' from extract_atom)
|
||||||
|
! will be transposed from what they might look like in C++. This is
|
||||||
|
! because of different bookkeeping conventions between Fortran and C
|
||||||
|
! that date back to about 1970 or so (when C was written).
|
||||||
|
! * Arrays start from 1, EXCEPT for mass from extract_atom, which
|
||||||
|
! starts from 0. This is because the C array actually has a blank
|
||||||
|
! first element (and thus mass[1] corresponds to the mass of type 1)
|
||||||
|
|
||||||
|
type (C_ptr) :: lmp
|
||||||
|
real (C_double), pointer :: compute => NULL()
|
||||||
|
real (C_double) :: fix, fix2
|
||||||
|
real (C_double), dimension(:), pointer :: compute_v => NULL()
|
||||||
|
real (C_double), dimension(:,:), pointer :: x => NULL()
|
||||||
|
real (C_double), dimension(:), pointer :: mass => NULL()
|
||||||
|
integer, dimension(:), allocatable :: types
|
||||||
|
double precision, dimension(:), allocatable :: r
|
||||||
|
integer :: error, narg, me, nprocs
|
||||||
|
character (len=1024) :: command_line
|
||||||
|
|
||||||
|
call MPI_Init (error)
|
||||||
|
call MPI_Comm_rank (MPI_COMM_WORLD, me, error)
|
||||||
|
call MPI_Comm_size (MPI_COMM_WORLD, nprocs, error)
|
||||||
|
|
||||||
|
! You are free to pass any string you like to lammps_open or
|
||||||
|
! lammps_open_no_mpi; here is how you pass it the command line
|
||||||
|
!call get_command (command_line)
|
||||||
|
!call lammps_open (command_line, MPI_COMM_WORLD, lmp)
|
||||||
|
|
||||||
|
! And here's how to to it with a string constant of your choice
|
||||||
|
call lammps_open_no_mpi ('lmp -log log.simple', lmp)
|
||||||
|
|
||||||
call lammps_open_no_mpi ('',lmp)
|
|
||||||
call lammps_file (lmp, 'in.simple')
|
call lammps_file (lmp, 'in.simple')
|
||||||
call lammps_command (lmp, 'run 500')
|
call lammps_command (lmp, 'run 500')
|
||||||
|
|
||||||
|
! This extracts f_2 as a scalar (the last two arguments can be arbitrary)
|
||||||
call lammps_extract_fix (fix, lmp, '2', 0, 1, 1, 1)
|
call lammps_extract_fix (fix, lmp, '2', 0, 1, 1, 1)
|
||||||
print *, 'Fix is ', fix
|
print *, 'Fix is ', fix
|
||||||
|
|
||||||
|
! This extracts f_4[1][1] as a scalar
|
||||||
call lammps_extract_fix (fix2, lmp, '4', 0, 2, 1, 1)
|
call lammps_extract_fix (fix2, lmp, '4', 0, 2, 1, 1)
|
||||||
print *, 'Fix 2 is ', fix2
|
print *, 'Fix 2 is ', fix2
|
||||||
|
|
||||||
|
! This extracts the scalar compute of compute thermo_temp
|
||||||
call lammps_extract_compute (compute, lmp, 'thermo_temp', 0, 0)
|
call lammps_extract_compute (compute, lmp, 'thermo_temp', 0, 0)
|
||||||
print *, 'Compute is ', compute
|
print *, 'Compute is ', compute
|
||||||
|
|
||||||
|
! This extracts the vector compute of compute thermo_temp
|
||||||
call lammps_extract_compute (compute_v, lmp, 'thermo_temp', 0, 1)
|
call lammps_extract_compute (compute_v, lmp, 'thermo_temp', 0, 1)
|
||||||
print *, 'Vector is ', compute_v
|
print *, 'Vector is ', compute_v
|
||||||
|
|
||||||
|
! This extracts the masses
|
||||||
call lammps_extract_atom (mass, lmp, 'mass')
|
call lammps_extract_atom (mass, lmp, 'mass')
|
||||||
print *, 'Mass is ', mass
|
print *, 'Mass is ', mass(1:)
|
||||||
|
|
||||||
|
! Extracts a pointer to the arrays of positions for all atoms
|
||||||
call lammps_extract_atom (x, lmp, 'x')
|
call lammps_extract_atom (x, lmp, 'x')
|
||||||
if ( .not. allocated (x) ) print *, 'x is not allocated'
|
if ( .not. associated (x) ) print *, 'x is not associated'
|
||||||
print *, 'x is ', x(1,:)
|
print *, 'x is ', x(:,1) ! Prints x, y, z for atom 1
|
||||||
|
|
||||||
call lammps_extract_atom (x_r, lmp, 'x')
|
! Extracts pointer to atom types
|
||||||
if ( .not. allocated (x_r) ) print *, 'x is not allocated'
|
call lammps_gather_atoms (lmp, 'type', 1, types)
|
||||||
print *, 'x_r is ', x_r(1,:)
|
print *, 'types is ', types(1:3)
|
||||||
|
|
||||||
call lammps_get_coords (lmp, r)
|
! Allocates an array and assigns all positions to it
|
||||||
print *, 'r is ', r(1:3)
|
call lammps_gather_atoms (lmp, 'x', 3, r)
|
||||||
|
print *, 'size(r) = ', size(r)
|
||||||
|
print *, 'r is ', r(1:6)
|
||||||
|
|
||||||
|
! Puts those position data back
|
||||||
|
call lammps_scatter_atoms (lmp, 'x', r)
|
||||||
|
|
||||||
|
call lammps_command (lmp, 'run 1')
|
||||||
|
print *, 'x is ', x(:,1) ! Note that the position updates!
|
||||||
|
print *, 'Compute is ', compute ! This did only because "temp" is part of
|
||||||
|
! the thermo output; the vector part did
|
||||||
|
! not, and won't until we give LAMMPS a
|
||||||
|
! thermo output or other command that
|
||||||
|
! requires its value
|
||||||
|
|
||||||
call lammps_close (lmp)
|
call lammps_close (lmp)
|
||||||
|
|
||||||
|
call MPI_Finalize (error)
|
||||||
|
|
||||||
end program simple
|
end program simple
|
||||||
|
|||||||
@ -9,7 +9,7 @@ doc/Section_python.html and in doc/Section_start.html#start_5.
|
|||||||
Basically you need to follow these steps in the src directory:
|
Basically you need to follow these steps in the src directory:
|
||||||
|
|
||||||
% make makeshlib # creates Makefile.shlib
|
% make makeshlib # creates Makefile.shlib
|
||||||
% make -f Makefile.shlib g++ # or whatever machine target you wish
|
% make -f Makefile.shlib g++ # build for whatever machine target you wish
|
||||||
% make install-python # may need to do this via sudo
|
% make install-python # may need to do this via sudo
|
||||||
|
|
||||||
You can replace the last step with running the python/install.py
|
You can replace the last step with running the python/install.py
|
||||||
|
|||||||
@ -22,11 +22,6 @@ me = 0
|
|||||||
#nprocs = pypar.size()
|
#nprocs = pypar.size()
|
||||||
|
|
||||||
from lammps import lammps
|
from lammps import lammps
|
||||||
from lammps import LMPINT as INT
|
|
||||||
from lammps import LMPDOUBLE as DOUBLE
|
|
||||||
from lammps import LMPIPTR as IPTR
|
|
||||||
from lammps import LMPDPTR as DPTR
|
|
||||||
from lammps import LMPDPTRPTR as DPTRPTR
|
|
||||||
|
|
||||||
lmp = lammps()
|
lmp = lammps()
|
||||||
|
|
||||||
@ -36,9 +31,9 @@ lmp.file("in.demo")
|
|||||||
|
|
||||||
if me == 0: print "\nPython output:"
|
if me == 0: print "\nPython output:"
|
||||||
|
|
||||||
natoms = lmp.extract_global("natoms",DOUBLE)
|
natoms = lmp.extract_global("natoms",0)
|
||||||
mass = lmp.extract_atom("mass",DPTR)
|
mass = lmp.extract_atom("mass",2)
|
||||||
x = lmp.extract_atom("x",DPTRPTR)
|
x = lmp.extract_atom("x",3)
|
||||||
print "Natoms, mass, x[0][0] coord =",natoms,mass[1],x[0][0]
|
print "Natoms, mass, x[0][0] coord =",natoms,mass[1],x[0][0]
|
||||||
|
|
||||||
temp = lmp.extract_compute("thermo_temp",0,0)
|
temp = lmp.extract_compute("thermo_temp",0,0)
|
||||||
@ -53,13 +48,13 @@ print "Velocity component from atom-style variable =",vy[1]
|
|||||||
natoms = lmp.get_natoms()
|
natoms = lmp.get_natoms()
|
||||||
print "Natoms from get_natoms =",natoms
|
print "Natoms from get_natoms =",natoms
|
||||||
|
|
||||||
xc = lmp.get_coords()
|
xc = lmp.gather_atoms("x",1,3)
|
||||||
print "Global coords from get_coords =",xc[0],xc[1],xc[31]
|
print "Global coords from gather_atoms =",xc[0],xc[1],xc[31]
|
||||||
|
|
||||||
xc[0] = xc[0] + 1.0
|
xc[0] = xc[0] + 1.0
|
||||||
lmp.put_coords(xc)
|
lmp.scatter_atoms("x",1,3,xc)
|
||||||
|
|
||||||
print "Changed x[0][0] via put_coords =",x[0][0]
|
print "Changed x[0][0] via scatter_atoms =",x[0][0]
|
||||||
|
|
||||||
# uncomment if running in parallel via Pypar
|
# uncomment if running in parallel via Pypar
|
||||||
#print "Proc %d out of %d procs has" % (me,nprocs), lmp
|
#print "Proc %d out of %d procs has" % (me,nprocs), lmp
|
||||||
|
|||||||
@ -24,8 +24,8 @@ class lammps:
|
|||||||
# if name = "g++", load liblammps_g++.so
|
# if name = "g++", load liblammps_g++.so
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not name: self.lib = CDLL("liblammps.so")
|
if not name: self.lib = CDLL("liblammps.so",RTLD_GLOBAL)
|
||||||
else: self.lib = CDLL("liblammps_%s.so" % name)
|
else: self.lib = CDLL("liblammps_%s.so" % name,RTLD_GLOBAL)
|
||||||
except:
|
except:
|
||||||
type,value,tb = sys.exc_info()
|
type,value,tb = sys.exc_info()
|
||||||
traceback.print_exception(type,value,tb)
|
traceback.print_exception(type,value,tb)
|
||||||
@ -89,11 +89,11 @@ class lammps:
|
|||||||
self.lib.lammps_extract_compute.restype = POINTER(c_double)
|
self.lib.lammps_extract_compute.restype = POINTER(c_double)
|
||||||
ptr = self.lib.lammps_extract_compute(self.lmp,id,style,type)
|
ptr = self.lib.lammps_extract_compute(self.lmp,id,style,type)
|
||||||
return ptr[0]
|
return ptr[0]
|
||||||
elif type == 1:
|
if type == 1:
|
||||||
self.lib.lammps_extract_compute.restype = POINTER(c_double)
|
self.lib.lammps_extract_compute.restype = POINTER(c_double)
|
||||||
ptr = self.lib.lammps_extract_compute(self.lmp,id,style,type)
|
ptr = self.lib.lammps_extract_compute(self.lmp,id,style,type)
|
||||||
return ptr
|
return ptr
|
||||||
elif type == 2:
|
if type == 2:
|
||||||
self.lib.lammps_extract_compute.restype = POINTER(POINTER(c_double))
|
self.lib.lammps_extract_compute.restype = POINTER(POINTER(c_double))
|
||||||
ptr = self.lib.lammps_extract_compute(self.lmp,id,style,type)
|
ptr = self.lib.lammps_extract_compute(self.lmp,id,style,type)
|
||||||
return ptr
|
return ptr
|
||||||
@ -110,11 +110,11 @@ class lammps:
|
|||||||
result = ptr[0]
|
result = ptr[0]
|
||||||
self.lib.lammps_free(ptr)
|
self.lib.lammps_free(ptr)
|
||||||
return result
|
return result
|
||||||
elif type == 1:
|
if type == 1:
|
||||||
self.lib.lammps_extract_fix.restype = POINTER(c_double)
|
self.lib.lammps_extract_fix.restype = POINTER(c_double)
|
||||||
ptr = self.lib.lammps_extract_fix(self.lmp,id,style,type,i,j)
|
ptr = self.lib.lammps_extract_fix(self.lmp,id,style,type,i,j)
|
||||||
return ptr
|
return ptr
|
||||||
elif type == 2:
|
if type == 2:
|
||||||
self.lib.lammps_extract_fix.restype = POINTER(POINTER(c_double))
|
self.lib.lammps_extract_fix.restype = POINTER(POINTER(c_double))
|
||||||
ptr = self.lib.lammps_extract_fix(self.lmp,id,style,type,i,j)
|
ptr = self.lib.lammps_extract_fix(self.lmp,id,style,type,i,j)
|
||||||
return ptr
|
return ptr
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -1,4 +1,4 @@
|
|||||||
/* -------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
http://lammps.sandia.gov, Sandia National Laboratories
|
http://lammps.sandia.gov, Sandia National Laboratories
|
||||||
Steve Plimpton, sjplimp@sandia.gov
|
Steve Plimpton, sjplimp@sandia.gov
|
||||||
@ -274,6 +274,13 @@ void VerletSplit::run(int n)
|
|||||||
|
|
||||||
rk_setup();
|
rk_setup();
|
||||||
|
|
||||||
|
// check if OpenMP support fix defined
|
||||||
|
|
||||||
|
Fix *fix_omp;
|
||||||
|
int ifix = modify->find_fix("package_omp");
|
||||||
|
if (ifix < 0) fix_omp = NULL;
|
||||||
|
else fix_omp = modify->fix[ifix];
|
||||||
|
|
||||||
// flags for timestepping iterations
|
// flags for timestepping iterations
|
||||||
|
|
||||||
int n_post_integrate = modify->n_post_integrate;
|
int n_post_integrate = modify->n_post_integrate;
|
||||||
@ -372,7 +379,8 @@ void VerletSplit::run(int n)
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
// run FixOMP as sole pre_force fix, if defined
|
// run FixOMP as sole pre_force fix, if defined
|
||||||
if (fix_omp != NULL) fix_omp->pre_force(vflag);
|
|
||||||
|
if (fix_omp) fix_omp->pre_force(vflag);
|
||||||
|
|
||||||
if (force->kspace) {
|
if (force->kspace) {
|
||||||
timer->stamp();
|
timer->stamp();
|
||||||
|
|||||||
@ -695,39 +695,20 @@ void FixRigid::setup(int vflag)
|
|||||||
tagint *image = atom->image;
|
tagint *image = atom->image;
|
||||||
double **x = atom->x;
|
double **x = atom->x;
|
||||||
|
|
||||||
double xprd = domain->xprd;
|
double dx,dy,dz;
|
||||||
double yprd = domain->yprd;
|
double unwrap[3];
|
||||||
double zprd = domain->zprd;
|
|
||||||
double xy = domain->xy;
|
|
||||||
double xz = domain->xz;
|
|
||||||
double yz = domain->yz;
|
|
||||||
|
|
||||||
for (ibody = 0; ibody < nbody; ibody++)
|
for (ibody = 0; ibody < nbody; ibody++)
|
||||||
for (i = 0; i < 6; i++) sum[ibody][i] = 0.0;
|
for (i = 0; i < 6; i++) sum[ibody][i] = 0.0;
|
||||||
int xbox,ybox,zbox;
|
|
||||||
double xunwrap,yunwrap,zunwrap,dx,dy,dz;
|
|
||||||
|
|
||||||
for (i = 0; i < nlocal; i++) {
|
for (i = 0; i < nlocal; i++) {
|
||||||
if (body[i] < 0) continue;
|
if (body[i] < 0) continue;
|
||||||
ibody = body[i];
|
ibody = body[i];
|
||||||
|
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
dx = unwrap[0] - xcm[ibody][0];
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
dy = unwrap[1] - xcm[ibody][1];
|
||||||
|
dz = unwrap[2] - xcm[ibody][2];
|
||||||
if (triclinic == 0) {
|
|
||||||
xunwrap = x[i][0] + xbox*xprd;
|
|
||||||
yunwrap = x[i][1] + ybox*yprd;
|
|
||||||
zunwrap = x[i][2] + zbox*zprd;
|
|
||||||
} else {
|
|
||||||
xunwrap = x[i][0] + xbox*xprd + ybox*xy + zbox*xz;
|
|
||||||
yunwrap = x[i][1] + ybox*yprd + zbox*yz;
|
|
||||||
zunwrap = x[i][2] + zbox*zprd;
|
|
||||||
}
|
|
||||||
|
|
||||||
dx = xunwrap - xcm[ibody][0];
|
|
||||||
dy = yunwrap - xcm[ibody][1];
|
|
||||||
dz = zunwrap - xcm[ibody][2];
|
|
||||||
|
|
||||||
if (rmass) massone = rmass[i];
|
if (rmass) massone = rmass[i];
|
||||||
else massone = mass[type[i]];
|
else massone = mass[type[i]];
|
||||||
@ -929,17 +910,9 @@ void FixRigid::final_integrate()
|
|||||||
double **f = atom->f;
|
double **f = atom->f;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
double xprd = domain->xprd;
|
double dx,dy,dz;
|
||||||
double yprd = domain->yprd;
|
double unwrap[3];
|
||||||
double zprd = domain->zprd;
|
|
||||||
if (triclinic) {
|
|
||||||
xy = domain->xy;
|
|
||||||
xz = domain->xz;
|
|
||||||
yz = domain->yz;
|
|
||||||
}
|
|
||||||
|
|
||||||
int xbox,ybox,zbox;
|
|
||||||
double xunwrap,yunwrap,zunwrap,dx,dy,dz;
|
|
||||||
for (ibody = 0; ibody < nbody; ibody++)
|
for (ibody = 0; ibody < nbody; ibody++)
|
||||||
for (i = 0; i < 6; i++) sum[ibody][i] = 0.0;
|
for (i = 0; i < 6; i++) sum[ibody][i] = 0.0;
|
||||||
|
|
||||||
@ -951,23 +924,10 @@ void FixRigid::final_integrate()
|
|||||||
sum[ibody][1] += f[i][1];
|
sum[ibody][1] += f[i][1];
|
||||||
sum[ibody][2] += f[i][2];
|
sum[ibody][2] += f[i][2];
|
||||||
|
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
dx = unwrap[0] - xcm[ibody][0];
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
dy = unwrap[1] - xcm[ibody][1];
|
||||||
|
dz = unwrap[2] - xcm[ibody][2];
|
||||||
if (triclinic == 0) {
|
|
||||||
xunwrap = x[i][0] + xbox*xprd;
|
|
||||||
yunwrap = x[i][1] + ybox*yprd;
|
|
||||||
zunwrap = x[i][2] + zbox*zprd;
|
|
||||||
} else {
|
|
||||||
xunwrap = x[i][0] + xbox*xprd + ybox*xy + zbox*xz;
|
|
||||||
yunwrap = x[i][1] + ybox*yprd + zbox*yz;
|
|
||||||
zunwrap = x[i][2] + zbox*zprd;
|
|
||||||
}
|
|
||||||
|
|
||||||
dx = xunwrap - xcm[ibody][0];
|
|
||||||
dy = yunwrap - xcm[ibody][1];
|
|
||||||
dz = zunwrap - xcm[ibody][2];
|
|
||||||
|
|
||||||
sum[ibody][3] += dy*f[i][2] - dz*f[i][1];
|
sum[ibody][3] += dy*f[i][2] - dz*f[i][1];
|
||||||
sum[ibody][4] += dz*f[i][0] - dx*f[i][2];
|
sum[ibody][4] += dz*f[i][0] - dx*f[i][2];
|
||||||
|
|||||||
@ -89,11 +89,8 @@ double ComputeTempRotate::compute_scalar()
|
|||||||
{
|
{
|
||||||
double vthermal[3];
|
double vthermal[3];
|
||||||
double vcm[3],xcm[3],inertia[3][3],angmom[3],omega[3];
|
double vcm[3],xcm[3],inertia[3][3],angmom[3],omega[3];
|
||||||
int xbox,ybox,zbox;
|
|
||||||
double dx,dy,dz;
|
double dx,dy,dz;
|
||||||
double xprd = domain->xprd;
|
double unwrap[3];
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
|
|
||||||
invoked_scalar = update->ntimestep;
|
invoked_scalar = update->ntimestep;
|
||||||
|
|
||||||
@ -123,17 +120,13 @@ double ComputeTempRotate::compute_scalar()
|
|||||||
|
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
dx = unwrap[0] - xcm[0];
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
dy = unwrap[1] - xcm[1];
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
dz = unwrap[2] - xcm[2];
|
||||||
dx = (x[i][0] + xbox*xprd) - xcm[0];
|
|
||||||
dy = (x[i][1] + ybox*yprd) - xcm[1];
|
|
||||||
dz = (x[i][2] + zbox*zprd) - xcm[2];
|
|
||||||
vbiasall[i][0] = vcm[0] + dz*omega[1]-dy*omega[2];
|
vbiasall[i][0] = vcm[0] + dz*omega[1]-dy*omega[2];
|
||||||
vbiasall[i][1] = vcm[1] + dx*omega[2]-dz*omega[0];
|
vbiasall[i][1] = vcm[1] + dx*omega[2]-dz*omega[0];
|
||||||
vbiasall[i][2] = vcm[2] + dy*omega[0]-dx*omega[1];
|
vbiasall[i][2] = vcm[2] + dy*omega[0]-dx*omega[1];
|
||||||
|
|
||||||
vthermal[0] = v[i][0] - vbiasall[i][0];
|
vthermal[0] = v[i][0] - vbiasall[i][0];
|
||||||
vthermal[1] = v[i][1] - vbiasall[i][1];
|
vthermal[1] = v[i][1] - vbiasall[i][1];
|
||||||
vthermal[2] = v[i][2] - vbiasall[i][2];
|
vthermal[2] = v[i][2] - vbiasall[i][2];
|
||||||
@ -155,14 +148,10 @@ double ComputeTempRotate::compute_scalar()
|
|||||||
|
|
||||||
void ComputeTempRotate::compute_vector()
|
void ComputeTempRotate::compute_vector()
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
double vthermal[3];
|
double vthermal[3];
|
||||||
double vcm[3],xcm[3],inertia[3][3],angmom[3],omega[3];
|
double vcm[3],xcm[3],inertia[3][3],angmom[3],omega[3];
|
||||||
int xbox,ybox,zbox;
|
|
||||||
double dx,dy,dz;
|
double dx,dy,dz;
|
||||||
double xprd = domain->xprd;
|
double unwrap[3];
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
|
|
||||||
invoked_vector = update->ntimestep;
|
invoked_vector = update->ntimestep;
|
||||||
|
|
||||||
@ -189,25 +178,20 @@ void ComputeTempRotate::compute_vector()
|
|||||||
}
|
}
|
||||||
|
|
||||||
double massone,t[6];
|
double massone,t[6];
|
||||||
for (i = 0; i < 6; i++) t[i] = 0.0;
|
for (int i = 0; i < 6; i++) t[i] = 0.0;
|
||||||
|
|
||||||
for (i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
dx = unwrap[0] - xcm[0];
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
dy = unwrap[1] - xcm[1];
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
dz = unwrap[2] - xcm[2];
|
||||||
dx = (x[i][0] + xbox*xprd) - xcm[0];
|
|
||||||
dy = (x[i][1] + ybox*yprd) - xcm[1];
|
|
||||||
dz = (x[i][2] + zbox*zprd) - xcm[2];
|
|
||||||
vbiasall[i][0] = vcm[0] + dz*omega[1]-dy*omega[2];
|
vbiasall[i][0] = vcm[0] + dz*omega[1]-dy*omega[2];
|
||||||
vbiasall[i][1] = vcm[1] + dx*omega[2]-dz*omega[0];
|
vbiasall[i][1] = vcm[1] + dx*omega[2]-dz*omega[0];
|
||||||
vbiasall[i][2] = vcm[2] + dy*omega[0]-dx*omega[1];
|
vbiasall[i][2] = vcm[2] + dy*omega[0]-dx*omega[1];
|
||||||
|
|
||||||
vthermal[0] = v[i][0] - vbiasall[i][0];
|
vthermal[0] = v[i][0] - vbiasall[i][0];
|
||||||
vthermal[1] = v[i][1] - vbiasall[i][1];
|
vthermal[1] = v[i][1] - vbiasall[i][1];
|
||||||
vthermal[2] = v[i][2] - vbiasall[i][2];
|
vthermal[2] = v[i][2] - vbiasall[i][2];
|
||||||
|
|
||||||
if (rmass) massone = rmass[i];
|
if (rmass) massone = rmass[i];
|
||||||
else massone = mass[type[i]];
|
else massone = mass[type[i]];
|
||||||
t[0] += massone * vthermal[0]*vthermal[0];
|
t[0] += massone * vthermal[0]*vthermal[0];
|
||||||
@ -219,7 +203,7 @@ void ComputeTempRotate::compute_vector()
|
|||||||
}
|
}
|
||||||
|
|
||||||
MPI_Allreduce(t,vector,6,MPI_DOUBLE,MPI_SUM,world);
|
MPI_Allreduce(t,vector,6,MPI_DOUBLE,MPI_SUM,world);
|
||||||
for (i = 0; i < 6; i++) vector[i] *= force->mvv2e;
|
for (int i = 0; i < 6; i++) vector[i] *= force->mvv2e;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|||||||
@ -109,19 +109,22 @@ void FixAddTorque::init()
|
|||||||
|
|
||||||
if (xstr) {
|
if (xstr) {
|
||||||
xvar = input->variable->find(xstr);
|
xvar = input->variable->find(xstr);
|
||||||
if (xvar < 0) error->all(FLERR,"Variable name for fix addtorque does not exist");
|
if (xvar < 0)
|
||||||
|
error->all(FLERR,"Variable name for fix addtorque does not exist");
|
||||||
if (input->variable->equalstyle(xvar)) xstyle = EQUAL;
|
if (input->variable->equalstyle(xvar)) xstyle = EQUAL;
|
||||||
else error->all(FLERR,"Variable for fix addtorque is invalid style");
|
else error->all(FLERR,"Variable for fix addtorque is invalid style");
|
||||||
}
|
}
|
||||||
if (ystr) {
|
if (ystr) {
|
||||||
yvar = input->variable->find(ystr);
|
yvar = input->variable->find(ystr);
|
||||||
if (yvar < 0) error->all(FLERR,"Variable name for fix addtorque does not exist");
|
if (yvar < 0)
|
||||||
|
error->all(FLERR,"Variable name for fix addtorque does not exist");
|
||||||
if (input->variable->equalstyle(yvar)) ystyle = EQUAL;
|
if (input->variable->equalstyle(yvar)) ystyle = EQUAL;
|
||||||
else error->all(FLERR,"Variable for fix addtorque is invalid style");
|
else error->all(FLERR,"Variable for fix addtorque is invalid style");
|
||||||
}
|
}
|
||||||
if (zstr) {
|
if (zstr) {
|
||||||
zvar = input->variable->find(zstr);
|
zvar = input->variable->find(zstr);
|
||||||
if (zvar < 0) error->all(FLERR,"Variable name for fix addtorque does not exist");
|
if (zvar < 0)
|
||||||
|
error->all(FLERR,"Variable name for fix addtorque does not exist");
|
||||||
if (input->variable->equalstyle(zvar)) zstyle = EQUAL;
|
if (input->variable->equalstyle(zvar)) zstyle = EQUAL;
|
||||||
else error->all(FLERR,"Variable for fix addtorque is invalid style");
|
else error->all(FLERR,"Variable for fix addtorque is invalid style");
|
||||||
}
|
}
|
||||||
@ -168,16 +171,14 @@ void FixAddTorque::post_force(int vflag)
|
|||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
double mvv2e = force->mvv2e;
|
double mvv2e = force->mvv2e;
|
||||||
|
|
||||||
int xbox,ybox,zbox;
|
|
||||||
double dx,dy,dz,vx,vy,vz,fx,fy,fz,massone,omegadotr;
|
double dx,dy,dz,vx,vy,vz,fx,fy,fz,massone,omegadotr;
|
||||||
double xprd = domain->xprd;
|
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
|
|
||||||
double tcm[3],xcm[3],angmom[3],omega[3],itorque[3],domegadt[3],tlocal[3];
|
double tcm[3],xcm[3],angmom[3],omega[3],itorque[3],domegadt[3],tlocal[3];
|
||||||
double inertia[3][3];
|
double inertia[3][3];
|
||||||
|
double unwrap[3];
|
||||||
|
|
||||||
// foriginal[0] = "potential energy" for added force
|
// foriginal[0] = "potential energy" for added force
|
||||||
// foriginal[123] = torque on atoms before extra force added
|
// foriginal[123] = torque on atoms before extra force added
|
||||||
|
|
||||||
foriginal[0] = foriginal[1] = foriginal[2] = foriginal[3] = 0.0;
|
foriginal[0] = foriginal[1] = foriginal[2] = foriginal[3] = 0.0;
|
||||||
force_flag = 0;
|
force_flag = 0;
|
||||||
|
|
||||||
@ -200,12 +201,10 @@ void FixAddTorque::post_force(int vflag)
|
|||||||
tlocal[0] = tlocal[1] = tlocal[2] = 0.0;
|
tlocal[0] = tlocal[1] = tlocal[2] = 0.0;
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
dx = unwrap[0] - xcm[0];
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
dy = unwrap[1] - xcm[1];
|
||||||
dx = (x[i][0] + xbox*xprd) - xcm[0];
|
dz = unwrap[2] - xcm[2];
|
||||||
dy = (x[i][1] + ybox*yprd) - xcm[1];
|
|
||||||
dz = (x[i][2] + zbox*zprd) - xcm[2];
|
|
||||||
if (rmass) massone = rmass[i];
|
if (rmass) massone = rmass[i];
|
||||||
else massone = mass[type[i]];
|
else massone = mass[type[i]];
|
||||||
omegadotr = omega[0]*dx+omega[1]*dy+omega[2]*dz;
|
omegadotr = omega[0]*dx+omega[1]*dy+omega[2]*dz;
|
||||||
@ -222,12 +221,10 @@ void FixAddTorque::post_force(int vflag)
|
|||||||
|
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
dx = unwrap[0] - xcm[0];
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
dy = unwrap[1] - xcm[1];
|
||||||
dx = (x[i][0] + xbox*xprd) - xcm[0];
|
dz = unwrap[2] - xcm[2];
|
||||||
dy = (x[i][1] + ybox*yprd) - xcm[1];
|
|
||||||
dz = (x[i][2] + zbox*zprd) - xcm[2];
|
|
||||||
vx = mvv2e*(dz*omega[1]-dy*omega[2]);
|
vx = mvv2e*(dz*omega[1]-dy*omega[2]);
|
||||||
vy = mvv2e*(dx*omega[2]-dz*omega[0]);
|
vy = mvv2e*(dx*omega[2]-dz*omega[0]);
|
||||||
vz = mvv2e*(dy*omega[0]-dx*omega[1]);
|
vz = mvv2e*(dy*omega[0]-dx*omega[1]);
|
||||||
|
|||||||
@ -96,8 +96,8 @@ void ComputeCOMMolecule::init()
|
|||||||
void ComputeCOMMolecule::compute_array()
|
void ComputeCOMMolecule::compute_array()
|
||||||
{
|
{
|
||||||
int i,imol;
|
int i,imol;
|
||||||
double xbox,ybox,zbox;
|
|
||||||
double massone;
|
double massone;
|
||||||
|
double unwrap[3];
|
||||||
|
|
||||||
invoked_array = update->ntimestep;
|
invoked_array = update->ntimestep;
|
||||||
|
|
||||||
@ -113,23 +113,17 @@ void ComputeCOMMolecule::compute_array()
|
|||||||
double *rmass = atom->rmass;
|
double *rmass = atom->rmass;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
double xprd = domain->xprd;
|
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
|
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
|
||||||
if (rmass) massone = rmass[i];
|
if (rmass) massone = rmass[i];
|
||||||
else massone = mass[type[i]];
|
else massone = mass[type[i]];
|
||||||
imol = molecule[i];
|
imol = molecule[i];
|
||||||
if (molmap) imol = molmap[imol-idlo];
|
if (molmap) imol = molmap[imol-idlo];
|
||||||
else imol--;
|
else imol--;
|
||||||
com[imol][0] += (x[i][0] + xbox*xprd) * massone;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
com[imol][1] += (x[i][1] + ybox*yprd) * massone;
|
com[imol][0] += unwrap[0] * massone;
|
||||||
com[imol][2] += (x[i][2] + zbox*zprd) * massone;
|
com[imol][1] += unwrap[1] * massone;
|
||||||
|
com[imol][2] += unwrap[2] * massone;
|
||||||
}
|
}
|
||||||
|
|
||||||
MPI_Allreduce(&com[0][0],&comall[0][0],3*nmolecules,
|
MPI_Allreduce(&com[0][0],&comall[0][0],3*nmolecules,
|
||||||
|
|||||||
@ -83,25 +83,22 @@ void ComputeGyration::compute_vector()
|
|||||||
double *rmass = atom->rmass;
|
double *rmass = atom->rmass;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
int xbox,ybox,zbox;
|
|
||||||
double dx,dy,dz,massone;
|
double dx,dy,dz,massone;
|
||||||
double xprd = domain->xprd;
|
double unwrap[3];
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
|
|
||||||
double rg[6];
|
double rg[6];
|
||||||
rg[0] = rg[1] = rg[2] = rg[3] = rg[4] = rg[5] = 0.0;
|
rg[0] = rg[1] = rg[2] = rg[3] = rg[4] = rg[5] = 0.0;
|
||||||
|
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
|
||||||
dx = (x[i][0] + xbox*xprd) - xcm[0];
|
|
||||||
dy = (x[i][1] + ybox*yprd) - xcm[1];
|
|
||||||
dz = (x[i][2] + zbox*zprd) - xcm[2];
|
|
||||||
if (rmass) massone = rmass[i];
|
if (rmass) massone = rmass[i];
|
||||||
else massone = mass[type[i]];
|
else massone = mass[type[i]];
|
||||||
|
|
||||||
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
|
dx = unwrap[0] - xcm[0];
|
||||||
|
dy = unwrap[1] - xcm[1];
|
||||||
|
dz = unwrap[2] - xcm[2];
|
||||||
|
|
||||||
rg[0] += dx*dx * massone;
|
rg[0] += dx*dx * massone;
|
||||||
rg[1] += dy*dy * massone;
|
rg[1] += dy*dy * massone;
|
||||||
rg[2] += dz*dz * massone;
|
rg[2] += dz*dz * massone;
|
||||||
|
|||||||
@ -123,8 +123,8 @@ void ComputeGyrationMolecule::init()
|
|||||||
void ComputeGyrationMolecule::compute_vector()
|
void ComputeGyrationMolecule::compute_vector()
|
||||||
{
|
{
|
||||||
int i,imol;
|
int i,imol;
|
||||||
double xbox,ybox,zbox,dx,dy,dz;
|
double dx,dy,dz,massone;
|
||||||
double massone;
|
double unwrap[3];
|
||||||
|
|
||||||
invoked_array = update->ntimestep;
|
invoked_array = update->ntimestep;
|
||||||
|
|
||||||
@ -141,21 +141,16 @@ void ComputeGyrationMolecule::compute_vector()
|
|||||||
double *rmass = atom->rmass;
|
double *rmass = atom->rmass;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
double xprd = domain->xprd;
|
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
|
|
||||||
for (i = 0; i < nlocal; i++)
|
for (i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
|
||||||
imol = molecule[i];
|
imol = molecule[i];
|
||||||
if (molmap) imol = molmap[imol-idlo];
|
if (molmap) imol = molmap[imol-idlo];
|
||||||
else imol--;
|
else imol--;
|
||||||
dx = (x[i][0] + xbox*xprd) - comall[imol][0];
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
dy = (x[i][1] + ybox*yprd) - comall[imol][1];
|
dx = unwrap[0] - comall[imol][0];
|
||||||
dz = (x[i][2] + zbox*zprd) - comall[imol][2];
|
dy = unwrap[1] - comall[imol][1];
|
||||||
|
dz = unwrap[2] - comall[imol][2];
|
||||||
if (rmass) massone = rmass[i];
|
if (rmass) massone = rmass[i];
|
||||||
else massone = mass[type[i]];
|
else massone = mass[type[i]];
|
||||||
rg[imol] += (dx*dx + dy*dy + dz*dz) * massone;
|
rg[imol] += (dx*dx + dy*dy + dz*dz) * massone;
|
||||||
@ -171,8 +166,8 @@ void ComputeGyrationMolecule::compute_vector()
|
|||||||
void ComputeGyrationMolecule::compute_array()
|
void ComputeGyrationMolecule::compute_array()
|
||||||
{
|
{
|
||||||
int i,j,imol;
|
int i,j,imol;
|
||||||
double xbox,ybox,zbox,dx,dy,dz;
|
double dx,dy,dz,massone;
|
||||||
double massone;
|
double unwrap[3];
|
||||||
|
|
||||||
invoked_array = update->ntimestep;
|
invoked_array = update->ntimestep;
|
||||||
|
|
||||||
@ -191,21 +186,15 @@ void ComputeGyrationMolecule::compute_array()
|
|||||||
double *rmass = atom->rmass;
|
double *rmass = atom->rmass;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
double xprd = domain->xprd;
|
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
|
|
||||||
for (i = 0; i < nlocal; i++)
|
for (i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
|
||||||
imol = molecule[i];
|
imol = molecule[i];
|
||||||
if (molmap) imol = molmap[imol-idlo];
|
if (molmap) imol = molmap[imol-idlo];
|
||||||
else imol--;
|
else imol--;
|
||||||
dx = (x[i][0] + xbox*xprd) - comall[imol][0];
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
dy = (x[i][1] + ybox*yprd) - comall[imol][1];
|
dx = unwrap[0] - comall[imol][0];
|
||||||
dz = (x[i][2] + zbox*zprd) - comall[imol][2];
|
dy = unwrap[1] - comall[imol][1];
|
||||||
|
dz = unwrap[2] - comall[imol][2];
|
||||||
if (rmass) massone = rmass[i];
|
if (rmass) massone = rmass[i];
|
||||||
else massone = mass[type[i]];
|
else massone = mass[type[i]];
|
||||||
rgt[imol][0] += dx*dx * massone;
|
rgt[imol][0] += dx*dx * massone;
|
||||||
@ -233,8 +222,8 @@ void ComputeGyrationMolecule::compute_array()
|
|||||||
void ComputeGyrationMolecule::molcom()
|
void ComputeGyrationMolecule::molcom()
|
||||||
{
|
{
|
||||||
int i,imol;
|
int i,imol;
|
||||||
double xbox,ybox,zbox,dx,dy,dz;
|
double dx,dy,dz,massone;
|
||||||
double massone;
|
double unwrap[3];
|
||||||
|
|
||||||
for (i = 0; i < nmolecules; i++)
|
for (i = 0; i < nmolecules; i++)
|
||||||
com[i][0] = com[i][1] = com[i][2] = 0.0;
|
com[i][0] = com[i][1] = com[i][2] = 0.0;
|
||||||
@ -248,23 +237,17 @@ void ComputeGyrationMolecule::molcom()
|
|||||||
double *rmass = atom->rmass;
|
double *rmass = atom->rmass;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
double xprd = domain->xprd;
|
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
|
|
||||||
for (i = 0; i < nlocal; i++)
|
for (i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
|
||||||
if (rmass) massone = rmass[i];
|
|
||||||
else massone = mass[type[i]];
|
|
||||||
imol = molecule[i];
|
imol = molecule[i];
|
||||||
if (molmap) imol = molmap[imol-idlo];
|
if (molmap) imol = molmap[imol-idlo];
|
||||||
else imol--;
|
else imol--;
|
||||||
com[imol][0] += (x[i][0] + xbox*xprd) * massone;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
com[imol][1] += (x[i][1] + ybox*yprd) * massone;
|
if (rmass) massone = rmass[i];
|
||||||
com[imol][2] += (x[i][2] + zbox*zprd) * massone;
|
else massone = mass[type[i]];
|
||||||
|
com[imol][0] += unwrap[0] * massone;
|
||||||
|
com[imol][1] += unwrap[1] * massone;
|
||||||
|
com[imol][2] += unwrap[2] * massone;
|
||||||
}
|
}
|
||||||
|
|
||||||
MPI_Allreduce(&com[0][0],&comall[0][0],3*nmolecules,
|
MPI_Allreduce(&com[0][0],&comall[0][0],3*nmolecules,
|
||||||
|
|||||||
@ -111,8 +111,8 @@ void ComputeMSDMolecule::init()
|
|||||||
void ComputeMSDMolecule::compute_array()
|
void ComputeMSDMolecule::compute_array()
|
||||||
{
|
{
|
||||||
int i,imol;
|
int i,imol;
|
||||||
double xbox,ybox,zbox,dx,dy,dz;
|
double dx,dy,dz,massone;
|
||||||
double massone;
|
double unwrap[3];
|
||||||
|
|
||||||
invoked_array = update->ntimestep;
|
invoked_array = update->ntimestep;
|
||||||
|
|
||||||
@ -130,23 +130,17 @@ void ComputeMSDMolecule::compute_array()
|
|||||||
double *rmass = atom->rmass;
|
double *rmass = atom->rmass;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
double xprd = domain->xprd;
|
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
|
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
|
||||||
if (rmass) massone = rmass[i];
|
|
||||||
else massone = mass[type[i]];
|
|
||||||
imol = molecule[i];
|
imol = molecule[i];
|
||||||
if (molmap) imol = molmap[imol-idlo];
|
if (molmap) imol = molmap[imol-idlo];
|
||||||
else imol--;
|
else imol--;
|
||||||
com[imol][0] += (x[i][0] + xbox*xprd) * massone;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
com[imol][1] += (x[i][1] + ybox*yprd) * massone;
|
if (rmass) massone = rmass[i];
|
||||||
com[imol][2] += (x[i][2] + zbox*zprd) * massone;
|
else massone = mass[type[i]];
|
||||||
|
com[imol][0] += unwrap[0] * massone;
|
||||||
|
com[imol][1] += unwrap[1] * massone;
|
||||||
|
com[imol][2] += unwrap[2] * massone;
|
||||||
}
|
}
|
||||||
|
|
||||||
MPI_Allreduce(&com[0][0],&comall[0][0],3*nmolecules,
|
MPI_Allreduce(&com[0][0],&comall[0][0],3*nmolecules,
|
||||||
|
|||||||
@ -217,12 +217,6 @@ void FixAddForce::min_setup(int vflag)
|
|||||||
|
|
||||||
void FixAddForce::post_force(int vflag)
|
void FixAddForce::post_force(int vflag)
|
||||||
{
|
{
|
||||||
int xbox,ybox,zbox;
|
|
||||||
|
|
||||||
double xprd = domain->xprd;
|
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
|
|
||||||
double **x = atom->x;
|
double **x = atom->x;
|
||||||
double **f = atom->f;
|
double **f = atom->f;
|
||||||
int *mask = atom->mask;
|
int *mask = atom->mask;
|
||||||
@ -247,18 +241,15 @@ void FixAddForce::post_force(int vflag)
|
|||||||
// potential energy = - x dot f in unwrapped coords
|
// potential energy = - x dot f in unwrapped coords
|
||||||
|
|
||||||
if (varflag == CONSTANT) {
|
if (varflag == CONSTANT) {
|
||||||
|
double unwrap[3];
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
if (iregion >= 0 &&
|
if (iregion >= 0 &&
|
||||||
!domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2]))
|
!domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
foriginal[0] -= xvalue*unwrap[0] + yvalue*unwrap[1] + zvalue*unwrap[2];
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
|
||||||
foriginal[0] -= xvalue * (x[i][0]+xbox*xprd) +
|
|
||||||
yvalue * (x[i][1]+ybox*yprd) + zvalue * (x[i][2]+zbox*zprd);
|
|
||||||
|
|
||||||
foriginal[1] += f[i][0];
|
foriginal[1] += f[i][0];
|
||||||
foriginal[2] += f[i][1];
|
foriginal[2] += f[i][1];
|
||||||
foriginal[3] += f[i][2];
|
foriginal[3] += f[i][2];
|
||||||
|
|||||||
@ -57,7 +57,8 @@ FixMomentum::FixMomentum(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
if (linear)
|
if (linear)
|
||||||
if (xflag < 0 || xflag > 1 || yflag < 0 || yflag > 1 ||
|
if (xflag < 0 || xflag > 1 || yflag < 0 || yflag > 1 ||
|
||||||
zflag < 0 || zflag > 1) error->all(FLERR,"Illegal fix momentum command");
|
zflag < 0 || zflag > 1)
|
||||||
|
error->all(FLERR,"Illegal fix momentum command");
|
||||||
|
|
||||||
// cannot have 0 atoms in group
|
// cannot have 0 atoms in group
|
||||||
|
|
||||||
@ -121,20 +122,15 @@ void FixMomentum::end_of_step()
|
|||||||
tagint *image = atom->image;
|
tagint *image = atom->image;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
int xbox,ybox,zbox;
|
|
||||||
double dx,dy,dz;
|
double dx,dy,dz;
|
||||||
double xprd = domain->xprd;
|
double unwrap[3];
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
|
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
dx = unwrap[0] - xcm[0];
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
dy = unwrap[1] - xcm[1];
|
||||||
dx = (x[i][0] + xbox*xprd) - xcm[0];
|
dz = unwrap[2] - xcm[2];
|
||||||
dy = (x[i][1] + ybox*yprd) - xcm[1];
|
|
||||||
dz = (x[i][2] + zbox*zprd) - xcm[2];
|
|
||||||
v[i][0] -= omega[1]*dz - omega[2]*dy;
|
v[i][0] -= omega[1]*dz - omega[2]*dy;
|
||||||
v[i][1] -= omega[2]*dx - omega[0]*dz;
|
v[i][1] -= omega[2]*dx - omega[0]*dz;
|
||||||
v[i][2] -= omega[0]*dy - omega[1]*dx;
|
v[i][2] -= omega[0]*dy - omega[1]*dx;
|
||||||
|
|||||||
@ -110,20 +110,15 @@ void FixSpringRG::post_force(int vflag)
|
|||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
double massfrac;
|
double massfrac;
|
||||||
double xprd = domain->xprd;
|
double unwrap[3];
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
|
|
||||||
int xbox,ybox,zbox;
|
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
|
dx = unwrap[0] - xcm[0];
|
||||||
|
dy = unwrap[1] - xcm[1];
|
||||||
|
dz = unwrap[2] - xcm[2];
|
||||||
term1 = 2.0 * k * (1.0 - rg0/rg);
|
term1 = 2.0 * k * (1.0 - rg0/rg);
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
|
||||||
dx = (x[i][0] + xbox*xprd) - xcm[0];
|
|
||||||
dy = (x[i][1] + ybox*yprd) - xcm[1];
|
|
||||||
dz = (x[i][2] + zbox*zprd) - xcm[2];
|
|
||||||
massfrac = mass[type[i]]/masstotal;
|
massfrac = mass[type[i]]/masstotal;
|
||||||
f[i][0] -= term1*dx*massfrac;
|
f[i][0] -= term1*dx*massfrac;
|
||||||
f[i][1] -= term1*dy*massfrac;
|
f[i][1] -= term1*dy*massfrac;
|
||||||
|
|||||||
@ -45,9 +45,10 @@ FixSpringSelf::FixSpringSelf(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
if (k <= 0.0) error->all(FLERR,"Illegal fix spring/self command");
|
if (k <= 0.0) error->all(FLERR,"Illegal fix spring/self command");
|
||||||
|
|
||||||
xflag = yflag = zflag = 1;
|
xflag = yflag = zflag = 1;
|
||||||
|
|
||||||
if (narg == 5) {
|
if (narg == 5) {
|
||||||
if (strcmp(arg[4],"xyz") == 0) {
|
if (strcmp(arg[4],"xyz") == 0) {
|
||||||
; /* default */
|
xflag = yflag = zflag = 1;
|
||||||
} else if (strcmp(arg[4],"xy") == 0) {
|
} else if (strcmp(arg[4],"xy") == 0) {
|
||||||
zflag = 0;
|
zflag = 0;
|
||||||
} else if (strcmp(arg[4],"xz") == 0) {
|
} else if (strcmp(arg[4],"xz") == 0) {
|
||||||
@ -78,20 +79,9 @@ FixSpringSelf::FixSpringSelf(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
tagint *image = atom->image;
|
tagint *image = atom->image;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
double xprd = domain->xprd;
|
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
int xbox,ybox,zbox;
|
|
||||||
|
|
||||||
for (int i = 0; i < nlocal; i++) {
|
for (int i = 0; i < nlocal; i++) {
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) domain->unmap(x[i],image[i],xoriginal[i]);
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
else xoriginal[i][0] = xoriginal[i][1] = xoriginal[i][2] = 0.0;
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
|
||||||
xoriginal[i][0] = x[i][0] + xbox*xprd;
|
|
||||||
xoriginal[i][1] = x[i][1] + ybox*yprd;
|
|
||||||
xoriginal[i][2] = x[i][2] + zbox*zprd;
|
|
||||||
} else xoriginal[i][0] = xoriginal[i][1] = xoriginal[i][2] = 0.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
espring = 0.0;
|
espring = 0.0;
|
||||||
@ -161,21 +151,17 @@ void FixSpringSelf::post_force(int vflag)
|
|||||||
tagint *image = atom->image;
|
tagint *image = atom->image;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
double xprd = domain->xprd;
|
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
int xbox,ybox,zbox;
|
|
||||||
double dx,dy,dz;
|
double dx,dy,dz;
|
||||||
|
double unwrap[3];
|
||||||
|
|
||||||
espring = 0.0;
|
espring = 0.0;
|
||||||
|
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
dx = unwrap[0] - xoriginal[i][0];
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
dy = unwrap[1] - xoriginal[i][1];
|
||||||
dx = x[i][0] + xbox*xprd - xoriginal[i][0];
|
dz = unwrap[2] - xoriginal[i][2];
|
||||||
dy = x[i][1] + ybox*yprd - xoriginal[i][1];
|
|
||||||
dz = x[i][2] + zbox*zprd - xoriginal[i][2];
|
|
||||||
if (!xflag) dx = 0.0;
|
if (!xflag) dx = 0.0;
|
||||||
if (!yflag) dy = 0.0;
|
if (!yflag) dy = 0.0;
|
||||||
if (!zflag) dz = 0.0;
|
if (!zflag) dz = 0.0;
|
||||||
|
|||||||
@ -98,26 +98,17 @@ FixTMD::FixTMD(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
double *mass = atom->mass;
|
double *mass = atom->mass;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
double xprd = domain->xprd;
|
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
|
|
||||||
double dx,dy,dz;
|
double dx,dy,dz;
|
||||||
int xbox,ybox,zbox;
|
|
||||||
rho_start = 0.0;
|
rho_start = 0.0;
|
||||||
|
|
||||||
for (int i = 0; i < nlocal; i++) {
|
for (int i = 0; i < nlocal; i++) {
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
domain->unmap(x[i],image[i],xold[i]);
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
dx = xold[i][0] - xf[i][0];
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
dy = xold[i][1] - xf[i][1];
|
||||||
dx = x[i][0] + xbox*xprd - xf[i][0];
|
dz = xold[i][2] - xf[i][2];
|
||||||
dy = x[i][1] + ybox*yprd - xf[i][1];
|
|
||||||
dz = x[i][2] + zbox*zprd - xf[i][2];
|
|
||||||
rho_start += mass[type[i]]*(dx*dx + dy*dy + dz*dz);
|
rho_start += mass[type[i]]*(dx*dx + dy*dy + dz*dz);
|
||||||
xold[i][0] = x[i][0] + xbox*xprd;
|
|
||||||
xold[i][1] = x[i][1] + ybox*yprd;
|
|
||||||
xold[i][2] = x[i][2] + zbox*zprd;
|
|
||||||
} else xold[i][0] = xold[i][1] = xold[i][2] = 0.0;
|
} else xold[i][0] = xold[i][1] = xold[i][2] = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,10 +181,8 @@ void FixTMD::initial_integrate(int vflag)
|
|||||||
double dxold,dyold,dzold,xback,yback,zback;
|
double dxold,dyold,dzold,xback,yback,zback;
|
||||||
double gamma_forward,gamma_back,gamma_max,lambda;
|
double gamma_forward,gamma_back,gamma_max,lambda;
|
||||||
double kt,fr,kttotal,frtotal,dtfm;
|
double kt,fr,kttotal,frtotal,dtfm;
|
||||||
|
double unwrap[3];
|
||||||
|
|
||||||
double xprd = domain->xprd;
|
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
double **x = atom->x;
|
double **x = atom->x;
|
||||||
double **v = atom->v;
|
double **v = atom->v;
|
||||||
double **f = atom->f;
|
double **f = atom->f;
|
||||||
@ -202,7 +191,6 @@ void FixTMD::initial_integrate(int vflag)
|
|||||||
int *type = atom->type;
|
int *type = atom->type;
|
||||||
int *mask = atom->mask;
|
int *mask = atom->mask;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
int xbox,ybox,zbox;
|
|
||||||
|
|
||||||
double delta = update->ntimestep - update->beginstep;
|
double delta = update->ntimestep - update->beginstep;
|
||||||
delta /= update->endstep - update->beginstep;
|
delta /= update->endstep - update->beginstep;
|
||||||
@ -216,12 +204,10 @@ void FixTMD::initial_integrate(int vflag)
|
|||||||
dxold = xold[i][0] - xf[i][0];
|
dxold = xold[i][0] - xf[i][0];
|
||||||
dyold = xold[i][1] - xf[i][1];
|
dyold = xold[i][1] - xf[i][1];
|
||||||
dzold = xold[i][2] - xf[i][2];
|
dzold = xold[i][2] - xf[i][2];
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
dx = unwrap[0] - xf[i][0];
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
dy = unwrap[1] - xf[i][1];
|
||||||
dx = x[i][0] + xbox*xprd - xf[i][0];
|
dz = unwrap[2] - xf[i][2];
|
||||||
dy = x[i][1] + ybox*yprd - xf[i][1];
|
|
||||||
dz = x[i][2] + zbox*zprd - xf[i][2];
|
|
||||||
a += mass[type[i]]*(dxold*dxold + dyold*dyold + dzold*dzold);
|
a += mass[type[i]]*(dxold*dxold + dyold*dyold + dzold*dzold);
|
||||||
b += mass[type[i]]*(dx *dxold + dy *dyold + dz *dzold);
|
b += mass[type[i]]*(dx *dxold + dy *dyold + dz *dzold);
|
||||||
e += mass[type[i]]*(dx *dx + dy *dy + dz *dz);
|
e += mass[type[i]]*(dx *dx + dy *dy + dz *dz);
|
||||||
@ -258,12 +244,10 @@ void FixTMD::initial_integrate(int vflag)
|
|||||||
dxold = xold[i][0] - xf[i][0];
|
dxold = xold[i][0] - xf[i][0];
|
||||||
dyold = xold[i][1] - xf[i][1];
|
dyold = xold[i][1] - xf[i][1];
|
||||||
dzold = xold[i][2] - xf[i][2];
|
dzold = xold[i][2] - xf[i][2];
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
xback = unwrap[0] + gamma_back*dxold;
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
yback = unwrap[1] + gamma_back*dyold;
|
||||||
xback = x[i][0] + xbox*xprd + gamma_back*dxold;
|
zback = unwrap[2] + gamma_back*dzold;
|
||||||
yback = x[i][1] + ybox*yprd + gamma_back*dyold;
|
|
||||||
zback = x[i][2] + zbox*zprd + gamma_back*dzold;
|
|
||||||
dxkt = xback - xold[i][0];
|
dxkt = xback - xold[i][0];
|
||||||
dykt = yback - xold[i][1];
|
dykt = yback - xold[i][1];
|
||||||
dzkt = zback - xold[i][2];
|
dzkt = zback - xold[i][2];
|
||||||
@ -314,12 +298,7 @@ void FixTMD::initial_integrate(int vflag)
|
|||||||
x[i][2] += gamma_forward*dzold;
|
x[i][2] += gamma_forward*dzold;
|
||||||
v[i][2] += gamma_forward*dzold/dtv;
|
v[i][2] += gamma_forward*dzold/dtv;
|
||||||
f[i][2] += gamma_forward*dzold/dtv/dtfm;
|
f[i][2] += gamma_forward*dzold/dtv/dtfm;
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
domain->unmap(x[i],image[i],xold[i]);
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
|
||||||
xold[i][0] = x[i][0] + xbox*xprd;
|
|
||||||
xold[i][1] = x[i][1] + ybox*yprd;
|
|
||||||
xold[i][2] = x[i][2] + zbox*zprd;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
176
src/group.cpp
176
src/group.cpp
@ -766,34 +766,27 @@ void Group::xcm(int igroup, double masstotal, double *cm)
|
|||||||
|
|
||||||
double cmone[3];
|
double cmone[3];
|
||||||
cmone[0] = cmone[1] = cmone[2] = 0.0;
|
cmone[0] = cmone[1] = cmone[2] = 0.0;
|
||||||
double xprd = domain->xprd;
|
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
|
|
||||||
int xbox,ybox,zbox;
|
|
||||||
double massone;
|
double massone;
|
||||||
|
double unwrap[3];
|
||||||
|
|
||||||
if (rmass) {
|
if (rmass) {
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
|
||||||
massone = rmass[i];
|
massone = rmass[i];
|
||||||
cmone[0] += (x[i][0] + xbox*xprd) * massone;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
cmone[1] += (x[i][1] + ybox*yprd) * massone;
|
cmone[0] += unwrap[0] * massone;
|
||||||
cmone[2] += (x[i][2] + zbox*zprd) * massone;
|
cmone[1] += unwrap[1] * massone;
|
||||||
|
cmone[2] += unwrap[2] * massone;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
|
||||||
massone = mass[type[i]];
|
massone = mass[type[i]];
|
||||||
cmone[0] += (x[i][0] + xbox*xprd) * massone;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
cmone[1] += (x[i][1] + ybox*yprd) * massone;
|
cmone[0] += unwrap[0] * massone;
|
||||||
cmone[2] += (x[i][2] + zbox*zprd) * massone;
|
cmone[1] += unwrap[1] * massone;
|
||||||
|
cmone[2] += unwrap[2] * massone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -827,34 +820,27 @@ void Group::xcm(int igroup, double masstotal, double *cm, int iregion)
|
|||||||
|
|
||||||
double cmone[3];
|
double cmone[3];
|
||||||
cmone[0] = cmone[1] = cmone[2] = 0.0;
|
cmone[0] = cmone[1] = cmone[2] = 0.0;
|
||||||
double xprd = domain->xprd;
|
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
|
|
||||||
int xbox,ybox,zbox;
|
|
||||||
double massone;
|
double massone;
|
||||||
|
double unwrap[3];
|
||||||
|
|
||||||
if (rmass) {
|
if (rmass) {
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit && region->match(x[i][0],x[i][1],x[i][2])) {
|
if (mask[i] & groupbit && region->match(x[i][0],x[i][1],x[i][2])) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
|
||||||
massone = rmass[i];
|
massone = rmass[i];
|
||||||
cmone[0] += (x[i][0] + xbox*xprd) * massone;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
cmone[1] += (x[i][1] + ybox*yprd) * massone;
|
cmone[0] += unwrap[0] * massone;
|
||||||
cmone[2] += (x[i][2] + zbox*zprd) * massone;
|
cmone[1] += unwrap[1] * massone;
|
||||||
|
cmone[2] += unwrap[2] * massone;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit && region->match(x[i][0],x[i][1],x[i][2])) {
|
if (mask[i] & groupbit && region->match(x[i][0],x[i][1],x[i][2])) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
|
||||||
massone = mass[type[i]];
|
massone = mass[type[i]];
|
||||||
cmone[0] += (x[i][0] + xbox*xprd) * massone;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
cmone[1] += (x[i][1] + ybox*yprd) * massone;
|
cmone[0] += unwrap[0] * massone;
|
||||||
cmone[2] += (x[i][2] + zbox*zprd) * massone;
|
cmone[1] += unwrap[1] * massone;
|
||||||
|
cmone[2] += unwrap[2] * massone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1102,21 +1088,16 @@ double Group::gyration(int igroup, double masstotal, double *cm)
|
|||||||
double *rmass = atom->rmass;
|
double *rmass = atom->rmass;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
int xbox,ybox,zbox;
|
|
||||||
double dx,dy,dz,massone;
|
double dx,dy,dz,massone;
|
||||||
double xprd = domain->xprd;
|
double unwrap[3];
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
double rg = 0.0;
|
double rg = 0.0;
|
||||||
|
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
dx = unwrap[0] - cm[0];
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
dy = unwrap[1] - cm[1];
|
||||||
dx = (x[i][0] + xbox*xprd) - cm[0];
|
dz = unwrap[2] - cm[2];
|
||||||
dy = (x[i][1] + ybox*yprd) - cm[1];
|
|
||||||
dz = (x[i][2] + zbox*zprd) - cm[2];
|
|
||||||
if (rmass) massone = rmass[i];
|
if (rmass) massone = rmass[i];
|
||||||
else massone = mass[type[i]];
|
else massone = mass[type[i]];
|
||||||
rg += (dx*dx + dy*dy + dz*dz) * massone;
|
rg += (dx*dx + dy*dy + dz*dz) * massone;
|
||||||
@ -1147,21 +1128,16 @@ double Group::gyration(int igroup, double masstotal, double *cm, int iregion)
|
|||||||
double *rmass = atom->rmass;
|
double *rmass = atom->rmass;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
int xbox,ybox,zbox;
|
|
||||||
double dx,dy,dz,massone;
|
double dx,dy,dz,massone;
|
||||||
double xprd = domain->xprd;
|
double unwrap[3];
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
double rg = 0.0;
|
double rg = 0.0;
|
||||||
|
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit && region->match(x[i][0],x[i][1],x[i][2])) {
|
if (mask[i] & groupbit && region->match(x[i][0],x[i][1],x[i][2])) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
dx = unwrap[0] - cm[0];
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
dy = unwrap[1] - cm[1];
|
||||||
dx = (x[i][0] + xbox*xprd) - cm[0];
|
dz = unwrap[2] - cm[2];
|
||||||
dy = (x[i][1] + ybox*yprd) - cm[1];
|
|
||||||
dz = (x[i][2] + zbox*zprd) - cm[2];
|
|
||||||
if (rmass) massone = rmass[i];
|
if (rmass) massone = rmass[i];
|
||||||
else massone = mass[type[i]];
|
else massone = mass[type[i]];
|
||||||
rg += (dx*dx + dy*dy + dz*dz) * massone;
|
rg += (dx*dx + dy*dy + dz*dz) * massone;
|
||||||
@ -1192,22 +1168,18 @@ void Group::angmom(int igroup, double *cm, double *lmom)
|
|||||||
double *rmass = atom->rmass;
|
double *rmass = atom->rmass;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
int xbox,ybox,zbox;
|
|
||||||
double dx,dy,dz,massone;
|
double dx,dy,dz,massone;
|
||||||
double xprd = domain->xprd;
|
double unwrap[3];
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
double p[3];
|
double p[3];
|
||||||
p[0] = p[1] = p[2] = 0.0;
|
p[0] = p[1] = p[2] = 0.0;
|
||||||
|
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
dx = unwrap[0] - cm[0];
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
dy = unwrap[1] - cm[1];
|
||||||
dx = (x[i][0] + xbox*xprd) - cm[0];
|
dz = unwrap[2] - cm[2];
|
||||||
dy = (x[i][1] + ybox*yprd) - cm[1];
|
|
||||||
dz = (x[i][2] + zbox*zprd) - cm[2];
|
|
||||||
if (rmass) massone = rmass[i];
|
if (rmass) massone = rmass[i];
|
||||||
else massone = mass[type[i]];
|
else massone = mass[type[i]];
|
||||||
p[0] += massone * (dy*v[i][2] - dz*v[i][1]);
|
p[0] += massone * (dy*v[i][2] - dz*v[i][1]);
|
||||||
@ -1238,22 +1210,18 @@ void Group::angmom(int igroup, double *cm, double *lmom, int iregion)
|
|||||||
double *rmass = atom->rmass;
|
double *rmass = atom->rmass;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
int xbox,ybox,zbox;
|
|
||||||
double dx,dy,dz,massone;
|
double dx,dy,dz,massone;
|
||||||
double xprd = domain->xprd;
|
double unwrap[3];
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
double p[3];
|
double p[3];
|
||||||
p[0] = p[1] = p[2] = 0.0;
|
p[0] = p[1] = p[2] = 0.0;
|
||||||
|
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit && region->match(x[i][0],x[i][1],x[i][2])) {
|
if (mask[i] & groupbit && region->match(x[i][0],x[i][1],x[i][2])) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
dx = unwrap[0] - cm[0];
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
dy = unwrap[1] - cm[1];
|
||||||
dx = (x[i][0] + xbox*xprd) - cm[0];
|
dz = unwrap[2] - cm[2];
|
||||||
dy = (x[i][1] + ybox*yprd) - cm[1];
|
|
||||||
dz = (x[i][2] + zbox*zprd) - cm[2];
|
|
||||||
if (rmass) massone = rmass[i];
|
if (rmass) massone = rmass[i];
|
||||||
else massone = mass[type[i]];
|
else massone = mass[type[i]];
|
||||||
p[0] += massone * (dy*v[i][2] - dz*v[i][1]);
|
p[0] += massone * (dy*v[i][2] - dz*v[i][1]);
|
||||||
@ -1280,22 +1248,18 @@ void Group::torque(int igroup, double *cm, double *tq)
|
|||||||
tagint *image = atom->image;
|
tagint *image = atom->image;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
int xbox,ybox,zbox;
|
|
||||||
double dx,dy,dz;
|
double dx,dy,dz;
|
||||||
double xprd = domain->xprd;
|
double unwrap[3];
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
double tlocal[3];
|
double tlocal[3];
|
||||||
tlocal[0] = tlocal[1] = tlocal[2] = 0.0;
|
tlocal[0] = tlocal[1] = tlocal[2] = 0.0;
|
||||||
|
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
dx = unwrap[0] - cm[0];
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
dy = unwrap[1] - cm[1];
|
||||||
dx = (x[i][0] + xbox*xprd) - cm[0];
|
dz = unwrap[2] - cm[2];
|
||||||
dy = (x[i][1] + ybox*yprd) - cm[1];
|
|
||||||
dz = (x[i][2] + zbox*zprd) - cm[2];
|
|
||||||
tlocal[0] += dy*f[i][2] - dz*f[i][1];
|
tlocal[0] += dy*f[i][2] - dz*f[i][1];
|
||||||
tlocal[1] += dz*f[i][0] - dx*f[i][2];
|
tlocal[1] += dz*f[i][0] - dx*f[i][2];
|
||||||
tlocal[2] += dx*f[i][1] - dy*f[i][0];
|
tlocal[2] += dx*f[i][1] - dy*f[i][0];
|
||||||
@ -1321,22 +1285,18 @@ void Group::torque(int igroup, double *cm, double *tq, int iregion)
|
|||||||
tagint *image = atom->image;
|
tagint *image = atom->image;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
int xbox,ybox,zbox;
|
|
||||||
double dx,dy,dz;
|
double dx,dy,dz;
|
||||||
double xprd = domain->xprd;
|
double unwrap[3];
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
double tlocal[3];
|
double tlocal[3];
|
||||||
tlocal[0] = tlocal[1] = tlocal[2] = 0.0;
|
tlocal[0] = tlocal[1] = tlocal[2] = 0.0;
|
||||||
|
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit && region->match(x[i][0],x[i][1],x[i][2])) {
|
if (mask[i] & groupbit && region->match(x[i][0],x[i][1],x[i][2])) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
dx = unwrap[0] - cm[0];
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
dy = unwrap[1] - cm[1];
|
||||||
dx = (x[i][0] + xbox*xprd) - cm[0];
|
dz = unwrap[2] - cm[2];
|
||||||
dy = (x[i][1] + ybox*yprd) - cm[1];
|
|
||||||
dz = (x[i][2] + zbox*zprd) - cm[2];
|
|
||||||
tlocal[0] += dy*f[i][2] - dz*f[i][1];
|
tlocal[0] += dy*f[i][2] - dz*f[i][1];
|
||||||
tlocal[1] += dz*f[i][0] - dx*f[i][2];
|
tlocal[1] += dz*f[i][0] - dx*f[i][2];
|
||||||
tlocal[2] += dx*f[i][1] - dy*f[i][0];
|
tlocal[2] += dx*f[i][1] - dy*f[i][0];
|
||||||
@ -1364,11 +1324,9 @@ void Group::inertia(int igroup, double *cm, double itensor[3][3])
|
|||||||
double *rmass = atom->rmass;
|
double *rmass = atom->rmass;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
int xbox,ybox,zbox;
|
|
||||||
double dx,dy,dz,massone;
|
double dx,dy,dz,massone;
|
||||||
double xprd = domain->xprd;
|
double unwrap[3];
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
double ione[3][3];
|
double ione[3][3];
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
for (j = 0; j < 3; j++)
|
for (j = 0; j < 3; j++)
|
||||||
@ -1376,12 +1334,10 @@ void Group::inertia(int igroup, double *cm, double itensor[3][3])
|
|||||||
|
|
||||||
for (i = 0; i < nlocal; i++)
|
for (i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
dx = unwrap[0] - cm[0];
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
dy = unwrap[1] - cm[1];
|
||||||
dx = (x[i][0] + xbox*xprd) - cm[0];
|
dz = unwrap[2] - cm[2];
|
||||||
dy = (x[i][1] + ybox*yprd) - cm[1];
|
|
||||||
dz = (x[i][2] + zbox*zprd) - cm[2];
|
|
||||||
if (rmass) massone = rmass[i];
|
if (rmass) massone = rmass[i];
|
||||||
else massone = mass[type[i]];
|
else massone = mass[type[i]];
|
||||||
ione[0][0] += massone * (dy*dy + dz*dz);
|
ione[0][0] += massone * (dy*dy + dz*dz);
|
||||||
@ -1418,11 +1374,9 @@ void Group::inertia(int igroup, double *cm, double itensor[3][3], int iregion)
|
|||||||
double *rmass = atom->rmass;
|
double *rmass = atom->rmass;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
int xbox,ybox,zbox;
|
|
||||||
double dx,dy,dz,massone;
|
double dx,dy,dz,massone;
|
||||||
double xprd = domain->xprd;
|
double unwrap[3];
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
double ione[3][3];
|
double ione[3][3];
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
for (j = 0; j < 3; j++)
|
for (j = 0; j < 3; j++)
|
||||||
@ -1430,12 +1384,10 @@ void Group::inertia(int igroup, double *cm, double itensor[3][3], int iregion)
|
|||||||
|
|
||||||
for (i = 0; i < nlocal; i++)
|
for (i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit && region->match(x[i][0],x[i][1],x[i][2])) {
|
if (mask[i] & groupbit && region->match(x[i][0],x[i][1],x[i][2])) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
dx = unwrap[0] - cm[0];
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
dy = unwrap[1] - cm[1];
|
||||||
dx = (x[i][0] + xbox*xprd) - cm[0];
|
dz = unwrap[2] - cm[2];
|
||||||
dy = (x[i][1] + ybox*yprd) - cm[1];
|
|
||||||
dz = (x[i][2] + zbox*zprd) - cm[2];
|
|
||||||
if (rmass) massone = rmass[i];
|
if (rmass) massone = rmass[i];
|
||||||
else massone = mass[type[i]];
|
else massone = mass[type[i]];
|
||||||
ione[0][0] += massone * (dy*dy + dz*dz);
|
ione[0][0] += massone * (dy*dy + dz*dz);
|
||||||
|
|||||||
@ -718,20 +718,15 @@ void Velocity::zero_rotation()
|
|||||||
tagint *image = atom->image;
|
tagint *image = atom->image;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
int xbox,ybox,zbox;
|
|
||||||
double dx,dy,dz;
|
double dx,dy,dz;
|
||||||
double xprd = domain->xprd;
|
double unwrap[3];
|
||||||
double yprd = domain->yprd;
|
|
||||||
double zprd = domain->zprd;
|
|
||||||
|
|
||||||
for (i = 0; i < nlocal; i++)
|
for (i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
domain->unmap(x[i],image[i],unwrap);
|
||||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
dx = unwrap[0]- xcm[0];
|
||||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
dy = unwrap[1] - xcm[1];
|
||||||
dx = (x[i][0] + xbox*xprd) - xcm[0];
|
dz = unwrap[2] - xcm[2];
|
||||||
dy = (x[i][1] + ybox*yprd) - xcm[1];
|
|
||||||
dz = (x[i][2] + zbox*zprd) - xcm[2];
|
|
||||||
v[i][0] -= omega[1]*dz - omega[2]*dy;
|
v[i][0] -= omega[1]*dz - omega[2]*dy;
|
||||||
v[i][1] -= omega[2]*dx - omega[0]*dz;
|
v[i][1] -= omega[2]*dx - omega[0]*dz;
|
||||||
v[i][2] -= omega[0]*dy - omega[1]*dx;
|
v[i][2] -= omega[0]*dy - omega[1]*dx;
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
#define LAMMPS_VERSION "23 Oct 2012"
|
#define LAMMPS_VERSION "26 Oct 2012"
|
||||||
|
|||||||
Reference in New Issue
Block a user