Metadata-Version: 2.4
Name: llevant
Version: 0.1.1
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Rust
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Topic :: Scientific/Engineering :: Visualization
Requires-Dist: numpy>=1.21
Requires-Dist: pandas>=1.5 ; extra == 'pandas'
Requires-Dist: polars>=1.0 ; extra == 'polars'
Requires-Dist: pytest ; extra == 'test'
Requires-Dist: mypy ; extra == 'test'
Provides-Extra: pandas
Provides-Extra: polars
Provides-Extra: test
License-File: LICENSE
Summary: Fast, exact queries on MCNP geometry, from Python or the command line (python -m llevant)
Keywords: mcnp,geometry,csg,monte-carlo,neutronics
Home-Page: https://fusion4energy.github.io/llevant/
Author: Alvaro Cubi
License: EUPL-1.2
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Documentation, https://fusion4energy.github.io/llevant/
Project-URL: Homepage, https://github.com/Fusion4Energy/llevant
Project-URL: Issues, https://github.com/Fusion4Energy/llevant/issues
Project-URL: Releases, https://github.com/Fusion4Energy/llevant/releases
Project-URL: Source, https://github.com/Fusion4Energy/llevant

# llevant

Fast, exact geometry queries on MCNP models, from Python or the command line.
llevant answers:

- where points are, and what lines cross;
- slices and 3D views;
- volumes, and the gaps and overlaps of a model;
- fingerprints that tell two versions of a model apart.

It reads the MCNP input and handles every universe level, lattice and transform.
It is checked point by point against MCNP 6.2. The Python module is built on the
Rust engine of the same name: models are compiled once (and cached on disk), then
queried in numpy batches.

![The viewer: a reactor core cut open in 3D, beside an exact slice through its fuel pins](https://raw.githubusercontent.com/Fusion4Energy/llevant/main/docs/img/viewer.png)

## Install

```sh
pip install llevant              # numpy comes with it; add polars or pandas for data frames
```

One abi3 wheel serves Python 3.9 and later, on Windows and Linux (x86-64; no macOS
yet). It includes the GPU renderer and the interactive viewer.

## Use

```python
import llevant

m = llevant.load("model.mcnp")          # compiled once (cached on disk), then queried as often as needed
m.locate(0, 0, 0)                       # <Label inside 12 > 304[1,-2,0] > 7>: .cell, .material, .path...
r = m.classify(points)                  # (N, 3) array -> numpy columns: r.ids, r.cell, r.material, r.status
tr = m.trace_lines(starts, ends)        # ragged: tr.offsets, tr.t0, tr.t1, tr.ids, tr.surface_in...
m.slice(z=37, colour="material")        # an Image: shown inline in Jupyter, .save("s.png")
m.render(direction=(1, 1, -0.5), hide=[12], gpu=True)
m.volumes(h=2).by("material")           # volumes with an honest uncertainty
m.check(h=2)                            # gaps and overlaps
f = llevant.Field.read(m, "run.msht", tally=14)   # meshtal, MCTAL, D1SUNED cuvmsh, CSV per cell
m.slice(z=37, field=f)                  # results over the geometry
```

The package also has the `llevant` command and the viewer:

```sh
python -m llevant slice model.mcnp --plane z=37 --colour material -o slice.png
python -m llevant render model.mcnp --gpu -o view.png
python -m llevant view model.mcnp
```

## Documentation

**<https://fusion4energy.github.io/llevant/>**:

- [Install](https://fusion4energy.github.io/llevant/install/) and
  [getting started](https://fusion4energy.github.io/llevant/getting-started/) on an example model
- [How do I…?](https://fusion4energy.github.io/llevant/how-to/): gaps and overlaps, volumes,
  tallies, comparing models
- [Python guide](https://fusion4energy.github.io/llevant/guide/python/) and
  [API reference](https://fusion4energy.github.io/llevant/reference/python-api/)
- [Source, issues and releases](https://github.com/Fusion4Energy/llevant)

Licence: EUPL-1.2.

