From fcf2730cd1ac0eb45a30228636e82730573f1fdc Mon Sep 17 00:00:00 2001 From: Simon Homes Date: Tue, 28 May 2024 17:48:14 +0200 Subject: [PATCH 1/3] Set initial simulation time (step) earlier --- src/Simulation.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Simulation.cpp b/src/Simulation.cpp index 53be31d563..7e10de4d6f 100644 --- a/src/Simulation.cpp +++ b/src/Simulation.cpp @@ -196,7 +196,8 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { /* run section */ if(xmlconfig.changecurrentnode("run")) { xmlconfig.getNodeValueReduced("currenttime", _simulationTime); - Log::global_log->info() << "Simulation start time: " << _simulationTime << std::endl; + Log::global_log->info() << "Simulation start time (might be altered by checkpoint): " + << getSimulationTime() << std::endl; /* steps */ xmlconfig.getNodeValue("equilibration/steps", _initStatistics); Log::global_log->info() << "Number of equilibration steps: " << _initStatistics << std::endl; @@ -682,11 +683,15 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { bool ignoreCheckpointTime = false; if(xmlconfig.getNodeValue("ignoreCheckpointTime", ignoreCheckpointTime)) { if(ignoreCheckpointTime) - _simulationTime = 0; + setSimulationTime(0.0); } } xmlconfig.changecurrentnode(oldpath); + + // _simulationTime might be updated by readers -> also update _initSimulation + _simstep = _initSimulation = (unsigned long) round(_simulationTime / _integrator->getTimestepLength() ); + Log::global_log->info() << "Set initial time step to start from to " << _initSimulation << std::endl; } @@ -942,8 +947,6 @@ void Simulation::prepare_start() { _ensemble->prepare_start(); - _simstep = _initSimulation = (unsigned long) round(_simulationTime / _integrator->getTimestepLength() ); - Log::global_log->info() << "Set initial time step to start from to " << _initSimulation << std::endl; Log::global_log->info() << "System initialised with " << _domain->getglobalNumMolecules(true, _moleculeContainer, _domainDecomposition) << " molecules." << std::endl; } From 8d7da1d9e31712557fe4ab2734b56a152329188e Mon Sep 17 00:00:00 2001 From: HomesGH <55833544+HomesGH@users.noreply.github.com> Date: Tue, 28 May 2024 19:38:12 +0200 Subject: [PATCH 2/3] Concise output Co-authored-by: FG-TUM --- src/Simulation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Simulation.cpp b/src/Simulation.cpp index 7e10de4d6f..f7309caf87 100644 --- a/src/Simulation.cpp +++ b/src/Simulation.cpp @@ -691,7 +691,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { // _simulationTime might be updated by readers -> also update _initSimulation _simstep = _initSimulation = (unsigned long) round(_simulationTime / _integrator->getTimestepLength() ); - Log::global_log->info() << "Set initial time step to start from to " << _initSimulation << std::endl; + Log::global_log->info() << "Set initial time step to " << _initSimulation << std::endl; } From 05ccdeb1d074f066d7e4e789b43ea3f34cca972b Mon Sep 17 00:00:00 2001 From: HomesGH <55833544+HomesGH@users.noreply.github.com> Date: Fri, 31 May 2024 11:01:45 +0200 Subject: [PATCH 3/3] Add doc and C++ style cast --- src/Simulation.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Simulation.cpp b/src/Simulation.cpp index f7309caf87..08e55f2ae5 100644 --- a/src/Simulation.cpp +++ b/src/Simulation.cpp @@ -690,7 +690,10 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) { xmlconfig.changecurrentnode(oldpath); // _simulationTime might be updated by readers -> also update _initSimulation - _simstep = _initSimulation = (unsigned long) round(_simulationTime / _integrator->getTimestepLength() ); + // In theory, the division of the physical time (_simulationTime) and the time step width, + // should give a whole number. However, due to numerical errors, the result of the + // division must be rounded + _simstep = _initSimulation = static_cast(std::round(_simulationTime / _integrator->getTimestepLength())); Log::global_log->info() << "Set initial time step to " << _initSimulation << std::endl; }