Examples

The pyrat/src/pyrat/examples subdirectory contains Python examples. These are translations from the original Rat C++ examples defined across the Project-Rat repositories.

The pyRat Python module directly ships these Python examples through the pyrat CLI in order to quickly get started.

  • List all available examples:

python -m pyrat -e

Examples can be generated from the list using patterns:

  • Generate examples from patterns:

python -m pyrat -e              # list all available examples
python -m pyrat -e moon         # generate rat/dm/moon.py example
python -m pyrat -e dmsh*        # generate rat/mdl/dmesher/{dmshcoil.py, dmshyoke1.py, dmshyoke2.py} examples
python -m pyrat -e mdl/**       # generate all Rat-Models examples
python -m pyrat -e rat-template # generate rat/rat-template/rat-template.py example
python -m pyrat -e **           # generate all examples

Examples will be stored under a generated ./examples directory like so:

examples/
├── rat/
    ├── dm/
    ├── fmm/
    ├── mat/
    ├── mdl/
    |   ├── asbuild/
    |   ├── dmesher/
    |   ├── nlsolver/
    |   ├── other/
    |   ├── simple/
    ├── rat-template/
  • Run any example:

python examples/rat/rat-template/rat_template.py