Page 5 - Demo
P. 5
Interface to Python%uf09f%uf09fRCPConsult2017-2025Page 5The assigned global nameswill have the very same names as in the Stochastic Model: Load, Strength, Diameter, PAR1, PAR2and corresponding values. Each global vectorwill have5 elements with corresponding values as ordered above.6.Pythonscript fileThe script file containing a Functionwith a single input argument usually looks likeimportmathdefStrurelPython (xp):# Usesonly vector notation to access values of Variables and Parameters.# The sequence in inputvector xp is predefined by Stochastic Model.returnxp[3]*(math.pi/4)*xp[1]*math.pow(xp[2],2)-xp[4]*xp[0]Here elements of input vector %u2019xp%u2019containing values from global vectorv_XP_can be accessed directly by an index, as is ordered in Stochastic Model of STRUREL.Alternatively, the assigned global namesmay be used also inside of functionimportmathdefStrurelPython (xp):# Uses global names of Variables and Parameters to access their values.# The sequence is arbitrary. Both STRUREL and Python are case sensitive.# Parameters:globalPAR1globalPAR2# Random Variables:globalStrengthglobalDiameterglobalLoadreturn=PAR1*(math.pi/4)*Strength*math.pow(Diameter,2)-PAR2*LoadDirect notation of both global vectorsis also applicableimportmathdefStrurelPython (xp):# Global vector notation to access values of Variables and Parameters.# The sequence in global vector v_XP_ is predefined by Stochastic Model.returnv_XP_[3]*(math.pi/4)*v_XP_[1]*math.pow(v_XP_[2],2)-v_XP_[4]*v_XP_[0]It is permitted to use a mixed mode %u2013global vectors, global namesand arguments in the same function.