FixSymmetry
is a custom LAMMPS fix that enforces crystal symmetry during simulations, porting from ase. It utilizes the spglib
library to obtain symmetry operations based on the specified space group.
This guide provides step-by-step instructions to install FixSymmetry
into LAMMPS and run a test simulation to verify its functionality.
- LAMMPS Source Code: Ensure you have the LAMMPS source code available on your system.
- spglib Library: Install
spglib
(version compatible with your system).
Clone the spglib
repository and install it:
git clone https://github.com/spglib/spglib.git
cd spglib
mkdir build
cd build
cmake .. --install-prefix=$HOME/.local
make
sudo make install
Ensure that the spglib
header files and libraries are installed in standard system directories or note their installation paths for later use.
Basically, you can use install_fix_symmetry.sh with CMake compiliation in lammps. If you would like to compile manually with Make, please check below.
Copy fix_symmetry.h
and fix_symmetry.cpp
into the LAMMPS src
directory:
cp fix_symmetry.h /path/to/lammps/src/
cp fix_symmetry.cpp /path/to/lammps/src/
Use Install_?
Navigate to the LAMMPS src
directory:
cd /path/to/lammps/src
-
Add Source File: Append
fix_symmetry.cpp
andfix_box_relax_symmetry.cpp
to the list of source files. EditMakefile
orMakefile.list
and include:EXTRA_SRCS += fix_symmetry.cpp:fix_box_relax_symmtery.cpp
-
Include spglib Headers and Libraries: Add the spglib include and library paths. Edit
Makefile.lammps
and include:EXTRA_INC += -I/path/to/spglib/include EXTRA_LIB += -L/path/to/spglib/lib -lspglib
Replace
/path/to/spglib/include
and/path/to/spglib/lib
with the actual paths ifspglib
is not in standard directories.
-
Modify CMakeLists.txt: If using CMake, add
fix_symmetry.cpp
to the source list and linkspglib
.In
CMakeLists.txt
, add:set(SOURCES ${SOURCES} fix_symmetry.cpp:fix_box_relax_symmetry.cpp) find_package(spglib REQUIRED) include_directories(${SPGLIB_INCLUDE_DIRS}) target_link_libraries(lammps ${SPGLIB_LIBRARIES})
mkdir build
cd build
cmake ../cmake ...
make -j8
Clean previous builds (optional):
make clean-all
Compile LAMMPS:
make mpi # Replace 'mpi' with your desired build target
Ensure that the compiler can find spglib
headers and libraries. If not in standard locations, you may need to set environment variables or adjust compiler flags.
After successful compilation, verify that FixSymmetry
is included:
- Run
lmp_mpi -h
and check iffix symmetry
andfix box/relax/symmetry
appears in the list of available fixes. - Alternatively, proceed to run the test simulation.
In your LAMMPS input script, use FixSymmetry
as follows:
fix sym all symmetry <tolerance>
<tolerance>
: Optional. The tolerance for symmetry enforcement (default is1e-5
).
In your LAMMPS input script, use FixSymmetry
as follows:
fix sym all box/relax/symmetry symprec <tolerance>
<tolerance>
: Optional. The tolerance for symmetry enforcement (default is1e-5
).
- Compilation Errors: Ensure that
spglib
is correctly installed and that the compiler and linker can find the necessary headers and libraries. - Runtime Errors: Verify that the space group number and tolerance are correctly specified and appropriate for your simulation.
- Missing Potentials: Ensure that all required potential files are available in your working directory.
This code is distributed under the GNU General Public License v2. See the LICENSE
file for more details.
- spglib: https://github.com/spglib/spglib
- LAMMPS: https://lammps.sandia.gov/