Metadata-Version: 2.1
Name: treetensor
Version: 0.1.0
Summary: Kinetic plasma simulation on tree tensor networks
Requires-Python: >=3.11
Project-URL: Homepage, https://itsuwari.github.io/vlasov/
Requires-Dist: numpy>=2
Provides-Extra: test
Requires-Dist: scipy>=1.17; extra == "test"
Description-Content-Type: text/markdown

# treetensor

Kinetic plasma simulation on tree tensor networks.
The `ttn` module calls a C++20 runtime in double precision.
The same model runs in the browser as the npm package `@tensortree/plasma`.

```sh
pip install treetensor
```

Wheels exist for Linux x86_64 and aarch64 (glibc 2.17 or later) and for macOS 14 or later on Apple silicon.
Python 3.11 and later are supported.

```python
import math
import ttn as t
x, v = t.periodic("x", 48, [0, 4 * math.pi]), t.periodic("v", 64, [-6, 6])
space, velocity = t.cartesian(x), t.cartesian(v)
density = t.cosine(x, 0.5, offset=1, amplitude=0.04)
electrons = t.species("electrons", charge=-1, mass=1, velocity=velocity,
                      initial=t.normalized(t.maxwellian(velocity, density=density), space.volume))
fields = t.maxwell(c_squared=16, electric=t.vector(x=t.product(-0.08, t.sine(x, 0.5))))
plasma = t.vlasov(space=space, species=[electrons], fields=fields)
Ex = t.observable("Ex", t.component(plasma.fields.electric, "x"))
s = (t.run(plasma).represent(electrons.f, t.ttn(rank=t.automatic(capacity=48)))
     .time(t.fixed_step(0.05, final_time=40)).observe(electrons.f, Ex, plasma.energy.total).compile())
while not s.done:
    s.advance()
    field = s.tensor(Ex)  # NumPy copy over x
```

`TTN_CPU_THREADS` sets the number of CPU executor threads.
Python mirrors the JavaScript API with keyword arguments in snake case; the JavaScript reference is at https://itsuwari.github.io/vlasov/llms.txt.
The live browser demo is at https://itsuwari.github.io/vlasov/.
