git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8321 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp 2012-06-19 14:01:40 +00:00
parent 3b8898e7e9
commit 023ccd9d7c
8 changed files with 44 additions and 6 deletions

View File

@ -99,6 +99,7 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS * lmp, int narg, char **arg):
startstep = 0; startstep = 0;
prefactor = 1.0; prefactor = 1.0;
fp = NULL; fp = NULL;
overwrite = 0;
char *title1 = NULL; char *title1 = NULL;
char *title2 = NULL; char *title2 = NULL;
char *title3 = NULL; char *title3 = NULL;
@ -139,6 +140,9 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS * lmp, int narg, char **arg):
} }
} }
iarg += 2; iarg += 2;
} else if (strcmp(arg[iarg],"rewrite") == 0) {
overwrite = 1;
iarg += 1;
} else if (strcmp(arg[iarg],"title1") == 0) { } else if (strcmp(arg[iarg],"title1") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/correlate command"); if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/correlate command");
delete [] title1; delete [] title1;
@ -172,6 +176,8 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS * lmp, int narg, char **arg):
error->all(FLERR,"Illegal fix ave/correlate command"); error->all(FLERR,"Illegal fix ave/correlate command");
if (ave == ONE && nfreq < (nrepeat-1)*nevery) if (ave == ONE && nfreq < (nrepeat-1)*nevery)
error->all(FLERR,"Illegal fix ave/correlate command"); error->all(FLERR,"Illegal fix ave/correlate command");
if (ave != RUNNING && overwrite)
error->all(FLERR,"Illegal fix ave/correlate command");
for (int i = 0; i < nvalues; i++) { for (int i = 0; i < nvalues; i++) {
if (which[i] == COMPUTE) { if (which[i] == COMPUTE) {
@ -255,6 +261,7 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS * lmp, int narg, char **arg):
fprintf(fp," %s*%s",arg[6+i],arg[6+j]); fprintf(fp," %s*%s",arg[6+i],arg[6+j]);
fprintf(fp,"\n"); fprintf(fp,"\n");
} }
filepos = ftell(fp);
} }
delete [] title1; delete [] title1;
@ -461,9 +468,10 @@ void FixAveCorrelate::end_of_step()
save_corr[i][j] = 0.0; save_corr[i][j] = 0.0;
} }
// output to file // output result to file
if (fp && me == 0) { if (fp && me == 0) {
if (overwrite) fseek(fp,filepos,SEEK_SET);
fprintf(fp,BIGINT_FORMAT " %d\n",ntimestep,nrepeat); fprintf(fp,BIGINT_FORMAT " %d\n",ntimestep,nrepeat);
for (i = 0; i < nrepeat; i++) { for (i = 0; i < nrepeat; i++) {
fprintf(fp,"%d %d %d",i+1,i*nevery,count[i]); fprintf(fp,"%d %d %d",i+1,i*nevery,count[i]);

View File

@ -44,9 +44,10 @@ class FixAveCorrelate : public Fix {
char **ids; char **ids;
FILE *fp; FILE *fp;
int type,ave,startstep; int type,ave,startstep,overwrite;
double prefactor; double prefactor;
char *title1,*title2,*title3; char *title1,*title2,*title3;
long filepos;
int firstindex; // index in values ring of earliest time sample int firstindex; // index in values ring of earliest time sample
int lastindex; // index in values ring of latest time sample int lastindex; // index in values ring of latest time sample

View File

@ -241,6 +241,8 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
error->all(FLERR,"Illegal fix ave/histo command"); error->all(FLERR,"Illegal fix ave/histo command");
if (lo >= hi) error->all(FLERR,"Illegal fix ave/histo command"); if (lo >= hi) error->all(FLERR,"Illegal fix ave/histo command");
if (nbins <= 0) error->all(FLERR,"Illegal fix ave/histo command"); if (nbins <= 0) error->all(FLERR,"Illegal fix ave/histo command");
if (ave != RUNNING && overwrite)
error->all(FLERR,"Illegal fix ave/histo command");
int kindflag; int kindflag;
for (int i = 0; i < nvalues; i++) { for (int i = 0; i < nvalues; i++) {
@ -419,6 +421,7 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
"Total-counts Missing-counts Min-value Max-value\n"); "Total-counts Missing-counts Min-value Max-value\n");
if (title3) fprintf(fp,"%s\n",title3); if (title3) fprintf(fp,"%s\n",title3);
else fprintf(fp,"# Bin Coord Count Count/Total\n"); else fprintf(fp,"# Bin Coord Count Count/Total\n");
filepos = ftell(fp);
} }
delete [] title1; delete [] title1;
@ -780,6 +783,7 @@ void FixAveHisto::end_of_step()
// output result to file // output result to file
if (fp && me == 0) { if (fp && me == 0) {
if (overwrite) fseek(fp,filepos,SEEK_SET);
fprintf(fp,BIGINT_FORMAT " %d %g %g %g %g\n",ntimestep,nbins, fprintf(fp,BIGINT_FORMAT " %d %g %g %g %g\n",ntimestep,nbins,
stats_total[0],stats_total[1],stats_total[2],stats_total[3]); stats_total[0],stats_total[1],stats_total[2],stats_total[3]);
if (stats_total[0] != 0.0) if (stats_total[0] != 0.0)
@ -886,6 +890,7 @@ void FixAveHisto::options(int narg, char **arg)
startstep = 0; startstep = 0;
mode = SCALAR; mode = SCALAR;
beyond = IGNORE; beyond = IGNORE;
overwrite = 0;
title1 = NULL; title1 = NULL;
title2 = NULL; title2 = NULL;
title3 = NULL; title3 = NULL;
@ -935,6 +940,9 @@ void FixAveHisto::options(int narg, char **arg)
else if (strcmp(arg[iarg+1],"extra") == 0) beyond = EXTRA; else if (strcmp(arg[iarg+1],"extra") == 0) beyond = EXTRA;
else error->all(FLERR,"Illegal fix ave/histo command"); else error->all(FLERR,"Illegal fix ave/histo command");
iarg += 2; iarg += 2;
} else if (strcmp(arg[iarg],"rewrite") == 0) {
overwrite = 1;
iarg += 1;
} else if (strcmp(arg[iarg],"title1") == 0) { } else if (strcmp(arg[iarg],"title1") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/spatial command"); if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/spatial command");
delete [] title1; delete [] title1;

View File

@ -45,7 +45,8 @@ class FixAveHisto : public Fix {
char **ids; char **ids;
FILE *fp; FILE *fp;
double lo,hi,binsize,bininv; double lo,hi,binsize,bininv;
int kind,beyond; int kind,beyond,overwrite;
long filepos;
double stats[4],stats_total[4],stats_all[4]; double stats[4],stats_total[4],stats_all[4];
double **stats_list; double **stats_list;

View File

@ -165,6 +165,7 @@ FixAveSpatial::FixAveSpatial(LAMMPS *lmp, int narg, char **arg) :
fp = NULL; fp = NULL;
ave = ONE; ave = ONE;
nwindow = 0; nwindow = 0;
overwrite = 0;
char *title1 = NULL; char *title1 = NULL;
char *title2 = NULL; char *title2 = NULL;
char *title3 = NULL; char *title3 = NULL;
@ -217,6 +218,9 @@ FixAveSpatial::FixAveSpatial(LAMMPS *lmp, int narg, char **arg) :
} }
iarg += 2; iarg += 2;
if (ave == WINDOW) iarg++; if (ave == WINDOW) iarg++;
} else if (strcmp(arg[iarg],"rewrite") == 0) {
overwrite = 1;
iarg += 1;
} else if (strcmp(arg[iarg],"title1") == 0) { } else if (strcmp(arg[iarg],"title1") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/spatial command"); if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/spatial command");
delete [] title1; delete [] title1;
@ -252,6 +256,8 @@ FixAveSpatial::FixAveSpatial(LAMMPS *lmp, int narg, char **arg) :
error->all(FLERR,"Illegal fix ave/spatial command"); error->all(FLERR,"Illegal fix ave/spatial command");
if (ndim == 3 && delta[2] <= 0.0) if (ndim == 3 && delta[2] <= 0.0)
error->all(FLERR,"Illegal fix ave/spatial command"); error->all(FLERR,"Illegal fix ave/spatial command");
if (ave != RUNNING && overwrite)
error->all(FLERR,"Illegal fix ave/spatial command");
for (int i = 0; i < nvalues; i++) { for (int i = 0; i < nvalues; i++) {
if (which[i] == COMPUTE) { if (which[i] == COMPUTE) {
@ -313,6 +319,7 @@ FixAveSpatial::FixAveSpatial(LAMMPS *lmp, int narg, char **arg) :
for (int i = 0; i < nvalues; i++) fprintf(fp," %s",arg[6+3*ndim+i]); for (int i = 0; i < nvalues; i++) fprintf(fp," %s",arg[6+3*ndim+i]);
fprintf(fp,"\n"); fprintf(fp,"\n");
} }
filepos = ftell(fp);
} }
delete [] title1; delete [] title1;
@ -790,6 +797,7 @@ void FixAveSpatial::end_of_step()
// output result to file // output result to file
if (fp && me == 0) { if (fp && me == 0) {
if (overwrite) fseek(fp,filepos,SEEK_SET);
fprintf(fp,BIGINT_FORMAT " %d\n",ntimestep,nbins); fprintf(fp,BIGINT_FORMAT " %d\n",ntimestep,nbins);
if (ndim == 1) if (ndim == 1)
for (m = 0; m < nbins; m++) { for (m = 0; m < nbins; m++) {

View File

@ -41,7 +41,7 @@ class FixAveSpatial : public Fix {
int me,nvalues; int me,nvalues;
int nrepeat,nfreq,irepeat; int nrepeat,nfreq,irepeat;
bigint nvalid; bigint nvalid;
int ndim,normflag,regionflag,iregion; int ndim,normflag,regionflag,iregion,overwrite;
char *tstring,*sstring,*idregion; char *tstring,*sstring,*idregion;
int *which,*argindex,*value2index; int *which,*argindex,*value2index;
char **ids; char **ids;
@ -53,6 +53,7 @@ class FixAveSpatial : public Fix {
double xscale,yscale,zscale; double xscale,yscale,zscale;
double bin_volume; double bin_volume;
long filepos;
int dim[3],originflag[3],nlayers[3]; int dim[3],originflag[3],nlayers[3];
double origin[3],delta[3]; double origin[3],delta[3];
double offset[3],invdelta[3]; double offset[3],invdelta[3];

View File

@ -169,6 +169,8 @@ FixAveTime::FixAveTime(LAMMPS *lmp, int narg, char **arg) :
error->all(FLERR,"Illegal fix ave/time command"); error->all(FLERR,"Illegal fix ave/time command");
if (nfreq % nevery || (nrepeat-1)*nevery >= nfreq) if (nfreq % nevery || (nrepeat-1)*nevery >= nfreq)
error->all(FLERR,"Illegal fix ave/time command"); error->all(FLERR,"Illegal fix ave/time command");
if (ave != RUNNING && overwrite)
error->all(FLERR,"Illegal fix ave/time command");
for (int i = 0; i < nvalues; i++) { for (int i = 0; i < nvalues; i++) {
if (which[i] == COMPUTE && mode == SCALAR) { if (which[i] == COMPUTE && mode == SCALAR) {
@ -220,7 +222,8 @@ FixAveTime::FixAveTime(LAMMPS *lmp, int narg, char **arg) :
if (argindex[i] && argindex[i] > modify->fix[ifix]->size_array_cols) if (argindex[i] && argindex[i] > modify->fix[ifix]->size_array_cols)
error->all(FLERR,"Fix ave/time fix array is accessed out-of-range"); error->all(FLERR,"Fix ave/time fix array is accessed out-of-range");
if (nevery % modify->fix[ifix]->global_freq) if (nevery % modify->fix[ifix]->global_freq)
error->all(FLERR,"Fix for fix ave/time not computed at compatible time"); error->all(FLERR,
"Fix for fix ave/time not computed at compatible time");
} else if (which[i] == VARIABLE) { } else if (which[i] == VARIABLE) {
int ivariable = input->variable->find(ids[i]); int ivariable = input->variable->find(ids[i]);
@ -281,6 +284,7 @@ FixAveTime::FixAveTime(LAMMPS *lmp, int narg, char **arg) :
} }
fprintf(fp,"\n"); fprintf(fp,"\n");
} }
filepos = ftell(fp);
} }
delete [] title1; delete [] title1;
@ -626,6 +630,7 @@ void FixAveTime::invoke_scalar(bigint ntimestep)
// output result to file // output result to file
if (fp && me == 0) { if (fp && me == 0) {
if (overwrite) fseek(fp,filepos,SEEK_SET);
fprintf(fp,BIGINT_FORMAT,ntimestep); fprintf(fp,BIGINT_FORMAT,ntimestep);
for (i = 0; i < nvalues; i++) fprintf(fp," %g",vector_total[i]/norm); for (i = 0; i < nvalues; i++) fprintf(fp," %g",vector_total[i]/norm);
fprintf(fp,"\n"); fprintf(fp,"\n");
@ -764,6 +769,7 @@ void FixAveTime::invoke_vector(bigint ntimestep)
// output result to file // output result to file
if (fp && me == 0) { if (fp && me == 0) {
if (overwrite) fseek(fp,filepos,SEEK_SET);
fprintf(fp,BIGINT_FORMAT " %d\n",ntimestep,nrows); fprintf(fp,BIGINT_FORMAT " %d\n",ntimestep,nrows);
for (i = 0; i < nrows; i++) { for (i = 0; i < nrows; i++) {
fprintf(fp,"%d",i+1); fprintf(fp,"%d",i+1);
@ -821,6 +827,7 @@ void FixAveTime::options(int narg, char **arg)
mode = SCALAR; mode = SCALAR;
noff = 0; noff = 0;
offlist = NULL; offlist = NULL;
overwrite = 0;
title1 = NULL; title1 = NULL;
title2 = NULL; title2 = NULL;
title3 = NULL; title3 = NULL;
@ -868,6 +875,9 @@ void FixAveTime::options(int narg, char **arg)
memory->grow(offlist,noff+1,"ave/time:offlist"); memory->grow(offlist,noff+1,"ave/time:offlist");
offlist[noff++] = atoi(arg[iarg+1]); offlist[noff++] = atoi(arg[iarg+1]);
iarg += 2; iarg += 2;
} else if (strcmp(arg[iarg],"rewrite") == 0) {
overwrite = 1;
iarg += 1;
} else if (strcmp(arg[iarg],"title1") == 0) { } else if (strcmp(arg[iarg],"title1") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/spatial command"); if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/spatial command");
delete [] title1; delete [] title1;

View File

@ -48,9 +48,10 @@ class FixAveTime : public Fix {
int nrows; int nrows;
int ave,nwindow,nsum,startstep,mode; int ave,nwindow,nsum,startstep,mode;
int noff; int noff,overwrite;
int *offlist; int *offlist;
char *title1,*title2,*title3; char *title1,*title2,*title3;
long filepos;
int norm,iwindow,window_limit; int norm,iwindow,window_limit;
double *vector; double *vector;