doc pages for new Python function wrappers

This commit is contained in:
Steve Plimpton
2025-05-01 12:41:48 -06:00
parent 19d25a3654
commit 76d0ead245
5 changed files with 333 additions and 22 deletions

View File

@ -0,0 +1,46 @@
# 3d Lennard-Jones melt with equal- and atom-style variables which
# use a Python function wrapper in their formulas
variable x index 5
variable y index 5
variable z index 5
units lj
atom_style atomic
lattice fcc 0.8442
region box block 0 $x 0 $y 0 $z
create_box 1 box
create_atoms 1 box
mass 1 1.0
velocity all create 1.44 87287 loop geom
pair_style lj/cut 2.5
pair_coeff 1 1 1.0 1.0 2.5
neighbor 0.3 bin
neigh_modify delay 0 every 20 check no
fix 1 all nve
variable foo python truncate
python truncate return v_foo input 1 v_pyarg1 format fi here """
def truncate(x):
return int(x)
"""
variable pyarg1 internal 0.0
variable scalar equal py_foo(4.5)
print "TRUNCATE ${scalar}"
variable xtrunc atom py_foo(x)
variable ytrunc atom py_foo(y)
variable ztrunc atom py_foo(z)
# examine dump file to see truncated xyz coords of each atom
#dump 1 all custom 100 tmp.dump id x y z
dump 1 all custom 100 tmp.dump id x y z v_xtrunc v_ytrunc v_ztrunc
run 100