/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. |
DAMielem_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. |
| key | Definition |
|---|---|
MONVOL_A(monvol_ID) |
Area of the monitored volume monvol_ID. |
MONVOL_P(monvol_ID) |
Pressure of the monitored volume monvol_ID. |
MONVOL_T(monvol_ID) |
Temperature of the monitored volume monvol_ID. |
MONVOL_VOL(monvol_ID) |
Volume of the monitored volume monvol_ID. |
Definition
| Field | Contents | SI Unit Example |
|---|---|---|
| node_ID | Node identifier or key
ACTIVE_NODE. 4 (Integer) |
|
| elem_ID | Element identifier.
(Integer) |
|
| monvol_ID | Monitored volume
identifier. (Integer) |
Example (Using TIME)
Sinus function using
TIME#---1----|----2----|----3----|----4----|----5----|----6----|----7----|----8----|----9----|---10----|
/FUNCT_PYTHON/1
def disp_X(x):
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:
- /IMPACC, /IMPDISP, /IMPDISP/FGEO, /IMPVEL, /IMPVEL/FGEO, /IMPVEL/LAGMUL
- /CLOAD, /PLOAD, /GRAV, /IMPFLUX, /IMPTEMP
- /MONVOL/AIRBAG1, /MONVOL/COMMU1, /MONVOL/FVMBAG1, /MONVOL/FVMBAG2, /MONVOL/GAS, /MONVOL/LFLUID, /MONVOL/PRES
- /PROP/INJECT1, /PROP/INJECT2
- /PROP/TYPE4 (SPRING), /PROP/TYPE8 (SPR_GENE), /PROP/TYPE12 (SPR_PUL), /PROP/TYPE13 (SPR_BEAM), /PROP/TYPE23 (SPR_MAT), /PROP/TYPE25 (SPR_AXI), /PROP/TYPE26 (SPR_TAB)
- For the node-based option, it is possible to replace the identifier node_ID by the key ACTIVE_NODE to compute the function using the active node values and apply the results on this active node only. It is used to define different values for each node of the set linked to the options:
- 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.