|
<< Click to Display Table of Contents >> Navigation: Users manual > Subroutines > User subroutines > Examples of user subroutines |
The following function contains errors:
The correct function type:
|
|||||||||||||
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
set_target_workpiece()
r =8.314-- Gas constant
-- Declaring user's fields LogZH = result("LogZH") LogZHmax = result("LogZHMax", -1e30) -- Activation energy coefficients as parameters c1 = parameter("C1",156000) c2 = parameter("C2",0) c3 = parameter("C3",0)
function UserFields(prev_Log_LogZHMax, T, strain, strain_rate) -- Converting degrees Celsius to Clvns T = T +273.15 -- Activation energy q = c1 + c2*T + c3*strain -- Zenner-Hollomon parameter simulation parameters z = strain_rate*math.exp(q/(r*T)) -- Natural logarithm lz =math.log(z) -- Determining the maximum value of a logarithm lzm =math.max(prev_LogZHMax, lz) -- Saving a variable for the fields of maxima store(LogZHmax, lzm) -- Saving the logarithm of the Zenner-Hollomon parameter store(LogZH, lz) end |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
A = parameter("A",1600)*1e6 -- value in MPa m1 = parameter("m1",0.002). m2 = parameter("m2",0.170) m3 = parameter("m3",0.144). m4 = parameter("m4",0.570). -- Redefining Lua math operators to keep the record concise exp = math.exp -- Computations of flow stresses function FlowStress (T, strain, strain_rate) F = A*exp(-m1*T)*strain^m2*exp(-m4*strain)*strain_rate^m3 return F end |