lammps/examples/COUPLE/fortran3f670dba3d019lammm-devel
fortran3
README
This directory has an example of using a callback function to obtain forces from a fortran code for a LAMMPS simulation. The reader should refer to the README file in COUPLE/fortran2 before proceeding. Here, the LAMMPS.F90 file has been modified slightly and additional files named LAMMPS-wrapper2.h and LAMMPS-wrapper2.cpp have been included in order to supply wrapper functions to set the LAMMPS callback function and total energy.
In this example, the callback function is set to run the semi-empirical quantum code DFTB+ in serial and then read in the total energy, forces, and stress tensor from file. In this case, nlocal = the total number of atoms in the system, so particle positions can be read from the pos array directly, and DFTB+ forces can simply be included via the fext array. The user should take care in the case of a parallel calculation, where LAMMPS can assign different particules to each processor. For example, the user should use functions such as lammps_gather_atoms() and lammps_scatter_atoms() in the case where the fortran force calculating code requires the positions of all atoms, etc.
A few more important notes:
-The stress tensor from DFTB+ is passed in to LAMMPS via pointer. -Calling the subroutine lammps_set_callback() is required in order to set
a pointer to the callback function in LAMMPS.
-The subroutine lammps_set_user_energy() passes in the potential energy
from DFTB+ to LAMMPS.
This example was created by Nir Goldman, whom you can contact with questions:
Nir Goldman, LLNL ngoldman@llnl.gov