diff --git a/lammps/src/COLVARS/colvarproxy_lammps.cpp b/lammps/src/COLVARS/colvarproxy_lammps.cpp index b305a615f..50a413be4 100644 --- a/lammps/src/COLVARS/colvarproxy_lammps.cpp +++ b/lammps/src/COLVARS/colvarproxy_lammps.cpp @@ -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(_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"); @@ -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(_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() {