Unverified Commit 8888b05b authored by Steve Plimpton's avatar Steve Plimpton Committed by GitHub
Browse files

Merge pull request #742 from rbberger/fix_python_move

Fix python/move
parents 3bb8294f 09ca7b32
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -620,7 +620,8 @@ USER-INTEL, k = KOKKOS, o = USER-OMP, t = OPT.
"press/berendsen"_fix_press_berendsen.html,
"print"_fix_print.html,
"property/atom"_fix_property_atom.html,
"python"_fix_python.html,
"python/invoke"_fix_python_invoke.html,
"python/move"_fix_python_move.html,
"qeq/comb (o)"_fix_qeq_comb.html,
"qeq/dynamic"_fix_qeq.html,
"qeq/fire"_fix_qeq.html,
+2 −2
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ code directly from an input script:

"python"_python.html
"variable python"_variable.html
"fix python"_fix_python.html
"fix python/invoke"_fix_python_invoke.html
"pair_style python"_pair_python.html :ul

The "python"_python.html command which can be used to define and
@@ -165,7 +165,7 @@ doc page for its python-style variables for more info, including
examples of Python code you can write for both pure Python operations
and callbacks to LAMMPS.

The "fix python"_fix_python.html command can execute
The "fix python/invoke"_fix_python_invoke.html command can execute
Python code at selected timesteps during a simulation run.

The "pair_style python"_pair_python command allows you to define
+5 −5
Original line number Diff line number Diff line
@@ -6,14 +6,14 @@

:line

fix python command :h3
fix python/invoke command :h3

[Syntax:]

fix ID group-ID python N callback function_name :pre
fix ID group-ID python/invoke N callback function_name :pre

ID, group-ID are ignored by this fix :ulb,l
python = style name of this fix command :l
python/invoke = style name of this fix command :l
N = execute every N steps :l
callback = {post_force} or {end_of_step} :l
  {post_force} = callback after force computations on atoms every N time steps
@@ -36,8 +36,8 @@ def end_of_step_callback(lammps_ptr):
    # access LAMMPS state using Python interface
""" :pre

fix pf  all python 50 post_force post_force_callback
fix eos all python 50 end_of_step end_of_step_callback :pre
fix pf  all python/invoke 50 post_force post_force_callback
fix eos all python/invoke 50 end_of_step end_of_step_callback :pre

[Description:]

+102 −0
Original line number Diff line number Diff line
"LAMMPS WWW Site"_lws - "LAMMPS Documentation"_ld - "LAMMPS Commands"_lc :c

:link(lws,http://lammps.sandia.gov)
:link(ld,Manual.html)
:link(lc,Section_commands.html#comm)

:line

fix python/move command :h3

[Syntax:]

fix python/move pymodule.CLASS :pre

pymodule.CLASS = use class [CLASS] in module/file [pymodule] to compute how to move atoms

[Examples:]

fix  1 all python/move py_nve.NVE
fix  1 all python/move py_nve.NVE_OPT :pre

[Description:]

The {python/move} fix style provides a way to define ways how particles
are moved during an MD run from python script code, that is loaded from
a file into LAMMPS and executed at the various steps where other fixes
can be executed. This python script must contain specific python class
definitions.

This allows to implement complex position updates and also modified
time integration methods. Due to python being an interpreted language,
however, the performance of this fix can be moderately to significantly
slower than the corresponding C++ code. For specific cases, this
performance penalty can be limited through effective use of NumPy.

:line

The python module file has to start with the following code:

from __future__ import print_function
import lammps
import ctypes
import traceback
import numpy as np
#
class LAMMPSFix(object):
    def __init__(self, ptr, group_name="all"):
        self.lmp = lammps.lammps(ptr=ptr)
        self.group_name = group_name
#
class LAMMPSFixMove(LAMMPSFix):
    def __init__(self, ptr, group_name="all"):
        super(LAMMPSFixMove, self).__init__(ptr, group_name)
#
    def init(self):
        pass
#
    def initial_integrate(self, vflag):
        pass
#
    def final_integrate(self):
        pass
#
    def initial_integrate_respa(self, vflag, ilevel, iloop):
        pass
#
    def final_integrate_respa(self, ilevel, iloop):
        pass
#
    def reset_dt(self):
        pass :pre

Any classes implementing new atom motion functionality have to be
derived from the [LAMMPSFixMove] class, overriding the available
methods as needed.

Examples for how to do this are in the {examples/python} folder.

:line

[Restart, fix_modify, output, run start/stop, minimize info:]

No information about this fix is written to "binary restart
files"_restart.html.  None of the "fix_modify"_fix_modify.html options
are relevant to this fix.  No global or per-atom quantities are stored
by this fix for access by various "output
commands"_Section_howto.html#howto_15.  No parameter of this fix can
be used with the {start/stop} keywords of the "run"_run.html command.
This fix is not invoked during "energy minimization"_minimize.html.

[Restrictions:]

This pair style is part of the PYTHON package.  It is only enabled if
LAMMPS was built with that package.  See the "Making
LAMMPS"_Section_start.html#start_3 section for more info.

[Related commands:]

"fix nve"_fix_nve.html, "fix python/invoke"_fix_python_invoke.html

[Default:] none
+2 −1
Original line number Diff line number Diff line
@@ -115,7 +115,8 @@ Fixes :h1
   fix_press_berendsen
   fix_print
   fix_property_atom
   fix_python
   fix_python_invoke
   fix_python_move
   fix_qbmsst
   fix_qeq
   fix_qeq_comb
Loading