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.

Use a Matlab script as limit-state function

In one of the previous posts, we showed you how to work with in-line Matlab functions directly in STRUREL. Did you know? You can also use a Matlab 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 Matlab installed on your system and if the Matlab interface of STRUREL is configured correctly, you could also use the following expression:

FLIM(1) = matlabs("my_model")

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

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

function [lsfval] = my_model(INPUT)

R = INPUT(1);
S = INPUT(2);

lsfval = R - S

end

The ordering of the random variables in the vector INPUT corresponds to the order in which they appear in the stochastic model of STRUREL.

Alternatively, the Matlab script file could look as follows:

function [lsfval] = my_model(INPUT)

global R;
global S;

lsfval = R - S

end

where the variable names R and S must match the names of the random variables of the stochastic model of STRUREL.

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

How to use in-line Matlab in Strurel

In the last post, we showed you how to work with in-line Python functions directly in STRUREL. Did you know? You can also use in-line Matlab 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 Matlab installed on your system and if the Matlab interface of STRUREL is configured correctly, you could also use the following expression:

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

Sure, calling the Matlab interpreter for this simple demonstration example is like taking a sledgehammer to crack a nut. However, the interface-function matlabf is a tool that gives you access to the full power of Matlab directly in the symbolic expression of 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.

Couple a FORTRAN library with Strurel (MinGW-compiler)

The latest version of Sturel allows you to couple external libraries with the application. In this post we show how to link a limit-state function written in FORTRAN to Comrel. As compiler we employ a variant of the free MinGW compiler (https://mingw-w64.org/).

Install the 64-bit MinGW compiler

First, you have to download the installer mingw-w64-install.exe from https://sourceforge.net/projects/mingw-w64/. Thereafter, please execute the downloaded installer and select x86-64 as architecture (you do not have to modify the other settings).

Compile the FORTRAN limit-state function

We assume that you implemented your limit-state function of interest in FORTRAN. A FORTRAN limit-state function that you can use as template can be downloaded from: http://strurel.com/files_blog/DLL_GNU_FORTRAN/Module.for

In this tutorial, we will directly compile the above mentioned file. The function is compiled using the Windows command prompt (cmd.exe). In the command prompt, first go to the installation directory of mingw-w64 (you can change directories with the command cd) and execute the bat-file mingw-w64.bat. Thereafter, to the folder containing the FORTRAN limit-state function and execute the following commands:

gfortran -fno-underscoring -c Module.for
gfortran -O3 -shared -o FORDLL.dll Module.o

where Module.for is the name of the FORTRAN file to compile and FORDLL.dll is the name of the DLL-library to generate.

If you do not have the FORTRAN compiler installed, you can download the compiled library from:
http://strurel.com/files_blog/DLL_GNU_FORTRAN/FORDLL.dll

Load the compiled library in Comrel

If you compiled the above mentioned template file without modifications, you can download the file Comrel file Pressure-Vessel.iti from:
http://strurel.com/files_blog/DLL_GNU_FORTRAN/Pressure-Vessel.iti
Put the file in the same folder as the compiled library (e.g., FORDLL.dll), and open the file with Comrel to see how the library can be used to perform a reliability analysis.

 

Presented RELY at the SOFiSTiK Seminar

The 25th SOFiSTiK Seminar took place on Friday and Saturday last week. We presented the SOFiSTiK module RELY, a coupling of the kernel of Strurel with the finite element package SOFiSTiK.

Abstract: RELY is a novel SOFiSTiK module for reliability analysis. It allows to employ the full capabilities of the SOFiSTiK finite element package to model the engineering system of interest, in combination with a powerful stochastic model and analysis toolbox. The kernel of RELY is powered by Strurel, one of the leading reliability software tools.
We show how to apply RELY to perform reliability analysis of a conventionally driven tunnel. Model parameters that are subject to considerable uncertainty are represented stochastically. The first-order reliability method (FORM) is employed to estimate the reliability of the outer tunnel lining. Sensitivity information provided by FORM is used to quantify the relative importance of the stochastic model parameters.