diff --git a/src/ASPHERE/fix_npt_asphere.cpp b/src/ASPHERE/fix_npt_asphere.cpp index c85b4f3a28..c2d3ec97c3 100755 --- a/src/ASPHERE/fix_npt_asphere.cpp +++ b/src/ASPHERE/fix_npt_asphere.cpp @@ -39,14 +39,6 @@ FixNPTASphere::FixNPTASphere(LAMMPS *lmp, int narg, char **arg) : "quat, angmom, torque"); } -/* ---------------------------------------------------------------------- */ - -void FixNPTASphere::init() -{ - FixNPT::init(); - dtq = 0.5 * update->dt; -} - /* ---------------------------------------------------------------------- 1st half of Verlet update ------------------------------------------------------------------------- */ diff --git a/src/ASPHERE/fix_npt_asphere.h b/src/ASPHERE/fix_npt_asphere.h index 83a4da2eb1..beec20f923 100755 --- a/src/ASPHERE/fix_npt_asphere.h +++ b/src/ASPHERE/fix_npt_asphere.h @@ -22,12 +22,10 @@ class FixNPTASphere : public FixNPT { public: FixNPTASphere(class LAMMPS *, int, char **); ~FixNPTASphere() {} - void init(); void initial_integrate(); void final_integrate(); private: - double dtq; double ang_factor; void richardson(double *, double *, double *); diff --git a/src/ASPHERE/fix_nve_asphere.cpp b/src/ASPHERE/fix_nve_asphere.cpp index 613f21920b..3972967afc 100755 --- a/src/ASPHERE/fix_nve_asphere.cpp +++ b/src/ASPHERE/fix_nve_asphere.cpp @@ -34,9 +34,8 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ FixNVEASphere::FixNVEASphere(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) + FixNVE(lmp, narg, arg) { - if (narg < 3) error->all("Illegal fix nve/asphere command"); if (!atom->quat_flag || !atom->angmom_flag || !atom->torque_flag) error->all("Fix nve/asphere requires atom attributes " "quat, angmom, torque"); @@ -53,22 +52,9 @@ FixNVEASphere::~FixNVEASphere() /* ---------------------------------------------------------------------- */ -int FixNVEASphere::setmask() -{ - int mask = 0; - mask |= INITIAL_INTEGRATE; - mask |= FINAL_INTEGRATE; - return mask; -} - -/* ---------------------------------------------------------------------- */ - void FixNVEASphere::init() { - dtv = update->dt; - dtf = 0.5 * update->dt * force->ftm2v; - dtq = 0.5 * update->dt; - + FixNVE::init(); calculate_inertia(); } diff --git a/src/ASPHERE/fix_nve_asphere.h b/src/ASPHERE/fix_nve_asphere.h index 4b7573ee18..b41a4c0e51 100755 --- a/src/ASPHERE/fix_nve_asphere.h +++ b/src/ASPHERE/fix_nve_asphere.h @@ -14,21 +14,19 @@ #ifndef FIX_NVE_ASPHERE_H #define FIX_NVE_ASPHERE_H -#include "fix.h" +#include "fix_nve.h" namespace LAMMPS_NS { -class FixNVEASphere : public Fix { +class FixNVEASphere : public FixNVE { public: FixNVEASphere(class LAMMPS *, int, char **); ~FixNVEASphere(); - int setmask(); void init(); void initial_integrate(); void final_integrate(); private: - double dtv,dtf,dtq; double **inertia; void richardson(double *, double *, double *); diff --git a/src/ASPHERE/fix_nvt_asphere.cpp b/src/ASPHERE/fix_nvt_asphere.cpp index 8d65a83264..fad60a7e73 100755 --- a/src/ASPHERE/fix_nvt_asphere.cpp +++ b/src/ASPHERE/fix_nvt_asphere.cpp @@ -43,14 +43,6 @@ FixNVTASphere::FixNVTASphere(LAMMPS *lmp, int narg, char **arg) : /* ---------------------------------------------------------------------- */ -void FixNVTASphere::init() -{ - FixNVT::init(); - dtq = 0.5 * update->dt; -} - -/* ---------------------------------------------------------------------- */ - void FixNVTASphere::initial_integrate() { double dtfm; diff --git a/src/ASPHERE/fix_nvt_asphere.h b/src/ASPHERE/fix_nvt_asphere.h index d07e5b2d34..6a12c65dd3 100755 --- a/src/ASPHERE/fix_nvt_asphere.h +++ b/src/ASPHERE/fix_nvt_asphere.h @@ -22,13 +22,10 @@ class FixNVTASphere : public FixNVT { public: FixNVTASphere(class LAMMPS *, int, char **); ~FixNVTASphere() {} - void init(); void initial_integrate(); void final_integrate(); private: - double dtq; - void richardson(double *, double *, double *); void omega_from_mq(double *, double *, double *, double *); void calculate_inertia(double mass, double *shape, double *inertia); diff --git a/src/DIPOLE/fix_nve_dipole.cpp b/src/DIPOLE/fix_nve_dipole.cpp index 782975793d..2048e3bbe2 100644 --- a/src/DIPOLE/fix_nve_dipole.cpp +++ b/src/DIPOLE/fix_nve_dipole.cpp @@ -187,3 +187,12 @@ void FixNVEDipole::final_integrate_respa(int ilevel) dtf = 0.5 * step_respa[ilevel] * force->ftm2v; final_integrate(); } + +/* ---------------------------------------------------------------------- */ + +void FixNVEDipole::reset_dt() +{ + dtv = update->dt; + dtf = 0.5 * update->dt * force->ftm2v; +} + diff --git a/src/DIPOLE/fix_nve_dipole.h b/src/DIPOLE/fix_nve_dipole.h index b19a0ff97b..01b3f75fda 100644 --- a/src/DIPOLE/fix_nve_dipole.h +++ b/src/DIPOLE/fix_nve_dipole.h @@ -28,6 +28,7 @@ class FixNVEDipole : public Fix { void final_integrate(); void initial_integrate_respa(int,int); void final_integrate_respa(int); + void reset_dt(); private: double dtv,dtf; diff --git a/src/GRANULAR/fix_nve_gran.cpp b/src/GRANULAR/fix_nve_gran.cpp index f169e40809..1afa347071 100644 --- a/src/GRANULAR/fix_nve_gran.cpp +++ b/src/GRANULAR/fix_nve_gran.cpp @@ -126,3 +126,14 @@ void FixNVEGran::final_integrate() } } } + +/* ---------------------------------------------------------------------- */ + +void FixNVEGran::reset_dt() +{ + dtv = update->dt; + dtf = 0.5 * update->dt * force->ftm2v; + if (domain->dimension == 3) dtfrotate = dtf / INERTIA3D; + else dtfrotate = dtf / INERTIA2D; +} + diff --git a/src/GRANULAR/fix_nve_gran.h b/src/GRANULAR/fix_nve_gran.h index bb6644bacd..ebe1e73828 100644 --- a/src/GRANULAR/fix_nve_gran.h +++ b/src/GRANULAR/fix_nve_gran.h @@ -25,6 +25,7 @@ class FixNVEGran : public Fix { void init(); void initial_integrate(); void final_integrate(); + void reset_dt(); private: double dtv,dtf,dtfrotate; diff --git a/src/GRANULAR/fix_pour.cpp b/src/GRANULAR/fix_pour.cpp index c580123c53..a931219513 100644 --- a/src/GRANULAR/fix_pour.cpp +++ b/src/GRANULAR/fix_pour.cpp @@ -550,3 +550,10 @@ void FixPour::xyz_random(double h, double *coord) coord[2] = 0.0; } } + +/* ---------------------------------------------------------------------- */ + +void FixPour::reset_dt() +{ + error->all("Cannot change timestep with fix pour"); +} diff --git a/src/GRANULAR/fix_pour.h b/src/GRANULAR/fix_pour.h index 0155ad6e14..394880ab92 100644 --- a/src/GRANULAR/fix_pour.h +++ b/src/GRANULAR/fix_pour.h @@ -29,6 +29,7 @@ class FixPour : public Fix { int setmask(); void init(); void pre_exchange(); + void reset_dt(); private: int ninsert,ntype,seed; diff --git a/src/GRANULAR/fix_wall_gran.cpp b/src/GRANULAR/fix_wall_gran.cpp index ccd67427d2..5b123becb9 100644 --- a/src/GRANULAR/fix_wall_gran.cpp +++ b/src/GRANULAR/fix_wall_gran.cpp @@ -748,3 +748,13 @@ int FixWallGran::size_restart(int nlocal) { return 4; } + +/* ---------------------------------------------------------------------- */ + +void FixWallGran::reset_dt() +{ + dt = update->dt; + double gammas = 0.5*gamman; + gamman_dl = gamman/dt; + gammas_dl = gammas/dt; +} diff --git a/src/GRANULAR/fix_wall_gran.h b/src/GRANULAR/fix_wall_gran.h index 0481481cd8..0fe97a7dfa 100644 --- a/src/GRANULAR/fix_wall_gran.h +++ b/src/GRANULAR/fix_wall_gran.h @@ -36,6 +36,7 @@ class FixWallGran : public Fix { void unpack_restart(int, int); int size_restart(int); int maxsize_restart(); + void reset_dt(); private: int wallstyle,pairstyle,wiggle,axis; diff --git a/src/GRANULAR/pair_gran_history.cpp b/src/GRANULAR/pair_gran_history.cpp index 73361b7fe6..3497467f79 100644 --- a/src/GRANULAR/pair_gran_history.cpp +++ b/src/GRANULAR/pair_gran_history.cpp @@ -499,3 +499,14 @@ void *PairGranHistory::extract(char *str) else if (strcmp(str,"dampflag") == 0) return (void *) &dampflag; return NULL; } + +/* ---------------------------------------------------------------------- */ + +void PairGranHistory::reset_dt() +{ + dt = update->dt; + double gammas = 0.5*gamman; + if (dampflag == 0) gammas = 0.0; + gamman_dl = gamman/dt; + gammas_dl = gammas/dt; +} diff --git a/src/GRANULAR/pair_gran_history.h b/src/GRANULAR/pair_gran_history.h index 04e9f8a33f..9509d6636f 100644 --- a/src/GRANULAR/pair_gran_history.h +++ b/src/GRANULAR/pair_gran_history.h @@ -33,6 +33,7 @@ class PairGranHistory : public Pair { void write_restart_settings(FILE *); void read_restart_settings(FILE *); void *extract(char *); + void reset_dt(); protected: double xkk,xkkt,xmu; diff --git a/src/POEMS/fix_poems.cpp b/src/POEMS/fix_poems.cpp index 3eea14e71d..a9665098fd 100644 --- a/src/POEMS/fix_poems.cpp +++ b/src/POEMS/fix_poems.cpp @@ -1580,3 +1580,12 @@ int FixPOEMS::unpack_exchange(int nlocal, double *buf) displace[nlocal][2] = buf[m++]; return m; } + +/* ---------------------------------------------------------------------- */ + +void FixPOEMS::reset_dt() +{ + dtv = update->dt; + dtf = 0.5 * update->dt * force->ftm2v; + dthalf = 0.5 * update->dt; +} diff --git a/src/POEMS/fix_poems.h b/src/POEMS/fix_poems.h index 366e83bbf4..16534d0bef 100644 --- a/src/POEMS/fix_poems.h +++ b/src/POEMS/fix_poems.h @@ -41,6 +41,7 @@ class FixPOEMS : public Fix { void pre_neighbor(); int dof(int); void deform(int); + void reset_dt(); private: int me; diff --git a/src/fix.h b/src/fix.h index e77f06aac7..1869960457 100644 --- a/src/fix.h +++ b/src/fix.h @@ -39,6 +39,7 @@ class Fix : protected Pointers { int vector_flag; // 0/1 if compute_vector() function exists int size_vector; // N = size of global vector int scalar_vector_freq; // frequency compute s/v data is available at + int extensive; // 0/1 if s/v are intensive/extensive values int peratom_flag; // 0/1 if per-atom data is stored int size_peratom; // 0 = scalar_atom, N = size of vector_atom @@ -103,6 +104,7 @@ class Fix : protected Pointers { virtual int dof(int) {return 0;} virtual void deform(int) {} + virtual void reset_dt() {} virtual int modify_param(int, char **) {return 0;} diff --git a/src/fix_indent.cpp b/src/fix_indent.cpp index 9f15aad46d..eae73fa595 100644 --- a/src/fix_indent.cpp +++ b/src/fix_indent.cpp @@ -42,6 +42,7 @@ FixIndent::FixIndent(LAMMPS *lmp, int narg, char **arg) : vector_flag = 1; size_vector = 3; scalar_vector_freq = 1; + extensive = 1; k = atof(arg[3]); diff --git a/src/fix_nph.cpp b/src/fix_nph.cpp index 2fe14a4c44..3ecafffd1a 100644 --- a/src/fix_nph.cpp +++ b/src/fix_nph.cpp @@ -49,6 +49,7 @@ FixNPH::FixNPH(LAMMPS *lmp, int narg, char **arg) : box_change = 1; scalar_flag = 1; scalar_vector_freq = 1; + extensive = 1; double p_period[3]; if (strcmp(arg[3],"xyz") == 0) { diff --git a/src/fix_npt.cpp b/src/fix_npt.cpp index 391d957637..b694ca4d8d 100644 --- a/src/fix_npt.cpp +++ b/src/fix_npt.cpp @@ -48,6 +48,7 @@ FixNPT::FixNPT(LAMMPS *lmp, int narg, char **arg) : box_change = 1; scalar_flag = 1; scalar_vector_freq = 1; + extensive = 1; t_start = atof(arg[3]); t_stop = atof(arg[4]); @@ -273,8 +274,8 @@ void FixNPT::init() // set timesteps and frequencies dtv = update->dt; - dtq = 0.5 * update->dt; dtf = 0.5 * update->dt * force->ftm2v; + dtq = 0.5 * update->dt; dthalf = 0.5 * update->dt; double freq = MAX(p_freq[0],p_freq[1]); @@ -825,3 +826,17 @@ double FixNPT::compute_scalar() return energy; } + +/* ---------------------------------------------------------------------- */ + +void FixNPT::reset_dt() +{ + dtv = update->dt; + dtf = 0.5 * update->dt * force->ftm2v; + dtq = 0.5 * update->dt; + dthalf = 0.5 * update->dt; + + double freq = MAX(p_freq[0],p_freq[1]); + freq = MAX(freq,p_freq[2]); + drag_factor = 1.0 - (update->dt * freq * drag); +} diff --git a/src/fix_npt.h b/src/fix_npt.h index 687756cddc..25703778d9 100644 --- a/src/fix_npt.h +++ b/src/fix_npt.h @@ -23,7 +23,7 @@ class FixNPT : public Fix { FixNPT(class LAMMPS *, int, char **); virtual ~FixNPT(); int setmask(); - virtual void init(); + void init(); void setup(); virtual void initial_integrate(); virtual void final_integrate(); @@ -33,10 +33,11 @@ class FixNPT : public Fix { void write_restart(FILE *); void restart(char *); int modify_param(int, char **); + void reset_dt(); protected: int dimension; - double dtv,dtq,dtf,dthalf; + double dtv,dtf,dtq,dthalf; double boltz,nktv2p; double vol0; diff --git a/src/fix_nve.cpp b/src/fix_nve.cpp index 883c1ab7fe..53ea6f9395 100644 --- a/src/fix_nve.cpp +++ b/src/fix_nve.cpp @@ -48,6 +48,7 @@ void FixNVE::init() { dtv = update->dt; dtf = 0.5 * update->dt * force->ftm2v; + dtq = 0.5 * update->dt; if (strcmp(update->integrate_style,"respa") == 0) step_respa = ((Respa *) update->integrate)->step; @@ -154,3 +155,12 @@ void FixNVE::final_integrate_respa(int ilevel) dtf = 0.5 * step_respa[ilevel] * force->ftm2v; final_integrate(); } + +/* ---------------------------------------------------------------------- */ + +void FixNVE::reset_dt() +{ + dtv = update->dt; + dtf = 0.5 * update->dt * force->ftm2v; + dtq = 0.5 * update->dt; +} diff --git a/src/fix_nve.h b/src/fix_nve.h index 5032b9bae5..8c0e219bf2 100644 --- a/src/fix_nve.h +++ b/src/fix_nve.h @@ -22,14 +22,15 @@ class FixNVE : public Fix { public: FixNVE(class LAMMPS *, int, char **); int setmask(); - void init(); - void initial_integrate(); - void final_integrate(); + virtual void init(); + virtual void initial_integrate(); + virtual void final_integrate(); void initial_integrate_respa(int, int); void final_integrate_respa(int); + void reset_dt(); - private: - double dtv,dtf; + protected: + double dtv,dtf,dtq; double *step_respa; int mass_require; }; diff --git a/src/fix_nve_limit.cpp b/src/fix_nve_limit.cpp index e016ce4cc2..25b3b3c4c7 100644 --- a/src/fix_nve_limit.cpp +++ b/src/fix_nve_limit.cpp @@ -193,3 +193,12 @@ void FixNVELimit::final_integrate_respa(int ilevel) dtf = 0.5 * step_respa[ilevel] * force->ftm2v; final_integrate(); } + +/* ---------------------------------------------------------------------- */ + +void FixNVELimit::reset_dt() +{ + dtv = update->dt; + dtf = 0.5 * update->dt * force->ftm2v; + vlimitsq = (xlimit/dtv) * (xlimit/dtv); +} diff --git a/src/fix_nve_limit.h b/src/fix_nve_limit.h index 1a8f88f9cb..2c1d61dd8b 100644 --- a/src/fix_nve_limit.h +++ b/src/fix_nve_limit.h @@ -27,6 +27,7 @@ class FixNVELimit : public Fix { void final_integrate(); void initial_integrate_respa(int, int); void final_integrate_respa(int); + void reset_dt(); private: double dtv,dtf; diff --git a/src/fix_nve_noforce.cpp b/src/fix_nve_noforce.cpp index 7e0f55b69e..96da6dc9bf 100644 --- a/src/fix_nve_noforce.cpp +++ b/src/fix_nve_noforce.cpp @@ -77,3 +77,10 @@ void FixNVENoforce::initial_integrate_respa(int ilevel, int flag) if (ilevel == 0) initial_integrate(); } + +/* ---------------------------------------------------------------------- */ + +void FixNVENoforce::reset_dt() +{ + dtv = update->dt; +} diff --git a/src/fix_nve_noforce.h b/src/fix_nve_noforce.h index b24554d5de..616a840373 100644 --- a/src/fix_nve_noforce.h +++ b/src/fix_nve_noforce.h @@ -25,6 +25,7 @@ class FixNVENoforce : public Fix { void init(); void initial_integrate(); void initial_integrate_respa(int, int); + void reset_dt(); private: double dtv; diff --git a/src/fix_nvt.cpp b/src/fix_nvt.cpp index 859080eb17..371c208bf8 100644 --- a/src/fix_nvt.cpp +++ b/src/fix_nvt.cpp @@ -41,6 +41,7 @@ FixNVT::FixNVT(LAMMPS *lmp, int narg, char **arg) : restart_global = 1; scalar_flag = 1; scalar_vector_freq = 1; + extensive = 1; t_start = atof(arg[3]); t_stop = atof(arg[4]); @@ -71,9 +72,12 @@ FixNVT::FixNVT(LAMMPS *lmp, int narg, char **arg) : char **newarg = new char*[3]; newarg[0] = id_temp; newarg[1] = group->names[igroup]; - if (strcmp(style,"nvt") == 0) newarg[2] = (char *) "temp"; - else if (strcmp(style,"nvt/asphere") == 0) newarg[2] = (char *) "temp/asphere"; - else if (strcmp(style,"nvt/sllod") == 0) newarg[2] = (char *) "temp/deform"; + if (strcmp(style,"nvt") == 0) + newarg[2] = (char *) "temp"; + else if (strcmp(style,"nvt/asphere") == 0) + newarg[2] = (char *) "temp/asphere"; + else if (strcmp(style,"nvt/sllod") == 0) + newarg[2] = (char *) "temp/deform"; modify->add_compute(3,newarg); delete [] newarg; tflag = 1; @@ -117,6 +121,7 @@ void FixNVT::init() dtv = update->dt; dtf = 0.5 * update->dt * force->ftm2v; + dtq = 0.5 * update->dt; dthalf = 0.5 * update->dt; drag_factor = 1.0 - (update->dt * t_freq * drag); @@ -379,6 +384,18 @@ void FixNVT::reset_target(double t_new) /* ---------------------------------------------------------------------- */ +void FixNVT::reset_dt() +{ + dtv = update->dt; + dtf = 0.5 * update->dt * force->ftm2v; + dtq = 0.5 * update->dt; + dthalf = 0.5 * update->dt; + + drag_factor = 1.0 - (update->dt * t_freq * drag); +} + +/* ---------------------------------------------------------------------- */ + double FixNVT::compute_scalar() { double ke = temperature->dof * force->boltz * t_target; diff --git a/src/fix_nvt.h b/src/fix_nvt.h index 12818afd1c..97618aa596 100644 --- a/src/fix_nvt.h +++ b/src/fix_nvt.h @@ -23,7 +23,7 @@ class FixNVT : public Fix { FixNVT(class LAMMPS *, int, char **); virtual ~FixNVT(); int setmask(); - virtual void init(); + void init(); void setup(); virtual void initial_integrate(); virtual void final_integrate(); @@ -34,13 +34,14 @@ class FixNVT : public Fix { void restart(char *); int modify_param(int, char **); void reset_target(double); + void reset_dt(); protected: double t_start,t_stop; double t_current,t_target; double t_freq,drag,drag_factor; double f_eta,eta_dot,eta,factor; - double dtv,dtf,dthalf; + double dtv,dtf,dtq,dthalf; int nlevels_respa; double *step_respa; diff --git a/src/fix_orient_fcc.cpp b/src/fix_orient_fcc.cpp index a50474bf23..8f97bc6181 100644 --- a/src/fix_orient_fcc.cpp +++ b/src/fix_orient_fcc.cpp @@ -48,6 +48,7 @@ FixOrientFCC::FixOrientFCC(LAMMPS *lmp, int narg, char **arg) : scalar_flag = 1; scalar_vector_freq = 1; + extensive = 1; nstats = atoi(arg[3]); direction_of_motion = atoi(arg[4]); diff --git a/src/fix_rigid.cpp b/src/fix_rigid.cpp index 49456c0390..f157bebf5b 100644 --- a/src/fix_rigid.cpp +++ b/src/fix_rigid.cpp @@ -1472,3 +1472,12 @@ int FixRigid::unpack_exchange(int nlocal, double *buf) displace[nlocal][2] = buf[3]; return 4; } + +/* ---------------------------------------------------------------------- */ + +void FixRigid::reset_dt() +{ + dtv = update->dt; + dtf = 0.5 * update->dt * force->ftm2v; + dtq = 0.5 * update->dt; +} diff --git a/src/fix_rigid.h b/src/fix_rigid.h index 238fc33af8..4b59512022 100644 --- a/src/fix_rigid.h +++ b/src/fix_rigid.h @@ -39,6 +39,7 @@ class FixRigid : public Fix { void pre_neighbor(); int dof(int); void deform(int); + void reset_dt(); private: double dtv,dtf,dtq; diff --git a/src/fix_set_force.cpp b/src/fix_set_force.cpp index 6474e095c3..d3eda26fcc 100644 --- a/src/fix_set_force.cpp +++ b/src/fix_set_force.cpp @@ -31,6 +31,7 @@ FixSetForce::FixSetForce(LAMMPS *lmp, int narg, char **arg) : vector_flag = 1; size_vector = 3; scalar_vector_freq = 1; + extensive = 1; flagx = flagy = flagz = 1; if (strcmp(arg[3],"NULL") == 0) flagx = 0; diff --git a/src/fix_shake.cpp b/src/fix_shake.cpp index cad005fb2d..d3e2a1eae9 100644 --- a/src/fix_shake.cpp +++ b/src/fix_shake.cpp @@ -2306,3 +2306,17 @@ void FixShake::unpack_comm(int n, int first, double *buf) xshake[i][2] = buf[m++]; } } + +/* ---------------------------------------------------------------------- */ + +void FixShake::reset_dt() +{ + if (strcmp(update->integrate_style,"verlet") == 0) { + dtv = update->dt; + dtfsq = update->dt * update->dt * force->ftm2v; + } else { + dtv = step_respa[0]; + dtf_innerhalf = 0.5 * step_respa[0] * force->ftm2v; + dtf_inner = step_respa[0] * force->ftm2v; + } +} diff --git a/src/fix_shake.h b/src/fix_shake.h index 52483fc56e..73c2ed4689 100644 --- a/src/fix_shake.h +++ b/src/fix_shake.h @@ -38,6 +38,7 @@ class FixShake : public Fix { void unpack_comm(int, int, double *); int dof(int); + void reset_dt(); private: int me,nprocs; diff --git a/src/fix_temp_rescale.cpp b/src/fix_temp_rescale.cpp index bd645be70c..827ecdf660 100644 --- a/src/fix_temp_rescale.cpp +++ b/src/fix_temp_rescale.cpp @@ -42,6 +42,7 @@ FixTempRescale::FixTempRescale(LAMMPS *lmp, int narg, char **arg) : scalar_flag = 1; scalar_vector_freq = nevery; + extensive = 1; t_start = atof(arg[4]); t_end = atof(arg[5]); diff --git a/src/fix_tmd.cpp b/src/fix_tmd.cpp index b3752b4bf2..f1fb0cae1a 100644 --- a/src/fix_tmd.cpp +++ b/src/fix_tmd.cpp @@ -169,11 +169,8 @@ void FixTMD::init() dtv = update->dt; dtf = update->dt * force->ftm2v; - if (strcmp(update->integrate_style,"respa") == 0) { - double *step_respa = ((Respa *) update->integrate)->step; - dtv = step_respa[0]; - dtf = step_respa[0] * force->ftm2v; - } + if (strcmp(update->integrate_style,"respa") == 0) + step_respa = ((Respa *) update->integrate)->step; } /* ---------------------------------------------------------------------- */ @@ -184,7 +181,7 @@ void FixTMD::initial_integrate() double dx,dy,dz,dxkt,dykt,dzkt; double dxold,dyold,dzold,xback,yback,zback; double gamma_forward,gamma_back,gamma_max,lambda; - double kt,fr,kttotal,frtotal; + double kt,fr,kttotal,frtotal,dtfm; double xprd = domain->xprd; double yprd = domain->yprd; @@ -322,6 +319,10 @@ void FixTMD::initial_integrate() void FixTMD::initial_integrate_respa(int ilevel, int flag) { if (flag) return; // only used by NPT,NPH + + dtv = step_respa[ilevel]; + dtf = step_respa[ilevel] * force->ftm2v; + if (ilevel == 0) initial_integrate(); } @@ -538,3 +539,11 @@ void FixTMD::open(char *file) error->one(str); } } + +/* ---------------------------------------------------------------------- */ + +void FixTMD::reset_dt() +{ + dtv = update->dt; + dtf = update->dt * force->ftm2v; +} diff --git a/src/fix_tmd.h b/src/fix_tmd.h index d3ffabb66d..78f61633ca 100644 --- a/src/fix_tmd.h +++ b/src/fix_tmd.h @@ -33,13 +33,15 @@ class FixTMD : public Fix { void copy_arrays(int, int); int pack_exchange(int, double *); int unpack_exchange(int, double *); + void reset_dt(); private: int me; int nfileevery,previous_stat; FILE *fp; double rho_start,rho_stop,rho_old,masstotal; - double dtv,dtf,dtfm; + double dtv,dtf; + double *step_respa; double work_lambda,work_analytical; double **xf,**xold; diff --git a/src/fix_wall_lj126.cpp b/src/fix_wall_lj126.cpp index 5b43044287..23306762e9 100644 --- a/src/fix_wall_lj126.cpp +++ b/src/fix_wall_lj126.cpp @@ -39,6 +39,7 @@ FixWallLJ126::FixWallLJ126(LAMMPS *lmp, int narg, char **arg) : vector_flag = 1; size_vector = 3; scalar_vector_freq = 1; + extensive = 1; if (strcmp(arg[3],"xlo") == 0) { dim = 0; diff --git a/src/fix_wall_lj93.cpp b/src/fix_wall_lj93.cpp index 99d020ebb6..e8f5312ce7 100644 --- a/src/fix_wall_lj93.cpp +++ b/src/fix_wall_lj93.cpp @@ -35,6 +35,7 @@ FixWallLJ93::FixWallLJ93(LAMMPS *lmp, int narg, char **arg) : vector_flag = 1; size_vector = 3; scalar_vector_freq = 1; + extensive = 1; if (strcmp(arg[3],"xlo") == 0) { dim = 0; @@ -192,5 +193,3 @@ double FixWallLJ93::compute_vector(int n) } return wall_all[n]; } - - diff --git a/src/fix_wiggle.cpp b/src/fix_wiggle.cpp index 43183af243..318f456707 100644 --- a/src/fix_wiggle.cpp +++ b/src/fix_wiggle.cpp @@ -175,3 +175,11 @@ int FixWiggle::unpack_exchange(int nlocal, double *buf) original[nlocal] = buf[0]; return 1; } + +/* ---------------------------------------------------------------------- */ + +void FixWiggle::reset_dt() +{ + dt = update->dt; +} + diff --git a/src/fix_wiggle.h b/src/fix_wiggle.h index 908e52fa15..620d2e78f5 100644 --- a/src/fix_wiggle.h +++ b/src/fix_wiggle.h @@ -32,6 +32,7 @@ class FixWiggle : public Fix { void copy_arrays(int, int); int pack_exchange(int, double *); int unpack_exchange(int, double *); + void reset_dt(); private: double dt; diff --git a/src/integrate.h b/src/integrate.h index e158d4067a..446cb1e6ea 100644 --- a/src/integrate.h +++ b/src/integrate.h @@ -27,6 +27,7 @@ class Integrate : protected Pointers { virtual void iterate(int) = 0; virtual void cleanup() {} virtual double memory_usage() {return 0.0;} + virtual void reset_dt() {} }; } diff --git a/src/pair.h b/src/pair.h index 4ad2b66830..1c4735fbb3 100644 --- a/src/pair.h +++ b/src/pair.h @@ -97,6 +97,7 @@ class Pair : protected Pointers { virtual void *extract(char *) {return NULL;} virtual void single_embed(int, int, double &) {} virtual void swap_eam(double *, double **) {} + virtual void reset_dt() {} protected: int allocated; // 0/1 = whether arrays are allocated diff --git a/src/pair_hybrid.cpp b/src/pair_hybrid.cpp index ab4c362bae..e0f83607c5 100644 --- a/src/pair_hybrid.cpp +++ b/src/pair_hybrid.cpp @@ -617,3 +617,10 @@ void *PairHybrid::extract(char *str) if (strcmp(str,"cut_coul") == 0) return cutptr; return NULL; } + +/* ---------------------------------------------------------------------- */ + +void PairHybrid::reset_dt() +{ + for (int m = 0; m < nstyles; m++) styles[m]->reset_dt(); +} diff --git a/src/pair_hybrid.h b/src/pair_hybrid.h index edcdffe4fb..0ba7f0bc57 100644 --- a/src/pair_hybrid.h +++ b/src/pair_hybrid.h @@ -43,6 +43,7 @@ class PairHybrid : public Pair { void compute_middle(); void compute_outer(int, int); void *extract(char *); + void reset_dt(); protected: int **nmap; // # of sub-styles itype,jtype points to diff --git a/src/respa.cpp b/src/respa.cpp index 3ba4a4f6de..eed422f3db 100644 --- a/src/respa.cpp +++ b/src/respa.cpp @@ -443,6 +443,15 @@ void Respa::cleanup() /* ---------------------------------------------------------------------- */ +void Respa::reset_dt() +{ + step[nlevels-1] = update->dt; + for (int ilevel = nlevels-2; ilevel >= 0; ilevel--) + step[ilevel] = step[ilevel+1]/loop[ilevel]; +} + +/* ---------------------------------------------------------------------- */ + void Respa::recurse(int ilevel) { copy_flevel_f(ilevel); diff --git a/src/respa.h b/src/respa.h index 6cb0aa06e4..ccc0691c3e 100644 --- a/src/respa.h +++ b/src/respa.h @@ -39,6 +39,7 @@ class Respa : public Integrate { void setup(); void iterate(int); void cleanup(); + void reset_dt(); void copy_f_flevel(int); void copy_flevel_f(int); diff --git a/src/style.h b/src/style.h index 9cdf05bac7..3831dff16d 100644 --- a/src/style.h +++ b/src/style.h @@ -144,9 +144,10 @@ DumpStyle(xyz,DumpXYZ) #include "fix_ave_spatial.h" #include "fix_ave_time.h" #include "fix_com.h" -#include "fix_drag.h" #include "fix_deform.h" #include "fix_deposit.h" +#include "fix_drag.h" +#include "fix_dt_reset.h" #include "fix_efield.h" #include "fix_enforce2d.h" #include "fix_gravity.h" @@ -194,9 +195,10 @@ FixStyle(aveforce,FixAveForce) FixStyle(ave/spatial,FixAveSpatial) FixStyle(ave/time,FixAveTime) FixStyle(com,FixCOM) -FixStyle(drag,FixDrag) FixStyle(deform,FixDeform) FixStyle(deposit,FixDeposit) +FixStyle(drag,FixDrag) +FixStyle(dt/reset,FixDtReset) FixStyle(efield,FixEfield) FixStyle(enforce2d,FixEnforce2D) FixStyle(gravity,FixGravity) diff --git a/src/style_asphere.h b/src/style_asphere.h index f67f9033ee..da375a0593 100644 --- a/src/style_asphere.h +++ b/src/style_asphere.h @@ -41,8 +41,10 @@ FixStyle(npt/asphere,FixNPTASphere) #ifdef PairInclude #include "pair_gayberne.h" +#include "pair_resquared.h" #endif #ifdef PairClass PairStyle(gayberne,PairGayBerne) +PairStyle(resquared,PairRESquared) #endif diff --git a/src/thermo.cpp b/src/thermo.cpp index b6c2bb9fd4..f3f491b247 100644 --- a/src/thermo.cpp +++ b/src/thermo.cpp @@ -1015,8 +1015,7 @@ int Thermo::evaluate_keyword(char *word, double *answer) extraction of Compute, Fix, Variable results ignore thermoflag, since these 3 routines only called by Thermo::compute(), not by variable evaluation - compute value is normalized by atoms if returning extensive quantities - fix value is normalized (so should return extensive quantity) + compute/fix are normalized by atoms if returning extensive value(s) variable value is not normalized (so formula should normalize if desired) ------------------------------------------------------------------------- */ @@ -1027,7 +1026,7 @@ void Thermo::compute_compute() int index = field2object[ifield]; if (arg_object[ifield] == 0) dvalue = computes[index]->scalar; else dvalue = computes[index]->vector[arg_object[ifield]-1]; - if (computes[index]->extensive && normflag) dvalue /= natoms; + if (normflag && computes[index]->extensive) dvalue /= natoms; } /* ---------------------------------------------------------------------- */ @@ -1037,7 +1036,7 @@ void Thermo::compute_fix() int index = field2object[ifield]; if (arg_object[ifield] == 0) dvalue = fixes[index]->compute_scalar(); else dvalue = fixes[index]->compute_vector(arg_object[ifield]-1); - if (normflag) dvalue /= natoms; + if (normflag && fixes[index]->extensive) dvalue /= natoms; } /* ---------------------------------------------------------------------- */