Merge pull request #3309 from akohlmey/collected-small-fixes
More fixes and small changes for the stable release
This commit is contained in:
@ -184,7 +184,7 @@ frame.
|
|||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
import re, yaml
|
import yaml
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -193,7 +193,7 @@ frame.
|
|||||||
from yaml import SafeLoader as Loader
|
from yaml import SafeLoader as Loader
|
||||||
|
|
||||||
with open("ave.yaml") as f:
|
with open("ave.yaml") as f:
|
||||||
ave = yaml.load(docs, Loader=Loader)
|
ave = yaml.load(f, Loader=Loader)
|
||||||
|
|
||||||
keys = ave['keywords']
|
keys = ave['keywords']
|
||||||
df = {}
|
df = {}
|
||||||
|
|||||||
@ -42,5 +42,4 @@ inaccurate relative timing data, because processors have to wait when
|
|||||||
communication occurs for other processors to catch up. Thus the
|
communication occurs for other processors to catch up. Thus the
|
||||||
reported times for "Communication" or "Other" may be higher than they
|
reported times for "Communication" or "Other" may be higher than they
|
||||||
really are, due to load-imbalance. If this is an issue, you can
|
really are, due to load-imbalance. If this is an issue, you can
|
||||||
uncomment the MPI_Barrier() lines in src/timer.cpp, and re-compile
|
use the :doc:`timer sync <timer>` command to obtain synchronized timings.
|
||||||
LAMMPS, to obtain synchronized timings.
|
|
||||||
|
|||||||
@ -11,7 +11,6 @@ Syntax
|
|||||||
read_restart file flag
|
read_restart file flag
|
||||||
|
|
||||||
* file = name of binary restart file to read in
|
* file = name of binary restart file to read in
|
||||||
* flag = remap (optional)
|
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
""""""""
|
""""""""
|
||||||
@ -19,44 +18,40 @@ Examples
|
|||||||
.. code-block:: LAMMPS
|
.. code-block:: LAMMPS
|
||||||
|
|
||||||
read_restart save.10000
|
read_restart save.10000
|
||||||
read_restart save.10000 remap
|
|
||||||
read_restart restart.*
|
read_restart restart.*
|
||||||
read_restart restart.*.mpiio
|
read_restart restart.*.mpiio
|
||||||
read_restart poly.*.% remap
|
|
||||||
|
|
||||||
Description
|
Description
|
||||||
"""""""""""
|
"""""""""""
|
||||||
|
|
||||||
Read in a previously saved system configuration from a restart file.
|
Read in a previously saved system configuration from a restart file.
|
||||||
This allows continuation of a previous run. Details about what
|
This allows continuation of a previous run. Details about what
|
||||||
information is stored (and not stored) in a restart file is given
|
information is stored (and not stored) in a restart file is given below.
|
||||||
below. Basically this operation will re-create the simulation box
|
Basically this operation will re-create the simulation box with all its
|
||||||
with all its atoms and their attributes as well as some related global
|
atoms and their attributes as well as some related global settings, at
|
||||||
settings, at the point in time it was written to the restart file by a
|
the point in time it was written to the restart file by a previous
|
||||||
previous simulation. The simulation box will be partitioned into a
|
simulation. The simulation box will be partitioned into a regular 3d
|
||||||
regular 3d grid of rectangular bricks, one per processor, based on the
|
grid of rectangular bricks, one per processor, based on the number of
|
||||||
number of processors in the current simulation and the settings of the
|
processors in the current simulation and the settings of the
|
||||||
:doc:`processors <processors>` command. The partitioning can later be
|
:doc:`processors <processors>` command. The partitioning can later be
|
||||||
changed by the :doc:`balance <balance>` or :doc:`fix balance <fix_balance>` commands.
|
changed by the :doc:`balance <balance>` or :doc:`fix balance
|
||||||
|
<fix_balance>` commands.
|
||||||
.. note::
|
|
||||||
|
|
||||||
Normally, restart files are written by the
|
|
||||||
:doc:`restart <restart>` or :doc:`write_restart <write_restart>` commands
|
|
||||||
so that all atoms in the restart file are inside the simulation box.
|
|
||||||
If this is not the case, the read_restart command will print an error
|
|
||||||
that atoms were "lost" when the file is read. This error should be
|
|
||||||
reported to the LAMMPS developers so the invalid writing of the
|
|
||||||
restart file can be fixed. If you still wish to use the restart file,
|
|
||||||
the optional *remap* flag can be appended to the read_restart command.
|
|
||||||
This should avoid the error, by explicitly remapping each atom back
|
|
||||||
into the simulation box, updating image flags for the atom
|
|
||||||
appropriately.
|
|
||||||
|
|
||||||
Restart files are saved in binary format to enable exact restarts,
|
Restart files are saved in binary format to enable exact restarts,
|
||||||
meaning that the trajectories of a restarted run will precisely match
|
meaning that the trajectories of a restarted run will precisely match
|
||||||
those produced by the original run had it continued on.
|
those produced by the original run had it continued on.
|
||||||
|
|
||||||
|
The binary restart file format was not designed with backward, forward,
|
||||||
|
or cross-platform compatibility in mind, so the files are only expected
|
||||||
|
to be read correctly by the same LAMMPS executable on the same platform.
|
||||||
|
Changes to the architecture, compilation settings, or LAMMPS version can
|
||||||
|
render a restart file unreadable or it may read the data incorrectly.
|
||||||
|
If you want a more portable format, you can use the data file format as
|
||||||
|
created by the :doc:`write_data <write_data>` command. Binary restart
|
||||||
|
files can also be converted into a data file from the command line by
|
||||||
|
the LAMMPS executable that wrote them using the :ref:`-restart2data
|
||||||
|
<restart2data>` command line flag.
|
||||||
|
|
||||||
Several things can prevent exact restarts due to round-off effects, in
|
Several things can prevent exact restarts due to round-off effects, in
|
||||||
which case the trajectories in the 2 runs will slowly diverge. These
|
which case the trajectories in the 2 runs will slowly diverge. These
|
||||||
include running on a different number of processors or changing
|
include running on a different number of processors or changing
|
||||||
@ -65,7 +60,8 @@ certain settings such as those set by the :doc:`newton <newton>` or
|
|||||||
these cases.
|
these cases.
|
||||||
|
|
||||||
Certain fixes will not restart exactly, though they should provide
|
Certain fixes will not restart exactly, though they should provide
|
||||||
statistically similar results. These include :doc:`fix shake <fix_shake>` and :doc:`fix langevin <fix_langevin>`.
|
statistically similar results. These include :doc:`fix shake
|
||||||
|
<fix_shake>` and :doc:`fix langevin <fix_langevin>`.
|
||||||
|
|
||||||
Certain pair styles will not restart exactly, though they should
|
Certain pair styles will not restart exactly, though they should
|
||||||
provide statistically similar results. This is because the forces
|
provide statistically similar results. This is because the forces
|
||||||
@ -81,18 +77,19 @@ produced the restart file, it could be a LAMMPS bug, so consider
|
|||||||
:doc:`reporting it <Errors_bugs>` if you think the behavior is a bug.
|
:doc:`reporting it <Errors_bugs>` if you think the behavior is a bug.
|
||||||
|
|
||||||
Because restart files are binary, they may not be portable to other
|
Because restart files are binary, they may not be portable to other
|
||||||
machines. In this case, you can use the :doc:`-restart command-line switch <Run_options>` to convert a restart file to a data file.
|
machines. In this case, you can use the :doc:`-restart command-line
|
||||||
|
switch <Run_options>` to convert a restart file to a data file.
|
||||||
|
|
||||||
Similar to how restart files are written (see the
|
Similar to how restart files are written (see the :doc:`write_restart
|
||||||
:doc:`write_restart <write_restart>` and :doc:`restart <restart>`
|
<write_restart>` and :doc:`restart <restart>` commands), the restart
|
||||||
commands), the restart filename can contain two wild-card characters.
|
filename can contain two wild-card characters. If a "\*" appears in the
|
||||||
If a "\*" appears in the filename, the directory is searched for all
|
filename, the directory is searched for all filenames that match the
|
||||||
filenames that match the pattern where "\*" is replaced with a timestep
|
pattern where "\*" is replaced with a timestep value. The file with the
|
||||||
value. The file with the largest timestep value is read in. Thus,
|
largest timestep value is read in. Thus, this effectively means, read
|
||||||
this effectively means, read the latest restart file. It's useful if
|
the latest restart file. It's useful if you want your script to
|
||||||
you want your script to continue a run from where it left off. See
|
continue a run from where it left off. See the :doc:`run <run>` command
|
||||||
the :doc:`run <run>` command and its "upto" option for how to specify
|
and its "upto" option for how to specify the run command so it does not
|
||||||
the run command so it does not need to be changed either.
|
need to be changed either.
|
||||||
|
|
||||||
If a "%" character appears in the restart filename, LAMMPS expects a
|
If a "%" character appears in the restart filename, LAMMPS expects a
|
||||||
set of multiple files to exist. The :doc:`restart <restart>` and
|
set of multiple files to exist. The :doc:`restart <restart>` and
|
||||||
@ -222,17 +219,17 @@ its calculations in a consistent manner.
|
|||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
There are a handful of commands which can be used before or
|
There are a handful of commands which can be used before or between
|
||||||
between runs which may require a system initialization. Examples
|
runs which may require a system initialization. Examples include the
|
||||||
include the "balance", "displace_atoms", "delete_atoms", "set" (some
|
"balance", "displace_atoms", "delete_atoms", "set" (some options),
|
||||||
options), and "velocity" (some options) commands. This is because
|
and "velocity" (some options) commands. This is because they can
|
||||||
they can migrate atoms to new processors. Thus they will also discard
|
migrate atoms to new processors. Thus they will also discard unused
|
||||||
unused "state" information from fixes. You will know the discard has
|
"state" information from fixes. You will know the discard has
|
||||||
occurred because a list of discarded fixes will be printed to the
|
occurred because a list of discarded fixes will be printed to the
|
||||||
screen and log file, as explained above. This means that if you wish
|
screen and log file, as explained above. This means that if you wish
|
||||||
to retain that info in a restarted run, you must re-specify the
|
to retain that info in a restarted run, you must re-specify the
|
||||||
relevant fixes and computes (which create fixes) before those commands
|
relevant fixes and computes (which create fixes) before those
|
||||||
are used.
|
commands are used.
|
||||||
|
|
||||||
Some pair styles, like the :doc:`granular pair styles <pair_gran>`, also
|
Some pair styles, like the :doc:`granular pair styles <pair_gran>`, also
|
||||||
use a fix to store "state" information that persists from timestep to
|
use a fix to store "state" information that persists from timestep to
|
||||||
@ -245,18 +242,19 @@ LAMMPS allows bond interactions (angle, etc) to be turned off or
|
|||||||
deleted in various ways, which can affect how their info is stored in
|
deleted in various ways, which can affect how their info is stored in
|
||||||
a restart file.
|
a restart file.
|
||||||
|
|
||||||
If bonds (angles, etc) have been turned off by the :doc:`fix shake <fix_shake>` or :doc:`delete_bonds <delete_bonds>` command,
|
If bonds (angles, etc) have been turned off by the :doc:`fix shake
|
||||||
their info will be written to a restart file as if they are turned on.
|
<fix_shake>` or :doc:`delete_bonds <delete_bonds>` command, their info
|
||||||
This means they will need to be turned off again in a new run after
|
will be written to a restart file as if they are turned on. This means
|
||||||
the restart file is read.
|
they will need to be turned off again in a new run after the restart
|
||||||
|
file is read.
|
||||||
|
|
||||||
Bonds that are broken (e.g. by a bond-breaking potential) are written
|
Bonds that are broken (e.g. by a bond-breaking potential) are written
|
||||||
to the restart file as broken bonds with a type of 0. Thus these
|
to the restart file as broken bonds with a type of 0. Thus these
|
||||||
bonds will still be broken when the restart file is read.
|
bonds will still be broken when the restart file is read.
|
||||||
|
|
||||||
Bonds that have been broken by the :doc:`fix bond/break <fix_bond_break>` command have disappeared from the
|
Bonds that have been broken by the :doc:`fix bond/break
|
||||||
system. No information about these bonds is written to the restart
|
<fix_bond_break>` command have disappeared from the system. No
|
||||||
file.
|
information about these bonds is written to the restart file.
|
||||||
|
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
|||||||
@ -2369,6 +2369,7 @@ nopreliminary
|
|||||||
Nord
|
Nord
|
||||||
norder
|
norder
|
||||||
Nordlund
|
Nordlund
|
||||||
|
noremap
|
||||||
normals
|
normals
|
||||||
normx
|
normx
|
||||||
normy
|
normy
|
||||||
|
|||||||
@ -12,8 +12,8 @@
|
|||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------
|
||||||
Contributing author: Karl D. Hammond <karlh@ugcs.caltech.edu>
|
Contributing author: Karl D. Hammond <hammondkd@missouri.edu>
|
||||||
University of Tennessee, Knoxville (USA), 2012
|
University of Missouri (USA), 2012
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* This is set of "wrapper" functions to assist LAMMPS.F90, which itself
|
/* This is set of "wrapper" functions to assist LAMMPS.F90, which itself
|
||||||
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <mpi.h>
|
#include <mpi.h>
|
||||||
#include "LAMMPS-wrapper.h"
|
#include "LAMMPS-wrapper.h"
|
||||||
|
#define LAMMPS_LIB_MPI 1
|
||||||
#include <library.h>
|
#include <library.h>
|
||||||
#include <lammps.h>
|
#include <lammps.h>
|
||||||
#include <atom.h>
|
#include <atom.h>
|
||||||
@ -56,181 +57,40 @@ void lammps_error_all (void *ptr, const char *file, int line, const char *str)
|
|||||||
|
|
||||||
int lammps_extract_compute_vectorsize (void *ptr, char *id, int style)
|
int lammps_extract_compute_vectorsize (void *ptr, char *id, int style)
|
||||||
{
|
{
|
||||||
class LAMMPS *lmp = (class LAMMPS *) ptr;
|
int *size;
|
||||||
int icompute = lmp->modify->find_compute(id);
|
size = (int *) lammps_extract_compute(ptr, id, style, LMP_SIZE_VECTOR);
|
||||||
if ( icompute < 0 ) return 0;
|
if (size) return *size;
|
||||||
class Compute *compute = lmp->modify->compute[icompute];
|
return 0;
|
||||||
|
|
||||||
if ( style == 0 )
|
|
||||||
{
|
|
||||||
if ( !compute->vector_flag )
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return compute->size_vector;
|
|
||||||
}
|
|
||||||
else if ( style == 1 )
|
|
||||||
{
|
|
||||||
return lammps_get_natoms (ptr);
|
|
||||||
}
|
|
||||||
else if ( style == 2 )
|
|
||||||
{
|
|
||||||
if ( !compute->local_flag )
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return compute->size_local_rows;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lammps_extract_compute_arraysize (void *ptr, char *id, int style,
|
void lammps_extract_compute_arraysize (void *ptr, char *id, int style,
|
||||||
int *nrows, int *ncols)
|
int *nrows, int *ncols)
|
||||||
{
|
{
|
||||||
class LAMMPS *lmp = (class LAMMPS *) ptr;
|
int *tmp;
|
||||||
int icompute = lmp->modify->find_compute(id);
|
tmp = (int *) lammps_extract_compute(ptr, id, style, LMP_SIZE_ROWS);
|
||||||
if ( icompute < 0 )
|
if (tmp) *nrows = *tmp;
|
||||||
{
|
tmp = (int *) lammps_extract_compute(ptr, id, style, LMP_SIZE_COLS);
|
||||||
*nrows = 0;
|
if (tmp) *ncols = *tmp;
|
||||||
*ncols = 0;
|
|
||||||
}
|
|
||||||
class Compute *compute = lmp->modify->compute[icompute];
|
|
||||||
|
|
||||||
if ( style == 0 )
|
|
||||||
{
|
|
||||||
if ( !compute->array_flag )
|
|
||||||
{
|
|
||||||
*nrows = 0;
|
|
||||||
*ncols = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*nrows = compute->size_array_rows;
|
|
||||||
*ncols = compute->size_array_cols;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( style == 1 )
|
|
||||||
{
|
|
||||||
if ( !compute->peratom_flag )
|
|
||||||
{
|
|
||||||
*nrows = 0;
|
|
||||||
*ncols = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*nrows = lammps_get_natoms (ptr);
|
|
||||||
*ncols = compute->size_peratom_cols;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( style == 2 )
|
|
||||||
{
|
|
||||||
if ( !compute->local_flag )
|
|
||||||
{
|
|
||||||
*nrows = 0;
|
|
||||||
*ncols = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*nrows = compute->size_local_rows;
|
|
||||||
*ncols = compute->size_local_cols;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*nrows = 0;
|
|
||||||
*ncols = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lammps_extract_fix_vectorsize (void *ptr, char *id, int style)
|
int lammps_extract_fix_vectorsize (void *ptr, char *id, int style)
|
||||||
{
|
{
|
||||||
class LAMMPS *lmp = (class LAMMPS *) ptr;
|
int *size;
|
||||||
int ifix = lmp->modify->find_fix(id);
|
size = (int *) lammps_extract_fix(ptr, id, style, LMP_SIZE_VECTOR, 0, 0);
|
||||||
if ( ifix < 0 ) return 0;
|
if (size) return *size;
|
||||||
class Fix *fix = lmp->modify->fix[ifix];
|
return 0;
|
||||||
|
|
||||||
if ( style == 0 )
|
|
||||||
{
|
|
||||||
if ( !fix->vector_flag )
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return fix->size_vector;
|
|
||||||
}
|
|
||||||
else if ( style == 1 )
|
|
||||||
{
|
|
||||||
return lammps_get_natoms (ptr);
|
|
||||||
}
|
|
||||||
else if ( style == 2 )
|
|
||||||
{
|
|
||||||
if ( !fix->local_flag )
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return fix->size_local_rows;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lammps_extract_fix_arraysize (void *ptr, char *id, int style,
|
void lammps_extract_fix_arraysize (void *ptr, char *id, int style,
|
||||||
int *nrows, int *ncols)
|
int *nrows, int *ncols)
|
||||||
{
|
{
|
||||||
class LAMMPS *lmp = (class LAMMPS *) ptr;
|
int *tmp;
|
||||||
int ifix = lmp->modify->find_fix(id);
|
tmp = (int *) lammps_extract_fix(ptr, id, style, LMP_SIZE_ROWS, 0, 0);
|
||||||
if ( ifix < 0 )
|
if (tmp) *nrows = *tmp;
|
||||||
{
|
tmp = (int *) lammps_extract_fix(ptr, id, style, LMP_SIZE_COLS, 0, 0);
|
||||||
*nrows = 0;
|
if (tmp) *ncols = *tmp;
|
||||||
*ncols = 0;
|
|
||||||
}
|
|
||||||
class Fix *fix = lmp->modify->fix[ifix];
|
|
||||||
|
|
||||||
if ( style == 0 )
|
|
||||||
{
|
|
||||||
if ( !fix->array_flag )
|
|
||||||
{
|
|
||||||
*nrows = 0;
|
|
||||||
*ncols = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*nrows = fix->size_array_rows;
|
|
||||||
*ncols = fix->size_array_cols;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( style == 1 )
|
|
||||||
{
|
|
||||||
if ( !fix->peratom_flag )
|
|
||||||
{
|
|
||||||
*nrows = 0;
|
|
||||||
*ncols = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*nrows = lammps_get_natoms (ptr);
|
|
||||||
*ncols = fix->size_peratom_cols;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( style == 2 )
|
|
||||||
{
|
|
||||||
if ( !fix->local_flag )
|
|
||||||
{
|
|
||||||
*nrows = 0;
|
|
||||||
*ncols = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*nrows = fix->size_local_rows;
|
|
||||||
*ncols = fix->size_local_cols;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*nrows = 0;
|
|
||||||
*ncols = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set ts=3 sts=3 expandtab: */
|
/* vim: set ts=3 sts=3 expandtab: */
|
||||||
|
|||||||
@ -12,8 +12,8 @@
|
|||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------
|
||||||
Contributing author: Karl D. Hammond <karlh@ugcs.caltech.edu>
|
Contributing author: Karl D. Hammond <hammondkd@missouri.edu>
|
||||||
University of Tennessee, Knoxville (USA), 2012
|
University of Missouri (USA), 2012
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* This is set of "wrapper" functions to assist LAMMPS.F90, which itself
|
/* This is set of "wrapper" functions to assist LAMMPS.F90, which itself
|
||||||
|
|||||||
@ -1292,7 +1292,7 @@ contains !! Wrapper functions local to this module {{{1
|
|||||||
Cname = string2Cstring (name)
|
Cname = string2Cstring (name)
|
||||||
Ccount = size(data) / natoms
|
Ccount = size(data) / natoms
|
||||||
if ( Ccount /= 1 .and. Ccount /= 3 ) &
|
if ( Ccount /= 1 .and. Ccount /= 3 ) &
|
||||||
call lammps_error_all (ptr, FLERR, 'lammps_gather_atoms requires&
|
call lammps_error_all (ptr, FLERR, 'lammps_scatter_atoms requires&
|
||||||
& count to be either 1 or 3')
|
& count to be either 1 or 3')
|
||||||
Fdata = data
|
Fdata = data
|
||||||
Cdata = C_loc (Fdata(1))
|
Cdata = C_loc (Fdata(1))
|
||||||
@ -1355,7 +1355,7 @@ contains !! Wrapper functions local to this module {{{1
|
|||||||
Cname = string2Cstring (name)
|
Cname = string2Cstring (name)
|
||||||
Ccount = size(data) / ndata
|
Ccount = size(data) / ndata
|
||||||
if ( Ccount /= 1 .and. Ccount /= 3 ) &
|
if ( Ccount /= 1 .and. Ccount /= 3 ) &
|
||||||
call lammps_error_all (ptr, FLERR, 'lammps_gather_atoms requires&
|
call lammps_error_all (ptr, FLERR, 'lammps_scatter_atoms requires&
|
||||||
& count to be either 1 or 3')
|
& count to be either 1 or 3')
|
||||||
Fdata = data
|
Fdata = data
|
||||||
Cdata = C_loc (Fdata(1))
|
Cdata = C_loc (Fdata(1))
|
||||||
|
|||||||
@ -14,7 +14,7 @@ CXXLIB = -lstdc++ # replace with your C++ runtime libs
|
|||||||
# Flags for Fortran compiler, C++ compiler, and C preprocessor, respectively
|
# Flags for Fortran compiler, C++ compiler, and C preprocessor, respectively
|
||||||
FFLAGS = -O2 -fPIC
|
FFLAGS = -O2 -fPIC
|
||||||
CXXFLAGS = -O2 -fPIC
|
CXXFLAGS = -O2 -fPIC
|
||||||
CPPFLAGS = -DOMPI_SKIP_MPICXX=1 -DMPICH_SKIP_MPICXX -DLAMMPS_LIB_MPI
|
CPPFLAGS = -DOMPI_SKIP_MPICXX=1 -DMPICH_SKIP_MPICXX
|
||||||
|
|
||||||
all : liblammps_fortran.a liblammps_fortran.so
|
all : liblammps_fortran.a liblammps_fortran.so
|
||||||
|
|
||||||
|
|||||||
@ -11,9 +11,8 @@ This interface was created by Karl Hammond who you can contact with
|
|||||||
questions:
|
questions:
|
||||||
|
|
||||||
Karl D. Hammond
|
Karl D. Hammond
|
||||||
University of Tennessee, Knoxville
|
University of Missouri
|
||||||
karlh at ugcs.caltech.edu
|
hammondkd at missouri.edu
|
||||||
karlh at utk.edu
|
|
||||||
|
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -12,8 +12,8 @@
|
|||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------
|
||||||
Contributing author: Karl D. Hammond <karlh@ugcs.caltech.edu>
|
Contributing author: Karl D. Hammond <hammondkd@missouri.edu>
|
||||||
University of Tennessee, Knoxville (USA), 2012
|
University of Missouri (USA), 2012
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* This is set of "wrapper" functions to assist LAMMPS.F90, which itself
|
/* This is set of "wrapper" functions to assist LAMMPS.F90, which itself
|
||||||
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <mpi.h>
|
#include <mpi.h>
|
||||||
#include "LAMMPS-wrapper.h"
|
#include "LAMMPS-wrapper.h"
|
||||||
|
#define LAMMPS_LIB_MPI 1
|
||||||
#include <library.h>
|
#include <library.h>
|
||||||
#include <lammps.h>
|
#include <lammps.h>
|
||||||
#include <atom.h>
|
#include <atom.h>
|
||||||
@ -56,181 +57,40 @@ void lammps_error_all (void *ptr, const char *file, int line, const char *str)
|
|||||||
|
|
||||||
int lammps_extract_compute_vectorsize (void *ptr, char *id, int style)
|
int lammps_extract_compute_vectorsize (void *ptr, char *id, int style)
|
||||||
{
|
{
|
||||||
class LAMMPS *lmp = (class LAMMPS *) ptr;
|
int *size;
|
||||||
int icompute = lmp->modify->find_compute(id);
|
size = (int *) lammps_extract_compute(ptr, id, style, LMP_SIZE_VECTOR);
|
||||||
if ( icompute < 0 ) return 0;
|
if (size) return *size;
|
||||||
class Compute *compute = lmp->modify->compute[icompute];
|
return 0;
|
||||||
|
|
||||||
if ( style == 0 )
|
|
||||||
{
|
|
||||||
if ( !compute->vector_flag )
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return compute->size_vector;
|
|
||||||
}
|
|
||||||
else if ( style == 1 )
|
|
||||||
{
|
|
||||||
return lammps_get_natoms (ptr);
|
|
||||||
}
|
|
||||||
else if ( style == 2 )
|
|
||||||
{
|
|
||||||
if ( !compute->local_flag )
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return compute->size_local_rows;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lammps_extract_compute_arraysize (void *ptr, char *id, int style,
|
void lammps_extract_compute_arraysize (void *ptr, char *id, int style,
|
||||||
int *nrows, int *ncols)
|
int *nrows, int *ncols)
|
||||||
{
|
{
|
||||||
class LAMMPS *lmp = (class LAMMPS *) ptr;
|
int *tmp;
|
||||||
int icompute = lmp->modify->find_compute(id);
|
tmp = (int *) lammps_extract_compute(ptr, id, style, LMP_SIZE_ROWS);
|
||||||
if ( icompute < 0 )
|
if (tmp) *nrows = *tmp;
|
||||||
{
|
tmp = (int *) lammps_extract_compute(ptr, id, style, LMP_SIZE_COLS);
|
||||||
*nrows = 0;
|
if (tmp) *ncols = *tmp;
|
||||||
*ncols = 0;
|
|
||||||
}
|
|
||||||
class Compute *compute = lmp->modify->compute[icompute];
|
|
||||||
|
|
||||||
if ( style == 0 )
|
|
||||||
{
|
|
||||||
if ( !compute->array_flag )
|
|
||||||
{
|
|
||||||
*nrows = 0;
|
|
||||||
*ncols = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*nrows = compute->size_array_rows;
|
|
||||||
*ncols = compute->size_array_cols;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( style == 1 )
|
|
||||||
{
|
|
||||||
if ( !compute->peratom_flag )
|
|
||||||
{
|
|
||||||
*nrows = 0;
|
|
||||||
*ncols = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*nrows = lammps_get_natoms (ptr);
|
|
||||||
*ncols = compute->size_peratom_cols;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( style == 2 )
|
|
||||||
{
|
|
||||||
if ( !compute->local_flag )
|
|
||||||
{
|
|
||||||
*nrows = 0;
|
|
||||||
*ncols = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*nrows = compute->size_local_rows;
|
|
||||||
*ncols = compute->size_local_cols;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*nrows = 0;
|
|
||||||
*ncols = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lammps_extract_fix_vectorsize (void *ptr, char *id, int style)
|
int lammps_extract_fix_vectorsize (void *ptr, char *id, int style)
|
||||||
{
|
{
|
||||||
class LAMMPS *lmp = (class LAMMPS *) ptr;
|
int *size;
|
||||||
int ifix = lmp->modify->find_fix(id);
|
size = (int *) lammps_extract_fix(ptr, id, style, LMP_SIZE_VECTOR, 0, 0);
|
||||||
if ( ifix < 0 ) return 0;
|
if (size) return *size;
|
||||||
class Fix *fix = lmp->modify->fix[ifix];
|
return 0;
|
||||||
|
|
||||||
if ( style == 0 )
|
|
||||||
{
|
|
||||||
if ( !fix->vector_flag )
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return fix->size_vector;
|
|
||||||
}
|
|
||||||
else if ( style == 1 )
|
|
||||||
{
|
|
||||||
return lammps_get_natoms (ptr);
|
|
||||||
}
|
|
||||||
else if ( style == 2 )
|
|
||||||
{
|
|
||||||
if ( !fix->local_flag )
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return fix->size_local_rows;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lammps_extract_fix_arraysize (void *ptr, char *id, int style,
|
void lammps_extract_fix_arraysize (void *ptr, char *id, int style,
|
||||||
int *nrows, int *ncols)
|
int *nrows, int *ncols)
|
||||||
{
|
{
|
||||||
class LAMMPS *lmp = (class LAMMPS *) ptr;
|
int *tmp;
|
||||||
int ifix = lmp->modify->find_fix(id);
|
tmp = (int *) lammps_extract_fix(ptr, id, style, LMP_SIZE_ROWS, 0, 0);
|
||||||
if ( ifix < 0 )
|
if (tmp) *nrows = *tmp;
|
||||||
{
|
tmp = (int *) lammps_extract_fix(ptr, id, style, LMP_SIZE_COLS, 0, 0);
|
||||||
*nrows = 0;
|
if (tmp) *ncols = *tmp;
|
||||||
*ncols = 0;
|
|
||||||
}
|
|
||||||
class Fix *fix = lmp->modify->fix[ifix];
|
|
||||||
|
|
||||||
if ( style == 0 )
|
|
||||||
{
|
|
||||||
if ( !fix->array_flag )
|
|
||||||
{
|
|
||||||
*nrows = 0;
|
|
||||||
*ncols = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*nrows = fix->size_array_rows;
|
|
||||||
*ncols = fix->size_array_cols;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( style == 1 )
|
|
||||||
{
|
|
||||||
if ( !fix->peratom_flag )
|
|
||||||
{
|
|
||||||
*nrows = 0;
|
|
||||||
*ncols = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*nrows = lammps_get_natoms (ptr);
|
|
||||||
*ncols = fix->size_peratom_cols;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( style == 2 )
|
|
||||||
{
|
|
||||||
if ( !fix->local_flag )
|
|
||||||
{
|
|
||||||
*nrows = 0;
|
|
||||||
*ncols = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*nrows = fix->size_local_rows;
|
|
||||||
*ncols = fix->size_local_cols;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*nrows = 0;
|
|
||||||
*ncols = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set ts=3 sts=3 expandtab: */
|
/* vim: set ts=3 sts=3 expandtab: */
|
||||||
|
|||||||
@ -12,8 +12,8 @@
|
|||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------
|
||||||
Contributing author: Karl D. Hammond <karlh@ugcs.caltech.edu>
|
Contributing author: Karl D. Hammond <hammondkd@missouri.edu>
|
||||||
University of Tennessee, Knoxville (USA), 2012
|
University of Missouri (USA), 2012
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* This is set of "wrapper" functions to assist LAMMPS.F90, which itself
|
/* This is set of "wrapper" functions to assist LAMMPS.F90, which itself
|
||||||
|
|||||||
@ -12,8 +12,7 @@
|
|||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------
|
||||||
Contributing author: Karl D. Hammond <karlh@ugcs.caltech.edu>
|
Contributing author: Nir Goldman, LLNL <ngoldman@llnl.gov>, 2016
|
||||||
University of Tennessee, Knoxville (USA), 2012
|
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* This is set of "wrapper" functions to assist LAMMPS.F90, which itself
|
/* This is set of "wrapper" functions to assist LAMMPS.F90, which itself
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------
|
||||||
Contributing author: Nir Goldman, ngoldman@llnl.gov, Oct. 19th, 2016
|
Contributing author: Nir Goldman, LLNL <ngoldman@llnl.gov>, 2016
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* This is set of "wrapper" functions to assist LAMMPS.F90, which itself
|
/* This is set of "wrapper" functions to assist LAMMPS.F90, which itself
|
||||||
|
|||||||
@ -12,8 +12,8 @@
|
|||||||
!--------------------------------------------------------------------------
|
!--------------------------------------------------------------------------
|
||||||
|
|
||||||
!! ------------------------------------------------------------------------
|
!! ------------------------------------------------------------------------
|
||||||
! Contributing author: Karl D. Hammond <karlh@ugcs.caltech.edu>
|
! Contributing author: Karl D. Hammond <hammondkd@missouri.edu>
|
||||||
! University of Tennessee, Knoxville (USA), 2012
|
! University of Missouri (USA), 2012
|
||||||
!--------------------------------------------------------------------------
|
!--------------------------------------------------------------------------
|
||||||
|
|
||||||
!! LAMMPS, a Fortran 2003 module containing an interface between Fortran
|
!! LAMMPS, a Fortran 2003 module containing an interface between Fortran
|
||||||
|
|||||||
@ -188,20 +188,17 @@ class lammps(object):
|
|||||||
[c_void_p,POINTER(c_double),POINTER(c_double),c_double,c_double,c_double]
|
[c_void_p,POINTER(c_double),POINTER(c_double),c_double,c_double,c_double]
|
||||||
self.lib.lammps_reset_box.restype = None
|
self.lib.lammps_reset_box.restype = None
|
||||||
|
|
||||||
self.lib.lammps_gather_atoms.argtypes = \
|
self.lib.lammps_gather_atoms.argtypes = [c_void_p,c_char_p,c_int,c_int,c_void_p]
|
||||||
[c_void_p,c_char_p,c_int,c_int,c_void_p]
|
|
||||||
self.lib.lammps_gather_atoms.restype = None
|
self.lib.lammps_gather_atoms.restype = None
|
||||||
|
|
||||||
self.lib.lammps_gather_atoms_concat.argtypes = \
|
self.lib.lammps_gather_atoms_concat.argtypes = [c_void_p,c_char_p,c_int,c_int,c_void_p]
|
||||||
[c_void_p,c_char_p,c_int,c_int,c_void_p]
|
|
||||||
self.lib.lammps_gather_atoms_concat.restype = None
|
self.lib.lammps_gather_atoms_concat.restype = None
|
||||||
|
|
||||||
self.lib.lammps_gather_atoms_subset.argtypes = \
|
self.lib.lammps_gather_atoms_subset.argtypes = \
|
||||||
[c_void_p,c_char_p,c_int,c_int,c_int,POINTER(c_int),c_void_p]
|
[c_void_p,c_char_p,c_int,c_int,c_int,POINTER(c_int),c_void_p]
|
||||||
self.lib.lammps_gather_atoms_subset.restype = None
|
self.lib.lammps_gather_atoms_subset.restype = None
|
||||||
|
|
||||||
self.lib.lammps_scatter_atoms.argtypes = \
|
self.lib.lammps_scatter_atoms.argtypes = [c_void_p,c_char_p,c_int,c_int,c_void_p]
|
||||||
[c_void_p,c_char_p,c_int,c_int,c_void_p]
|
|
||||||
self.lib.lammps_scatter_atoms.restype = None
|
self.lib.lammps_scatter_atoms.restype = None
|
||||||
|
|
||||||
self.lib.lammps_scatter_atoms_subset.argtypes = \
|
self.lib.lammps_scatter_atoms_subset.argtypes = \
|
||||||
@ -211,20 +208,17 @@ class lammps(object):
|
|||||||
self.lib.lammps_gather_bonds.argtypes = [c_void_p,c_void_p]
|
self.lib.lammps_gather_bonds.argtypes = [c_void_p,c_void_p]
|
||||||
self.lib.lammps_gather_bonds.restype = None
|
self.lib.lammps_gather_bonds.restype = None
|
||||||
|
|
||||||
self.lib.lammps_gather.argtypes = \
|
self.lib.lammps_gather.argtypes = [c_void_p,c_char_p,c_int,c_int,c_void_p]
|
||||||
[c_void_p,c_char_p,c_int,c_int,c_void_p]
|
|
||||||
self.lib.lammps_gather.restype = None
|
self.lib.lammps_gather.restype = None
|
||||||
|
|
||||||
self.lib.lammps_gather_concat.argtypes = \
|
self.lib.lammps_gather_concat.argtypes = [c_void_p,c_char_p,c_int,c_int,c_void_p]
|
||||||
[c_void_p,c_char_p,c_int,c_int,c_void_p]
|
|
||||||
self.lib.lammps_gather_concat.restype = None
|
self.lib.lammps_gather_concat.restype = None
|
||||||
|
|
||||||
self.lib.lammps_gather_subset.argtypes = \
|
self.lib.lammps_gather_subset.argtypes = \
|
||||||
[c_void_p,c_char_p,c_int,c_int,c_int,POINTER(c_int),c_void_p]
|
[c_void_p,c_char_p,c_int,c_int,c_int,POINTER(c_int),c_void_p]
|
||||||
self.lib.lammps_gather_subset.restype = None
|
self.lib.lammps_gather_subset.restype = None
|
||||||
|
|
||||||
self.lib.lammps_scatter.argtypes = \
|
self.lib.lammps_scatter.argtypes = [c_void_p,c_char_p,c_int,c_int,c_void_p]
|
||||||
[c_void_p,c_char_p,c_int,c_int,c_void_p]
|
|
||||||
self.lib.lammps_scatter.restype = None
|
self.lib.lammps_scatter.restype = None
|
||||||
|
|
||||||
self.lib.lammps_scatter_subset.argtypes = \
|
self.lib.lammps_scatter_subset.argtypes = \
|
||||||
@ -244,7 +238,8 @@ class lammps(object):
|
|||||||
self.lib.lammps_neighlist_num_elements.argtypes = [c_void_p, c_int]
|
self.lib.lammps_neighlist_num_elements.argtypes = [c_void_p, c_int]
|
||||||
self.lib.lammps_neighlist_num_elements.restype = c_int
|
self.lib.lammps_neighlist_num_elements.restype = c_int
|
||||||
|
|
||||||
self.lib.lammps_neighlist_element_neighbors.argtypes = [c_void_p, c_int, c_int, POINTER(c_int), POINTER(c_int), POINTER(POINTER(c_int))]
|
self.lib.lammps_neighlist_element_neighbors.argtypes = \
|
||||||
|
[c_void_p, c_int, c_int, POINTER(c_int), POINTER(c_int), POINTER(POINTER(c_int))]
|
||||||
self.lib.lammps_neighlist_element_neighbors.restype = None
|
self.lib.lammps_neighlist_element_neighbors.restype = None
|
||||||
|
|
||||||
self.lib.lammps_is_running.argtypes = [c_void_p]
|
self.lib.lammps_is_running.argtypes = [c_void_p]
|
||||||
@ -368,11 +363,9 @@ class lammps(object):
|
|||||||
if type(cmdargs[i]) is str:
|
if type(cmdargs[i]) is str:
|
||||||
cmdargs[i] = cmdargs[i].encode()
|
cmdargs[i] = cmdargs[i].encode()
|
||||||
cargs = (c_char_p*narg)(*cmdargs)
|
cargs = (c_char_p*narg)(*cmdargs)
|
||||||
self.lib.lammps_open.argtypes = [c_int, c_char_p*narg, \
|
self.lib.lammps_open.argtypes = [c_int, c_char_p*narg, MPI_Comm, c_void_p]
|
||||||
MPI_Comm, c_void_p]
|
|
||||||
else:
|
else:
|
||||||
self.lib.lammps_open.argtypes = [c_int, c_char_p, \
|
self.lib.lammps_open.argtypes = [c_int, c_char_p, MPI_Comm, c_void_p]
|
||||||
MPI_Comm, c_void_p]
|
|
||||||
|
|
||||||
self.opened = 1
|
self.opened = 1
|
||||||
comm_ptr = self.MPI._addressof(comm)
|
comm_ptr = self.MPI._addressof(comm)
|
||||||
@ -390,8 +383,7 @@ class lammps(object):
|
|||||||
if type(cmdargs[i]) is str:
|
if type(cmdargs[i]) is str:
|
||||||
cmdargs[i] = cmdargs[i].encode()
|
cmdargs[i] = cmdargs[i].encode()
|
||||||
cargs = (c_char_p*narg)(*cmdargs)
|
cargs = (c_char_p*narg)(*cmdargs)
|
||||||
self.lib.lammps_open_no_mpi.argtypes = [c_int, c_char_p*narg, \
|
self.lib.lammps_open_no_mpi.argtypes = [c_int, c_char_p*narg, c_void_p]
|
||||||
c_void_p]
|
|
||||||
self.lmp = c_void_p(self.lib.lammps_open_no_mpi(narg,cargs,None))
|
self.lmp = c_void_p(self.lib.lammps_open_no_mpi(narg,cargs,None))
|
||||||
else:
|
else:
|
||||||
self.lib.lammps_open_no_mpi.argtypes = [c_int, c_char_p, c_void_p]
|
self.lib.lammps_open_no_mpi.argtypes = [c_int, c_char_p, c_void_p]
|
||||||
@ -963,17 +955,14 @@ class lammps(object):
|
|||||||
return ptr
|
return ptr
|
||||||
|
|
||||||
elif ctype == LMP_SIZE_COLS:
|
elif ctype == LMP_SIZE_COLS:
|
||||||
if cstyle == LMP_STYLE_GLOBAL \
|
if cstyle == LMP_STYLE_GLOBAL or cstyle == LMP_STYLE_ATOM or cstyle == LMP_STYLE_LOCAL:
|
||||||
or cstyle == LMP_STYLE_ATOM \
|
|
||||||
or cstyle == LMP_STYLE_LOCAL:
|
|
||||||
self.lib.lammps_extract_compute.restype = POINTER(c_int)
|
self.lib.lammps_extract_compute.restype = POINTER(c_int)
|
||||||
with ExceptionCheck(self):
|
with ExceptionCheck(self):
|
||||||
ptr = self.lib.lammps_extract_compute(self.lmp,cid,cstyle,ctype)
|
ptr = self.lib.lammps_extract_compute(self.lmp,cid,cstyle,ctype)
|
||||||
return ptr[0]
|
return ptr[0]
|
||||||
|
|
||||||
elif ctype == LMP_SIZE_VECTOR or ctype == LMP_SIZE_ROWS:
|
elif ctype == LMP_SIZE_VECTOR or ctype == LMP_SIZE_ROWS:
|
||||||
if cstyle == LMP_STYLE_GLOBAL \
|
if cstyle == LMP_STYLE_GLOBAL or cstyle == LMP_STYLE_LOCAL:
|
||||||
or cstyle == LMP_STYLE_LOCAL:
|
|
||||||
self.lib.lammps_extract_compute.restype = POINTER(c_int)
|
self.lib.lammps_extract_compute.restype = POINTER(c_int)
|
||||||
with ExceptionCheck(self):
|
with ExceptionCheck(self):
|
||||||
ptr = self.lib.lammps_extract_compute(self.lmp,cid,cstyle,ctype)
|
ptr = self.lib.lammps_extract_compute(self.lmp,cid,cstyle,ctype)
|
||||||
|
|||||||
@ -165,7 +165,7 @@ class numpy_wrapper:
|
|||||||
"""
|
"""
|
||||||
value = self.lmp.extract_compute(cid, cstyle, ctype)
|
value = self.lmp.extract_compute(cid, cstyle, ctype)
|
||||||
|
|
||||||
if cstyle in (LMP_STYLE_GLOBAL, LMP_STYLE_LOCAL):
|
if cstyle == LMP_STYLE_GLOBAL:
|
||||||
if ctype == LMP_TYPE_VECTOR:
|
if ctype == LMP_TYPE_VECTOR:
|
||||||
nrows = self.lmp.extract_compute(cid, cstyle, LMP_SIZE_VECTOR)
|
nrows = self.lmp.extract_compute(cid, cstyle, LMP_SIZE_VECTOR)
|
||||||
return self.darray(value, nrows)
|
return self.darray(value, nrows)
|
||||||
@ -173,6 +173,13 @@ class numpy_wrapper:
|
|||||||
nrows = self.lmp.extract_compute(cid, cstyle, LMP_SIZE_ROWS)
|
nrows = self.lmp.extract_compute(cid, cstyle, LMP_SIZE_ROWS)
|
||||||
ncols = self.lmp.extract_compute(cid, cstyle, LMP_SIZE_COLS)
|
ncols = self.lmp.extract_compute(cid, cstyle, LMP_SIZE_COLS)
|
||||||
return self.darray(value, nrows, ncols)
|
return self.darray(value, nrows, ncols)
|
||||||
|
elif cstyle == LMP_STYLE_LOCAL:
|
||||||
|
nrows = self.lmp.extract_compute(cid, cstyle, LMP_SIZE_ROWS)
|
||||||
|
ncols = self.lmp.extract_compute(cid, cstyle, LMP_SIZE_COLS)
|
||||||
|
if ncols == 0:
|
||||||
|
return self.darray(value, nrows)
|
||||||
|
else:
|
||||||
|
return self.darray(value, nrows, ncols)
|
||||||
elif cstyle == LMP_STYLE_ATOM:
|
elif cstyle == LMP_STYLE_ATOM:
|
||||||
if ctype == LMP_TYPE_VECTOR:
|
if ctype == LMP_TYPE_VECTOR:
|
||||||
nlocal = self.lmp.extract_global("nlocal")
|
nlocal = self.lmp.extract_global("nlocal")
|
||||||
|
|||||||
@ -266,7 +266,7 @@ void ComputeStressCartesian::compute_array()
|
|||||||
Pair *pair = force->pair;
|
Pair *pair = force->pair;
|
||||||
double **cutsq = force->pair->cutsq;
|
double **cutsq = force->pair->cutsq;
|
||||||
|
|
||||||
double xi1, xi2, xj1, xj2;
|
double xi1, xi2;
|
||||||
|
|
||||||
for (ii = 0; ii < inum; ii++) {
|
for (ii = 0; ii < inum; ii++) {
|
||||||
i = ilist[ii];
|
i = ilist[ii];
|
||||||
@ -305,9 +305,6 @@ void ComputeStressCartesian::compute_array()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xj1 = x[j][dir1];
|
|
||||||
xj2 = x[j][dir2];
|
|
||||||
|
|
||||||
delx = x[j][0] - xtmp;
|
delx = x[j][0] - xtmp;
|
||||||
dely = x[j][1] - ytmp;
|
dely = x[j][1] - ytmp;
|
||||||
delz = x[j][2] - ztmp;
|
delz = x[j][2] - ztmp;
|
||||||
|
|||||||
@ -124,6 +124,12 @@ void DumpYAML::write_data(int n, double *mybuf)
|
|||||||
}
|
}
|
||||||
fputs("]\n", fp);
|
fputs("]\n", fp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void DumpYAML::write_footer()
|
||||||
|
{
|
||||||
fputs("...\n", fp);
|
fputs("...\n", fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -35,6 +35,7 @@ class DumpYAML : public DumpCustom {
|
|||||||
void write() override;
|
void write() override;
|
||||||
void write_header(bigint) override;
|
void write_header(bigint) override;
|
||||||
void write_data(int, double *) override;
|
void write_data(int, double *) override;
|
||||||
|
void write_footer() override;
|
||||||
|
|
||||||
int modify_param(int, char **) override;
|
int modify_param(int, char **) override;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -517,6 +517,8 @@ void Dump::write()
|
|||||||
|
|
||||||
if (refreshflag) modify->compute[irefresh]->refresh();
|
if (refreshflag) modify->compute[irefresh]->refresh();
|
||||||
|
|
||||||
|
if (filewriter && fp != nullptr) write_footer();
|
||||||
|
|
||||||
// if file per timestep, close file if I am filewriter
|
// if file per timestep, close file if I am filewriter
|
||||||
|
|
||||||
if (multifile) {
|
if (multifile) {
|
||||||
|
|||||||
@ -153,6 +153,8 @@ class Dump : protected Pointers {
|
|||||||
virtual void pack(tagint *) = 0;
|
virtual void pack(tagint *) = 0;
|
||||||
virtual int convert_string(int, double *) { return 0; }
|
virtual int convert_string(int, double *) { return 0; }
|
||||||
virtual void write_data(int, double *) = 0;
|
virtual void write_data(int, double *) = 0;
|
||||||
|
virtual void write_footer() {}
|
||||||
|
|
||||||
void pbc_allocate();
|
void pbc_allocate();
|
||||||
double compute_time();
|
double compute_time();
|
||||||
|
|
||||||
|
|||||||
@ -1659,14 +1659,18 @@ lists the available options.
|
|||||||
- LMP_TYPE_ARRAY
|
- LMP_TYPE_ARRAY
|
||||||
- ``double **``
|
- ``double **``
|
||||||
- Local data array
|
- Local data array
|
||||||
|
* - LMP_STYLE_LOCAL
|
||||||
|
- LMP_SIZE_VECTOR
|
||||||
|
- ``int *``
|
||||||
|
- Alias for using LMP_SIZE_ROWS
|
||||||
* - LMP_STYLE_LOCAL
|
* - LMP_STYLE_LOCAL
|
||||||
- LMP_SIZE_ROWS
|
- LMP_SIZE_ROWS
|
||||||
- ``int *``
|
- ``int *``
|
||||||
- Number of local data rows
|
- Number of local array rows or length of vector
|
||||||
* - LMP_STYLE_LOCAL
|
* - LMP_STYLE_LOCAL
|
||||||
- LMP_SIZE_COLS
|
- LMP_SIZE_COLS
|
||||||
- ``int *``
|
- ``int *``
|
||||||
- Number of local data columns
|
- Number of local array columns, 0 if vector
|
||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
|
|
||||||
@ -1749,6 +1753,7 @@ void *lammps_extract_compute(void *handle, const char *id, int style, int type)
|
|||||||
if (type == LMP_TYPE_SCALAR) return (void *) &compute->size_local_rows; /* for backward compatibility */
|
if (type == LMP_TYPE_SCALAR) return (void *) &compute->size_local_rows; /* for backward compatibility */
|
||||||
if (type == LMP_TYPE_VECTOR) return (void *) compute->vector_local;
|
if (type == LMP_TYPE_VECTOR) return (void *) compute->vector_local;
|
||||||
if (type == LMP_TYPE_ARRAY) return (void *) compute->array_local;
|
if (type == LMP_TYPE_ARRAY) return (void *) compute->array_local;
|
||||||
|
if (type == LMP_SIZE_VECTOR) return (void *) &compute->size_local_rows; /* alias for LMP_SIZE_ROWS */
|
||||||
if (type == LMP_SIZE_ROWS) return (void *) &compute->size_local_rows;
|
if (type == LMP_SIZE_ROWS) return (void *) &compute->size_local_rows;
|
||||||
if (type == LMP_SIZE_COLS) return (void *) &compute->size_local_cols;
|
if (type == LMP_SIZE_COLS) return (void *) &compute->size_local_cols;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,9 +61,10 @@ void ReadRestart::command(int narg, char **arg)
|
|||||||
|
|
||||||
// check for remap option
|
// check for remap option
|
||||||
|
|
||||||
int remapflag = 0;
|
int remapflag = 1;
|
||||||
if (narg == 2) {
|
if (narg == 2) {
|
||||||
if (strcmp(arg[1],"remap") == 0) remapflag = 1;
|
if (strcmp(arg[1],"noremap") == 0) remapflag = 0;
|
||||||
|
else if (strcmp(arg[1],"remap") == 0) remapflag = 1; // for backward compatibility
|
||||||
else error->all(FLERR,"Illegal read_restart command");
|
else error->all(FLERR,"Illegal read_restart command");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -643,8 +644,7 @@ void ReadRestart::header()
|
|||||||
int dimension = read_int();
|
int dimension = read_int();
|
||||||
domain->dimension = dimension;
|
domain->dimension = dimension;
|
||||||
if (domain->dimension == 2 && domain->zperiodic == 0)
|
if (domain->dimension == 2 && domain->zperiodic == 0)
|
||||||
error->all(FLERR,
|
error->all(FLERR, "Cannot run 2d simulation with non-periodic Z dimension");
|
||||||
"Cannot run 2d simulation with non-periodic Z dimension");
|
|
||||||
|
|
||||||
// read nprocs from restart file, warn if different
|
// read nprocs from restart file, warn if different
|
||||||
|
|
||||||
|
|||||||
@ -66,9 +66,9 @@
|
|||||||
* The program is started by supplying information at the command prompt
|
* The program is started by supplying information at the command prompt
|
||||||
* according to the usage described below.
|
* according to the usage described below.
|
||||||
*
|
*
|
||||||
* USAGE: msi2lmp3 ROOTNAME {-print #} {-class #} {-frc FRC_FILE} {-ignore} {-nocenter} {-oldstyle}
|
* USAGE: msi2lmp ROOTNAME {-print #} {-class #} {-frc FRC_FILE} {-ignore} {-nocenter} {-oldstyle}
|
||||||
*
|
*
|
||||||
* -- msi2lmp3 is the name of the executable
|
* -- msi2lmp is the name of the executable
|
||||||
* -- ROOTNAME is the base name of the .car and .mdf files
|
* -- ROOTNAME is the base name of the .car and .mdf files
|
||||||
* -- all opther flags are optional and can be abbreviated (e.g. -p instead of -print)
|
* -- all opther flags are optional and can be abbreviated (e.g. -p instead of -print)
|
||||||
*
|
*
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
lammps_version: 17 Feb 2022
|
lammps_version: 17 Feb 2022
|
||||||
date_generated: Fri Mar 18 22:17:48 2022
|
date_generated: Fri Mar 18 22:17:48 2022
|
||||||
epsilon: 1e-12
|
epsilon: 5e-12
|
||||||
skip_tests:
|
skip_tests:
|
||||||
prerequisites: ! |
|
prerequisites: ! |
|
||||||
pair pace
|
pair pace
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
lammps_version: 10 Mar 2021
|
lammps_version: 10 Mar 2021
|
||||||
date_generated: Wed Apr 7 19:30:07 2021
|
date_generated: Wed Apr 7 19:30:07 2021
|
||||||
epsilon: 1e-12
|
epsilon: 5e-12
|
||||||
prerequisites: ! |
|
prerequisites: ! |
|
||||||
pair pace
|
pair pace
|
||||||
pre_commands: ! |
|
pre_commands: ! |
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
import sys,os,unittest,ctypes
|
import sys,os,unittest,ctypes
|
||||||
from lammps import lammps, LMP_VAR_ATOM, LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR, LAMMPS_DOUBLE_2D, LAMMPS_AUTODETECT
|
from lammps import lammps, LMP_VAR_ATOM, LMP_STYLE_GLOBAL, LMP_STYLE_LOCAL
|
||||||
|
from lammps import LMP_TYPE_VECTOR, LMP_SIZE_VECTOR, LMP_SIZE_ROWS, LMP_SIZE_COLS
|
||||||
|
from lammps import LAMMPS_DOUBLE_2D, LAMMPS_AUTODETECT
|
||||||
|
|
||||||
has_manybody=False
|
has_manybody=False
|
||||||
try:
|
try:
|
||||||
@ -311,6 +313,14 @@ create_atoms 1 single &
|
|||||||
self.assertEqual(minval,1.0)
|
self.assertEqual(minval,1.0)
|
||||||
self.assertEqual(maxval,2.1)
|
self.assertEqual(maxval,2.1)
|
||||||
|
|
||||||
|
ndist1 = self.lmp.extract_compute("dist",LMP_STYLE_LOCAL,LMP_SIZE_VECTOR)
|
||||||
|
ndist2 = self.lmp.extract_compute("dist",LMP_STYLE_LOCAL,LMP_SIZE_ROWS)
|
||||||
|
ndist3 = self.lmp.extract_compute("dist",LMP_STYLE_LOCAL,LMP_SIZE_COLS)
|
||||||
|
|
||||||
|
self.assertEqual(ndist1,21)
|
||||||
|
self.assertEqual(ndist2,21)
|
||||||
|
self.assertEqual(ndist3,0)
|
||||||
|
|
||||||
self.assertNotEqual(self.lmp.find_pair_neighlist("lj/cut"),-1)
|
self.assertNotEqual(self.lmp.find_pair_neighlist("lj/cut"),-1)
|
||||||
self.assertNotEqual(self.lmp.find_compute_neighlist("dist"),-1)
|
self.assertNotEqual(self.lmp.find_compute_neighlist("dist"),-1)
|
||||||
self.assertEqual(self.lmp.find_compute_neighlist("xxx"),-1)
|
self.assertEqual(self.lmp.find_compute_neighlist("xxx"),-1)
|
||||||
|
|||||||
@ -93,17 +93,39 @@ class PythonNumpy(unittest.TestCase):
|
|||||||
# TODO
|
# TODO
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def testExtractComputeLocalScalar(self):
|
|
||||||
# TODO
|
|
||||||
pass
|
|
||||||
|
|
||||||
def testExtractComputeLocalVector(self):
|
def testExtractComputeLocalVector(self):
|
||||||
# TODO
|
self.lmp.command("region box block 0 2 0 2 0 2")
|
||||||
pass
|
self.lmp.command("create_box 1 box")
|
||||||
|
self.lmp.command("create_atoms 1 single 1.0 1.0 1.0")
|
||||||
|
self.lmp.command("create_atoms 1 single 1.0 1.0 1.5")
|
||||||
|
self.lmp.command("mass 1 1.0")
|
||||||
|
self.lmp.command("pair_style lj/cut 1.9")
|
||||||
|
self.lmp.command("pair_coeff 1 1 1.0 1.0")
|
||||||
|
self.lmp.command("compute r0 all pair/local dist")
|
||||||
|
self.lmp.command("run 0 post no")
|
||||||
|
values = self.lmp.numpy.extract_compute("r0", LMP_STYLE_LOCAL, LMP_TYPE_VECTOR)
|
||||||
|
self.assertEqual(values.ndim, 1)
|
||||||
|
self.assertEqual(values.size, 2)
|
||||||
|
self.assertEqual(values[0], 0.5)
|
||||||
|
self.assertEqual(values[1], 1.5)
|
||||||
|
|
||||||
def testExtractComputeLocalArray(self):
|
def testExtractComputeLocalArray(self):
|
||||||
# TODO
|
self.lmp.command("region box block 0 2 0 2 0 2")
|
||||||
pass
|
self.lmp.command("create_box 1 box")
|
||||||
|
self.lmp.command("create_atoms 1 single 1.0 1.0 1.0")
|
||||||
|
self.lmp.command("create_atoms 1 single 1.0 1.0 1.5")
|
||||||
|
self.lmp.command("mass 1 1.0")
|
||||||
|
self.lmp.command("pair_style lj/cut 1.9")
|
||||||
|
self.lmp.command("pair_coeff 1 1 1.0 1.0")
|
||||||
|
self.lmp.command("compute r0 all pair/local dist dx dy dz")
|
||||||
|
self.lmp.command("run 0 post no")
|
||||||
|
values = self.lmp.numpy.extract_compute("r0", LMP_STYLE_LOCAL, LMP_TYPE_ARRAY)
|
||||||
|
self.assertEqual(values.ndim, 2)
|
||||||
|
self.assertEqual(values.size, 8)
|
||||||
|
self.assertEqual(values[0,0], 0.5)
|
||||||
|
self.assertEqual(values[0,3], -0.5)
|
||||||
|
self.assertEqual(values[1,0], 1.5)
|
||||||
|
self.assertEqual(values[1,3], 1.5)
|
||||||
|
|
||||||
def testExtractAtomDeprecated(self):
|
def testExtractAtomDeprecated(self):
|
||||||
self.lmp.command("units lj")
|
self.lmp.command("units lj")
|
||||||
|
|||||||
Reference in New Issue
Block a user