Orrery
A GPU-accelerated N-body gravitational simulator
Loading...
Searching...
No Matches
configuration.hpp
Go to the documentation of this file.
1#pragma once
2
37
38#include <cstdint>
39#include <optional>
40#include <string>
41#include <string_view>
42#include <vector>
43
44#include "orrery/core/types.hpp"
45
46namespace orrery::sim {
47
56enum class SolverKind : std::uint8_t {
57 kDirect,
58 kBarnesHut,
59 kSyclDirect,
60 kSyclTree,
61};
62
64enum class IntegratorKind : std::uint8_t {
65 kVelocityVerlet,
66 kYoshida4,
67 kRungeKutta4,
68};
69
71enum class InitialConditionKind : std::uint8_t {
72 kPlummer,
73 kUniformSphere,
74 kKepler,
75 kDiscGalaxy,
76 kGalaxyCollision,
77};
78
84enum class ExecutorKind : std::uint8_t {
85 kSerial,
86 kStatic,
87 kWorkStealing,
88};
89
95[[nodiscard]] std::string_view to_string(SolverKind kind) noexcept;
96[[nodiscard]] std::string_view to_string(IntegratorKind kind) noexcept;
97[[nodiscard]] std::string_view to_string(InitialConditionKind kind) noexcept;
98[[nodiscard]] std::string_view to_string(ExecutorKind kind) noexcept;
99
105[[nodiscard]] std::optional<SolverKind> parse_solver_kind(std::string_view text) noexcept;
106[[nodiscard]] std::optional<IntegratorKind> parse_integrator_kind(std::string_view text) noexcept;
107[[nodiscard]] std::optional<InitialConditionKind>
108parse_initial_condition_kind(std::string_view text) noexcept;
109[[nodiscard]] std::optional<ExecutorKind> parse_executor_kind(std::string_view text) noexcept;
110
113[[nodiscard]] std::string solver_kind_names();
114[[nodiscard]] std::string integrator_kind_names();
115[[nodiscard]] std::string initial_condition_kind_names();
116[[nodiscard]] std::string executor_kind_names();
117
126 core::Real timestep = 0;
127
130
136 std::uint64_t seed = 0;
137
138 [[nodiscard]] friend bool operator==(const RunSettings&, const RunSettings&) = default;
139};
140
157 InitialConditionKind kind = InitialConditionKind::kPlummer;
158
163
165 core::Real total_mass = 1;
166
170 core::Real scale_radius = 0;
171
173 core::Real radius = 1;
174
176 core::Real mass_fraction_cutoff = static_cast<core::Real>(0.999);
177
179 core::Real primary_mass = 1;
180 core::Real secondary_mass = 1;
181
182 core::Real semi_major_axis = 1;
183 core::Real eccentricity = 0;
184
191 core::Real bulge_fraction = static_cast<core::Real>(0.2);
192
194 core::Real scale_length = 1;
195
196 core::Real scale_height = static_cast<core::Real>(0.1);
197
199 core::Real bulge_radius = static_cast<core::Real>(0.2);
200
203 core::Real inclination = 0;
204 core::Real position_angle = 0;
205
212 core::Real mass_ratio = static_cast<core::Real>(0.5);
213
219 core::Real secondary_inclination = 1;
220 core::Real secondary_position_angle = 0;
221
224 core::Real separation = 20;
225 core::Real impact_parameter = 2;
226
229 core::Real approach_speed = static_cast<core::Real>(0.8);
230
231 [[nodiscard]] friend bool operator==(const InitialConditionSettings&,
232 const InitialConditionSettings&) = default;
233};
234
237 SolverKind kind = SolverKind::kBarnesHut;
238
247 core::Real softening = 0;
248
250 core::Real opening_angle = static_cast<core::Real>(0.5);
251
252 core::Index leaf_capacity = 32;
253
254 bool quadrupole = false;
255
256 ExecutorKind executor = ExecutorKind::kWorkStealing;
257
259 unsigned threads = 0;
260
271
272 [[nodiscard]] friend bool operator==(const SolverSettings&, const SolverSettings&) = default;
273};
274
280 IntegratorKind kind = IntegratorKind::kVelocityVerlet;
281
282 [[nodiscard]] friend bool operator==(const IntegratorSettings&,
283 const IntegratorSettings&) = default;
284};
285
296 std::string trajectory_path;
297
298 core::Index trajectory_stride = 0;
299
307
309 std::string diagnostics_path;
310
318
324 std::string checkpoint_path;
325
326 core::Index checkpoint_stride = 0;
327
328 [[nodiscard]] friend bool operator==(const OutputSettings&, const OutputSettings&) = default;
329};
330
333 RunSettings run;
334 InitialConditionSettings initial_conditions;
335 SolverSettings solver;
336 IntegratorSettings integrator;
337 OutputSettings output;
338
339 [[nodiscard]] friend bool operator==(const Configuration&, const Configuration&) = default;
340};
341
353[[nodiscard]] std::vector<std::string> problems_with(const Configuration& configuration);
354
364[[nodiscard]] core::Real resolved_scale_radius(const InitialConditionSettings& settings) noexcept;
365
366} // namespace orrery::sim
std::string solver_kind_names()
Every spelling each enumeration accepts, for the help text and for the error message that lists the a...
std::optional< SolverKind > parse_solver_kind(std::string_view text) noexcept
The inverse of the above, empty for a word that names nothing.
core::Real resolved_scale_radius(const InitialConditionSettings &settings) noexcept
The scale radius the Plummer sampler will actually use.
InitialConditionKind
Which configuration the run starts from.
Definition configuration.hpp:71
SolverKind
Which force solver computes the accelerations.
Definition configuration.hpp:56
IntegratorKind
Which integrator advances the state.
Definition configuration.hpp:64
ExecutorKind
How the CPU solvers divide their loop over target particles.
Definition configuration.hpp:84
std::string_view to_string(SolverKind kind) noexcept
The spelling each of the above has in a configuration file.
std::vector< std::string > problems_with(const Configuration &configuration)
Every objection to configuration, in the order the fields appear.
A whole run, as data.
Definition configuration.hpp:332
What the run starts from.
Definition configuration.hpp:156
core::Real inclination
The tilt of the disc's spin axis away from the z axis, in radians, and the angle it is then turned by...
Definition configuration.hpp:203
core::Real radius
The radius of the uniform sphere.
Definition configuration.hpp:173
core::Real primary_mass
The two masses of the Kepler configuration.
Definition configuration.hpp:179
core::Real scale_length
The exponential scale length of the disc.
Definition configuration.hpp:194
core::Index count
The number of particles, for the two sampled models.
Definition configuration.hpp:162
core::Real approach_speed
The relative speed of the two galaxies, as a multiple of the escape speed at their initial separation...
Definition configuration.hpp:229
core::Real separation
The initial separation of the two galaxies along the x axis, and the offset along y that makes the en...
Definition configuration.hpp:224
core::Real total_mass
Shared equally among the particles of a sampled model.
Definition configuration.hpp:165
core::Real mass_fraction_cutoff
The fraction of a Plummer model's mass the sample is drawn from.
Definition configuration.hpp:176
core::Real bulge_radius
The Plummer scale radius of the bulge.
Definition configuration.hpp:199
core::Real mass_ratio
The mass of the second galaxy of a collision as a fraction of the first.
Definition configuration.hpp:212
core::Real secondary_inclination
The orientation of the second galaxy's disc.
Definition configuration.hpp:219
core::Real scale_radius
The Plummer scale radius.
Definition configuration.hpp:170
core::Real bulge_fraction
The share of a galaxy's mass held by its bulge rather than its disc.
Definition configuration.hpp:191
Definition configuration.hpp:275
IntegratorKind kind
Velocity Verlet by default, on ADR-0011's argument: one force evaluation per step and an energy error...
Definition configuration.hpp:280
What the run writes down, and how often.
Definition configuration.hpp:293
bool trajectory_velocities
Whether trajectory frames carry velocities as well as positions.
Definition configuration.hpp:306
std::string checkpoint_path
Where checkpoints go, if any.
Definition configuration.hpp:324
core::Index diagnostics_stride
How often the conserved quantities are measured, in steps.
Definition configuration.hpp:317
std::string trajectory_path
Where the binary trajectory goes.
Definition configuration.hpp:296
std::string diagnostics_path
Where the CSV diagnostics stream goes.
Definition configuration.hpp:309
How far to go, and from what stream of random numbers.
Definition configuration.hpp:119
std::uint64_t seed
The seed for the sampler that draws the initial conditions.
Definition configuration.hpp:136
core::Index steps
How many steps to take.
Definition configuration.hpp:129
core::Real timestep
The interval of simulated time one step covers.
Definition configuration.hpp:126
Which solver, and the parameters that decide what it computes.
Definition configuration.hpp:236
unsigned threads
How many workers the executor runs with. Zero means one per core.
Definition configuration.hpp:259
bool allow_cpu_fallback
Whether a run may fall back to the CPU when the GPU it asked for is absent.
Definition configuration.hpp:270
core::Real opening_angle
The Barnes-Hut opening angle, ignored by the direct solvers.
Definition configuration.hpp:250
core::Real softening
The Plummer softening length, in the units of the configuration.
Definition configuration.hpp:247
The scalar and index types that every layer of the project agrees on.
std::size_t Index
The type of a particle index and of any count of particles.
Definition types.hpp:45