Metadata-Version: 2.5
Name: rwl
Version: 0.2.0
Summary: Turbidity measurement and crew-scale sizing for a three-stage water pre-treatment column
Project-URL: Homepage, https://rwl.leonardosalas.dev
Project-URL: Repository, https://github.com/leonardosalasd/regolith-water-loop
Project-URL: Documentation, https://rwl.leonardosalas.dev/docs/
Author-email: Leonardo Salas <leonardo.salas01@outlook.com>
License: MIT License
        
        Copyright (c) 2026 Leonardo Salas
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
License-File: LICENSE-DOCS
Keywords: biochar,filtration,open hardware,regolith,turbidity,water treatment
Classifier: Environment :: Console
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.10
Requires-Dist: numpy>=1.24
Requires-Dist: pillow>=10.0
Requires-Dist: rich>=13.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == 'dev'
Description-Content-Type: text/markdown

<div align="center">

<img src="https://raw.githubusercontent.com/leonardosalasd/regolith-water-loop/main/public/logo.svg" width="100" alt="Regolith Water Loop Logo">

# **Regolith Water Loop**

Three-stage water pre-treatment column: bioremediated regolith, pyrolysis biochar, and a gravity feed. Bench-built and tested.

[**Leonardo Salas**](mailto:leonardo.salas01@outlook.com) · [rwl.leonardosalas.dev](https://rwl.leonardosalas.dev)

<br>

<a href="https://pypi.org/project/rwl/">
  <img src="https://img.shields.io/pypi/v/rwl?style=for-the-badge&color=F54927&label=pypi" alt="rwl on PyPI" height="34"/>
</a>
<a href="https://github.com/sponsors/leonardosalasd">
  <img src="https://img.shields.io/badge/Sponsor%20this%20project-%E2%9D%A4-F54927?style=for-the-badge&logo=githubsponsors&logoColor=white" alt="Sponsor Regolith Water Loop on GitHub Sponsors" height="34"/>
</a>

<sub>Built and documented in the open by one person. Sponsorship keeps it that way.</sub>

</div>

---

> [!CAUTION]
> **This is not a drinking water system.**
> This column is a pre-treatment stage. It is meant to reduce turbidity and suspended solids. It does **not** remove bacteria, viruses or parasites, and it does **not** make water safe to drink. Water leaving this column still requires proper disinfection.

---

## What this is

A habitat has to detoxify its own soil, handle the waste it produces every day, and recycle water. Solved separately those are three problems. Solved together they are one machine, where the furnace that processes waste also keeps the bioreactor warm and fed, and both of them produce the material the filter is made of.

This repository holds the design, the bench build, and the code that measures whether it works.

| | |
| --- | --- |
| [docs/system.md](https://github.com/leonardosalasd/regolith-water-loop/blob/main/docs/system.md) | The three stages and how they depend on each other |
| [docs/mars.md](https://github.com/leonardosalasd/regolith-water-loop/blob/main/docs/mars.md) | Mars conditions, sizing for six crew and habitat requirements |
| [docs/method.md](https://github.com/leonardosalasd/regolith-water-loop/blob/main/docs/method.md) | How turbidity is measured from photographs |
| [docs/protocol.md](https://github.com/leonardosalasd/regolith-water-loop/blob/main/docs/protocol.md) | Greywater recipe, grading, calibration and run procedure |
| [docs/build.md](https://github.com/leonardosalasd/regolith-water-loop/blob/main/docs/build.md) | Build log with photographs and measured volumes |
| [docs/results.md](https://github.com/leonardosalasd/regolith-water-loop/blob/main/docs/results.md) | First runs and what they show |
| [docs/print/target-sheet.pdf](https://github.com/leonardosalasd/regolith-water-loop/blob/main/docs/print/target-sheet.pdf) | Printable checker target and white card for the rig |
| [docs/drawings/](https://github.com/leonardosalasd/regolith-water-loop/tree/main/docs/drawings/) | Bench drawings RWL-001 and RWL-002, system schematics RWL-003 and RWL-004 |
| [docs/references.md](https://github.com/leonardosalasd/regolith-water-loop/blob/main/docs/references.md) | Every source, checked against the claim it supports |
| [GLOSSARY.md](https://github.com/leonardosalasd/regolith-water-loop/blob/main/GLOSSARY.md) | Terms used throughout |

Stage 2, the filtration column, is the stage built and tested on the bench; see [docs/results.md](https://github.com/leonardosalasd/regolith-water-loop/blob/main/docs/results.md). Stages 1 and 3 are supported by published work. Perchlorate salts are strong oxidisers and are not handled in this project.

---

## Install

```bash
pipx install rwl   # or: pip install rwl
```

Published as [`rwl` on PyPI](https://pypi.org/project/rwl/). Run `rwl` with no arguments, or `rwl info`, for a summary of every command.

## Measuring turbidity

Removal is measured from photographs rather than an electronic probe: a phone camera is available and free, a nephelometer is not. A printed target behind the sample loses contrast as suspended solids rise, and a white card in frame cancels exposure differences between shots.

Results are relative to the influent, never reported in NTU.

```bash
rwl target --out target-sheet.pdf   # print this at 100%, next to the sample
rwl roi photos/cal0.jpg --setup setup.json   # check the regions before measuring

rwl measure photos/cal*.jpg --setup setup.json --out readings.csv
rwl calibrate --readings readings.csv --levels levels.csv --out calibration.json
rwl measure photos/influent.jpg photos/charge*.jpg --setup setup.json --out run.csv
rwl report --readings run.csv --calibration calibration.json \
    --before influent --after charge1 charge2 charge3
```

`report` flags any result outside the calibrated range instead of extrapolating it. The timed drain of a charge doubles as a falling-head test: `rwl permeability --seconds 45 --outlet-drop 0.30` gives the bed's hydraulic conductivity on Earth and at 0.37 g.

Read [docs/method.md](https://github.com/leonardosalasd/regolith-water-loop/blob/main/docs/method.md) before shooting a session. The rig has to stay fixed or the series is void.

### Sizing

```bash
rwl size --crew 6 --base early --explain
rwl cartridge --crew 6
```

`size` covers greywater, filter area under Mars gravity, retort heat, char output and perchlorate, chloride and oxygen stoichiometry for a crew. `cartridge` splits one filter cartridge into what Mars supplies and what Earth does. `--explain` prints the formula and source behind every number, `--json` the raw values; each constant is also cited directly in [src/rwl/sizing.py](https://github.com/leonardosalasd/regolith-water-loop/blob/main/src/rwl/sizing.py).

### Development

```bash
pip install -e '.[dev]'
pytest
```

---

## Documentation site

A static site under [`site/`](https://github.com/leonardosalasd/regolith-water-loop/tree/main/site/), English at the root and Spanish under `/es/`. Besides the documentation it has three tools that run entirely in the browser:

- [Sizing simulator](https://rwl.leonardosalas.dev/docs/simulator/): the `rwl size` model, live, from the same constants
- [Measure in the browser](https://rwl.leonardosalas.dev/docs/measure/): the photographic method from photos or a live camera, with files interchangeable with the CLI
- [3D model](https://rwl.leonardosalas.dev/docs/model/): the habitat layout of RWL-004 and the column of RWL-001

```bash
pnpm install --dir site
pnpm --dir site dev # development
pnpm --dir site build # static export into site/out/
```

---

## Building the PDF

The whole technical document is assembled from these Markdown files and the SVG drawings with [doc-engine-cli](https://github.com/leonardosalasd/doc-engine-cli).
[`doc-engine.md`](https://github.com/leonardosalasd/regolith-water-loop/blob/main/doc-engine.md) is the manifest.

```bash
pipx install doc-engine-cli
doc-engine build doc-engine.md
```

---

## Docker

```bash
docker compose up site # site on http://localhost:8080
docker compose run --rm rwl --help
```

---

## Share this project

Share the link directly or scan the code:
[rwl.leonardosalas.dev](https://rwl.leonardosalas.dev)

<div align="center">

<img src="https://raw.githubusercontent.com/leonardosalasd/regolith-water-loop/main/public/qr/qr2_bg_black.png" width="260" alt="QR code linking to the project">

</div>

---

## Support

If this is useful to you, [sponsorship on GitHub](https://github.com/sponsors/leonardosalasd)
funds the parts, the materials and the time that go into documenting it properly.

---

## License

Licensing is split by what you are using:

* **Source code** — [MIT](https://github.com/leonardosalasd/regolith-water-loop/blob/main/LICENSE). Use, modify and build on it freely.
* **Documentation, guides and media** — [CC BY 4.0](https://github.com/leonardosalasd/regolith-water-loop/blob/main/LICENSE-DOCS). Share and adapt with credit.
* **3D models** in [`site/public/models/`](https://github.com/leonardosalasd/regolith-water-loop/tree/main/site/public/models/) — [CC BY-NC-ND 4.0](https://github.com/leonardosalasd/regolith-water-loop/blob/main/site/public/models/LICENSE.md). Share unchanged with credit; no modifications, no commercial use. Textures excluded, see the notice.
