Problem with lammps_extract_compute using lammps as a library in a fortran code

Dear all,

I have linked lammps with a fortran code, using lammps as a library. I could extracted from lammps the force per atom (using lammps_extract_atom) and the total potential energy (using lammps_extract_compute).

However, I struggle to extract the potential energy per atom or in fact any other vectors with lammps_extract_compute and I would appreciate your help on this point. See below the command I’m using now :

  1. first I defined the compute command :
    call lammps_command(lmp,‘compute peperatom all pe/atom’)
  2. then I want to extract the result of such compute as a vector:
    call lammps_extract_compute (energy_pa, lmp, ‘peperatom’,1,1)
    where energy_pa is defined as follow
    real (C_double),dimension(:), pointer :: energy_pa => NULL()
    The code starts to crash at the second step with a segmentation fault.

I also tried the style 2 because I’m not sure about it : call lammps_extract_compute (energy_pa, lmp, ‘peperatom’,2,1) but it does not work either.

Thanks,

Best regards,

Marie

See if you can get you Python code to work with compute ke/atom first.
If you can’t then something is wrong with your Python code or with
the lib interface to per-atom computes (e.g. a bug).

If you can, then the problem is probably that you can’t access the results
from compute pe/atom unless you insure that LAMMPS actually tallied
per-atom potential energy on the tilmestep you are accessing it.
You can do this by defining a compute reduce that used the
pe/atom compute and sums the pe/atom into a total pe and outputs
it with thermo output. If you only access compute pe/atom on
timesteps you do thermo output, then you should be fine.

Steve

Sorry, meant your Fortran code, not your Python code.

Steve

Thanks Steve,
Yes in fact it doesn’t work with ke/atom either or other things/atom… Yes you’re right I think also that there still a bug to found, it might probably be in the lib interface (the wrapper.cpp maybe also ?) because extract_compute works well when I extract a scalar data.

Best regards,
Marie