Execution error of the lammps script example invoking a python function

Hello everyone,
I am a beginner with lammps,
I have compiled the python package of Lammps with the cmake interface on windows 10.
then to check that python and lammps are embedded, I made some examples in the python subfolder of the example folder. I took the example in.python.lmp whose script invokes the function funcs.py, and so far I have an error that I do not understand.

can someone help me please?

Glenn

lammps_4|690x369

This part of the LAMMPS code has not been ported to Windows yet.
Your best shot at getting this functionality to work on Windows is currently to install the Windows subsystem for Linux (WSL) and then compile with Linux tools and libraries inside the bash shell.

https://docs.lammps.org/Howto_wsl.html

After some checking with a Linux to Windows cross compiler and running the resulting executable with a wine docker container on a Linux machine with singularity (I don’t think there is a more indirect way of testing this…), it looks like I was able to identify the changes that are necessary to compile a working Python support on Windows. It basically boils down to the fact that a long int on Linux and macOS is a 64-bit integer, while on Windows it is (still) 32-bit and you need to use a long long int to store a 64-bit integer. The actual change is in this commit.

and will be released with the next LAMMPS patch release (aka pre-release).

$ singularity exec --bind /usr/x86_64-w64-mingw32 ~/compile/lammps/wine.sif env WINEPATH="D:\\bin;..\\..\\" env PYTHONPATH=..\\python  wine lammps-shell.exe
LAMMPS Shell version 1.1  OS: Windows 6.1 (7601) on x86_64
GNU C++ 10.3.1 20210422 (Fedora MinGW 10.3.1-1.fc34) with OpenMP 4.5
LAMMPS (14 May 2021)
  using 4 OpenMP thread(s) per MPI task
LAMMPS Shell> source in.python
Lattice spacing in x,y,z = 1.6795962 1.6795962 1.6795962
Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (16.795962 16.795962 16.795962)
  1 by 1 by 1 MPI processor grid
Created 4000 atoms
  create_atoms CPU = 0.001 seconds
Neighbor list info ...
  update every 1 steps, delay 0 steps, check yes
  max neighbors/atom: 2000, page size: 100000
  master list distance cutoff = 2.8
  ghost atom cutoff = 2.8
  binsize = 1.4, bins = 12 12 12
  1 neighbor lists, perpetual/occasional/extra = 1 0 0
  (1) pair lj/cut, perpetual
      attributes: half, newton on
      pair build: half/bin/atomonly/newton
      stencil: half/bin/3d
      bin: standard
Setting up Verlet run ...
  Unit style    : lj
  Current step  : 0
  Time step     : 0.005
Per MPI rank memory allocation (min/avg/max) = 6.366 | 6.366 | 6.366 Mbytes
Step Temp E_pair E_mol TotEng Press 
       0         1.44   -6.7733681            0   -4.6139081   -5.0199732 
      10    1.1259767   -6.3010653            0   -4.6125225   -2.5704638 
Loop time of 0.0600009 on 4 procs for 10 steps with 4000 atoms

Performance: 71998.924 tau/day, 166.664 timesteps/s
83.3% CPU use with 1 MPI tasks x 4 OpenMP threads

MPI task timing breakdown:
Section |  min time  |  avg time  |  max time  |%varavg| %total
---------------------------------------------------------------
Pair    | 0.044      | 0.044      | 0.044      |   0.0 | 73.33
Neigh   | 0.011001   | 0.011001   | 0.011001   |   0.0 | 18.33
Comm    | 0.0019999  | 0.0019999  | 0.0019999  |   0.0 |  3.33
Output  | 0.0019999  | 0.0019999  | 0.0019999  |   0.0 |  3.33
Modify  | 0.0010002  | 0.0010002  | 0.0010002  |   0.0 |  1.67
Other   |            | 0          |            |       |  0.00

Nlocal:        4000.00 ave        4000 max        4000 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Nghost:        5841.00 ave        5841 max        5841 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Neighs:        155984.0 ave      155984 max      155984 min
Histogram: 1 0 0 0 0 0 0 0 0 0

