Andam
A comprehensive Rust library for cosmological calculations and visualizations.
Andam (அண்டம்) means "universe" in தமிழ் (Tamil).
Features
Core Cosmology
- ΛCDM cosmology with Planck 2018 parameters
- Friedmann equation solver with multiple components
- Distance measures (luminosity, angular diameter, comoving)
- Universe age and evolution calculations
CMB Physics
- Recombination physics (Saha equation, Peebles evolution)
- Angular power spectrum (acoustic peaks)
- NEW: Polarization (E-mode and B-mode power spectra)
- NEW: Temperature-E cross-correlation
- NEW: Tensor-to-scalar ratio constraints
Structure Formation
- Linear matter power spectrum (Eisenstein-Hu transfer function)
- Non-linear power spectrum (HALOFIT)
- Halo mass functions (Press-Schechter, Sheth-Tormen, Tinker)
- Two-point correlation function and redshift-space distortions
- 3D cosmic web density field generation
- Growth factors and perturbation theory
Early Universe
- Big Bang Nucleosynthesis (BBN)
- Primordial element abundances (⁴He, D, ⁷Li)
- Neutron-proton freeze-out physics
Statistical Analysis
- NEW: MCMC parameter estimation (Metropolis-Hastings)
- NEW: Fisher information matrix forecasts
- NEW: Posterior distributions and confidence intervals
- NEW: Corner plots and parameter constraints
Beyond ΛCDM
- NEW: Dark energy models (w(z) parametrizations)
- NEW: CPL equation of state: w(a) = w₀ + wₐ(1-a)
- NEW: Massive neutrino cosmology
- NEW: Power spectrum suppression from neutrinos
- NEW: Model comparison tools
Visualization
- Publication-quality plots (up to 300 DPI)
- Static (PNG) and interactive (HTML) visualizations
- Corner plots for MCMC chains
- Multi-panel scientific figures
Quick Example
use Universe;
use luminosity_distance;
use *;
Installation
From crates.io
# Default installation (includes plotting)
# With static image export (requires network during build)
# With HDF5 storage support (requires HDF5 1.12 or earlier)
# Minimal installation (no plotting or HDF5)
# Everything (includes kaleido)
In Cargo.toml
[]
# Default (with plotting)
= "0.1.1"
# With HDF5 storage
= { = "0.1.1", = ["hdf5-storage"] }
# Minimal
= { = "0.1.1", = false }
# All features
= { = "0.1.1", = ["full"] }
From source
Feature Flags
| Feature | Description | Default | Dependencies |
|---|---|---|---|
plotting |
Visualization with plotly and plotters | Yes | plotly, plotters |
plotting-kaleido |
Add static image export (requires network during build) | No | plotly/kaleido |
hdf5-storage |
HDF5 data storage and retrieval | No | hdf5, flate2, chrono |
full |
All features enabled | No | All of the above |
Notes on Optional Features
HDF5 Storage:
- Requires HDF5 system library (1.12 or earlier for crates.io version)
- Not needed for most users (core functionality works without it)
- Can be enabled with
--features hdf5-storage - For HDF5 1.14+ support, see HDF5 Publishing Notes
Kaleido (Static Image Export):
- Required only for exporting plots as PNG/SVG/PDF
- Requires network access during build (downloads binaries)
- Not compatible with offline builds (e.g., docs.rs)
- Interactive HTML plots work without kaleido
- Enable with
--features plotting-kaleido
Documentation
- Quick Start - Get started in 5 minutes
- User Guide - Comprehensive documentation
- API Reference - Technical API details
- Project Overview - Architecture and roadmap
Implementation Summaries
Generate API docs: cargo doc --open
Examples
Run built-in examples:
Basic Cosmology (Phases 1-4)
Big Bang Nucleosynthesis (Phase 5)
Advanced Structure (Phase 6)
Statistical Analysis (Phase 7)
CMB Polarization (Phase 8)
Beyond ΛCDM (Phase 9)
Total: 15 examples covering all 9 implementation phases.
See examples/ directory for complete demonstration programs.
Testing
Status: All 60 tests passing
Project Structure
andam/
src/
constants.rs # Physical constants
units.rs # Unit conversions
dynamics/ # Universe evolution (Friedmann)
observations/ # Distance measures
cmb/ # CMB physics & polarization
structure/ # Power spectra, halos, cosmic web
perturbations/ # Growth theory
advanced/ # Weak lensing
early_universe/ # BBN, freeze-out
statistics/ # MCMC, Fisher matrices (NEW)
beyond_lcdm/ # Dark energy, neutrinos (NEW)
visualization/ # Plotting tools
examples/ # 15 demo programs
tests/ # Integration tests
docs/ # Documentation
Scientific Validation
Validated against:
- Planck 2018 cosmological parameters
- Standard ΛCDM predictions
- Published transfer functions (Eisenstein-Hu 1998)
- HALOFIT non-linear corrections (Takahashi et al. 2012)
- BBN predictions (Yp ≈ 0.24, matches observations)
Key results:
- Universe age: 13.80 Gyr (matches Planck)
- CMB recombination: z ≈ 1091
- Distance measures verified against CAMB/CLASS
- Helium-4 abundance: Yp = 0.2397 (excellent agreement)
- Non-linear power spectrum matches N-body simulations
- Halo mass functions match Millennium simulation
Library Coverage
Implemented (Phases 1-9):
- Friedmann equations and cosmic evolution
- Cosmological distances and ages
- CMB recombination and power spectrum
- CMB polarization (E/B modes)
- Matter power spectrum (linear and non-linear)
- Structure formation (halos, cosmic web)
- Big Bang Nucleosynthesis
- MCMC parameter estimation
- Fisher matrix forecasts
- Dark energy models beyond ΛCDM
- Massive neutrino cosmology
- Weak gravitational lensing
- Growth factors and perturbations
Coverage: ~90-95% of graduate-level cosmology textbooks
Module Overview
| Module | Features | Tests |
|---|---|---|
dynamics |
Friedmann solver, components | 5 |
observations |
Distances, ages | 4 |
cmb |
Recombination, power, polarization | 7 |
structure |
P(k), halos, correlation, cosmic web | 12 |
perturbations |
Growth factors, Boltzmann | 4 |
advanced |
Weak lensing, convergence | 3 |
early_universe |
BBN, freeze-out | 6 |
statistics |
MCMC, Fisher | 3 |
beyond_lcdm |
Dark energy, neutrinos | 5 |
storage |
HDF5 data storage (optional) | 6 |
visualization |
Plotting (optional, default) | - |
units |
Conversions | 3 |
constants |
Physical constants | 3 |
Total: 66 tests passing
Performance
- All tests complete in < 0.01s
- MCMC: ~1000 steps with 50 walkers in seconds
- BBN evolution: Stable analytical approach
- Non-linear P(k): Fast HALOFIT implementation
- Examples build in ~2-5 seconds
Contributing
Contributions welcome! See CONTRIBUTING.md.
Areas of interest:
- Performance optimizations
- Full Boltzmann hierarchy solver
- Reionization modeling
- Modified gravity models (f(R), DGP)
- Additional examples and documentation
- Bug fixes and tests
Roadmap
Completed:
- Phase 1-4: Core cosmology, CMB, structure
- Phase 5: Big Bang Nucleosynthesis
- Phase 6: Advanced structure formation
- Phase 7: Statistical methods (MCMC, Fisher)
- Phase 8: CMB polarization
- Phase 9: Beyond-ΛCDM cosmology
Future (Optional Enhancements):
- Full Boltzmann solver for CMB
- Reionization history modeling
- Secondary anisotropies (SZ effect)
- N-body simulation integration
- Machine learning for parameter estimation
License
Licensed under either:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
Citation
References
Textbooks
- Ryden, B. (2016). Introduction to Cosmology (2nd ed.)
- Dodelson, S. & Schmidt, F. (2020). Modern Cosmology (2nd ed.)
- Weinberg, S. (2008). Cosmology
- Baumann, D. (2022). Cosmology
Key Papers
- Planck Collaboration (2020). Cosmological parameters (A&A 641, A6)
- Eisenstein & Hu (1998). Transfer function (ApJ 496, 605)
- Takahashi et al. (2012). Non-linear power spectrum (ApJ 761, 152)
- Tinker et al. (2008). Halo mass function (ApJ 688, 709)
Contact
- Issues: https://github.com/cosmos-andam/andam/issues
- Discussions: https://github.com/cosmos-andam/andam/discussions
- Documentation: https://docs.rs/andam
Status: Version 0.1.1 | 60 tests passing | 15 examples | Phases 1-9 complete | Production-ready