Config

Provides a centralised, immutable container for all simulation parameters.
- module:
config
- author:
Le Bars, Yoann
- class src.config.SimulationConfig(n_iter: int, n_bodies: int, dens: float, universal_g: float, epsilon: float, seed: int, log_freq: int, target_dx: float = 0.01, max_dt: float = 0.01, dt_damping_factor: float = 0.1, coeff_restitution: float = 0.1, coeff_friction: float = 0.6, positional_correction_factor: float = 0.2, coeff_static_friction: float = 0.8, linear_damping: float = 0.005, angular_damping: float = 0.005, show_torque_arrow: bool = False, show_alpha_arrow: bool = False)[source]
Bases:
objectA centralised, immutable container for all simulation parameters.
This object is created from command-line arguments and passed to the simulation engine, decoupling the core logic from argument parsing. The frozen=True attribute makes instances of this class immutable, preventing accidental modification of parameters during the simulation.
- Variables:
n_iter (int) – Number of simulation iterations.
n_bodies (int) – Number of bodies to simulate.
dens (float) – Density of the bodies.
universal_g (float) – Universal gravitational constant.
epsilon (float) – Softening factor for force calculations.
seed (int) – Seed for random number generation.
log_freq (int) – Frequency of energy log output.
target_dx (float) – Heuristic for adaptive time-stepping.
max_dt (float) – Maximum allowed time step.
dt_damping_factor (float) – Damping factor for time step smoothing.
coeff_restitution (float) – Coefficient of restitution for collisions.
coeff_friction (float) – Coefficient of kinetic friction.
positional_correction_factor (float) – Factor for Baumgarte stabilisation.
coeff_static_friction (float) – Coefficient of static friction.
linear_damping (float) – Damping factor for linear velocity.
angular_damping (float) – Damping factor for angular velocity.
- angular_damping: float = 0.005
- coeff_friction: float = 0.6
- coeff_restitution: float = 0.1
- coeff_static_friction: float = 0.8
- dens: float
- dt_damping_factor: float = 0.1
- epsilon: float
- classmethod from_args(args: CmdLineArgs) SimulationConfig[source]
Factory method to create a SimulationConfig instance from parsed command-line arguments.
- Parameters:
args (CmdLineArgs) – The parsed command-line arguments.
- Returns:
An initialised SimulationConfig object.
- Return type:
‘SimulationConfig’
- linear_damping: float = 0.005
- log_freq: int
- max_dt: float = 0.01
- n_bodies: int
- n_iter: int
- positional_correction_factor: float = 0.2
- seed: int
- show_alpha_arrow: bool = False
- show_torque_arrow: bool = False
- target_dx: float = 0.01
- universal_g: float