Merge pull request #1232 from akohlmey/collected-small-fixes

First chunk of collected small fixes for the stable release
This commit is contained in:
Axel Kohlmeyer 2018-11-29 18:19:12 -05:00 committed by GitHub
commit e4ca5b1889
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 62 additions and 592 deletions

View File

@ -279,12 +279,6 @@ multibody joint). The bodies you have defined exceed this limit. :dd
This is an internal LAMMPS error. Please report it to the
developers. :dd
{Atom sorting has bin size = 0.0} :dt
The neighbor cutoff is being used as the bin size, but it is zero.
Thus you must explicitly list a bin size in the atom_modify sort
command or turn off sorting. :dd
{Atom style hybrid cannot have hybrid as an argument} :dt
Self-explanatory. :dd

View File

@ -166,7 +166,8 @@ info), a map is used. The default map style is array if no atom ID is
larger than 1 million, otherwise the default is hash. By default, a
"first" group is not defined. By default, sorting is enabled with a
frequency of 1000 and a binsize of 0.0, which means the neighbor
cutoff will be used to set the bin size.
cutoff will be used to set the bin size. If no neighbor cutoff is
defined, sorting will be turned off.
:line

View File

@ -904,6 +904,7 @@ gcc
gcmc
gdot
GeC
gencode
georg
Georg
Germann

View File

@ -31,6 +31,7 @@ struct POEMSChain{
{
delete childChains(i);
}
listOfNodes.DeleteValues();
}
//void printTreeStructure(int tabs);
//void getTreeAsList(List<int> * temp);

View File

