Use a Python script as limit-state function

In one of the previous posts, we showed you how to work with in-line Python functions directly in STRUREL. Did you know? You can also use a Python script as limit-state function in STRUREL.

Again, we use the example limit-state function RS that we already used in the past: Our stochastic model consists of the two random variables R and S, where R represents the resistance of a system of interest and S is the system load. The symbolic expression for the corresponding limit-state function in the native syntax of STRUREL would be:

FLIM(1) = R-S

However, if you have Python installed on your system and if the Python interface of STRUREL is configured correctly, you could also use the following expression:

FLIM(1) = pythons("my_model")

where my_model.py is a Pyhton script file located in the same directory as the iti-file of STRUREL.

For the example at hand, the Python script file should look as follows:

res = R - S

where the variable names R and S must match the names of the random variables of the stochastic model of STRUREL. The variable res must contain the value of the limit-state function, where the value of res is later retrieved by STRUREL.

By means of the STRUREL command pythons, you can integrate any limit-state function written in Python directly in your reliability analysis performed with STRUREL.

How to use in-line Python in Strurel

Did you know? You can use in-line Python functions directly in a symbolic expression in STRUREL.

For example, assume a problem for which you have the two random variables R and S in your stochastic model, where R represents the resistance of a system of interest and S is the system load. The symbolic expression for the corresponding limit-state function in the native syntax of STRUREL would be:

FLIM(1) = R-S

However, if you have Python installed on your system and if the Python interface of Strurel is configured correctly, you could also use the following expression:

FLIM(1) = pythonf("R-S")

Sure, calling the Python interpreter for this simple demonstration example is like taking a sledgehammer to crack a nut. However, the interface-function pythonf is a tool that gives you access to the full power of Python directly in the symbolic expression of Strurel.