Total # of neighbors = 155984
Ave neighs/atom = 38.996000
Neighbor list builds = 1
Dangerous builds = 0
Inside simple function
Factorial of 10 = 3628800
Factorial of 20 = -2102132736
LOOP ARGS 10 1.0 -4.0 <capsule object NULL at 0x0000000007c25030>
Setting up Verlet run ...
  Unit style    : lj
  Current step  : 10
  Time step     : 0.005
Per MPI rank memory allocation (min/avg/max) = 6.461 | 6.461 | 6.461 Mbytes
Step Temp E_pair E_mol TotEng Press 
      10    1.1259767  0.016557378            0    1.7051002    1.2784679 
      20   0.87608998   0.39300382            0    1.7068103    6.0488236 
Loop time of 0.00900102 on 4 procs for 10 steps with 4000 atoms

Performance: 479945.787 tau/day, 1110.986 timesteps/s
111.1% CPU use with 1 MPI tasks x 4 OpenMP threads

MPI task timing breakdown:
Section |  min time  |  avg time  |  max time  |%varavg| %total
---------------------------------------------------------------
Pair    | 0.0039999  | 0.0039999  | 0.0039999  |   0.0 | 44.44
Neigh   | 0.003      | 0.003      | 0.003      |   0.0 | 33.33
Comm    | 0          | 0          | 0          |   0.0 |  0.00
Output  | 0.002001   | 0.002001   | 0.002001   |   0.0 | 22.23
Modify  | 0          | 0          | 0          |   0.0 |  0.00
Other   |            | 0          |            |       |  0.00

Nlocal:        4000.00 ave        4000 max        4000 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Nghost:        2083.00 ave        2083 max        2083 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Neighs:        17727.0 ave       17727 max       17727 min
Histogram: 1 0 0 0 0 0 0 0 0 0

Total # of neighbors = 17727
Ave neighs/atom = 4.4317500
Neighbor list builds = 1
Dangerous builds = 0
PE 0.39300382487856356 -4.0
Setting up Verlet run ...
  Unit style    : lj
  Current step  : 20
  Time step     : 0.005
Per MPI rank memory allocation (min/avg/max) = 6.461 | 6.461 | 6.461 Mbytes
Step Temp E_pair E_mol TotEng Press 
      20   0.87608998  -0.33042884            0    0.9833776    8.5817494 
      30    1.0155079  -0.83166219            0   0.69121891    7.9905553 
Loop time of 0.0140009 on 4 procs for 10 steps with 4000 atoms

Performance: 308551.755 tau/day, 714.240 timesteps/s
71.4% CPU use with 1 MPI tasks x 4 OpenMP threads

MPI task timing breakdown:
Section |  min time  |  avg time  |  max time  |%varavg| %total
---------------------------------------------------------------
Pair    | 0.003      | 0.003      | 0.003      |   0.0 | 21.43
Neigh   | 0.0039999  | 0.0039999  | 0.0039999  |   0.0 | 28.57
Comm    | 0          | 0          | 0          |   0.0 |  0.00
Output  | 0.003      | 0.003      | 0.003      |   0.0 | 21.43
Modify  | 0.0019999  | 0.0019999  | 0.0019999  |   0.0 | 14.28
Other   |            | 0.002001   |            |       | 14.29

Nlocal:        4000.00 ave        4000 max        4000 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Nghost:        2087.00 ave        2087 max        2087 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Neighs:        21036.0 ave       21036 max       21036 min
Histogram: 1 0 0 0 0 0 0 0 0 0

Total # of neighbors = 21036
Ave neighs/atom = 5.2590000
Neighbor list builds = 1
Dangerous builds = 0
PE -0.8316621917281097 -4.0
Setting up Verlet run ...
  Unit style    : lj
  Current step  : 30
  Time step     : 0.005
Per MPI rank memory allocation (min/avg/max) = 6.461 | 6.461 | 6.461 Mbytes
Step Temp E_pair E_mol TotEng Press 
      30    1.0155079   -2.0616558            0  -0.53877467    7.6238572 
      40    1.0490928   -2.1868324            0  -0.61358669    7.2084131 
