Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0627182
Split plasma_dummy and macro_dummy into sub-structs for future
kslong Mar 19, 2026
1c9d1ff
Modernize function declarations: remove K&R style and empty-paren pro…
kslong Mar 20, 2026
78d50ad
Update developer docs to describe plasma/macro sub-struct memory model
kslong Mar 20, 2026
96cc54c
Implement MPI-3 shared memory for plasma/macro dynamic arrays
kslong Mar 21, 2026
7a00daf
Move fixed-size plasma arrays to shared contiguous blocks
kslong Mar 21, 2026
a6d5c65
Dynamically size n_bf_in/n_bf_out to nphot_total instead of N_PHOT_PR…
kslong Mar 21, 2026
5819f9d
Share wind struct (wmain) via MPI-3 shared memory
kslong Mar 21, 2026
9362f1f
Dynamically size cell_spec_flux with -cell_spec_dim flag
kslong Mar 21, 2026
c1f4f6c
Share matom_matrix via MPI-3 shared memory
kslong Mar 22, 2026
641647a
Reduce peak transient memory in macro-atom communication
kslong Mar 22, 2026
7595621
Work around macOS MPI-3 shared-memory SEGV_ACCERR for wmain
kslong Mar 31, 2026
bf727a1
Convert K&R function definitions to modern prototypes
kslong Apr 1, 2026
dc217a8
Fix remaining warnings in make all (MPI build)
kslong Apr 1, 2026
b070ade
Add a big disk to regress3d
kslong Apr 8, 2026
839087e
Fix unit tests for memory branch restructuring
kslong Apr 16, 2026
d036427
Remove agn_cyl_big.pf from memory (belongs on xmem3d branch)
kslong Apr 17, 2026
7a496fb
Merge origin/dev into memory, keeping memory's run_check.py fixes
kslong Apr 17, 2026
3e579f0
Fix MPI shared-memory race conditions and clean up unit test warnings
kslong Apr 17, 2026
7d7056d
Rename mpi_comms.rst to mixed_memory_model.rst and restructure
kslong Apr 18, 2026
4fe09bf
Fix rad_hydro_files MPI initialization for memory branch
kslong Apr 20, 2026
201594e
Fix macOS load warnings, windsave shared-memory bug, and add C execut…
kslong Apr 21, 2026
cf7ec00
Standardize regression_plot.py try/except to polar version
kslong May 5, 2026
c0c3fbb
Mpich (#1182)
kslong May 17, 2026
a496ccf
Mpich and rad_hydro (#1183)
kslong May 18, 2026
6aa1e45
Merge branch 'dev' into memory
jhmatthews May 26, 2026
57da495
Fix: spherical_ds_in_cell infinite loop at outer cell boundary
kslong Jun 5, 2026
4474ed9
Fix: two bugs in velocity gradient computation (gradv.c)
kslong Jun 6, 2026
47982be
Fix: move ext.txt to diag folder; only open when actually needed
kslong Jun 6, 2026
4032349
Fix: correct spherical_ds_in_cell cherry-pick for memory branch
kslong Jun 6, 2026
3878576
Add macro2simple.py: convert macro-atom atomic data to simple-atom fo…
kslong Jun 6, 2026
aefa080
Add ConvertMacro2Simple.py: camel-case copy of macro2simple.py for macOS
kslong Jun 17, 2026
2502208
Remove macro2simple.py: replaced by ConvertMacro2Simple.py
kslong Jun 17, 2026
3c68041
Add CLAUDE.md: rule against case-only filename differences for macOS …
kslong Jun 17, 2026
4c990a0
Update CLAUDE.md: replace stub with full project documentation
kslong Jun 17, 2026
e1287e0
Fix cell_spec_flux persistence and -cell_spec_dim for new runs
kslong Jun 18, 2026
4b076b5
Merge branch 'dev' into memory2607
kslong Jul 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 145 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

Sirocco (Simulating Ionization and Radiation in Outflows Created by Compact Objects) is a Monte Carlo radiative transfer code using the Sobolev approximation. It simulates winds and outflows in systems like cataclysmic variables, AGN, X-ray binaries, and young stellar objects. Formerly known as "Python" (renamed October 2024).

## Build Commands

**Environment setup** (required before building):
```bash
export SIROCCO=/path/to/Sirocco
```

**First-time full build** (compiles GSL, CUnit, then Sirocco):
```bash
./configure # detects compilers (mpicc/gcc) and optional CUDA
make install # builds GSL 2.6, CUnit 3.2.7, and all source
```

**Recompile source only** (after initial install):
```bash
cd source && make CC=mpicc sirocco # main program
cd source && make CC=mpicc all # all targets + indent check
cd source && make D sirocco # debug/profiling build (-g -pg)
cd source && make CC=gcc sirocco # compile without MPI
cd source && make INDENT=no sirocco # skip auto-indentation
```

**Other build targets** (all from `source/`):
- `make swind` — spectral wind analysis
- `make windsave2table` — convert wind saves to ASCII tables
- `make windsave2fits` — convert wind saves to FITS (requires cfitsio)
- `make rad_hydro_files`, `make modify_wind`, `make inspect_wind` — wind utilities
- `make sirocco_optd` — optical depth calculations

**Clean build artifacts**:
```bash
cd source && make clean
```

**Unit tests** (requires CUnit + cmake):
```bash
make check # from top-level
cd source && make check # from source directory
```

**Running Sirocco**:
```bash
$SIROCCO/bin/Setup_Sirocco_Dir # set up working directory with symlinks
sirocco parameter_file.pf # serial
sirocco -i root # interactive mode (creates parameter file)
mpirun -n 4 sirocco parameter_file.pf # parallel with MPI
```

## Architecture

### Language and Compilation
- C (gnu99 standard), ~130 source files in `source/`
- Default compiler: `mpicc` (sets `-DMPI_ON`); falls back to gcc/clang
- Optional CUDA support via `--with-cuda` configure flag (matrix operations on GPU)
- Dependencies: GSL 2.6 (bundled in `software/`), CUnit 3.2.7 (bundled)
- Auto-indentation enforced on commit via `py_progs/run_indent.py` using GNU indent

### Key Source Files
- `source/sirocco.c` — main entry point, orchestrates ionization and spectrum cycles
- `source/sirocco.h` (~98KB) — central header with all major data structures (`PlasmaPtr`, `WindPtr`, `PhotPtr`, domain geometry structs)
- `source/atomic.h` (~31KB) — atomic data structures (ions, lines, levels, cross-sections)
- `source/templates.h` — auto-generated function prototypes (via `cproto`)
- `source/version.h` — auto-generated at build time from git hash

### Core Code Organization (in `source/`)
- **Wind models**: `define_wind.c`, `wind.c`, `wind2d.c`, `spherical.c`, `cylindrical.c`, `rtheta.c`, `sv.c` (Shlosman-Vitello), `knigge.c`, `homologous.c`, `corona.c`, `shell_wind.c`, `hydro_import.c`
- **Photon transport**: `trans_phot.c`, `photon2d.c`, `photon_gen.c`, `extract.c`, `paths.c`, `phot_util.c`
- **Radiation & spectra**: `radiation.c`, `spectra.c`, `bands.c`, `continuum.c`, `brem.c`, `compton.c`, `emission.c`
- **Ionization**: `ionization.c`, `direct_ion.c`, `saha.c`, `charge_exchange.c`, `partition.c`, `levels.c`, `recomb.c`
- **Macro-atom**: `matom.c`, `matom_diag.c`, `macro_gov.c`, `macro_gen_f.c`, `macro_accelerate.c`, `estimators_macro.c`
- **Line transfer**: `lines.c`, `resonance.c` (`resonate.c`), `dielectronic.c`
- **Disk**: `disk.c`, `disk_init.c`, `disk_photon_gen.c`
- **Setup/config**: `setup.c`, `setup_domains.c`, `setup_disk.c`, `setup_star_bh.c`, `setup_line_transfer.c`, `parse.c`, `rdpar.c`
- **MPI communication**: `communicate_plasma.c`, `communicate_wind.c`, `communicate_macro.c`, `communicate_spectra.c`, `para_update.c`
- **I/O**: `windsave.c`, `windsave2table_sub.c`, `xlog.c`, `diag.c`
- **Math utilities**: `recipes.c`, `random.c`, `cdf.c`, `vvector.c`, `matrix_cpu.c`, `matrix_gpu.cu`
- **Frame transformations**: `frame.c`

### Data Directories
- `xdata/` — atomic data files read at runtime (referenced via `Atomic_data` parameter)
- `xmod/` — model grids and spectra for disk/stellar models
- `examples/` — parameter files (`.pf`) organized by type: `basic/`, `extended/`, `regress/`, `gh-workflow/`

### Python Utilities (`py_progs/`)
Support scripts for data processing, visualization, and code maintenance:
- `run_indent.py` — enforces GNU indent code style on changed C files
- `MakeMacro.py` — generates macro-atom data from Chianti/Topbase databases
- `plot_spec.py`, `plot_wind.py`, `plot_tot.py` — visualization
- `hydro_2_python.py` — parse hydro simulation output for use with Sirocco's hydro import facility
- `import_model.py` — unified import-file generator for all coordinate systems (spherical, cylindrical, polar, cyl3d, sph3d)
- `balmer_decrement.py` — physics validation test
- `regression.py` — regression testing utilities

### Testing
- **Unit tests**: CUnit-based in `source/tests/` (test_matrix, test_compton, test_define_wind, test_run_mode, test_translate)
- **Integration tests**: GitHub Actions workflow (`.github/workflows/build.yml`) runs multiple example parameter files (CV, AGN, XRB, SN models) on pushes to dev/main
- **Regression tests**: Examples in `examples/regress/`

### Build System Notes
- `Makefile.in` is the top-level template (not auto-generated by autoconf — `configure` is a hand-written shell script)
- `source/Makefile` handles all C compilation, prototype generation, and indentation
- `source/tests/Makefile` includes the main source Makefile and links all Sirocco source for unit tests
- `get_models.c` cannot be included in `sirocco_source` list (prototype generation issue) but is added separately to object lists
- `make prototypes` regenerates `templates.h`, `log.h`, `atomic_proto.h`, `math_proto.h` via `cproto`

## Dependencies
- GSL 2.6 (bundled in `software/`)
- CUnit 3.2.7 (bundled in `software/`, requires CMake)
- MPI: OpenMPI or MPICH (`mpicc`)
- Optional: cfitsio (for FITS output via `windsave2fits`)
- Optional: CUDA (for GPU matrix operations via `--with-cuda`)

## Parameter Files

Sirocco uses `.pf` parameter files with key-value pairs:
```
System_type(star,cv,bh,agn,previous) cv
Central_object.mass(msol) 0.8
Wind.type(SV,star,hydro,corona,...) sv
Photons_per_cycle 100000
```
Example files are in `examples/basic/`, `examples/extended/`, and `examples/gh-workflow/`.

## Documentation
- Full docs: https://sirocco-rt.readthedocs.io
- Model spectra (optional): clone `https://github.com/sirocco-rt/xmod` into `xmod/`

## Claude Code Rules
- **Never change the version number** in `source/version.h` or `source/Makefile` without explicit user instruction. Always ask before touching these.
- **Never create two files whose names differ only in case** (e.g. `macro2simple.py` and `Macro2Simple.py`). macOS uses a case-insensitive filesystem and will treat them as the same file, causing one to silently overwrite the other on any Mac clone or pull.

## Coding Conventions
- GNU indent style enforced automatically on changed files during build (unless `INDENT=no`)
- ANSI C with gnu99 standard
- MPI code guarded by `#ifdef MPI_ON` preprocessor directives
- CUDA code guarded by `#ifdef CUDA_ON`
- Logging via `xlog.c` functions (Log, Error, Debug)
Loading