From 0b51e9b2ffb8bc4e9b1d697645ce3b74eec451cb Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer <akohlmey@gmail.com> Date: Thu, 7 Dec 2017 16:36:36 -0500 Subject: [PATCH] add documentation for fix move/python --- doc/src/Section_commands.txt | 1 + doc/src/fix_python_move.txt | 102 +++++++++++++++++++++++++++++++++++ doc/src/fixes.txt | 1 + doc/src/lammps.book | 1 + src/.gitignore | 4 +- 5 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 doc/src/fix_python_move.txt diff --git a/doc/src/Section_commands.txt b/doc/src/Section_commands.txt index 62d3bf3d71..d2b837581a 100644 --- a/doc/src/Section_commands.txt +++ b/doc/src/Section_commands.txt @@ -585,6 +585,7 @@ USER-INTEL, k = KOKKOS, o = USER-OMP, t = OPT. "lineforce"_fix_lineforce.html, "momentum (k)"_fix_momentum.html, "move"_fix_move.html, +"move/python"_fix_move_python.html, "mscg"_fix_mscg.html, "msst"_fix_msst.html, "neb"_fix_neb.html, diff --git a/doc/src/fix_python_move.txt b/doc/src/fix_python_move.txt new file mode 100644 index 0000000000..156fde9f49 --- /dev/null +++ b/doc/src/fix_python_move.txt @@ -0,0 +1,102 @@ +"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 move/python command :h3 + +[Syntax:] + +fix move/python pymodule.CLASS :pre + +pymodule.CLASS = use class [CLASS] in module/file [pymodule] to compute how to move atoms + +[Examples:] + +fix 1 all move/python py_nve.NVE +fix 1 all move/python py_nve.NVE_OPT :pre + +[Description:] + +The {move/python} 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"_fix_python.html + +[Default:] none + diff --git a/doc/src/fixes.txt b/doc/src/fixes.txt index ad3e95fa41..4649d6ec12 100644 --- a/doc/src/fixes.txt +++ b/doc/src/fixes.txt @@ -71,6 +71,7 @@ Fixes :h1 fix_meso_stationary fix_momentum fix_move + fix_move_python fix_mscg fix_msst fix_mvv_dpd diff --git a/doc/src/lammps.book b/doc/src/lammps.book index 0691f43e9b..b62ec3e5be 100644 --- a/doc/src/lammps.book +++ b/doc/src/lammps.book @@ -200,6 +200,7 @@ fix_meso.html fix_meso_stationary.html fix_momentum.html fix_move.html +fix_move_python.html fix_mscg.html fix_msst.html fix_mvv_dpd.html diff --git a/src/.gitignore b/src/.gitignore index 3abd3a549b..dd7082243a 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -908,10 +908,10 @@ /python_impl.cpp /python_impl.h /python_compat.h +/fix_move_python.cpp +/fix_move_python.h /fix_python.cpp /fix_python.h -/fix_python_move.cpp -/fix_python_move.h /pair_python.cpp /pair_python.h /reader_molfile.cpp -- GitLab