diff -Naur lammps-26Jun09/src/temper.cpp lammps-27Jun09/src/temper.cpp --- lammps-26Jun09/src/temper.cpp 2009-03-20 09:01:17.000000000 -0600 +++ lammps-27Jun09/src/temper.cpp 2009-06-23 14:11:54.000000000 -0600 @@ -176,7 +176,7 @@ // setup tempering runs int i,which,partner,swap,partner_set_temp,partner_world; - double pe,pe_partner,boltz_factor,new_temp; + double pe,pe_partner,ke,boltz_factor,new_temp; MPI_Status status; if (me_universe == 0 && universe->uscreen) @@ -193,16 +193,15 @@ timer->barrier_start(TIME_LOOP); for (int iswap = 0; iswap < nswaps; iswap++) { - + // run for nevery timesteps update->integrate->iterate(nevery); - - // compute PE, normalize if thermo PE does + + // compute PE // notify compute it will be called at next swap pe = pe_compute->compute_scalar(); - if (output->thermo->normflag) pe /= atom->natoms; pe_compute->addstep(update->ntimestep + nevery); // which = which of 2 kinds of swaps to do (0,1) @@ -268,6 +267,10 @@ MPI_Bcast(&swap,1,MPI_INT,0,world); + // rescale kinetic energy via velocities if move is accepted + + if (swap) scale_velocities(partner_set_temp,my_set_temp); + // if my world swapped, all procs in world reset temp target of Fix if (swap) { @@ -305,6 +308,24 @@ } /* ---------------------------------------------------------------------- + scale kinetic energy via velocities a la Sugita +------------------------------------------------------------------------- */ + +void Temper::scale_velocities(int t_partner, int t_me) +{ + double sfactor = sqrt(set_temp[t_partner]/set_temp[t_me]); + + double **v = atom->v; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + v[i][0] = v[i][0]*sfactor; + v[i][1] = v[i][1]*sfactor; + v[i][2] = v[i][2]*sfactor; + } +} + +/* ---------------------------------------------------------------------- proc 0 prints current tempering status ------------------------------------------------------------------------- */ diff -Naur lammps-26Jun09/src/temper.h lammps-27Jun09/src/temper.h --- lammps-26Jun09/src/temper.h 2007-01-29 17:22:05.000000000 -0700 +++ lammps-27Jun09/src/temper.h 2009-06-23 14:11:54.000000000 -0600 @@ -43,6 +43,7 @@ int *world2temp; // world2temp[i] = temp simulated by world i int *world2root; // world2root[i] = root proc of world i + void scale_velocities(int, int); void print_status(); };