Here's a draft for the `README.md` file for your project:
```markdown
# N-Body Problem Simulation
This project simulates the gravitational interactions between multiple celestial bodies using the n-body problem framework. It provides an API for users to input initial conditions and retrieve simulation results, along with visualization tools to display these results.
## Features
- **API Interface**: Built with FastAPI, allowing users to interact with the simulation engine.
- **Simulation Engine**: Models gravitational interactions using classical physics principles.
- **Visualization**: Uses Matplotlib to animate and visualize the simulation results.
## Installation
1. Clone the repository:
```bash
git clone <repository-url>
- Navigate to the project directory:
cd nbodyproblem
- Install the required dependencies:
pip install -r requirements.txt
- Start the FastAPI server:
uvicorn api:app --reload
- Access the API documentation at
http://127.0.0.1:8000/docs
.
- GET /: Returns a welcome message.
- POST /simulate: Accepts a list of celestial bodies, an end time, and a time step to perform the simulation. Returns the simulation results as a JSON object.
POST /simulate
{
"bodies": [
{
"name": "Earth",
"mass": 5.972e24,
"position": [1.496e11, 0],
"velocity": [0, 29780]
},
{
"name": "Sun",
"mass": 1.989e30,
"position": [0, 0],
"velocity": [0, 0]
}
],
"endtime": 31536000,
"timestep": 604800
}
- Execute the simulation script directly to visualize the results:
python nbodyproblem/solver.py
- api.py: Contains the FastAPI application and endpoint definitions.
- nbodyproblem/solver.py: Implements the core simulation logic and visualization.
- nbodyproblem/models: Contains data models for celestial bodies and time series.
- FastAPI
- Pydantic
- Matplotlib
- NumPy
- Pandas
- SciPy
Contributions are welcome! Please fork the repository and submit a pull request for review.
This project is licensed under the MIT License. See the LICENSE file for details.
This README provides an overview of the project's purpose, features, installation instructions, usage examples, and project structure. Adjust the `<repository-url>` placeholder with your actual repository URL.