coupling Lammps as a library with a fortran code

Hi,

i would have some help with the example in the COUPLE directory:

my goal is to create a interface between my code (write in fortran) and Lammps as a library

  1. I need to send the position of atom from my code to Lammps :
    I think I can do this by using a read data in the input file but
    I would like to do it like a call inside a Lammps instance if it is possible

  2. after i get the position of atoms in the Lammps instance
    i would like to get the potential energy and force of my systeme and sending back to my code

  3. is it possible to use the library without using the in. file
    if anyone can help me

Thanks

Mickaƫl

Comments below.

Steve

Hi,

i would have some help with the example in the COUPLE directory:

my goal is to create a interface between my code (write in fortran) and
Lammps as a library

1) I need to send the position of atom from my code to Lammps :
I think I can do this by using a read data in the input file but
I would like to do it like a call inside a Lammps instance if it is possible

You can do this via the lib function lammps_extract_atom (which gives
you a ptr to the internal coords), or lammps_scatter_atoms().

2) after i get the position of atoms in the Lammps instance
i would like to get the potential energy and force of my systeme and sending
back to my code

You can do this, by asking LAMMPS to run for 0 timesteps, then
extract the force ptr, and the energy value. The latter
thru lammps_extract_compute(), where you give it an id to
a compute pe you have defined.

3) is it possible to use the library without using the in. file
if anyone can help me

yes, the lib func lammps_command() can pass one command to
LAMMPS at a time.