pure-cpp 1.0.0
A C++ physics simulation benchmark comparing performance with Python implementations
constants.hpp
Go to the documentation of this file.
1#ifndef CONSTANTS_HPP
2#define CONSTANTS_HPP
3
4/**
5 * \file constants.hpp
6 * \brief Constants for the model.
7 * \author Le Bars, Yoann
8 *
9 * This file is part of the pure C++ benchmark.
10 *
11 * This program is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the Free
13 * Software Foundation, either version 3 of the License, or (at your option)
14 * any later version.
15 *
16 * This program is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 * more details.
20 *
21 * You should have received a copy of the GNU General Public License along with
22 * this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
25/**
26 * \brief Contains all classes and constants for the core physics simulation.
27 * \defgroup ModelConstants Simulation Constants
28 * @{
29 */
30namespace Model {
31 /// \brief Default computing precision value.
32 constexpr double EPSILON = 1e-6;
33
34 /// \brief Default universal gravitational constant (in m³⋅kg⁻¹⋅s⁻²).
35 constexpr double G = 6.67430e-11;
36
37 /// \brief Heuristic for the maximum distance a body should travel in one
38 /// step, used for adaptive time stepping.
39 constexpr double TARGET_DX = 0.01;
40
41 /// \brief Maximum time step allowed for the simulation to ensure stability.
42 constexpr double MAX_DT = 0.01;
43
44 /// \brief Coefficient of restitution for collisions (e.g., 0.8 for a very
45 /// bouncy ball).
46 constexpr double COEFF_RESTITUTION = 0.1;
47
48 /// \brief Coefficient of static friction.
49 constexpr double COEFF_STATIC_FRICTION = 0.8;
50
51 /// \brief Coefficient of kinetic (sliding) friction, also known as dynamic
52 /// friction.
53 constexpr double COEFF_FRICTION = 0.6;
54
55 /// \brief Damping factor for smoothing adaptive time step changes.
56 constexpr double DT_DAMPING_FACTOR = 0.1;
57
58 /// \brief The percentage of overlap to correct per frame (Baumgarte
59 /// stabilisation).
60 constexpr double POSITIONAL_CORRECTION_FACTOR = 0.2;
61
62 /// \brief Damping factor for linear velocity.
63 constexpr double LINEAR_DAMPING = 0.005;
64
65 /// \brief Damping factor for angular velocity.
66 constexpr double ANGULAR_DAMPING = 0.005;
67
68 /// \brief Default frequency for logging system energy.
69 constexpr int DEFAULT_LOG_FREQ = 100;
70
71 // --- Initial Conditions ---
72 /// \brief Minimum mass for randomly generated bodies.
73 constexpr double MIN_BODY_MASS = 25.0;
74
75 /// \brief Maximum mass for randomly generated bodies.
76 constexpr double MAX_BODY_MASS = 75.0;
77
78 /// \brief Minimum initial velocity component for randomly generated bodies.
79 constexpr double MIN_INITIAL_VELOCITY = -5.0;
80
81 /// \brief Maximum initial velocity component for randomly generated bodies.
82 constexpr double MAX_INITIAL_VELOCITY = 5.0;
83
84 /// \brief Maximum initial angular velocity component for randomly generated
85 /// bodies (in rad/s).
86 constexpr double MAX_INITIAL_ANGULAR_VELOCITY = 0.5;
87
88 /// \brief Heuristic scaling factor for the initial placement volume of
89 /// bodies.
90 constexpr double PLACEMENT_SCALE_FACTOR = 4.0;
91
92 /// \brief The number of "settling" steps to run at the start of the
93 /// simulation.
94 constexpr int SETTLING_STEPS = 5;
95
96 // --- UI and Visualization ---
97 /// \brief Scaling factor for the length of the torque visualization arrow.
98 constexpr double TORQUE_ARROW_SCALE = 0.1;
99
100 /// \brief Scaling factor for the length of the angular acceleration arrow.
101 constexpr double ALPHA_ARROW_SCALE = 1.0;
102}
103/** @} */
104
105#endif // CONSTANTS_HPP
constexpr double TORQUE_ARROW_SCALE
Scaling factor for the length of the torque visualization arrow.
Definition: constants.hpp:98
constexpr double EPSILON
Default computing precision value.
Definition: constants.hpp:32
constexpr double ALPHA_ARROW_SCALE
Scaling factor for the length of the angular acceleration arrow.
Definition: constants.hpp:101
constexpr double MIN_BODY_MASS
Minimum mass for randomly generated bodies.
Definition: constants.hpp:73
constexpr int DEFAULT_LOG_FREQ
Default frequency for logging system energy.
Definition: constants.hpp:69
constexpr double MIN_INITIAL_VELOCITY
Minimum initial velocity component for randomly generated bodies.
Definition: constants.hpp:79
constexpr double MAX_BODY_MASS
Maximum mass for randomly generated bodies.
Definition: constants.hpp:76
constexpr double G
Default universal gravitational constant (in m³⋅kg⁻¹⋅s⁻²).
Definition: constants.hpp:35
constexpr double COEFF_FRICTION
Coefficient of kinetic (sliding) friction, also known as dynamic friction.
Definition: constants.hpp:53
constexpr double TARGET_DX
Heuristic for the maximum distance a body should travel in one step, used for adaptive time stepping.
Definition: constants.hpp:39
constexpr double LINEAR_DAMPING
Damping factor for linear velocity.
Definition: constants.hpp:63
constexpr double PLACEMENT_SCALE_FACTOR
Heuristic scaling factor for the initial placement volume of bodies.
Definition: constants.hpp:90
constexpr double MAX_INITIAL_VELOCITY
Maximum initial velocity component for randomly generated bodies.
Definition: constants.hpp:82
constexpr double ANGULAR_DAMPING
Damping factor for angular velocity.
Definition: constants.hpp:66
constexpr double COEFF_STATIC_FRICTION
Coefficient of static friction.
Definition: constants.hpp:49
constexpr double POSITIONAL_CORRECTION_FACTOR
The percentage of overlap to correct per frame (Baumgarte stabilisation).
Definition: constants.hpp:60
constexpr double DT_DAMPING_FACTOR
Damping factor for smoothing adaptive time step changes.
Definition: constants.hpp:56
constexpr double MAX_INITIAL_ANGULAR_VELOCITY
Maximum initial angular velocity component for randomly generated bodies (in rad/s).
Definition: constants.hpp:86
constexpr int SETTLING_STEPS
The number of "settling" steps to run at the start of the simulation.
Definition: constants.hpp:94
constexpr double COEFF_RESTITUTION
Coefficient of restitution for collisions (e.g., 0.8 for a very bouncy ball).
Definition: constants.hpp:46
constexpr double MAX_DT
Maximum time step allowed for the simulation to ensure stability.
Definition: constants.hpp:42