OUTPUT_SENSOR_EXTENDED
Output
Beta command
This command is in the beta stage and the format may change over time.
"python_file_name"
coid
sid${}_0$, sid${}_1$, $\Delta t_{out}$, fid${}_1$, ..., fid${}_5$
"name${}_1$"
"name${}_2$"
.
"name${}_n$"
Parameter definition
Description
This command is used to add complex user defined variables (signals) to existing sensors (see OUTPUT_SENSOR). Variables are automatically defined by declaring their names (name${}_1$ to name${}_n$).
All calculations are done in a python script python_file_name.py. The script must contain the two functions init and update. init is called at time 0 and it is used to set intitial variable values. update is called every time step and it is used to compute/update the sensor variables.
The computed values are written to the time history file python_file_name_X.out, where X=coid.
Arguments to the python update function are the sensor variables name${}_1$ to name${}_n$, followed by current time, current time step size, effective plastic strain, effective creep strain, damage level, temperature, stress components (6), strain components (6), velocity components (3), current coordinate (3) and finally (if defined) the optional function values fid${}_1$ to fid${}_5$.
Example
Compare two different damage models
A model using OUTPUT_SENSOR_EXTENDED to test and compare two different damage models (Cockcroft-Latham and Johnson-Cook). The damage evolution is evaluated at the sensors with ID's 10 and 11. The results are output to the file damage_55.out.
Command file:
Python script damage.py:
#
# COMPARISON OF DAMAGE MODELS
# dmg_cl - Cockcroft-Latham
# dmg_jc - Johnson-Cook
#
import math
# damage parameters
Wc = 1.0e9
d1 = 0.1
d2 = 0.3
d3 = 0.5
d4 = 0.01
d5 = 0.7
eps_0 = 1.0
T_0 = 0.0
T_m = 1500.0
#
# INITIALIZE DAMAGE
def init():
return [0, 0, 0]
#
# UPDATE DAMAGE
def update(dmg_cl, dmg_jc, epsp_old,
t, dt, epsp, epsc, dmg, T, sig_xx, sig_yy, sig_zz, sig_xy, sig_yz, sig_zx,
eps_xx, eps_yy, eps_zz, eps_xy, eps_yz, eps_zx, vx, vy, vz, x, y, z):
# damage parameters
global Wc, d1, d2, d3, d4, d5, eps_0, T_0, T_m
# incremental plastic strain and strain rate
depsp = epsp - epsp_old
rate = depsp / dt
# principal stresses
[s1, s2, s3] = eigval(sig_xx, sig_yy, sig_zz, sig_xy, sig_yz, sig_zx)
# pressure and von Mises stress
p =-(s1+s2+s3)/3.0
sig_vm = math.sqrt(1.5*( (s1+p)**2 + (s2+p)**2 + (s3+p)**2 ))
# damage increment
if (depsp > 0):
dmg_cl = dmg_cl + max(0,s1,s2,s3)*depsp / Wc
eps_f = (d1 + d2*math.exp(d3*p/sig_vm)) * (1.0 + d4*math.log(rate/eps_0)) * (1.0 + d5*(T - T_0)/(T_m - T_0))
dmg_jc = dmg_jc + depsp / eps_f
return [dmg_cl, dmg_jc, epsp]
#
# COMPUTE PRINCIPAL STRESSES
def eigval(sig_xx, sig_yy, sig_zz, sig_xy, sig_yz, sig_zx):
# constant, linear and quadratic terms in characteristic equation f = x^3 + a2*x^2 + a1*x + a0 = 0
a0 =-sig_xx*sig_yy*sig_zz + sig_xx*sig_yz**2 + sig_xy**2*sig_zz + sig_zx**2*sig_yy - 2.0*sig_xy*sig_yz*sig_zx
a1 =-sig_xy**2 - sig_yz**2 - sig_zx**2 + sig_yy*sig_zz + sig_xx*sig_yy + sig_xx*sig_zz
a2 =-(sig_xx+sig_yy+sig_zz)
Q = a1/3.0 - a2**2/9.0
Q = min(0.0,Q)
R = a1*a2/6.0 - a0/2.0 - a2**3/27.0
T =-a2/3.0
if (Q > -1.0e-10):
cc = 0.0
ss = 0.0
else:
S = max(-1.0,min(1.0,R/math.sqrt(-Q**3)))
theta = math.acos(S)
Q2 = 2.0*math.sqrt(-Q)
cc = Q2*math.cos(theta/3.0)
ss = Q2*math.sin(theta/3.0)
# principal stresses
s1 = cc + T
s2 =-cc/2.0 - math.sqrt(3.0)/2.0*ss + T
s3 =-cc/2.0 + math.sqrt(3.0)/2.0*ss + T
return [s1, s2, s3]
Results in ASCII file damage_55.out: