Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91659740
in.simple-002.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Nov 13, 04:56
Size
801 B
Mime Type
text/x-python
Expires
Fri, Nov 15, 04:56 (2 d)
Engine
blob
Format
Raw Data
Handle
22302607
Attached To
rLAMMPS lammps
in.simple-002.py
View Options
#!/usr/bin/env python -i
# preceeding line should have path for Python on your machine
# simple.py
# Purpose: mimic operation of couple/simple/simple.cpp via Python
# Syntax: simple.py in.lammps
# in.lammps = LAMMPS input script
from
__future__
import
print_function
import
sys
infile
=
'in.simple'
me
=
0
from
lammps
import
lammps
lmp
=
lammps
(
cmdargs
=
sys
.
argv
[
1
:])
# run infile one line at a time
lines
=
open
(
infile
,
'r'
)
.
readlines
()
for
line
in
lines
:
lmp
.
command
(
line
)
lmp
.
command
(
"run 10"
)
x
=
lmp
.
gather_atoms
(
"x"
,
1
,
3
)
epsilon
=
0.1
x
[
0
]
+=
epsilon
lmp
.
scatter_atoms
(
"x"
,
1
,
3
,
x
)
lmp
.
command
(
"run 1"
);
f
=
lmp
.
extract_atom
(
"f"
,
3
)
print
(
"Force on 1 atom via extract_atom: "
,
f
[
0
][
0
])
fx
=
lmp
.
extract_variable
(
"fx"
,
"all"
,
1
)
print
(
"Force on 1 atom via extract_variable:"
,
fx
[
0
])
Event Timeline
Log In to Comment