GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing docs.lammps.org — 1. LAMMPS Library Interfaces — LAMMPS documentation 1. LAMMPS Library InterfacesAs described on the library interface to LAMMPS page, LAMMPS can be built as a library (static or shared), so that it can be called by another code, used in a coupled manner with other codes, or driven through a Python script. The LAMMPS standalone executable itself is essentially a thin wrapper on top of the LAMMPS library, which creates a LAMMPS instance, passes the input for processing to that instance, and then exits. Most of the APIs described below are based on C language wrapper
functions in the files Thread-safety LAMMPS was initially not conceived as a thread-safe program, but over the years changes have been applied to replace operations that collide with creating multiple LAMMPS instances from multiple-threads of the same process with thread-safe alternatives. This primarily applies to the core LAMMPS code and less so on add-on packages, especially when those packages require additional code in the lib folder, interface LAMMPS to Fortran libraries, or the code uses static variables (like the COLVARS package). Another major issue to deal with is to correctly handle MPI.
Creating a LAMMPS instance requires passing an MPI communicator, or
it assumes the 1.1. LAMMPS C Library APIThe C library interface is the most commonly used path to manage LAMMPS
instances from a compiled code and it is the basis for the Python and Fortran modules. Almost all
functions of the C language API require an argument containing a
“handle” in the form of a The Please note the Errors versus exceptions If the LAMMPS executable encounters an error condition, it will abort
after printing an error message. It does so by catching the
exceptions that LAMMPS could throw. For a C library interface this
is usually not desirable since the calling code might lack the
ability to catch such exceptions. Thus, the library functions will
catch those exceptions and return from the affected functions. The
error status Using the C library interface as a plugin Rather than including the C library interface directly including the
Warning No checks are made on the arguments of the function calls of the C library interface. All function arguments must be non-NULL unless explicitly allowed, and must point to consistent and valid data. Buffers for storing returned data must be allocated to a suitable size. Passing invalid or unsuitable information will likely cause crashes or corrupt data.
1.2. LAMMPS Python APIThe LAMMPS Python module enables calling the LAMMPS C library API from Python by dynamically loading functions in the LAMMPS shared library through the Python ctypes module. Because of the dynamic loading, it is required that LAMMPS is compiled in “shared” mode. The Python interface is object-oriented, but otherwise tries to be very similar to the C library API. More information on this is in the Use Python with LAMMPS section of the manual. Use of the LAMMPS Python module is described in The lammps Python module. 1.3. LAMMPS Fortran APIThe LAMMPS Fortran module is a wrapper around calling functions from the LAMMPS C library API. This is done using the ISO_C_BINDING feature in Fortran 2003. The interface is object-oriented but otherwise tries to be very similar to the C library API and the basic Python module. 1.4. LAMMPS C++ APIIt is also possible to invoke the LAMMPS C++ API directly in your code. It lacks some of the convenience of the C library API, but it allows more direct access to simulation data and thus more low-level manipulations. The following links provide some examples and references to the C++ API. |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |