Molecular Dynamics Simulation  1.0
ThermostatInterceptor.cpp
Go to the documentation of this file.
2 
3 #include "io/logger/Logger.h"
4 
5 ThermostatInterceptor::ThermostatInterceptor(std::shared_ptr<Thermostat> thermostat, size_t application_interval) : thermostat(thermostat) {
7 }
8 
10 
11 void ThermostatInterceptor::operator()(size_t iteration, Simulation& simulation) {
12  thermostat->scaleTemperature(simulation.particle_container);
13 }
14 
15 void ThermostatInterceptor::onSimulationEnd(size_t iteration, Simulation& simulation) {}
16 
17 void ThermostatInterceptor::logSummary(int depth) const {
18  std::string indent = std::string(depth * 2, ' ');
19 
20  Logger::logger->info("{}╟┤{}Thermostat: {}", indent, ansi_orange_bold, ansi_end);
21  Logger::logger->info("{}║ ┌Target temperature: {}", indent, thermostat->getTargetTemperature());
22  Logger::logger->info("{}║ ├Maximum temperature change: {}", indent, thermostat->getMaxTemperatureChange());
23  Logger::logger->info("{}║ └Application interval: {}", indent, every_nth_iteration);
24 }
25 
26 ThermostatInterceptor::operator std::string() const { return ""; }
const std::string ansi_end
Definition: Logger.h:13
const std::string ansi_orange_bold
Definition: Logger.h:10
static std::shared_ptr< spdlog::logger > logger
Publically accessible shared pointer to the logger.
Definition: Logger.h:35
Class to run a simulation.
Definition: Simulation.h:20
std::unique_ptr< ParticleContainer > particle_container
Reference to the ParticleContainer on whose content the simulation is performed.
Definition: Simulation.h:50
void onSimulationEnd(size_t iteration, Simulation &simulation) override
This function is empty as the thermostat doesnt need to do anything at the end of the simulation.
std::shared_ptr< Thermostat > thermostat
The thermostat that is used to scale the temperature.
void operator()(size_t iteration, Simulation &simulation) override
This function is called on every nth iteration. It scales the temperature of the particles in accorda...
ThermostatInterceptor(std::shared_ptr< Thermostat > thermostat, size_t application_interval)
Construct a new Thermostat Interceptor object.
void onSimulationStart(Simulation &simulation) override
This function is empty as the thermostat doesnt need initialization.
size_t application_interval
The interval at which the thermostat is applied.
void logSummary(int depth) const override
Logs the summary of the thermostat.