Skip to content

SiorMeir/NbodySim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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>
  1. Navigate to the project directory:
    cd nbodyproblem
  2. Install the required dependencies:
    pip install -r requirements.txt

Usage

Running the API

  1. Start the FastAPI server:
    uvicorn api:app --reload
  2. Access the API documentation at http://127.0.0.1:8000/docs.

API Endpoints

  • 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.

Example Request

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
}

Running the Simulation Script

  1. Execute the simulation script directly to visualize the results:
    python nbodyproblem/solver.py

Project Structure

  • 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.

Dependencies

  • FastAPI
  • Pydantic
  • Matplotlib
  • NumPy
  • Pandas
  • SciPy

Contributing

Contributions are welcome! Please fork the repository and submit a pull request for review.

License

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published