From 950bfb84a90134fd8df0a4b33a2c1b6928983a8e Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Fri, 15 Dec 2017 13:20:13 -0500 Subject: [PATCH] Clean up after renaming back to fix python/move --- examples/python/README.fix_python_move | 4 +- ...n_nve_melt => in.fix_python_move_nve_melt} | 0 ...lt_opt => in.fix_python_move_nve_melt_opt} | 0 src/.gitignore | 4 +- src/PYTHON/fix_python_move.cpp | 38 +++++++++---------- src/PYTHON/fix_python_move.h | 2 +- 6 files changed, 24 insertions(+), 24 deletions(-) rename examples/python/{in.fix_python_nve_melt => in.fix_python_move_nve_melt} (100%) rename examples/python/{in.fix_python_nve_melt_opt => in.fix_python_move_nve_melt_opt} (100%) diff --git a/examples/python/README.fix_python_move b/examples/python/README.fix_python_move index 308d154119..95730d327c 100644 --- a/examples/python/README.fix_python_move +++ b/examples/python/README.fix_python_move @@ -2,7 +2,7 @@ This folder contains several LAMMPS input scripts and a python module file py_nve.py to demonstrate the use of the fix style python/move to reimplement NVE using Python. -in.fix_python_nve_melt: +in.fix_python_move_nve_melt: This is a version of the melt example which replaces the default NVE integrator with a Python implementation. Fix python/move is used to create an instance of the py_nve.NVE class which implements the required interface. @@ -10,7 +10,7 @@ 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_nve_melt_opt: +in.fix_python_move_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_nve_melt b/examples/python/in.fix_python_move_nve_melt similarity index 100% rename from examples/python/in.fix_python_nve_melt rename to examples/python/in.fix_python_move_nve_melt diff --git a/examples/python/in.fix_python_nve_melt_opt b/examples/python/in.fix_python_move_nve_melt_opt similarity index 100% rename from examples/python/in.fix_python_nve_melt_opt rename to examples/python/in.fix_python_move_nve_melt_opt diff --git a/src/.gitignore b/src/.gitignore index dd7082243a..23ce8390ed 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -908,8 +908,8 @@ /python_impl.cpp /python_impl.h /python_compat.h -/fix_move_python.cpp -/fix_move_python.h +/fix_python_move.cpp +/fix_python_move.h /fix_python.cpp /fix_python.h /pair_python.cpp diff --git a/src/PYTHON/fix_python_move.cpp b/src/PYTHON/fix_python_move.cpp index 2c216d8aad..22d3bd065f 100644 --- a/src/PYTHON/fix_python_move.cpp +++ b/src/PYTHON/fix_python_move.cpp @@ -42,7 +42,7 @@ FixPythonMove::FixPythonMove(LAMMPS *lmp, int narg, char **arg) : python->init(); - py_integrator = NULL; + py_move = NULL; PyGILState_STATE gstate = PyGILState_Ensure(); @@ -80,8 +80,8 @@ FixPythonMove::FixPythonMove(LAMMPS *lmp, int narg, char **arg) : // create LAMMPS atom type to potential file type mapping in python class // by calling 'lammps_pair_style.map_coeff(name,type)' - PyObject *py_integrator_type = PyObject_GetAttrString(pModule, cls_name); - if (!py_integrator_type) { + PyObject *py_move_type = PyObject_GetAttrString(pModule, cls_name); + if (!py_move_type) { PyErr_Print(); PyErr_Clear(); PyGILState_Release(gstate); @@ -93,10 +93,10 @@ FixPythonMove::FixPythonMove(LAMMPS *lmp, int narg, char **arg) : PyObject * ptr = PY_VOID_POINTER(lmp); PyObject * arglist = Py_BuildValue("(O)", ptr); - PyObject * py_integrator_obj = PyObject_CallObject(py_integrator_type, arglist); + PyObject * py_move_obj = PyObject_CallObject(py_move_type, arglist); Py_DECREF(arglist); - if (!py_integrator_obj) { + if (!py_move_obj) { PyErr_Print(); PyErr_Clear(); PyGILState_Release(gstate); @@ -104,7 +104,7 @@ FixPythonMove::FixPythonMove(LAMMPS *lmp, int narg, char **arg) : } // check object interface - py_integrator = (void *) py_integrator_obj; + py_move = (void *) py_move_obj; PyGILState_Release(gstate); } @@ -114,7 +114,7 @@ FixPythonMove::FixPythonMove(LAMMPS *lmp, int narg, char **arg) : FixPythonMove::~FixPythonMove() { PyGILState_STATE gstate = PyGILState_Ensure(); - if(py_integrator) Py_DECREF((PyObject*) py_integrator); + if(py_move) Py_DECREF((PyObject*) py_move); PyGILState_Release(gstate); } @@ -135,8 +135,8 @@ int FixPythonMove::setmask() void FixPythonMove::init() { PyGILState_STATE gstate = PyGILState_Ensure(); - PyObject *py_integrator_obj = (PyObject *) py_integrator; - PyObject *py_init = PyObject_GetAttrString(py_integrator_obj,"init"); + PyObject *py_move_obj = (PyObject *) py_move; + PyObject *py_init = PyObject_GetAttrString(py_move_obj,"init"); if (!py_init) { PyErr_Print(); PyErr_Clear(); @@ -152,8 +152,8 @@ void FixPythonMove::init() void FixPythonMove::initial_integrate(int vflag) { PyGILState_STATE gstate = PyGILState_Ensure(); - PyObject *py_integrator_obj = (PyObject *) py_integrator; - PyObject *py_initial_integrate = PyObject_GetAttrString(py_integrator_obj,"initial_integrate"); + PyObject *py_move_obj = (PyObject *) py_move; + PyObject *py_initial_integrate = PyObject_GetAttrString(py_move_obj,"initial_integrate"); if (!py_initial_integrate) { PyErr_Print(); PyErr_Clear(); @@ -171,8 +171,8 @@ void FixPythonMove::initial_integrate(int vflag) void FixPythonMove::final_integrate() { PyGILState_STATE gstate = PyGILState_Ensure(); - PyObject *py_integrator_obj = (PyObject *) py_integrator; - PyObject *py_final_integrate = PyObject_GetAttrString(py_integrator_obj,"final_integrate"); + PyObject *py_move_obj = (PyObject *) py_move; + PyObject *py_final_integrate = PyObject_GetAttrString(py_move_obj,"final_integrate"); if (!py_final_integrate) { PyErr_Print(); PyErr_Clear(); @@ -188,8 +188,8 @@ void FixPythonMove::final_integrate() void FixPythonMove::initial_integrate_respa(int vflag, int ilevel, int iloop) { PyGILState_STATE gstate = PyGILState_Ensure(); - PyObject *py_integrator_obj = (PyObject *) py_integrator; - PyObject *py_initial_integrate_respa = PyObject_GetAttrString(py_integrator_obj,"initial_integrate_respa"); + PyObject *py_move_obj = (PyObject *) py_move; + PyObject *py_initial_integrate_respa = PyObject_GetAttrString(py_move_obj,"initial_integrate_respa"); if (!py_initial_integrate_respa) { PyErr_Print(); PyErr_Clear(); @@ -207,8 +207,8 @@ void FixPythonMove::initial_integrate_respa(int vflag, 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; - PyObject *py_final_integrate_respa = PyObject_GetAttrString(py_integrator_obj,"final_integrate_respa"); + PyObject *py_move_obj = (PyObject *) py_move; + PyObject *py_final_integrate_respa = PyObject_GetAttrString(py_move_obj,"final_integrate_respa"); if (!py_final_integrate_respa) { PyErr_Print(); PyErr_Clear(); @@ -226,8 +226,8 @@ void FixPythonMove::final_integrate_respa(int ilevel, int iloop) void FixPythonMove::reset_dt() { PyGILState_STATE gstate = PyGILState_Ensure(); - PyObject *py_integrator_obj = (PyObject *) py_integrator; - PyObject *py_reset_dt = PyObject_GetAttrString(py_integrator_obj,"reset_dt"); + PyObject *py_move_obj = (PyObject *) py_move; + PyObject *py_reset_dt = PyObject_GetAttrString(py_move_obj,"reset_dt"); if (!py_reset_dt) { PyErr_Print(); PyErr_Clear(); diff --git a/src/PYTHON/fix_python_move.h b/src/PYTHON/fix_python_move.h index 0d06305fb9..7f92ecc957 100644 --- a/src/PYTHON/fix_python_move.h +++ b/src/PYTHON/fix_python_move.h @@ -48,7 +48,7 @@ class FixPythonMove : public Fix { virtual void reset_dt(); protected: - void * py_integrator; + void * py_move; }; }