-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain_utils.h
88 lines (71 loc) · 2.58 KB
/
main_utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef MAIN_UTILS_H
#define MAIN_UTILS_H
#include "utils.h"
#include "spin.h"
#include "obs1.h"
#include "obs2.h"
/**
* The main_utils namespace provides an API for the entrypiont in main.cpp.
* This way everything can be properly scoped and organized. main.cpp will only
* call functions from this namespace.
*/
namespace main_utils
{
/**
* @brief [brief description]
* @details [long description]
*
* @param p [description]
*/
void simulation_parameters_from_disk_(utils::SimulationParameters* p);
/**
* @brief Completes the CLI-provided parameters
* @details The user has full control over almost every part of the simulation,
* but can optionally not provide explicit arguments for all of them. Additionally,
* some parameters are explicit functions of what the user provides. This method
* modifies the simulation parameters in-place.
*
* @param p Simulation parameters
*/
void update_parameters_(utils::SimulationParameters* p);
/**
* @brief Saves and logs the config file
* @details Given a SimulationParameters struct, this first converts the
* object to json format, then logs it (prints to std::cout), then saves it as
* config.json in the working directory.
*
* @param p Simulation parameters
*/
void save_and_log_config(const utils::SimulationParameters p);
/**
* @brief Initializes directories and the grid utility files
* @details hdspin requires an energy and "pi" grid. This function creates the
* data and grids directories, then populates the grid directory with the
* aforementioned files.
*
* @param p Simulation parameters
*/
void initialize_grids_and_directories(const utils::SimulationParameters p);
/**
* @brief Given "auto" as a dynamics type, automatically determines which
* dynamics will be faster (gillespie or standard)
* @details This is an MPI-aware function which uses all available tasks to get
* some lightweight statistics on which simulation dynamics will be faster.
* Specifically, it calculates the average walltime/simulation time (this is
* necessary since gillespie can, by design, sometimes overshoot the maximum
* simulation time). The faster simulator is then set in the simulation
* parameters in-place.
*
* @param p Simulation parameters
*/
void auto_determine_dynamics_(utils::SimulationParameters* params);
/**
* @brief Executes the simulation
* @details Utilizes a process pool: a single "master" controller dynamically
* allocates tasks to workers until the total number of simulations is complete.
*
* @param p Simulation parameters
*/
void execute_process_pool(const utils::SimulationParameters params);
}
#endif