Compare commits

...

14 Commits

Author SHA1 Message Date
81a2db8a0c 17Dec16 patch 2016-12-16 11:36:54 -07:00
0a176841e7 extra python_wrapper change needed for last patch 2016-12-16 11:35:42 -07:00
3027ac9250 patch 16Dec16 2016-12-16 10:30:57 -07:00
fc54ab5cea Merge pull request #301 from akohlmey/corrections-and-bugfixes
Collected corrections and bugfixes
2016-12-16 10:25:29 -07:00
e364b80724 added length keyword to python command 2016-12-16 10:24:25 -07:00
830c9e8661 Merge branch 'USER-DPD_internal_energy' of https://github.com/timattox/lammps_USER-DPD into corrections-and-bugfixes
This closes #303
2016-12-16 11:22:25 -05:00
4907b29ad2 Merge branch 'USER-DPD_bugfixes' of https://github.com/timattox/lammps_USER-DPD into corrections-and-bugfixes
This closes #302
2016-12-16 11:21:15 -05:00
eff7238ff2 USER-DPD: fix_eos*: partition all internal energy into the uMech term only
This makes our results more closely match a vetted serial implementation.
NOTE: This does make the output different from any previous versions.
Patch by Jim Larentzos.  Applied by Tim Mattox.
2016-12-16 10:25:12 -05:00
126fb22e93 USER-DPD: Fix #define typo in pair_multi_lucy.h and pair_multi_lucy_rx.h 2016-12-16 10:08:30 -05:00
0a90492c44 USER-DPD: Update the header files to properly document all error statements
Patch by Jim Larentzos.  Applied by Tim Mattox.
2016-12-15 17:39:15 -05:00
fed629c23e USER-DPD: Bugfix for fix_rx and fix_eos_table_rx to handle restart files.
Patch by Jim Larentzos.  Applied by Tim Mattox.
2016-12-15 17:10:13 -05:00
925481c3f4 USER-DPD: Fix hard-wall force interaction bug, and ensure fraction is >= 0
pair_exp6_rx.cpp patch by Jim Larentzos.  Applied by Tim Mattox.
2016-12-15 16:46:25 -05:00
da2ad5b6e0 update FixIntel code for new neighbor list code 2016-12-14 15:51:12 -05:00
bfcab72268 restore change to make -DLAMMPS_MEMALIGN=64 default when USER-INTEL package is installed (which requires it) 2016-12-14 15:24:55 -05:00
22 changed files with 157 additions and 64 deletions

View File

@ -1,7 +1,7 @@
<!-- HTML_ONLY -->
<HEAD>
<TITLE>LAMMPS Users Manual</TITLE>
<META NAME="docnumber" CONTENT="13 Dec 2016 version">
<META NAME="docnumber" CONTENT="17 Dec 2016 version">
<META NAME="author" CONTENT="http://lammps.sandia.gov - Sandia National Laboratories">
<META NAME="copyright" CONTENT="Copyright (2003) Sandia Corporation. This software and manual is distributed under the GNU General Public License.">
</HEAD>
@ -21,7 +21,7 @@
<H1></H1>
LAMMPS Documentation :c,h3
13 Dec 2016 version :c,h4
17 Dec 2016 version :c,h4
Version info: :h4

View File

