From 31731fd1cef1391d8c5a23ec6886a3f32962c50f Mon Sep 17 00:00:00 2001 From: sjplimp Date: Tue, 20 Jan 2015 23:17:36 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@12977 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/XTC/dump_xtc.cpp | 28 ++++++++++++++++++++++++---- src/XTC/dump_xtc.h | 2 +- src/create_bonds.cpp | 2 +- src/update.cpp | 2 +- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/XTC/dump_xtc.cpp b/src/XTC/dump_xtc.cpp index cd86e2dbac..f2709f431f 100644 --- a/src/XTC/dump_xtc.cpp +++ b/src/XTC/dump_xtc.cpp @@ -76,10 +76,18 @@ DumpXTC::DumpXTC(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg) memory->create(coords,3*natoms,"dump:coords"); // sfactor = conversion of coords to XTC units - // GROMACS standard is nanometers, not Angstroms + // tfactor = conversion of simulation time to XTC units + // GROMACS standard is nanometers and picoseconds - sfactor = 0.1; - if (strcmp(update->unit_style,"lj") == 0) sfactor = 1.0; + sfactor = 0.1 / force->angstrom; + tfactor = 0.001 / force->femtosecond; + + // in reduced units we do not scale anything + if (strcmp(update->unit_style,"lj") == 0) { + sfactor = tfactor = 1.0; + error->warning(FLERR,"No automatic unit conversion to XTC file " + "format conventions possible for 'units lj'"); + } openfile(); nevery_save = 0; @@ -160,7 +168,7 @@ void DumpXTC::write_header(bigint nbig) xdr_int(&xd,&tmp); xdr_int(&xd,&n); xdr_int(&xd,&ntimestep); - float time_value = ntimestep * update->dt; + float time_value = ntimestep * tfactor * update->dt; xdr_float(&xd,&time_value); // cell basis vectors @@ -280,6 +288,18 @@ int DumpXTC::modify_param(int narg, char **arg) (fabs(precision-1000000.0) > EPS)) error->all(FLERR,"Illegal dump_modify command"); return 2; + } else if (strcmp(arg[0],"sfactor") == 0) { + if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); + sfactor = force->numeric(FLERR,arg[1]); + if (sfactor <= 0.0) + error->all(FLERR,"Illegal dump_modify sfactor value (must be >0.0)"); + return 2; + } else if (strcmp(arg[0],"tfactor") == 0) { + if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); + tfactor = force->numeric(FLERR,arg[1]); + if (tfactor <= 0.0) + error->all(FLERR,"Illegal dump_modify tfactor value (must be >0.0)"); + return 2; } return 0; } diff --git a/src/XTC/dump_xtc.h b/src/XTC/dump_xtc.h index f1e960af6c..0c1eed5204 100644 --- a/src/XTC/dump_xtc.h +++ b/src/XTC/dump_xtc.h @@ -42,7 +42,7 @@ class DumpXTC : public Dump { int unwrap_flag; // 1 if atom coords are unwrapped, 0 if no float precision; // user-adjustable precision setting float *coords; - double sfactor; + double sfactor,tfactor; // scaling factors for positions and time unit XDR xd; void init_style(); diff --git a/src/create_bonds.cpp b/src/create_bonds.cpp index 3de639c30a..c56adbfd13 100644 --- a/src/create_bonds.cpp +++ b/src/create_bonds.cpp @@ -101,7 +101,7 @@ void CreateBonds::command(int narg, char **arg) if (force->special_lj[1] != 0.0 || force->special_coul[1] != 0.0) error->all(FLERR,"Create_bonds command requires " "special_bonds 1-2 weights be 0.0"); - if (force->kspace_style) + if (force->kspace) error->all(FLERR,"Create_bonds command requires " "no kspace_style be defined"); diff --git a/src/update.cpp b/src/update.cpp index 610cce1abd..ac5318578b 100644 --- a/src/update.cpp +++ b/src/update.cpp @@ -235,7 +235,7 @@ void Update::set_units(const char *style) force->hhmrr2e = 0.0; force->mvh2r = 0.0; force->angstrom = 1.88972612; - force->femtosecond = 0.0241888428; + force->femtosecond = 41.34137413; force->qelectron = 1.0; dt = 0.001;