Molecular Dynamics Simulation  1.0
Public Member Functions | Private Attributes | List of all members
ThermostatInterceptor Class Reference

#include <ThermostatInterceptor.h>

Inheritance diagram for ThermostatInterceptor:
Inheritance graph
Collaboration diagram for ThermostatInterceptor:
Collaboration graph

Public Member Functions

 ThermostatInterceptor (std::shared_ptr< Thermostat > thermostat, size_t application_interval)
 Construct a new Thermostat Interceptor object. More...
 
void onSimulationStart (Simulation &simulation) override
 This function is empty as the thermostat doesnt need initialization. More...
 
void operator() (size_t iteration, Simulation &simulation) override
 This function is called on every nth iteration. It scales the temperature of the particles in accordance with the thermostat. More...
 
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. More...
 
 operator std::string () const override
 The string representation of this interceptor. More...
 
void logSummary (int depth) const override
 Logs the summary of the thermostat. More...
 
- Public Member Functions inherited from SimulationInterceptor
virtual ~SimulationInterceptor ()=default
 Destroy the Simulation Interceptor object. More...
 
void notify (size_t iteration, Simulation &simulation)
 This function is called by the simulation loop on every iteration. Whenever the iteration is a multiple of every_nth_iteration, the operator() function is called. More...
 

Private Attributes

std::shared_ptr< Thermostatthermostat
 The thermostat that is used to scale the temperature. More...
 
size_t application_interval
 The interval at which the thermostat is applied. More...
 

Additional Inherited Members

- Protected Attributes inherited from SimulationInterceptor
size_t every_nth_iteration = 1
 

Detailed Description

Definition at line 9 of file ThermostatInterceptor.h.

Constructor & Destructor Documentation

◆ ThermostatInterceptor()

ThermostatInterceptor::ThermostatInterceptor ( std::shared_ptr< Thermostat thermostat,
size_t  application_interval 
)
explicit

Construct a new Thermostat Interceptor object.

Definition at line 5 of file ThermostatInterceptor.cpp.

7 }
std::shared_ptr< Thermostat > thermostat
The thermostat that is used to scale the temperature.
size_t application_interval
The interval at which the thermostat is applied.

Member Function Documentation

◆ logSummary()

void ThermostatInterceptor::logSummary ( int  depth) const
overridevirtual

Logs the summary of the thermostat.

Implements SimulationInterceptor.

Definition at line 17 of file ThermostatInterceptor.cpp.

17  {
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 }
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

◆ onSimulationEnd()

void ThermostatInterceptor::onSimulationEnd ( size_t  iteration,
Simulation simulation 
)
overridevirtual

This function is empty as the thermostat doesnt need to do anything at the end of the simulation.

Parameters
iterationThe current iteration
simulationThe simulation object

Implements SimulationInterceptor.

Definition at line 15 of file ThermostatInterceptor.cpp.

15 {}

◆ onSimulationStart()

void ThermostatInterceptor::onSimulationStart ( Simulation simulation)
overridevirtual

This function is empty as the thermostat doesnt need initialization.

Parameters
simulationThe simulation object

Implements SimulationInterceptor.

Definition at line 9 of file ThermostatInterceptor.cpp.

9 {}

◆ operator std::string()

ThermostatInterceptor::operator std::string ( ) const
explicitoverridevirtual

The string representation of this interceptor.

Returns
std::string

This is used to write the final summary of the Interceptors to the console.

Implements SimulationInterceptor.

Definition at line 26 of file ThermostatInterceptor.cpp.

26 { return ""; }

◆ operator()()

void ThermostatInterceptor::operator() ( size_t  iteration,
Simulation simulation 
)
overridevirtual

This function is called on every nth iteration. It scales the temperature of the particles in accordance with the thermostat.

Parameters
iterationThe current iteration
simulationThe simulation object

Implements SimulationInterceptor.

Definition at line 11 of file ThermostatInterceptor.cpp.

11  {
12  thermostat->scaleTemperature(simulation.particle_container);
13 }
std::unique_ptr< ParticleContainer > particle_container
Reference to the ParticleContainer on whose content the simulation is performed.
Definition: Simulation.h:50

Member Data Documentation

◆ application_interval

size_t ThermostatInterceptor::application_interval
private

The interval at which the thermostat is applied.

Definition at line 65 of file ThermostatInterceptor.h.

◆ thermostat

std::shared_ptr<Thermostat> ThermostatInterceptor::thermostat
private

The thermostat that is used to scale the temperature.

Definition at line 60 of file ThermostatInterceptor.h.


The documentation for this class was generated from the following files: