Author(s): Tero Frondelius
Abstract: making the initial version to call Abaqus umat
In [1]:
run(`wget http://www.eng.ox.ac.uk/NP/ICP/plasticity_imp/code_imp.f`)
In [2]:
run(`head -30 code_imp.f`)
In [3]:
f = open("ABA_PARAM.INC","w")
write(f," implicit real*8(a-h,o-z)\n")
write(f," parameter (nprecd=2)\n")
close(f)
In [4]:
run(`gfortran -shared -fPIC -o libumat.so code_imp.f`)
variable | explanation |
---|---|
DDSDDE(NTENS,NTENS) | Jacobian matrix of the constitutive model |
STRESS(NTENS) | the stress tensor (in vector format) |
STATEV(NSTATV) | An array containing the solution-dependent state variables. |
SSE | Specific elastic strain energy |
SPD | plastic dissipation |
SCD | “creep” dissipation |
RPL | Volumetric heat generation per unit time |
DDSDDT(NTENS) | Variation of the stress increments with respect to the temperature. |
DRPLDE(NTENS) | Variation of RPL with respect to the strain increments. |
DRPLDT | Variation of RPL with respect to the temperature. |
RPL | RPL is used to indicate whether or not a cohesive element is open to the tangential flow of pore fluid. |
PNEWDT | Ratio of suggested new time increment to the time increment being used |
STRAN(NTENS) | An array containing the total strains at the beginning of the increment. |
DSTRAN(NTENS) | Array of strain increments. |
TIME(1) | Value of step time at the beginning of the current increment. |
TIME(2) | Value of total time at the beginning of the current increment. |
DTIME | Time increment. |
TEMP | Temperature at the start of the increment. |
DTEMP | Increment of temperature. |
PREDEF | Array of interpolated values of predefined field variables at this point at the start of the increment, based on the values read in at the nodes. |
DPRED | Array of increments of predefined field variables. |
CMNAME | User-defined material name, left justified. |
NDI | Number of direct stress components at this point. |
NSHR | Number of engineering shear stress components at this point. |
NTENS | Size of the stress or strain component array (NDI + NSHR). |
NSTATV | Number of solution-dependent state variables that are associated with this material type |
PROPS(NPROPS) | User-specified array of material constants associated with this user material. |
NPROPS | User-defined number of material constants associated with this user material. |
COORDS | An array containing the coordinates of this point. |
DROT(3,3) | Rotation increment matrix. |
CELENT | Characteristic element length |
DFGRD0(3,3) | Array containing the deformation gradient at the beginning of the increment. |
DFGRD1(3,3) | Array containing the deformation gradient at the end of the increment. |
NOEL | Element number. |
NPT | Integration point number. |
LAYER | Layer number (for composite shells and layered solids). |
KSPT | Section point number within the current layer. |
KSTEP | Step number. |
KINC | Increment number. |
In [5]:
STRESS = [0. 0. 0. 0.]
p = 0. # EFFECTIVE PLASTIC STRAIN
r = 0. # ISOTROPIC HARDENING VARIABLE
STATEV = [p r]
NTENS = 4
DDSDDE = zeros(NTENS,NTENS)
SSE = {} # Not used in this example
SPD = {} # Not used in this example
SCD = {} # Not used in this example
RPL = {} # Not used in this example
DDSDDT = {} # Not used in this example
DRPLDE = {} # Not used in this example
DRPLDT = {} # Not used in this example
STRAN = [0. 0. 0. 0.]
DSTRAN = [0. 0. 0. 0.]
TIME = [0. 0.1] # CHECK TIME(2)
DTIME = {} # Not used in this example
TEMP = {} # Not used in this example
DTEMP = {} # Not used in this example
PREDEF = {} # Not used in this example
DPRED = {} # Not used in this example
CMNAME = {} # Not used in this example CHARACTER*80 CMNAME
NDI = {} # Not used in this example
NSHR = {} # Not used in this example
#NTENS correct place
NSTATV = length(STATEV)
PROPS = {} # Not used in this example
NPROPS = {} # Not used in this example
COORDS = {} # Not used in this example
DROT = {} # Not used in this example
PNEWDT = {} # Not used in this example EXPLANATION MISSING
CELENT = {} # Not used in this example
DFGRD0 = {} # Not used in this example
DFGRD1 = {} # Not used in this example
NOEL = {} # Not used in this example
NPT = {} # Not used in this example
LAYER = {} # Not used in this example
KSPT = {} # Not used in this example
KSTEP = {} # Not used in this example
KINC = {} # Not used in this example
Out[5]:
In [6]:
ccall((:umat_, "./libumat"), Int64,
(Ptr{Float64},Ptr{Float64},Ptr{Float64},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},
Ptr{Float64},Ptr{Float64},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},
Ptr{Int64},Ptr{Int64},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},
Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void}),
STRESS,STATEV,DDSDDE,SSE,SPD,SCD,RPL,DDSDDT,DRPLDE,DRPLDT,
STRAN,DSTRAN,TIME,DTIME,TEMP,DTEMP,PREDEF,DPRED,CMNAME,NDI,NSHR,
&NTENS,&NSTATV,PROPS,NPROPS,COORDS,DROT,PNEWDT,CELENT,DFGRD0,DFGRD1,
NOEL,NPT,LAYER,KSPT,KSTEP,KINC)
Out[6]:
In [7]:
DDSDDE
Out[7]:
In [8]:
STATEV
Out[8]:
In [29]:
function isotropichardening!(stress,p,r,jacobian,strain,DSTRAN)
local STRESS = stress
local STATEV = [p r]
local DDSDDE = jacobian
local STRAN = strain
o = ccall((:umat_, "./libumat"), Int64,
(Ptr{Float64},Ptr{Float64},Ptr{Float64},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},
Ptr{Float64},Ptr{Float64},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},
Ptr{Void},Ptr{Int64},Ptr{Int64},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},
Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void},Ptr{Void}),
STRESS,STATEV,DDSDDE,SSE,SPD,SCD,RPL,DDSDDT,DRPLDE,DRPLDT,
STRAN,DSTRAN,TIME,DTIME,TEMP,DTEMP,PREDEF,DPRED,CMNAME,NDI,
NSHR,&NTENS,&NSTATV,PROPS,NPROPS,COORDS,DROT,PNEWDT,CELENT,DFGRD0,DFGRD1,
NOEL,NPT,LAYER,KSPT,KSTEP,KINC)
stress = STRESS
p = STATEV[1]
r = STATEV[2]
jacobian = DDSDDE
strain = STRAN + DSTRAN
if o != 0
throw("UMAT failed. Return code is $o")
end
return o
end
Out[29]:
In [30]:
p = 0.0
r = 0.0
S = [0. 0. 0. 0.]
strain = [0. 0. 0. 0.]
for i in range(0,0.0001,11)
DSTRAN = [i 0. 0. 0.]
out = isotropichardening!(S,p,r,DDSDDE,strain,DSTRAN)
println(out,S,p,r, DSTRAN)
#println(i)
end
In [11]:
fil = open("code_imp.f")
sub_list = Set{ASCIIString}()
for line in readlines(fil)
# Fortran comment = something non whitespce at the firts character
if ismatch(r"^[^\s]",line)
#println(line)
continue
end
if ismatch(r"call",lowercase(line))
call = split(lowercase(line))[2] #divede by white space
sub = split(call,"(")[1] #divide by "("
#println(sub)
push!(sub_list,sub)
end
end
close(fil)
In [12]:
sub_list
Out[12]:
In [13]:
fil = open("code_imp.f")
fun_list = Set{ASCIIString}()
for line in readlines(fil)
if ismatch(r"^[^\s]",line)
#println(line)
continue
end
comp = lowercase(line)
if ismatch(r"subroutine",comp) || ismatch(r"funtion",comp) || ismatch(r"external",comp)
#println(line)
call = split(lowercase(line),"(")[1] #divede by white space
sub = split(call)[end] #divide by "("
#if length(sub) > 1
# sub = sub[2]
#end
#println(sub)
push!(fun_list,sub)
end
end
close(fil)
In [14]:
fun_list
Out[14]:
In [16]:
setdiff(sub_list,fun_list)
Out[16]: