Support : Knowledge base

Knowledge Base

Welcome to OPAL-RT’s Knowledge Base

OPAL-RT offers a repository of support information for optimal use of its technology.

Loading…

Please note that OPAL-RT knowledge base is not fully optimized for mobile platforms.

For optimal experience, use a desktop computer.

Reference Number: AA-02135// Views: AA-02135// Created: 2023-03-09 00:22:54// Last Updated: 2023-03-09 00:25:07
HowTo
How to Use the Time Factor on RT-LAB Python API

If you are performing a testing automation using PythonAPI, one of the variables that you may want to change is the time-step from one simulation execution to another.

The best way to do it is changing is using the Time Factor.

The Time Factor it the value used as a multiplication factor with the calculation step to obtain the effective calculation step.

Example:

Time Step: 0.001s à calculationStep: Calculation step size as specified in the model file

Time Factor: 0.5

Effective calculation step: calculationStep *TimeFactor = 0.001*0.5 = 500us à This is the real time step used during the simulation

 

The Time Factor value can be used directly on RT-LAB, being set on Execution tab of your model:


To use it with Python API to change the Time-Step value between one execution and another, you can define a variable that will receive the time factor value and change the variable value between model executions. This variable should be declared as an argument for the Load and Execute function, like the example below:

TimeFactor   = 1

 

##Load the model

RtlabApi.Load(realTimeMode, TimeFactor)

##Execute the model

RtlabApi.Execute(TimeFactor)


Note: you can not change the time step value during the simulation execution.