Skip to content

Commit

Permalink
Initial attempt to parametrize: �NTENS, NSTATV, and NPROPS
Browse files Browse the repository at this point in the history
  • Loading branch information
TeroFrondelius committed Oct 15, 2019
1 parent 0225216 commit 49788fa
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Materials = "35fa313e-aa48-52ea-bc82-ddb91c7db87b"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"

[compat]
julia = "1"
Materials = ">= 0.2.0"
julia = "1"

[extras]
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
Expand Down
2 changes: 1 addition & 1 deletion deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License is MIT: see https://github.com/JuliaFEM/UMAT.jl/blob/master/LICENSE

dependencies = [
"https://github.com/TeroFrondelius/umat_binaries_builder/releases/download/v0.3.2/build_umat_binaries.v0.1.0.jl"
"https://github.com/TeroFrondelius/umat_binaries_builder/releases/download/v0.4.0/build_umat_binaries.v0.2.0.jl"
]

for build_script in dependencies
Expand Down
43 changes: 32 additions & 11 deletions src/UMAT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,18 @@ Variables updated by UMAT routine.
DRPLDE :: Array{Float64,1} = zeros(Float64, NTENS)
DRPLDT :: Array{Float64,1} = zeros(Float64, 1)
PNEWDT :: Array{Float64,1} = ones(Float64, 1)

NTENS :: Integer
NSTATV :: Integer
end

"""
Material parameters in order that is specific to chosen UMAT.
"""
@with_kw struct UmatParameterState <: AbstractMaterialState
PROPS :: Array{Float64,1} = zeros(Float64, NPROPS)

NPROPS :: Integer
end

"""
Expand All @@ -50,6 +55,8 @@ These drive evolution of the material state.
TIME :: Array{Float64,1} = zeros(Float64, 2)
TEMP :: Float64 = zero(Float64)
PREDEF :: Float64 = zero(Float64)

NTENS :: Integer
end

"""
Expand All @@ -59,9 +66,9 @@ Other Abaqus UMAT variables passed in for information.
CMNAME :: Cuchar = 'U'
NDI :: Int64 = 3
NSHR :: Int64 = 3
NTENS :: Int64 = NTENS # NDI + NSHR
NSTATV :: Int64 = NSTATV #zero(Int64)
NPROPS :: Int64 = NPROPS #zero(Int64)
NTENS :: Int64 # NDI + NSHR
NSTATV :: Int64
NPROPS :: Int64
COORDS :: Array{Float64,1} = zeros(Float64, 3)
DROT :: Array{Float64,2} = I + zeros(Float64, 3, 3)
CELENT :: Float64 = zero(Float64)
Expand All @@ -85,19 +92,24 @@ UMAT material structure.
MFront Abaqus interface produces specific name, e.g. `ELASTICITY_3D`.
"""
@with_kw mutable struct UmatMaterial <: AbstractMaterial
drivers :: UmatDriverState = UmatDriverState()
ddrivers :: UmatDriverState = UmatDriverState()
variables :: UmatVariableState = UmatVariableState()
variables_new :: UmatVariableState = UmatVariableState()
parameters :: UmatParameterState = UmatParameterState()
dparameters :: UmatParameterState = UmatParameterState()
drivers :: UmatDriverState = UmatDriverState(NTENS=NTENS)
ddrivers :: UmatDriverState = UmatDriverState(NTENS=NTENS)
variables :: UmatVariableState = UmatVariableState(NTENS=NTENS, NSTATV=NSTATV)
variables_new :: UmatVariableState = UmatVariableState(NTENS=NTENS, NSTATV=NSTATV)
parameters :: UmatParameterState = UmatParameterState(NPROPS=NPROPS)
dparameters :: UmatParameterState = UmatParameterState(NPROPS=NPROPS)

umat_other :: UmatOtherState = UmatOtherState()
umat_other :: UmatOtherState = UmatOtherState(NTENS=NTENS, NSTATV=NSTATV, NPROPS=NPROPS)

lib_path :: String
behaviour :: Symbol = :umat_

NTENS :: Integer
NSTATV :: Integer
NPROPS :: Integer
end


"""
Wrapper function to ccall the UMAT subroutine from the compiled shared library.
"""
Expand Down Expand Up @@ -139,9 +151,18 @@ function integrate_material!(material::UmatMaterial)
NTENS, NSTATV, PROPS, NPROPS, COORDS, DROT, PNEWDT, CELENT, DFGRD0, DFGRD1,
NOEL, NPT, LAYER, KSPT, KSTEP, KINC)

variables_new = UmatVariableState(STRESS=STRESS,STATEV=STATEV,DDSDDE=DDSDDE,SSE=SSE,SPD=SPD,SCD=SCD,RPL=RPL,DDSDDT=DDSDDT,DRPLDE=DRPLDE,DRPLDT=DRPLDT,PNEWDT=PNEWDT)
variables_new = UmatVariableState(NSTATV=NSTATV,NTENS=NTENS,STRESS=STRESS,STATEV=STATEV,DDSDDE=DDSDDE,SSE=SSE,SPD=SPD,SCD=SCD,RPL=RPL,DDSDDT=DDSDDT,DRPLDE=DRPLDE,DRPLDT=DRPLDT,PNEWDT=PNEWDT)
material.variables_new = variables_new
end

function Materials.reset_material!(material::UmatMaterial)
material.ddrivers = UmatDriverState(NTENS=NTENS)
material.dparameters = UmatParameterState(NPROPS=NPROPS)
material.variables_new = UmatVariableState(NTENS=NTENS, NSTATV=NSTATV)
return nothing
end

include("umat_models.jl")

export UmatMaterial, UmatDriverState, UmatParameterState, UmatVariableState, UmatOtherState
end # module
2 changes: 2 additions & 0 deletions src/umat_models.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/UMAT.jl/blob/master/LICENSE
5 changes: 3 additions & 2 deletions test/test_elastic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ else
lib_dir = joinpath(pkg_dir,"..","deps","usr","lib")
end

material = UmatMaterial(lib_path=joinpath(lib_dir,"libelastic." * dlext))
material = UmatMaterial(NTENS=4, NSTATV=0, NPROPS=0,
lib_path=joinpath(lib_dir,"libelastic." * dlext))

strains = [1.0e-3, 0.0, 0.0, 0.0]
ref_stress = [282.6923171355886, 121.1538570784259, 121.1538570784259, 0.0]
material.ddrivers = UmatDriverState(STRAN = strains)
material.ddrivers = UmatDriverState(NTENS=4, STRAN = strains)
UMAT.integrate_material!(material)
update_material!(material)

Expand Down
4 changes: 2 additions & 2 deletions test/test_umatmaterial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ else
end

E = 160e9; NU = 0.3; SYIELD = 100
parameters = UmatParameterState([E, NU, SYIELD])
material = UmatMaterial(parameters=parameters,
#parameters = UmatParameterState(NPROPS=3,[E, NU, SYIELD])
material = UmatMaterial(NTENS=6, NSTATV=0, NPROPS=3,
lib_path=joinpath(lib_dir,"libmises_umat." * dlext),
behaviour=:mises_umat_)

0 comments on commit 49788fa

Please sign in to comment.