How cosmolike/cocoa works
Overall Project Type and Purpose
• The project is a full-stack, scientific computing environment tailored for cosmological analysis. It tightly integrates external Boltzmann codes (e.g., CAMB, CLASS), likelihood codes (Planck, ACT, SPT, etc.), and sampling routines (Cobaya/PolyChord) to simulate and analyze multi-probe cosmological data (from DES, LSST, Roman, etc.).
• The README emphasizes aspects like containerization and consistent compiler/library choices across machines, reflecting a need for robust reproducibility and HPC deployment.
Key Directories and Their Roles
• The top-level “Cocoa” directory houses the core environment and scripts:
– Installation and compilation scripts (e.g., setup_cocoa.sh, compile_cocoa.sh, start_cocoa.sh, stop_cocoa.sh) that set up the environment and build external modules.
– The “external_modules” folder is organized into subdirectories for code (e.g., CAMB, CLASS, cosmolike, various likelihood modules) and data (e.g., Planck, BAO, SPT), which are downloaded and compiled via installation scripts.
– The “projects” directory contains example YAML configuration files and project-specific scripts. This folder supports setting up concrete cosmological analyses with Cobaya-run commands.
• Additionally, there are installation libraries (e.g., cocoa_installation_libraries) with lecture notes and changes that support users and developers in understanding the lower-level code.
Main System Components
a. Environment & Containerization Layer (User Interface/Deployment)
– Conda Environment: Represent the use of cocoapy39.yml, cocoapy310.yml files for core package management.
– Docker Container (e.g., whovian-cocoa): Indicate that Cocoa can run within a dockerized environment for consistent setup across Linux, Windows, and macOS.
b. Core Scripts/Bootstrapper
– Setup and compilation scripts (setup_cocoa.sh, compile_cocoa.sh) that download and build external modules.
– Start/Stop scripts (start_cocoa.sh, stop_cocoa.sh) that manage the private Python/Cobaya environments.
c. External Modules & Libraries
– Modules under “external_modules/code” such as:
• Boltzmann codes (CAMB, CLASS)
• Likelihood codes (Planck’s PLC, SPT, ACT, etc.)
• Sampling and interfacing layers (cfastpt, cfftlog, cosmolike, log.c, spt_clik, etc.)
– Data directories under “external_modules/data” for cosmological datasets.
– “cocoa_installation_libraries” which contains patches, teaching notes, and library changes.
d. User Projects
– The “projects” folder (e.g., projects/example and lsst_y1) contains customized YAML configuration files and scripts for running evaluations, MCMCs, and profiling.
– Represents user-configured instances that use the core framework and the external modules.
e. Integration with Cobaya
– The overall system is a “wrapper” which integrates CosmoLike routines into the Cobaya sampler framework. There is a bidirectional relationship where Cocoa’s infrastructure prepares the necessary shared libraries, symbolic links, and environment variables so that Cobaya (and its “cobaya-run” command) can access likelihoods and data.
Relationships and Data/Control Flows
• The Cona/Docker layer encapsulates the full environment; within it, the startup scripts create a “private” workspace. From here:
– Setup scripts trigger the download, extraction, and compilation of the external modules.
– Compiled binaries and libraries are then linked (via softlink scripts from start_cocoa.sh) so Cobaya (the sampling engine) can locate and use them.
– User projects (YAML files) specify parameters and likelihood functions; these are fed to the Cobaya-run command (often wrapped in hybrid MPI+OpenMP commands).
– Feedback flows from sampling runs (MCMC chains, evaluations, profiling) back to the user who can observe outputs or fine-tune YAML configurations.
• Installation scripts and manual options control which modules or datasets are included. Environment flags (e.g., for debugging, ignoring certain datasets) impact the system’s compilation behavior.
Architectural Patterns and Technologies
• Modular architecture: Separation between core environment, external modules and user projects.
• Containerization and environment isolation: Ensures reproducibility (via conda environments and Docker).
• Use of multiple languages supported by language-specific compilation and linking (C, C++, Fortran, Python, Bash).
• Deployment on HPC: MPI and OpenMP settings and NUMA-aware scheduling (as seen in the mpirun flags) are important details.