How minhnvm2307/kepler-equation works
The Kepler Equation Solver project is a compact Python-based tool whose primary purpose is to compute the eccentric anomaly (E) of a planet in an elliptical orbit, given the mean anomaly (M) and eccentricity (e). It implements three well-known numerical methods (Newton-Raphson, Secant, and Binary Search) and visualizes the orbit through plotting, making it a computational and visualization tool rather than a full-stack or multi-tier web application.
Main Components
• Entry Point (main.py): Represents the starting point of the application. This module is responsible for reading inputs (such as e and M), orchestrating the computation by calling the appropriate numerical method, and triggering plotting.
• Numerical Methods (methods.py): Contains the implementations of the three algorithms:
• Newton-Raphson
• Secant
• Binary (Bisection) Method
This component encapsulates the core computational logic.
• Utility Functions (utils.py): Likely provides shared routines such as preprocessing input values, error checking, or additional helper methods for plotting or formatting output.
• Plotting/Visualization: Although not a separate file, the code integrates with external libraries (matplotlib and numpy) to produce orbit graphs which are stored or referenced in the img directory.
Relationships and Interactions
• The main.py module acts as the central coordinator. It gathers user parameters, then:
• Calls numerical methods from methods.py to solve the Kepler Equation.
• Uses functions from utils.py for any supplementary tasks (for example, data parsing, formatting, or interfacing with matplotlib).
• The numerical methods in methods.py perform iterative calculations and provide computed results.
• After computation, control is passed back to main.py to handle visualization; here, matplotlib and numpy are used to render plots and save or display orbit images (as seen in the img folder).
Architectural Patterns and Design Principles
• Separation of Concerns: The program cleanly separates its core functionalities—input handling (main.py), computation (methods.py), and auxiliary functions (utils.py). This modular design ensures ease of maintenance and straightforward testing.
• Procedural Structure: Given the relatively small codebase, the design focuses on procedural decomposition, with each script handling a specific set of tasks.
• Extensibility: Clear division allows for future expansion (for instance, adding more solution methods or enhancing the visualization module).