Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
cba27f5
sqlite driver now supports adding columns
XRByte Jun 22, 2026
e6ac3f7
Added capability for updating cells in sqlite driver
XRByte Jun 22, 2026
7bf3df2
Added fetching functionality on a per cell basis
XRByte Jun 22, 2026
e2a2bad
Added shielding utility script
XRByte Jun 24, 2026
aee1a54
UPdated database
XRByte Jun 24, 2026
86e34d7
Added leiden shielding tables
XRByte Jun 24, 2026
60648b9
Refactored the physics folder structure
XRByte Jun 24, 2026
f245903
Fixed bug where molecular photo-ionization reactions were not being r…
XRByte Jun 24, 2026
d210e30
Updated database
XRByte Jun 24, 2026
807e64e
Updated database with shielding tables
XRByte Jun 24, 2026
d1f7f46
Added some utility scripts
XRByte Jun 24, 2026
84e08cf
Added new config files for project wide config
XRByte Jun 24, 2026
236a299
Added support for evaluating shielding
XRByte Jun 24, 2026
73b5627
Added filter functionality to hdf5 group
XRByte Jun 25, 2026
bc3d2bf
Updated some type annotations
XRByte Jun 25, 2026
048b903
Fixed broken shielding functionality
XRByte Jun 26, 2026
d1979e3
Added shielding for leiden datatables
XRByte Jun 26, 2026
beaafa7
Removed unnecessary debugging statements
XRByte Jun 26, 2026
7998018
Fixed bug where output table did not have an extension
XRByte Jun 26, 2026
c467425
Fixed Leiden shielding
XRByte Jun 26, 2026
0d7c392
Added specialized H2 self shielding
XRByte Jun 26, 2026
95d0796
Added mode control to hdf5.to_dict()
XRByte Jun 26, 2026
1f064e3
Fixed bugs in leiden shielding
XRByte Jun 26, 2026
3a2a704
Shielding files are now downloaded
XRByte Jun 26, 2026
f322582
Fixed pooch caching
XRByte Jun 26, 2026
7412c0a
Updated docstrings
XRByte Jun 26, 2026
699a17a
Modified previous docs
XRByte Jun 26, 2026
fbae62f
Added shielding docs
XRByte Jun 26, 2026
55c7947
Added missing database table methods to docs
XRByte Jun 26, 2026
e1178d8
Updated zensical configuration
XRByte Jun 26, 2026
046cd84
Added guide for implementing custom global and local shielding functions
XRByte Jun 27, 2026
412586e
Improved network loading performace by properly caching expressions a…
XRByte Jun 27, 2026
2ef2e09
Improved performance of rate table generation
XRByte Jun 27, 2026
a3d173c
Update .gitignore
XRByte Jun 27, 2026
e9c114f
Github workflows now caches the downloaded files
XRByte Jun 27, 2026
f800219
Improved notebook performance
XRByte Jun 27, 2026
3c28b62
Reduce example notebook rate table tolerance
XRByte Jun 27, 2026
7327f68
Removed test config file
XRByte Jun 28, 2026
0206371
Completely decoupled network format parsing (required to properly det…
XRByte Jun 28, 2026
34eed70
Fixed linting error
XRByte Jun 28, 2026
5761158
Updated relevant docs
XRByte Jun 28, 2026
c8d6ac6
[WIP] Include special species in reactions
XRByte Jun 28, 2026
aef6325
[WIP] Changed serialization strategy
XRByte Jun 28, 2026
ead1b7c
[WIP] Species added for reactions which doesn't contain the reactants
XRByte Jun 28, 2026
1dfc40c
[WIP] Reaction type is now assigned by the parser
XRByte Jun 28, 2026
55eae8a
[WIP] Species can now be filterned as core and special
XRByte Jun 28, 2026
f4aa14e
[WIP] Equations and codegen now use core species correctly
XRByte Jun 28, 2026
11e8e67
[WIP] Modified jaff.db
XRByte Jun 28, 2026
9bdae83
Fixed utility scripts
XRByte Jun 28, 2026
984ee2a
[WIP] Updated jaff.db
XRByte Jun 28, 2026
6506f3f
Fixed shielding template
XRByte Jun 28, 2026
98ab1ef
Fixed photo reaction detection in network
XRByte Jun 29, 2026
25d4a93
Added core grain species to db so that it can be treated normally in …
XRByte Jun 29, 2026
631b706
Updated registry
XRByte Jun 29, 2026
239c3e6
Fixed shielding regression
XRByte Jun 29, 2026
01036ab
Fixed unit tests
XRByte Jun 29, 2026
1591a99
Improved json serialization performance
XRByte Jun 29, 2026
67fc0b4
[WIP] Removed unused tables and script
XRByte Jun 29, 2026
8aa8ebc
Updated docstring
XRByte Jun 29, 2026
11ce368
Updated docs
XRByte Jun 29, 2026
0022ee8
Updated docs
XRByte Jun 29, 2026
0f3e4c0
Updated docs
XRByte Jun 29, 2026
b1c97be
Updated main notebook
XRByte Jul 2, 2026
55d09f9
Merge remote-tracking branch 'upstream' into bug/fix_photo_reaction_d…
XRByte Jul 2, 2026
b5acf11
Fixed flux expression generation
XRByte Jul 3, 2026
461b0fd
Added specie name normalization arguments
XRByte Jul 3, 2026
b71faee
Files now use preconfigured directory paths from config
XRByte Jul 4, 2026
5ca1eab
Reaction type is now an attribute of a reaction
XRByte Jul 4, 2026
e9294f1
Updated notebook
XRByte Jul 4, 2026
fe9f3ac
Changed metadata attributes for private use
XRByte Jul 4, 2026
a473ba6
Updated logo
XRByte Jul 4, 2026
d52af84
Updated readme and contributing guide
XRByte Jul 5, 2026
646f0fc
Updated readme
XRByte Jul 5, 2026
ef86809
Added link to contribution guide in readme
XRByte Jul 5, 2026
eba7ab0
Updated readme
XRByte Jul 5, 2026
daca77d
Updated readme
XRByte Jul 5, 2026
3806b8b
Added band properties to reaction
XRByte Jul 5, 2026
c016445
Improved plotting
XRByte Jul 5, 2026
e98e9d8
Updated theme
XRByte Jul 5, 2026
196c3ae
Improved plotting functionality
XRByte Jul 5, 2026
3a323db
Updated reaction.py
XRByte Jul 5, 2026
9a900d5
Updated stale docstrings
XRByte Jul 5, 2026
11162ce
Updated docs
XRByte Jul 5, 2026
7ba8525
Updated notebook
XRByte Jul 5, 2026
4bfce2c
Separated language tokens and code generation logic
XRByte Jul 8, 2026
9e283d6
Reaction code now uses the new language infrastructure
XRByte Jul 8, 2026
1943aa3
Updated docs
XRByte Jul 8, 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
99 changes: 59 additions & 40 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,79 @@
# Contributing to JAFF

Welcome! We're excited that you're interested in contributing to JAFF (Just Another Fancy Format), an astrochemical network parser.
Thanks for your interest in contributing! This is a quick-start summary — the
full guides live in [`docs/development/`](docs/development/) and online in the
[Documentation](https://jaff-chemistry.github.io/jaff/).

PLEASE NOTE:
If you choose to make contributions to the code, you hereby grant a non-exclusive, royalty-free perpetual license
to install, use, modify, prepare derivative works, incorporate into other computer software,
distribute, and sublicense such enhancements or derivative works thereof, in binary and source code form.
## Ways to Contribute

## Getting Started
- **Report bugs** — open an issue with steps to reproduce.
- **Suggest features** — open an issue to discuss before building anything large.
- **Fix issues / add features** — pick an issue, then send a PR.
- **Improve docs** — corrections and clarifications are always welcome.

1. Fork the repository
2. Clone your fork: `git clone https://github.com/YOUR-USERNAME/jaff.git`
3. Create a new branch: `git checkout -b your-feature-name`
4. Install the package in development mode: `uv pip install -e ".[dev]"`
For major changes, open an issue first so the direction can be agreed on before
you invest time.

## Development Process
## Development Setup

### Code Style
Fork the repo, clone your fork, and install in editable mode with dev tooling:

- Match the style and formatting of surrounding code
- Keep solutions simple, clean, and maintainable
- Each code file should start with a 2-line comment beginning with "ABOUTME: "
- Preserve existing comments unless they are demonstrably false
```bash
git clone https://github.com/YOUR_USERNAME/jaff.git
cd jaff
pip install -e ".[dev]"
```

### Making Changes
Requires **Python 3.11+**. Full instructions (venv, uv, conda, IDE setup) are in
the [Installation Guide](docs/development/installation.md).

1. Make the smallest reasonable changes to achieve your goal
2. Write tests BEFORE implementing new features (Test-Driven Development)
3. Ensure all tests pass before submitting
4. Commit frequently with clear, descriptive messages
## Workflow

### Testing
1. **Branch** off an up-to-date `main` — never commit to `main` directly. Prefix
the branch with its purpose: `feature/`, `bug-fix/`, `docs/`, `refactor/`,
`test/`, or `chore/`.

All contributions should include:
```bash
git checkout main && git pull upstream main
git checkout -b feature/short-description
```

- Unit tests for individual components
- An example Python notebook in `examples/` demonstrating your feature
2. **Commit** with clear messages explaining _what_ and _why_. Use Conventional
Commit types (`feat`, `fix`, `docs`, `refactor`, `test`, `chore`):

Run tests with: `uv run pytest` (once test framework is set up)
```bash
git commit -m "feat: add support for GPU code generation"
```

### Submitting Changes
3. **Check** that tests pass and code is formatted before opening a PR:

1. Push your branch to your fork
2. Create a Pull Request with:
- Clear description of the changes
- Reference to any related issues
- Test results showing all tests pass
3. Address any review feedback promptly
```bash
pytest # run the test suite
ruff check . # lint
ruff format . # format
```

## Questions?
4. **Open a PR** against `jaff-chemistry/jaff:main`. Summarize the change,
reference related issues (`Fixes #123`), and note anything reviewers should
look at. All CI checks (tests on Linux/macOS/Windows × Python 3.11–3.13, docs
build, notebook execution) must pass before merge.

Open an issue for:
## Standards

- Bug reports
- Feature requests
- Questions about the codebase
- Discussion of potential contributions
- **Code style** — Ruff (90-char lines, double quotes), built-in generics and
`X | None` unions, NumPy-style docstrings. See the
[Code Style Guide](docs/development/code-style.md).
- **Tests** — pytest, one behaviour per test, descriptive names. New code should
be fully covered. See the [Testing Guide](docs/development/testing.md).
- **Codebase layout** — see the
[Codebase Structure](docs/development/codebase-structure.md) guide.

Thank you for contributing to JAFF!
## Getting Help

- **GitHub Issues** — bug reports and feature requests.
- **GitHub Discussions** — questions about the codebase or usage.

## License

By contributing, you agree that your contributions are licensed under the
project's [MIT License](LICENSE).
158 changes: 79 additions & 79 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,129 +1,129 @@
<div align="center">
<h1>JAFF</h1>
<img src="assets/logo.png" alt="Logo" width="100" /><br>
(Just Another Fancy Format)
<br><br>
<img src="assets/logo.png" alt="JAFF logo" width="120" />

<h1>JAFF</h1>

<p><em>Just Another Fancy Format</em></p>

<p>A fast, multi-format astrochemical network parser with analysis, code generation, and explicit photochemistry.</p>

<p>
<a href="https://github.com/jaff-chemistry/jaff/blob/main/LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-8b6cff?style=for-the-badge&labelColor=241b2f&logo=opensourceinitiative&logoColor=EDE4FF"></a>
<a href="https://www.python.org/downloads/"><img alt="Python 3.11+" src="https://img.shields.io/badge/Python-3.11%2B-e05fb0?style=for-the-badge&labelColor=241b2f&logo=python&logoColor=EDE4FF"></a>
<img alt="Version" src="https://img.shields.io/badge/Version-0.1.5-ff6a5a?style=for-the-badge&labelColor=241b2f&logo=semanticrelease&logoColor=EDE4FF">
<img alt="Status" src="https://img.shields.io/badge/Status-alpha-ffc24b?style=for-the-badge&labelColor=241b2f&logo=rocket&logoColor=EDE4FF">
<a href="https://jaff-chemistry.github.io/jaff/"><img alt="Docs" src="https://img.shields.io/badge/Docs-online-8b6cff?style=for-the-badge&labelColor=241b2f&logo=readthedocs&logoColor=EDE4FF"></a>
</p>

<p>
<a href="#installation">Installation</a> ·
<a href="#quick-start">Quick Start</a> ·
<a href="#supported-network-formats">Formats</a> ·
<a href="https://jaff-chemistry.github.io/jaff/">Documentation</a> ·
<a href="#contributing">Contributing</a>
</p>
</div>

An astrochemical network parser that supports multiple reaction network formats including KIDA, UDFA, PRIZMO, KROME, and UCLCHEM.
---

## Overview

**JAFF** is an astrochemical network parser that reads multiple network formats, validates and analyses them, generates simulation code, and handles explicit photochemistry — all from a single tool.

- **Multi-format** — parse KIDA, UDFA, PRIZMO, KROME, and UCLCHEM networks
- **Automatic validation** — catch malformed reactions and inconsistent species
- **Analysis** — inspect species, reactions, masses, charges, and rates
- **Code generation** — emit ODE solvers in C, C++, Python, Fortran, Rust, Julia, and R
- **Explicit photochemistry** — first-class treatment of photoreactions

For detailed instructons, please refer to the [Documentation](https://jaff-chemistry.github.io/jaff/)
> Full guides and API reference live in the [Documentation](https://jaff-chemistry.github.io/jaff/).

## Installation

### From source
Clone the repository and install with `pip`:

```bash
git clone https://github.com/jaff-chemistry/jaff.git
cd jaff
pip install .
```

### For development

```bash
git clone https://github.com/jaff-chemistry/jaff.git
cd jaff
pip install -e . # Editable install
```
Requires **Python 3.11+**.

## Quick Start

### Command Line Usage
### Command Line

After installation, you can use the `jaff` command:
Installation provides two commands: `jaffx` for quick network inspection and
export, and `jaffgen` for code generation.

```bash
# Load and validate a network file
jaff networks/gas_reactions_kida.uva.2024.in
# Count species and reactions in a network
jaffx get num-species --network networks/COthin/react_COthin.jet
jaffx get num-reactions --network networks/COthin/react_COthin.jet

# List all species and reactions
jaff networks/test.dat --list-species --list-reactions
# Export rate coefficients over a temperature range to a text file
jaffx export txt --network networks/COthin/react_COthin.jet --tmin 10 --tmax 1e4
```

### Python API Usage
### Network Parsing

The format is auto-detected — the same `Network` call reads KIDA, KROME,
PRIZMO, UDFA, and UCLCHEM files, plus JAFF's own `.jaff` format:

```python
from jaff import Network

# Load a chemical network
network = Network("networks/react_COthin")
network = Network("networks/COthin/react_COthin.jet")
network = Network("networks/kida_uva_2024/gas_reactions_kida.uva.2024.jet")
```

### Analysis

```python
# Access species
for species in network.species:
print(f"{species.name}: mass={species.mass}, charge={species.charge}")

# Access reactions
for reaction in network.reactions:
print(f"{reaction.get_sympy()}")
print(f"{reaction.reactants}")
```

## Features
### Code Generation

- **Multi-format support**: Automatically detects and parses KIDA, UDFA, PRIZMO, KROME, and UCLCHEM formats
- **Validation**: Checks for mass and charge conservation in reactions
- **Species analysis**: Automatic extraction of elemental composition and properties
- **Rate calculations**: Temperature-dependent rate coefficient evaluation
- **ODE generation**: Creates differential equations for chemical kinetics

## Supported Network Formats

- **KIDA**: Kinetic Database for Astrochemistry format
Reference: [A&A, 689, A63 (2024)](https://doi.org/10.1051/0004-6361/202450606)
- **UDFA**: UMIST Database for Astrochemistry format
Reference: [A&A, 682, A109 (2024)](https://doi.org/10.1051/0004-6361/202346908)
- **PRIZMO**: Uses `->` separator with `VARIABLES{}` blocks
Reference:[MNRAS 494, 4471–4491 (2020)](https://doi.org/10.1093/mnras/staa971)
- **KROME**: Comma-separated values with `@format:` header
Reference: [MNRAS 439, 2386–2419 (2014)](https://doi.org/10.1093/mnras/stu114)
- **UCLCHEM**: Comma-separated with `,NAN,` marker (UNDER CONSTRUCTION)
Reference: [J. Holdship et al 2017 AJ 154 38](https://doi.org/10.3847/1538-3881/aa773f)
```bash
jaffgen --template microphysics --network networks/GOW/GOW.jet
```

## Primitive Variables
**Supported languages:** C · C++ · Python · Fortran · Rust · Julia · R

The following variables are recognized in rate expressions:
## Supported Network Formats

- `tgas`: gas temperature, K
- `av`: visual extinction, Draine units
- `crate`: cosmic rays ionization rate of H2, 1/s
- `ntot`: total number density, 1/cm3
- `hnuclei`: H nuclei number density, 1/cm3
- `d2g`: dust-to-gas mass ratio
| Format | Reference |
| ----------- | ---------------------------------------------------------------------------- |
| **KIDA** | [A&A, 689, A63 (2024)](https://doi.org/10.1051/0004-6361/202450606) |
| **UDFA** | [A&A, 682, A109 (2024)](https://doi.org/10.1051/0004-6361/202346908) |
| **PRIZMO** | [MNRAS 494, 4471–4491 (2020)](https://doi.org/10.1093/mnras/staa971) |
| **KROME** | [MNRAS 439, 2386–2419 (2014)](https://doi.org/10.1093/mnras/stu114) |
| **UCLCHEM** | [J. Holdship et al 2017 AJ 154 38](https://doi.org/10.3847/1538-3881/aa773f) |

## Examples

Example network files can be found in the `networks/` directory.

## Development

To contribute or modify JAFF:

```bash
# Install in development mode with dev dependencies
pip install -e ".[dev]"

# Run tests
pytest
Example network files can be found in the [`networks/`](networks/) directory.

# Format code
ruff format
## Contributing

# Lint code
ruff check src/jaff
Contributions are welcome! To contribute or modify JAFF, please refer to our
[Contributing Guide](CONTRIBUTING.md).

# Organize imports
ruff check --select I --fix
```
## License

## JAFF Schema Validation

JAFF network exports are JSON payloads serialized to `.jaff` (optionally gzip-compressed as `.jaff.gz`).
To validate a decompressed payload against the schema:

```bash
check-jsonschema --schemafile jaff.network.schema.json test.jaff
```
Distributed under the **MIT License**. See [`LICENSE`](LICENSE) for details.

---

![xkcd:927](./assets/xkcd.png)
<div align="center">
<img src="./assets/xkcd.png" alt="xkcd 927: Standards" width="500" /><br>
<sub><a href="https://xkcd.com/927/">xkcd 927</a></sub>
</div>
Binary file modified assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/logo.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/api/codegen/codegen/get_commons.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const int nreactions = 5;
**Parameters**

**idx_offset** : _int, optional_
: Base index added to each species position. `-1` uses the language default stored in `self.ioff`. Default `-1`.
: Base index added to each species position. `-1` uses the language default stored in `self.lang.idx_offset`. Default `-1`.

**idx_prefix** : _str, optional_
: Prefix for index names, e.g. `"idx_"`. Default `""`.
Expand Down
Loading
Loading