Configuration

Configuration of the Core Package

Several constants that control numerical or algorithmic behavior are defined in the Config class. The class supports determining the configuration values in 3 ways: by predefined default value, by environment variables and by setting through Python code. The default value is the value set in the class definition as listed below. Environment variables following the pattern PYROLL_CORE_<NAME_OF_THE_CONSTANT> can be used to set the configuration from the shell environment. The prefix PYROLL_CORE is required for the config class of the pyroll.core package. Other package may define their own config classes with different prefixes, see their respective documentation.

To set an environment variable under Unix, execute the following before executing a PyRolL script or the PyRolL CLI. You may also add the following line to your shell’s run configuration (.bashrc, .zshrc, …) to have it always present when launching a new shell.

export PYROLL_CORE_DEFAULT_MAX_ITERATION_COUNT=50

Under Windows, you have to edit the environment variables using the system settings.

You can also set the value in Python code like any other variable. This type of setting takes precedence over environment variables.

from pyroll.core import Config

Config.DEFAULT_MAX_ITERATION_COUNT = 50
class Config

Configuration class for pyroll.core.

AVOGADRO_CONSTANT = 6.02214076e+23

Avogadro constant NA.

BOLTZMANN_CONSTANT = 1.380649e-23

Boltzmann constant kB.

DEFAULT_ITERATION_PRECISION = 0.001

Default precision of iteration loops required to break successfully.

DEFAULT_MAX_ITERATION_COUNT = 100

Default maximum count of iterations before aborting the loop.

GROOVE_PADDING = 0.2

Fraction of the total groove width that is added at the sides of the groove contour to represent the roll face.

GROOVE_RADIUS_POINT_COUNT = 20

Count of points used to represent the radii in a generic elongation groove as line string.

PLOT_HEIGHT = 480

Height of plots (using ReprMixin) in pixels.

PLOT_RESOLUTION = 100

Resolution of plots in dots per inches (dpi).

PLOT_WIDTH = 640

Width of plots (using ReprMixin) in pixels.

PREFERRED_PLOTTING_BACKEND = 1

Sets the preferred plotting backend to use when both matplotlib and plotly are installed.

PROFILE_CONTOUR_REFINEMENT = 0

Refine the line string of profile contours with more intermediate points. Higher integers mean finer. Values < 1 disable this feature.

ROLL_PASS_AUTO_ROTATION = True

Whether to enable automatic rotation of incoming profiles in roll passes by default.

ROLL_SURFACE_DISCRETIZATION_COUNT = 100

Count of discrete points used to describe the roll surface.

STANDARD_GRAVITY = 9.80665

Standard acceleration of gravity g0.

STEFAN_BOLTZMANN_CONSTANT = 5.670374419e-08

Stefan-Boltzmann radiation constant σ.

UNIVERSAL_GAS_CONSTANT = 8.31446261815324

Universal gas constant R.

Creating Configurations for Plugin Packages

If you are developing your own plugin or extension you may create your own config class using the config() decorator. The only argument to this decorator is the prefix used for the environment variables (like PYROLL_CORE above).

config(env_var_prefix)

Decorator for creating config classes. Automatically creates a metaclass with respective ConfigValue descriptors for class attributes with uppercase names that do not start with underscore.

Use it as follows:

@config("PREFIX")
class Config:
    VAR1 = 42
    VAR2 = "abc"

    # not modified
    _PRIV_VAR = None
    normal_var = None
Parameters:

env_var_prefix – prefix for the respective env vars, should be uppercase and delimited by underscores