This project implements a numerical simulation of an expanding universe based on the Friedmann-Lemaître equations. It allows exploring various cosmological parameters (Ω_m, Ω_Λ, etc.) and visualizing the evolution of the scale factor, energy densities, and other cosmological quantities.
- Numerical solutions to the Friedmann equations with customizable cosmological parameters
- Visualization of scale factor evolution over time
- Analysis of energy density components (matter, radiation, dark energy)
- Calculation of observable cosmological quantities (distances, lookback time, etc.)
- Interactive exploration via Jupyter notebooks
- Analytical solutions for special cases (matter-dominated, radiation-dominated, etc.)
- Phase space diagram for different cosmological parameters
- Python 3.8+
- NumPy
- SciPy
- Matplotlib
- SymPy
- Jupyter (for interactive notebooks)
src/
: Source code modulesfriedmann_universe.py
: Core implementation of the Friedmann equationsanalytical_solutions.py
: Analytical solutions for special casesobservables.py
: Calculation of observable cosmological quantitiesvisualizations.py
: Advanced visualization functions
data/
: Data files (if any)results/
: Output files and generated plotstests/
: Test modulesnotebooks/
: Jupyter notebooks for interactive exploration
- Clone this repository:
git clone https://github.com/yourusername/expanding-universe-simulation.git
cd expanding-universe-simulation
- Create a virtual environment:
python -m venv venv
- Activate the virtual environment:
# On Windows:
.\venv\Scripts\activate
# On Unix or MacOS:
source venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
python main.py
This will run the simulation with default parameters and generate plots in the results/
directory.
Launch Jupyter Notebook:
jupyter notebook notebooks/interactive_exploration.ipynb
This notebook provides interactive sliders to explore different cosmological parameters and visualize their effects.
from src.friedmann_universe import FriedmannUniverse
# Create a universe model with custom parameters
my_universe = FriedmannUniverse(
omega_m=0.3, # Matter density parameter
omega_lambda=0.7, # Dark energy density parameter
omega_r=8.4e-5, # Radiation density parameter
omega_k=0.0, # Curvature density parameter
H0=70.0 # Hubble parameter (km/s/Mpc)
)
# Solve for the scale factor evolution
t, a, da_dt = my_universe.solve_evolution(t_span=(0, 20), t_points=500)
# Plot the results
my_universe.plot_scale_factor(t, a, save_path="results/my_universe_scale_factor.png")
from src.friedmann_universe import FriedmannUniverse
from src.observables import CosmologicalObservables
# Create a standard ΛCDM model
universe = FriedmannUniverse(omega_m=0.3, omega_lambda=0.7)
# Create observables calculator
observables = CosmologicalObservables(universe)
# Calculate the age of the universe
age = observables.age()
print(f"Age of the universe: {age:.2f} Gyr")
# Calculate the luminosity distance to a redshift z=1
d_L = observables.luminosity_distance(1.0)
print(f"Luminosity distance to z=1: {d_L:.1f} Mpc")
The Friedmann equations describe how a universe expands or contracts with time under different cosmological parameters. The first Friedmann equation relates the expansion rate to the energy density:
Where:
-
$a(t)$ is the scale factor -
$H(t)$ is the Hubble parameter -
$\rho$ is the energy density -
$k$ is the curvature parameter -
$\Lambda$ is the cosmological constant -
$G$ is the gravitational constant -
$c$ is the speed of light
The second Friedmann equation describes the acceleration of the expansion:
Where
MIT License
This project is created for educational purposes to study cosmology and numerical methods in astrophysics.
- Friedmann, A. (1922). "Über die Krümmung des Raumes". Zeitschrift für Physik. 10 (1): 377–386.
- Lemaître, G. (1927). "Un Univers homogène de masse constante et de rayon croissant rendant compte de la vitesse radiale des nébuleuses extra-galactiques". Annales de la Société Scientifique de Bruxelles. A47: 49–59.
- Weinberg, S. (2008). "Cosmology". Oxford University Press.
- Ryden, B. (2017). "Introduction to Cosmology". Cambridge University Press.