From f8891a445160bc3decbb651146f64bda916a2ee2 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Sat, 2 Dec 2017 01:04:46 -0500 Subject: [PATCH] Rename fix python/integrate to python/move This is to avoid confusion to what LAMMPS considers to be an integrator like Verlet and RESPA. --- ...ython_integrate => README.fix_python_move} | 11 +++++----- ..._integrate_melt => in.fix_python_nve_melt} | 2 +- ...te_melt_opt => in.fix_python_nve_melt_opt} | 2 +- .../python/{py_integrate.py => py_nve.py} | 8 ++++---- src/.gitignore | 4 ++-- ...thon_integrate.cpp => fix_python_move.cpp} | 20 +++++++++---------- ...x_python_integrate.h => fix_python_move.h} | 12 +++++------ 7 files changed, 30 insertions(+), 29 deletions(-) rename examples/python/{README.fix_python_integrate => README.fix_python_move} (65%) rename examples/python/{in.fix_python_integrate_melt => in.fix_python_nve_melt} (87%) rename examples/python/{in.fix_python_integrate_melt_opt => in.fix_python_nve_melt_opt} (86%) rename examples/python/{py_integrate.py => py_nve.py} (95%) rename src/PYTHON/{fix_python_integrate.cpp => fix_python_move.cpp} (93%) rename src/PYTHON/{fix_python_integrate.h => fix_python_move.h} (87%) diff --git a/examples/python/README.fix_python_integrate b/examples/python/README.fix_python_move similarity index 65% rename from examples/python/README.fix_python_integrate rename to examples/python/README.fix_python_move index 63de0910f4..308d154119 100644 --- a/examples/python/README.fix_python_integrate +++ b/examples/python/README.fix_python_move @@ -1,15 +1,16 @@ This folder contains several LAMMPS input scripts and a python module -file py_integrate.py to demonstrate the use of the fix style python/integrate. +file py_nve.py to demonstrate the use of the fix style python/move +to reimplement NVE using Python. -in.fix_python_integrate_melt: +in.fix_python_nve_melt: This is a version of the melt example which replaces the default NVE integrator -with a Python implementation. Fix python/integrate is used to create an -instance of the py_integrate.NVE class which implements the required interface. +with a Python implementation. Fix python/move is used to create an +instance of the py_nve.NVE class which implements the required interface. It demonstrates how to access LAMMPS data as numpy arrays. This gives direct access to memory owned by the C++ code, allows easy manipulation through numpy operations and avoids unnecessary copies. -in.fix_python_integrate_melt_opt: +in.fix_python_nve_melt_opt: This version of melt example uses NVE_Opt instead of NVE. While this Python implementation is still much slower than the native version, it shows that simple code transformations can lead to speedups. diff --git a/examples/python/in.fix_python_integrate_melt b/examples/python/in.fix_python_nve_melt similarity index 87% rename from examples/python/in.fix_python_integrate_melt rename to examples/python/in.fix_python_nve_melt index d1103f866a..24828d7445 100644 --- a/examples/python/in.fix_python_integrate_melt +++ b/examples/python/in.fix_python_nve_melt @@ -17,7 +17,7 @@ pair_coeff 1 1 1.0 1.0 2.5 neighbor 0.3 bin neigh_modify every 20 delay 0 check no -fix 1 all python/integrate py_integrate.NVE +fix 1 all python/move py_nve.NVE thermo 50 run 250 diff --git a/examples/python/in.fix_python_integrate_melt_opt b/examples/python/in.fix_python_nve_melt_opt similarity index 86% rename from examples/python/in.fix_python_integrate_melt_opt rename to examples/python/in.fix_python_nve_melt_opt index fd1d11b292..9564ffa02e 100644 --- a/examples/python/in.fix_python_integrate_melt_opt +++ b/examples/python/in.fix_python_nve_melt_opt @@ -17,7 +17,7 @@ pair_coeff 1 1 1.0 1.0 2.5 neighbor 0.3 bin neigh_modify every 20 delay 0 check no -fix 1 all python/integrate py_integrate.NVE_Opt +fix 1 all python/move py_nve.NVE_Opt thermo 50 run 250 diff --git a/examples/python/py_integrate.py b/examples/python/py_nve.py similarity index 95% rename from examples/python/py_integrate.py rename to examples/python/py_nve.py index 142fe1fc13..79331528b1 100644 --- a/examples/python/py_integrate.py +++ b/examples/python/py_nve.py @@ -9,9 +9,9 @@ class LAMMPSFix(object): self.lmp = lammps.lammps(ptr=ptr) self.group_name = group_name -class LAMMPSIntegrator(LAMMPSFix): +class LAMMPSFixMove(LAMMPSFix): def __init__(self, ptr, group_name="all"): - super(LAMMPSIntegrator, self).__init__(ptr, group_name) + super(LAMMPSFixMove, self).__init__(ptr, group_name) def init(self): pass @@ -32,7 +32,7 @@ class LAMMPSIntegrator(LAMMPSFix): pass -class NVE(LAMMPSIntegrator): +class NVE(LAMMPSFixMove): """ Python implementation of fix/nve """ def __init__(self, ptr, group_name="all"): super(NVE, self).__init__(ptr) @@ -70,7 +70,7 @@ class NVE(LAMMPSIntegrator): v[i,:] += dtfm * f[i,:] -class NVE_Opt(LAMMPSIntegrator): +class NVE_Opt(LAMMPSFixMove): """ Performance-optimized Python implementation of fix/nve """ def __init__(self, ptr, group_name="all"): super(NVE_Opt, self).__init__(ptr) diff --git a/src/.gitignore b/src/.gitignore index 1fe371c687..3abd3a549b 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -910,8 +910,8 @@ /python_compat.h /fix_python.cpp /fix_python.h -/fix_python_integrate.cpp -/fix_python_integrate.h +/fix_python_move.cpp +/fix_python_move.h /pair_python.cpp /pair_python.h /reader_molfile.cpp diff --git a/src/PYTHON/fix_python_integrate.cpp b/src/PYTHON/fix_python_move.cpp similarity index 93% rename from src/PYTHON/fix_python_integrate.cpp rename to src/PYTHON/fix_python_move.cpp index 00f5a5544d..2c216d8aad 100644 --- a/src/PYTHON/fix_python_integrate.cpp +++ b/src/PYTHON/fix_python_move.cpp @@ -19,7 +19,7 @@ #include #include #include -#include "fix_python_integrate.h" +#include "fix_python_move.h" #include "atom.h" #include "comm.h" #include "force.h" @@ -34,7 +34,7 @@ using namespace FixConst; /* ---------------------------------------------------------------------- */ -FixPythonIntegrate::FixPythonIntegrate(LAMMPS *lmp, int narg, char **arg) : +FixPythonMove::FixPythonMove(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { dynamic_group_allow = 1; @@ -111,7 +111,7 @@ FixPythonIntegrate::FixPythonIntegrate(LAMMPS *lmp, int narg, char **arg) : /* ---------------------------------------------------------------------- */ -FixPythonIntegrate::~FixPythonIntegrate() +FixPythonMove::~FixPythonMove() { PyGILState_STATE gstate = PyGILState_Ensure(); if(py_integrator) Py_DECREF((PyObject*) py_integrator); @@ -120,7 +120,7 @@ FixPythonIntegrate::~FixPythonIntegrate() /* ---------------------------------------------------------------------- */ -int FixPythonIntegrate::setmask() +int FixPythonMove::setmask() { int mask = 0; mask |= INITIAL_INTEGRATE; @@ -132,7 +132,7 @@ int FixPythonIntegrate::setmask() /* ---------------------------------------------------------------------- */ -void FixPythonIntegrate::init() +void FixPythonMove::init() { PyGILState_STATE gstate = PyGILState_Ensure(); PyObject *py_integrator_obj = (PyObject *) py_integrator; @@ -149,7 +149,7 @@ void FixPythonIntegrate::init() /* ---------------------------------------------------------------------- */ -void FixPythonIntegrate::initial_integrate(int vflag) +void FixPythonMove::initial_integrate(int vflag) { PyGILState_STATE gstate = PyGILState_Ensure(); PyObject *py_integrator_obj = (PyObject *) py_integrator; @@ -168,7 +168,7 @@ void FixPythonIntegrate::initial_integrate(int vflag) /* ---------------------------------------------------------------------- */ -void FixPythonIntegrate::final_integrate() +void FixPythonMove::final_integrate() { PyGILState_STATE gstate = PyGILState_Ensure(); PyObject *py_integrator_obj = (PyObject *) py_integrator; @@ -185,7 +185,7 @@ void FixPythonIntegrate::final_integrate() /* ---------------------------------------------------------------------- */ -void FixPythonIntegrate::initial_integrate_respa(int vflag, int ilevel, int iloop) +void FixPythonMove::initial_integrate_respa(int vflag, int ilevel, int iloop) { PyGILState_STATE gstate = PyGILState_Ensure(); PyObject *py_integrator_obj = (PyObject *) py_integrator; @@ -204,7 +204,7 @@ void FixPythonIntegrate::initial_integrate_respa(int vflag, int ilevel, int iloo /* ---------------------------------------------------------------------- */ -void FixPythonIntegrate::final_integrate_respa(int ilevel, int iloop) +void FixPythonMove::final_integrate_respa(int ilevel, int iloop) { PyGILState_STATE gstate = PyGILState_Ensure(); PyObject *py_integrator_obj = (PyObject *) py_integrator; @@ -223,7 +223,7 @@ void FixPythonIntegrate::final_integrate_respa(int ilevel, int iloop) /* ---------------------------------------------------------------------- */ -void FixPythonIntegrate::reset_dt() +void FixPythonMove::reset_dt() { PyGILState_STATE gstate = PyGILState_Ensure(); PyObject *py_integrator_obj = (PyObject *) py_integrator; diff --git a/src/PYTHON/fix_python_integrate.h b/src/PYTHON/fix_python_move.h similarity index 87% rename from src/PYTHON/fix_python_integrate.h rename to src/PYTHON/fix_python_move.h index b823453d23..0d06305fb9 100644 --- a/src/PYTHON/fix_python_integrate.h +++ b/src/PYTHON/fix_python_move.h @@ -23,21 +23,21 @@ #ifdef FIX_CLASS -FixStyle(python/integrate,FixPythonIntegrate) +FixStyle(python/move,FixPythonMove) #else -#ifndef LMP_FIX_PYTHON_INTEGRATE_H -#define LMP_FIX_PYTHON_INTEGRATE_H +#ifndef LMP_FIX_PYTHON_MOVE_H +#define LMP_FIX_PYTHON_MOVE_H #include "fix.h" namespace LAMMPS_NS { -class FixPythonIntegrate : public Fix { +class FixPythonMove : public Fix { public: - FixPythonIntegrate(LAMMPS *lmp, int narg, char **arg); - virtual ~FixPythonIntegrate(); + FixPythonMove(LAMMPS *lmp, int narg, char **arg); + virtual ~FixPythonMove(); int setmask(); virtual void init();