From a554d22cd19dc3c68e81dface492bb7cf0c48141 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Fri, 8 Feb 2008 20:00:47 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@1472 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/fix_langevin.cpp | 11 +++++++++-- src/fix_langevin.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/fix_langevin.cpp b/src/fix_langevin.cpp index 9a31cb89fd..61307e6d74 100644 --- a/src/fix_langevin.cpp +++ b/src/fix_langevin.cpp @@ -58,6 +58,7 @@ FixLangevin::FixLangevin(LAMMPS *lmp, int narg, char **arg) : flagx = flagy = flagz = 1; for (int i = 1; i <= atom->ntypes; i++) ratio[i] = 1.0; iregion = -1; + scalefactor = 1.0; int iarg = 7; while (iarg < narg) { @@ -76,9 +77,15 @@ FixLangevin::FixLangevin(LAMMPS *lmp, int narg, char **arg) : ratio[itype] = scale; iarg += 3; } else if (strcmp(arg[iarg],"region") == 0) { + if (iarg+2 > narg) error->all("Illegal fix langevin command"); iregion = domain->find_region(arg[iarg+1]); if (iregion == -1) error->all("Fix langevin region ID does not exist"); iarg += 2; + } else if (strcmp(arg[iarg],"weight") == 0) { + if (iarg+2 > narg) error->all("Illegal fix langevin command"); + scalefactor = atof(arg[iarg+1]); + if (scalefactor <= 0.0) error->all("Illegal fix langevin command"); + iarg += 2; } else error->all("Illegal fix langevin command"); } } @@ -114,7 +121,7 @@ void FixLangevin::init() for (int i = 1; i <= atom->ntypes; i++) { gfactor1[i] = - atom->mass[i] / t_period / force->ftm2v; - gfactor2[i] = sqrt(atom->mass[i]) * + gfactor2[i] = scalefactor * sqrt(atom->mass[i]) * sqrt(24.0*force->boltz/t_period/update->dt/force->mvv2e) / force->ftm2v; gfactor1[i] *= 1.0/ratio[i]; gfactor2[i] *= 1.0/sqrt(ratio[i]); @@ -203,7 +210,7 @@ void FixLangevin::reset_target(double t_new) void FixLangevin::reset_dt() { for (int i = 1; i <= atom->ntypes; i++) { - gfactor2[i] = sqrt(atom->mass[i]) * + gfactor2[i] = scalefactor * sqrt(atom->mass[i]) * sqrt(24.0*force->boltz/t_period/update->dt/force->mvv2e) / force->ftm2v; gfactor2[i] *= 1.0/sqrt(ratio[i]); } diff --git a/src/fix_langevin.h b/src/fix_langevin.h index 1deeb84926..2cd90ef2db 100644 --- a/src/fix_langevin.h +++ b/src/fix_langevin.h @@ -34,6 +34,7 @@ class FixLangevin : public Fix { double t_start,t_stop,t_period; int flagx,flagy,flagz,iregion; double *gfactor1,*gfactor2,*ratio; + double scalefactor; int nlevels_respa; class RanMars *random;