/SENSOR/PYTHON
Block Format Keyword Describes a sensor defined Python script and used to activate or deactivate an object.
Format
| (1) | (2) | (3) | (4) | (5) | (6) | (7) | (8) | (9) | (10) |
|---|---|---|---|---|---|---|---|---|---|
| /SENSOR/PYTHON/sens_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 |
|---|---|---|
| sens_ID | Sensor identifier. (Integer, maximum 10 digits) |
|
| 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, elementary or
other sensors 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. |
The Python script can get information from other sensors
using the dictionary sensors and the following syntax:
sensors[sens_ID].get(key)sensors[sens_ID][key]
| Sensor | Sensors Dictionary Keys |
|---|---|
| /SENSOR/DIST | 'type', 'status', 'Distance' |
| /SENSOR/DIST_SURF | 'type', 'status', 'Distance' |
| /SENSOR/ENERGY | 'type', 'status', 'Eint', 'Ekin' |
| /SENSOR/GAUGE | 'type', 'status', 'Pressure' |
| /SENSOR/INTER | 'type', 'status', 'Force' |
| /SENSOR/RWALL | 'type', 'status', 'Force' |
| Other sensors | 'type', 'status' |
Example (Using TIME)
Using global
TIME:#---1----|----2----|----3----|----4----|----5----|----6----|----7----|----8----|----9----|---10----|
/SENSOR/PYTHON/1
def sensor_1(arg):
if TIME >= 0.001:
return 1.0
return 0.0
#---1----|----2----|----3----|----4----|----5----|----6----|----7----|----8----|----9----|---10----|Example (Nodal)
Using nodal
information:
#---1----|----2----|----3----|----4----|----5----|----6----|----7----|----8----|----9----|---10----|
/SENSOR/PYTHON/2
def sensor_2(arg):
wall_disp=DX(30517)
if wall_disp < -20.0:
return 1.0
return 0.0
#---1----|----2----|----3----|----4----|----5----|----6----|----7----|----8----|----9----|---10----|Example (/SENSOR)
Using sensor
information:
#---1----|----2----|----3----|----4----|----5----|----6----|----7----|----8----|----9----|---10----|
/SENSOR/PYTHON/3
def sensor_3(arg):
Internal_energy = sensors[4]['Eint']
if Internal_energy > 1E+07:
return 1.0
return 0.0
#---1----|----2----|----3----|----4----|----5----|----6----|----7----|----8----|----9----|---10----|Comments
- The empty line after the “return” is mandatory.
- Sensors can be used to activate airbags, imposed forces, pressures, and fixed velocities.
- Sensors can be used to activate or deactivate these elements: brick, quad, shell, truss, beam, spring or 3N shell with /ACTIV
- 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 has 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 the user wants to explicitly use a Python script with Radioss.