@ -14,7 +14,7 @@ python func keyword args ... :pre
func = name of Python function :ulb,l
one or more keyword/args pairs must be appended :l
keyword = {invoke} or {input} or {return} or {format} or {file} or {here} or {exists}
keyword = {invoke} or {input} or {return} or {format} or {length} or {file} or {here} or {exists}
{invoke} arg = none = invoke the previously defined Python function
{input} args = N i1 i2 ... iN
N = # of inputs to function
@ -29,6 +29,8 @@ keyword = {invoke} or {input} or {return} or {format} or {file} or {here} or {ex
M = N+1 if there is a return value
fstring = each character (i,f,s,p) corresponds in order to an input or return value
'i' = integer, 'f' = floating point, 's' = string, 'p' = SELF
{length} arg = Nlen
Nlen = max length of string returned from Python function
{file} arg = filename
filename = file of Python code, which defines func
{here} arg = inline
@ -165,6 +167,17 @@ equal-style variable as an argument, but only if the output of the
Python function is flagged as a numeric value ("i" or "f") via the
{format} keyword.
If the {return} keyword is used and the {format} keyword specifies the
output as a string, then the default maximum length of that string is
63 characters (64-1 for the string terminator). If you want to return
a longer string, the {length} keyword can be specified with its {Nlen}
value set to a larger number (the code allocates space for Nlen+1 to
include the string terminator). If the Python function generates a
string longer than the default 63 or the specified {Nlen}, it will be
trunctated.
:line
Either the {file}, {here}, or {exists} keyword must be used, but only
one of them. These keywords specify what Python code to load into the
Python interpreter. The {file} keyword gives the name of a file,

View File

@ -89,6 +89,7 @@ void Python::command(int narg, char **arg)
istr = NULL;
ostr = NULL;
format = NULL;
length_longstr = 0;
char *pyfile = NULL;
char *herestr = NULL;
int existflag = 0;
@ -115,6 +116,11 @@ void Python::command(int narg, char **arg)
format = new char[n];
strcpy(format,arg[iarg+1]);
iarg += 2;
} else if (strcmp(arg[iarg],"length") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Invalid python command");
length_longstr = force->inumeric(FLERR,arg[iarg+1]);
if (length_longstr <= 0) error->all(FLERR,"Invalid python command");
iarg += 2;
} else if (strcmp(arg[iarg],"file") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Invalid python command");
delete[] pyfile;
@ -249,6 +255,7 @@ void Python::invoke_function(int ifunc, char *result)
// function returned a value
// assign it to result string stored by python-style variable
// or if user specified a length, assign it to longstr
if (pfuncs[ifunc].noutput) {
int otype = pfuncs[ifunc].otype;
@ -258,7 +265,9 @@ void Python::invoke_function(int ifunc, char *result)
sprintf(result,"%.15g",PyFloat_AsDouble(pValue));
} else if (otype == STRING) {
char *pystr = PyString_AsString(pValue);
strncpy(result,pystr,VALUELENGTH-1);
if (pfuncs[ifunc].longstr)
strncpy(pfuncs[ifunc].longstr,pystr,pfuncs[ifunc].length_longstr);
else strncpy(result,pystr,VALUELENGTH-1);
}
Py_DECREF(pValue);
}
@ -287,6 +296,13 @@ int Python::variable_match(char *name, char *varname, int numeric)
/* ------------------------------------------------------------------ */
char *Python::long_string(int ifunc)
{
return pfuncs[ifunc].longstr;
}
/* ------------------------------------------------------------------ */
int Python::create_entry(char *name)
{
// ifunc = index to entry by name in pfuncs vector, can be old or new
@ -370,6 +386,7 @@ int Python::create_entry(char *name)
// process output as value or variable
pfuncs[ifunc].ovarname = NULL;
pfuncs[ifunc].longstr = NULL;
if (!noutput) return ifunc;
char type = format[ninput];
@ -378,6 +395,14 @@ int Python::create_entry(char *name)
else if (type == 's') pfuncs[ifunc].otype = STRING;
else error->all(FLERR,"Invalid python command");
if (length_longstr) {
if (pfuncs[ifunc].otype != STRING)
error->all(FLERR,"Python command length keyword "
"cannot be used unless output is a string");
pfuncs[ifunc].length_longstr = length_longstr;
pfuncs[ifunc].longstr = new char[length_longstr+1];
}
if (strstr(ostr,"v_") != ostr) error->all(FLERR,"Invalid python command");
int n = strlen(&ostr[2]) + 1;
pfuncs[ifunc].ovarname = new char[n];
@ -398,4 +423,5 @@ void Python::deallocate(int i)
delete [] pfuncs[i].svalue[j];
delete [] pfuncs[i].svalue;
delete [] pfuncs[i].ovarname;
delete [] pfuncs[i].longstr;
}

View File

@ -28,9 +28,10 @@ class Python : protected Pointers {
void invoke_function(int, char *);
int find(char *);
int variable_match(char *, char *, int);
char *long_string(int);
private:
int ninput,noutput;
int ninput,noutput,length_longstr;
char **istr;
char *ostr,*format;
void *pyMain;
@ -44,6 +45,8 @@ class Python : protected Pointers {
char **svalue;
int otype;
char *ovarname;
char *longstr;
int length_longstr;
void *pFunc;
};

View File

@ -70,8 +70,8 @@ void FixEOScv::init()
if (mask[i] & groupbit) {
if(dpdTheta[i] <= 0.0)
error->one(FLERR,"Internal temperature <= zero");
uCond[i] = 0.5*cvEOS*dpdTheta[i];
uMech[i] = 0.5*cvEOS*dpdTheta[i];
uCond[i] = 0.0;
uMech[i] = cvEOS*dpdTheta[i];
}
}
}

