diff --git a/src/COMPRESS/dump_atom_gz.cpp b/src/COMPRESS/dump_atom_gz.cpp index 78f2c6d4f7..9be8d17b06 100644 --- a/src/COMPRESS/dump_atom_gz.cpp +++ b/src/COMPRESS/dump_atom_gz.cpp @@ -112,6 +112,8 @@ void DumpAtomGZ::write_header(bigint ndump) ++unit_count; gzprintf(gzFp,"ITEM: UNITS\n%s\n",update->unit_style); } + if (time_flag) gzprintf(gzFp,"ITEM: TIME\n%.16g\n",compute_time()); + gzprintf(gzFp,"ITEM: TIMESTEP\n"); gzprintf(gzFp,BIGINT_FORMAT "\n",update->ntimestep); gzprintf(gzFp,"ITEM: NUMBER OF ATOMS\n"); diff --git a/src/COMPRESS/dump_custom_gz.cpp b/src/COMPRESS/dump_custom_gz.cpp index 7eb77cb697..58ce98ad06 100644 --- a/src/COMPRESS/dump_custom_gz.cpp +++ b/src/COMPRESS/dump_custom_gz.cpp @@ -112,6 +112,8 @@ void DumpCustomGZ::write_header(bigint ndump) ++unit_count; gzprintf(gzFp,"ITEM: UNITS\n%s\n",update->unit_style); } + if (time_flag) gzprintf(gzFp,"ITEM: TIME\n%.16g\n",compute_time()); + gzprintf(gzFp,"ITEM: TIMESTEP\n"); gzprintf(gzFp,BIGINT_FORMAT "\n",update->ntimestep); gzprintf(gzFp,"ITEM: NUMBER OF ATOMS\n"); diff --git a/src/COMPRESS/dump_local_gz.cpp b/src/COMPRESS/dump_local_gz.cpp index 801547543a..c27c795f75 100644 --- a/src/COMPRESS/dump_local_gz.cpp +++ b/src/COMPRESS/dump_local_gz.cpp @@ -112,6 +112,8 @@ void DumpLocalGZ::write_header(bigint ndump) ++unit_count; gzprintf(gzFp,"ITEM: UNITS\n%s\n",update->unit_style); } + if (time_flag) gzprintf(gzFp,"ITEM: TIME\n%.16g\n",compute_time()); + gzprintf(gzFp,"ITEM: TIMESTEP\n"); gzprintf(gzFp,BIGINT_FORMAT "\n",update->ntimestep); gzprintf(gzFp,"ITEM: NUMBER OF ATOMS\n"); diff --git a/src/dump.cpp b/src/dump.cpp index e995644a36..83b74f1bbc 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -87,6 +87,7 @@ Dump::Dump(LAMMPS *lmp, int /*narg*/, char **arg) : Pointers(lmp) buffer_flag = 0; padflag = 0; pbcflag = 0; + time_flag = 0; unit_flag = 0; unit_count = 0; delay_flag = 0; @@ -1123,6 +1124,13 @@ void Dump::modify_params(int narg, char **arg) } iarg += 2; + } else if (strcmp(arg[iarg],"time") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); + if (strcmp(arg[iarg+1],"yes") == 0) time_flag = 1; + else if (strcmp(arg[iarg+1],"no") == 0) time_flag = 0; + else error->all(FLERR,"Illegal dump_modify command"); + iarg += 2; + } else if (strcmp(arg[iarg],"units") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); if (strcmp(arg[iarg+1],"yes") == 0) unit_flag = 1; @@ -1138,6 +1146,12 @@ void Dump::modify_params(int narg, char **arg) } } +/* ---------------------------------------------------------------------- */ + +double Dump::compute_time() +{ + return update->atime + (update->ntimestep - update->atimestep)*update->dt; +} /* ---------------------------------------------------------------------- return # of bytes of allocated memory ------------------------------------------------------------------------- */ diff --git a/src/dump.h b/src/dump.h index 43855c9362..17e9434faa 100644 --- a/src/dump.h +++ b/src/dump.h @@ -75,6 +75,7 @@ class Dump : protected Pointers { int sortcol; // 0 to sort on ID, 1-N on columns int sortcolm1; // sortcol - 1 int sortorder; // ASCEND or DESCEND + int time_flag; // 1 if output accumulated time int unit_flag; // 1 if dump should contain unit information int unit_count; // # of times the unit information was written int delay_flag; // 1 if delay output until delaystep @@ -145,6 +146,7 @@ class Dump : protected Pointers { virtual int convert_string(int, double *) {return 0;} virtual void write_data(int, double *) = 0; void pbc_allocate(); + double compute_time(); void sort(); #if defined(LMP_QSORT) diff --git a/src/dump_atom.cpp b/src/dump_atom.cpp index d5eba98078..401b47051d 100644 --- a/src/dump_atom.cpp +++ b/src/dump_atom.cpp @@ -15,9 +15,9 @@ #include #include "domain.h" #include "atom.h" -#include "update.h" #include "memory.h" #include "error.h" +#include "update.h" using namespace LAMMPS_NS; @@ -213,6 +213,8 @@ void DumpAtom::header_item(bigint ndump) ++unit_count; fprintf(fp,"ITEM: UNITS\n%s\n",update->unit_style); } + if (time_flag) fprintf(fp,"ITEM: TIME\n%.16g\n",compute_time()); + fprintf(fp,"ITEM: TIMESTEP\n"); fprintf(fp,BIGINT_FORMAT "\n",update->ntimestep); fprintf(fp,"ITEM: NUMBER OF ATOMS\n"); @@ -232,6 +234,8 @@ void DumpAtom::header_item_triclinic(bigint ndump) ++unit_count; fprintf(fp,"ITEM: UNITS\n%s\n",update->unit_style); } + if (time_flag) fprintf(fp,"ITEM: TIME\n%.16g\n",compute_time()); + fprintf(fp,"ITEM: TIMESTEP\n"); fprintf(fp,BIGINT_FORMAT "\n",update->ntimestep); fprintf(fp,"ITEM: NUMBER OF ATOMS\n"); diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp index a99151f890..489067d90e 100644 --- a/src/dump_custom.cpp +++ b/src/dump_custom.cpp @@ -20,14 +20,14 @@ #include "region.h" #include "group.h" #include "input.h" -#include "variable.h" -#include "update.h" #include "modify.h" #include "compute.h" #include "fix.h" #include "fix_store.h" #include "memory.h" #include "error.h" +#include "update.h" +#include "variable.h" using namespace LAMMPS_NS; @@ -424,6 +424,8 @@ void DumpCustom::header_item(bigint ndump) ++unit_count; fprintf(fp,"ITEM: UNITS\n%s\n",update->unit_style); } + if (time_flag) fprintf(fp,"ITEM: TIME\n%.16g\n",compute_time()); + fprintf(fp,"ITEM: TIMESTEP\n"); fprintf(fp,BIGINT_FORMAT "\n",update->ntimestep); fprintf(fp,"ITEM: NUMBER OF ATOMS\n"); @@ -443,6 +445,8 @@ void DumpCustom::header_item_triclinic(bigint ndump) ++unit_count; fprintf(fp,"ITEM: UNITS\n%s\n",update->unit_style); } + if (time_flag) fprintf(fp,"ITEM: TIME\n%.16g\n",compute_time()); + fprintf(fp,"ITEM: TIMESTEP\n"); fprintf(fp,BIGINT_FORMAT "\n",update->ntimestep); fprintf(fp,"ITEM: NUMBER OF ATOMS\n"); diff --git a/src/dump_local.cpp b/src/dump_local.cpp index 52a222eaeb..21a96d1e8a 100644 --- a/src/dump_local.cpp +++ b/src/dump_local.cpp @@ -260,6 +260,8 @@ void DumpLocal::write_header(bigint ndump) ++unit_count; fprintf(fp,"ITEM: UNITS\n%s\n",update->unit_style); } + if (time_flag) fprintf(fp,"ITEM: TIME\n%.16g\n",compute_time()); + fprintf(fp,"ITEM: TIMESTEP\n"); fprintf(fp,BIGINT_FORMAT "\n",update->ntimestep); fprintf(fp,"ITEM: NUMBER OF %s\n",label);