How franciszekcieslik/classical-mechanics-simulator-in-2d works
Project type and purpose
• This is a desktop‐based 2D classical mechanics simulator written in Python.
• It provides an interactive GUI for users to define forces and velocities, runs a physics simulation loop, renders trajectories in real time, and persists experiment data to local JSON files.
File structure
• Top-level modules:
• app/main.py → application entry point and orchestrator
• app/app.py → application class that initializes subsystems (GUI, simulation loop, file I/O)
• Core directories:
• app/obj → all physics, rendering, GUI helper classes, managers
• app/local_save → JSON files for saved experiments
• Within app/obj you see subpackages for:
– guielements (sidebar, inputs, buttons)
– managers (ForceManager, VectorManager, ObjectsManager, SaveManager, etc.)
– core models (PhysicObject, RealObject, Trajectory)
README for additional insights
• Implements an extendable, interactive simulation with clear visualization
• Uses JSON for configuration and persistence
• Targets Python 3.9+ with pip‐installable requirements
a. Application Controller (app/main.py → app/app.py)
b. GUI Module (app/obj/guielements + renderer classes in app/obj/drawn)
c. Physics Simulation Engine (ForceManager, VectorManager, ObjectsManager, Trajectory)
e. Persistence Layer (SaveManager + local_save JSON storage)
g. External environment (Python runtime, optional Git for install)
Relationships and interactions
• User events → GUI Module → Controller
• Controller schedules Simulation Engine updates on tick
• Simulation Engine updates model state → passes updated state to Rendering Engine
• Rendering Engine draws on canvas via GUI Module
• Persistence Layer reads/writes model state to JSON when user saves/loads
Architectural patterns and principles
• MVC‐like separation:
• Model = physics objects & state managers
• Controller = app/app.py + event handlers in guielements → drives simulation loop
• Single responsibility: each manager class handles one concern (forces, objects, I/O)
Relevant technologies and frameworks
• Python 3.9+
• JSON for data persistence
• Standard library (dataclasses, tkinter or similar GUI bindings)
• Project uses pyproject.toml and requirements.txt for dependency management
Detail level
• Avoid over‐abstraction—show actual modules where business logic resides.