View File

@ -50,6 +50,10 @@ Self-explanatory. Check the input script syntax and compare to the
documentation for the command. You can use -echo screen as a
command-line option when running LAMMPS to see the offending line.
E: FixEOScv requires atom_style with internal temperature and energies (e.g. dpd)
Self-explanatory.
E: EOS cv must be > 0.0
The constant volume heat capacity must be larger than zero.

View File

@ -122,8 +122,8 @@ void FixEOStable::init()
if(dpdTheta[i] <= 0.0)
error->one(FLERR,"Internal temperature <= zero");
energy_lookup(dpdTheta[i],tmp);
uCond[i] = tmp / 2.0;
uMech[i] = tmp / 2.0;
uCond[i] = 0.0;
uMech[i] = tmp;
}
}
}

View File

@ -92,6 +92,10 @@ E: eos/table values are not increasing
The EOS must be a monotonically, increasing function
E: FixEOStable requires atom_style with internal temperature and energies (e.g. dpd)
Self-explanatory.
E: Internal temperature < zero
Self-explanatory. EOS may not be valid under current simulation conditions.

View File

@ -162,13 +162,15 @@ void FixEOStableRX::setup(int vflag)
double *uCG = atom->uCG;
double *uCGnew = atom->uCGnew;
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit){
duChem = uCG[i] - uCGnew[i];
uChem[i] += duChem;
uCG[i] = 0.0;
uCGnew[i] = 0.0;
}
if(!this->restart_reset){
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit){
duChem = uCG[i] - uCGnew[i];
uChem[i] += duChem;
uCG[i] = 0.0;
uCGnew[i] = 0.0;
}
}
// Communicate the updated momenta and velocities to all nodes
comm->forward_comm_fix(this);
@ -200,8 +202,8 @@ void FixEOStableRX::init()
if(dpdTheta[i] <= 0.0)
error->one(FLERR,"Internal temperature <= zero");
energy_lookup(i,dpdTheta[i],tmp);
uCond[i] = tmp / 2.0;
uMech[i] = tmp / 2.0;
uCond[i] = 0.0;
uMech[i] = tmp;
uChem[i] = 0.0;
}
}

View File

@ -106,6 +106,10 @@ E: eos/table/rx values are not increasing
The equation-of-state must an increasing function
E: FixEOStableRX requires atom_style with internal temperature and energies (e.g. dpd)
Self-explanatory.
E: Internal temperature <= zero.
Self-explanatory.

View File

@ -69,7 +69,6 @@ FixRX::FixRX(LAMMPS *lmp, int narg, char **arg) :
id_fix_species_old(NULL), fix_species(NULL), fix_species_old(NULL)
{
if (narg < 7 || narg > 12) error->all(FLERR,"Illegal fix rx command");
restart_peratom = 1;
nevery = 1;
nreactions = maxparam = 0;
@ -366,6 +365,7 @@ void FixRX::post_constructor()
modify->add_fix(nspecies+5,newarg);
fix_species = (FixPropertyAtom *) modify->fix[modify->nfix-1];
restartFlag = modify->fix[modify->nfix-1]->restart_reset;
modify->add_fix(nspecies+5,newarg2);
fix_species_old = (FixPropertyAtom *) modify->fix[modify->nfix-1];
@ -647,34 +647,38 @@ void FixRX::setup_pre_force(int vflag)
double tmp;
int ii;
if(localTempFlag){
int count = nlocal + (newton_pair ? nghost : 0);
dpdThetaLocal = new double[count];
memset(dpdThetaLocal, 0, sizeof(double)*count);
computeLocalTemperature();
if(restartFlag){
restartFlag = 0;
} else {
if(localTempFlag){
int count = nlocal + (newton_pair ? nghost : 0);
dpdThetaLocal = new double[count];
memset(dpdThetaLocal, 0, sizeof(double)*count);
computeLocalTemperature();
}
for (int id = 0; id < nlocal; id++)
for (int ispecies=0; ispecies<nspecies; ispecies++){
tmp = atom->dvector[ispecies][id];
atom->dvector[ispecies+nspecies][id] = tmp;
}
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit){
// Set the reaction rate constants to zero: no reactions occur at step 0
for(int irxn=0;irxn<nreactions;irxn++)
kR[irxn] = 0.0;
if (odeIntegrationFlag == ODE_LAMMPS_RK4)
rk4(i,NULL);
else if (odeIntegrationFlag == ODE_LAMMPS_RKF45)
rkf45(i,NULL);
}
// Communicate the updated momenta and velocities to all nodes
comm->forward_comm_fix(this);
if(localTempFlag) delete [] dpdThetaLocal;
}
for (int id = 0; id < nlocal; id++)
for (int ispecies=0; ispecies<nspecies; ispecies++){
tmp = atom->dvector[ispecies][id];
atom->dvector[ispecies+nspecies][id] = tmp;
}
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit){
// Set the reaction rate constants to zero: no reactions occur at step 0
for(int irxn=0;irxn<nreactions;irxn++)
kR[irxn] = 0.0;
if (odeIntegrationFlag == ODE_LAMMPS_RK4)
rk4(i,NULL);
else if (odeIntegrationFlag == ODE_LAMMPS_RKF45)
rkf45(i,NULL);
}
// Communicate the updated momenta and velocities to all nodes
comm->forward_comm_fix(this);
if(localTempFlag) delete [] dpdThetaLocal;
}
/* ---------------------------------------------------------------------- */

