more debugging and features

This commit is contained in:
Steve Plimpton
2021-12-10 11:13:06 -07:00
parent e2969d09e1
commit 5ead32f886
6 changed files with 43 additions and 32 deletions

View File

@ -330,6 +330,8 @@ void Dump::write()
if (delay_flag && update->ntimestep < delaystep) return; if (delay_flag && update->ntimestep < delaystep) return;
printf("DUMP %ld\n",update->ntimestep);
// if file per timestep, open new file // if file per timestep, open new file
if (multifile) openfile(); if (multifile) openfile();

View File

@ -198,6 +198,7 @@ void FixDtReset::end_of_step()
laststep = update->ntimestep; laststep = update->ntimestep;
// calls to other classes that need to know timestep size changed // calls to other classes that need to know timestep size changed
// similar logic is in Input::timestep()
update->update_time(); update->update_time();
update->dt = dt; update->dt = dt;

View File

@ -1836,8 +1836,24 @@ void Input::timer_command()
void Input::timestep() void Input::timestep()
{ {
if (narg != 1) error->all(FLERR,"Illegal timestep command"); if (narg != 1) error->all(FLERR,"Illegal timestep command");
update->update_time();
update->dt = utils::numeric(FLERR,arg[0],false,lmp); update->dt = utils::numeric(FLERR,arg[0],false,lmp);
update->dt_default = 0; update->dt_default = 0;
if (update->first_update == 0) return;
// calls to other classes that need to know timestep size changed
// similar logic is in FixDtReset::end_of_step()
// only if a run has already occurred
int respaflag = 0;
if (utils::strmatch(update->integrate_style, "^respa")) respaflag = 1;
if (respaflag) update->integrate->reset_dt();
if (force->pair) force->pair->reset_dt();
for (int i = 0; i < modify->nfix; i++) modify->fix[i]->reset_dt();
output->reset_dt();
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -565,42 +565,22 @@ void Output::write_restart(bigint ntimestep)
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
timestep is being changed, called by update->reset_timestep() timestep is being changed, called by update->reset_timestep()
reset next output values for dumps, restart, thermo output for dumps, require that no dump is "active"
meaning that a snapshot has already been output
reset next output values restart and thermo output
reset to smallest value >= new timestep reset to smallest value >= new timestep
if next timestep set by variable evaluation, if next timestep set by variable evaluation,
eval for ntimestep-1, so current ntimestep can be returned if needed eval for ntimestep-1, so current ntimestep can be returned if needed
no guarantee that variable can be evaluated for ntimestep-1 no guarantee that variable can be evaluated for ntimestep-1
if it depends on computes, but live with that rare case for now e.g. if it depends on computes, but live with that rare case for now
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Output::reset_timestep(bigint ntimestep) void Output::reset_timestep(bigint ntimestep)
{ {
next_dump_any = MAXBIGINT; next_dump_any = MAXBIGINT;
for (int idump = 0; idump < ndump; idump++) { for (int idump = 0; idump < ndump; idump++)
if (every_dump[idump]) { if (last_dump[idump] >= 0)
next_dump[idump] = (ntimestep/every_dump[idump])*every_dump[idump]; error->all("Cannot reset timestep with active dump - must undump first");
if (next_dump[idump] < ntimestep) next_dump[idump] += every_dump[idump];
} else {
// ivar_dump may not be initialized
if (ivar_dump[idump] < 0) {
ivar_dump[idump] = input->variable->find(var_dump[idump]);
if (ivar_dump[idump] < 0)
error->all(FLERR,"Variable name for dump every does not exist");
if (!input->variable->equalstyle(ivar_dump[idump]))
error->all(FLERR,"Variable for dump every is invalid style");
}
modify->clearstep_compute();
update->ntimestep--;
bigint nextdump = static_cast<bigint>
(input->variable->compute_equal(ivar_dump[idump]));
if (nextdump < ntimestep)
error->all(FLERR,"Dump every variable returned a bad timestep");
update->ntimestep++;
next_dump[idump] = nextdump;
modify->addstep_compute(next_dump[idump]);
}
next_dump_any = MIN(next_dump_any,next_dump[idump]);
}
if (restart_flag_single) { if (restart_flag_single) {
if (restart_every_single) { if (restart_every_single) {
@ -669,21 +649,30 @@ void Output::reset_timestep(bigint ntimestep)
void Output::reset_dt() void Output::reset_dt()
{ {
next_dump_any = MAXBIGINT;
bigint ntimestep = update->ntimestep; bigint ntimestep = update->ntimestep;
next_dump_any = MAXBIGINT;
for (int idump = 0; idump < ndump; idump++) { for (int idump = 0; idump < ndump; idump++) {
if (mode_dump[idump] == 1) { if (mode_dump[idump] == 1) {
// reset next_dump for unchanged next_time_dump, 2 arg for reset_dt() // reset next_dump but do not change next_time_dump, 2 arg for reset_dt()
// do not invoke for a dump already scheduled for this step // do not invoke for a dump already scheduled for this step
// use compute_all() b/c don't know what computes will be needed // use compute_all() b/c don't know what computes will be needed
if (next_dump[idump] != ntimestep) { if (next_dump[idump] != ntimestep) {
calculate_next_dump(2,idump,update->ntimestep); calculate_next_dump(2,idump,update->ntimestep);
if (dump[idump]->clearstep || var_dump[idump])
modify->addstep_compute_all(next_dump[idump]); // NOTE: think I should not do this here
// for time dumps, calc_next_dump should calc the next timestep
// as one less and not add it to computes
// then on that step, write() should not actually write the dump
// but trigger it on next step and addstep_compute_all for that step
// b/c when write() is called, the next-step timestep is set
// unless run every timestep is invoked in-between!
//if (dump[idump]->clearstep || var_dump[idump])
// modify->addstep_compute_all(next_dump[idump]);
} }
} }

View File

@ -491,6 +491,7 @@ void Update::reset_timestep(bigint newstep)
} }
// changes to output that depend on timestep // changes to output that depend on timestep
// no active dumps allowed
output->reset_timestep(ntimestep); output->reset_timestep(ntimestep);

View File

@ -252,6 +252,8 @@ void Verlet::run(int n)
ntimestep = ++update->ntimestep; ntimestep = ++update->ntimestep;
ev_set(ntimestep); ev_set(ntimestep);
printf("VERLET %ld: %d %d\n",ntimestep,eflag,vflag);
// initial time integration // initial time integration
timer->stamp(); timer->stamp();