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

Class to store some overview data of an executed simulation. More...

#include <SimulationOverview.h>

Collaboration diagram for SimulationOverview:
Collaboration graph

Public Member Functions

void logSummary (int depth=0) const
 Prints a summary of the simulation overview to the logger. More...
 
void savePerformanceDataCSV () const
 Saves the simulation overview to a csv file. More...
 
void savePerformanceDataCSV (const std::string &filename_prefix) const
 Saves the simulation overview to a csv file. More...
 

Public Attributes

const SimulationParamsparams
 Original simulation parameters bevore the simulation. More...
 
double total_time_seconds
 Total time the simulation took to execute in seconds (includes time for writing output files and logging) More...
 
size_t total_iterations
 Total number of iterations the simulation ran for (includes an initial force calculation) More...
 
std::vector< std::string > interceptor_summaries
 Summary of the interceptors that were used during the simulation. More...
 
std::vector< Particleresulting_particles
 Resulting particles after the simulation. More...
 

Detailed Description

Class to store some overview data of an executed simulation.

Definition at line 13 of file SimulationOverview.h.

Member Function Documentation

◆ logSummary()

void SimulationOverview::logSummary ( int  depth = 0) const

Prints a summary of the simulation overview to the logger.

Parameters
depthdetermines the indentation of the log message

Definition at line 15 of file SimulationOverview.cpp.

15  {
16  std::string indent = std::string(depth * 2, ' ');
17 
18  Logger::logger->info("{}╔════════════════════════════════════════", indent);
19  Logger::logger->info("{}╟┤{}Simulation overview: {}", indent, ansi_yellow_bold, ansi_end);
20  Logger::logger->info("{}║ Input file: {}", indent, params.input_file_path.string());
21  Logger::logger->info("{}║ Output directory: {}", indent, params.output_dir_path.string());
22  Logger::logger->info("{}║ Simulation time: {}", indent, format_seconds_total(total_time_seconds));
23  Logger::logger->info("{}║ Number of iterations: {}", indent, total_iterations);
24  Logger::logger->info("{}║ Number of particles left: {}", indent, resulting_particles.size());
25  Logger::logger->info("{}╟┤{}Interceptor Logs: {}", indent, ansi_yellow_bold, ansi_end);
26 
27  if (interceptor_summaries.empty()) {
28  Logger::logger->info("{}║ └No interceptors", indent);
29  } else {
30  for (auto& interceptor_summary : interceptor_summaries) {
31  Logger::logger->info("{}║ ├{}", indent, interceptor_summary);
32  }
33  }
34 
35  Logger::logger->info("{}╚════════════════════════════════════════", indent);
36 }
std::string format_seconds_total(double total_seconds)
Formats the given seconds into a string of the form "HHh MMm SSs MMMms".
Definition: FormatTime.cpp:34
const std::string ansi_yellow_bold
Definition: Logger.h:11
const std::string ansi_end
Definition: Logger.h:13
static std::shared_ptr< spdlog::logger > logger
Publically accessible shared pointer to the logger.
Definition: Logger.h:35
std::vector< std::string > interceptor_summaries
Summary of the interceptors that were used during the simulation.
double total_time_seconds
Total time the simulation took to execute in seconds (includes time for writing output files and logg...
std::vector< Particle > resulting_particles
Resulting particles after the simulation.
size_t total_iterations
Total number of iterations the simulation ran for (includes an initial force calculation)
const SimulationParams & params
Original simulation parameters bevore the simulation.
std::filesystem::path output_dir_path
Path to the directory in which to save the simulation output.
std::filesystem::path input_file_path
Path to the input file of the simulation.

◆ savePerformanceDataCSV() [1/2]

void SimulationOverview::savePerformanceDataCSV ( ) const

Saves the simulation overview to a csv file.

Definition at line 38 of file SimulationOverview.cpp.

void savePerformanceDataCSV() const
Saves the simulation overview to a csv file.

◆ savePerformanceDataCSV() [2/2]

void SimulationOverview::savePerformanceDataCSV ( const std::string &  filename_prefix) const

Saves the simulation overview to a csv file.

Parameters
filename_prefixPrefix for the outputted filename (<prefix>performance_data<timestamp>.csv)

Definition at line 40 of file SimulationOverview.cpp.

40  {
41  // write the results to the file
42  std::time_t now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
43  auto formatted_time = fmt::format("{:%d.%m.%Y-%H:%M:%S}", fmt::localtime(now));
44 
45  CSVWriter csv_writer(
46  params.output_dir_path / "statistics" /
47  (filename_prefix + (filename_prefix.empty() ? "" : "_") + "performance_data_" + formatted_time + ".csv"),
48  {"num_particles", "particle_container", "delta_t", "total_time[s]", "particle_updates_per_second[1/s]", "total_iterations"}, false);
49 
50  // find ParticleUpdateCounterInterceptor
51  auto particle_update_counter = std::find_if(params.interceptors.begin(), params.interceptors.end(), [](auto& interceptor) {
52  return std::dynamic_pointer_cast<ParticleUpdateCounterInterceptor>(interceptor) != nullptr;
53  });
54 
55  auto particle_updates_per_second =
56  particle_update_counter != params.interceptors.end()
58  std::dynamic_pointer_cast<ParticleUpdateCounterInterceptor>(*particle_update_counter)->getParticleUpdatesPerSecond())
59  : "N/A";
60 
61  std::string container_type_string = std::visit([](auto&& arg) { return std::string(arg); }, params.container_type);
62 
63  csv_writer.writeRow(
64  {params.num_particles, container_type_string, params.delta_t, total_time_seconds, particle_updates_per_second, total_iterations});
65 }
size_t num_particles
Number of particles in the simulation.
double delta_t
Time step of a single simulation iteration.
std::vector< std::shared_ptr< SimulationInterceptor > > interceptors
List of interceptors to be used in the simulation.
std::variant< DirectSumType, LinkedCellsType > container_type
Type of the particle container.
std::string to_string(const Container &container, const std::string &delimiter=", ", const std::array< std::string, 2 > &surround={"[", "]"})
Definition: ArrayUtils.h:97

Member Data Documentation

◆ interceptor_summaries

std::vector<std::string> SimulationOverview::interceptor_summaries

Summary of the interceptors that were used during the simulation.

Definition at line 33 of file SimulationOverview.h.

◆ params

const SimulationParams& SimulationOverview::params

Original simulation parameters bevore the simulation.

Definition at line 18 of file SimulationOverview.h.

◆ resulting_particles

std::vector<Particle> SimulationOverview::resulting_particles

Resulting particles after the simulation.

Definition at line 38 of file SimulationOverview.h.

◆ total_iterations

size_t SimulationOverview::total_iterations

Total number of iterations the simulation ran for (includes an initial force calculation)

Definition at line 28 of file SimulationOverview.h.

◆ total_time_seconds

double SimulationOverview::total_time_seconds

Total time the simulation took to execute in seconds (includes time for writing output files and logging)

Definition at line 23 of file SimulationOverview.h.


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