View File

@ -132,6 +132,7 @@ class FixRX : public Fix {
char *kineticsFile;
char *id_fix_species,*id_fix_species_old;
class FixPropertyAtom *fix_species,*fix_species_old;
int restartFlag;
};

View File

@ -310,13 +310,13 @@ void PairExp6rx::compute(int eflag, int vflag)
uin1 = buck1*(6.0*rin1exp - alphaOld12_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut);
win1 = -buck1*buck2*(rin1*rin1exp*rminv - rm6ij*rin6inv) - rin1*durc;
win1 = buck1*buck2*(rin1*rin1exp*rminv - rm6ij*rin6inv) + rin1*durc;
aRep = -1.0*win1*powint(rin1,nRep)/nRep;
aRep = win1*powint(rin1,nRep)/nRep;
uin1rep = aRep/powint(rin1,nRep);
forceExp6 = -double(nRep)*aRep/powint(r,nRep);
forceExp6 = double(nRep)*aRep/powint(r,nRep);
fpairOldEXP6_12 = factor_lj*forceExp6*r2inv;
evdwlOldEXP6_12 = uin1 - uin1rep + aRep/powint(r,nRep);
@ -350,13 +350,13 @@ void PairExp6rx::compute(int eflag, int vflag)
uin1 = buck1*(6.0*rin1exp - alphaOld21_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut);
win1 = -buck1*buck2*(rin1*rin1exp*rminv - rm6ij*rin6inv) - rin1*durc;
win1 = buck1*buck2*(rin1*rin1exp*rminv - rm6ij*rin6inv) + rin1*durc;
aRep = -1.0*win1*powint(rin1,nRep)/nRep;
aRep = win1*powint(rin1,nRep)/nRep;
uin1rep = aRep/powint(rin1,nRep);
forceExp6 = -double(nRep)*aRep/powint(r,nRep);
forceExp6 = double(nRep)*aRep/powint(r,nRep);
fpairOldEXP6_21 = factor_lj*forceExp6*r2inv;
evdwlOldEXP6_21 = uin1 - uin1rep + aRep/powint(r,nRep);
@ -405,9 +405,9 @@ void PairExp6rx::compute(int eflag, int vflag)
uin1 = buck1*(6.0*rin1exp - alpha12_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut);
win1 = -buck1*buck2*(rin1*rin1exp*rminv - rm6ij*rin6inv) - rin1*durc;
win1 = buck1*buck2*(rin1*rin1exp*rminv - rm6ij*rin6inv) + rin1*durc;
aRep = -1.0*win1*powint(rin1,nRep)/nRep;
aRep = win1*powint(rin1,nRep)/nRep;
uin1rep = aRep/powint(rin1,nRep);
@ -437,9 +437,9 @@ void PairExp6rx::compute(int eflag, int vflag)
uin1 = buck1*(6.0*rin1exp - alpha21_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut);
win1 = -buck1*buck2*(rin1*rin1exp*rminv - rm6ij*rin6inv) - rin1*durc;
win1 = buck1*buck2*(rin1*rin1exp*rminv - rm6ij*rin6inv) + rin1*durc;
aRep = -1.0*win1*powint(rin1,nRep)/nRep;
aRep = win1*powint(rin1,nRep)/nRep;
uin1rep = aRep/powint(rin1,nRep);
@ -1102,6 +1102,32 @@ void PairExp6rx::getParamsEXP6(int id,double &epsilon1,double &alpha1,double &rm
rm2_old *= pow(nTotalOFA_old,fuchslinR);
}
}
// Check that no fractions are less than zero
if(fraction1 < 0.0){
if(fraction1 < -1.0e-10){
error->all(FLERR,"Computed fraction less than -1.0e-10");
}
fraction1 = 0.0;
}
if(fraction2 < 0.0){
if(fraction2 < -1.0e-10){
error->all(FLERR,"Computed fraction less than -1.0e-10");
}
fraction2 = 0.0;
}
if(fraction1_old < 0.0){
if(fraction1_old < -1.0e-10){
error->all(FLERR,"Computed fraction less than -1.0e-10");
}
fraction1_old = 0.0;
}
if(fraction2_old < 0.0){
if(fraction2_old < -1.0e-10){
error->all(FLERR,"Computed fraction less than -1.0e-10");
}
fraction2_old = 0.0;
}
}
/* ---------------------------------------------------------------------- */

