Hi all,
I want to use lammps_extract_fix from python to access a fixed based per-atom type array (3 components per atoms) from python.
My python code is :
from lammps import lammps
lmp = lammps()
lmp.file(infile)
…
v1 = lmp.extract_fix(“f1”, 1, 2, 1, 1) # f1 is the fix id
print("v1=s" v1)
v2 = v1[1]
print("v2=s" v2)
v3= v2[0]
print("v3=s" v3)
but I get the following error :
Step Atoms KinEng 1 Volume CPU
1 30 0.0076871121 8.3995398e-07 0.0008 0
10 30 0.13298132 0.00042168989 0.0008 0.0013921261
11 30 0.13211083 0.00044754583 0.0008 0.00157094
Loop time of 0.00158596 on 1 procs for 10 steps with 30 atoms
v1=<lammps.LP_LP_c_double object at 0x872077c>
v2=<lammps.LP_c_double object at 0x872080c>
[joris-desktop:25652] *** Process received signal ***
[joris-desktop:25652] Signal: Segmentation fault (11)
[joris-desktop:25652] Signal code: Address not mapped (1)
[joris-desktop:25652] Failing at address: 0x5f6164fd
[joris-desktop:25652] [ 0] [0xb772940c]
[joris-desktop:25652] [ 1] /usr/lib/python2.7/lib-dynload/_ctypes.so(+0x77b2) [0xb5f8e7b2]
[joris-desktop:25652] [ 2] python(PyEval_EvalFrameEx+0x11a4) [0x81958d4]
[joris-desktop:25652] [ 3] python(PyEval_EvalCodeEx+0x150) [0x819af70]
[joris-desktop:25652] [ 4] python(PyRun_FileExFlags+0xe1) [0x819b8a1]
[joris-desktop:25652] [ 5] python(PyRun_SimpleFileExFlags+0x21a) [0x80a8bda]
[joris-desktop:25652] [ 6] python(Py_Main+0x559) [0x80a9949]
[joris-desktop:25652] [ 7] python(main+0x1b) [0x805ea5b]
[joris-desktop:25652] [ 8] /lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0xb73384d3]
[joris-desktop:25652] [ 9] python() [0x805ea81]
[joris-desktop:25652] *** End of error message ***
Segmentation fault (core dumped)
I don’t understand if it is my way of making use in python of the pointer of extract_variable that is wrong, or the function itself that is not intended for fix per_atom type vectors…
I precise that my fix works perfectly on lammps alone.
Thanks for your help !
PS: Steve, I have really no idea how to save last step variable so I’m still trying a python-lammps coupling to manage the external force field and send it to lammps.