pylammps - accessing the result of compute property/atom

Dear all,

I am trying to “incorporate” the following two LAMMPS commands to a PyLAMMPS script:

compute metal_id shell_atom property/atom id

dump myDump all custom 2 dump.atom id c_metal_id

where shell_atom is a group I have previously defined using a command that looks like “group shell_atom type 1”. Following the manual, the compute command can be written as

L.compute(" metal_id shell_atom property/atom id")

I would like to assign the c_metal_id in a python variable instead of writing it to a file. How can I do that? I have thought of the following commands:

L.variable("xxx atom c_ metal_id ")
L.run(0)
x = L.variables[‘xxx’]

but when executing I get the following message: “ERROR: Variable xxx: Compute used in variable between runs is not current (…/variable.cpp:1529)”

Thank you,
Evangelos

as a general rule, data from computes can only be accessed during runs, as they may be depending on data that has to be tallied during a force computation or similar, which will happen only during a run. a workaround in many cases has been to use an averaging fix, but averaging only over a single repeat, so that it acts as a cache.

in the particular case, there is not much of a point in using compute property/atom as an atom style variable function of: id*gmask(shell_atom) should have the same result.

axel.

Thanks a lot for the clarification ! I had overlooked gmask.

Evangelos

Στις Τετ, 20 Μαρ 2019 στις 3:43 μ.μ., ο/η Axel Kohlmeyer <[email protected]> έγραψε: