Metadata-Version: 2.4
Name: grav_sim
Version: 1.0.0
Summary: Gravity Simulator
Author-email: Ching-Yin Ng <alvinng324@gmail.com>
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: matplotlib>=3.8.3
Requires-Dist: numpy>=1.26.4
Requires-Dist: h5py>=3.0.0
Requires-Dist: cmake>=3.10.0
Provides-Extra: dev
Requires-Dist: ruff; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Dynamic: license-file

# grav_sim

N-body gravity simulation library with C and Python API

Project Homepage and documentations: https://alvinng4.github.io/grav_sim/

**Target Audience:**

* Physics students
* Anyone interested in N-body simulations

**Features:**

* Ten integrators including WHFast and IAS15
* Barnes-Hut algorithm with linear octree
* Particle-Mesh method for cosmological structure formation
* Multiple sample projects

## 5 steps to N-body simulation

A short course to teach beginners how to write fast and clean N-body gravity simulations code in Python.

Homepage: https://alvinng4.github.io/grav_sim/5_steps_to_n_body_simulation/

**Contents**

- [Step 1: Initial setup](5_steps_to_n_body_simulation/step1.md)
- [Step 2: Gravity](5_steps_to_n_body_simulation/step2.md)
- [Step 3: Your first N-body program](5_steps_to_n_body_simulation/step3.md)
- [Step 4: Higher-order algorithms](5_steps_to_n_body_simulation/step4.md)
- [Step 5: Adaptive time-stepping](5_steps_to_n_body_simulation/step5.md)
- [Extra: Plotting and animation](5_steps_to_n_body_simulation/extra.md)
- [Conclusion and Final Project](5_steps_to_n_body_simulation/conclusion.md)

<img src="./examples/media/solar_plus_3d.png" alt="Image" width="300">
<img src="./examples/media/rel_energy.png" alt="Image" width="300">

## Sample projects

### Evolving the solar system for 1 million years

<img src="./examples/media/eccentricity.png" alt="Image" width="300">
<img src="./examples/media/inclination.png" alt="Image" width="300">

### Asteroid belt animation

[![Asteroid belt animation 0](https://img.youtube.com/vi/C45ceYja0jE/0.jpg)](https://www.youtube.com/watch?v=C45ceYja0jE)  
[![Asteroid belt animation 1](https://img.youtube.com/vi/eg7plHjP1eg/0.jpg)](https://www.youtube.com/watch?v=eg7plHjP1eg)  
[![Asteroid belt animation 2](https://img.youtube.com/vi/HMv7OwqAmBY/0.jpg)](https://www.youtube.com/watch?v=HMv7OwqAmBY)

### Formation of Kirkwood gaps

[![Kirkwood gaps 1](https://img.youtube.com/vi/AEyjIF-8zT0/0.jpg)](https://www.youtube.com/watch?v=AEyjIF-8zT0)  
[![Kirkwood gaps 2](https://img.youtube.com/vi/jHLLr7ACvDQ/0.jpg)](https://www.youtube.com/watch?v=jHLLr7ACvDQ)

### Galaxy collision

[![Galaxy collision](https://img.youtube.com/vi/nXTUdjLXwtI/0.jpg)](https://www.youtube.com/watch?v=nXTUdjLXwtI)

### Cosmological structure formation

[![Cosmological structure formation](https://img.youtube.com/vi/yof2x_0IeOA/0.jpg)](https://www.youtube.com/watch?v=yof2x_0IeOA)

## Feedback and Bugs
If you found any bugs or want to leave some feedback, please feel free to let me know by opening an issue or sending an email to alvinng324(at)gmail.com.
