Merge branch 'master' into resetids

This commit is contained in:
Steve Plimpton
2018-03-30 09:15:24 -06:00
committed by GitHub
12 changed files with 137 additions and 6580 deletions

View File

@ -15,8 +15,9 @@ compute ID group-ID displace/atom :pre
ID, group-ID are documented in "compute"_compute.html command :ulb,l ID, group-ID are documented in "compute"_compute.html command :ulb,l
displace/atom = style name of this compute command :l displace/atom = style name of this compute command :l
zero or more keyword/arg pairs may be appended :l zero or more keyword/arg pairs may be appended :l
keyword = {refresh} :l keyword = {refresh} :
{replace} arg = per-atom variable ID :pre {replace} arg = name of per-atom variable :pre
:ule :ule
[Examples:] [Examples:]

View File

@ -121,7 +121,7 @@ See the "dump_modify every"_dump_modify.html command.
Only information for atoms in the specified group is dumped. The Only information for atoms in the specified group is dumped. The
"dump_modify thresh and region and refresh"_dump_modify.html commands "dump_modify thresh and region and refresh"_dump_modify.html commands
can also alter what atoms are included. Not all styles support all can also alter what atoms are included. Not all styles support
these options; see details on the "dump_modify"_dump_modify.html doc these options; see details on the "dump_modify"_dump_modify.html doc
page. page.

File diff suppressed because it is too large Load Diff

View File

@ -1,32 +0,0 @@
# Solvated 5-mer peptide
# Demonstrating temper_npt
units real
atom_style full
pair_style lj/charmm/coul/long 8.0 10.0 10.0
bond_style harmonic
angle_style charmm
dihedral_style charmm
improper_style harmonic
kspace_style pppm 0.0001
read_data data.peptide
neighbor 2.0 bin
neigh_modify delay 5
timestep 2.0
thermo_style custom step temp epair emol etotal press density
thermo 50
variable temper_T world 275 280 285 290 295 300 305 310
variable rep world 0 1 2 3 4 5 6 7
fix myfix all npt temp ${temper_T} ${temper_T} 100.0 iso 1 1 1000
run 500
temper_npt 2000 100 ${temper_T} myfix 0 58728 1
fix 2 all shake 0.0001 10 100 b 4 6 8 10 12 14 18 a 31
group peptide type <= 12

View File

