Merge branch 'master' into bond/react-molecule-fragment-support
This commit is contained in:
@ -15,14 +15,35 @@ if(ENABLE_COVERAGE)
|
||||
gen_coverage_xml
|
||||
COMMAND ${GCOVR_BINARY} -s -x -r ${ABSOLUTE_LAMMPS_SOURCE_DIR} --object-directory=${CMAKE_BINARY_DIR} -o coverage.xml
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Generating XML Coverage Report..."
|
||||
COMMENT "Generating XML coverage report..."
|
||||
)
|
||||
|
||||
set(COVERAGE_HTML_DIR ${CMAKE_BINARY_DIR}/coverage_html)
|
||||
|
||||
add_custom_target(coverage_html_folder
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${COVERAGE_HTML_DIR})
|
||||
|
||||
add_custom_target(
|
||||
gen_coverage_html
|
||||
COMMAND ${GCOVR_BINARY} -s --html --html-details -r ${ABSOLUTE_LAMMPS_SOURCE_DIR} --object-directory=${CMAKE_BINARY_DIR} -o coverage.html
|
||||
COMMAND ${GCOVR_BINARY} -s --html --html-details -r ${ABSOLUTE_LAMMPS_SOURCE_DIR} --object-directory=${CMAKE_BINARY_DIR} -o ${COVERAGE_HTML_DIR}/index.html
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Generating HTML Coverage Report..."
|
||||
COMMENT "Generating HTML coverage report..."
|
||||
)
|
||||
add_dependencies(gen_coverage_html coverage_html_folder)
|
||||
|
||||
add_custom_target(clean_coverage_html
|
||||
${CMAKE_COMMAND} -E remove_directory ${COVERAGE_HTML_DIR}
|
||||
COMMENT "Deleting HTML coverage report..."
|
||||
)
|
||||
|
||||
add_custom_target(reset_coverage
|
||||
${CMAKE_COMMAND} -E remove -f */*.gcda */*/*.gcda */*/*/*.gcda
|
||||
*/*/*/*/*.gcda */*/*/*/*/*.gcda */*/*/*/*/*/*.gcda
|
||||
*/*/*/*/*/*/*/*.gcda */*/*/*/*/*/*/*/*.gcda
|
||||
*/*/*/*/*/*/*/*/*/*.gcda */*/*/*/*/*/*/*/*/*/*.gcda
|
||||
WORKIND_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Deleting coverage data files..."
|
||||
)
|
||||
add_dependencies(reset_coverage clean_coverage_html)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -107,7 +107,7 @@ re-compile and relink the LAMMPS executable with ``cmake --build .`` (or
|
||||
``cmake .`` and then compile again. The included dependency tracking
|
||||
should make certain that only the necessary subset of files are
|
||||
re-compiled. You can also delete compiled objects, libraries and
|
||||
executables with ``cmake --build . clean`` (or ``make clean``).
|
||||
executables with ``cmake --build . --target clean`` (or ``make clean``).
|
||||
|
||||
After compilation, you may optionally install the LAMMPS executable into
|
||||
your system with:
|
||||
|
||||
@ -75,9 +75,9 @@ The unit testing facility is integrated into the CMake build process
|
||||
of the LAMMPS source code distribution itself. It can be enabled by
|
||||
setting ``-D ENABLE_TESTING=on`` during the CMake configuration step.
|
||||
It requires the `YAML <http://pyyaml.org/>`_ library and development
|
||||
headers to compile and will download and compile the
|
||||
headers to compile and will download and compile a recent version of the
|
||||
`Googletest <https://github.com/google/googletest/>`_ C++ test framework
|
||||
for programming the tests.
|
||||
for implementing the tests.
|
||||
|
||||
After compilation is complete, the unit testing is started in the build
|
||||
folder using the ``ctest`` command, which is part of the CMake software.
|
||||
@ -100,6 +100,30 @@ The output of this command will be looking something like this::
|
||||
|
||||
Total Test time (real) = 0.27 sec
|
||||
|
||||
|
||||
The ``ctest`` command has many options, the most important ones are:
|
||||
|
||||
.. list-table::
|
||||
|
||||
* - Option
|
||||
- Function
|
||||
* - -V
|
||||
- verbose output: display output of individual test runs
|
||||
* - -j <num>
|
||||
- parallel run: run <num> tests in parallel
|
||||
* - -R <regex>
|
||||
- run subset of tests matching the regular expression <regex>
|
||||
* - -E <regex>
|
||||
- exclude subset of tests matching the regular expression <regex>
|
||||
* - -N
|
||||
- dry-run: display list of tests without running them
|
||||
|
||||
In its full implementation, the unit test framework will consist of multiple
|
||||
kinds of tests implemented in different programming languages (C++, C, Python,
|
||||
Fortran) and testing different aspects of the LAMMPS software and its features.
|
||||
At the moment only tests for "force styles" are implemented. More on those
|
||||
in the next section.
|
||||
|
||||
.. note::
|
||||
|
||||
This unit test framework is new and still under development.
|
||||
@ -114,22 +138,141 @@ The output of this command will be looking something like this::
|
||||
the contents of the YAML files for existing test programs
|
||||
will be provided in time as well.
|
||||
|
||||
------------
|
||||
Unit tests for force styles
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
You can also collect code coverage metrics while running the tests by
|
||||
enabling coverage support during building.
|
||||
A large part of LAMMPS are different "styles" for computing non-bonded
|
||||
and bonded interactions selected through the :doc:`pair_style`,
|
||||
:doc:`bond_style`, :doc:`angle_style`, :doc:`dihedral_style`,
|
||||
:doc:`improper_style`, and :doc:`kspace_style`. Since these all share
|
||||
common interfaces, it is possible to write generic test programs that
|
||||
will call those common interfaces for small test systems with less than
|
||||
100 atoms and compare the results with pre-recorded reference results.
|
||||
A test run is then a a collection multiple individual test runs each
|
||||
with many comparisons to reference results based on template input
|
||||
files, individual command settings, relative error margins, and
|
||||
reference data stored in a YAML format file with ``.yaml``
|
||||
suffix. Currently the programs ``pair_style``, ``bond_style``, and
|
||||
``angle_style`` are implemented. They will compare forces, energies and
|
||||
(global) stress for all atoms after a ``run 0`` calculation and after a
|
||||
few steps of MD with :doc:`fix nve <fix_nve>`, each in multiple variants
|
||||
with different settings and also for multiple accelerated styles. If a
|
||||
prerequisite style or package is missing, the individual tests are
|
||||
skipped. All tests will be executed on a single MPI process, so using
|
||||
the CMake option ``-D BUILD_MPI=off`` can significantly speed up testing,
|
||||
since this will skip the MPI initialization for each test run.
|
||||
Below is an example command and output:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
[tests]$ pair_style mol-pair-lj_cut.yaml
|
||||
[==========] Running 6 tests from 1 test suite.
|
||||
[----------] Global test environment set-up.
|
||||
[----------] 6 tests from PairStyle
|
||||
[ RUN ] PairStyle.plain
|
||||
[ OK ] PairStyle.plain (24 ms)
|
||||
[ RUN ] PairStyle.omp
|
||||
[ OK ] PairStyle.omp (18 ms)
|
||||
[ RUN ] PairStyle.intel
|
||||
[ OK ] PairStyle.intel (6 ms)
|
||||
[ RUN ] PairStyle.opt
|
||||
[ SKIPPED ] PairStyle.opt (0 ms)
|
||||
[ RUN ] PairStyle.single
|
||||
[ OK ] PairStyle.single (7 ms)
|
||||
[ RUN ] PairStyle.extract
|
||||
[ OK ] PairStyle.extract (6 ms)
|
||||
[----------] 6 tests from PairStyle (62 ms total)
|
||||
|
||||
[----------] Global test environment tear-down
|
||||
[==========] 6 tests from 1 test suite ran. (63 ms total)
|
||||
[ PASSED ] 5 tests.
|
||||
[ SKIPPED ] 1 test, listed below:
|
||||
[ SKIPPED ] PairStyle.opt
|
||||
|
||||
In this particular case, 5 out of 6 sets of tests were conducted, the
|
||||
tests for the ``lj/cut/opt`` pair style was skipped, since the tests
|
||||
executable did not include it. To learn what individual tests are performed,
|
||||
you (currently) need to read the source code. You can use code coverage
|
||||
recording (see next section) to confirm how well the tests cover the individual
|
||||
source files.
|
||||
|
||||
The force style test programs have a common set of options:
|
||||
|
||||
.. list-table::
|
||||
|
||||
* - Option
|
||||
- Function
|
||||
* - -g <newfile>
|
||||
- regenerate reference data in new YAML file
|
||||
* - -u
|
||||
- update reference data in the original YAML file
|
||||
* - -s
|
||||
- print error statistics for each group of comparisons
|
||||
* - -v
|
||||
- verbose output: also print the executed LAMMPS commands
|
||||
|
||||
To add a test for a style that is not yet covered, it is usually best
|
||||
to copy a YAML file for a similar style to a new file, edit the details
|
||||
of the style (how to call it, how to set its coefficients) and then
|
||||
run test command with either the *-g* and the replace the initial
|
||||
test file with the regenerated one or the *-u* option. The *-u* option
|
||||
will destroy the original file, if the generation run does not complete,
|
||||
so using *-g* is recommended unless the YAML file is fully tested
|
||||
and working.
|
||||
|
||||
.. admonition:: Recommendations and notes for YAML files
|
||||
:class: note
|
||||
|
||||
- The reference results should be recorded without any code
|
||||
optimization or related compiler flags enabled.
|
||||
- The ``epsilon`` parameter defines the relative precision with which
|
||||
the reference results must be met. The test geometries often have
|
||||
high and low energy parts and thus a significant impact from
|
||||
floating-point math truncation errors is to be expected. Some
|
||||
functional forms and potentials are more noisy than others, so this
|
||||
parameter needs to be adjusted. Typically a value around 1.0e-13
|
||||
can be used, but it may need to be as large as 1.0e-8 in some
|
||||
cases.
|
||||
- The tests for pair styles from OPT, USER-OMP and USER-INTEL are
|
||||
performed with automatically rescaled epsilon to account for
|
||||
additional loss of precision from code optimizations and different
|
||||
summation orders.
|
||||
- When compiling with aggressive compiler optimization, some tests
|
||||
are likely to fail. It is recommended to inspect the individual
|
||||
tests in detail to decide whether the specific error for a specific
|
||||
property is acceptable (it often is), or this may be an indication
|
||||
of mis-compiled code (or undesired large of precision due to
|
||||
reordering of operations).
|
||||
|
||||
Collect and visualize code coverage metrics
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
You can also collect code coverage metrics while running LAMMPS or the
|
||||
tests by enabling code coverage support during the CMake configuration:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
-D ENABLE_COVERAGE=value # enable coverage measurements, value = no (default) or yes
|
||||
-D ENABLE_COVERAGE=on # enable coverage measurements (off by default)
|
||||
|
||||
This will also add the following targets to generate coverage reports
|
||||
after running the LAMMPS executable or the unit tests:
|
||||
This will instrument all object files to write information about which
|
||||
lines of code were accessed during execution in files next to the
|
||||
corresponding object files. These can be post-processed to visually
|
||||
show the degree of coverage and which code paths are accessed and which
|
||||
are not taken. When working on unit tests (see above), this can be
|
||||
extremely helpful to determine which parts of the code are not executed
|
||||
and thus what kind of tests are still missing. The coverage data is
|
||||
cumulative, i.e. new data is added with each new run.
|
||||
|
||||
Enabling code coverage will also add the following build targets to
|
||||
generate coverage reports after running the LAMMPS executable or the
|
||||
unit tests:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
make gen_coverage_html # generate coverage report in HTML format
|
||||
make gen_coverage_xml # generate coverage report in XML format
|
||||
make clean_coverage_html # delete folder with HTML format coverage report
|
||||
make reset_coverage # delete all collected coverage data and HTML output
|
||||
|
||||
These reports require `GCOVR <https://gcovr.com/>`_ to be installed. The easiest way
|
||||
to do this to install it via pip:
|
||||
@ -137,3 +280,29 @@ to do this to install it via pip:
|
||||
.. code-block:: bash
|
||||
|
||||
pip install git+https://github.com/gcovr/gcovr.git
|
||||
|
||||
After post-processing with ``gen_coverage_html`` the results are in
|
||||
a folder ``coverage_html`` and can be viewed with a web browser.
|
||||
The images below illustrate how the data is presented.
|
||||
|
||||
.. list-table::
|
||||
|
||||
* - .. figure:: JPG/coverage-overview-top.png
|
||||
:target: JPG/coverage-overview-top.png
|
||||
|
||||
Top of the overview page
|
||||
|
||||
- .. figure:: JPG/coverage-overview-manybody.png
|
||||
:target: JPG/coverage-overview-manybody.png
|
||||
|
||||
Styles with good coverage
|
||||
|
||||
- .. figure:: JPG/coverage-file-top.png
|
||||
:target: JPG/coverage-file-top.png
|
||||
|
||||
Top of individual source page
|
||||
|
||||
- .. figure:: JPG/coverage-file-branches.png
|
||||
:target: JPG/coverage-file-branches.png
|
||||
|
||||
Source page with branches
|
||||
|
||||
@ -92,8 +92,8 @@ OPT.
|
||||
* :doc:`drip <pair_drip>`
|
||||
* :doc:`eam (gikot) <pair_eam>`
|
||||
* :doc:`eam/alloy (gikot) <pair_eam>`
|
||||
* :doc:`eam/cd (o) <pair_eam>`
|
||||
* :doc:`eam/cd/old (o) <pair_eam>`
|
||||
* :doc:`eam/cd <pair_eam>`
|
||||
* :doc:`eam/cd/old <pair_eam>`
|
||||
* :doc:`eam/fs (gikot) <pair_eam>`
|
||||
* :doc:`edip (o) <pair_edip>`
|
||||
* :doc:`edip/multi <pair_edip>`
|
||||
|
||||
@ -415,8 +415,10 @@ This is particularly convenient, if you have set a custom build command
|
||||
via the ``CMAKE_MAKE_PROGRAM`` variable.
|
||||
|
||||
When calling the build program, you can also select which "target" is to
|
||||
be build through appending the name of the target to the build command.
|
||||
Example: ``cmake --build . all``. The following abstract targets are available:
|
||||
be build through appending the ``--target`` flag and the name of the target
|
||||
to the build command. When using ``make`` as build tool, you can just append
|
||||
the target name to the command. Example: ``cmake --build . --target all`` or
|
||||
``make all``. The following abstract targets are available:
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
@ -432,7 +434,7 @@ Example: ``cmake --build . all``. The following abstract targets are available:
|
||||
* - ``install``
|
||||
- install all target files into folders in ``CMAKE_INSTALL_PREFIX``
|
||||
* - ``test``
|
||||
- run some simple tests (if configured with ``-D ENABLE_TESTING=on``)
|
||||
- run some tests (if configured with ``-D ENABLE_TESTING=on``)
|
||||
* - ``clean``
|
||||
- remove all generated files
|
||||
|
||||
|
||||
BIN
doc/src/JPG/coverage-file-branches.png
Normal file
BIN
doc/src/JPG/coverage-file-branches.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 153 KiB |
BIN
doc/src/JPG/coverage-file-top.png
Normal file
BIN
doc/src/JPG/coverage-file-top.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 110 KiB |
BIN
doc/src/JPG/coverage-overview-manybody.png
Normal file
BIN
doc/src/JPG/coverage-overview-manybody.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 302 KiB |
BIN
doc/src/JPG/coverage-overview-top.png
Normal file
BIN
doc/src/JPG/coverage-overview-top.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 238 KiB |
@ -39,15 +39,9 @@ pair_style eam/alloy/opt command
|
||||
pair_style eam/cd command
|
||||
=========================
|
||||
|
||||
pair_style eam/cd/omp command
|
||||
=============================
|
||||
|
||||
pair_style eam/cd/old command
|
||||
=============================
|
||||
|
||||
pair_style eam/cd/old/omp command
|
||||
=================================
|
||||
|
||||
pair_style eam/fs command
|
||||
=========================
|
||||
|
||||
|
||||
@ -1984,6 +1984,7 @@ Neumann
|
||||
Nevent
|
||||
nevery
|
||||
Nevery
|
||||
newfile
|
||||
Newns
|
||||
newtype
|
||||
Neyts
|
||||
|
||||
@ -19,13 +19,13 @@
|
||||
# 27 entries for a system containing three elements A, B and C
|
||||
# These entries are in LAMMPS "metal" units
|
||||
#
|
||||
Hf Hf Hf 1 0 1 0 1.011011 0.046511 0.959614 0.959614 55.9421 55.9421 3.85 0.20 2.069563 2.069563 707.53 707.53 0 0 0.008 0 0 0 1 1 1 1 -4 4 0.26152 -0.25918 -4 4 0.26152 -0.25918 0 3.139520d0 0 0.009410d0 0 0.679131 -3.92875 -3.92875 4.83958 4.83958 12 0
|
||||
Hf Hf Hf 1 0 1 0 1.011011 0.046511 0.959614 0.959614 55.9421 55.9421 3.85 0.20 2.069563 2.069563 707.53 707.53 0 0 0.008 0 0 0 1 1 1 1 -4 4 0.26152 -0.25918 -4 4 0.26152 -0.25918 0 3.139520 0 0.009410 0 0.679131 -3.92875 -3.92875 4.83958 4.83958 12 0
|
||||
Ti Ti Ti 1 0 1 0 1.255016 0.089078 1.226342 1.226342 99.3916 99.3916 3.43 0.05 2.082408 2.082408 546.386 546.386 0 0 0.0084 0 0 0 1 1 1 1 -4 4 2.508854 -2.511416 -4 4 2.508854 -2.511416 0 2.46820415900968 0 0.151351003255176 0 0.873685 0.392632 0.392632 1.78349 1.78349 12 0
|
||||
O O O 1 6.6 1 -0.229 1 2 2.68 2.68 260.893 260.893 2.8 0.2 5.36 5.36 3326.69 3326.69 0 0 0 0 0 0 1 1 1 1 -1.8349 5.5046 0.00148 -0.00112 -1.8349 5.5046 0.00148 -0.00112 5.63441383 7.689598017 4.51426991 1.330079082 0 2.243072 -3.922011 -3.922011 0.971086 0.971086 12 0
|
||||
Cu Cu Cu 1 0 1 0 1 0.140835 1.681711 1.681711 146.987 146.987 3.0 0.05 2.794608 2.794608 952.693 952.693 0.077 0.0095 0 0 0 0 1 1 1 1 -6 2 0.1677645 -0.161007 -6 2 0.1677645 -0.161007 0 5.946437 0 0 0 0.454784 0.72571 0.72571 0.274649 0.274649 12 0
|
||||
Si Si Si 3 100390 16.218 -0.59826 0.78734 1.0999E-06 1.7322 1.7322 471.18 471.18 2.90 0.10 2.4799 2.4799 1830.8 1830.8 0 0 0 0 0 0 1 1 1 1 -4 4 1.651725 -1.658949 -4 4 1.651725 -1.658949 0 3.625144859 0 0.087067714 0 0.772871 -0.499378 -0.499378 2.999911 2.999911 12 0
|
||||
Zr Zr Zr 1 0 1 0 1 0 0.929 0.929 39.9454 39.9454 3.8 0.31 1.857 1.857 382.6 382.6 0 0 0 0 0 0 1 1 1 1 -4 4 1.64 -1.5 -4 4 1.64 -1.5 0 3.139520d0 0 0.009410d0 0 0.679131 -3.92875 -3.92875 4.83958 4.83958 12 0
|
||||
U U U 1 0 1 0 4.346966 0.77617 0.832 0.832 162.6 162.6 3.9 0.15 1.835 1.835 795.6 795.6 0 0 0 0 0 0 1 1 1 1 -4 4 2 -2 -4 4 2 -2 0 3.139520d0 0 0.009410d0 0 0.679131 -3.92875 -3.92875 4.83958 4.83958 12 0
|
||||
Zr Zr Zr 1 0 1 0 1 0 0.929 0.929 39.9454 39.9454 3.8 0.31 1.857 1.857 382.6 382.6 0 0 0 0 0 0 1 1 1 1 -4 4 1.64 -1.5 -4 4 1.64 -1.5 0 3.139520 0 0.009410 0 0.679131 -3.92875 -3.92875 4.83958 4.83958 12 0
|
||||
U U U 1 0 1 0 4.346966 0.77617 0.832 0.832 162.6 162.6 3.9 0.15 1.835 1.835 795.6 795.6 0 0 0 0 0 0 1 1 1 1 -4 4 2 -2 -4 4 2 -2 0 3.139520 0 0.009410 0 0.679131 -3.92875 -3.92875 4.83958 4.83958 12 0
|
||||
#
|
||||
Si O O 3 100390 16.218 -0.59826 0.78734 1.0999E-06 1.7322 2.68 471.18 260.893 2.80 0.25 2.4799 5.36 1830.8 3326.69 0 0 0 109.47 0.3122 0 1 1 1 1 -4 4 1.651725 -1.658949 -1.8349 5.5046 0.00148 -0.00112 0 3.625144859 0 0.087067714 0 0.772871 -0.499378 -3.922011 2.999911 0.971086 12 0
|
||||
O Si Si 1 6.6 1 -0.229 1 2 2.68 1.7322 260.893 471.18 2.80 0.25 5.36 2.4799 3326.69 1830.8 0 0 0 143.73 2.6 0 1 1 1 1 -1.8349 5.5046 0.00148 -0.00112 -4 4 1.651725 -1.658949 5.63441383 7.689598017 4.51426991 1.330079082 0 2.243072 -3.922011 -0.499378 0.971086 2.999911 12 0
|
||||
|
||||
@ -31,11 +31,11 @@
|
||||
#include "domain.h"
|
||||
#include "utils.h"
|
||||
#include "suffix.h"
|
||||
#include "tokenizer.h"
|
||||
#include "potential_file_reader.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define MAXLINE 1024
|
||||
|
||||
// External functions from cuda library for atom decomposition
|
||||
|
||||
int eam_alloy_gpu_init(const int ntypes, double host_cutforcesq,
|
||||
@ -369,94 +369,112 @@ void PairEAMAlloyGPU::read_file(char *filename)
|
||||
{
|
||||
Setfl *file = setfl;
|
||||
|
||||
// open potential file
|
||||
// read potential file
|
||||
if(comm->me == 0) {
|
||||
PotentialFileReader reader(lmp, filename, "EAM");
|
||||
|
||||
int me = comm->me;
|
||||
FILE *fptr;
|
||||
char line[MAXLINE];
|
||||
try {
|
||||
char * line = nullptr;
|
||||
|
||||
if (me == 0) {
|
||||
fptr = fopen(filename,"r");
|
||||
if (fptr == NULL) {
|
||||
char str[128];
|
||||
snprintf(str,128,"Cannot open EAM potential file %s",filename);
|
||||
error->one(FLERR,str);
|
||||
}
|
||||
}
|
||||
reader.skip_line();
|
||||
reader.skip_line();
|
||||
reader.skip_line();
|
||||
|
||||
// read and broadcast header
|
||||
// extract element names from nelements line
|
||||
line = reader.next_line(1);
|
||||
ValueTokenizer values(line);
|
||||
file->nelements = values.next_int();
|
||||
|
||||
int n;
|
||||
if (me == 0) {
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error);
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error);
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error);
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error);
|
||||
n = strlen(line) + 1;
|
||||
}
|
||||
MPI_Bcast(&n,1,MPI_INT,0,world);
|
||||
MPI_Bcast(line,n,MPI_CHAR,0,world);
|
||||
|
||||
sscanf(line,"%d",&file->nelements);
|
||||
int nwords = atom->count_words(line);
|
||||
if (nwords != file->nelements + 1)
|
||||
error->all(FLERR,"Incorrect element names in EAM potential file");
|
||||
|
||||
char **words = new char*[file->nelements+1];
|
||||
nwords = 0;
|
||||
strtok(line," \t\n\r\f");
|
||||
while ( (words[nwords++] = strtok(NULL," \t\n\r\f")) ) continue;
|
||||
if (values.count() != file->nelements + 1)
|
||||
error->one(FLERR,"Incorrect element names in EAM potential file");
|
||||
|
||||
file->elements = new char*[file->nelements];
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
n = strlen(words[i]) + 1;
|
||||
const std::string word = values.next_string();
|
||||
const int n = word.length() + 1;
|
||||
file->elements[i] = new char[n];
|
||||
strcpy(file->elements[i],words[i]);
|
||||
strcpy(file->elements[i], word.c_str());
|
||||
}
|
||||
delete [] words;
|
||||
|
||||
if (me == 0) {
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error);
|
||||
sscanf(line,"%d %lg %d %lg %lg",
|
||||
&file->nrho,&file->drho,&file->nr,&file->dr,&file->cut);
|
||||
//
|
||||
|
||||
line = reader.next_line(5);
|
||||
values = ValueTokenizer(line);
|
||||
file->nrho = values.next_int();
|
||||
file->drho = values.next_double();
|
||||
file->nr = values.next_int();
|
||||
file->dr = values.next_double();
|
||||
file->cut = values.next_double();
|
||||
|
||||
if ((file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0))
|
||||
error->one(FLERR,"Invalid EAM potential file");
|
||||
|
||||
memory->create(file->mass, file->nelements, "pair:mass");
|
||||
memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho");
|
||||
memory->create(file->rhor, file->nelements, file->nr + 1, "pair:rhor");
|
||||
memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r");
|
||||
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
line = reader.next_line(2);
|
||||
values = ValueTokenizer(line);
|
||||
values.next_int(); // ignore
|
||||
file->mass[i] = values.next_double();
|
||||
|
||||
reader.next_dvector(file->nrho, &file->frho[i][1]);
|
||||
reader.next_dvector(file->nr, &file->rhor[i][1]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
for (int j = 0; j <= i; j++) {
|
||||
reader.next_dvector(file->nr, &file->z2r[i][j][1]);
|
||||
}
|
||||
}
|
||||
} catch (TokenizerException & e) {
|
||||
error->one(FLERR, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
// broadcast potential information
|
||||
MPI_Bcast(&file->nelements, 1, MPI_INT, 0, world);
|
||||
|
||||
MPI_Bcast(&file->nrho, 1, MPI_INT, 0, world);
|
||||
MPI_Bcast(&file->drho, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&file->nr, 1, MPI_INT, 0, world);
|
||||
MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world);
|
||||
|
||||
file->mass = new double[file->nelements];
|
||||
// allocate memory on other procs
|
||||
if (comm->me != 0) {
|
||||
file->elements = new char*[file->nelements];
|
||||
for (int i = 0; i < file->nelements; i++) file->elements[i] = nullptr;
|
||||
memory->create(file->mass, file->nelements, "pair:mass");
|
||||
memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho");
|
||||
memory->create(file->rhor, file->nelements, file->nr + 1, "pair:rhor");
|
||||
memory->create(file->z2r,file->nelements,file->nelements,file->nr+1,
|
||||
"pair:z2r");
|
||||
|
||||
int i,j,tmp;
|
||||
for (i = 0; i < file->nelements; i++) {
|
||||
if (me == 0) {
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error);
|
||||
sscanf(line,"%d %lg",&tmp,&file->mass[i]);
|
||||
memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r");
|
||||
}
|
||||
MPI_Bcast(&file->mass[i],1,MPI_DOUBLE,0,world);
|
||||
|
||||
if (me == 0) grab(fptr,file->nrho,&file->frho[i][1]);
|
||||
// broadcast file->elements string array
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
int n;
|
||||
if (comm->me == 0) n = strlen(file->elements[i]) + 1;
|
||||
MPI_Bcast(&n, 1, MPI_INT, 0, world);
|
||||
if (comm->me != 0) file->elements[i] = new char[n];
|
||||
MPI_Bcast(file->elements[i], n, MPI_CHAR, 0, world);
|
||||
}
|
||||
|
||||
// broadcast file->mass, frho, rhor
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
MPI_Bcast(&file->mass[i], 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&file->frho[i][1], file->nrho, MPI_DOUBLE, 0, world);
|
||||
if (me == 0) grab(fptr,file->nr,&file->rhor[i][1]);
|
||||
MPI_Bcast(&file->rhor[i][1], file->nr, MPI_DOUBLE, 0, world);
|
||||
}
|
||||
|
||||
for (i = 0; i < file->nelements; i++)
|
||||
for (j = 0; j <= i; j++) {
|
||||
if (me == 0) grab(fptr,file->nr,&file->z2r[i][j][1]);
|
||||
// broadcast file->z2r
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
for (int j = 0; j <= i; j++) {
|
||||
MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world);
|
||||
}
|
||||
|
||||
// close the potential file
|
||||
|
||||
if (me == 0) fclose(fptr);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
@ -30,11 +30,12 @@
|
||||
#include "gpu_extra.h"
|
||||
#include "domain.h"
|
||||
#include "suffix.h"
|
||||
#include "utils.h"
|
||||
#include "tokenizer.h"
|
||||
#include "potential_file_reader.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define MAXLINE 1024
|
||||
|
||||
// External functions from cuda library for atom decomposition
|
||||
|
||||
int eam_fs_gpu_init(const int ntypes, double host_cutforcesq,
|
||||
@ -368,58 +369,76 @@ void PairEAMFSGPU::read_file(char *filename)
|
||||
{
|
||||
Fs *file = fs;
|
||||
|
||||
// open potential file
|
||||
// read potential file
|
||||
if(comm->me == 0) {
|
||||
PotentialFileReader reader(lmp, filename, "EAM");
|
||||
|
||||
int me = comm->me;
|
||||
FILE *fptr;
|
||||
char line[MAXLINE];
|
||||
try {
|
||||
char * line = nullptr;
|
||||
|
||||
if (me == 0) {
|
||||
fptr = force->open_potential(filename);
|
||||
if (fptr == NULL) {
|
||||
char str[128];
|
||||
snprintf(str,128,"Cannot open EAM potential file %s",filename);
|
||||
error->one(FLERR,str);
|
||||
}
|
||||
}
|
||||
reader.skip_line();
|
||||
reader.skip_line();
|
||||
reader.skip_line();
|
||||
|
||||
// read and broadcast header
|
||||
// extract element names from nelements line
|
||||
line = reader.next_line(1);
|
||||
ValueTokenizer values(line);
|
||||
file->nelements = values.next_int();
|
||||
|
||||
int n;
|
||||
if (me == 0) {
|
||||
fgets(line,MAXLINE,fptr);
|
||||
fgets(line,MAXLINE,fptr);
|
||||
fgets(line,MAXLINE,fptr);
|
||||
fgets(line,MAXLINE,fptr);
|
||||
n = strlen(line) + 1;
|
||||
}
|
||||
MPI_Bcast(&n,1,MPI_INT,0,world);
|
||||
MPI_Bcast(line,n,MPI_CHAR,0,world);
|
||||
|
||||
sscanf(line,"%d",&file->nelements);
|
||||
int nwords = atom->count_words(line);
|
||||
if (nwords != file->nelements + 1)
|
||||
error->all(FLERR,"Incorrect element names in EAM potential file");
|
||||
|
||||
char **words = new char*[file->nelements+1];
|
||||
nwords = 0;
|
||||
strtok(line," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue;
|
||||
if (values.count() != file->nelements + 1)
|
||||
error->one(FLERR,"Incorrect element names in EAM potential file");
|
||||
|
||||
file->elements = new char*[file->nelements];
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
n = strlen(words[i]) + 1;
|
||||
const std::string word = values.next_string();
|
||||
const int n = word.length() + 1;
|
||||
file->elements[i] = new char[n];
|
||||
strcpy(file->elements[i],words[i]);
|
||||
strcpy(file->elements[i], word.c_str());
|
||||
}
|
||||
delete [] words;
|
||||
|
||||
if (me == 0) {
|
||||
fgets(line,MAXLINE,fptr);
|
||||
sscanf(line,"%d %lg %d %lg %lg",
|
||||
&file->nrho,&file->drho,&file->nr,&file->dr,&file->cut);
|
||||
//
|
||||
|
||||
line = reader.next_line(5);
|
||||
values = ValueTokenizer(line);
|
||||
file->nrho = values.next_int();
|
||||
file->drho = values.next_double();
|
||||
file->nr = values.next_int();
|
||||
file->dr = values.next_double();
|
||||
file->cut = values.next_double();
|
||||
|
||||
if ((file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0))
|
||||
error->one(FLERR,"Invalid EAM potential file");
|
||||
|
||||
memory->create(file->mass, file->nelements, "pair:mass");
|
||||
memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho");
|
||||
memory->create(file->rhor, file->nelements, file->nelements, file->nr + 1, "pair:rhor");
|
||||
memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r");
|
||||
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
line = reader.next_line(2);
|
||||
values = ValueTokenizer(line);
|
||||
values.next_int(); // ignore
|
||||
file->mass[i] = values.next_double();
|
||||
|
||||
reader.next_dvector(file->nrho, &file->frho[i][1]);
|
||||
|
||||
for (int j = 0; j < file->nelements; j++) {
|
||||
reader.next_dvector(file->nr, &file->rhor[i][j][1]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
for (int j = 0; j <= i; j++) {
|
||||
reader.next_dvector(file->nr, &file->z2r[i][j][1]);
|
||||
}
|
||||
}
|
||||
} catch (TokenizerException & e) {
|
||||
error->one(FLERR, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
// broadcast potential information
|
||||
MPI_Bcast(&file->nelements, 1, MPI_INT, 0, world);
|
||||
|
||||
MPI_Bcast(&file->nrho, 1, MPI_INT, 0, world);
|
||||
MPI_Bcast(&file->drho, 1, MPI_DOUBLE, 0, world);
|
||||
@ -427,40 +446,41 @@ void PairEAMFSGPU::read_file(char *filename)
|
||||
MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world);
|
||||
|
||||
file->mass = new double[file->nelements];
|
||||
memory->create(file->frho,file->nelements,file->nrho+1,
|
||||
"pair:frho");
|
||||
memory->create(file->rhor,file->nelements,file->nelements,
|
||||
file->nr+1,"pair:rhor");
|
||||
memory->create(file->z2r,file->nelements,file->nelements,
|
||||
file->nr+1,"pair:z2r");
|
||||
|
||||
int i,j,tmp;
|
||||
for (i = 0; i < file->nelements; i++) {
|
||||
if (me == 0) {
|
||||
fgets(line,MAXLINE,fptr);
|
||||
sscanf(line,"%d %lg",&tmp,&file->mass[i]);
|
||||
// allocate memory on other procs
|
||||
if (comm->me != 0) {
|
||||
file->elements = new char*[file->nelements];
|
||||
for (int i = 0; i < file->nelements; i++) file->elements[i] = nullptr;
|
||||
memory->create(file->mass, file->nelements, "pair:mass");
|
||||
memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho");
|
||||
memory->create(file->rhor, file->nelements, file->nelements, file->nr + 1, "pair:rhor");
|
||||
memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r");
|
||||
}
|
||||
MPI_Bcast(&file->mass[i],1,MPI_DOUBLE,0,world);
|
||||
|
||||
if (me == 0) grab(fptr,file->nrho,&file->frho[i][1]);
|
||||
// broadcast file->elements string array
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
int n;
|
||||
if (comm->me == 0) n = strlen(file->elements[i]) + 1;
|
||||
MPI_Bcast(&n, 1, MPI_INT, 0, world);
|
||||
if (comm->me != 0) file->elements[i] = new char[n];
|
||||
MPI_Bcast(file->elements[i], n, MPI_CHAR, 0, world);
|
||||
}
|
||||
|
||||
// broadcast file->mass, frho, rhor
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
MPI_Bcast(&file->mass[i], 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&file->frho[i][1], file->nrho, MPI_DOUBLE, 0, world);
|
||||
|
||||
for (j = 0; j < file->nelements; j++) {
|
||||
if (me == 0) grab(fptr,file->nr,&file->rhor[i][j][1]);
|
||||
for (int j = 0; j < file->nelements; j++) {
|
||||
MPI_Bcast(&file->rhor[i][j][1], file->nr, MPI_DOUBLE, 0, world);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < file->nelements; i++)
|
||||
for (j = 0; j <= i; j++) {
|
||||
if (me == 0) grab(fptr,file->nr,&file->z2r[i][j][1]);
|
||||
// broadcast file->z2r
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
for (int j = 0; j <= i; j++) {
|
||||
MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world);
|
||||
}
|
||||
|
||||
// close the potential file
|
||||
|
||||
if (me == 0) fclose(fptr);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
@ -464,7 +464,8 @@ void kimProperty::command(int narg, char **arg)
|
||||
error->one(FLERR, "Error Python `kim_property_dump` function "
|
||||
"evaluation failed!");
|
||||
}
|
||||
}
|
||||
} else
|
||||
pValue = NULL;
|
||||
|
||||
// Destroy the variable
|
||||
kim_str_cmd[1] = const_cast<char *>("delete");
|
||||
|
||||
@ -29,11 +29,12 @@
|
||||
#include "memory_kokkos.h"
|
||||
#include "error.h"
|
||||
#include "atom_masks.h"
|
||||
#include "utils.h"
|
||||
#include "tokenizer.h"
|
||||
#include "potential_file_reader.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define MAXLINE 1024
|
||||
|
||||
// Cannot use virtual inheritance on the GPU, so must duplicate code
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -982,94 +983,112 @@ void PairEAMAlloyKokkos<DeviceType>::read_file(char *filename)
|
||||
{
|
||||
Setfl *file = setfl;
|
||||
|
||||
// open potential file
|
||||
// read potential file
|
||||
if(comm->me == 0) {
|
||||
PotentialFileReader reader(lmp, filename, "EAM");
|
||||
|
||||
int me = comm->me;
|
||||
FILE *fptr;
|
||||
char line[MAXLINE];
|
||||
try {
|
||||
char * line = nullptr;
|
||||
|
||||
if (me == 0) {
|
||||
fptr = force->open_potential(filename);
|
||||
if (fptr == NULL) {
|
||||
char str[128];
|
||||
snprintf(str,128,"Cannot open EAM potential file %s",filename);
|
||||
error->one(FLERR,str);
|
||||
}
|
||||
}
|
||||
reader.skip_line();
|
||||
reader.skip_line();
|
||||
reader.skip_line();
|
||||
|
||||
// read and broadcast header
|
||||
// extract element names from nelements line
|
||||
line = reader.next_line(1);
|
||||
ValueTokenizer values(line);
|
||||
file->nelements = values.next_int();
|
||||
|
||||
int n;
|
||||
if (me == 0) {
|
||||
fgets(line,MAXLINE,fptr);
|
||||
fgets(line,MAXLINE,fptr);
|
||||
fgets(line,MAXLINE,fptr);
|
||||
fgets(line,MAXLINE,fptr);
|
||||
n = strlen(line) + 1;
|
||||
}
|
||||
MPI_Bcast(&n,1,MPI_INT,0,world);
|
||||
MPI_Bcast(line,n,MPI_CHAR,0,world);
|
||||
|
||||
sscanf(line,"%d",&file->nelements);
|
||||
int nwords = atom->count_words(line);
|
||||
if (nwords != file->nelements + 1)
|
||||
error->all(FLERR,"Incorrect element names in EAM potential file");
|
||||
|
||||
char **words = new char*[file->nelements+1];
|
||||
nwords = 0;
|
||||
strtok(line," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue;
|
||||
if (values.count() != file->nelements + 1)
|
||||
error->one(FLERR,"Incorrect element names in EAM potential file");
|
||||
|
||||
file->elements = new char*[file->nelements];
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
n = strlen(words[i]) + 1;
|
||||
const std::string word = values.next_string();
|
||||
const int n = word.length() + 1;
|
||||
file->elements[i] = new char[n];
|
||||
strcpy(file->elements[i],words[i]);
|
||||
strcpy(file->elements[i], word.c_str());
|
||||
}
|
||||
delete [] words;
|
||||
|
||||
if (me == 0) {
|
||||
fgets(line,MAXLINE,fptr);
|
||||
sscanf(line,"%d %lg %d %lg %lg",
|
||||
&file->nrho,&file->drho,&file->nr,&file->dr,&file->cut);
|
||||
//
|
||||
|
||||
line = reader.next_line(5);
|
||||
values = ValueTokenizer(line);
|
||||
file->nrho = values.next_int();
|
||||
file->drho = values.next_double();
|
||||
file->nr = values.next_int();
|
||||
file->dr = values.next_double();
|
||||
file->cut = values.next_double();
|
||||
|
||||
if ((file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0))
|
||||
error->one(FLERR,"Invalid EAM potential file");
|
||||
|
||||
memory->create(file->mass, file->nelements, "pair:mass");
|
||||
memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho");
|
||||
memory->create(file->rhor, file->nelements, file->nr + 1, "pair:rhor");
|
||||
memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r");
|
||||
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
line = reader.next_line(2);
|
||||
values = ValueTokenizer(line);
|
||||
values.next_int(); // ignore
|
||||
file->mass[i] = values.next_double();
|
||||
|
||||
reader.next_dvector(file->nrho, &file->frho[i][1]);
|
||||
reader.next_dvector(file->nr, &file->rhor[i][1]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
for (int j = 0; j <= i; j++) {
|
||||
reader.next_dvector(file->nr, &file->z2r[i][j][1]);
|
||||
}
|
||||
}
|
||||
} catch (TokenizerException & e) {
|
||||
error->one(FLERR, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
// broadcast potential information
|
||||
MPI_Bcast(&file->nelements, 1, MPI_INT, 0, world);
|
||||
|
||||
MPI_Bcast(&file->nrho, 1, MPI_INT, 0, world);
|
||||
MPI_Bcast(&file->drho, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&file->nr, 1, MPI_INT, 0, world);
|
||||
MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world);
|
||||
|
||||
file->mass = new double[file->nelements];
|
||||
// allocate memory on other procs
|
||||
if (comm->me != 0) {
|
||||
file->elements = new char*[file->nelements];
|
||||
for (int i = 0; i < file->nelements; i++) file->elements[i] = nullptr;
|
||||
memory->create(file->mass, file->nelements, "pair:mass");
|
||||
memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho");
|
||||
memory->create(file->rhor, file->nelements, file->nr + 1, "pair:rhor");
|
||||
memory->create(file->z2r,file->nelements,file->nelements,file->nr+1,
|
||||
"pair:z2r");
|
||||
|
||||
int i,j,tmp;
|
||||
for (i = 0; i < file->nelements; i++) {
|
||||
if (me == 0) {
|
||||
fgets(line,MAXLINE,fptr);
|
||||
sscanf(line,"%d %lg",&tmp,&file->mass[i]);
|
||||
memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r");
|
||||
}
|
||||
MPI_Bcast(&file->mass[i],1,MPI_DOUBLE,0,world);
|
||||
|
||||
if (me == 0) grab(fptr,file->nrho,&file->frho[i][1]);
|
||||
// broadcast file->elements string array
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
int n;
|
||||
if (comm->me == 0) n = strlen(file->elements[i]) + 1;
|
||||
MPI_Bcast(&n, 1, MPI_INT, 0, world);
|
||||
if (comm->me != 0) file->elements[i] = new char[n];
|
||||
MPI_Bcast(file->elements[i], n, MPI_CHAR, 0, world);
|
||||
}
|
||||
|
||||
// broadcast file->mass, frho, rhor
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
MPI_Bcast(&file->mass[i], 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&file->frho[i][1], file->nrho, MPI_DOUBLE, 0, world);
|
||||
if (me == 0) grab(fptr,file->nr,&file->rhor[i][1]);
|
||||
MPI_Bcast(&file->rhor[i][1], file->nr, MPI_DOUBLE, 0, world);
|
||||
}
|
||||
|
||||
for (i = 0; i < file->nelements; i++)
|
||||
for (j = 0; j <= i; j++) {
|
||||
if (me == 0) grab(fptr,file->nr,&file->z2r[i][j][1]);
|
||||
// broadcast file->z2r
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
for (int j = 0; j <= i; j++) {
|
||||
MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world);
|
||||
}
|
||||
|
||||
// close the potential file
|
||||
|
||||
if (me == 0) fclose(fptr);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
@ -29,11 +29,12 @@
|
||||
#include "memory_kokkos.h"
|
||||
#include "error.h"
|
||||
#include "atom_masks.h"
|
||||
#include "utils.h"
|
||||
#include "tokenizer.h"
|
||||
#include "potential_file_reader.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define MAXLINE 1024
|
||||
|
||||
// Cannot use virtual inheritance on the GPU, so must duplicate code
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -982,58 +983,76 @@ void PairEAMFSKokkos<DeviceType>::read_file(char *filename)
|
||||
{
|
||||
Fs *file = fs;
|
||||
|
||||
// open potential file
|
||||
// read potential file
|
||||
if(comm->me == 0) {
|
||||
PotentialFileReader reader(lmp, filename, "EAM");
|
||||
|
||||
int me = comm->me;
|
||||
FILE *fptr;
|
||||
char line[MAXLINE];
|
||||
try {
|
||||
char * line = nullptr;
|
||||
|
||||
if (me == 0) {
|
||||
fptr = force->open_potential(filename);
|
||||
if (fptr == NULL) {
|
||||
char str[128];
|
||||
snprintf(str,128,"Cannot open EAM potential file %s",filename);
|
||||
error->one(FLERR,str);
|
||||
}
|
||||
}
|
||||
reader.skip_line();
|
||||
reader.skip_line();
|
||||
reader.skip_line();
|
||||
|
||||
// read and broadcast header
|
||||
// extract element names from nelements line
|
||||
line = reader.next_line(1);
|
||||
ValueTokenizer values(line);
|
||||
file->nelements = values.next_int();
|
||||
|
||||
int n;
|
||||
if (me == 0) {
|
||||
fgets(line,MAXLINE,fptr);
|
||||
fgets(line,MAXLINE,fptr);
|
||||
fgets(line,MAXLINE,fptr);
|
||||
fgets(line,MAXLINE,fptr);
|
||||
n = strlen(line) + 1;
|
||||
}
|
||||
MPI_Bcast(&n,1,MPI_INT,0,world);
|
||||
MPI_Bcast(line,n,MPI_CHAR,0,world);
|
||||
|
||||
sscanf(line,"%d",&file->nelements);
|
||||
int nwords = atom->count_words(line);
|
||||
if (nwords != file->nelements + 1)
|
||||
error->all(FLERR,"Incorrect element names in EAM potential file");
|
||||
|
||||
char **words = new char*[file->nelements+1];
|
||||
nwords = 0;
|
||||
strtok(line," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue;
|
||||
if (values.count() != file->nelements + 1)
|
||||
error->one(FLERR,"Incorrect element names in EAM potential file");
|
||||
|
||||
file->elements = new char*[file->nelements];
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
n = strlen(words[i]) + 1;
|
||||
const std::string word = values.next_string();
|
||||
const int n = word.length() + 1;
|
||||
file->elements[i] = new char[n];
|
||||
strcpy(file->elements[i],words[i]);
|
||||
strcpy(file->elements[i], word.c_str());
|
||||
}
|
||||
delete [] words;
|
||||
|
||||
if (me == 0) {
|
||||
fgets(line,MAXLINE,fptr);
|
||||
sscanf(line,"%d %lg %d %lg %lg",
|
||||
&file->nrho,&file->drho,&file->nr,&file->dr,&file->cut);
|
||||
//
|
||||
|
||||
line = reader.next_line(5);
|
||||
values = ValueTokenizer(line);
|
||||
file->nrho = values.next_int();
|
||||
file->drho = values.next_double();
|
||||
file->nr = values.next_int();
|
||||
file->dr = values.next_double();
|
||||
file->cut = values.next_double();
|
||||
|
||||
if ((file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0))
|
||||
error->one(FLERR,"Invalid EAM potential file");
|
||||
|
||||
memory->create(file->mass, file->nelements, "pair:mass");
|
||||
memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho");
|
||||
memory->create(file->rhor, file->nelements, file->nelements, file->nr + 1, "pair:rhor");
|
||||
memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r");
|
||||
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
line = reader.next_line(2);
|
||||
values = ValueTokenizer(line);
|
||||
values.next_int(); // ignore
|
||||
file->mass[i] = values.next_double();
|
||||
|
||||
reader.next_dvector(file->nrho, &file->frho[i][1]);
|
||||
|
||||
for (int j = 0; j < file->nelements; j++) {
|
||||
reader.next_dvector(file->nr, &file->rhor[i][j][1]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
for (int j = 0; j <= i; j++) {
|
||||
reader.next_dvector(file->nr, &file->z2r[i][j][1]);
|
||||
}
|
||||
}
|
||||
} catch (TokenizerException & e) {
|
||||
error->one(FLERR, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
// broadcast potential information
|
||||
MPI_Bcast(&file->nelements, 1, MPI_INT, 0, world);
|
||||
|
||||
MPI_Bcast(&file->nrho, 1, MPI_INT, 0, world);
|
||||
MPI_Bcast(&file->drho, 1, MPI_DOUBLE, 0, world);
|
||||
@ -1041,40 +1060,41 @@ void PairEAMFSKokkos<DeviceType>::read_file(char *filename)
|
||||
MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world);
|
||||
|
||||
file->mass = new double[file->nelements];
|
||||
memory->create(file->frho,file->nelements,file->nrho+1,
|
||||
"pair:frho");
|
||||
memory->create(file->rhor,file->nelements,file->nelements,
|
||||
file->nr+1,"pair:rhor");
|
||||
memory->create(file->z2r,file->nelements,file->nelements,
|
||||
file->nr+1,"pair:z2r");
|
||||
|
||||
int i,j,tmp;
|
||||
for (i = 0; i < file->nelements; i++) {
|
||||
if (me == 0) {
|
||||
fgets(line,MAXLINE,fptr);
|
||||
sscanf(line,"%d %lg",&tmp,&file->mass[i]);
|
||||
// allocate memory on other procs
|
||||
if (comm->me != 0) {
|
||||
file->elements = new char*[file->nelements];
|
||||
for (int i = 0; i < file->nelements; i++) file->elements[i] = nullptr;
|
||||
memory->create(file->mass, file->nelements, "pair:mass");
|
||||
memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho");
|
||||
memory->create(file->rhor, file->nelements, file->nelements, file->nr + 1, "pair:rhor");
|
||||
memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r");
|
||||
}
|
||||
MPI_Bcast(&file->mass[i],1,MPI_DOUBLE,0,world);
|
||||
|
||||
if (me == 0) grab(fptr,file->nrho,&file->frho[i][1]);
|
||||
// broadcast file->elements string array
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
int n;
|
||||
if (comm->me == 0) n = strlen(file->elements[i]) + 1;
|
||||
MPI_Bcast(&n, 1, MPI_INT, 0, world);
|
||||
if (comm->me != 0) file->elements[i] = new char[n];
|
||||
MPI_Bcast(file->elements[i], n, MPI_CHAR, 0, world);
|
||||
}
|
||||
|
||||
// broadcast file->mass, frho, rhor
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
MPI_Bcast(&file->mass[i], 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&file->frho[i][1], file->nrho, MPI_DOUBLE, 0, world);
|
||||
|
||||
for (j = 0; j < file->nelements; j++) {
|
||||
if (me == 0) grab(fptr,file->nr,&file->rhor[i][j][1]);
|
||||
for (int j = 0; j < file->nelements; j++) {
|
||||
MPI_Bcast(&file->rhor[i][j][1], file->nr, MPI_DOUBLE, 0, world);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < file->nelements; i++)
|
||||
for (j = 0; j <= i; j++) {
|
||||
if (me == 0) grab(fptr,file->nr,&file->z2r[i][j][1]);
|
||||
// broadcast file->z2r
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
for (int j = 0; j <= i; j++) {
|
||||
MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world);
|
||||
}
|
||||
|
||||
// close the potential file
|
||||
|
||||
if (me == 0) fclose(fptr);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
#include "neigh_request.h"
|
||||
#include "atom_kokkos.h"
|
||||
#include "kokkos.h"
|
||||
#include "utils.h"
|
||||
|
||||
#ifdef _OPENMP
|
||||
#include <omp.h>
|
||||
@ -1752,7 +1753,7 @@ void PairExp6rxKokkos<DeviceType>::read_file(char *file)
|
||||
// strip comment, skip line if blank
|
||||
|
||||
if ((ptr = strchr(line,'#'))) *ptr = '\0';
|
||||
nwords = atom->count_words(line);
|
||||
nwords = utils::count_words(line);
|
||||
if (nwords == 0) continue;
|
||||
|
||||
// concatenate additional lines until have params_per_line words
|
||||
@ -1771,7 +1772,7 @@ void PairExp6rxKokkos<DeviceType>::read_file(char *file)
|
||||
MPI_Bcast(&n,1,MPI_INT,0,world);
|
||||
MPI_Bcast(line,n,MPI_CHAR,0,world);
|
||||
if ((ptr = strchr(line,'#'))) *ptr = '\0';
|
||||
nwords = atom->count_words(line);
|
||||
nwords = utils::count_words(line);
|
||||
}
|
||||
|
||||
if (nwords != params_per_line)
|
||||
|
||||
@ -93,6 +93,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -93,6 +93,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -91,6 +91,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -91,6 +91,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -98,6 +98,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -33,6 +33,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -102,6 +102,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -109,6 +109,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -94,6 +94,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -93,6 +93,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -97,6 +97,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -97,6 +97,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -97,6 +97,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -97,6 +97,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -93,6 +93,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -112,6 +112,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -93,6 +93,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -99,6 +99,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -97,6 +97,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -96,6 +96,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -95,6 +95,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -96,6 +96,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -93,6 +93,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -94,6 +94,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -93,6 +93,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -93,6 +93,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -98,6 +98,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -93,6 +93,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -97,6 +97,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -96,6 +96,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -96,6 +96,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -97,6 +97,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -95,6 +95,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -97,6 +97,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -93,6 +93,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -93,6 +93,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -94,6 +94,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
|
||||
# Library targets
|
||||
|
||||
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
|
||||
@rm -f ../$(ARLIB)
|
||||
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
|
||||
@rm -f $(ARLIB)
|
||||
@ln -s ../$(ARLIB) $(ARLIB)
|
||||
|
||||
@ -29,11 +29,11 @@
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "utils.h"
|
||||
#include "tokenizer.h"
|
||||
#include "potential_file_reader.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define MAXLINE 1024
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PairADP::PairADP(LAMMPS *lmp) : Pair(lmp)
|
||||
@ -96,7 +96,7 @@ PairADP::~PairADP()
|
||||
if (setfl) {
|
||||
for (int i = 0; i < setfl->nelements; i++) delete [] setfl->elements[i];
|
||||
delete [] setfl->elements;
|
||||
delete [] setfl->mass;
|
||||
memory->destroy(setfl->mass);
|
||||
memory->destroy(setfl->frho);
|
||||
memory->destroy(setfl->rhor);
|
||||
memory->destroy(setfl->z2r);
|
||||
@ -453,7 +453,7 @@ void PairADP::coeff(int narg, char **arg)
|
||||
if (setfl) {
|
||||
for (i = 0; i < setfl->nelements; i++) delete [] setfl->elements[i];
|
||||
delete [] setfl->elements;
|
||||
delete [] setfl->mass;
|
||||
memory->destroy(setfl->mass);
|
||||
memory->destroy(setfl->frho);
|
||||
memory->destroy(setfl->rhor);
|
||||
memory->destroy(setfl->z2r);
|
||||
@ -541,110 +541,130 @@ void PairADP::read_file(char *filename)
|
||||
{
|
||||
Setfl *file = setfl;
|
||||
|
||||
// open potential file
|
||||
// read potential file
|
||||
if(comm->me == 0) {
|
||||
PotentialFileReader reader(lmp, filename, "ADP");
|
||||
|
||||
int me = comm->me;
|
||||
FILE *fp;
|
||||
char line[MAXLINE];
|
||||
try {
|
||||
char * line = nullptr;
|
||||
|
||||
if (me == 0) {
|
||||
fp = force->open_potential(filename);
|
||||
if (fp == NULL) {
|
||||
char str[128];
|
||||
snprintf(str,128,"Cannot open ADP potential file %s",filename);
|
||||
error->one(FLERR,str);
|
||||
}
|
||||
}
|
||||
reader.skip_line();
|
||||
reader.skip_line();
|
||||
reader.skip_line();
|
||||
|
||||
// read and broadcast header
|
||||
// extract element names from nelements line
|
||||
line = reader.next_line(1);
|
||||
ValueTokenizer values(line);
|
||||
file->nelements = values.next_int();
|
||||
|
||||
int n;
|
||||
if (me == 0) {
|
||||
utils::sfgets(FLERR,line,MAXLINE,fp,filename,error);
|
||||
utils::sfgets(FLERR,line,MAXLINE,fp,filename,error);
|
||||
utils::sfgets(FLERR,line,MAXLINE,fp,filename,error);
|
||||
utils::sfgets(FLERR,line,MAXLINE,fp,filename,error);
|
||||
n = strlen(line) + 1;
|
||||
}
|
||||
MPI_Bcast(&n,1,MPI_INT,0,world);
|
||||
MPI_Bcast(line,n,MPI_CHAR,0,world);
|
||||
|
||||
sscanf(line,"%d",&file->nelements);
|
||||
int nwords = atom->count_words(line);
|
||||
if (nwords != file->nelements + 1)
|
||||
error->all(FLERR,"Incorrect element names in ADP potential file");
|
||||
|
||||
char **words = new char*[file->nelements+1];
|
||||
nwords = 0;
|
||||
strtok(line," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue;
|
||||
if (values.count() != file->nelements + 1)
|
||||
error->one(FLERR,"Incorrect element names in ADP potential file");
|
||||
|
||||
file->elements = new char*[file->nelements];
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
n = strlen(words[i]) + 1;
|
||||
const std::string word = values.next_string();
|
||||
const int n = word.length() + 1;
|
||||
file->elements[i] = new char[n];
|
||||
strcpy(file->elements[i],words[i]);
|
||||
strcpy(file->elements[i], word.c_str());
|
||||
}
|
||||
delete [] words;
|
||||
|
||||
if (me == 0) {
|
||||
utils::sfgets(FLERR,line,MAXLINE,fp,filename,error);
|
||||
sscanf(line,"%d %lg %d %lg %lg",
|
||||
&file->nrho,&file->drho,&file->nr,&file->dr,&file->cut);
|
||||
//
|
||||
|
||||
line = reader.next_line(5);
|
||||
values = ValueTokenizer(line);
|
||||
file->nrho = values.next_int();
|
||||
file->drho = values.next_double();
|
||||
file->nr = values.next_int();
|
||||
file->dr = values.next_double();
|
||||
file->cut = values.next_double();
|
||||
|
||||
if ((file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0))
|
||||
error->one(FLERR,"Invalid EAM potential file");
|
||||
|
||||
memory->create(file->mass, file->nelements, "pair:mass");
|
||||
memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho");
|
||||
memory->create(file->rhor, file->nelements, file->nr + 1, "pair:rhor");
|
||||
memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r");
|
||||
memory->create(file->u2r, file->nelements, file->nelements, file->nr + 1, "pair:u2r");
|
||||
memory->create(file->w2r, file->nelements, file->nelements, file->nr + 1, "pair:w2r");
|
||||
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
line = reader.next_line(2);
|
||||
values = ValueTokenizer(line);
|
||||
values.next_int(); // ignore
|
||||
file->mass[i] = values.next_double();
|
||||
|
||||
reader.next_dvector(file->nrho, &file->frho[i][1]);
|
||||
reader.next_dvector(file->nr, &file->rhor[i][1]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
for (int j = 0; j <= i; j++) {
|
||||
reader.next_dvector(file->nr, &file->z2r[i][j][1]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
for (int j = 0; j <= i; j++) {
|
||||
reader.next_dvector(file->nr, &file->u2r[i][j][1]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
for (int j = 0; j <= i; j++) {
|
||||
reader.next_dvector(file->nr, &file->w2r[i][j][1]);
|
||||
}
|
||||
}
|
||||
} catch (TokenizerException & e) {
|
||||
error->one(FLERR, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
// broadcast potential information
|
||||
MPI_Bcast(&file->nelements, 1, MPI_INT, 0, world);
|
||||
|
||||
MPI_Bcast(&file->nrho, 1, MPI_INT, 0, world);
|
||||
MPI_Bcast(&file->drho, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&file->nr, 1, MPI_INT, 0, world);
|
||||
MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world);
|
||||
|
||||
file->mass = new double[file->nelements];
|
||||
// allocate memory on other procs
|
||||
if (comm->me != 0) {
|
||||
file->elements = new char*[file->nelements];
|
||||
for (int i = 0; i < file->nelements; i++) file->elements[i] = nullptr;
|
||||
memory->create(file->mass, file->nelements, "pair:mass");
|
||||
memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho");
|
||||
memory->create(file->rhor, file->nelements, file->nr + 1, "pair:rhor");
|
||||
memory->create(file->z2r,file->nelements,file->nelements,file->nr+1,
|
||||
"pair:z2r");
|
||||
memory->create(file->u2r,file->nelements,file->nelements,file->nr+1,
|
||||
"pair:u2r");
|
||||
memory->create(file->w2r,file->nelements,file->nelements,file->nr+1,
|
||||
"pair:w2r");
|
||||
|
||||
int i,j,tmp;
|
||||
for (i = 0; i < file->nelements; i++) {
|
||||
if (me == 0) {
|
||||
utils::sfgets(FLERR,line,MAXLINE,fp,filename,error);
|
||||
sscanf(line,"%d %lg",&tmp,&file->mass[i]);
|
||||
memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r");
|
||||
memory->create(file->u2r, file->nelements, file->nelements, file->nr + 1, "pair:u2r");
|
||||
memory->create(file->w2r, file->nelements, file->nelements, file->nr + 1, "pair:w2r");
|
||||
}
|
||||
MPI_Bcast(&file->mass[i],1,MPI_DOUBLE,0,world);
|
||||
|
||||
if (me == 0) grab(fp,filename,file->nrho,&file->frho[i][1]);
|
||||
// broadcast file->elements string array
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
int n;
|
||||
if (comm->me == 0) n = strlen(file->elements[i]) + 1;
|
||||
MPI_Bcast(&n, 1, MPI_INT, 0, world);
|
||||
if (comm->me != 0) file->elements[i] = new char[n];
|
||||
MPI_Bcast(file->elements[i], n, MPI_CHAR, 0, world);
|
||||
}
|
||||
|
||||
// broadcast file->mass, frho, rhor
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
MPI_Bcast(&file->mass[i],1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&file->frho[i][1],file->nrho,MPI_DOUBLE,0,world);
|
||||
if (me == 0) grab(fp,filename,file->nr,&file->rhor[i][1]);
|
||||
MPI_Bcast(&file->rhor[i][1],file->nr,MPI_DOUBLE,0,world);
|
||||
}
|
||||
|
||||
for (i = 0; i < file->nelements; i++)
|
||||
for (j = 0; j <= i; j++) {
|
||||
if (me == 0) grab(fp,filename,file->nr,&file->z2r[i][j][1]);
|
||||
// broadcast file->z2r, u2r, w2r
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
for (int j = 0; j <= i; j++) {
|
||||
MPI_Bcast(&file->z2r[i][j][1],file->nr,MPI_DOUBLE,0,world);
|
||||
}
|
||||
|
||||
for (i = 0; i < file->nelements; i++)
|
||||
for (j = 0; j <= i; j++) {
|
||||
if (me == 0) grab(fp,filename,file->nr,&file->u2r[i][j][1]);
|
||||
MPI_Bcast(&file->u2r[i][j][1],file->nr,MPI_DOUBLE,0,world);
|
||||
}
|
||||
|
||||
for (i = 0; i < file->nelements; i++)
|
||||
for (j = 0; j <= i; j++) {
|
||||
if (me == 0) grab(fp,filename,file->nr,&file->w2r[i][j][1]);
|
||||
MPI_Bcast(&file->w2r[i][j][1],file->nr,MPI_DOUBLE,0,world);
|
||||
}
|
||||
|
||||
// close the potential file
|
||||
|
||||
if (me == 0) fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -912,26 +932,6 @@ void PairADP::interpolate(int n, double delta, double *f, double **spline)
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
grab n values from file fp and put them in list
|
||||
values can be several to a line
|
||||
only called by proc 0
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void PairADP::grab(FILE *fp, char *filename, int n, double *list)
|
||||
{
|
||||
char *ptr;
|
||||
char line[MAXLINE];
|
||||
|
||||
int i = 0;
|
||||
while (i < n) {
|
||||
utils::sfgets(FLERR,line,MAXLINE,fp,filename,error);
|
||||
ptr = strtok(line," \t\n\r\f");
|
||||
if (ptr) list[i++] = atof(ptr);
|
||||
while ((ptr = strtok(NULL," \t\n\r\f"))) list[i++] = atof(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int PairADP::pack_forward_comm(int n, int *list, double *buf,
|
||||
|
||||
@ -82,7 +82,6 @@ class PairADP : public Pair {
|
||||
void allocate();
|
||||
void array2spline();
|
||||
void interpolate(int, double, double *, double **);
|
||||
void grab(FILE *, char *, int, double *);
|
||||
|
||||
void read_file(char *);
|
||||
void file2array();
|
||||
|
||||
@ -1035,145 +1035,6 @@ void PairBOP::gneigh()
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void PairBOP::theta()
|
||||
{
|
||||
int i,j,ii,jj,kk;
|
||||
int itype,jtype,i12;
|
||||
int temp_ij,temp_ik,temp_ijk;
|
||||
int n,nlocal,nall,ks;
|
||||
int nlisti;
|
||||
int *ilist;
|
||||
int *iilist;
|
||||
int **firstneigh;
|
||||
double rj2,rk2,rsq,ps;
|
||||
double rj1k1,rj2k2;
|
||||
double **x = atom->x;
|
||||
int *type = atom->type;
|
||||
|
||||
nlocal = atom->nlocal;
|
||||
nall = nlocal+atom->nghost;
|
||||
ilist = list->ilist;
|
||||
firstneigh = list->firstneigh;
|
||||
if(update_list!=0)
|
||||
memory_theta_grow();
|
||||
else
|
||||
memory_theta_create();
|
||||
for (ii = 0; ii < nall; ii++) {
|
||||
if(ii<nlocal)
|
||||
i= ilist[ii];
|
||||
else
|
||||
i=ii;
|
||||
itype = map[type[i]]+1;
|
||||
|
||||
iilist=firstneigh[i];
|
||||
nlisti=BOP_total[i];
|
||||
for(jj=0;jj<nlisti;jj++) {
|
||||
temp_ij=BOP_index[i]+jj;
|
||||
j=iilist[neigh_index[temp_ij]];
|
||||
jtype = map[type[j]]+1;
|
||||
if(itype==jtype)
|
||||
i12=itype-1;
|
||||
else if(itype<jtype)
|
||||
i12=itype*bop_types-itype*(itype+1)/2+jtype-1;
|
||||
else
|
||||
i12=jtype*bop_types-jtype*(jtype+1)/2+itype-1;
|
||||
if(i12>=npairs) {
|
||||
error->one(FLERR,"Too many atom pairs for pair bop");
|
||||
}
|
||||
disij[0][temp_ij]=x[j][0]-x[i][0];
|
||||
disij[1][temp_ij]=x[j][1]-x[i][1];
|
||||
disij[2][temp_ij]=x[j][2]-x[i][2];
|
||||
rsq=disij[0][temp_ij]*disij[0][temp_ij]
|
||||
+disij[1][temp_ij]*disij[1][temp_ij]
|
||||
+disij[2][temp_ij]*disij[2][temp_ij];
|
||||
rij[temp_ij]=sqrt(rsq);
|
||||
if(rij[temp_ij]<=rcut[i12])
|
||||
neigh_flag[temp_ij]=1;
|
||||
else
|
||||
neigh_flag[temp_ij]=0;
|
||||
if(rij[temp_ij]<=rcut3[i12])
|
||||
neigh_flag3[temp_ij]=1;
|
||||
else
|
||||
neigh_flag3[temp_ij]=0;
|
||||
ps=rij[temp_ij]*rdr[i12]+1.0;
|
||||
ks=(int)ps;
|
||||
if(nr-1<ks)
|
||||
ks=nr-1;
|
||||
ps=ps-ks;
|
||||
if(ps>1.0)
|
||||
ps=1.0;
|
||||
betaS[temp_ij]=((pBetaS3[i12][ks-1]*ps+pBetaS2[i12][ks-1])*ps+pBetaS1[i12][ks-1])*ps+pBetaS[i12][ks-1];
|
||||
dBetaS[temp_ij]=(pBetaS6[i12][ks-1]*ps+pBetaS5[i12][ks-1])*ps
|
||||
+pBetaS4[i12][ks-1];
|
||||
betaP[temp_ij]=((pBetaP3[i12][ks-1]*ps+pBetaP2[i12][ks-1])*ps
|
||||
+pBetaP1[i12][ks-1])*ps+pBetaP[i12][ks-1];
|
||||
dBetaP[temp_ij]=(pBetaP6[i12][ks-1]*ps+pBetaP5[i12][ks-1])*ps
|
||||
+pBetaP4[i12][ks-1];
|
||||
repul[temp_ij]=((pRepul3[i12][ks-1]*ps+pRepul2[i12][ks-1])*ps
|
||||
+pRepul1[i12][ks-1])*ps+pRepul[i12][ks-1];
|
||||
dRepul[temp_ij]=(pRepul6[i12][ks-1]*ps+pRepul5[i12][ks-1])*ps
|
||||
+pRepul4[i12][ks-1];
|
||||
}
|
||||
}
|
||||
for (ii = 0; ii < nall; ii++) {
|
||||
n=0;
|
||||
if(ii<nlocal)
|
||||
i= ilist[ii];
|
||||
else
|
||||
i=ii;
|
||||
iilist=firstneigh[i];
|
||||
nlisti=BOP_total[i];
|
||||
for(jj=0;jj<nlisti;jj++) {
|
||||
temp_ij=BOP_index[i]+jj;
|
||||
j=iilist[neigh_index[temp_ij]];
|
||||
rj2=rij[temp_ij]*rij[temp_ij];
|
||||
for(kk=jj+1;kk<nlisti;kk++) {
|
||||
if(cos_index[i]+n>=cos_total) {
|
||||
error->one(FLERR,"Too many atom triplets for pair bop");
|
||||
}
|
||||
temp_ik=BOP_index[i]+kk;
|
||||
temp_ijk=cos_index[i]+n;
|
||||
if(temp_ijk>=cos_total) {
|
||||
error->one(FLERR,"Too many atom triplets for pair bop");
|
||||
}
|
||||
rk2=rij[temp_ik]*rij[temp_ik];
|
||||
rj1k1=rij[temp_ij]*rij[temp_ik];
|
||||
rj2k2=rj1k1*rj1k1;
|
||||
if(temp_ijk>=cos_total) {
|
||||
error->one(FLERR,"Too many atom triplets for pair bop");
|
||||
}
|
||||
cosAng[temp_ijk]=(disij[0][temp_ij]*disij[0][temp_ik]+disij[1][temp_ij]
|
||||
*disij[1][temp_ik]+disij[2][temp_ij]*disij[2][temp_ik])/rj1k1;
|
||||
dcAng[temp_ijk][0][0]=(disij[0][temp_ik]*rj1k1-cosAng[temp_ijk]
|
||||
*disij[0][temp_ij]*rk2)/(rj2k2);
|
||||
dcAng[temp_ijk][1][0]=(disij[1][temp_ik]*rj1k1-cosAng[temp_ijk]
|
||||
*disij[1][temp_ij]*rk2)/(rj2k2);
|
||||
dcAng[temp_ijk][2][0]=(disij[2][temp_ik]*rj1k1-cosAng[temp_ijk]
|
||||
*disij[2][temp_ij]*rk2)/(rj2k2);
|
||||
dcAng[temp_ijk][0][1]=(disij[0][temp_ij]*rj1k1-cosAng[temp_ijk]
|
||||
*disij[0][temp_ik]*rj2)/(rj2k2);
|
||||
dcAng[temp_ijk][1][1]=(disij[1][temp_ij]*rj1k1-cosAng[temp_ijk]
|
||||
*disij[1][temp_ik]*rj2)/(rj2k2);
|
||||
dcAng[temp_ijk][2][1]=(disij[2][temp_ij]*rj1k1-cosAng[temp_ijk]
|
||||
*disij[2][temp_ik]*rj2)/(rj2k2);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void PairBOP::theta_mod()
|
||||
{
|
||||
if(update_list!=0)
|
||||
memory_theta_grow();
|
||||
else
|
||||
memory_theta_create();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
/* The formulation differs slightly to avoid negative square roots
|
||||
in the calculation of Sigma^(1/2) of (a) Eq. 6 and (b) Eq. 11 */
|
||||
|
||||
@ -5556,26 +5417,6 @@ void _noopt PairBOP::read_table(char *filename)
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
double PairBOP::cutoff(double rp,double vrcut,int mode,double r)
|
||||
{
|
||||
double tmp,tmp_beta,tmp_alpha,cut_store;
|
||||
|
||||
if(mode==1) {
|
||||
tmp=(rsmall-rbig)*(r-rp)/(vrcut-rp)+rbig;
|
||||
cut_store=(erfc(tmp)-erfc(rsmall))/(erfc(rbig)-erfc(rsmall));
|
||||
}
|
||||
else {
|
||||
tmp_beta=log(log(rbig)/log(rsmall))/log(rp/vrcut);
|
||||
tmp_alpha=-log(rbig)/pow(rp,tmp_beta);
|
||||
cut_store=(exp(-tmp_alpha*pow(r,tmp_beta))-exp(-tmp_alpha*pow(vrcut
|
||||
,tmp_beta)))/(exp(-tmp_alpha*pow(rp,tmp_beta))-exp(-tmp_alpha
|
||||
*pow(vrcut,tmp_beta)));
|
||||
}
|
||||
return(cut_store);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
memory usage of local atom-based arrays
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
@ -199,14 +199,11 @@ class PairBOP : public Pair {
|
||||
void setPrepul();
|
||||
void setSign();
|
||||
void gneigh();
|
||||
void theta();
|
||||
void theta_mod();
|
||||
double sigmaBo(int, int);
|
||||
double PiBo(int, int);
|
||||
void memory_theta_create();
|
||||
void memory_theta_destroy();
|
||||
void memory_theta_grow();
|
||||
double cutoff(double, double, int, double);
|
||||
|
||||
void read_table(char *);
|
||||
void allocate();
|
||||
|
||||
@ -34,11 +34,13 @@
|
||||
#include "math_const.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "utils.h"
|
||||
#include "tokenizer.h"
|
||||
#include "potential_file_reader.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
|
||||
#define MAXLINE 1024
|
||||
#define DELTA 4
|
||||
#define PGDELTA 1
|
||||
#define MAXNEIGH 24
|
||||
@ -580,92 +582,37 @@ double PairComb::init_one(int i, int j)
|
||||
|
||||
void PairComb::read_file(char *file)
|
||||
{
|
||||
int params_per_line = 49;
|
||||
char **words = new char*[params_per_line+1];
|
||||
|
||||
memory->sfree(params);
|
||||
params = NULL;
|
||||
params = nullptr;
|
||||
nparams = 0;
|
||||
maxparam = 0;
|
||||
|
||||
// open file on proc 0
|
||||
|
||||
FILE *fp;
|
||||
if (comm->me == 0) {
|
||||
fp = force->open_potential(file);
|
||||
if (fp == NULL) {
|
||||
char str[128];
|
||||
snprintf(str,128,"Cannot open COMB potential file %s",file);
|
||||
error->one(FLERR,str);
|
||||
}
|
||||
}
|
||||
PotentialFileReader reader(lmp, file, "COMB");
|
||||
char * line;
|
||||
|
||||
// read each line out of file, skipping blank lines or leading '#'
|
||||
// store line of params if all 3 element tags are in element list
|
||||
while((line = reader.next_line(NPARAMS_PER_LINE))) {
|
||||
try {
|
||||
ValueTokenizer values(line," \t\n\r\f");
|
||||
|
||||
int n,nwords,ielement,jelement,kelement;
|
||||
char line[MAXLINE],*ptr;
|
||||
int eof = 0;
|
||||
|
||||
while (1) {
|
||||
if (comm->me == 0) {
|
||||
ptr = fgets(line,MAXLINE,fp);
|
||||
if (ptr == NULL) {
|
||||
eof = 1;
|
||||
fclose(fp);
|
||||
} else n = strlen(line) + 1;
|
||||
}
|
||||
MPI_Bcast(&eof,1,MPI_INT,0,world);
|
||||
if (eof) break;
|
||||
MPI_Bcast(&n,1,MPI_INT,0,world);
|
||||
MPI_Bcast(line,n,MPI_CHAR,0,world);
|
||||
|
||||
// strip comment, skip line if blank
|
||||
|
||||
if ((ptr = strchr(line,'#'))) *ptr = '\0';
|
||||
nwords = atom->count_words(line);
|
||||
if (nwords == 0) continue;
|
||||
|
||||
// concatenate additional lines until have params_per_line words
|
||||
|
||||
while (nwords < params_per_line) {
|
||||
n = strlen(line);
|
||||
if (comm->me == 0) {
|
||||
ptr = fgets(&line[n],MAXLINE-n,fp);
|
||||
if (ptr == NULL) {
|
||||
eof = 1;
|
||||
fclose(fp);
|
||||
} else n = strlen(line) + 1;
|
||||
}
|
||||
MPI_Bcast(&eof,1,MPI_INT,0,world);
|
||||
if (eof) break;
|
||||
MPI_Bcast(&n,1,MPI_INT,0,world);
|
||||
MPI_Bcast(line,n,MPI_CHAR,0,world);
|
||||
if ((ptr = strchr(line,'#'))) *ptr = '\0';
|
||||
nwords = atom->count_words(line);
|
||||
}
|
||||
|
||||
if (nwords != params_per_line)
|
||||
error->all(FLERR,"Incorrect format in COMB potential file");
|
||||
|
||||
// words = ptrs to all words in line
|
||||
|
||||
nwords = 0;
|
||||
words[nwords++] = strtok(line," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue;
|
||||
std::string iname = values.next_string();
|
||||
std::string jname = values.next_string();
|
||||
std::string kname = values.next_string();
|
||||
|
||||
// ielement,jelement,kelement = 1st args
|
||||
// if all 3 args are in element list, then parse this line
|
||||
// else skip to next line
|
||||
int ielement, jelement, kelement;
|
||||
|
||||
for (ielement = 0; ielement < nelements; ielement++)
|
||||
if (strcmp(words[0],elements[ielement]) == 0) break;
|
||||
if (iname == elements[ielement]) break;
|
||||
if (ielement == nelements) continue;
|
||||
for (jelement = 0; jelement < nelements; jelement++)
|
||||
if (strcmp(words[1],elements[jelement]) == 0) break;
|
||||
if (jname == elements[jelement]) break;
|
||||
if (jelement == nelements) continue;
|
||||
for (kelement = 0; kelement < nelements; kelement++)
|
||||
if (strcmp(words[2],elements[kelement]) == 0) break;
|
||||
if (kname == elements[kelement]) break;
|
||||
if (kelement == nelements) continue;
|
||||
|
||||
// load up parameter settings and error check their values
|
||||
@ -679,52 +626,55 @@ void PairComb::read_file(char *file)
|
||||
params[nparams].ielement = ielement;
|
||||
params[nparams].jelement = jelement;
|
||||
params[nparams].kelement = kelement;
|
||||
params[nparams].powerm = atof(words[3]);
|
||||
params[nparams].c = atof(words[4]);
|
||||
params[nparams].d = atof(words[5]);
|
||||
params[nparams].h = atof(words[6]);
|
||||
params[nparams].powern = atof(words[7]);
|
||||
params[nparams].beta = atof(words[8]);
|
||||
params[nparams].lam21 = atof(words[9]);
|
||||
params[nparams].lam22 = atof(words[10]);
|
||||
params[nparams].bigb1 = atof(words[11]);
|
||||
params[nparams].bigb2 = atof(words[12]);
|
||||
params[nparams].bigr = atof(words[13]);
|
||||
params[nparams].bigd = atof(words[14]);
|
||||
params[nparams].lam11 = atof(words[15]);
|
||||
params[nparams].lam12 = atof(words[16]);
|
||||
params[nparams].biga1 = atof(words[17]);
|
||||
params[nparams].biga2 = atof(words[18]);
|
||||
params[nparams].plp1 = atof(words[19]);
|
||||
params[nparams].plp3 = atof(words[20]);
|
||||
params[nparams].plp6 = atof(words[21]);
|
||||
params[nparams].a123 = atof(words[22]);
|
||||
params[nparams].aconf= atof(words[23]);
|
||||
params[nparams].addrep = atof(words[24]);
|
||||
params[nparams].romigb = atof(words[25]);
|
||||
params[nparams].romigc = atof(words[26]);
|
||||
params[nparams].romigd = atof(words[27]);
|
||||
params[nparams].romiga = atof(words[28]);
|
||||
params[nparams].QL1 = atof(words[29]);
|
||||
params[nparams].QU1 = atof(words[30]);
|
||||
params[nparams].DL1 = atof(words[31]);
|
||||
params[nparams].DU1 = atof(words[32]);
|
||||
params[nparams].QL2 = atof(words[33]);
|
||||
params[nparams].QU2 = atof(words[34]);
|
||||
params[nparams].DL2 = atof(words[35]);
|
||||
params[nparams].DU2 = atof(words[36]);
|
||||
params[nparams].chi = atof(words[37]);
|
||||
params[nparams].dj = atof(words[38]);
|
||||
params[nparams].dk = atof(words[39]);
|
||||
params[nparams].dl = atof(words[40]);
|
||||
params[nparams].dm = atof(words[41]);
|
||||
params[nparams].esm1 = atof(words[42]);
|
||||
params[nparams].cmn1 = atof(words[43]);
|
||||
params[nparams].cml1 = atof(words[44]);
|
||||
params[nparams].cmn2 = atof(words[45]);
|
||||
params[nparams].cml2 = atof(words[46]);
|
||||
params[nparams].coulcut = atof(words[47]);
|
||||
params[nparams].hfocor = atof(words[48]);
|
||||
params[nparams].powerm = values.next_double();
|
||||
params[nparams].c = values.next_double();
|
||||
params[nparams].d = values.next_double();
|
||||
params[nparams].h = values.next_double();
|
||||
params[nparams].powern = values.next_double();
|
||||
params[nparams].beta = values.next_double();
|
||||
params[nparams].lam21 = values.next_double();
|
||||
params[nparams].lam22 = values.next_double();
|
||||
params[nparams].bigb1 = values.next_double();
|
||||
params[nparams].bigb2 = values.next_double();
|
||||
params[nparams].bigr = values.next_double();
|
||||
params[nparams].bigd = values.next_double();
|
||||
params[nparams].lam11 = values.next_double();
|
||||
params[nparams].lam12 = values.next_double();
|
||||
params[nparams].biga1 = values.next_double();
|
||||
params[nparams].biga2 = values.next_double();
|
||||
params[nparams].plp1 = values.next_double();
|
||||
params[nparams].plp3 = values.next_double();
|
||||
params[nparams].plp6 = values.next_double();
|
||||
params[nparams].a123 = values.next_double();
|
||||
params[nparams].aconf = values.next_double();
|
||||
params[nparams].addrep = values.next_double();
|
||||
params[nparams].romigb = values.next_double();
|
||||
params[nparams].romigc = values.next_double();
|
||||
params[nparams].romigd = values.next_double();
|
||||
params[nparams].romiga = values.next_double();
|
||||
params[nparams].QL1 = values.next_double();
|
||||
params[nparams].QU1 = values.next_double();
|
||||
params[nparams].DL1 = values.next_double();
|
||||
params[nparams].DU1 = values.next_double();
|
||||
params[nparams].QL2 = values.next_double();
|
||||
params[nparams].QU2 = values.next_double();
|
||||
params[nparams].DL2 = values.next_double();
|
||||
params[nparams].DU2 = values.next_double();
|
||||
params[nparams].chi = values.next_double();
|
||||
params[nparams].dj = values.next_double();
|
||||
params[nparams].dk = values.next_double();
|
||||
params[nparams].dl = values.next_double();
|
||||
params[nparams].dm = values.next_double();
|
||||
params[nparams].esm1 = values.next_double();
|
||||
params[nparams].cmn1 = values.next_double();
|
||||
params[nparams].cml1 = values.next_double();
|
||||
params[nparams].cmn2 = values.next_double();
|
||||
params[nparams].cml2 = values.next_double();
|
||||
params[nparams].coulcut = values.next_double();
|
||||
params[nparams].hfocor = values.next_double();
|
||||
} catch (TokenizerException & e) {
|
||||
error->one(FLERR, e.what());
|
||||
}
|
||||
|
||||
params[nparams].powermint = int(params[nparams].powerm);
|
||||
|
||||
@ -754,18 +704,26 @@ void PairComb::read_file(char *file)
|
||||
// params[nparams].dj < 0.0 || params[nparams].dk < 0.0 ||
|
||||
// params[nparams].dl < 0.0 || params[nparams].dm < 0.0 ||
|
||||
params[nparams].esm1 < 0.0)
|
||||
error->all(FLERR,"Illegal COMB parameter");
|
||||
error->one(FLERR,"Illegal COMB parameter");
|
||||
|
||||
if (params[nparams].lam11 < params[nparams].lam21 ||
|
||||
params[nparams].lam12 < params[nparams].lam22 ||
|
||||
params[nparams].biga1< params[nparams].bigb1 ||
|
||||
params[nparams].biga2< params[nparams].bigb2)
|
||||
error->all(FLERR,"Illegal COMB parameter");
|
||||
error->one(FLERR,"Illegal COMB parameter");
|
||||
|
||||
nparams++;
|
||||
}
|
||||
}
|
||||
|
||||
delete [] words;
|
||||
MPI_Bcast(&nparams, 1, MPI_INT, 0, world);
|
||||
MPI_Bcast(&maxparam, 1, MPI_INT, 0, world);
|
||||
|
||||
if(comm->me != 0) {
|
||||
params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params");
|
||||
}
|
||||
|
||||
MPI_Bcast(params, maxparam*sizeof(Param), MPI_BYTE, 0, world);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -38,6 +38,8 @@ class PairComb : public Pair {
|
||||
virtual double yasu_char(double *, int &);
|
||||
double enegtot;
|
||||
|
||||
static const int NPARAMS_PER_LINE = 49;
|
||||
|
||||
protected:
|
||||
struct Param {
|
||||
double lam11,lam12,lam21,lam22;
|
||||
|
||||
@ -34,11 +34,12 @@
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "utils.h"
|
||||
#include "tokenizer.h"
|
||||
#include "potential_file_reader.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
|
||||
#define MAXLINE 1024
|
||||
#define DELTA 4
|
||||
#define PGDELTA 1
|
||||
#define MAXNEIGH 24
|
||||
@ -312,109 +313,103 @@ double PairComb3::init_one(int i, int j)
|
||||
void PairComb3::read_lib()
|
||||
{
|
||||
const unsigned int MAXLIB = 1024;
|
||||
int i,j,k,l,nwords,m;
|
||||
int i,j,k,l,m;
|
||||
int ii,jj,kk,ll,mm,iii;
|
||||
char s[MAXLIB];
|
||||
char **words = new char*[80];
|
||||
|
||||
// open libraray file on proc 0
|
||||
// open library file on proc 0
|
||||
|
||||
if (comm->me == 0) {
|
||||
const char filename[] = "lib.comb3";
|
||||
FILE *fp = force->open_potential(filename);
|
||||
if (fp == NULL) error->one(FLERR,"Cannot open COMB3 lib.comb3 file");
|
||||
|
||||
try {
|
||||
// read and store at the same time
|
||||
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error);
|
||||
utils::sfgets(FLERR,s,MAXLIB,fp,filename,error);
|
||||
nwords = 0;
|
||||
words[nwords++] = strtok(s," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue;
|
||||
ccutoff[0] = atof(words[0]);
|
||||
ccutoff[1] = atof(words[1]);
|
||||
ccutoff[2] = atof(words[2]);
|
||||
ccutoff[3] = atof(words[3]);
|
||||
ccutoff[4] = atof(words[4]);
|
||||
ccutoff[5] = atof(words[5]);
|
||||
|
||||
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error);
|
||||
nwords = 0;
|
||||
words[nwords++] = strtok(s," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue;
|
||||
ch_a[0] = atof(words[0]);
|
||||
ch_a[1] = atof(words[1]);
|
||||
ch_a[2] = atof(words[2]);
|
||||
ch_a[3] = atof(words[3]);
|
||||
ch_a[4] = atof(words[4]);
|
||||
ch_a[5] = atof(words[5]);
|
||||
ch_a[6] = atof(words[6]);
|
||||
ValueTokenizer values(s, " \t\n\r\f");
|
||||
|
||||
ccutoff[0] = values.next_double();
|
||||
ccutoff[1] = values.next_double();
|
||||
ccutoff[2] = values.next_double();
|
||||
ccutoff[3] = values.next_double();
|
||||
ccutoff[4] = values.next_double();
|
||||
ccutoff[5] = values.next_double();
|
||||
|
||||
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error);
|
||||
nwords = 0;
|
||||
words[nwords++] = strtok(s," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue;
|
||||
nsplpcn = atoi(words[0]);
|
||||
nsplrad = atoi(words[1]);
|
||||
nspltor = atoi(words[2]);
|
||||
values = ValueTokenizer(s, " \t\n\r\f");
|
||||
|
||||
ch_a[0] = values.next_double();
|
||||
ch_a[1] = values.next_double();
|
||||
ch_a[2] = values.next_double();
|
||||
ch_a[3] = values.next_double();
|
||||
ch_a[4] = values.next_double();
|
||||
ch_a[5] = values.next_double();
|
||||
ch_a[6] = values.next_double();
|
||||
|
||||
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error);
|
||||
nwords = 0;
|
||||
words[nwords++] = strtok(s," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue;
|
||||
maxx = atoi(words[0]);
|
||||
maxy = atoi(words[1]);
|
||||
maxz = atoi(words[2]);
|
||||
values = ValueTokenizer(s, " \t\n\r\f");
|
||||
|
||||
nsplpcn = values.next_int();
|
||||
nsplrad = values.next_int();
|
||||
nspltor = values.next_int();
|
||||
|
||||
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error);
|
||||
nwords = 0;
|
||||
words[nwords++] = strtok(s," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue;
|
||||
maxxc = atoi(words[0]);
|
||||
maxyc = atoi(words[1]);
|
||||
maxconj = atoi(words[2]);
|
||||
values = ValueTokenizer(s, " \t\n\r\f");
|
||||
|
||||
maxx = values.next_int();
|
||||
maxy = values.next_int();
|
||||
maxz = values.next_int();
|
||||
|
||||
utils::sfgets(FLERR,s,MAXLIB,fp,filename,error);
|
||||
values = ValueTokenizer(s, " \t\n\r\f");
|
||||
|
||||
maxxc = values.next_int();
|
||||
maxyc = values.next_int();
|
||||
maxconj = values.next_int();
|
||||
|
||||
for (l = 0; l < nsplpcn; l++) {
|
||||
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error);
|
||||
nwords = 0;
|
||||
words[nwords++] = strtok(s," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue;
|
||||
maxxcn[l] = atoi(words[1]);
|
||||
vmaxxcn[l] = atof(words[2]);
|
||||
dvmaxxcn[l] = atof(words[3]);
|
||||
values = ValueTokenizer(s, " \t\n\r\f");
|
||||
values.skip(1);
|
||||
|
||||
maxxcn[l] = values.next_int();
|
||||
vmaxxcn[l] = values.next_double();
|
||||
dvmaxxcn[l] = values.next_double();
|
||||
}
|
||||
|
||||
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error);
|
||||
nwords = 0;
|
||||
words[nwords++] = strtok(s," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue;
|
||||
ntab = atoi(words[0]);
|
||||
values = ValueTokenizer(s, " \t\n\r\f");
|
||||
|
||||
for (i=0; i<ntab+1; i++){
|
||||
ntab = values.next_int();
|
||||
|
||||
for (i = 0; i < (ntab + 1); i++){
|
||||
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error);
|
||||
nwords = 0;
|
||||
words[nwords++] = strtok(s," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue;
|
||||
pang[i] = atof(words[1]);
|
||||
dpang[i] = atof(words[2]);
|
||||
ddpang[i] = atof(words[3]);
|
||||
values = ValueTokenizer(s, " \t\n\r\f");
|
||||
values.skip(1);
|
||||
|
||||
pang[i] = values.next_double();
|
||||
dpang[i] = values.next_double();
|
||||
ddpang[i] = values.next_double();
|
||||
}
|
||||
|
||||
for (l = 0; l < nsplpcn; l++)
|
||||
for (i=0; i<maxx+1; i++)
|
||||
for (j=0; j<maxy+1; j++)
|
||||
for (k=0; k<maxz+1; k++) {
|
||||
for (i = 0; i < (maxx + 1); i++)
|
||||
for (j = 0; j < (maxy + 1); j++)
|
||||
for (k = 0; k < (maxz + 1); k++) {
|
||||
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error);
|
||||
nwords = 0;
|
||||
words[nwords++] = strtok(s," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue;
|
||||
ll = atoi(words[0])-1;
|
||||
ii = atoi(words[1]);
|
||||
jj = atoi(words[2]);
|
||||
kk = atoi(words[3]);
|
||||
pcn_grid[ll][ii][jj][kk] = atof(words[4]);
|
||||
pcn_gridx[ll][ii][jj][kk] = atof(words[5]);
|
||||
pcn_gridy[ll][ii][jj][kk] = atof(words[6]);
|
||||
pcn_gridz[ll][ii][jj][kk] = atof(words[7]);
|
||||
values = ValueTokenizer(s, " \t\n\r\f");
|
||||
|
||||
ll = values.next_int() - 1;
|
||||
ii = values.next_int();
|
||||
jj = values.next_int();
|
||||
kk = values.next_int();
|
||||
pcn_grid[ll][ii][jj][kk] = values.next_double();
|
||||
pcn_gridx[ll][ii][jj][kk] = values.next_double();
|
||||
pcn_gridy[ll][ii][jj][kk] = values.next_double();
|
||||
pcn_gridz[ll][ii][jj][kk] = values.next_double();
|
||||
}
|
||||
|
||||
for (l = 0; l < nsplpcn; l++)
|
||||
@ -422,63 +417,60 @@ void PairComb3::read_lib()
|
||||
for (j = 0; j < maxy; j++)
|
||||
for (k = 0; k < maxz; k++) {
|
||||
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error);
|
||||
nwords = 0;
|
||||
words[nwords++] = strtok(s," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue;
|
||||
ll = atoi(words[0])-1;
|
||||
ii = atoi(words[1]);
|
||||
jj = atoi(words[2]);
|
||||
kk = atoi(words[3]);
|
||||
values = ValueTokenizer(s, " \t\n\r\f");
|
||||
|
||||
ll = values.next_int()-1;
|
||||
ii = values.next_int();
|
||||
jj = values.next_int();
|
||||
kk = values.next_int();
|
||||
|
||||
for(iii = 0; iii < 2; iii++) {
|
||||
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error);
|
||||
nwords = 0;
|
||||
words[nwords++] = strtok(s," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue;
|
||||
values = ValueTokenizer(s, " \t\n\r\f");
|
||||
|
||||
for(m = 0; m < 32 ; m++) {
|
||||
mm = iii*32 + m;
|
||||
pcn_cubs[ll][ii][jj][kk][mm] = atof(words[m]);
|
||||
pcn_cubs[ll][ii][jj][kk][mm] = values.next_double();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (l = 0; l < nsplrad; l++)
|
||||
for (i=0; i<maxxc+1; i++)
|
||||
for (j=0; j<maxyc+1; j++)
|
||||
for (i = 0; i < (maxxc + 1); i++)
|
||||
for (j = 0; j < (maxyc + 1); j++)
|
||||
for (k = 0; k < maxconj; k++) {
|
||||
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error);
|
||||
nwords = 0;
|
||||
words[nwords++] = strtok(s," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue;
|
||||
ll = atoi(words[0])-1;
|
||||
ii = atoi(words[1]);
|
||||
jj = atoi(words[2]);
|
||||
kk = atoi(words[3])-1;
|
||||
rad_grid[ll][ii][jj][kk] = atof(words[4]);
|
||||
rad_gridx[ll][ii][jj][kk] = atof(words[5]);
|
||||
rad_gridy[ll][ii][jj][kk] = atof(words[6]);
|
||||
rad_gridz[ll][ii][jj][kk] = atof(words[7]);
|
||||
values = ValueTokenizer(s, " \t\n\r\f");
|
||||
|
||||
ll = values.next_int() - 1;
|
||||
ii = values.next_int();
|
||||
jj = values.next_int();
|
||||
kk = values.next_int() - 1;
|
||||
rad_grid[ll][ii][jj][kk] = values.next_double();
|
||||
rad_gridx[ll][ii][jj][kk] = values.next_double();
|
||||
rad_gridy[ll][ii][jj][kk] = values.next_double();
|
||||
rad_gridz[ll][ii][jj][kk] = values.next_double();
|
||||
}
|
||||
|
||||
for (l = 0; l < nsplrad; l++)
|
||||
for (i = 0; i < maxxc; i++)
|
||||
for (j = 0; j < maxyc; j++)
|
||||
for (k=0; k<maxconj-1; k++) {
|
||||
for (k = 0; k < (maxconj - 1); k++) {
|
||||
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error);
|
||||
nwords = 0;
|
||||
words[nwords++] = strtok(s," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue;
|
||||
ll = atoi(words[0])-1;
|
||||
ii = atoi(words[1]);
|
||||
jj = atoi(words[2]);
|
||||
kk = atoi(words[3])-1;
|
||||
values = ValueTokenizer(s, " \t\n\r\f");
|
||||
|
||||
ll = values.next_int() - 1;
|
||||
ii = values.next_int();
|
||||
jj = values.next_int();
|
||||
kk = values.next_int() - 1;
|
||||
|
||||
for (iii = 0; iii < 2; iii++) {
|
||||
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error);
|
||||
nwords = 0;
|
||||
words[nwords++] = strtok(s," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue;
|
||||
values = ValueTokenizer(s, " \t\n\r\f");
|
||||
|
||||
for(m = 0; m < 32 ; m++){
|
||||
mm = iii * 32 + m;
|
||||
rad_spl[ll][ii][jj][kk][mm] = atof(words[m]);
|
||||
rad_spl[ll][ii][jj][kk][mm] = values.next_double();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -488,17 +480,16 @@ void PairComb3::read_lib()
|
||||
for (j=0; j<maxyc+1; j++)
|
||||
for (k=0; k<maxconj; k++) {
|
||||
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error);
|
||||
nwords = 0;
|
||||
words[nwords++] = strtok(s," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue;
|
||||
ll = atoi(words[0])-1;
|
||||
ii = atoi(words[1]);
|
||||
jj = atoi(words[2]);
|
||||
kk = atoi(words[3])-1;
|
||||
tor_grid[ll][ii][jj][kk] = atof(words[4]);
|
||||
tor_gridx[ll][ii][jj][kk] = atof(words[5]);
|
||||
tor_gridy[ll][ii][jj][kk] = atof(words[6]);
|
||||
tor_gridz[ll][ii][jj][kk] = atof(words[7]);
|
||||
values = ValueTokenizer(s, " \t\n\r\f");
|
||||
|
||||
ll = values.next_int() - 1;
|
||||
ii = values.next_int();
|
||||
jj = values.next_int();
|
||||
kk = values.next_int() - 1;
|
||||
tor_grid[ll][ii][jj][kk] = values.next_double();
|
||||
tor_gridx[ll][ii][jj][kk] = values.next_double();
|
||||
tor_gridy[ll][ii][jj][kk] = values.next_double();
|
||||
tor_gridz[ll][ii][jj][kk] = values.next_double();
|
||||
}
|
||||
|
||||
for (l=0; l<nspltor; l++)
|
||||
@ -506,26 +497,27 @@ void PairComb3::read_lib()
|
||||
for (j=0; j<maxyc; j++)
|
||||
for (k=0; k<maxconj-1; k++) {
|
||||
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error);
|
||||
nwords = 0;
|
||||
words[nwords++] = strtok(s," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue;
|
||||
ll = atoi(words[0])-1;
|
||||
ii = atoi(words[1]);
|
||||
jj = atoi(words[2]);
|
||||
kk = atoi(words[3])-1;
|
||||
values = ValueTokenizer(s, " \t\n\r\f");
|
||||
|
||||
ll = values.next_int() - 1;
|
||||
ii = values.next_int();
|
||||
jj = values.next_int();
|
||||
kk = values.next_int() - 1;
|
||||
for(iii=0; iii<2; iii++) {
|
||||
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error);
|
||||
nwords = 0;
|
||||
words[nwords++] = strtok(s," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue;
|
||||
values = ValueTokenizer(s, " \t\n\r\f");
|
||||
|
||||
for (m = 0; m < 32 ; m++){
|
||||
mm=iii*32+m;
|
||||
tor_spl[ll][ii][jj][kk][mm] = atof(words[m]);
|
||||
tor_spl[ll][ii][jj][kk][mm] = values.next_double();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
} catch (TokenizerException & e) {
|
||||
fclose(fp);
|
||||
error->one(FLERR, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
k = 0;
|
||||
@ -584,102 +576,43 @@ void PairComb3::read_lib()
|
||||
|
||||
MPI_Bcast(&iin2[0][0],32,MPI_INT,0,world);
|
||||
MPI_Bcast(&iin3[0][0],192,MPI_INT,0,world);
|
||||
delete [] words;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void PairComb3::read_file(char *file)
|
||||
{
|
||||
int params_per_line = 74;
|
||||
char **words = new char*[params_per_line+1];
|
||||
|
||||
if (params) delete [] params;
|
||||
params = NULL;
|
||||
memory->sfree(params);
|
||||
params = nullptr;
|
||||
nparams = 0;
|
||||
maxparam = 0;
|
||||
|
||||
// open file on proc 0
|
||||
|
||||
FILE *fp;
|
||||
if (comm->me == 0) {
|
||||
fp = force->open_potential(file);
|
||||
if (fp == NULL) {
|
||||
char str[128];
|
||||
snprintf(str,128,"Cannot open COMB3 potential file %s",file);
|
||||
error->one(FLERR,str);
|
||||
}
|
||||
}
|
||||
PotentialFileReader reader(lmp, file, "COMB3");
|
||||
char * line;
|
||||
|
||||
// read each line out of file, skipping blank lines or leading '#'
|
||||
// store line of params if all 3 element tags are in element list
|
||||
while((line = reader.next_line(NPARAMS_PER_LINE))) {
|
||||
try {
|
||||
ValueTokenizer values(line, " \t\n\r\f");
|
||||
|
||||
int n,nwords,ielement,jelement,kelement;
|
||||
char line[MAXLINE],*ptr;
|
||||
int eof = 0;
|
||||
nwords=0;
|
||||
while (1) {
|
||||
if (comm->me == 0) {
|
||||
ptr = fgets(line,MAXLINE,fp);
|
||||
if (ptr == NULL) {
|
||||
eof = 1;
|
||||
fclose(fp);
|
||||
} else n = strlen(line) + 1;
|
||||
}
|
||||
MPI_Bcast(&eof,1,MPI_INT,0,world);
|
||||
if (eof) break;
|
||||
MPI_Bcast(&n,1,MPI_INT,0,world);
|
||||
MPI_Bcast(line,n,MPI_CHAR,0,world);
|
||||
|
||||
// strip comment, skip line if blank
|
||||
|
||||
if ((ptr = strchr(line,'#'))) *ptr = '\0';
|
||||
|
||||
nwords = atom->count_words(line);
|
||||
if (nwords == 0) continue;
|
||||
|
||||
// concatenate additional lines until have params_per_line words
|
||||
|
||||
while (nwords < params_per_line) {
|
||||
n = strlen(line);
|
||||
|
||||
if (comm->me == 0) {
|
||||
ptr = fgets(&line[n],MAXLINE-n,fp);
|
||||
if (ptr == NULL) {
|
||||
eof = 1;
|
||||
fclose(fp);
|
||||
} else n = strlen(line) + 1;
|
||||
}
|
||||
MPI_Bcast(&eof,1,MPI_INT,0,world);
|
||||
if (eof) break;
|
||||
MPI_Bcast(&n,1,MPI_INT,0,world);
|
||||
MPI_Bcast(line,n,MPI_CHAR,0,world);
|
||||
if ((ptr = strchr(line,'#'))) *ptr = '\0';
|
||||
nwords = atom->count_words(line);
|
||||
}
|
||||
if (nwords != params_per_line){
|
||||
error->all(FLERR,"Incorrect format in COMB3 potential file");
|
||||
}
|
||||
// words = ptrs to all words in line
|
||||
|
||||
nwords = 0;
|
||||
words[nwords++] = strtok(line," \t\n\r\f");
|
||||
while ((nwords <= params_per_line)
|
||||
&& (words[nwords++] = strtok(NULL," \t\n\r\f"))) {
|
||||
continue;
|
||||
}
|
||||
std::string iname = values.next_string();
|
||||
std::string jname = values.next_string();
|
||||
std::string kname = values.next_string();
|
||||
|
||||
// ielement,jelement,kelement = 1st args
|
||||
// if all 3 args are in element list, then parse this line
|
||||
// else skip to next line
|
||||
int ielement, jelement, kelement;
|
||||
|
||||
for (ielement = 0; ielement < nelements; ielement++)
|
||||
if (strcmp(words[0],elements[ielement]) == 0) break;
|
||||
if (iname == elements[ielement]) break;
|
||||
if (ielement == nelements) continue;
|
||||
for (jelement = 0; jelement < nelements; jelement++)
|
||||
if (strcmp(words[1],elements[jelement]) == 0) break;
|
||||
if (jname == elements[jelement]) break;
|
||||
if (jelement == nelements) continue;
|
||||
for (kelement = 0; kelement < nelements; kelement++)
|
||||
if (strcmp(words[2],elements[kelement]) == 0) break;
|
||||
if (kname == elements[kelement]) break;
|
||||
if (kelement == nelements) continue;
|
||||
|
||||
// load up parameter settings and error check their values
|
||||
@ -693,78 +626,81 @@ void PairComb3::read_file(char *file)
|
||||
params[nparams].ielement = ielement;
|
||||
params[nparams].jelement = jelement;
|
||||
params[nparams].kelement = kelement;
|
||||
params[nparams].ielementgp = atoi(words[3]);
|
||||
params[nparams].jelementgp = atoi(words[4]);
|
||||
params[nparams].kelementgp = atoi(words[5]);
|
||||
params[nparams].ang_flag = atoi(words[6]);
|
||||
params[nparams].pcn_flag = atoi(words[7]);
|
||||
params[nparams].rad_flag = atoi(words[8]);
|
||||
params[nparams].tor_flag = atoi(words[9]);
|
||||
params[nparams].vdwflag = atof(words[10]);
|
||||
params[nparams].powerm = atof(words[11]);
|
||||
params[nparams].veps = atof(words[12]);
|
||||
params[nparams].vsig = atof(words[13]);
|
||||
params[nparams].paaa = atof(words[14]);
|
||||
params[nparams].pbbb = atof(words[15]);
|
||||
params[nparams].lami = atof(words[16]);
|
||||
params[nparams].alfi = atof(words[17]);
|
||||
params[nparams].powern = atof(words[18]);
|
||||
params[nparams].QL = atof(words[19]);
|
||||
params[nparams].QU = atof(words[20]);
|
||||
params[nparams].DL = atof(words[21]);
|
||||
params[nparams].DU = atof(words[22]);
|
||||
params[nparams].qmin = atof(words[23]);
|
||||
params[nparams].qmax = atof(words[24]);
|
||||
params[nparams].chi = atof(words[25]);
|
||||
params[nparams].dj = atof(words[26]);
|
||||
params[nparams].dk = atof(words[27]);
|
||||
params[nparams].dl = atof(words[28]);
|
||||
params[nparams].esm = atof(words[29]);
|
||||
params[nparams].cmn1 = atof(words[30]);
|
||||
params[nparams].cmn2 = atof(words[31]);
|
||||
params[nparams].pcmn1 = atof(words[32]);
|
||||
params[nparams].pcmn2 = atof(words[33]);
|
||||
params[nparams].coulcut = atof(words[34]);
|
||||
params[nparams].polz = atof(words[35]);
|
||||
params[nparams].curl = atof(words[36]);
|
||||
params[nparams].curlcut1 = atof(words[37]);
|
||||
params[nparams].curlcut2 = atof(words[38]);
|
||||
params[nparams].curl0 = atof(words[39]);
|
||||
params[nparams].alpha1 = atof(words[40]);
|
||||
params[nparams].bigB1 = atof(words[41]);
|
||||
params[nparams].alpha2 = atof(words[42]);
|
||||
params[nparams].bigB2 = atof(words[43]);
|
||||
params[nparams].alpha3 = atof(words[44]);
|
||||
params[nparams].bigB3 = atof(words[45]);
|
||||
params[nparams].lambda = atof(words[46]);
|
||||
params[nparams].bigA = atof(words[47]);
|
||||
params[nparams].beta = atof(words[48]);
|
||||
params[nparams].bigr = atof(words[49]);
|
||||
params[nparams].bigd = atof(words[50]);
|
||||
params[nparams].pcos6 = atof(words[51]);
|
||||
params[nparams].pcos5 = atof(words[52]);
|
||||
params[nparams].pcos4 = atof(words[53]);
|
||||
params[nparams].pcos3 = atof(words[54]);
|
||||
params[nparams].pcos2 = atof(words[55]);
|
||||
params[nparams].pcos1 = atof(words[56]);
|
||||
params[nparams].pcos0 = atof(words[57]);
|
||||
params[nparams].pcna = atof(words[58]);
|
||||
params[nparams].pcnb = atof(words[59]);
|
||||
params[nparams].pcnc = atof(words[60]);
|
||||
params[nparams].pcnd = atof(words[61]);
|
||||
params[nparams].p6p0 = atof(words[62]);
|
||||
params[nparams].p6p1 = atof(words[63]);
|
||||
params[nparams].p6p2 = atof(words[64]);
|
||||
params[nparams].p6p3 = atof(words[65]);
|
||||
params[nparams].p6p4 = atof(words[66]);
|
||||
params[nparams].p6p5 = atof(words[67]);
|
||||
params[nparams].p6p6 = atof(words[68]);
|
||||
params[nparams].ptork1=atof(words[69]);
|
||||
params[nparams].ptork2=atof(words[70]);
|
||||
params[nparams].addrepr=atof(words[71]);
|
||||
params[nparams].addrep=atof(words[72]);
|
||||
params[nparams].pcross = atof(words[73]);
|
||||
params[nparams].ielementgp = values.next_int();
|
||||
params[nparams].jelementgp = values.next_int();
|
||||
params[nparams].kelementgp = values.next_int();
|
||||
params[nparams].ang_flag = values.next_int();
|
||||
params[nparams].pcn_flag = values.next_int();
|
||||
params[nparams].rad_flag = values.next_int();
|
||||
params[nparams].tor_flag = values.next_int();
|
||||
params[nparams].vdwflag = values.next_double();
|
||||
params[nparams].powerm = values.next_double();
|
||||
params[nparams].veps = values.next_double();
|
||||
params[nparams].vsig = values.next_double();
|
||||
params[nparams].paaa = values.next_double();
|
||||
params[nparams].pbbb = values.next_double();
|
||||
params[nparams].lami = values.next_double();
|
||||
params[nparams].alfi = values.next_double();
|
||||
params[nparams].powern = values.next_double();
|
||||
params[nparams].QL = values.next_double();
|
||||
params[nparams].QU = values.next_double();
|
||||
params[nparams].DL = values.next_double();
|
||||
params[nparams].DU = values.next_double();
|
||||
params[nparams].qmin = values.next_double();
|
||||
params[nparams].qmax = values.next_double();
|
||||
params[nparams].chi = values.next_double();
|
||||
params[nparams].dj = values.next_double();
|
||||
params[nparams].dk = values.next_double();
|
||||
params[nparams].dl = values.next_double();
|
||||
params[nparams].esm = values.next_double();
|
||||
params[nparams].cmn1 = values.next_double();
|
||||
params[nparams].cmn2 = values.next_double();
|
||||
params[nparams].pcmn1 = values.next_double();
|
||||
params[nparams].pcmn2 = values.next_double();
|
||||
params[nparams].coulcut = values.next_double();
|
||||
params[nparams].polz = values.next_double();
|
||||
params[nparams].curl = values.next_double();
|
||||
params[nparams].curlcut1 = values.next_double();
|
||||
params[nparams].curlcut2 = values.next_double();
|
||||
params[nparams].curl0 = values.next_double();
|
||||
params[nparams].alpha1 = values.next_double();
|
||||
params[nparams].bigB1 = values.next_double();
|
||||
params[nparams].alpha2 = values.next_double();
|
||||
params[nparams].bigB2 = values.next_double();
|
||||
params[nparams].alpha3 = values.next_double();
|
||||
params[nparams].bigB3 = values.next_double();
|
||||
params[nparams].lambda = values.next_double();
|
||||
params[nparams].bigA = values.next_double();
|
||||
params[nparams].beta = values.next_double();
|
||||
params[nparams].bigr = values.next_double();
|
||||
params[nparams].bigd = values.next_double();
|
||||
params[nparams].pcos6 = values.next_double();
|
||||
params[nparams].pcos5 = values.next_double();
|
||||
params[nparams].pcos4 = values.next_double();
|
||||
params[nparams].pcos3 = values.next_double();
|
||||
params[nparams].pcos2 = values.next_double();
|
||||
params[nparams].pcos1 = values.next_double();
|
||||
params[nparams].pcos0 = values.next_double();
|
||||
params[nparams].pcna = values.next_double();
|
||||
params[nparams].pcnb = values.next_double();
|
||||
params[nparams].pcnc = values.next_double();
|
||||
params[nparams].pcnd = values.next_double();
|
||||
params[nparams].p6p0 = values.next_double();
|
||||
params[nparams].p6p1 = values.next_double();
|
||||
params[nparams].p6p2 = values.next_double();
|
||||
params[nparams].p6p3 = values.next_double();
|
||||
params[nparams].p6p4 = values.next_double();
|
||||
params[nparams].p6p5 = values.next_double();
|
||||
params[nparams].p6p6 = values.next_double();
|
||||
params[nparams].ptork1 = values.next_double();
|
||||
params[nparams].ptork2 = values.next_double();
|
||||
params[nparams].addrepr = values.next_double();
|
||||
params[nparams].addrep = values.next_double();
|
||||
params[nparams].pcross = values.next_double();
|
||||
params[nparams].powermint = int(params[nparams].powerm);
|
||||
} catch (TokenizerException & e) {
|
||||
error->one(FLERR, e.what());
|
||||
}
|
||||
|
||||
// parameter sanity checks
|
||||
|
||||
@ -783,12 +719,20 @@ void PairComb3::read_file(char *file)
|
||||
params[nparams].esm < 0.0 || params[nparams].veps < 0.0 ||
|
||||
params[nparams].vsig < 0.0 || params[nparams].vdwflag < 0.0
|
||||
)
|
||||
error->all(FLERR,"Illegal COMB3 parameter");
|
||||
error->one(FLERR,"Illegal COMB3 parameter");
|
||||
|
||||
nparams++;
|
||||
}
|
||||
}
|
||||
|
||||
delete [] words;
|
||||
MPI_Bcast(&nparams, 1, MPI_INT, 0, world);
|
||||
MPI_Bcast(&maxparam, 1, MPI_INT, 0, world);
|
||||
|
||||
if(comm->me != 0) {
|
||||
params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params");
|
||||
}
|
||||
|
||||
MPI_Bcast(params, maxparam*sizeof(Param), MPI_BYTE, 0, world);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -37,8 +37,10 @@ class PairComb3 : public Pair {
|
||||
virtual double combqeq(double *, int &);
|
||||
double enegtot;
|
||||
|
||||
// general potential parameters
|
||||
static const int NPARAMS_PER_LINE = 74;
|
||||
|
||||
protected:
|
||||
// general potential parameters
|
||||
struct Param {
|
||||
int ielement,jelement,kelement,powermint;
|
||||
int ielementgp,jelementgp,kelementgp; //element group
|
||||
|
||||
@ -29,6 +29,8 @@
|
||||
#include "error.h"
|
||||
#include "update.h"
|
||||
#include "utils.h"
|
||||
#include "tokenizer.h"
|
||||
#include "potential_file_reader.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
@ -462,30 +464,43 @@ void PairEAM::read_file(char *filename)
|
||||
{
|
||||
Funcfl *file = &funcfl[nfuncfl-1];
|
||||
|
||||
int me = comm->me;
|
||||
FILE *fptr;
|
||||
char line[MAXLINE];
|
||||
// read potential file
|
||||
if(comm->me == 0) {
|
||||
PotentialFileReader reader(lmp, filename, "EAM");
|
||||
|
||||
if (me == 0) {
|
||||
fptr = force->open_potential(filename);
|
||||
if (fptr == NULL) {
|
||||
char str[128];
|
||||
snprintf(str,128,"Cannot open EAM potential file %s",filename);
|
||||
error->one(FLERR,str);
|
||||
try {
|
||||
char * line = nullptr;
|
||||
|
||||
reader.skip_line();
|
||||
|
||||
line = reader.next_line(2);
|
||||
ValueTokenizer values(line);
|
||||
values.next_int(); // ignore
|
||||
file->mass = values.next_double();
|
||||
|
||||
line = reader.next_line(5);
|
||||
values = ValueTokenizer(line);
|
||||
file->nrho = values.next_int();
|
||||
file->drho = values.next_double();
|
||||
file->nr = values.next_int();
|
||||
file->dr = values.next_double();
|
||||
file->cut = values.next_double();
|
||||
|
||||
if ((file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0))
|
||||
error->one(FLERR,"Invalid EAM potential file");
|
||||
|
||||
memory->create(file->frho, (file->nrho+1), "pair:frho");
|
||||
memory->create(file->rhor, (file->nr+1), "pair:rhor");
|
||||
memory->create(file->zr, (file->nr+1), "pair:zr");
|
||||
|
||||
reader.next_dvector(file->nrho, &file->frho[1]);
|
||||
reader.next_dvector(file->nr, &file->zr[1]);
|
||||
reader.next_dvector(file->nr, &file->rhor[1]);
|
||||
} catch (TokenizerException & e) {
|
||||
error->one(FLERR, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
int tmp,nwords;
|
||||
if (me == 0) {
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error);
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error);
|
||||
sscanf(line,"%d %lg",&tmp,&file->mass);
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error);
|
||||
nwords = sscanf(line,"%d %lg %d %lg %lg",
|
||||
&file->nrho,&file->drho,&file->nr,&file->dr,&file->cut);
|
||||
}
|
||||
|
||||
MPI_Bcast(&nwords,1,MPI_INT,0,world);
|
||||
MPI_Bcast(&file->mass, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&file->nrho, 1, MPI_INT, 0, world);
|
||||
MPI_Bcast(&file->drho, 1, MPI_DOUBLE, 0, world);
|
||||
@ -493,23 +508,15 @@ void PairEAM::read_file(char *filename)
|
||||
MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world);
|
||||
|
||||
if ((nwords != 5) || (file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0))
|
||||
error->all(FLERR,"Invalid EAM potential file");
|
||||
|
||||
if(comm->me != 0) {
|
||||
memory->create(file->frho, (file->nrho+1), "pair:frho");
|
||||
memory->create(file->rhor, (file->nr+1), "pair:rhor");
|
||||
memory->create(file->zr, (file->nr+1), "pair:zr");
|
||||
}
|
||||
|
||||
if (me == 0) grab(fptr,file->nrho,&file->frho[1]);
|
||||
MPI_Bcast(&file->frho[1], file->nrho, MPI_DOUBLE, 0, world);
|
||||
|
||||
if (me == 0) grab(fptr,file->nr,&file->zr[1]);
|
||||
MPI_Bcast(&file->zr[1], file->nr, MPI_DOUBLE, 0, world);
|
||||
|
||||
if (me == 0) grab(fptr,file->nr,&file->rhor[1]);
|
||||
MPI_Bcast(&file->rhor[1], file->nr, MPI_DOUBLE, 0, world);
|
||||
|
||||
if (me == 0) fclose(fptr);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -782,26 +789,6 @@ void PairEAM::interpolate(int n, double delta, double *f, double **spline)
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
grab n values from file fp and put them in list
|
||||
values can be several to a line
|
||||
only called by proc 0
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void PairEAM::grab(FILE *fptr, int n, double *list)
|
||||
{
|
||||
char *ptr;
|
||||
char line[MAXLINE];
|
||||
|
||||
int i = 0;
|
||||
while (i < n) {
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,NULL,error);
|
||||
ptr = strtok(line," \t\n\r\f");
|
||||
if (ptr) list[i++] = atof(ptr);
|
||||
while ((ptr = strtok(NULL," \t\n\r\f"))) list[i++] = atof(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
double PairEAM::single(int i, int j, int itype, int jtype,
|
||||
|
||||
@ -107,7 +107,6 @@ class PairEAM : public Pair {
|
||||
virtual void allocate();
|
||||
virtual void array2spline();
|
||||
void interpolate(int, double, double *, double **);
|
||||
void grab(FILE *, int, double *);
|
||||
|
||||
virtual void read_file(char *);
|
||||
virtual void file2array();
|
||||
|
||||
@ -24,11 +24,11 @@
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "utils.h"
|
||||
#include "tokenizer.h"
|
||||
#include "potential_file_reader.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define MAXLINE 1024
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PairEAMAlloy::PairEAMAlloy(LAMMPS *lmp) : PairEAM(lmp)
|
||||
@ -61,7 +61,7 @@ void PairEAMAlloy::coeff(int narg, char **arg)
|
||||
if (setfl) {
|
||||
for (i = 0; i < setfl->nelements; i++) delete [] setfl->elements[i];
|
||||
delete [] setfl->elements;
|
||||
delete [] setfl->mass;
|
||||
memory->destroy(setfl->mass);
|
||||
memory->destroy(setfl->frho);
|
||||
memory->destroy(setfl->rhor);
|
||||
memory->destroy(setfl->z2r);
|
||||
@ -117,98 +117,112 @@ void PairEAMAlloy::read_file(char *filename)
|
||||
{
|
||||
Setfl *file = setfl;
|
||||
|
||||
// open potential file
|
||||
// read potential file
|
||||
if(comm->me == 0) {
|
||||
PotentialFileReader reader(lmp, filename, "EAM");
|
||||
|
||||
int me = comm->me;
|
||||
FILE *fptr;
|
||||
char line[MAXLINE];
|
||||
try {
|
||||
char * line = nullptr;
|
||||
|
||||
if (me == 0) {
|
||||
fptr = force->open_potential(filename);
|
||||
if (fptr == NULL) {
|
||||
char str[128];
|
||||
snprintf(str,128,"Cannot open EAM potential file %s",filename);
|
||||
error->one(FLERR,str);
|
||||
}
|
||||
}
|
||||
reader.skip_line();
|
||||
reader.skip_line();
|
||||
reader.skip_line();
|
||||
|
||||
// read and broadcast header
|
||||
// extract element names from nelements line
|
||||
line = reader.next_line(1);
|
||||
ValueTokenizer values(line);
|
||||
file->nelements = values.next_int();
|
||||
|
||||
int n;
|
||||
if (me == 0) {
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error);
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error);
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error);
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error);
|
||||
n = strlen(line) + 1;
|
||||
}
|
||||
MPI_Bcast(&n,1,MPI_INT,0,world);
|
||||
MPI_Bcast(line,n,MPI_CHAR,0,world);
|
||||
|
||||
sscanf(line,"%d",&file->nelements);
|
||||
int nwords = atom->count_words(line);
|
||||
if (nwords != file->nelements + 1)
|
||||
error->all(FLERR,"Incorrect element names in EAM potential file");
|
||||
|
||||
char **words = new char*[file->nelements+1];
|
||||
nwords = 0;
|
||||
strtok(line," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue;
|
||||
if (values.count() != file->nelements + 1)
|
||||
error->one(FLERR,"Incorrect element names in EAM potential file");
|
||||
|
||||
file->elements = new char*[file->nelements];
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
n = strlen(words[i]) + 1;
|
||||
const std::string word = values.next_string();
|
||||
const int n = word.length() + 1;
|
||||
file->elements[i] = new char[n];
|
||||
strcpy(file->elements[i],words[i]);
|
||||
}
|
||||
delete [] words;
|
||||
|
||||
if (me == 0) {
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error);
|
||||
nwords = sscanf(line,"%d %lg %d %lg %lg",
|
||||
&file->nrho,&file->drho,&file->nr,&file->dr,&file->cut);
|
||||
strcpy(file->elements[i], word.c_str());
|
||||
}
|
||||
|
||||
MPI_Bcast(&nwords,1,MPI_INT,0,world);
|
||||
//
|
||||
|
||||
line = reader.next_line(5);
|
||||
values = ValueTokenizer(line);
|
||||
file->nrho = values.next_int();
|
||||
file->drho = values.next_double();
|
||||
file->nr = values.next_int();
|
||||
file->dr = values.next_double();
|
||||
file->cut = values.next_double();
|
||||
|
||||
if ((file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0))
|
||||
error->one(FLERR,"Invalid EAM potential file");
|
||||
|
||||
memory->create(file->mass, file->nelements, "pair:mass");
|
||||
memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho");
|
||||
memory->create(file->rhor, file->nelements, file->nr + 1, "pair:rhor");
|
||||
memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r");
|
||||
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
line = reader.next_line(2);
|
||||
values = ValueTokenizer(line);
|
||||
values.next_int(); // ignore
|
||||
file->mass[i] = values.next_double();
|
||||
|
||||
reader.next_dvector(file->nrho, &file->frho[i][1]);
|
||||
reader.next_dvector(file->nr, &file->rhor[i][1]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
for (int j = 0; j <= i; j++) {
|
||||
reader.next_dvector(file->nr, &file->z2r[i][j][1]);
|
||||
}
|
||||
}
|
||||
} catch (TokenizerException & e) {
|
||||
error->one(FLERR, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
// broadcast potential information
|
||||
MPI_Bcast(&file->nelements, 1, MPI_INT, 0, world);
|
||||
|
||||
MPI_Bcast(&file->nrho, 1, MPI_INT, 0, world);
|
||||
MPI_Bcast(&file->drho, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&file->nr, 1, MPI_INT, 0, world);
|
||||
MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world);
|
||||
|
||||
if ((nwords != 5) || (file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0))
|
||||
error->all(FLERR,"Invalid EAM potential file");
|
||||
|
||||
file->mass = new double[file->nelements];
|
||||
// allocate memory on other procs
|
||||
if (comm->me != 0) {
|
||||
file->elements = new char*[file->nelements];
|
||||
for (int i = 0; i < file->nelements; i++) file->elements[i] = nullptr;
|
||||
memory->create(file->mass, file->nelements, "pair:mass");
|
||||
memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho");
|
||||
memory->create(file->rhor, file->nelements, file->nr + 1, "pair:rhor");
|
||||
memory->create(file->z2r,file->nelements,file->nelements,file->nr+1,
|
||||
"pair:z2r");
|
||||
|
||||
int i,j,tmp;
|
||||
for (i = 0; i < file->nelements; i++) {
|
||||
if (me == 0) {
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error);
|
||||
sscanf(line,"%d %lg",&tmp,&file->mass[i]);
|
||||
memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r");
|
||||
}
|
||||
MPI_Bcast(&file->mass[i],1,MPI_DOUBLE,0,world);
|
||||
|
||||
if (me == 0) grab(fptr,file->nrho,&file->frho[i][1]);
|
||||
// broadcast file->elements string array
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
int n;
|
||||
if (comm->me == 0) n = strlen(file->elements[i]) + 1;
|
||||
MPI_Bcast(&n, 1, MPI_INT, 0, world);
|
||||
if (comm->me != 0) file->elements[i] = new char[n];
|
||||
MPI_Bcast(file->elements[i], n, MPI_CHAR, 0, world);
|
||||
}
|
||||
|
||||
// broadcast file->mass, frho, rhor
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
MPI_Bcast(&file->mass[i], 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&file->frho[i][1], file->nrho, MPI_DOUBLE, 0, world);
|
||||
if (me == 0) grab(fptr,file->nr,&file->rhor[i][1]);
|
||||
MPI_Bcast(&file->rhor[i][1], file->nr, MPI_DOUBLE, 0, world);
|
||||
}
|
||||
|
||||
for (i = 0; i < file->nelements; i++)
|
||||
for (j = 0; j <= i; j++) {
|
||||
if (me == 0) grab(fptr,file->nr,&file->z2r[i][j][1]);
|
||||
// broadcast file->z2r
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
for (int j = 0; j <= i; j++) {
|
||||
MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world);
|
||||
}
|
||||
|
||||
// close the potential file
|
||||
|
||||
if (me == 0) fclose(fptr);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
#include "neigh_list.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "tokenizer.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
@ -512,16 +513,20 @@ void PairEAMCD::read_h_coeff(char *filename)
|
||||
while(fgets(nextline, MAXLINE, fptr) != NULL) {
|
||||
strcpy(line, nextline);
|
||||
}
|
||||
char* ptr = strtok(line, " \t\n\r\f");
|
||||
int degree = atoi(ptr);
|
||||
|
||||
ValueTokenizer values(line, " \t\n\r\f");
|
||||
int degree = values.next_int();
|
||||
nhcoeff = degree+1;
|
||||
|
||||
if (values.count() != nhcoeff + 1 || nhcoeff < 1)
|
||||
error->one(FLERR, "Failed to read h(x) function coefficients in EAM file.");
|
||||
|
||||
hcoeff = new double[nhcoeff];
|
||||
|
||||
int i = 0;
|
||||
while((ptr = strtok(NULL," \t\n\r\f")) != NULL && i < nhcoeff) {
|
||||
hcoeff[i++] = atof(ptr);
|
||||
while(values.has_next()) {
|
||||
hcoeff[i++] = values.next_double();
|
||||
}
|
||||
if (i != nhcoeff || nhcoeff < 1)
|
||||
error->one(FLERR,"Failed to read h(x) function coefficients from EAM file.");
|
||||
|
||||
// Close the potential file.
|
||||
|
||||
|
||||
@ -24,11 +24,11 @@
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "utils.h"
|
||||
#include "tokenizer.h"
|
||||
#include "potential_file_reader.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define MAXLINE 1024
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PairEAMFS::PairEAMFS(LAMMPS *lmp) : PairEAM(lmp)
|
||||
@ -61,7 +61,7 @@ void PairEAMFS::coeff(int narg, char **arg)
|
||||
if (fs) {
|
||||
for (i = 0; i < fs->nelements; i++) delete [] fs->elements[i];
|
||||
delete [] fs->elements;
|
||||
delete [] fs->mass;
|
||||
memory->destroy(fs->mass);
|
||||
memory->destroy(fs->frho);
|
||||
memory->destroy(fs->rhor);
|
||||
memory->destroy(fs->z2r);
|
||||
@ -117,103 +117,118 @@ void PairEAMFS::read_file(char *filename)
|
||||
{
|
||||
Fs *file = fs;
|
||||
|
||||
// open potential file
|
||||
// read potential file
|
||||
if(comm->me == 0) {
|
||||
PotentialFileReader reader(lmp, filename, "EAM");
|
||||
|
||||
int me = comm->me;
|
||||
FILE *fptr;
|
||||
char line[MAXLINE];
|
||||
try {
|
||||
char * line = nullptr;
|
||||
|
||||
if (me == 0) {
|
||||
fptr = force->open_potential(filename);
|
||||
if (fptr == NULL) {
|
||||
char str[128];
|
||||
snprintf(str,128,"Cannot open EAM potential file %s",filename);
|
||||
error->one(FLERR,str);
|
||||
}
|
||||
}
|
||||
reader.skip_line();
|
||||
reader.skip_line();
|
||||
reader.skip_line();
|
||||
|
||||
// read and broadcast header
|
||||
// extract element names from nelements line
|
||||
line = reader.next_line(1);
|
||||
ValueTokenizer values(line);
|
||||
file->nelements = values.next_int();
|
||||
|
||||
int n;
|
||||
if (me == 0) {
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error);
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error);
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error);
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error);
|
||||
n = strlen(line) + 1;
|
||||
}
|
||||
MPI_Bcast(&n,1,MPI_INT,0,world);
|
||||
MPI_Bcast(line,n,MPI_CHAR,0,world);
|
||||
|
||||
sscanf(line,"%d",&file->nelements);
|
||||
int nwords = atom->count_words(line);
|
||||
if (nwords != file->nelements + 1)
|
||||
error->all(FLERR,"Incorrect element names in EAM potential file");
|
||||
|
||||
char **words = new char*[file->nelements+1];
|
||||
nwords = 0;
|
||||
strtok(line," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue;
|
||||
if (values.count() != file->nelements + 1)
|
||||
error->one(FLERR,"Incorrect element names in EAM potential file");
|
||||
|
||||
file->elements = new char*[file->nelements];
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
n = strlen(words[i]) + 1;
|
||||
const std::string word = values.next_string();
|
||||
const int n = word.length() + 1;
|
||||
file->elements[i] = new char[n];
|
||||
strcpy(file->elements[i],words[i]);
|
||||
}
|
||||
delete [] words;
|
||||
|
||||
if (me == 0) {
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error);
|
||||
nwords = sscanf(line,"%d %lg %d %lg %lg",
|
||||
&file->nrho,&file->drho,&file->nr,&file->dr,&file->cut);
|
||||
strcpy(file->elements[i], word.c_str());
|
||||
}
|
||||
|
||||
MPI_Bcast(&nwords,1,MPI_INT,0,world);
|
||||
//
|
||||
|
||||
line = reader.next_line(5);
|
||||
values = ValueTokenizer(line);
|
||||
file->nrho = values.next_int();
|
||||
file->drho = values.next_double();
|
||||
file->nr = values.next_int();
|
||||
file->dr = values.next_double();
|
||||
file->cut = values.next_double();
|
||||
|
||||
if ((file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0))
|
||||
error->one(FLERR,"Invalid EAM potential file");
|
||||
|
||||
memory->create(file->mass, file->nelements, "pair:mass");
|
||||
memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho");
|
||||
memory->create(file->rhor, file->nelements, file->nelements, file->nr + 1, "pair:rhor");
|
||||
memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r");
|
||||
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
line = reader.next_line(2);
|
||||
values = ValueTokenizer(line);
|
||||
values.next_int(); // ignore
|
||||
file->mass[i] = values.next_double();
|
||||
|
||||
reader.next_dvector(file->nrho, &file->frho[i][1]);
|
||||
|
||||
for (int j = 0; j < file->nelements; j++) {
|
||||
reader.next_dvector(file->nr, &file->rhor[i][j][1]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
for (int j = 0; j <= i; j++) {
|
||||
reader.next_dvector(file->nr, &file->z2r[i][j][1]);
|
||||
}
|
||||
}
|
||||
} catch (TokenizerException & e) {
|
||||
error->one(FLERR, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
// broadcast potential information
|
||||
MPI_Bcast(&file->nelements, 1, MPI_INT, 0, world);
|
||||
|
||||
MPI_Bcast(&file->nrho, 1, MPI_INT, 0, world);
|
||||
MPI_Bcast(&file->drho, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&file->nr, 1, MPI_INT, 0, world);
|
||||
MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world);
|
||||
|
||||
if ((nwords != 5) || (file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0))
|
||||
error->all(FLERR,"Invalid EAM potential file");
|
||||
|
||||
file->mass = new double[file->nelements];
|
||||
memory->create(file->frho,file->nelements,file->nrho+1,
|
||||
"pair:frho");
|
||||
memory->create(file->rhor,file->nelements,file->nelements,
|
||||
file->nr+1,"pair:rhor");
|
||||
memory->create(file->z2r,file->nelements,file->nelements,
|
||||
file->nr+1,"pair:z2r");
|
||||
|
||||
int i,j,tmp;
|
||||
for (i = 0; i < file->nelements; i++) {
|
||||
if (me == 0) {
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error);
|
||||
sscanf(line,"%d %lg",&tmp,&file->mass[i]);
|
||||
// allocate memory on other procs
|
||||
if (comm->me != 0) {
|
||||
file->elements = new char*[file->nelements];
|
||||
for (int i = 0; i < file->nelements; i++) file->elements[i] = nullptr;
|
||||
memory->create(file->mass, file->nelements, "pair:mass");
|
||||
memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho");
|
||||
memory->create(file->rhor, file->nelements, file->nelements, file->nr + 1, "pair:rhor");
|
||||
memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r");
|
||||
}
|
||||
MPI_Bcast(&file->mass[i],1,MPI_DOUBLE,0,world);
|
||||
|
||||
if (me == 0) grab(fptr,file->nrho,&file->frho[i][1]);
|
||||
// broadcast file->elements string array
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
int n;
|
||||
if (comm->me == 0) n = strlen(file->elements[i]) + 1;
|
||||
MPI_Bcast(&n, 1, MPI_INT, 0, world);
|
||||
if (comm->me != 0) file->elements[i] = new char[n];
|
||||
MPI_Bcast(file->elements[i], n, MPI_CHAR, 0, world);
|
||||
}
|
||||
|
||||
// broadcast file->mass, frho, rhor
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
MPI_Bcast(&file->mass[i], 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&file->frho[i][1], file->nrho, MPI_DOUBLE, 0, world);
|
||||
|
||||
for (j = 0; j < file->nelements; j++) {
|
||||
if (me == 0) grab(fptr,file->nr,&file->rhor[i][j][1]);
|
||||
for (int j = 0; j < file->nelements; j++) {
|
||||
MPI_Bcast(&file->rhor[i][j][1], file->nr, MPI_DOUBLE, 0, world);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < file->nelements; i++)
|
||||
for (j = 0; j <= i; j++) {
|
||||
if (me == 0) grab(fptr,file->nr,&file->z2r[i][j][1]);
|
||||
// broadcast file->z2r
|
||||
for (int i = 0; i < file->nelements; i++) {
|
||||
for (int j = 0; j <= i; j++) {
|
||||
MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world);
|
||||
}
|
||||
|
||||
// close the potential file
|
||||
|
||||
if (me == 0) fclose(fptr);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
@ -27,11 +27,11 @@
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "utils.h"
|
||||
#include "tokenizer.h"
|
||||
#include "potential_file_reader.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define MAXLINE 1024
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PairEIM::PairEIM(LAMMPS *lmp) : Pair(lmp)
|
||||
@ -451,20 +451,6 @@ double PairEIM::init_one(int i, int j)
|
||||
|
||||
void PairEIM::read_file(char *filename)
|
||||
{
|
||||
// open potential file
|
||||
|
||||
int me = comm->me;
|
||||
FILE *fptr;
|
||||
|
||||
if (me == 0) {
|
||||
fptr = force->open_potential(filename);
|
||||
if (fptr == NULL) {
|
||||
char str[128];
|
||||
snprintf(str,128,"Cannot open EIM potential file %s",filename);
|
||||
error->one(FLERR,str);
|
||||
}
|
||||
}
|
||||
|
||||
int npair = nelements*(nelements+1)/2;
|
||||
setfl->ielement = new int[nelements];
|
||||
setfl->mass = new double[nelements];
|
||||
@ -488,24 +474,14 @@ void PairEIM::read_file(char *filename)
|
||||
setfl->rs = new double[npair];
|
||||
setfl->tp = new int[npair];
|
||||
|
||||
if (me == 0)
|
||||
if (!grabglobal(fptr))
|
||||
error->one(FLERR,"Could not grab global entry from EIM potential file");
|
||||
MPI_Bcast(&setfl->division,1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&setfl->rbig,1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&setfl->rsmall,1,MPI_DOUBLE,0,world);
|
||||
// read potential file
|
||||
if( comm->me == 0) {
|
||||
EIMPotentialFileReader reader(lmp, filename);
|
||||
|
||||
reader.get_global(setfl);
|
||||
|
||||
for (int i = 0; i < nelements; i++) {
|
||||
if (me == 0)
|
||||
if (!grabsingle(fptr,i))
|
||||
error->one(FLERR,"Could not grab element entry from EIM potential file");
|
||||
MPI_Bcast(&setfl->ielement[i],1,MPI_INT,0,world);
|
||||
MPI_Bcast(&setfl->mass[i],1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&setfl->negativity[i],1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&setfl->ra[i],1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&setfl->ri[i],1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&setfl->Ec[i],1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&setfl->q0[i],1,MPI_DOUBLE,0,world);
|
||||
reader.get_element(setfl, i, elements[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < nelements; i++) {
|
||||
@ -514,25 +490,38 @@ void PairEIM::read_file(char *filename)
|
||||
if (i == j) ij = i;
|
||||
else if (i < j) ij = nelements*(i+1) - (i+1)*(i+2)/2 + j;
|
||||
else ij = nelements*(j+1) - (j+1)*(j+2)/2 + i;
|
||||
if (me == 0)
|
||||
if (grabpair(fptr,i,j) == 0)
|
||||
error->one(FLERR,"Could not grab pair entry from EIM potential file");
|
||||
MPI_Bcast(&setfl->rcutphiA[ij],1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&setfl->rcutphiR[ij],1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&setfl->Eb[ij],1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&setfl->r0[ij],1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&setfl->alpha[ij],1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&setfl->beta[ij],1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&setfl->rcutq[ij],1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&setfl->Asigma[ij],1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&setfl->rq[ij],1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&setfl->rcutsigma[ij],1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&setfl->Ac[ij],1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&setfl->zeta[ij],1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&setfl->rs[ij],1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&setfl->tp[ij],1,MPI_INT,0,world);
|
||||
reader.get_pair(setfl, ij, elements[i], elements[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// broadcast potential information to other procs
|
||||
MPI_Bcast(&setfl->division, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&setfl->rbig, 1, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(&setfl->rsmall, 1, MPI_DOUBLE, 0, world);
|
||||
|
||||
MPI_Bcast(setfl->ielement, nelements, MPI_INT, 0, world);
|
||||
MPI_Bcast(setfl->mass, nelements, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(setfl->negativity, nelements, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(setfl->ra, nelements, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(setfl->ri, nelements, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(setfl->Ec, nelements, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(setfl->q0, nelements, MPI_DOUBLE, 0, world);
|
||||
|
||||
MPI_Bcast(setfl->rcutphiA, npair, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(setfl->rcutphiR, npair, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(setfl->Eb, npair, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(setfl->r0, npair, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(setfl->alpha, npair, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(setfl->beta, npair, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(setfl->rcutq, npair, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(setfl->Asigma, npair, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(setfl->rq, npair, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(setfl->rcutsigma, npair, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(setfl->Ac, npair, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(setfl->zeta, npair, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(setfl->rs, npair, MPI_DOUBLE, 0, world);
|
||||
MPI_Bcast(setfl->tp, npair, MPI_INT, 0, world);
|
||||
|
||||
setfl->nr = 5000;
|
||||
setfl->cut = 0.0;
|
||||
@ -602,10 +591,6 @@ void PairEIM::read_file(char *filename)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// close the potential file
|
||||
|
||||
if (me == 0) fclose(fptr);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -879,114 +864,6 @@ void PairEIM::interpolate(int n, double delta, double *f,
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
grab global line from file and store info in setfl
|
||||
return 0 if error
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int PairEIM::grabglobal(FILE *fptr)
|
||||
{
|
||||
char line[MAXLINE];
|
||||
|
||||
char *pch = NULL, *data = NULL;
|
||||
while (pch == NULL) {
|
||||
if (fgets(line,MAXLINE,fptr) == NULL) break;
|
||||
pch = strstr(line,"global");
|
||||
if (pch != NULL) {
|
||||
data = strtok (line," \t\n\r\f");
|
||||
data = strtok (NULL,"?");
|
||||
sscanf(data,"%lg %lg %lg",&setfl->division,&setfl->rbig,&setfl->rsmall);
|
||||
}
|
||||
}
|
||||
if (pch == NULL) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
grab elemental line from file and store info in setfl
|
||||
return 0 if error
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int PairEIM::grabsingle(FILE *fptr, int i)
|
||||
{
|
||||
char line[MAXLINE];
|
||||
|
||||
rewind(fptr);
|
||||
|
||||
char *pch1 = NULL, *pch2 = NULL, *data = NULL;
|
||||
while (pch1 == NULL || pch2 == NULL) {
|
||||
if (fgets(line,MAXLINE,fptr) == NULL) break;
|
||||
pch1 = strtok (line," \t\n\r\f");
|
||||
pch1 = strstr(pch1,"element:");
|
||||
if (pch1 != NULL) {
|
||||
pch2 = strtok(NULL, " \t\n\r\f");
|
||||
if (pch2 != NULL) {
|
||||
data = strtok (NULL, "?");
|
||||
if (strcmp(pch2,elements[i]) == 0) {
|
||||
sscanf(data,"%d %lg %lg %lg %lg %lg %lg",&setfl->ielement[i],
|
||||
&setfl->mass[i],&setfl->negativity[i],&setfl->ra[i],
|
||||
&setfl->ri[i],&setfl->Ec[i],&setfl->q0[i]);
|
||||
} else pch2 = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pch1 == NULL || pch2 == NULL) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
grab pair line from file and store info in setfl
|
||||
return 0 if error
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int PairEIM::grabpair(FILE *fptr, int i, int j)
|
||||
{
|
||||
char line[MAXLINE];
|
||||
|
||||
rewind(fptr);
|
||||
|
||||
int ij;
|
||||
if (i == j) ij = i;
|
||||
else if (i < j) ij = nelements*(i+1) - (i+1)*(i+2)/2 + j;
|
||||
else ij = nelements*(j+1) - (j+1)*(j+2)/2 + i;
|
||||
|
||||
char *pch1 = NULL, *pch2 = NULL, *pch3 = NULL, *data = NULL;
|
||||
while (pch1 == NULL || pch2 == NULL || pch3 == NULL) {
|
||||
if (fgets(line,MAXLINE,fptr) == NULL) break;
|
||||
pch1 = strtok (line," \t\n\r\f");
|
||||
pch1 = strstr(pch1,"pair:");
|
||||
if (pch1 != NULL) {
|
||||
pch2 = strtok (NULL, " \t\n\r\f");
|
||||
if (pch2 != NULL) pch3 = strtok (NULL, " \t\n\r\f");
|
||||
if (pch3 != NULL) data = strtok (NULL, "?");
|
||||
if ((pch2 != NULL) && (pch3 != NULL)) {
|
||||
if ((strcmp(pch2,elements[i]) == 0 &&
|
||||
strcmp(pch3,elements[j]) == 0) ||
|
||||
(strcmp(pch2,elements[j]) == 0 &&
|
||||
strcmp(pch3,elements[i]) == 0)) {
|
||||
sscanf(data,"%lg %lg %lg %lg %lg",
|
||||
&setfl->rcutphiA[ij],&setfl->rcutphiR[ij],
|
||||
&setfl->Eb[ij],&setfl->r0[ij],&setfl->alpha[ij]);
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,NULL,error);
|
||||
sscanf(line,"%lg %lg %lg %lg %lg",
|
||||
&setfl->beta[ij],&setfl->rcutq[ij],&setfl->Asigma[ij],
|
||||
&setfl->rq[ij],&setfl->rcutsigma[ij]);
|
||||
utils::sfgets(FLERR,line,MAXLINE,fptr,NULL,error);
|
||||
sscanf(line,"%lg %lg %lg %d",
|
||||
&setfl->Ac[ij],&setfl->zeta[ij],&setfl->rs[ij],
|
||||
&setfl->tp[ij]);
|
||||
} else {
|
||||
pch1 = NULL;
|
||||
pch2 = NULL;
|
||||
pch3 = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pch1 == NULL || pch2 == NULL || pch3 == NULL) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
cutoff function
|
||||
------------------------------------------------------------------------- */
|
||||
@ -1171,3 +1048,221 @@ double PairEIM::memory_usage()
|
||||
bytes += 2 * nmax * sizeof(double);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
EIMPotentialFileReader::EIMPotentialFileReader(LAMMPS * lmp, const std::string & filename) :
|
||||
Pointers(lmp), filename(filename)
|
||||
{
|
||||
if (comm->me != 0) {
|
||||
error->one(FLERR, "EIMPotentialFileReader should only be called by proc 0!");
|
||||
}
|
||||
|
||||
FILE * fp = force->open_potential(filename.c_str());
|
||||
|
||||
if (fp == NULL) {
|
||||
char str[128];
|
||||
snprintf(str, 128, "cannot open EIM potential file %s", filename.c_str());
|
||||
error->one(FLERR, str);
|
||||
}
|
||||
|
||||
parse(fp);
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
std::pair<std::string, std::string> EIMPotentialFileReader::get_pair(const std::string & a, const std::string & b) {
|
||||
if (a < b) {
|
||||
return std::make_pair(a, b);
|
||||
}
|
||||
return std::make_pair(b, a);
|
||||
}
|
||||
|
||||
char * EIMPotentialFileReader::next_line(FILE * fp) {
|
||||
// concatenate lines if they end with '&'
|
||||
// strip comments after '#'
|
||||
int n = 0;
|
||||
int nwords = 0;
|
||||
bool concat = false;
|
||||
|
||||
char *ptr = fgets(line, MAXLINE, fp);
|
||||
|
||||
if (ptr == nullptr) {
|
||||
// EOF
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// strip comment
|
||||
if ((ptr = strchr(line, '#'))) *ptr = '\0';
|
||||
|
||||
// strip ampersand
|
||||
if ((ptr = strrchr(line, '&'))) {
|
||||
concat = true;
|
||||
*ptr = '\0';
|
||||
}
|
||||
|
||||
nwords = utils::count_words(line);
|
||||
|
||||
if (nwords > 0) {
|
||||
n = strlen(line);
|
||||
}
|
||||
|
||||
while(n == 0 || concat) {
|
||||
char *ptr = fgets(&line[n], MAXLINE - n, fp);
|
||||
|
||||
if (ptr == nullptr) {
|
||||
// EOF
|
||||
return line;
|
||||
}
|
||||
|
||||
// strip comment
|
||||
if ((ptr = strchr(line, '#'))) *ptr = '\0';
|
||||
|
||||
// strip ampersand
|
||||
if ((ptr = strrchr(line, '&'))) {
|
||||
concat = true;
|
||||
*ptr = '\0';
|
||||
} else {
|
||||
concat = false;
|
||||
}
|
||||
|
||||
nwords = utils::count_words(line);
|
||||
|
||||
// skip line if blank
|
||||
if (nwords > 0) {
|
||||
n = strlen(line);
|
||||
}
|
||||
}
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
void EIMPotentialFileReader::parse(FILE * fp)
|
||||
{
|
||||
char * line = nullptr;
|
||||
bool found_global = false;
|
||||
|
||||
while((line = next_line(fp))) {
|
||||
ValueTokenizer values(line, " \t\r\n\f");
|
||||
std::string type = values.next_string();
|
||||
|
||||
if (type == "global:") {
|
||||
if (values.count() != 4) {
|
||||
error->one(FLERR, "Invalid global line in EIM potential file");
|
||||
}
|
||||
|
||||
division = values.next_double();
|
||||
rbig = values.next_double();
|
||||
rsmall = values.next_double();
|
||||
|
||||
found_global = true;
|
||||
} else if (type == "element:") {
|
||||
if (values.count() != 9) {
|
||||
error->one(FLERR, "Invalid element line in EIM potential file");
|
||||
}
|
||||
|
||||
std::string name = values.next_string();
|
||||
|
||||
ElementData data;
|
||||
data.ielement = values.next_int();
|
||||
data.mass = values.next_double();
|
||||
data.negativity = values.next_double();
|
||||
data.ra = values.next_double();
|
||||
data.ri = values.next_double();
|
||||
data.Ec = values.next_double();
|
||||
data.q0 = values.next_double();
|
||||
|
||||
if (elements.find(name) == elements.end()) {
|
||||
elements[name] = data;
|
||||
} else {
|
||||
error->one(FLERR, "Duplicate pair line in EIM potential file");
|
||||
}
|
||||
|
||||
} else if (type == "pair:") {
|
||||
if (values.count() != 17) {
|
||||
error->one(FLERR, "Invalid element line in EIM potential file");
|
||||
}
|
||||
|
||||
std::string elementA = values.next_string();
|
||||
std::string elementB = values.next_string();
|
||||
|
||||
PairData data;
|
||||
data.rcutphiA = values.next_double();
|
||||
data.rcutphiR = values.next_double();
|
||||
data.Eb = values.next_double();
|
||||
data.r0 = values.next_double();
|
||||
data.alpha = values.next_double();
|
||||
data.beta = values.next_double();
|
||||
data.rcutq = values.next_double();
|
||||
data.Asigma = values.next_double();
|
||||
data.rq = values.next_double();
|
||||
data.rcutsigma = values.next_double();
|
||||
data.Ac = values.next_double();
|
||||
data.zeta = values.next_double();
|
||||
data.rs = values.next_double();
|
||||
|
||||
// should be next_int, but since existing potential files have 1.0000e+00 format
|
||||
// we're doing this instead to keep compatibility
|
||||
data.tp = (int)values.next_double();
|
||||
|
||||
auto p = get_pair(elementA, elementB);
|
||||
|
||||
if (pairs.find(p) == pairs.end()) {
|
||||
pairs[p] = data;
|
||||
} else {
|
||||
error->one(FLERR, "Duplicate pair line in EIM potential file");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found_global) {
|
||||
error->one(FLERR, "Missing global line in EIM potential file");
|
||||
}
|
||||
}
|
||||
|
||||
void EIMPotentialFileReader::get_global(PairEIM::Setfl * setfl) {
|
||||
setfl->division = division;
|
||||
setfl->rbig = rbig;
|
||||
setfl->rsmall = rsmall;
|
||||
}
|
||||
|
||||
void EIMPotentialFileReader::get_element(PairEIM::Setfl * setfl, int i, const std::string & name) {
|
||||
if (elements.find(name) == elements.end()) {
|
||||
char str[128];
|
||||
snprintf(str, 128, "Element %s not defined in EIM potential file", name.c_str());
|
||||
error->one(FLERR, str);
|
||||
}
|
||||
|
||||
ElementData & data = elements[name];
|
||||
setfl->ielement[i] = data.ielement;
|
||||
setfl->mass[i] = data.mass;
|
||||
setfl->negativity[i] = data.negativity;
|
||||
setfl->ra[i] = data.ra;
|
||||
setfl->ri[i] = data.ri;
|
||||
setfl->Ec[i] = data.Ec;
|
||||
setfl->q0[i] = data.q0;
|
||||
}
|
||||
|
||||
void EIMPotentialFileReader::get_pair(PairEIM::Setfl * setfl, int ij, const std::string & elemA, const std::string & elemB) {
|
||||
auto p = get_pair(elemA, elemB);
|
||||
|
||||
if (pairs.find(p) == pairs.end()) {
|
||||
char str[128];
|
||||
snprintf(str, 128, "Pair (%s, %s) not defined in EIM potential file", elemA.c_str(), elemB.c_str());
|
||||
error->one(FLERR, str);
|
||||
}
|
||||
|
||||
PairData & data = pairs[p];
|
||||
setfl->rcutphiA[ij] = data.rcutphiA;
|
||||
setfl->rcutphiR[ij] = data.rcutphiR;
|
||||
setfl->Eb[ij] = data.Eb;
|
||||
setfl->r0[ij] = data.r0;
|
||||
setfl->alpha[ij] = data.alpha;
|
||||
setfl->beta[ij] = data.beta;
|
||||
setfl->rcutq[ij] = data.rcutq;
|
||||
setfl->Asigma[ij] = data.Asigma;
|
||||
setfl->rq[ij] = data.rq;
|
||||
setfl->rcutsigma[ij] = data.rcutsigma;
|
||||
setfl->Ac[ij] = data.Ac;
|
||||
setfl->zeta[ij] = data.zeta;
|
||||
setfl->rs[ij] = data.rs;
|
||||
setfl->tp[ij] = data.tp;
|
||||
}
|
||||
|
||||
@ -21,6 +21,8 @@ PairStyle(eim,PairEIM)
|
||||
#define LMP_PAIR_EIM_H
|
||||
|
||||
#include "pair.h"
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
@ -40,16 +42,6 @@ class PairEIM : public Pair {
|
||||
void unpack_reverse_comm(int, int *, double *);
|
||||
double memory_usage();
|
||||
|
||||
protected:
|
||||
double **cutforcesq,cutmax;
|
||||
int nmax;
|
||||
double *rho,*fp;
|
||||
int rhofp;
|
||||
int *map; // which element each atom type maps to
|
||||
|
||||
int nelements; // # of elements to read from potential file
|
||||
char **elements; // element names
|
||||
|
||||
struct Setfl {
|
||||
double division,rbig,rsmall;
|
||||
int nr;
|
||||
@ -62,6 +54,17 @@ class PairEIM : public Pair {
|
||||
double ***Fij,***Gij,***phiij;
|
||||
double **cuts;
|
||||
};
|
||||
|
||||
protected:
|
||||
double **cutforcesq,cutmax;
|
||||
int nmax;
|
||||
double *rho,*fp;
|
||||
int rhofp;
|
||||
int *map; // which element each atom type maps to
|
||||
|
||||
int nelements; // # of elements to read from potential file
|
||||
char **elements; // element names
|
||||
|
||||
Setfl *setfl;
|
||||
|
||||
// potentials as array data
|
||||
@ -80,9 +83,6 @@ class PairEIM : public Pair {
|
||||
void allocate();
|
||||
void array2spline();
|
||||
void interpolate(int, double, double *, double **, double);
|
||||
int grabglobal(FILE *);
|
||||
int grabsingle(FILE *, int);
|
||||
int grabpair(FILE *, int, int);
|
||||
|
||||
double funccutoff(double, double, double);
|
||||
double funcphi(int, int, double);
|
||||
@ -94,6 +94,59 @@ class PairEIM : public Pair {
|
||||
void file2array();
|
||||
};
|
||||
|
||||
class EIMPotentialFileReader : protected Pointers {
|
||||
std::string filename;
|
||||
static const int MAXLINE = 1024;
|
||||
char line[MAXLINE];
|
||||
|
||||
void parse(FILE * fp);
|
||||
char * next_line(FILE * fp);
|
||||
std::pair<std::string, std::string> get_pair(const std::string & a, const std::string & b);
|
||||
|
||||
public:
|
||||
EIMPotentialFileReader(class LAMMPS* lmp, const std::string & filename);
|
||||
|
||||
void get_global(PairEIM::Setfl * setfl);
|
||||
void get_element(PairEIM::Setfl * setfl, int i, const std::string & name);
|
||||
void get_pair(PairEIM::Setfl * setfl, int ij, const std::string & elemA, const std::string & elemB);
|
||||
|
||||
private:
|
||||
// potential parameters
|
||||
double division;
|
||||
double rbig;
|
||||
double rsmall;
|
||||
|
||||
struct ElementData {
|
||||
int ielement;
|
||||
double mass;
|
||||
double negativity;
|
||||
double ra;
|
||||
double ri;
|
||||
double Ec;
|
||||
double q0;
|
||||
};
|
||||
|
||||
struct PairData {
|
||||
double rcutphiA;
|
||||
double rcutphiR;
|
||||
double Eb;
|
||||
double r0;
|
||||
double alpha;
|
||||
double beta;
|
||||
double rcutq;
|
||||
double Asigma;
|
||||
double rq;
|
||||
double rcutsigma;
|
||||
double Ac;
|
||||
double zeta;
|
||||
double rs;
|
||||
int tp;
|
||||
};
|
||||
|
||||
std::map<std::string, ElementData> elements;
|
||||
std::map<std::pair<std::string,std::string>, PairData> pairs;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -29,13 +29,15 @@
|
||||
#include "comm.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "utils.h"
|
||||
#include "tokenizer.h"
|
||||
#include "potential_file_reader.h"
|
||||
|
||||
#include "math_const.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
|
||||
#define MAXLINE 1024
|
||||
#define DELTA 4
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -366,91 +368,37 @@ double PairGW::init_one(int i, int j)
|
||||
|
||||
void PairGW::read_file(char *file)
|
||||
{
|
||||
int params_per_line = 17;
|
||||
char **words = new char*[params_per_line+1];
|
||||
|
||||
memory->sfree(params);
|
||||
params = NULL;
|
||||
nparams = maxparam = 0;
|
||||
|
||||
// open file on proc 0
|
||||
|
||||
FILE *fp;
|
||||
if (comm->me == 0) {
|
||||
fp = force->open_potential(file);
|
||||
if (fp == NULL) {
|
||||
char str[128];
|
||||
snprintf(str,128,"Cannot open GW potential file %s",file);
|
||||
error->one(FLERR,str);
|
||||
}
|
||||
}
|
||||
PotentialFileReader reader(lmp, file, "GW");
|
||||
char * line;
|
||||
|
||||
// read each line out of file, skipping blank lines or leading '#'
|
||||
// store line of params if all 3 element tags are in element list
|
||||
while((line = reader.next_line(NPARAMS_PER_LINE))) {
|
||||
try {
|
||||
ValueTokenizer values(line, " \t\n\r\f");
|
||||
|
||||
int n,nwords,ielement,jelement,kelement;
|
||||
char line[MAXLINE],*ptr;
|
||||
int eof = 0;
|
||||
|
||||
while (1) {
|
||||
if (comm->me == 0) {
|
||||
ptr = fgets(line,MAXLINE,fp);
|
||||
if (ptr == NULL) {
|
||||
eof = 1;
|
||||
fclose(fp);
|
||||
} else n = strlen(line) + 1;
|
||||
}
|
||||
MPI_Bcast(&eof,1,MPI_INT,0,world);
|
||||
if (eof) break;
|
||||
MPI_Bcast(&n,1,MPI_INT,0,world);
|
||||
MPI_Bcast(line,n,MPI_CHAR,0,world);
|
||||
|
||||
// strip comment, skip line if blank
|
||||
|
||||
if ((ptr = strchr(line,'#'))) *ptr = '\0';
|
||||
nwords = atom->count_words(line);
|
||||
if (nwords == 0) continue;
|
||||
|
||||
// concatenate additional lines until have params_per_line words
|
||||
|
||||
while (nwords < params_per_line) {
|
||||
n = strlen(line);
|
||||
if (comm->me == 0) {
|
||||
ptr = fgets(&line[n],MAXLINE-n,fp);
|
||||
if (ptr == NULL) {
|
||||
eof = 1;
|
||||
fclose(fp);
|
||||
} else n = strlen(line) + 1;
|
||||
}
|
||||
MPI_Bcast(&eof,1,MPI_INT,0,world);
|
||||
if (eof) break;
|
||||
MPI_Bcast(&n,1,MPI_INT,0,world);
|
||||
MPI_Bcast(line,n,MPI_CHAR,0,world);
|
||||
if ((ptr = strchr(line,'#'))) *ptr = '\0';
|
||||
nwords = atom->count_words(line);
|
||||
}
|
||||
|
||||
if (nwords != params_per_line)
|
||||
error->all(FLERR,"Incorrect format in GW potential file");
|
||||
|
||||
// words = ptrs to all words in line
|
||||
|
||||
nwords = 0;
|
||||
words[nwords++] = strtok(line," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue;
|
||||
std::string iname = values.next_string();
|
||||
std::string jname = values.next_string();
|
||||
std::string kname = values.next_string();
|
||||
|
||||
// ielement,jelement,kelement = 1st args
|
||||
// if all 3 args are in element list, then parse this line
|
||||
// else skip to next line
|
||||
// else skip to next entry in file
|
||||
int ielement, jelement, kelement;
|
||||
|
||||
for (ielement = 0; ielement < nelements; ielement++)
|
||||
if (strcmp(words[0],elements[ielement]) == 0) break;
|
||||
if (iname == elements[ielement]) break;
|
||||
if (ielement == nelements) continue;
|
||||
for (jelement = 0; jelement < nelements; jelement++)
|
||||
if (strcmp(words[1],elements[jelement]) == 0) break;
|
||||
if (jname == elements[jelement]) break;
|
||||
if (jelement == nelements) continue;
|
||||
for (kelement = 0; kelement < nelements; kelement++)
|
||||
if (strcmp(words[2],elements[kelement]) == 0) break;
|
||||
if (kname == elements[kelement]) break;
|
||||
if (kelement == nelements) continue;
|
||||
|
||||
// load up parameter settings and error check their values
|
||||
@ -464,25 +412,26 @@ void PairGW::read_file(char *file)
|
||||
params[nparams].ielement = ielement;
|
||||
params[nparams].jelement = jelement;
|
||||
params[nparams].kelement = kelement;
|
||||
params[nparams].powerm = atof(words[3]);
|
||||
params[nparams].gamma = atof(words[4]);
|
||||
params[nparams].lam3 = atof(words[5]);
|
||||
params[nparams].c = atof(words[6]);
|
||||
params[nparams].d = atof(words[7]);
|
||||
params[nparams].h = atof(words[8]);
|
||||
params[nparams].powern = atof(words[9]);
|
||||
params[nparams].beta = atof(words[10]);
|
||||
params[nparams].lam2 = atof(words[11]);
|
||||
params[nparams].bigb = atof(words[12]);
|
||||
params[nparams].bigr = atof(words[13]);
|
||||
params[nparams].bigd = atof(words[14]);
|
||||
params[nparams].lam1 = atof(words[15]);
|
||||
params[nparams].biga = atof(words[16]);
|
||||
params[nparams].powerm = values.next_double();
|
||||
params[nparams].gamma = values.next_double();
|
||||
params[nparams].lam3 = values.next_double();
|
||||
params[nparams].c = values.next_double();
|
||||
params[nparams].d = values.next_double();
|
||||
params[nparams].h = values.next_double();
|
||||
params[nparams].powern = values.next_double();
|
||||
params[nparams].beta = values.next_double();
|
||||
params[nparams].lam2 = values.next_double();
|
||||
params[nparams].bigb = values.next_double();
|
||||
params[nparams].bigr = values.next_double();
|
||||
params[nparams].bigd = values.next_double();
|
||||
params[nparams].lam1 = values.next_double();
|
||||
params[nparams].biga = values.next_double();
|
||||
params[nparams].powermint = int(params[nparams].powerm);
|
||||
} catch (TokenizerException & e) {
|
||||
error->one(FLERR, e.what());
|
||||
}
|
||||
|
||||
// currently only allow m exponent of 1 or 3
|
||||
|
||||
params[nparams].powermint = int(params[nparams].powerm);
|
||||
|
||||
if (params[nparams].c < 0.0 || params[nparams].d < 0.0 ||
|
||||
params[nparams].powern < 0.0 || params[nparams].beta < 0.0 ||
|
||||
params[nparams].lam2 < 0.0 || params[nparams].bigb < 0.0 ||
|
||||
@ -492,12 +441,20 @@ void PairGW::read_file(char *file)
|
||||
params[nparams].powerm - params[nparams].powermint != 0.0 ||
|
||||
(params[nparams].powermint != 3 && params[nparams].powermint != 1) ||
|
||||
params[nparams].gamma < 0.0)
|
||||
error->all(FLERR,"Illegal GW parameter");
|
||||
error->one(FLERR,"Illegal GW parameter");
|
||||
|
||||
nparams++;
|
||||
}
|
||||
}
|
||||
|
||||
delete [] words;
|
||||
MPI_Bcast(&nparams, 1, MPI_INT, 0, world);
|
||||
MPI_Bcast(&maxparam, 1, MPI_INT, 0, world);
|
||||
|
||||
if(comm->me != 0) {
|
||||
params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params");
|
||||
}
|
||||
|
||||
MPI_Bcast(params, maxparam*sizeof(Param), MPI_BYTE, 0, world);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -34,6 +34,8 @@ class PairGW : public Pair {
|
||||
void init_style();
|
||||
double init_one(int, int);
|
||||
|
||||
static const int NPARAMS_PER_LINE = 17;
|
||||
|
||||
protected:
|
||||
struct Param {
|
||||
double lam1,lam2,lam3;
|
||||
|
||||
@ -27,6 +27,9 @@
|
||||
#include "comm.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "utils.h"
|
||||
#include "tokenizer.h"
|
||||
#include "potential_file_reader.h"
|
||||
|
||||
#include "math_const.h"
|
||||
using namespace LAMMPS_NS;
|
||||
@ -60,91 +63,37 @@ PairGWZBL::PairGWZBL(LAMMPS *lmp) : PairGW(lmp)
|
||||
|
||||
void PairGWZBL::read_file(char *file)
|
||||
{
|
||||
int params_per_line = 21;
|
||||
char **words = new char*[params_per_line+1];
|
||||
|
||||
memory->sfree(params);
|
||||
params = NULL;
|
||||
nparams = maxparam = 0;
|
||||
|
||||
// open file on proc 0
|
||||
|
||||
FILE *fp;
|
||||
if (comm->me == 0) {
|
||||
fp = force->open_potential(file);
|
||||
if (fp == NULL) {
|
||||
char str[128];
|
||||
snprintf(str,128,"Cannot open GW potential file %s",file);
|
||||
error->one(FLERR,str);
|
||||
}
|
||||
}
|
||||
PotentialFileReader reader(lmp, file, "GW/ZBL");
|
||||
char * line;
|
||||
|
||||
// read each line out of file, skipping blank lines or leading '#'
|
||||
// store line of params if all 3 element tags are in element list
|
||||
while((line = reader.next_line(NPARAMS_PER_LINE))) {
|
||||
try {
|
||||
ValueTokenizer values(line, " \t\n\r\f");
|
||||
|
||||
int n,nwords,ielement,jelement,kelement;
|
||||
char line[MAXLINE],*ptr;
|
||||
int eof = 0;
|
||||
|
||||
while (1) {
|
||||
if (comm->me == 0) {
|
||||
ptr = fgets(line,MAXLINE,fp);
|
||||
if (ptr == NULL) {
|
||||
eof = 1;
|
||||
fclose(fp);
|
||||
} else n = strlen(line) + 1;
|
||||
}
|
||||
MPI_Bcast(&eof,1,MPI_INT,0,world);
|
||||
if (eof) break;
|
||||
MPI_Bcast(&n,1,MPI_INT,0,world);
|
||||
MPI_Bcast(line,n,MPI_CHAR,0,world);
|
||||
|
||||
// strip comment, skip line if blank
|
||||
|
||||
if ((ptr = strchr(line,'#'))) *ptr = '\0';
|
||||
nwords = atom->count_words(line);
|
||||
if (nwords == 0) continue;
|
||||
|
||||
// concatenate additional lines until have params_per_line words
|
||||
|
||||
while (nwords < params_per_line) {
|
||||
n = strlen(line);
|
||||
if (comm->me == 0) {
|
||||
ptr = fgets(&line[n],MAXLINE-n,fp);
|
||||
if (ptr == NULL) {
|
||||
eof = 1;
|
||||
fclose(fp);
|
||||
} else n = strlen(line) + 1;
|
||||
}
|
||||
MPI_Bcast(&eof,1,MPI_INT,0,world);
|
||||
if (eof) break;
|
||||
MPI_Bcast(&n,1,MPI_INT,0,world);
|
||||
MPI_Bcast(line,n,MPI_CHAR,0,world);
|
||||
if ((ptr = strchr(line,'#'))) *ptr = '\0';
|
||||
nwords = atom->count_words(line);
|
||||
}
|
||||
|
||||
if (nwords != params_per_line)
|
||||
error->all(FLERR,"Incorrect format in GW potential file");
|
||||
|
||||
// words = ptrs to all words in line
|
||||
|
||||
nwords = 0;
|
||||
words[nwords++] = strtok(line," \t\n\r\f");
|
||||
while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue;
|
||||
std::string iname = values.next_string();
|
||||
std::string jname = values.next_string();
|
||||
std::string kname = values.next_string();
|
||||
|
||||
// ielement,jelement,kelement = 1st args
|
||||
// if all 3 args are in element list, then parse this line
|
||||
// else skip to next line
|
||||
// else skip to next entry in file
|
||||
int ielement, jelement, kelement;
|
||||
|
||||
for (ielement = 0; ielement < nelements; ielement++)
|
||||
if (strcmp(words[0],elements[ielement]) == 0) break;
|
||||
if (iname == elements[ielement]) break;
|
||||
if (ielement == nelements) continue;
|
||||
for (jelement = 0; jelement < nelements; jelement++)
|
||||
if (strcmp(words[1],elements[jelement]) == 0) break;
|
||||
if (jname == elements[jelement]) break;
|
||||
if (jelement == nelements) continue;
|
||||
for (kelement = 0; kelement < nelements; kelement++)
|
||||
if (strcmp(words[2],elements[kelement]) == 0) break;
|
||||
if (kname == elements[kelement]) break;
|
||||
if (kelement == nelements) continue;
|
||||
|
||||
// load up parameter settings and error check their values
|
||||
@ -158,29 +107,30 @@ void PairGWZBL::read_file(char *file)
|
||||
params[nparams].ielement = ielement;
|
||||
params[nparams].jelement = jelement;
|
||||
params[nparams].kelement = kelement;
|
||||
params[nparams].powerm = atof(words[3]);
|
||||
params[nparams].gamma = atof(words[4]);
|
||||
params[nparams].lam3 = atof(words[5]);
|
||||
params[nparams].c = atof(words[6]);
|
||||
params[nparams].d = atof(words[7]);
|
||||
params[nparams].h = atof(words[8]);
|
||||
params[nparams].powern = atof(words[9]);
|
||||
params[nparams].beta = atof(words[10]);
|
||||
params[nparams].lam2 = atof(words[11]);
|
||||
params[nparams].bigb = atof(words[12]);
|
||||
params[nparams].bigr = atof(words[13]);
|
||||
params[nparams].bigd = atof(words[14]);
|
||||
params[nparams].lam1 = atof(words[15]);
|
||||
params[nparams].biga = atof(words[16]);
|
||||
params[nparams].Z_i = atof(words[17]);
|
||||
params[nparams].Z_j = atof(words[18]);
|
||||
params[nparams].ZBLcut = atof(words[19]);
|
||||
params[nparams].ZBLexpscale = atof(words[20]);
|
||||
params[nparams].powerm = values.next_double();
|
||||
params[nparams].gamma = values.next_double();
|
||||
params[nparams].lam3 = values.next_double();
|
||||
params[nparams].c = values.next_double();
|
||||
params[nparams].d = values.next_double();
|
||||
params[nparams].h = values.next_double();
|
||||
params[nparams].powern = values.next_double();
|
||||
params[nparams].beta = values.next_double();
|
||||
params[nparams].lam2 = values.next_double();
|
||||
params[nparams].bigb = values.next_double();
|
||||
params[nparams].bigr = values.next_double();
|
||||
params[nparams].bigd = values.next_double();
|
||||
params[nparams].lam1 = values.next_double();
|
||||
params[nparams].biga = values.next_double();
|
||||
params[nparams].Z_i = values.next_double();
|
||||
params[nparams].Z_j = values.next_double();
|
||||
params[nparams].ZBLcut = values.next_double();
|
||||
params[nparams].ZBLexpscale = values.next_double();
|
||||
params[nparams].powermint = int(params[nparams].powerm);
|
||||
} catch (TokenizerException & e) {
|
||||
error->one(FLERR, e.what());
|
||||
}
|
||||
|
||||
// currently only allow m exponent of 1 or 3
|
||||
|
||||
params[nparams].powermint = int(params[nparams].powerm);
|
||||
|
||||
if (
|
||||
params[nparams].lam3 < 0.0 || params[nparams].c < 0.0 ||
|
||||
params[nparams].d < 0.0 || params[nparams].powern < 0.0 ||
|
||||
@ -194,12 +144,20 @@ void PairGWZBL::read_file(char *file)
|
||||
params[nparams].gamma < 0.0 ||
|
||||
params[nparams].Z_i < 1.0 || params[nparams].Z_j < 1.0 ||
|
||||
params[nparams].ZBLcut < 0.0 || params[nparams].ZBLexpscale < 0.0)
|
||||
error->all(FLERR,"Illegal GW parameter");
|
||||
error->one(FLERR,"Illegal GW parameter");
|
||||
|
||||
nparams++;
|
||||
}
|
||||
}
|
||||
|
||||
delete [] words;
|
||||
MPI_Bcast(&nparams, 1, MPI_INT, 0, world);
|
||||
MPI_Bcast(&maxparam, 1, MPI_INT, 0, world);
|
||||
|
||||
if(comm->me != 0) {
|
||||
params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params");
|
||||
}
|
||||
|
||||
MPI_Bcast(params, maxparam*sizeof(Param), MPI_BYTE, 0, world);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -29,6 +29,8 @@ class PairGWZBL : public PairGW {
|
||||
PairGWZBL(class LAMMPS *);
|
||||
~PairGWZBL() {}
|
||||
|
||||
static const int NPARAMS_PER_LINE = 21;
|
||||
|
||||
private:
|
||||
double global_a_0; // Bohr radius for Coulomb repulsion
|
||||
double global_epsilon_0; // permittivity of vacuum for Coulomb repulsion
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user