/FUNCT_PYTHON
Block Format Keyword Defines a function defined with Python script.
Format
(1) | (2) | (3) | (4) | (5) | (6) | (7) | (8) | (9) | (10) |
---|---|---|---|---|---|---|---|---|---|
/FUNCT_PYTHON/fct_ID | |||||||||
def function_name(argument) | |||||||||
…Python code… | |||||||||
return variable |
Blank line after the “return” is mandatory
(1) | (2) | (3) | (4) | (5) | (6) | (7) | (8) | (9) | (10) |
---|---|---|---|---|---|---|---|---|---|
Blank line |
Definition
Field | Contents | SI Unit Example |
---|---|---|
fct_ID | Function identifier. | |
function_name | Function name. Must be unique in
the model. (Text) |
|
argument | (Mandatory) Argument of the
function. (Text) |
|
variable | (Mandatory) Output
variable. (Text) |
Radioss Variables
The Python script can use global, nodal or elementary data from Radioss.
key | Definition |
---|---|
TIME |
Current simulation time. |
DT |
Current time step. |
key | Definition |
---|---|
Ci(node_ID) |
Coordinate of node_ID in the global coordinate system. |
Di(node_ID) |
Displacement of node_ID in the global coordinate system. |
Vi(node_ID) |
Translational velocity of node_ID in the global coordinate system. |
Ai(node_ID) |
Translational acceleration of node_ID in the global coordinate system. |
VRi(node_ID) |
Rotational velocity of node_ID in the global coordinate system. |
ARi(node_ID) |
Rotational acceleration of node_ID in the global coordinate system. |
DRi(node_ID) |
Rotation of node_ID in the global coordinate system. |
key | Definition |
---|---|
ALPHA(ELEM_ID) |
Shear angle alpha of material /MAT/LAW58 in degrees for the element ELEM_ID. |
AMS(ELEM_ID) |
Elements using AMS timestep due to /DT/CST_AMS for the element ELEM_ID. |
BFRAC(ELEM_ID) |
Burn fraction of the element ELEM_ID. |
BULK(ELEM_ID) |
Artificial viscosity of the element ELEM_ID. |
COLOR(ELEM_ID) |
Volume fraction color of the element ELEM_ID. |
DAMi(ELEM_ID) |
Principal damage values in local cracking skew direction for the element ELEM_ID. |
DAMA(ELEM_ID) |
Maximum damage over time of all /FAIL criteria for the element ELEM_ID. |
DAMG(ELEM_ID) |
Mean damage over thickness integration points (only for coupled damage models) for the element ELEM_ID. |
DAMINI(ELEM_ID) |
Maximum damage initiation variable among all failure criteria using initiation variable before computing stress softening (/FAIL/INIEVO) for the element ELEM_ID. |
DENS(ELEM_ID) |
Density for the element ELEM_ID. |
DOMAIN(ELEM_ID) |
SPMD domain number of an element for the element ELEM_ID. |
DT(ELEM_ID) |
Element timestep for the element ELEM_ID. |
EINT(ELEM_ID) |
Element internal energy per unit volume for the element ELEM_ID. |
EINTM(ELEM_ID) |
Specific internal energy for the element ELEM_ID. |
EINTV(ELEM_ID) |
Internal energy density for the element ELEM_ID. |
ENER(ELEM_ID) |
Specific energy density (internal energy divided by the element mass) for the element ELEM_ID. |
ENTH(ELEM_ID) |
Enthalpy for the element ELEM_ID. |
ENTHM(ELEM_ID) |
Massic enthalpy for the element ELEM_ID. |
ENTHV(ELEM_ID) |
Enthalpy density for the element ELEM_ID. |
EPSD(ELEM_ID) |
Equivalent strain rate for the element ELEM_ID. |
EPSP(ELEM_ID) |
Plastic strain for the element ELEM_ID. |
FAIL(ELEM_ID) |
Number of failed layers for the element ELEM_ID. |
FAILURE(ELEM_ID) |
Damage of a specific failure criterion references by its optional identifier fail_ID for the element ELEM_ID. |
FILL(ELEM_ID) |
Filling percentage for the element ELEM_ID. |
FLDF(ELEM_ID) |
FLD damage factor indicator for the FLD failure model of the element ELEM_ID. |
FLDZ(ELEM_ID) |
FLD failure zone factor for the FLD failure model of the element ELEM_ID. |
GROUP(ELEM_ID) |
Internal group identifier of the element ELEM_ID. |
HC_DSSE_F(ELEM_ID) |
HC_DSSE damage factor indicator of the element ELEM_ID. |
HC_DSSE_Z(ELEM_ID) |
HC_DSSE failure zone factor for the HC_DSSE failure model of the element ELEM_ID. |
HOURGLASS(ELEM_ID) |
Hourglass energy per mass unit of the element ELEM_ID. |
K(ELEM_ID) |
Specific for turbulent energy in CFD of the element ELEM_ID. |
MACH(ELEM_ID) |
Mach number of the element ELEM_ID. |
MASS(ELEM_ID) |
Element mass of the element ELEM_ID |
MOMi(ELEM_ID) |
Cell momentum Density in direction for FVM with Interface TYPE22 of the element ELEM_ID. |
NL_EPSD(ELEM_ID) |
Non-local plastic strain rate of the element ELEM_ID. |
NL_EPSP(ELEM_ID) |
Non-local plastic strain of the element ELEM_ID. |
NXTF(ELEM_ID) |
Instability factor of /FAIL/NXT failure model of the element ELEM_ID. |
OFF(ELEM_ID) |
Status of the element ELEM_ID. |
P(ELEM_ID) |
Pressure of the element ELEM_ID. |
PHI(ELEM_ID) |
Angle between the element system and direction 1 orthotropy of the element ELEM_ID. |
SCHLIEREN(ELEM_ID) |
Schlieren image of the element ELEM_ID. |
SIGEQ(ELEM_ID) |
Equivalent stress based on a material’s yield criteria of the element ELEM_ID. |
SIGi(ELEM_ID) |
Stress in specified direction of the element ELEM_ID. |
SSP(ELEM_ID) |
Sound speed of the element ELEM_ID. |
TDEL(ELEM_ID) |
Time at which element ELEM_ID is deleted. |
TDET(ELEM_ID) |
Detonation time of the element ELEM_ID. |
TEMP(ELEM_ID) |
Temperature of the element ELEM_ID. |
THICK(ELEM_ID) |
Thickness of the element ELEM_ID. |
THIN(ELEM_ID) |
% thinning for shell of the element ELEM_ID. |
TILLOTSON(ELEM_ID) |
Region identifier for Tillotson Equation of State of the element ELEM_ID. |
TSAIWU(ELEM_ID) |
Tsai-Wu criterion for material of the element ELEM_ID. |
TVIS(ELEM_ID) |
Specific for turbulent viscosity in CFD of the element ELEM_ID. |
VDAMi(ELEM_ID) |
Value of damage for /FAIL/SNCONNECT of the element ELEM_ID. |
VELi(ELEM_ID) |
Cell velocity for FVM with Interface TYPE22 of the element ELEM_ID. |
VFRAC1(ELEM_ID) |
Volumetric fraction of the element ELEM_ID. |
VOLU(ELEM_ID) |
Volume of the element ELEM_ID. |
VONM(ELEM_ID) |
von Mises stress of the element ELEM_ID. |
VORT(ELEM_ID) |
Vorticity resultant for ALE material of the element ELEM_ID. |
VORTi(ELEM_ID) |
Vorticity in direction for ALE material of the element ELEM_ID. |
Example (Using TIME
)
Sinus function using
TIME
#---1----|----2----|----3----|----4----|----5----|----6----|----7----|----8----|----9----|---10----|
/FUNCT_PYTHON/1
def disp_X(x):
import math
X = TIME
Y = 10*math.sin(X*20*math.pi)
return Y
#---1----|----2----|----3----|----4----|----5----|----6----|----7----|----8----|----9----|---10----|
Example (/FUNCT_SMOOTH)
Same function as
/FUNCT_SMOOTH
#---1----|----2----|----3----|----4----|----5----|----6----|----7----|----8----|----9----|---10----|
/FUNCT_PYTHON/1
def smooth_interpolation(x):
X = [0.0 , 1.00000E-02]
Y = [0.0 , -1.33000E+02]
N = len(X)
# Return Y[0] if x is less than the smallest X
if (x < X[0]):
return Y[0]
# Return Y[N-1] if x is greater than the largest X
if (x > X[-1]):
return Y[-1]
# Find the interval where X[i] <= x < X[i+1]
for i in range(N - 1):
if (X[i] <= x < X[i + 1]):
d = (x - X[i]) / (X[i + 1] - X[i])
return Y[i] + (Y[i + 1] - Y[i]) * d * d * d * (10 - 15 * d + 6 * d * d)
# In case x is exactly X[N-1]
return Y[-1]
#---1----|----2----|----3----|----4----|----5----|----6----|----7----|----8----|----9----|---10----|
Example (Nodal)
Sample using nodal
information
#---1----|----2----|----3----|----4----|----5----|----6----|----7----|----8----|----9----|---10----|
/FUNCT_PYTHON/1
def velocity(x):
pos_X = CX(1)
vel_X = VX(1)
#
if (pos_X > 100):
Y = -2000.0
elif (pos_X < 1):
Y = 2000.0
else:
Y = vel_X
return Y
#---1----|----2----|----3----|----4----|----5----|----6----|----7----|----8----|----9----|---10----|
Comments
- The empty line after the “return” is mandatory.
- A function and a table cannot share the same identifier.
- This function can be used with these options: /IMPDISP, /IMPVEL, /IMPACC, /IMPDISP/FGEO, /IMPVEL/FGEO, /IMPVEL/LAGMUL, /IMPTEMP, /CLOAD, /PLOAD, /GRAV, and /IMPFLUX.
- The number of lines in a function is limited to 1000. But it is possible to break a function into multiple functions, since it is possible to call a Python function from another Python function.
- Radioss variables are in “read only” mode from python.
- Python values will always be in double precision.
- The returned value will be 0.0 if the result is there with no data for the requested Radioss variable and element ELEM_ID.
- Radioss uses the Python library
available in the HyperWorks installation. It is
possible to use a different Python distribution by setting the environment
variable
RAD_PYTHON_PATH
. - The option “
-python
” must be added to the Starter command line to confirm that you want to explicitly use a python script with Radioss.