@ -264,12 +264,21 @@ void FixSRP::setup_pre_force(int zz)
rmax = sqrt(rsqmax); rmax = sqrt(rsqmax);
double cutneighmax_srp = neighbor->cutneighmax + 0.51*rmax; double cutneighmax_srp = neighbor->cutneighmax + 0.51*rmax;
// find smallest cutghost double length0,length1,length2;
double cutghostmin = comm->cutghost[0]; if (domain->triclinic) {
if (cutghostmin > comm->cutghost[1]) double *h_inv = domain->h_inv;
cutghostmin = comm->cutghost[1]; length0 = sqrt(h_inv[0]*h_inv[0] + h_inv[5]*h_inv[5] + h_inv[4]*h_inv[4]);
if (cutghostmin > comm->cutghost[2]) length1 = sqrt(h_inv[1]*h_inv[1] + h_inv[3]*h_inv[3]);
cutghostmin = comm->cutghost[2]; length2 = h_inv[2];
} else length0 = length1 = length2 = 1.0;
// find smallest cutghost.
// comm->cutghost is stored in fractional coordinates for triclinic
double cutghostmin = comm->cutghost[0]/length0;
if (cutghostmin > comm->cutghost[1]/length1)
cutghostmin = comm->cutghost[1]/length1;
if (cutghostmin > comm->cutghost[2]/length2)
cutghostmin = comm->cutghost[2]/length2;
// stop if cutghost is insufficient // stop if cutghost is insufficient
if (cutneighmax_srp > cutghostmin){ if (cutneighmax_srp > cutghostmin){

View File

@ -129,6 +129,8 @@ class Compute : protected Pointers {
virtual void lock(class Fix *, bigint, bigint) {} virtual void lock(class Fix *, bigint, bigint) {}
virtual void unlock(class Fix *) {} virtual void unlock(class Fix *) {}
virtual void refresh() {}
void addstep(bigint); void addstep(bigint);
int matchstep(bigint); int matchstep(bigint);
void clearstep(); void clearstep();

View File

@ -21,6 +21,8 @@
#include "modify.h" #include "modify.h"
#include "fix.h" #include "fix.h"
#include "fix_store.h" #include "fix_store.h"
#include "input.h"
#include "variable.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
@ -32,12 +34,42 @@ ComputeDisplaceAtom::ComputeDisplaceAtom(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg), Compute(lmp, narg, arg),
displace(NULL), id_fix(NULL) displace(NULL), id_fix(NULL)
{ {
if (narg != 3) error->all(FLERR,"Illegal compute displace/atom command"); if (narg < 3) error->all(FLERR,"Illegal compute displace/atom command");
peratom_flag = 1; peratom_flag = 1;
size_peratom_cols = 4; size_peratom_cols = 4;
create_attribute = 1; create_attribute = 1;
// optional args
refreshflag = 0;
rvar = NULL;
int iarg = 3;
while (iarg < narg) {
if (strcmp(arg[iarg],"refresh") == 0) {
if (iarg+2 > narg)
error->all(FLERR,"Illegal compute displace/atom command");
refreshflag = 1;
delete [] rvar;
int n = strlen(arg[iarg+1]) + 1;
rvar = new char[n];
strcpy(rvar,arg[iarg+1]);
iarg += 2;
} else error->all(FLERR,"Illegal compute displace/atom command");
}
// error check
if (refreshflag) {
ivar = input->variable->find(rvar);
if (ivar < 0)
error->all(FLERR,"Variable name for compute displace/atom does not exist");
if (input->variable->atomstyle(ivar) == 0)
error->all(FLERR,"Compute displace/atom variable "
"is not atom-style variable");
}
// create a new fix STORE style // create a new fix STORE style
// id = compute-ID + COMPUTE_STORE, fix group = compute group // id = compute-ID + COMPUTE_STORE, fix group = compute group
@ -76,7 +108,8 @@ ComputeDisplaceAtom::ComputeDisplaceAtom(LAMMPS *lmp, int narg, char **arg) :
// per-atom displacement array // per-atom displacement array
nmax = 0; nmax = nvmax = 0;
varatom = NULL;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -89,6 +122,8 @@ ComputeDisplaceAtom::~ComputeDisplaceAtom()
delete [] id_fix; delete [] id_fix;
memory->destroy(displace); memory->destroy(displace);
delete [] rvar;
memory->destroy(varatom);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -100,6 +135,12 @@ void ComputeDisplaceAtom::init()
int ifix = modify->find_fix(id_fix); int ifix = modify->find_fix(id_fix);
if (ifix < 0) error->all(FLERR,"Could not find compute displace/atom fix ID"); if (ifix < 0) error->all(FLERR,"Could not find compute displace/atom fix ID");
fix = (FixStore *) modify->fix[ifix]; fix = (FixStore *) modify->fix[ifix];
if (refreshflag) {
ivar = input->variable->find(rvar);
if (ivar < 0)
error->all(FLERR,"Variable name for compute displace/atom does not exist");
}
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -183,6 +224,30 @@ void ComputeDisplaceAtom::set_arrays(int i)
xoriginal[i][2] = x[i][2]; xoriginal[i][2] = x[i][2];
} }
/* ----------------------------------------------------------------------
reset per-atom storage values, based on atom-style variable evaluation
called by dump when dump_modify refresh is set
------------------------------------------------------------------------- */
void ComputeDisplaceAtom::refresh()
{
if (atom->nmax > nvmax) {
nvmax = atom->nmax;
memory->destroy(varatom);
memory->create(varatom,nvmax,"displace/atom:varatom");
}
input->variable->compute_atom(ivar,igroup,varatom,1,0);
double **xoriginal = fix->astore;
double **x = atom->x;
imageint *image = atom->image;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++)
if (varatom[i]) domain->unmap(x[i],image[i],xoriginal[i]);
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
memory usage of local atom-based array memory usage of local atom-based array
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
@ -190,5 +255,6 @@ void ComputeDisplaceAtom::set_arrays(int i)
double ComputeDisplaceAtom::memory_usage() double ComputeDisplaceAtom::memory_usage()
{ {
double bytes = nmax*4 * sizeof(double); double bytes = nmax*4 * sizeof(double);
bytes += nvmax * sizeof(double);
return bytes; return bytes;
} }

View File

@ -31,6 +31,7 @@ class ComputeDisplaceAtom : public Compute {
void init(); void init();
void compute_peratom(); void compute_peratom();
void set_arrays(int); void set_arrays(int);
void refresh();
double memory_usage(); double memory_usage();
private: private:
@ -38,6 +39,10 @@ class ComputeDisplaceAtom : public Compute {
double **displace; double **displace;
char *id_fix; char *id_fix;
class FixStore *fix; class FixStore *fix;
int refreshflag,ivar,nvmax; // refresh option is enabled
char *rvar; // for incremental dumps
double *varatom;
}; };
} }

View File

@ -22,11 +22,12 @@
#include "domain.h" #include "domain.h"
#include "group.h" #include "group.h"
#include "output.h" #include "output.h"
#include "memory.h"
#include "error.h"
#include "force.h" #include "force.h"
#include "modify.h" #include "modify.h"
#include "fix.h" #include "fix.h"
#include "compute.h"
#include "memory.h"
#include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -78,6 +79,9 @@ Dump::Dump(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
format_bigint_user = NULL; format_bigint_user = NULL;
format_column_user = NULL; format_column_user = NULL;
refreshflag = 0;
refresh = NULL;
clearstep = 0; clearstep = 0;
sort_flag = 0; sort_flag = 0;
append_flag = 0; append_flag = 0;
@ -161,6 +165,8 @@ Dump::~Dump()
delete [] format_int_user; delete [] format_int_user;
delete [] format_bigint_user; delete [] format_bigint_user;
delete [] refresh;
// format_column_user is deallocated by child classes that use it // format_column_user is deallocated by child classes that use it
memory->destroy(buf); memory->destroy(buf);
@ -278,6 +284,16 @@ void Dump::init()
} }
} }
// search for refresh compute specified by dump_modify refresh
if (refreshflag) {
int icompute;
for (icompute = 0; icompute < modify->ncompute; icompute++)
if (strcmp(refresh,modify->compute[icompute]->id) == 0) break;
if (icompute < modify->ncompute) irefresh = icompute;
else error->all(FLERR,"Dump could not find refresh compute ID");
}
// preallocation for PBC copies if requested // preallocation for PBC copies if requested
if (pbcflag && atom->nlocal > maxpbc) pbc_allocate(); if (pbcflag && atom->nlocal > maxpbc) pbc_allocate();
@ -483,6 +499,11 @@ void Dump::write()
atom->image = imagehold; atom->image = imagehold;
} }
// trigger post-dump refresh by specified compute
// currently used for incremental dump files
if (refreshflag) modify->compute[irefresh]->refresh();
// if file per timestep, close file if I am filewriter // if file per timestep, close file if I am filewriter
if (multifile) { if (multifile) {

View File

@ -80,6 +80,10 @@ class Dump : protected Pointers {
int delay_flag; // 1 if delay output until delaystep int delay_flag; // 1 if delay output until delaystep
bigint delaystep; bigint delaystep;
int refreshflag; // 1 if dump_modify refresh specified
char *refresh; // compute ID to invoke refresh() on
int irefresh; // index of compute
char boundstr[9]; // encoding of boundary flags char boundstr[9]; // encoding of boundary flags
char *format; // format string for the file write char *format; // format string for the file write

View File

@ -60,7 +60,8 @@ DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) :
earg(NULL), vtype(NULL), vformat(NULL), columns(NULL), choose(NULL), earg(NULL), vtype(NULL), vformat(NULL), columns(NULL), choose(NULL),
dchoose(NULL), clist(NULL), field2index(NULL), argindex(NULL), id_compute(NULL), dchoose(NULL), clist(NULL), field2index(NULL), argindex(NULL), id_compute(NULL),
compute(NULL), id_fix(NULL), fix(NULL), id_variable(NULL), variable(NULL), compute(NULL), id_fix(NULL), fix(NULL), id_variable(NULL), variable(NULL),
vbuf(NULL), id_custom(NULL), flag_custom(NULL), typenames(NULL), pack_choice(NULL) vbuf(NULL), id_custom(NULL), flag_custom(NULL), typenames(NULL),
pack_choice(NULL)
{ {
if (narg == 5) error->all(FLERR,"No dump custom arguments specified"); if (narg == 5) error->all(FLERR,"No dump custom arguments specified");
@ -1673,6 +1674,19 @@ int DumpCustom::modify_param(int narg, char **arg)
return ntypes+1; return ntypes+1;
} }
if (strcmp(arg[0],"refresh") == 0) {
if (narg < 2) error->all(FLERR,"Illegal dump_modify command");
if (strncmp(arg[1],"c_",2) != 0)
error->all(FLERR,"Illegal dump_modify command");
if (refreshflag) error->all(FLERR,"Dump modify can only have one refresh");
refreshflag = 1;
int n = strlen(arg[1]);
refresh = new char[n];
strcpy(refresh,&arg[1][2]);
return 2;
}
if (strcmp(arg[0],"thresh") == 0) { if (strcmp(arg[0],"thresh") == 0) {
if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); if (narg < 2) error->all(FLERR,"Illegal dump_modify command");
if (strcmp(arg[1],"none") == 0) { if (strcmp(arg[1],"none") == 0) {

View File

@ -537,10 +537,8 @@ double MathSpecial::exp2_x86(double x)
double MathSpecial::fm_exp(double x) double MathSpecial::fm_exp(double x)
{ {
#if defined(__BYTE_ORDER__) #if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
return exp2_x86(FM_DOUBLE_LOG2OFE * x); return exp2_x86(FM_DOUBLE_LOG2OFE * x);
#endif
#else #else
return ::exp(x); return ::exp(x);
#endif #endif