Metadata-Version: 2.4
Name: genkai
Version: 0.1.0
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: 3
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering
License-File: LICENSE
License-File: NOTICE
Summary: 限界 (Genkai) — pure-Rust structural cross-section analysis & EN 1992 RC/PSC design engine, with a Python API. Every section checked against its limit state (限界状態 · genkai jōtai).
Author: Pavlishenku
License-Expression: Apache-2.0
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Changelog, https://github.com/Pavlishenku/Genkai/blob/main/CHANGELOG.md
Project-URL: Documentation, https://github.com/Pavlishenku/Genkai/tree/main/docs
Project-URL: Homepage, https://github.com/Pavlishenku/Genkai
Project-URL: Issues, https://github.com/Pavlishenku/Genkai/issues
Project-URL: Repository, https://github.com/Pavlishenku/Genkai

<p align="center">
  <img src="https://raw.githubusercontent.com/Pavlishenku/Genkai/main/brand/genkai-banner.png" alt="限界 Genkai — structural cross-sections, pushed to the limit" width="100%">
</p>

<h1 align="center">限界 · Genkai</h1>

<p align="center"><em>Structural cross-sections, pushed to the limit.</em></p>

<p align="center">
  <img src="https://img.shields.io/badge/license-Apache--2.0-2da44e" alt="License: Apache-2.0">
  <img src="https://img.shields.io/badge/status-pre--alpha-C8432B" alt="Status: pre-alpha">
  <img src="https://img.shields.io/badge/python-3.9%2B-243F59" alt="Python 3.9+">
  <img src="https://img.shields.io/badge/rust-1.83%2B-383B40" alt="Rust 1.83+">
</p>

---

**Genkai** (限界, *"the limit"*) is a pure-Rust engine for structural cross-section
analysis, exposed through a Python API and a desktop GUI.

It computes the geometric, elastic, plastic, and warping/torsion properties of arbitrary
cross-sections (massive or thin-walled, with holes, single- or multi-material), and has grown
into a reinforced and prestressed concrete (RC/PSC) section design and verification engine to
the Eurocodes (EN 1992).

> **Why the name.** In structural engineering, **限界状態** (*genkai jōtai*) is the **limit
> state** — the ultimate and serviceability limits that the whole of Eurocode design is built
> around. Every section this engine touches is checked against its limit. And **もう限界**
> (*mou genkai*, *"I'm at my limit"*) is, roughly, how it felt to name the thing. The name
> stuck for both reasons.

Status: pre-alpha. Phases 1–5 are shipped (geometry/elastic/plastic/warping replacing
`sectionproperties`, multi-material, thin-wall shear/torsion, and an EN 1992 RC/PSC design
engine); Phases 6 (EN 1992 conformance hardening) and 7 (design feature-parity) are
outstanding. See [CHANGELOG.md](CHANGELOG.md) for completed work.

## Why

- **Performance** — a native, parallel Rust core (single sparse factorization reused across
  right-hand sides, GIL-free assembly) instead of interpreted Python.
- **Independence** — a fully owned, permissively licensed computation stack with no third-party
  analysis engine.
- **Scope** — multi-material sections and RC/PSC design to the Eurocodes, an area not covered
  by existing open tools.

## Architecture

- `crates/genkai-core` — pure Rust computation core: geometry, meshing, finite-element warping,
  and section properties. No Python, no GUI.
- `crates/genkai-py` — PyO3 bindings exposing the `genkai._genkai` extension module.
- `crates/genkai-gui` — Tauri v2 desktop backend over the core (serde DTOs). The frontend lives
  in `gui/` (React + Vite + TypeScript).
- `python/genkai` — the Python package surface.
- `docs/theory` — the theory manual (mdBook): derivations and validation references.
- `docs/api` — the Python API guide (mdBook): how to drive the engine, with runnable examples.

## At a glance

```python
import genkai

g = genkai.Geometry(outers=[[(0, 0), (100, 0), (100, 60), (0, 60)]])
sec = genkai.Section(g, material=genkai.Material("steel", 200e3, 0.3, 355, 7.85e-9))

geo = sec.geometric()                 # frozen results: .area, .ixx_c, .perimeter, …
solved = sec.analyze(mesh_size=5.0)   # mesh + warping solve, once
warp = solved.warping()               # .j, .cw, .x_se, …
stress = solved.stress(mxx=1e6, mzz=5e4)
```

## Technology stack

Permissive licenses only, enforced in CI by [`deny.toml`](deny.toml):

| Concern | Crate |
|---|---|
| Polygon boolean ops | `geo` / `i_overlay` |
| Quality meshing | `spade` (constrained Delaunay + Ruppert refinement) |
| Sparse direct solver | `faer` |
| Python bindings / packaging | `pyo3`, `rust-numpy`, `maturin` |
| Desktop GUI | `tauri` |

## Build (developer)

Requires Rust (stable, MSRV 1.83). Building the GUI backend (`crates/genkai-gui`) additionally
needs the frontend bundle, which Tauri embeds at compile time — build it first:

```
cd gui && npm ci && npm run build   # produces gui/dist (required by `cargo build --workspace`)
cd ..
```

Then the Rust workspace:

```
cargo build --workspace      # build the Rust core, bindings, and GUI backend
cargo test  --workspace      # run the Rust test suite
cargo deny  check            # license and advisory gate
```

The Python extension is built and installed into the active virtual environment with
[maturin](https://github.com/PyO3/maturin) — the recommended developer loop:

```
maturin develop              # build + install `genkai` (editable) into the active venv
pytest python/tests          # run the Python test suite
```

To rebuild the extension manually without maturin, build the crate and copy the artifact next to
the package using the name for your platform:

```
cargo build -p genkai-py
# Linux:    cp target/debug/lib_genkai.so   python/genkai/_genkai.so
# macOS:    cp target/debug/lib_genkai.dylib python/genkai/_genkai.so
# Windows:  copy target\debug\_genkai.dll    python\genkai\_genkai.pyd
```

## License

Genkai is licensed under the [Apache License 2.0](LICENSE). You are free to use, modify, and
distribute it, **including for commercial purposes**, provided you retain the copyright and
[NOTICE](NOTICE) attribution as required by the License.

## Citation

If you use Genkai in academic, professional, or commercial work, please cite it. GitHub renders a
**"Cite this repository"** button from [CITATION.cff](CITATION.cff); attribution in any derived
product, publication, or report is requested.

