diff --git a/doc/Manual.html b/doc/Manual.html index 84a071a6db..ac4f3e1afd 100644 --- a/doc/Manual.html +++ b/doc/Manual.html @@ -22,7 +22,7 @@

LAMMPS-ICMS Documentation

-

14 May 2013 version +

24 May 2013 version

Version info:

diff --git a/doc/Manual.txt b/doc/Manual.txt index 38f1f4c5d2..8e0aa5aa13 100644 --- a/doc/Manual.txt +++ b/doc/Manual.txt @@ -18,7 +18,7 @@

LAMMPS-ICMS Documentation :c,h3 -14 May 2013 version :c,h4 +24 May 2013 version :c,h4 Version info: :h4 diff --git a/doc/delete_atoms.html b/doc/delete_atoms.html index 02cc1e2726..3ea9f9d361 100644 --- a/doc/delete_atoms.html +++ b/doc/delete_atoms.html @@ -30,9 +30,10 @@
  • zero or more keyword/value pairs may be appended -
  • keyword = compress +
  • keyword = compress or mol -
      compress value = no or yes 
    +
      compress value = no or yes
    +  mol value = no or yes 
     
    @@ -53,6 +54,9 @@ close to each other (e.g. at a grain boundary).

    For style group, all atoms belonging to the group are deleted.

    For style region, all atoms in the region volume are deleted. +Additional atoms can be deleted if they are in a molecule for which +one or more atoms were deleted within the region; see the mol +keyword discussion below.

    For style overlap pairs of atoms whose distance of separation is within the specified cutoff distance are searched for, and one of the @@ -85,6 +89,12 @@ number of atoms in the system. This is not done for molecular systems compress setting, since it would foul up the bond connectivity that has already been assigned.

    +

    It the mol keyword is set to yes, then for every atom that is +deleted, all other atoms in the same molecule will also be deleted. +This keyword is only used by the region style. It is a way to +insure that entire molecules are deleted instead of only a subset of +atoms in a bond or angle or dihedral interaction. +

    Restrictions:

    The overlap styles requires inter-processor communication to acquire @@ -108,6 +118,6 @@ deleting one atom in a bonded pair anyway.

    Default:

    -

    The option defaults are compress = yes. +

    The option defaults are compress = yes and mol = no.

    diff --git a/doc/delete_atoms.txt b/doc/delete_atoms.txt index 5a613a352b..7c4bd2bcf9 100644 --- a/doc/delete_atoms.txt +++ b/doc/delete_atoms.txt @@ -24,8 +24,9 @@ style = {group} or {region} or {overlap} or {porosity} :ulb,l fraction = delete this fraction of atoms seed = random number seed (positive integer) :pre zero or more keyword/value pairs may be appended :l -keyword = {compress} :l - {compress} value = {no} or {yes} :pre +keyword = {compress} or {mol} :l + {compress} value = {no} or {yes} + {mol} value = {no} or {yes} :pre :ule [Examples:] @@ -45,6 +46,9 @@ close to each other (e.g. at a grain boundary). For style {group}, all atoms belonging to the group are deleted. For style {region}, all atoms in the region volume are deleted. +Additional atoms can be deleted if they are in a molecule for which +one or more atoms were deleted within the region; see the {mol} +keyword discussion below. For style {overlap} pairs of atoms whose distance of separation is within the specified cutoff distance are searched for, and one of the @@ -77,6 +81,12 @@ number of atoms in the system. This is not done for molecular systems {compress} setting, since it would foul up the bond connectivity that has already been assigned. +It the {mol} keyword is set to {yes}, then for every atom that is +deleted, all other atoms in the same molecule will also be deleted. +This keyword is only used by the {region} style. It is a way to +insure that entire molecules are deleted instead of only a subset of +atoms in a bond or angle or dihedral interaction. + [Restrictions:] The {overlap} styles requires inter-processor communication to acquire @@ -100,4 +110,4 @@ deleting one atom in a bonded pair anyway. [Default:] -The option defaults are compress = yes. +The option defaults are compress = yes and mol = no. diff --git a/doc/fix_gcmc.html b/doc/fix_gcmc.html index c8a38e8125..4be3248a44 100644 --- a/doc/fix_gcmc.html +++ b/doc/fix_gcmc.html @@ -51,7 +51,7 @@

    Examples:

    fix 2 gas gcmc 10 1000 1000 2 29494 298.0 -0.5 0.01
    -fix 3 Kr gcmc 10 100 100 1 3456543 3.0 -2.5 0.1 molecule yes maxrot 180
    +fix 3 Kr gcmc 10 100 100 1 3456543 3.0 -2.5 0.1 molecule yes maxangle 180
     fix 4 my_gas gcmc 1 10 10 1 123456543 300.0 -12.5 1.0 region disk 
     

    Description: diff --git a/doc/fix_gcmc.txt b/doc/fix_gcmc.txt index 02f8791055..1f7af8d7a9 100644 --- a/doc/fix_gcmc.txt +++ b/doc/fix_gcmc.txt @@ -35,7 +35,7 @@ keyword = {molecule}, {region}, {maxangle}, {pressure}, or {fugacity_coeff} :l [Examples:] fix 2 gas gcmc 10 1000 1000 2 29494 298.0 -0.5 0.01 -fix 3 Kr gcmc 10 100 100 1 3456543 3.0 -2.5 0.1 molecule yes maxrot 180 +fix 3 Kr gcmc 10 100 100 1 3456543 3.0 -2.5 0.1 molecule yes maxangle 180 fix 4 my_gas gcmc 1 10 10 1 123456543 300.0 -12.5 1.0 region disk :pre [Description:] diff --git a/doc/fix_reax_bonds.html b/doc/fix_reax_bonds.html index b7c8e36590..dd25932e9c 100644 --- a/doc/fix_reax_bonds.html +++ b/doc/fix_reax_bonds.html @@ -30,11 +30,11 @@ fix 1 all reax/c/bonds 100 bonds.reaxc

    Description:

    Write out the bond information computed by the ReaxFF potential -specified by pair_style reax or -pair_style reax/c in the exact same format as -the stand-alone ReaxFF code. The bond information -is written to filename on timesteps that are multiples of Nevery, -including timestep 0. For time-averaged chemical species analysis, +specified by pair_style reax or pair_style +reax/c in the exact same format as the original +stand-alone ReaxFF code of Adri van Duin. The bond information is +written to filename on timesteps that are multiples of Nevery, +including timestep 0. For time-averaged chemical species analysis, please see the fix species command.

    The format of the output file should be self-explantory. @@ -58,10 +58,10 @@ reax be invoked. This fix is part of the REAX package. It is only enabled if LAMMPS was built with that package, which also requires the REAX library be built and linked with LAMMPS. The fix reax/c/bonds command requires that the pair_style -reax/c be invoked. This fix is part of the USER-REAXC -package. It is only enabled if LAMMPS was built with that package. -See the Making LAMMPS section for more -info. +reax/c be invoked. This fix is part of the +USER-REAXC package. It is only enabled if LAMMPS was built with that +package. See the Making LAMMPS section +for more info.

    Related commands:

    diff --git a/doc/fix_reax_bonds.txt b/doc/fix_reax_bonds.txt index d51e08ef53..cc8966db6f 100644 --- a/doc/fix_reax_bonds.txt +++ b/doc/fix_reax_bonds.txt @@ -26,11 +26,11 @@ fix 1 all reax/c/bonds 100 bonds.reaxc :pre [Description:] Write out the bond information computed by the ReaxFF potential -specified by "pair_style reax"_pair_reax.html or -"pair_style reax/c"_pair_reax_c.html in the exact same format as -the stand-alone ReaxFF code. The bond information -is written to {filename} on timesteps that are multiples of {Nevery}, -including timestep 0. For time-averaged chemical species analysis, +specified by "pair_style reax"_pair_reax.html or "pair_style +reax/c"_pair_reax_c.html in the exact same format as the original +stand-alone ReaxFF code of Adri van Duin. The bond information is +written to {filename} on timesteps that are multiples of {Nevery}, +including timestep 0. For time-averaged chemical species analysis, please see the "fix species"_fix_species.html command. The format of the output file should be self-explantory. @@ -54,10 +54,10 @@ reax"_pair_reax.html be invoked. This fix is part of the REAX package. It is only enabled if LAMMPS was built with that package, which also requires the REAX library be built and linked with LAMMPS. The fix reax/c/bonds command requires that the "pair_style -reax/c"_pair_reax_c.html be invoked. This fix is part of the USER-REAXC -package. It is only enabled if LAMMPS was built with that package. -See the "Making LAMMPS"_Section_start.html#start_3 section for more -info. +reax/c"_pair_reax_c.html be invoked. This fix is part of the +USER-REAXC package. It is only enabled if LAMMPS was built with that +package. See the "Making LAMMPS"_Section_start.html#start_3 section +for more info. [Related commands:] diff --git a/doc/fix_reaxc_species.html b/doc/fix_reaxc_species.html new file mode 100644 index 0000000000..e1af71daa4 --- /dev/null +++ b/doc/fix_reaxc_species.html @@ -0,0 +1,143 @@ + +
    LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Commands +
    + + + + + + +
    + +

    fix reax/c/species command +

    +

    Syntax: +

    +
    fix ID group-ID reax/c/species Nevery Nrepeat Nfreq filename keyword value ... 
    +
    +
    • ID, group-ID are documented in fix command + +
    • reax/c/species = style name of this command + +
    • Nevery = sample bond-order every this many timesteps + +
    • Nrepeat = # of bond-order samples used for calculating averages + +
    • Nfreq = calculate average bond-order every this many timesteps + +
    • filename = name of output file + +
    • zero or more keyword/value pairs may be appended + +
    • keyword = cutoff or element or position + +
        cutoff value = I J Cutoff
      +    I, J = atom types
      +    Cutoff = Bond-order cutoff value for this pair of atom types
      +  element value = Element1, Element2, ... 
      +  position value = posfreq filepos
      +    posfreq = write position files every this many timestep
      +    filepos = name of position output file 
      +
      + +
    +

    Examples: +

    +
    fix 1 all species 10 10 100 species.out
    +fix 1 all species 1 2 20 species.out cutoff 1 1 0.40 cutoff 1 2 0.55
    +fix 1 all species 1 100 100 species.out element Au O H position 1000 AuOH.pos 
    +
    +

    Description: +

    +

    Write out the chemical species information computed by the ReaxFF potential +specified by pair_style reax/c. Bond-order values +(either averaged or instantaneous, depending on value of Nrepeat) +are used to determine chemical bonds. Every Nfreq timesteps, +chemical species information is written to filename as a two line output. +The first line is a header containing labels. The second line consists +of the following: timestep, total number of molecules, +total number of distinct species, number of molecules of each species. +The chemical formula of each species is given in the first line. +

    +

    Optional keyword cutoff can be assigned to change the minimum bond-order values +used in identifying chemical bonds between pairs of atoms. Bond-order cutoffs +should be carefully chosen, as bond-order cutoffs that are too small may include +too many bonds (which will result in an error), while too-large cutoffs will +result in fragmented molecules. The default cutoff of 0.3 usually gives good +estimate. +

    +

    Optional keyword element can be used to specify the chemical symbol printed for +each LAMMPS atom type. The number of symbols must match the number of LAMMPS atom types +and each symbol must consist of 1 or 2 alphanumeric characters. Normally, these +symbols should be chosen to match the chemical identity of each LAMMPS atom type, +as specified using the reax/c pair_coeff command and +the ReaxFF force field file. +

    +

    Optional keyword position writes center-of-mass positions of each identified +molecules to file filepos every posfreq timesteps. The first line contains +information on timestep, total number of molecules, total number of distinct +species, and box dimensions. The second line is a header containing labels. +From the third line downward, each molecule writes a line of output containing +the following information: molecule ID, number of atoms in this molecule, chemical +formula, total charge, and center-of-mass xyz positions of this molecule. The xyz +positions are in fractional coordinates relative to the box dimensions. +

    +

    Keyword position output file filepos can contain the wildcard character "*". +If the "*" character appears in filepos, then one file per snapshot is written +at posfreq and the "*" character is replaced with the timestep value. +For example, AuO.pos.* becomes AuO.pos.0, AuO.pos.1000, etc. +

    +
    + +

    The Nevery, Nrepeat, and Nfreq arguments specify on what +timesteps the bond-order values are sampled to get the average bond +order. The species analysis is performed using the average bond-order +on timesteps +that are a multiple of Nfreq. The average is over Nrepeat +bond-order samples, computed in the preceding portion of the simulation every +Nevery timesteps. Nfreq must be a multiple of Nevery and +Nevery must be non-zero even if Nrepeat is 1. Also, the timesteps +contributing to the average bond-order cannot overlap, i.e. Nfreq > +(Nrepeat-1)*Nevery is required. +

    +

    For example, if Nevery=2, Nrepeat=6, and Nfreq=100, then bond-order values on +timesteps 90,92,94,96,98,100 will be used to compute the average bond-order + for the species analysis output on timestep 100. +

    +
    + +

    Restart, fix_modify, output, run start/stop, minimize info: +

    +

    No information about this fix is written to binary restart +files. None of the fix_modify options +are relevant to this fix. No global or per-atom quantities are stored +by this fix for access by various output +commands. No parameter of this fix can +be used with the start/stop keywords of the run command. +This fix is not invoked during energy minimization. +

    +

    Restrictions: +

    +

    The fix species currently only works with +pair_style reax/c and it requires that the pair_style +reax/c be invoked. This fix is part of the +USER-REAXC package. It is only enabled if LAMMPS was built with that +package. See the Making LAMMPS section +for more info. +

    +

    It should be possible to extend it to other reactive pair_styles (such as +rebo, airebo, +comb, and bop), but this has not yet been done. +

    +

    Related commands: +

    +

    pair_style reax/c, fix +reax/bonds +

    +

    Default: +

    +

    The default values for bond-order cutoffs are 0.3 for all I-J pairs. The +default element symbols are C, H, O, N. Position files are not written +by default. +

    + diff --git a/doc/thermo_style.html b/doc/thermo_style.html index 8641eb138f..78bcc3038e 100644 --- a/doc/thermo_style.html +++ b/doc/thermo_style.html @@ -22,7 +22,7 @@
      one args = none
       multi args = none
       custom args = list of attributes
    -    possible attributes = step, elapsed, elaplong, dt, cpu, tpcpu, spcpu,
    +    possible attributes = step, elapsed, elaplong, dt, time, cpu, tpcpu, spcpu,
                               atoms, temp, press, pe, ke, etotal, enthalpy,
                               evdwl, ecoul, epair, ebond, eangle, edihed, eimp,
                               emol, elong, etail,
    @@ -38,6 +38,7 @@
           elapsed = timesteps since start of this run
           elaplong = timesteps since start of initial run in a series of runs
           dt = timestep size
    +      time = simulation time
           cpu = elapsed CPU time in seconds
           tpcpu = time per CPU second
           spcpu = timesteps per CPU second
    @@ -213,6 +214,15 @@ keywords for the run for info on how to invoke a series
     runs that keep track of an initial starting time.  If these keywords
     are not used, then elapsed and elaplong are the same value.
     

    +

    The dt keyword is the current timestep size in time +units. The time keyword is the current elapsed +simulation time, also in time units, which is simply +(step*dt) if the timestep size has not changed and the timestep has +not been reset. If the timestep has changed (e.g. via fix +dt/reset) or the timestep has been reset (e.g. via +the "reset_timestep" command), then the simulation time is effectively +a cummulative value up to the current point. +

    The cpu keyword is elapsed CPU seconds since the beginning of this run. The tpcpu and spcpu keywords are measures of how fast your simulation is currently running. The tpcpu keyword is simulation diff --git a/doc/thermo_style.txt b/doc/thermo_style.txt index 0e77cb7287..29acefe6ab 100644 --- a/doc/thermo_style.txt +++ b/doc/thermo_style.txt @@ -17,7 +17,7 @@ args = list of arguments for a particular style :l {one} args = none {multi} args = none {custom} args = list of attributes - possible attributes = step, elapsed, elaplong, dt, cpu, tpcpu, spcpu, + possible attributes = step, elapsed, elaplong, dt, time, cpu, tpcpu, spcpu, atoms, temp, press, pe, ke, etotal, enthalpy, evdwl, ecoul, epair, ebond, eangle, edihed, eimp, emol, elong, etail, @@ -33,6 +33,7 @@ args = list of arguments for a particular style :l elapsed = timesteps since start of this run elaplong = timesteps since start of initial run in a series of runs dt = timestep size + time = simulation time cpu = elapsed CPU time in seconds tpcpu = time per CPU second spcpu = timesteps per CPU second @@ -207,6 +208,15 @@ keywords for the "run"_run.html for info on how to invoke a series of runs that keep track of an initial starting time. If these keywords are not used, then {elapsed} and {elaplong} are the same value. +The {dt} keyword is the current timestep size in time +"units"_units.html. The {time} keyword is the current elapsed +simulation time, also in time "units"_units.html, which is simply +(step*dt) if the timestep size has not changed and the timestep has +not been reset. If the timestep has changed (e.g. via "fix +dt/reset"_fix_dt_reset.html) or the timestep has been reset (e.g. via +the "reset_timestep" command), then the simulation time is effectively +a cummulative value up to the current point. + The {cpu} keyword is elapsed CPU seconds since the beginning of this run. The {tpcpu} and {spcpu} keywords are measures of how fast your simulation is currently running. The {tpcpu} keyword is simulation diff --git a/src/atom_vec_sphere.cpp b/src/atom_vec_sphere.cpp index a757d89754..5d331953cb 100644 --- a/src/atom_vec_sphere.cpp +++ b/src/atom_vec_sphere.cpp @@ -1048,12 +1048,11 @@ void AtomVecSphere::pack_data(double **buf) else buf[i][3] = rmass[i] / (4.0*MY_PI/3.0 * radius[i]*radius[i]*radius[i]); buf[i][4] = x[i][0]; - buf[i][5] = x[i][0]; - buf[i][6] = x[i][1]; - buf[i][7] = x[i][2]; - buf[i][8] = (image[i] & IMGMASK) - IMGMAX; - buf[i][9] = (image[i] >> IMGBITS & IMGMASK) - IMGMAX; - buf[i][10] = (image[i] >> IMG2BITS) - IMGMAX; + buf[i][5] = x[i][1]; + buf[i][6] = x[i][2]; + buf[i][7] = (image[i] & IMGMASK) - IMGMAX; + buf[i][8] = (image[i] >> IMGBITS & IMGMASK) - IMGMAX; + buf[i][9] = (image[i] >> IMG2BITS) - IMGMAX; } } diff --git a/src/comm.cpp b/src/comm.cpp index 4f4dfe75f6..b15fc5a285 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -534,7 +534,8 @@ void Comm::setup() maxneed[0] = MAX(all[0],all[1]); maxneed[1] = MAX(all[2],all[3]); maxneed[2] = MAX(all[4],all[5]); - // if (me == 0) printf("MAXNEED %d %d %d\n",maxneed[0],maxneed[1],maxneed[2]); + //if (me == 0) + //printf("MAXNEED %d %d %d\n",maxneed[0],maxneed[1],maxneed[2]); } // allocate comm memory @@ -1508,9 +1509,10 @@ void Comm::forward_comm_array(int n, double **array) communicate inbuf around full ring of processors with messtag nbytes = size of inbuf = n datums * nper bytes callback() is invoked to allow caller to process/update each proc's inbuf - note that callback() is invoked on final iteration for original inbuf + if self=1 (default), then callback() is invoked on final iteration + using original inbuf, which may have been updated for non-NULL outbuf, final updated inbuf is copied to it - outbuf = inbuf is OK + outbuf = inbuf is OK ------------------------------------------------------------------------- */ void Comm::ring(int n, int nper, void *inbuf, int messtag, diff --git a/src/delete_atoms.cpp b/src/delete_atoms.cpp index dc70d8557c..d2fa42192b 100644 --- a/src/delete_atoms.cpp +++ b/src/delete_atoms.cpp @@ -28,8 +28,14 @@ #include "memory.h" #include "error.h" +#include + using namespace LAMMPS_NS; +// allocate space for static class variable + +DeleteAtoms *DeleteAtoms::cptr; + /* ---------------------------------------------------------------------- */ DeleteAtoms::DeleteAtoms(LAMMPS *lmp) : Pointers(lmp) {} @@ -138,6 +144,7 @@ void DeleteAtoms::delete_group(int narg, char **arg) /* ---------------------------------------------------------------------- delete all atoms in region + if mol_flag is set, also delete atoms in molecules with any deletions ------------------------------------------------------------------------- */ void DeleteAtoms::delete_region(int narg, char **arg) @@ -158,6 +165,54 @@ void DeleteAtoms::delete_region(int narg, char **arg) for (int i = 0; i < nlocal; i++) if (domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2])) dlist[i] = 1; + + if (mol_flag == 0) return; + + // delete entire molecules if any atom in molecule was deleted + // store list of molecule IDs I delete atoms from in list + // pass list from proc to proc via ring communication + + hash = new std::map(); + + int *molecule = atom->molecule; + for (int i = 0; i < nlocal; i++) + if (dlist[i] && hash->find(molecule[i]) == hash->end()) + (*hash)[molecule[i]] = 1; + + int n = hash->size(); + int *list; + memory->create(list,n,"delete_atoms:list"); + + n = 0; + std::map::iterator pos; + for (pos = hash->begin(); pos != hash->end(); ++pos) list[n++] = pos->first; + + cptr = this; + comm->ring(n,sizeof(int),list,1,molring,NULL); + + delete hash; + memory->destroy(list); +} + +/* ---------------------------------------------------------------------- + callback from comm->ring() + cbuf = list of N molecule IDs, put them in hash + loop over my atoms, if matches moleculed ID in hash, delete that atom +------------------------------------------------------------------------- */ + +void DeleteAtoms::molring(int n, char *cbuf) +{ + int *list = (int *) cbuf; + int *dlist = cptr->dlist; + std::map *hash = cptr->hash; + int nlocal = cptr->atom->nlocal; + int *molecule = cptr->atom->molecule; + + hash->clear(); + for (int i = 0; i < n; i++) (*hash)[list[i]] = 1; + + for (int i = 0; i < nlocal; i++) + if (hash->find(molecule[i]) != hash->end()) dlist[i] = 1; } /* ---------------------------------------------------------------------- @@ -346,6 +401,7 @@ void DeleteAtoms::delete_porosity(int narg, char **arg) void DeleteAtoms::options(int narg, char **arg) { compress_flag = 1; + mol_flag = 0; int iarg = 0; while (iarg < narg) { @@ -355,6 +411,12 @@ void DeleteAtoms::options(int narg, char **arg) else if (strcmp(arg[iarg+1],"no") == 0) compress_flag = 0; else error->all(FLERR,"Illegal delete_bonds command"); iarg += 2; + } else if (strcmp(arg[iarg],"mol") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal delete_bonds command"); + if (strcmp(arg[iarg+1],"yes") == 0) mol_flag = 1; + else if (strcmp(arg[iarg+1],"no") == 0) mol_flag = 0; + else error->all(FLERR,"Illegal delete_bonds command"); + iarg += 2; } else error->all(FLERR,"Illegal delete_bonds command"); } } diff --git a/src/delete_atoms.h b/src/delete_atoms.h index aab02f41d6..217401c970 100644 --- a/src/delete_atoms.h +++ b/src/delete_atoms.h @@ -21,6 +21,7 @@ CommandStyle(delete_atoms,DeleteAtoms) #define LMP_DELETE_ATOMS_H #include "pointers.h" +#include namespace LAMMPS_NS { @@ -31,7 +32,8 @@ class DeleteAtoms : protected Pointers { private: int *dlist; - int compress_flag; + int compress_flag,mol_flag; + std::map *hash; void delete_group(int, char **); void delete_region(int, char **); @@ -42,6 +44,12 @@ class DeleteAtoms : protected Pointers { inline int sbmask(int j) { return j >> SBBITS & 3; } + + // static variable for ring communication callback to access class data + // callback functions for ring communication + + static DeleteAtoms *cptr; + static void molring(int, char *); }; } diff --git a/src/fix_dt_reset.cpp b/src/fix_dt_reset.cpp index 60e9e0b449..79e9441f6b 100644 --- a/src/fix_dt_reset.cpp +++ b/src/fix_dt_reset.cpp @@ -46,7 +46,7 @@ FixDtReset::FixDtReset(LAMMPS *lmp, int narg, char **arg) : time_depend = 1; scalar_flag = 1; vector_flag = 1; - size_vector = 2; + size_vector = 1; global_freq = 1; extscalar = 0; extvector = 0; @@ -89,7 +89,7 @@ FixDtReset::FixDtReset(LAMMPS *lmp, int narg, char **arg) : // initializations - t_elapsed = t_laststep = 0.0; + t_laststep = 0.0; laststep = update->ntimestep; } @@ -98,7 +98,6 @@ FixDtReset::FixDtReset(LAMMPS *lmp, int narg, char **arg) : int FixDtReset::setmask() { int mask = 0; - mask |= INITIAL_INTEGRATE; mask |= END_OF_STEP; return mask; } @@ -133,15 +132,6 @@ void FixDtReset::setup(int vflag) /* ---------------------------------------------------------------------- */ -void FixDtReset::initial_integrate(int vflag) -{ - // calculate elapsed time based on previous reset timestep - - t_elapsed = t_laststep + (update->ntimestep-laststep)*dt; -} - -/* ---------------------------------------------------------------------- */ - void FixDtReset::end_of_step() { double dtv,dtf,dtsq; @@ -190,9 +180,9 @@ void FixDtReset::end_of_step() if (dt == update->dt) return; - t_elapsed = t_laststep += (update->ntimestep-laststep)*update->dt; laststep = update->ntimestep; + update->update_time(); update->dt = dt; if (respaflag) update->integrate->reset_dt(); if (force->pair) force->pair->reset_dt(); @@ -210,6 +200,5 @@ double FixDtReset::compute_scalar() double FixDtReset::compute_vector(int n) { - if (n == 0) return t_elapsed; return (double) laststep; } diff --git a/src/fix_dt_reset.h b/src/fix_dt_reset.h index de97d147dc..7084b59934 100644 --- a/src/fix_dt_reset.h +++ b/src/fix_dt_reset.h @@ -31,7 +31,6 @@ class FixDtReset : public Fix { int setmask(); void init(); void setup(int); - void initial_integrate(int); void end_of_step(); double compute_scalar(); double compute_vector(int); @@ -41,7 +40,7 @@ class FixDtReset : public Fix { int minbound,maxbound; double tmin,tmax,xmax; double ftm2v; - double dt,t_elapsed,t_laststep; + double dt,t_laststep; int respaflag; }; diff --git a/src/respa.cpp b/src/respa.cpp index 469b3d698e..8e9288e35e 100644 --- a/src/respa.cpp +++ b/src/respa.cpp @@ -503,6 +503,7 @@ void Respa::cleanup() modify->post_run(); modify->delete_fix("RESPA"); domain->box_too_small_check(); + update->update_time(); } /* ---------------------------------------------------------------------- */ diff --git a/src/thermo.cpp b/src/thermo.cpp index 1b9ce64ba4..634fc420f6 100644 --- a/src/thermo.cpp +++ b/src/thermo.cpp @@ -47,7 +47,7 @@ using namespace MathConst; // customize a new keyword by adding to this list: -// step, elapsed, elaplong, dt, cpu, tpcpu, spcpu +// step, elapsed, elaplong, dt, time, cpu, tpcpu, spcpu // atoms, temp, press, pe, ke, etotal, enthalpy // evdwl, ecoul, epair, ebond, eangle, edihed, eimp, emol, elong, etail // vol, lx, ly, lz, xlo, xhi, ylo, yhi, zlo, zhi, xy, xz, yz, xlat, ylat, zlat @@ -649,6 +649,8 @@ void Thermo::parse_fields(char *str) addfield("Elaplong",&Thermo::compute_elapsed_long,BIGINT); } else if (strcmp(word,"dt") == 0) { addfield("Dt",&Thermo::compute_dt,FLOAT); + } else if (strcmp(word,"time") == 0) { + addfield("Time",&Thermo::compute_time,FLOAT); } else if (strcmp(word,"cpu") == 0) { addfield("CPU",&Thermo::compute_cpu,FLOAT); } else if (strcmp(word,"tpcpu") == 0) { @@ -996,6 +998,9 @@ int Thermo::evaluate_keyword(char *word, double *answer) } else if (strcmp(word,"dt") == 0) { compute_dt(); + } else if (strcmp(word,"time") == 0) { + compute_time(); + } else if (strcmp(word,"cpu") == 0) { if (update->whichflag == 0) error->all(FLERR, @@ -1449,6 +1454,13 @@ void Thermo::compute_dt() /* ---------------------------------------------------------------------- */ +void Thermo::compute_time() +{ + dvalue = update->atime + (update->ntimestep-update->atimestep)*update->dt; +} + +/* ---------------------------------------------------------------------- */ + void Thermo::compute_cpu() { if (firststep == 0) dvalue = 0.0; diff --git a/src/thermo.h b/src/thermo.h index 173e7239df..e0a10ea0dd 100644 --- a/src/thermo.h +++ b/src/thermo.h @@ -122,6 +122,7 @@ class Thermo : protected Pointers { void compute_elapsed(); void compute_elapsed_long(); void compute_dt(); + void compute_time(); void compute_cpu(); void compute_tpcpu(); void compute_spcpu(); diff --git a/src/update.cpp b/src/update.cpp index b502822c8b..ad58842937 100644 --- a/src/update.cpp +++ b/src/update.cpp @@ -38,6 +38,8 @@ Update::Update(LAMMPS *lmp) : Pointers(lmp) char *str; ntimestep = 0; + atime = 0.0; + atimestep = 0; first_update = 0; whichflag = 0; @@ -356,6 +358,7 @@ void Update::reset_timestep(int narg, char **arg) /* ---------------------------------------------------------------------- reset timestep + set atimestep to new timestep, so future update_time() calls will be correct trigger reset of timestep for output and for fixes that require it do not allow any timestep-dependent fixes to be defined reset eflag/vflag global so nothing will think eng/virial are current @@ -371,6 +374,8 @@ void Update::reset_timestep(bigint newstep) if (ntimestep < 0) error->all(FLERR,"Timestep must be >= 0"); if (ntimestep > MAXBIGINT) error->all(FLERR,"Too big a timestep"); + atimestep = ntimestep; + output->reset_timestep(ntimestep); for (int i = 0; i < modify->nfix; i++) { @@ -400,6 +405,17 @@ void Update::reset_timestep(bigint newstep) // error->all(FLERR,"Cannot reset timestep with a dynamic region defined"); } +/* ---------------------------------------------------------------------- + update elapsed simulation time + called at end of runs or when timestep size changes +------------------------------------------------------------------------- */ + +void Update::update_time() +{ + atime += (ntimestep-atimestep) * dt; + atimestep = ntimestep; +} + /* ---------------------------------------------------------------------- memory usage of update and integrate/minimize ------------------------------------------------------------------------- */ diff --git a/src/update.h b/src/update.h index f94ac92d98..1f347d7d0b 100644 --- a/src/update.h +++ b/src/update.h @@ -25,6 +25,8 @@ class Update : protected Pointers { bigint ntimestep; // current step (dynamics or min iterations) int nsteps; // # of steps to run (dynamics or min iter) int whichflag; // 0 for unset, 1 for dynamics, 2 for min + double atime; // simulation time at atime_step + bigint atimestep; // last timestep atime was updated bigint firststep,laststep; // 1st & last step of this run bigint beginstep,endstep; // 1st and last step of multiple runs int first_update; // 0 before initial update, 1 after @@ -52,6 +54,7 @@ class Update : protected Pointers { void create_minimize(int, char **); void reset_timestep(int, char **); void reset_timestep(bigint); + void update_time(); bigint memory_usage(); private: diff --git a/src/verlet.cpp b/src/verlet.cpp index 9020c9399c..966d14dba8 100644 --- a/src/verlet.cpp +++ b/src/verlet.cpp @@ -334,6 +334,7 @@ void Verlet::cleanup() { modify->post_run(); domain->box_too_small_check(); + update->update_time(); } /* ---------------------------------------------------------------------- diff --git a/src/version.h b/src/version.h index 81efb3170f..5d67f892bd 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define LAMMPS_VERSION "14 May 2013" +#define LAMMPS_VERSION "24 May 2013"