From 87a6c1368f6f1e5771fe6a0b7bccfd99d8203a26 Mon Sep 17 00:00:00 2001 From: sjplimp <sjplimp@f3b2605a-c512-4ea7-a41b-209d697bcdaa> Date: Fri, 22 Jul 2016 22:56:08 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@15356 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/Makefile | 4 +++- src/library.cpp | 29 +++++++++++++++++++++++++++++ src/library.h | 2 ++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 7cf9d1730f..4467095a6c 100755 --- a/src/Makefile +++ b/src/Makefile @@ -1,6 +1,8 @@ # LAMMPS multiple-machine -*- Makefile -*- SHELL = /bin/bash +PYTHON = python + #.IGNORE: # Definitions @@ -198,7 +200,7 @@ mpi-stubs: # install LAMMPS shared lib and Python wrapper for Python usage install-python: - @python ../python/install.py + @$(PYTHON) ../python/install.py # Create a tarball of src dir and packages diff --git a/src/library.cpp b/src/library.cpp index e51813413d..29e00d211d 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -28,6 +28,8 @@ #include "input.h" #include "variable.h" #include "modify.h" +#include "output.h" +#include "thermo.h" #include "compute.h" #include "fix.h" #include "comm.h" @@ -149,9 +151,19 @@ void *lammps_extract_global(void *ptr, char *name) if (strcmp(name,"xz") == 0) return (void *) &lmp->domain->xz; if (strcmp(name,"yz") == 0) return (void *) &lmp->domain->yz; if (strcmp(name,"natoms") == 0) return (void *) &lmp->atom->natoms; + if (strcmp(name,"nbonds") == 0) return (void *) &lmp->atom->nbonds; + if (strcmp(name,"nangles") == 0) return (void *) &lmp->atom->nangles; + if (strcmp(name,"ndihedrals") == 0) return (void *) &lmp->atom->ndihedrals; + if (strcmp(name,"nimpropers") == 0) return (void *) &lmp->atom->nimpropers; if (strcmp(name,"nlocal") == 0) return (void *) &lmp->atom->nlocal; if (strcmp(name,"ntimestep") == 0) return (void *) &lmp->update->ntimestep; + // NOTE: we cannot give access to the thermo "time" data by reference, + // as that is a recomputed property. only "atime" can be provided as pointer. + // please use lammps_get_thermo() defined below to access all supported + // thermo keywords by value + if (strcmp(name,"atime") == 0) return (void *) &lmp->update->atime; + return NULL; } @@ -383,6 +395,23 @@ int lammps_set_variable(void *ptr, char *name, char *str) return err; } +/* ---------------------------------------------------------------------- + return the current value of a thermo keyword as double. + unlike lammps_extract_global() this does not give access to the + storage of the data in question, and thus needs to be called + again to retrieve an updated value. The upshot is that it allows + accessing information that is only computed on-the-fly. +------------------------------------------------------------------------- */ + +double lammps_get_thermo(void *ptr, char *name) +{ + LAMMPS *lmp = (LAMMPS *) ptr; + double dval; + + lmp->output->thermo->evaluate_keyword(name,&dval); + return dval; +} + /* ---------------------------------------------------------------------- return the total number of atoms in the system useful before call to lammps_get_atoms() so can pre-allocate vector diff --git a/src/library.h b/src/library.h index 3bdeddbac4..8b7dc43f08 100644 --- a/src/library.h +++ b/src/library.h @@ -39,7 +39,9 @@ void *lammps_extract_fix(void *, char *, int, int, int, int); void *lammps_extract_variable(void *, char *, char *); int lammps_set_variable(void *, char *, char *); +double lammps_get_thermo(void *, char *); int lammps_get_natoms(void *); + void lammps_gather_atoms(void *, char *, int, int, void *); void lammps_scatter_atoms(void *, char *, int, int, void *); -- GitLab