Loop time of 0.0150001 on 4 procs for 10 steps with 4000 atoms

Performance: 287997.986 tau/day, 666.662 timesteps/s
66.7% CPU use with 1 MPI tasks x 4 OpenMP threads

MPI task timing breakdown:
Section |  min time  |  avg time  |  max time  |%varavg| %total
---------------------------------------------------------------
Pair    | 0.006      | 0.006      | 0.006      |   0.0 | 40.00
Neigh   | 0.0040002  | 0.0040002  | 0.0040002  |   0.0 | 26.67
Comm    | 0.00099993 | 0.00099993 | 0.00099993 |   0.0 |  6.67
Output  | 0.003      | 0.003      | 0.003      |   0.0 | 20.00
Modify  | 0          | 0          | 0          |   0.0 |  0.00
Other   |            | 0.0009999  |            |       |  6.67

Nlocal:        4000.00 ave        4000 max        4000 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Nghost:        2250.00 ave        2250 max        2250 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Neighs:        24095.0 ave       24095 max       24095 min
Histogram: 1 0 0 0 0 0 0 0 0 0

Total # of neighbors = 24095
Ave neighs/atom = 6.0237500
Neighbor list builds = 1
Dangerous builds = 0
PE -2.186832445057782 -4.0
Setting up Verlet run ...
  Unit style    : lj
  Current step  : 40
  Time step     : 0.005
Per MPI rank memory allocation (min/avg/max) = 6.461 | 6.461 | 6.461 Mbytes
Step Temp E_pair E_mol TotEng Press 
      40    1.0490928   -3.0667608            0    -1.493515    6.2796311 
      50    1.0764484   -3.1173704            0   -1.5031014    6.0850409 
Loop time of 0.0190001 on 4 procs for 10 steps with 4000 atoms

Performance: 227367.782 tau/day, 526.314 timesteps/s
52.6% CPU use with 1 MPI tasks x 4 OpenMP threads

MPI task timing breakdown:
Section |  min time  |  avg time  |  max time  |%varavg| %total
---------------------------------------------------------------
Pair    | 0.01       | 0.01       | 0.01       |   0.0 | 52.63
Neigh   | 0.0050001  | 0.0050001  | 0.0050001  |   0.0 | 26.32
Comm    | 0.00099993 | 0.00099993 | 0.00099993 |   0.0 |  5.26
Output  | 0.0020001  | 0.0020001  | 0.0020001  |   0.0 | 10.53
Modify  | 0.00099993 | 0.00099993 | 0.00099993 |   0.0 |  5.26
Other   |            | 0          |            |       |  0.00

Nlocal:        4000.00 ave        4000 max        4000 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Nghost:        2572.00 ave        2572 max        2572 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Neighs:        27137.0 ave       27137 max       27137 min
Histogram: 1 0 0 0 0 0 0 0 0 0

Total # of neighbors = 27137
Ave neighs/atom = 6.7842500
Neighbor list builds = 1
Dangerous builds = 0
PE -3.1173703652218787 -4.0
Setting up Verlet run ...
  Unit style    : lj
  Current step  : 50
  Time step     : 0.005
Per MPI rank memory allocation (min/avg/max) = 6.461 | 6.461 | 6.461 Mbytes
Step Temp E_pair E_mol TotEng Press 
      50    1.0764484   -3.6112241            0   -1.9969552    5.4223348 
      60    1.1101013   -3.6616014            0   -1.9968657    5.2348251 
Loop time of 0.022001 on 4 procs for 10 steps with 4000 atoms

Performance: 196354.461 tau/day, 454.524 timesteps/s
90.9% CPU use with 1 MPI tasks x 4 OpenMP threads

MPI task timing breakdown:
Section |  min time  |  avg time  |  max time  |%varavg| %total
---------------------------------------------------------------
Pair    | 0.014001   | 0.014001   | 0.014001   |   0.0 | 63.64
Neigh   | 0.0049999  | 0.0049999  | 0.0049999  |   0.0 | 22.73
Comm    | 0          | 0          | 0          |   0.0 |  0.00
Output  | 0.0020001  | 0.0020001  | 0.0020001  |   0.0 |  9.09
Modify  | 0.00099993 | 0.00099993 | 0.00099993 |   0.0 |  4.54
Other   |            | 0          |            |       |  0.00