@ -40,7 +40,9 @@ struct POEMSNode {
class SystemProcessor{
private:
Tree nodes;
// List<POEMSNode> forDeletion;
static void POEMSNodeDelete_cb(void *node) {
delete (POEMSNode *) node;
}
List<POEMSChain> headsOfSystems;
List<List<int> > ringsInSystem;
POEMSNode * findSingleLink(TreeNode * aNode);
@ -65,6 +67,8 @@ public:
};
SystemProcessor::SystemProcessor(void){
// register callback for deleting auxiliary data from tree nodes.
nodes.SetDeleteAuxData(&POEMSNodeDelete_cb);
}
void SystemProcessor::processArray(int** links, int numLinks)

View File

@ -40,6 +40,9 @@ protected:
// used by the copy constructor and assignment operator
TreeNode *CopyTree(TreeNode *t);
// callback function to delete aux data
void (*DeleteAuxData)(void *);
// used by insert and delete method to re-establish
// the avl conditions after a node is added or deleted
// from a subtree
@ -72,7 +75,13 @@ public:
// standard list handling methods
void * Find(int& item);
void * GetAuxData(int item) { return (void *)(FindNode(item, root)->GetAuxData());}
void * GetAuxData(int item) {
return (void *)(FindNode(item, root)->GetAuxData());
}
void SetDeleteAuxData(void (*callback)(void *)) {
DeleteAuxData = callback;
}
void Insert(const int& item, const int& data, void * AuxData = NULL);
void Delete(const int& item);
void AVLInsert(TreeNode* &tree, TreeNode* newNode, int &reviseBalanceFactor);
@ -90,6 +99,7 @@ Tree::Tree(void)
root = 0;
current = 0;
size = 0;
DeleteAuxData = NULL;
}
@ -569,12 +579,17 @@ TreeNode *Tree::CopyTree(TreeNode *t)
// the tree and delete each node as the vist operation
void Tree::DeleteTree(TreeNode *t)
{
if (t != NULL)
{
if (t != NULL) {
DeleteTree(t->Left());
DeleteTree(t->Right());
if (t->GetAuxData() != NULL)
delete (TreeNode *) t->GetAuxData();
void *aux = t->GetAuxData();
if (aux != NULL) {
if (DeleteAuxData != NULL) {
(*DeleteAuxData)(aux);
} else {
delete (TreeNode *) aux;
}
}
FreeTreeNode(t);
}
}

View File

@ -406,6 +406,8 @@ FixGCMC::~FixGCMC()
memory->destroy(local_gas_list);
memory->destroy(molcoords);
memory->destroy(molq);
memory->destroy(molimage);
delete [] idrigid;
delete [] idshake;

View File

@ -346,7 +346,7 @@ void DumpH5MD::openfile()
/* ---------------------------------------------------------------------- */
void DumpH5MD::write_header(bigint nbig)
void DumpH5MD::write_header(bigint /* nbig */)
{
return;
}

View File

@ -1,460 +0,0 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include <cmath>
#include <cstring>
#include <cstdlib>
#include "fix_nphug_omp.h"
#include "modify.h"
#include "error.h"
#include "update.h"
#include "compute.h"
#include "force.h"
#include "domain.h"
#include "group.h"
#include "memory.h"
#include "comm.h"
using namespace LAMMPS_NS;
using namespace FixConst;
enum{ISO,ANISO,TRICLINIC}; // same as fix_nh.cpp
/* ---------------------------------------------------------------------- */
FixNPHugOMP::FixNPHugOMP(LAMMPS *lmp, int narg, char **arg) :
FixNHOMP(lmp, narg, arg), pe(NULL), id_pe(NULL)
{
// Prevent masses from being updated every timestep
eta_mass_flag = 0;
omega_mass_flag = 0;
etap_mass_flag = 0;
// extend vector of base-class computes
size_vector += 3;
// turn off deviatoric flag and remove strain energy from vector
deviatoric_flag = 0;
size_vector -= 1;
// use initial state as reference state
v0_set = p0_set = e0_set = 0;
// check pressure settings
if (p_start[0] != p_stop[0] ||
p_start[1] != p_stop[1] ||
p_start[2] != p_stop[2])
error->all(FLERR,"Pstart and Pstop must have the same value");
// uniaxial = 0 means hydrostatic compression
// uniaxial = 1 means uniaxial compression
// in x, y, or z (idir = 0, 1, or 2)
// isotropic hydrostatic compression
if (pstyle == ISO) {
uniaxial = 0;
// anisotropic compression
} else if (pstyle == ANISO) {
// anisotropic hydrostatic compression
if (p_start[0] == p_start[1] &&
p_start[0] == p_start[2] )
uniaxial = 0;
// uniaxial compression
else if (p_flag[0] == 1 && p_flag[1] == 0
&& p_flag[2] == 0) {
uniaxial = 1;
idir = 0;
} else if (p_flag[0] == 0 && p_flag[1] == 1
&& p_flag[2] == 0) {
uniaxial = 1;
idir = 1;
} else if (p_flag[0] == 0 && p_flag[1] == 0
&& p_flag[2] == 1) {
uniaxial = 1;
idir = 2;
} else error->all(FLERR,"Specified target stress must be uniaxial or hydrostatic");
// triclinic hydrostatic compression
} else if (pstyle == TRICLINIC) {
if (p_start[0] == p_start[1] &&
p_start[0] == p_start[2] &&
p_start[3] == 0.0 &&
p_start[4] == 0.0 &&
p_start[5] == 0.0 )
uniaxial = 0;
else error->all(FLERR,"For triclinic deformation, specified target stress must be hydrostatic");
}
if (!tstat_flag)
error->all(FLERR,"Temperature control must be used with fix nphug/omp");
if (!pstat_flag)
error->all(FLERR,"Pressure control must be used with fix nphug/omp");
// create a new compute temp style
// id = fix-ID + temp
// compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all
int n = strlen(id) + 6;
id_temp = new char[n];
strcpy(id_temp,id);
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = (char *) "all";
newarg[2] = (char *) "temp";
modify->add_compute(3,newarg);
delete [] newarg;
tcomputeflag = 1;
// create a new compute pressure style
// id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor
n = strlen(id) + 7;
id_press = new char[n];
strcpy(id_press,id);
strcat(id_press,"_press");
newarg = new char*[4];
newarg[0] = id_press;
newarg[1] = (char *) "all";
newarg[2] = (char *) "pressure";
newarg[3] = id_temp;
modify->add_compute(4,newarg);
delete [] newarg;
pcomputeflag = 1;
// create a new compute potential energy compute
n = strlen(id) + 4;
id_pe = new char[n];
strcpy(id_pe,id);
strcat(id_pe,"_pe");
newarg = new char*[3];
newarg[0] = id_pe;
newarg[1] = (char*)"all";
newarg[2] = (char*)"pe";
modify->add_compute(3,newarg);
delete [] newarg;
peflag = 1;
}
/* ---------------------------------------------------------------------- */
FixNPHugOMP::~FixNPHugOMP()
{
// temp and press computes handled by base class
// delete pe compute
if (peflag) modify->delete_compute(id_pe);
delete [] id_pe;
}
/* ---------------------------------------------------------------------- */
void FixNPHugOMP::init()
{
// Call base class init()
FixNHOMP::init();
// set pe ptr
int icompute = modify->find_compute(id_pe);
if (icompute < 0)
error->all(FLERR,"Potential energy ID for fix nvt/nph/npt does not exist");
pe = modify->compute[icompute];
}
/* ----------------------------------------------------------------------
compute initial state before integrator starts
------------------------------------------------------------------------- */
void FixNPHugOMP::setup(int vflag)
{
FixNHOMP::setup(vflag);
if ( v0_set == 0 ) {
v0 = compute_vol();
v0_set = 1;
}
if ( p0_set == 0 ) {
p0_set = 1;
if (uniaxial == 1)
p0 = p_current[idir];
else
p0 = (p_current[0]+p_current[1]+p_current[2])/3.0;
}
if ( e0_set == 0 ) {
e0 = compute_etotal();
e0_set = 1;
}
double masstot = group->mass(igroup);
rho0 = nktv2p*force->mvv2e*masstot/v0;
t_target = 0.01;
pe->addstep(update->ntimestep+1);
}
/* ----------------------------------------------------------------------
compute target temperature and kinetic energy
-----------------------------------------------------------------------*/
void FixNPHugOMP::compute_temp_target()
{
t_target = t_current + compute_hugoniot();
ke_target = tdof * boltz * t_target;
pe->addstep(update->ntimestep+1);
}
/* ---------------------------------------------------------------------- */
double FixNPHugOMP::compute_etotal()
{
double epot,ekin,etot;
epot = pe->compute_scalar();
if (thermo_energy) epot -= compute_scalar();
ekin = temperature->compute_scalar();
ekin *= 0.5 * tdof * force->boltz;
etot = epot+ekin;
return etot;
}
/* ---------------------------------------------------------------------- */
double FixNPHugOMP::compute_vol()
{
if (domain->dimension == 3)
return domain->xprd * domain->yprd * domain->zprd;
else
return domain->xprd * domain->yprd;
}
/* ----------------------------------------------------------------------
Computes the deviation of the current point
from the Hugoniot in temperature units.
------------------------------------------------------------------------- */
double FixNPHugOMP::compute_hugoniot()
{
double v,e,p;
double dhugo;
e = compute_etotal();
temperature->compute_vector();
if (uniaxial == 1) {
pressure->compute_vector();
p = pressure->vector[idir];
} else
p = pressure->compute_scalar();
v = compute_vol();
dhugo = (0.5 * (p + p0 ) * ( v0 - v)) /
force->nktv2p + e0 - e;
dhugo /= tdof * boltz;
return dhugo;
}
/* ----------------------------------------------------------------------
Compute shock velocity is distance/time units
------------------------------------------------------------------------- */
double FixNPHugOMP::compute_us()
{
double v,p;
double eps,us;
temperature->compute_vector();
if (uniaxial == 1) {
pressure->compute_vector();
p = pressure->vector[idir];
} else
p = pressure->compute_scalar();
v = compute_vol();
// Us^2 = (p-p0)/(rho0*eps)
eps = 1.0 - v/v0;
if (eps < 1.0e-10) us = 0.0;
else if (p < p0) us = 0.0;
else us = sqrt((p-p0)/(rho0*eps));
return us;
}
/* ----------------------------------------------------------------------
Compute particle velocity is distance/time units
------------------------------------------------------------------------- */
double FixNPHugOMP::compute_up()
{
double v;
double eps,us,up;
v = compute_vol();
us = compute_us();
// u = eps*Us
eps = 1.0 - v/v0;
up = us*eps;
return up;
}
// look for index in local class
// if index not found, look in base class
double FixNPHugOMP::compute_vector(int n)
{
int ilen;
// n = 0: Hugoniot energy difference (temperature units)
ilen = 1;
if (n < ilen) return compute_hugoniot();
n -= ilen;
// n = 1: Shock velocity
ilen = 1;
if (n < ilen) return compute_us();
n -= ilen;
// n = 2: Particle velocity
ilen = 1;
if (n < ilen) return compute_up();
n -= ilen;
// index not found, look in base class
return FixNHOMP::compute_vector(n);
}
/* ----------------------------------------------------------------------
pack restart data
------------------------------------------------------------------------- */
int FixNPHugOMP::pack_restart_data(double *list)
{
int n = 0;
list[n++] = e0;
list[n++] = v0;
list[n++] = p0;
// call the base class function
n += FixNHOMP::pack_restart_data(list+n);
return n;
}
/* ----------------------------------------------------------------------
calculate the number of data to be packed
------------------------------------------------------------------------- */
int FixNPHugOMP::size_restart_global()
{
int nsize = 3;
// call the base class function
nsize += FixNHOMP::size_restart_global();
return nsize;
}
/* ----------------------------------------------------------------------
use state info from restart file to restart the Fix
------------------------------------------------------------------------- */
void FixNPHugOMP::restart(char *buf)
{
int n = 0;
double *list = (double *) buf;
e0 = list[n++];
v0 = list[n++];
p0 = list[n++];
e0_set = 1;
v0_set = 1;
p0_set = 1;
// call the base class function
buf += n*sizeof(double);
FixNHOMP::restart(buf);
}
/* ---------------------------------------------------------------------- */
int FixNPHugOMP::modify_param(int narg, char **arg)
{
if (strcmp(arg[0],"e0") == 0) {
if (narg < 2) error->all(FLERR,"Illegal fix nphug/omp command");
e0 = force->numeric(FLERR,arg[1]);
e0_set = 1;
return 2;
} else if (strcmp(arg[0],"v0") == 0) {
if (narg < 2) error->all(FLERR,"Illegal fix nphug/omp command");
v0 = force->numeric(FLERR,arg[1]);
v0_set = 1;
return 2;
} else if (strcmp(arg[0],"p0") == 0) {
if (narg < 2) error->all(FLERR,"Illegal fix nphug/omp command");
p0 = force->numeric(FLERR,arg[1]);
p0_set = 1;
return 2;
}
return 0;
}

View File

@ -1,98 +0,0 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifdef FIX_CLASS
FixStyle(nphug/omp,FixNPHugOMP)
#else
#ifndef LMP_FIX_NPHUG_OMP_H
#define LMP_FIX_NPHUG_OMP_H
#include "fix_nh_omp.h"
namespace LAMMPS_NS {
class FixNPHugOMP : public FixNHOMP {
public:
FixNPHugOMP(class LAMMPS *, int, char **);
virtual ~FixNPHugOMP();
virtual void init();
virtual void setup(int);
virtual int modify_param(int, char **);
virtual int pack_restart_data(double *); // pack restart data
virtual void restart(char *);
private:
class Compute *pe; // PE compute pointer
void compute_temp_target();
double compute_vector(int);
double compute_etotal();
double compute_vol();
double compute_hugoniot();
double compute_us();
double compute_up();
char *id_pe;
int peflag;
int v0_set,p0_set,e0_set;
double v0,p0,e0,rho0;
int idir;
int uniaxial;
int size_restart_global();
};
}
#endif
#endif
/* ERROR/WARNING messages:
E: Pstart and Pstop must have the same value
Self-explanatory.
E: Specified target stress must be uniaxial or hydrostatic
Self-explanatory.
E: For triclinic deformation, specified target stress must be hydrostatic
Triclinic pressure control is allowed using the tri keyword, but
non-hydrostatic pressure control can not be used in this case.
E: Temperature control must be used with fix nphug
The temp keyword must be provided.
E: Pressure control must be used with fix nphug
A pressure control keyword (iso, aniso, tri, x, y, or z) must be
provided.
E: Potential energy ID for fix nvt/nph/npt does not exist
A compute for potential energy must be defined.
E: Illegal ... command
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.
*/

View File

@ -1884,11 +1884,19 @@ void Atom::setup_sort_bins()
// user setting if explicitly set
// default = 1/2 of neighbor cutoff
// check if neighbor cutoff = 0.0
// and in that case, disable sorting
double binsize;
if (userbinsize > 0.0) binsize = userbinsize;
else binsize = 0.5 * neighbor->cutneighmax;
if (binsize == 0.0) error->all(FLERR,"Atom sorting has bin size = 0.0");
else if (neighbor->cutneighmax > 0.0) binsize = 0.5 * neighbor->cutneighmax;
if ((binsize == 0.0) && (sortfreq > 0)) {
sortfreq = 0;
if (comm->me == 0)
error->warning(FLERR,"No pairwise cutoff or binsize set. "
"Atom sorting therefore disabled.");
return;
}
double bininv = 1.0/binsize;

View File

@ -496,12 +496,6 @@ E: Atom sort did not operate correctly
This is an internal LAMMPS error. Please report it to the
developers.
E: Atom sorting has bin size = 0.0
The neighbor cutoff is being used as the bin size, but it is zero.
Thus you must explicitly list a bin size in the atom_modify sort
command or turn off sorting.
E: Too many atom sorting bins
This is likely due to an immense simulation box that has blown up

View File

@ -174,9 +174,9 @@ void Universe::add_world(char *str)
// str may not be empty and may only consist of digits or 'x'
int len = strlen(str);
size_t len = strlen(str);
if (len < 1) valid = false;
for (int i=0; i < len; ++i)
for (size_t i=0; i < len; ++i)
if (isdigit(str[i]) || str[i] == 'x') continue;
else valid = false;

View File

@ -956,7 +956,7 @@ double Variable::compute_equal(char *str)
void Variable::compute_atom(int ivar, int igroup,
double *result, int stride, int sumflag)
{
Tree *tree;
Tree *tree = NULL;
double *vstore;
if (eval_in_progress[ivar])
@ -971,6 +971,7 @@ void Variable::compute_atom(int ivar, int igroup,
} else vstore = reader[ivar]->fixstore->vstore;
if (result == NULL) {
if (style[ivar] == ATOM) free_tree(tree);
eval_in_progress[ivar] = 0;
return;
}
@ -1028,7 +1029,7 @@ void Variable::compute_atom(int ivar, int igroup,
int Variable::compute_vector(int ivar, double **result)
{
Tree *tree;
Tree *tree = NULL;
if (vecs[ivar].currentstep == update->ntimestep) {
*result = vecs[ivar].values;
return vecs[ivar].n;
@ -1215,7 +1216,7 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
// evaluate contents and push on stack
if (tree) {
Tree *newtree;
Tree *newtree = NULL;
evaluate(contents,&newtree,ivar);
treestack[ntreestack++] = newtree;
} else argstack[nargstack++] = evaluate(contents,NULL,ivar);
@ -1915,7 +1916,7 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
print_var_error(FLERR,"Atom-style variable in "
"vector-style variable formula",ivar);
Tree *newtree;
Tree *newtree = NULL;
evaluate(data[ivar][0],&newtree,ivar);
treestack[ntreestack++] = newtree;
@ -3325,7 +3326,7 @@ int Variable::math_function(char *word, char *contents, Tree **tree,
char *args[MAXFUNCARG];
int narg = parse_args(contents,args);
Tree *newtree;
Tree *newtree = NULL;
double value1,value2;
double values[MAXFUNCARG-2];
@ -3333,7 +3334,7 @@ int Variable::math_function(char *word, char *contents, Tree **tree,
newtree = new Tree();
newtree->first = newtree->second = NULL;
newtree->nextra = 0;
Tree *argtree;
Tree *argtree = NULL;
evaluate(args[0],&argtree,ivar);
newtree->first = argtree;
if (narg > 1) {

View File

@ -92,6 +92,13 @@ class Variable : protected Pointers {
int nextra; // # of additional args beyond first 2
Tree *first,*second; // ptrs further down tree for first 2 args
Tree **extra; // ptrs further down tree for nextra args
Tree() :
array(NULL), iarray(NULL), barray(NULL),
selfalloc(0), nextra(0),
first(NULL), second(NULL), extra(NULL)
{
}
};
int compute_python(int);