LIGGGHTS and python3

Submitted by Schuette on Tue, 06/05/2018 - 13:29

Hey everyone,
has anyone tried using LIGGGHTS with python3? Right now I'm using python2, but i want to update it and use python3 . If I just try to use the install.py with python3 (and change the print structure to python3) I can't open files with a python3 script.

The python script only has the import and liggghts file call. With python2 it works fine but with python3 it says:

LIGGGHTS (Version LIGGGHTS-PUBLIC 3.8.0, compiled 2018-06-04-15:19:16 by root, git commit 28301df8853491784b1d8b90533ea89b8c6af1e8)
ERROR on proc 0: Cannot open input script i (../input.cpp:285)
--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD
with errorcode 1.NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.
--------------------------------------------------------------------------

Right now I have no clue how to get python3 running.

If anyone has some ideas or already has python3 running, some help would be really appreciated.

Greetings,
Thomas

Alex E | Fri, 01/25/2019 - 13:25

Hello there,
I am facing the same problem stated by Thomas last year.

I have tried to compile liggghts without MPI by disabling MPI in the MAKE/Makefile.user file.
But without success.

Has anyone found a solution for this problem jet?
It would help me a lot.
Thanks in advance.

Greetings,
Alex

arnom's picture

arnom | Thu, 02/21/2019 - 11:18

Thanks for brining this issue to our attention and sorry for the long delay in a reply. We at DCS don't use the python interface so I was not aware of the issue. I will put it on our internal bug tracker and see if we can find some time to fix it. As usual contributions by the community are welcome as it might take a while for us.

DCS team member & LIGGGHTS(R) core developer

mschramm | Mon, 10/14/2019 - 07:42

Hello,
I know this is old but I didn't find a discussion about this elsewhere.

It appears that a python3 string gets turned into a wchar_t* array for C++. Thus to get a command to run in python you must do
from liggghts_test import liggghts
lmp = liggghts()
sendStr = 'variable dt equal 1.0e-5'
lmp.command(sendStr.encode())

This creates a byte array in python which is converted into a char* array.
(Of course you have to still do the other things to get the liggghts.py and install.py scripts to work on python 3).