View File

@ -18,7 +18,7 @@ PairStyle(multi/lucy,PairMultiLucy)
#else
#ifndef LMP_PAIR_MULTI_LUCY_H
#define LMP_PAIR_MUTLI_LUCY_H
#define LMP_PAIR_MULTI_LUCY_H
#include "pair.h"

View File

@ -18,7 +18,7 @@ PairStyle(multi/lucy/rx,PairMultiLucyRX)
#else
#ifndef LMP_PAIR_MULTI_LUCY_RX_H
#define LMP_PAIR_MUTLI_LUCY_RX_H
#define LMP_PAIR_MULTI_LUCY_RX_H
#include "pair.h"

View File

@ -325,8 +325,6 @@ void FixIntel::init()
error->all(FLERR,
"Currently, cannot use more than one intel style with hybrid.");
neighbor->fix_intel = (void *)this;
check_neighbor_intel();
if (_precision_mode == PREC_MODE_SINGLE)
_single_buffers->zero_ev();

View File

@ -526,7 +526,7 @@ double FixShearHistory::memory_usage()
{
int nmax = atom->nmax;
double bytes = nmax * sizeof(int);
bytes += nmax * sizeof(int *);
bytes += nmax * sizeof(tagint *);
bytes += nmax * sizeof(double *);
int nmypage = comm->nthreads;

View File

@ -26,6 +26,10 @@
#endif
#endif
#if defined(LMP_USER_INTEL) && !defined(LAMMPS_MEMALIGN)
#define LAMMPS_MEMALIGN 64
#endif
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */

View File

@ -33,7 +33,7 @@ methods:
minchunk <= N <= maxchunk required
put(index) = return indexed chunk to pool (same index returned by get)
int size() = return total size of allocated pages in bytes
public varaibles:
public variables:
ndatum = total # of stored datums
nchunk = total # of stored chunks
size = total size of all allocated pages in daums

View File

@ -38,7 +38,7 @@ class Python {
void invoke_function(int, char *) {}
int find(char *) {return -1;}
int variable_match(char *, char *, int) {return -1;}
char *long_string(int) {return NULL;}
};
}

View File

@ -875,6 +875,10 @@ char *Variable::retrieve(char *name)
error->all(FLERR,"Python variable does not match Python function");
python->invoke_function(ifunc,data[ivar][1]);
str = data[ivar][1];
// if Python func returns a string longer than VALUELENGTH
// then the Python class stores the result, query it via long_string()
char *strlong = python->long_string(ifunc);
if (strlong) str = strlong;
} else if (style[ivar] == INTERNAL) {
sprintf(data[ivar][0],"%.15g",dvalue[ivar]);
str = data[ivar][0];

View File

@ -1 +1 @@
#define LAMMPS_VERSION "13 Dec 2016"
#define LAMMPS_VERSION "17 Dec 2016"