Skip to content

Commit

Permalink
Communicate LAMMPS timestep after Colvars is configured (restore orig…
Browse files Browse the repository at this point in the history
…inal behavior after #418)
  • Loading branch information
giacomofiorin committed Sep 6, 2023
1 parent 7435483 commit 3d202c5
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lammps/src/COLVARS/colvarproxy_lammps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@ void colvarproxy_lammps::init()
boltzmann_ = _lmp->force->boltz;
set_integration_timestep(_lmp->update->dt * _lmp->force->femtosecond);

if (_lmp->update->ntimestep != 0) {
cvm::log("Setting initial step number from LAMMPS: "+
cvm::to_str(_lmp->update->ntimestep)+"\n");
colvarmodule::it = colvarmodule::it_restart =
static_cast<cvm::step_number>(_lmp->update->ntimestep);
}

if (cvm::debug()) {
cvm::log("atoms_ids = "+cvm::to_str(atoms_ids)+"\n");
cvm::log("atoms_refcount = "+cvm::to_str(atoms_refcount)+"\n");
Expand Down Expand Up @@ -111,17 +104,25 @@ void colvarproxy_lammps::set_replicas_communicator(MPI_Comm root2root)
}


// re-initialize data where needed
// Initialize Colvars now that LAMMPS data structures are set up
int colvarproxy_lammps::setup()
{
int error_code = colvarproxy::setup();
set_integration_timestep(_lmp->update->dt * _lmp->force->femtosecond);
if ((_lmp->update->ntimestep != 0) && (colvars->it == 0)) {
// Note: initializing here and not in the constructor so that the Colvars
// configuration can be first read when the internal step is still zero
cvm::log("Setting initial step number from LAMMPS: "+
cvm::to_str(_lmp->update->ntimestep)+"\n");
colvars->it = colvars->it_restart = static_cast<cvm::step_number>(_lmp->update->ntimestep);
}
error_code |= colvars->update_engine_parameters();
error_code |= colvars->setup_input();
error_code |= colvars->setup_output();
return error_code;
}


// trigger colvars computation
double colvarproxy_lammps::compute()
{
Expand Down

0 comments on commit 3d202c5

Please sign in to comment.