Structure

pyRat is structured as a somewhat hybrid C++ and Python project.

Repository structure

pyrat/
├── figs/            ← Figures and images
├── include/         ← C++ headers: docstrings, one per bound class
│   ├── <library>/   ← one directory per Rat library, as in src/
│   ├── utils/       ← C++ utilities (prelude, type casters, macros, GIL)
│   ├── rat.hh       ← pyrat.rat module docstring
├── scripts/         ← build_wheel.py (wheels), stubgen.py (stubs)
├── src/             ← C++ and Python source files
│   ├── arma/        ← Armadillo internals (random generator)
│   ├── common/      ← Rat-Common bindings
│   ├── dmsh/        ← Rat-Distmesh bindings
│   ├── mat/         ← Rat-Materials bindings
│   ├── math/        ← Rat-Math bindings
│   ├── mlfmm/       ← Rat-MLFMM bindings
│   ├── models/      ← Rat-Models bindings
│   ├── nl/          ← Rat-NL bindings
│   ├── pyrat/       ← Python sources for other submodules, examples
│   ├── rat.cpp      ← pyrat.rat module definition
├── tests/           ← Python unit tests
├── .clang-format    ← C++ formatting rules
├── .gitattributes   ← Line endings (LF everywhere)
├── .gitignore       ← Git ignored items (e.g. build)
├── CHANGELOG.md     ← Changelog for evolution tracking
├── CMakeLists.txt   ← C++ CMake configuration file
├── CONTRIBUTING.md  ← Contributing guidelines file
├── LICENSE.md       ← MIT license file
├── pyproject.toml   ← Python project specifications
├── README.md        ← Repository simple information

The C++ part is used to build the pyrat.rat submodule which acts as the bridge between Python and Rat C++ libraries. It is then aggregated into a global pyrat Python module along with other pure Python submodules shipping various helpers.

The bindings are defined in the src directory, and their documentation (the docstrings) in the include directory.

The CMakeLists.txt configuration file uses macros defined by pybind11 to easily define a Python module and how to compile it. It then links the produced rat library to the Rat libraries selected by its PYRAT2_* options (see Manual build).

Module structure

        ---
align: center
alt: pyRat Python module structure
name: pyrat_python_module_structure
config:
    theme: 'neutral'
---

    flowchart LR
        pyrat(pyrat)

        subgraph python["Python"]
            direction TB

            cli(cli) --> pyrat
            col(col) --> pyrat
            log(log) --> pyrat
            meta(meta) --> pyrat
            typ(typ) --> pyrat
        end

        subgraph cpp["C++"]
            direction TB

            rat --> pyrat
            arma(arma) --> rat
            cmn(cmn) --> rat
            math(math) --> rat
            dm(dm) --> rat
            mat(mat) --> rat
            fmm(fmm) --> rat
            nl(nl) --> rat
            mdl(mdl) --> rat
        end