Nlocal:        4000.00 ave        4000 max        4000 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Nghost:        3013.00 ave        3013 max        3013 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Neighs:        30887.0 ave       30887 max       30887 min
Histogram: 1 0 0 0 0 0 0 0 0 0

Total # of neighbors = 30887
Ave neighs/atom = 7.7217500
Neighbor list builds = 1
Dangerous builds = 0
PE -3.6616013599521033 -4.0
Setting up Verlet run ...
  Unit style    : lj
  Current step  : 60
  Time step     : 0.005
Per MPI rank memory allocation (min/avg/max) = 6.461 | 6.461 | 6.461 Mbytes
Step Temp E_pair E_mol TotEng Press 
      60    1.1101013   -3.9655053            0   -2.3007696    4.7849008 
      70    1.1122144   -3.9657095            0    -2.297805    4.8014106 
Loop time of 0.02 on 4 procs for 10 steps with 4000 atoms

Performance: 216000.206 tau/day, 500.000 timesteps/s
100.0% CPU use with 1 MPI tasks x 4 OpenMP threads

MPI task timing breakdown:
Section |  min time  |  avg time  |  max time  |%varavg| %total
---------------------------------------------------------------
Pair    | 0.011      | 0.011      | 0.011      |   0.0 | 55.00
Neigh   | 0.006      | 0.006      | 0.006      |   0.0 | 30.00
Comm    | 0.00099993 | 0.00099993 | 0.00099993 |   0.0 |  5.00
Output  | 0.0019999  | 0.0019999  | 0.0019999  |   0.0 | 10.00
Modify  | 0          | 0          | 0          |   0.0 |  0.00
Other   |            | 0          |            |       |  0.00

Nlocal:        4000.00 ave        4000 max        4000 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Nghost:        3388.00 ave        3388 max        3388 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Neighs:        35959.0 ave       35959 max       35959 min
Histogram: 1 0 0 0 0 0 0 0 0 0

Total # of neighbors = 35959
Ave neighs/atom = 8.9897500
Neighbor list builds = 1
Dangerous builds = 0
PE -3.9657094549806113 -4.0
Setting up Verlet run ...
  Unit style    : lj
  Current step  : 70
  Time step     : 0.005
Per MPI rank memory allocation (min/avg/max) = 6.461 | 6.461 | 6.461 Mbytes
Step Temp E_pair E_mol TotEng Press 
      70    1.1122144   -4.1752688            0   -2.5073643    4.4755409 
      80     1.117224   -4.1831357            0   -2.5077187     4.446079 
Loop time of 0.0310011 on 4 procs for 10 steps with 4000 atoms

Performance: 139349.934 tau/day, 322.569 timesteps/s
96.8% CPU use with 1 MPI tasks x 4 OpenMP threads

MPI task timing breakdown:
Section |  min time  |  avg time  |  max time  |%varavg| %total
---------------------------------------------------------------
Pair    | 0.019001   | 0.019001   | 0.019001   |   0.0 | 61.29
Neigh   | 0.007      | 0.007      | 0.007      |   0.0 | 22.58
Comm    | 0.0020001  | 0.0020001  | 0.0020001  |   0.0 |  6.45
Output  | 0.0020001  | 0.0020001  | 0.0020001  |   0.0 |  6.45
Modify  | 0          | 0          | 0          |   0.0 |  0.00
Other   |            | 0.0009999  |            |       |  3.23

Nlocal:        4000.00 ave        4000 max        4000 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Nghost:        3612.00 ave        3612 max        3612 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Neighs:        43239.0 ave       43239 max       43239 min
Histogram: 1 0 0 0 0 0 0 0 0 0

Total # of neighbors = 43239
Ave neighs/atom = 10.809750
Neighbor list builds = 1
Dangerous builds = 0
PE -4.183135662582033 -4.0
LAMMPS Shell>  exit
Total wall time: 0:01:08

Thank you so much Axel,
it works
Best regards
Glenn