Solutions to the problem sets from Binney & Tremaine's Galactic Dynamics (2nd Edition). This repository contains Python implementations of numerical solutions, leveraging libraries such as NumPy, SciPy, and Matplotlib for efficient computation and visualization.
This project provides detailed solutions to problems from the seminal textbook Galactic Dynamics by James Binney and Scott Tremaine (2nd Edition, 2008). The solutions are implemented in Python and organized by chapter, featuring:
- Analytical derivations with step-by-step mathematical explanations
- Numerical implementations using modern Python scientific computing stack
- Visualizations with publication-quality plots
- Interactive documentation with mathematical formulas and figures (https://caverac.github.io/galactic-dynamics-bt/)
- Python 3.12 or higher
- uv package manager (recommended) or pip
-
Clone the repository:
git clone https://github.com/caverac/galactic-dynamics-bt.git cd galactic-dynamics-bt -
Install dependencies using uv:
uv sync
Or using pip:
pip install -e .
Generate figures and run solutions:
# Generate plots for Chapter 1
uv run python scripts/generate_assets.py
# Run all tests
uv run pytest
# Build documentation
uv run mkdocs serve
# Build documentation - live
uv run mkdocs serve --livereloadThe complete documentation with mathematical derivations, figures, and code explanations is available at:
https://caverac.github.io/galactic-dynamics-bt/
To build and serve the documentation locally:
uv run mkdocs serveThen open http://localhost:8000 in your browser.
galactic-dynamics-bt/
βββ docs/ # Documentation source
β βββ assets/ # Generated figures and images
β βββ chapterX.md # Chapter X solutions
β βββ index.md # Homepage
βββ galactic-dynamics-bt/ # Source code
β βββ chapterX/ # Chapter X implementations
β βββ y.py # Implementation for problem y
βββ tests/ # Test suite
β βββ unit/ # Unit tests
βββ scripts/ # Utility scripts
βββ main.py # MkDocs macro definitions
βββ pyproject.toml # Project configuration
βββ mkdocs.yml # Documentation configuration
- Problem 1.1: Perihelion precession in constant density background
- Problem 1.11: FRW cosmological models and universe boundaries
- More solutions coming soon...
-
Install development dependencies:
uv sync --group dev
-
Install pre-commit hooks:
uv run pre-commit install
-
Run code quality checks:
# Format code uv run black src tests # Lint code uv run flake8 src # Type checking uv run mypy src # Run tests uv run pytest
This project uses Commitizen for semantic versioning:
# Bump version and create changelog
uv run cz bump
# Push changes and tags
git push --follow-tagsWe welcome contributions! Please see CONTRIBUTING.md for detailed guidelines on:
- Setting up the development environment
- Code style and quality standards
- Submitting pull requests
- Adding new problem solutions
This project is licensed under the MIT License - see the LICENSE.md file for details.
- Solutions for Chapter 1: Introduction
- Solutions for Chapter 2: Potential Theory
- Solutions for Chapter 3: The Orbits of Stars
- Solutions for Chapter 4: Equilibria of Collisionless Systems
- Solutions for Chapter 5: Stability of Collisionless Systems
- Solutions for Chapter 6: Disk Dynamics and Spiral Structure
- Solutions for Chapter 7: Kinetic Theory
- Solutions for Chapter 8: Collisions and Encounters of Stellar Systems
- Solutions for Chapter 9: Galaxy Formation
- Interactive Jupyter notebooks
- 3D visualizations for orbital mechanics
- Animation support for time-dependent solutions
Carlos Vera-Ciro - [email protected]
Project Link: https://github.com/caverac/galactic-dynamics-bt
- James Binney and Scott Tremaine for their excellent textbook Galactic Dynamics
- The Python scientific computing community for the amazing tools
- Contributors and users of this repository
Binney, J., & Tremaine, S. (2008). Galactic Dynamics (2nd ed.). Princeton University Press.