Use

The previous Build section showed how to build a pyRat pyrat-....whl Python wheel.

This section describes how to use such wheels in order to install it into a Python virtual environment for better isolation, getting started with pyRat and how to define magnetic simulations with it.

python -m venv venv
source ./venv/bin/activate
python -m pip install ./pyrat-....whl

Once installed into a Python environment, one can import pyRat Python module to have access to all submodules defined in the previous Module pyrat section.

The general use case import statement is the following:

# Rat namespaces and objects (e.g. rat.cmn.Gauss, rat.mdl.Model, ...)
from pyrat import rat

# Colors into global namespace (e.g. KRED, KYEL, KNRM, ...)
from pyrat.col import *

Rat can now be invoked from Python code through the rat submodule to run magnetic simulations, and the col submodule exposes ANSI escapes sequences for colors to the global namespace for easy message formatting when logging results.

Inspiration can be drawn from the several pyRat examples or directly from the original Project-Rat repositories and their examples subdirectories.

Caution

pyRat is still under active development and might lack some functionalities from original Rat C++ libraries for now.