File: run_python_example.sh.in

package info (click to toggle)
lammps 20220106.git7586adbb6a%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 348,064 kB
  • sloc: cpp: 831,421; python: 24,896; xml: 14,949; f90: 10,845; ansic: 7,967; sh: 4,226; perl: 4,064; fortran: 2,424; makefile: 1,501; objc: 238; lisp: 163; csh: 16; awk: 14; tcl: 6
file content (63 lines) | stat: -rwxr-xr-x 1,977 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/sh

if [ ! -f _pylammps.so ]
then \
    echo "Need to compile '_pylammps.so' first for this script to work"
    exit 1
fi

cat > example.py <<EOF
from pylammps import *

osinfo = lammps_get_os_info(512)
print(osinfo)

lmp = lammps_open_no_mpi(0,None,None)
ver = lammps_version(lmp)

npair_styles = lammps_style_count(lmp, 'pair')
print("LAMMPS includes %d pair styles" % npair_styles)
for i in range(10):
    found, style = lammps_style_name(lmp, 'pair', i, 128)
    if found == 1: print("Style %d: " % i, style)

lammps_command(lmp, "units real")
lammps_command(lmp, "lattice fcc 2.5")
lammps_command(lmp, "region box block -5 5 -5 5 -5 5")
lammps_command(lmp, "create_box 1 box")
lammps_command(lmp, "create_atoms 1 box")

boxlo_p = new_double_1d(3)
boxhi_p = new_double_1d(3)
xy_p = new_double_p()
yz_p = new_double_p()
xz_p = new_double_p()
pflags_p = new_int_1d(3)
boxflag_p = new_int_p()

lammps_extract_box(lmp, boxlo_p, boxhi_p, xy_p, yz_p, xz_p, pflags_p, boxflag_p)

print("boxlo:    %g %g %g" % (double_1d_getitem(boxlo_p, 0), double_1d_getitem(boxlo_p, 1), double_1d_getitem(boxlo_p, 2)))
print("boxhi:    %g %g %g" % (double_1d_getitem(boxhi_p, 0), double_1d_getitem(boxhi_p, 1), double_1d_getitem(boxhi_p, 2)))
print("xy/yz/xz: %g %g %g" % (double_p_value(xy_p), double_p_value(yz_p), double_p_value(xz_p)))
print("periodicity: %d %d %d" % (int_1d_getitem(pflags_p, 0), int_1d_getitem(pflags_p, 1), int_1d_getitem(pflags_p, 2)))
print("boxflag:  %d" % int_p_value(boxflag_p))
delete_double_1d(boxlo_p)
delete_double_1d(boxhi_p)
delete_int_1d(pflags_p)
delete_double_p(xy_p)
delete_double_p(yz_p)
delete_double_p(xz_p)
delete_int_p(boxflag_p)

print("LAMMPS version ",ver)
print("Number of created atoms: %g" % lammps_get_natoms(lmp))
print("Current size of timestep: %g" % double_p_value(void_p_to_double_p(lammps_extract_global(lmp,'dt'))))
lammps_close(lmp)
EOF

PYTHONPATH=${PWD}:${PYTHONPATH-${PWD}}

export PYTHONPATH

@Python3_EXECUTABLE@ example.py