3 #include <spdlog/fmt/chrono.h>
27 std::make_unique<LinkedCellsContainer>(lc_type.domain_size, lc_type.cutoff_radius, lc_type.boundary_conditions);
31 throw std::runtime_error(
"Unknown container type");
36 for (
auto& particle : initial_particles) {
55 std::time_t t_start_helper = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
56 Logger::logger->info(
"Start time: {}", fmt::format(
"{:%A %Y-%m-%d %H:%M:%S}", fmt::localtime(t_start_helper)));
60 (*interceptor).onSimulationStart(*
this);
63 auto t_start = std::chrono::high_resolution_clock::now();
74 (*interceptor).notify(iteration, *
this);
78 auto t_end = std::chrono::high_resolution_clock::now();
82 (*interceptor).onSimulationEnd(iteration, *
this);
86 Logger::logger->info(
"End time: {}", fmt::format(
"{:%A %Y-%m-%d %H:%M:%S}", fmt::localtime(t_end)));
88 std::vector<std::string> interceptor_summaries;
90 auto summary = std::string(*interceptor);
91 if (!summary.empty()) {
92 interceptor_summaries.push_back(summary);
96 auto total_time_ms = std::chrono::duration_cast<std::chrono::milliseconds>(t_end - t_start).count();
std::unique_ptr< IntegrationFunctor > get_integration_functor(IntegrationMethod method)
Returns the corresponding integration functor for the given integration method.
IntegrationMethod
Enum class to specify the integration method.
static std::shared_ptr< spdlog::logger > logger
Publically accessible shared pointer to the logger.
Class to store some overview data of an executed simulation.
Contains all parameters needed to run a simulation.
std::vector< std::shared_ptr< PairwiseForceSource > > pairwise_forces
Pairwise Forces to be applied to the particles.
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.
size_t start_iteration
Start iteration of the simulation.
std::vector< std::shared_ptr< SimpleForceSource > > simple_forces
Simple Forces to be applied to the particles.
std::vector< std::shared_ptr< TargettedForceSource > > targetted_forces
Targetted Forces to be applied to the particles.
std::variant< DirectSumType, LinkedCellsType > container_type
Type of the particle container.
double end_time
End time of the simulation.
Simulation(const std::vector< Particle > &particles, const SimulationParams ¶ms, IntegrationMethod integration_method=IntegrationMethod::VERLET)
Construct a new Simulation object and initialize all the necessary components.
std::unique_ptr< ParticleContainer > particle_container
Reference to the ParticleContainer on whose content the simulation is performed.
SimulationOverview runSimulation()
Runs the simulation, using the parameters given at construction and returns a SimulationOverview obje...
std::unique_ptr< IntegrationFunctor > integration_functor
Functor used to integrate the particles.
const SimulationParams & params
Reference to the simulation parameters object.