Skip to main content

code for cosmological gravitational wave backgrounds

Project description

License: GPL v3 PyPI version

CosmoGW v1.0

CosmoGW is a Python package for the analysis and modeling of cosmological gravitational wave (GW) backgrounds from different sources in the early Universe, including analytical models, templates, and data analysis routines.

v1.0 (August 2025) focuses on the production of GWs from sound waves and MHD turbulence from cosmological phase transitions.

Other sources of GWs will be included in future versions, contact me if you are interested in contributing and becoming a developer.

CosmoGW is an extension of GW_turbulence, created in December 2021, used for calculations of GWs produced by MHD turbulence.


Contact

Author: Alberto Roper Pol
Email: alberto.roperpol@unige.ch
GitHub: albertoroperpol

If you use any of the cosmoGW results, please cite this repository, the [manual] (coming soon) and the relevant references listed in the routines.

Feel free to reach out for questions, issues, or collaboration! I would also love to hear about your interest for this project and your work, so feel free to reach out for questions, issues, or collaboration!


Installation

CosmoGW is a Python package that can be installed using pip from PyPI:

pip install cosmoGW

Or directly from GitHub (last version but not necessarily stable):

pip install git+https://github.com/cosmoGW/cosmoGW.git

Requirements:
Python >= 3.8, numpy, scipy, matplotlib, astropy, pandas

To use the plotting routines available in the tutorials and in plot_sets, make sure to install latex for Python:

sudo apt install cm-super dvipng texlive-latex-extra texlive-latex-recommended

File Structure

The main routines of cosmoGW are stored under src/cosmoGW:

  • cosmology.py: Cosmological calculations.
  • GW_analytical.py: Analytical calculations and mathematical functions.
  • GW_back.py: Functions for cosmological GW backgrounds.
  • GW_models.py: Theoretical and numerical models for sources of GWs.
  • GW_templates.py: Templates for GW backgrounds from different sources.
  • hydro_bubbles.py: Fluid perturbations from bubbles in first-order phase transitions.
  • interferometry.py: Response and sensitivity functions for GW detectors (LISA, Taiji).
  • utils.py: Utility functions and reference values for CosmoGW.
  • tests/: Unit tests and example data.
  • resources/: Data files used in the code (numerical data, sensitivity curves, ...)
  • tutorials/: Tutorials showing how to use CosmoGW for different applications.

Documentation

Comprehensive documentation is available at Read the Docs.

  • API Reference: Detailed documentation for all modules and functions.
  • Tutorials: Step-by-step guides and example workflows.
  • Theory: Background information and mathematical details.

To build the documentation locally:

cd docs
make html

Tutorials

Tutorials and example notebooks are available in the tutorials/ directory:

These tutorials can be run from Google Colab by loading the notebooks from GitHub.

When using Colab, latex needs to be installed, together with CosmoGW, for plotting routines. For the installation, uncomment and execute the first cell of the tutorials:

pip install cosmoGW
sudo apt-get update
sudo apt-get install -y cm-super dvipng texlive-latex-extra texlive-latex-recommended

Tests

Unit tests are provided in the tests/ directory.

To run all tests (from cosmoGW directory):

pytest

Make sure pytest is installed and that all required test data files are present in the tests directory.

Further test is available using the tutorial notebooks (see [python-package_nbs.yml]). To test the output plots and results from the notebooks run (e.g. from GWs_sound-waves tutorial):

pytest --nbval tutorials/GWs_sound-waves.ipynb

Make sure to have installed pytest, nbval and latex:

pip install pytest nbval
sudo apt install cm-super dvipng texlive-latex-extra texlive-latex-recommended

Resources

Data files are available in cosmoGW that are required by some of the libraries.

They are stored in src/cosmoGW/resources:

  • cosmology: Cosmological evolution files and Friedmann equation tutorial.
  • interferometry: Space-based GW interferometry calculations and tutorials.
  • detector_sensitivity: Sensitivity of various detectors; see the README.
  • higgsless: Data sets from Higgsless simulations of phase transitions.

Examples of Use

Importing the Package

import cosmoGW

Compute a Cosmology Quantity

from cosmoGW import cosmology

# Example: Calculate Hubble parameter at z=1
H_z1 = cosmology.Hubble_parameter(1)
print(f"Hubble parameter at z=1: {H_z1}")

Plotting with cosmoGW

import matplotlib.pyplot as plt
from cosmoGW import plot_sets

plt.plot([0, 1], [0, 1])
plot_sets.save_fig(name='example_plot')

Using Gravitational Wave Models

from cosmoGW import GW_models

# Example: Generate a GW spectrum
spectrum = GW_models.generate_spectrum(params)

📄 License

This project is licensed under the GNU General Public License v3 (GPLv3).


🚀 Enjoy exploring the early Universe with gravitational waves! 🪐

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cosmogw-0.0.35.tar.gz (5.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cosmogw-0.0.35-py3-none-any.whl (5.8 MB view details)

Uploaded Python 3

File details

Details for the file cosmogw-0.0.35.tar.gz.

File metadata

  • Download URL: cosmogw-0.0.35.tar.gz
  • Upload date:
  • Size: 5.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for cosmogw-0.0.35.tar.gz
Algorithm Hash digest
SHA256 e32f21e4f3984d33ea7b110cc9a174b5acf11090995618f62aaf660a3c8c5303
MD5 2815d5a62f35b97073a83cdad39d372a
BLAKE2b-256 9c466020d647cdf3e6c1c819c14e1b3a0dcf514f6ec2c5ca97cf57342be50b88

See more details on using hashes here.

File details

Details for the file cosmogw-0.0.35-py3-none-any.whl.

File metadata

  • Download URL: cosmogw-0.0.35-py3-none-any.whl
  • Upload date:
  • Size: 5.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for cosmogw-0.0.35-py3-none-any.whl
Algorithm Hash digest
SHA256 7613490561fd63a1313b9b8d14512ca6994b5559d628539e5d4a86b11b40602a
MD5 825743f3914840367a3043299f35b2be
BLAKE2b-256 64ba8bba9a8d800fd904525863f42ad09b2f07175618328f9c1105908398e577

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page