Skip to content

Commit

Permalink
Merge pull request #25 from JuliaFEM/uniaxial
Browse files Browse the repository at this point in the history
Adding uniaxial_increment! testing to ensure Materials.jl compatibility.
  • Loading branch information
TeroFrondelius authored Oct 18, 2019
2 parents 7523639 + 66eb37d commit 44ce243
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 18 deletions.
7 changes: 6 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ eps = 1.e-12
include("test_binary_dependencies.jl")
if Sys.islinux()
@testset "Norton model" begin include("test_norton_model.jl") end
include("test_show_methods.jl")

@testset "show methods" begin include("test_show_methods.jl") end

@testset "test MFront ideal plastic material model" begin
include("test_isotropic_linear_hardening_plasticity.jl")
Expand All @@ -30,6 +31,10 @@ eps = 1.e-12

@testset "test MFront together with JuAFEM" begin
include("test_mfront_juafem_3dbeam.jl")

@testset "test plasticity with uniaxial_increment!" begin
include("test_vonmises_uniaxial.jl")
end
end
end
end
37 changes: 20 additions & 17 deletions test/test_show_methods.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
@testset "show methods" begin
b = load("test_show_methods/libBehaviour.so","Norton",mbv.Tridimensional)
BehaviourAllocated_out = @capture_out show(b)
BehaviourAllocated_expected = "behaviour Norton in shared library test_show_methods/libBehaviour.so for modelling hypothesis Tridimensional generated from Norton.mfront using TFEL version: 3.3.0-dev."
@test BehaviourAllocated_out == BehaviourAllocated_expected
using MFrontInterface
using DelimitedFiles
using Suppressor
using Test

d = BehaviourData(b)
RealsVectorRef_out = @capture_out show(get_internal_state_variables(get_initial_state(d)))
RealsVectorRef_expected = "7-element RealsVector\n 0.0\n 0.0\n 0.0\n 0.0\n 0.0\n 0.0\n 0.0\n"
@test RealsVectorRef_expected == RealsVectorRef_out
b = load("test_show_methods/libBehaviour.so","Norton",mbv.Tridimensional)
BehaviourAllocated_out = @capture_out show(b)
BehaviourAllocated_expected = "behaviour Norton in shared library test_show_methods/libBehaviour.so for modelling hypothesis Tridimensional generated from Norton.mfront using TFEL version: 3.3.0-dev."
@test BehaviourAllocated_out == BehaviourAllocated_expected

StringsVectorAllocated_out = @capture_out show(get_parameters(b))
StringsVectorAllocated_expected = "11-element StringsVector\n epsilon\n YoungModulus\n PoissonRatio\n RelativeValueForTheEquivalentStressLowerBoundDefinition\n K\n E\n A\n minimal_time_step_scaling_factor\n maximal_time_step_scaling_factor\n theta\n numerical_jacobian_epsilon\n"
@test StringsVectorAllocated_expected == StringsVectorAllocated_out
d = BehaviourData(b)
RealsVectorRef_out = @capture_out show(get_internal_state_variables(get_initial_state(d)))
RealsVectorRef_expected = "7-element RealsVector\n 0.0\n 0.0\n 0.0\n 0.0\n 0.0\n 0.0\n 0.0\n"
@test RealsVectorRef_expected == RealsVectorRef_out

set_external_state_variable!(get_final_state(d), "Temperature", 293.15)
VariablesVectorAllocated_out = @capture_out show(get_external_state_variables(b))
VariablesVectorAllocated_expected = "1-element VariablesVector\n Temperature\n"
@test VariablesVectorAllocated_expected == VariablesVectorAllocated_out
end
StringsVectorAllocated_out = @capture_out show(get_parameters(b))
StringsVectorAllocated_expected = "11-element StringsVector\n epsilon\n YoungModulus\n PoissonRatio\n RelativeValueForTheEquivalentStressLowerBoundDefinition\n K\n E\n A\n minimal_time_step_scaling_factor\n maximal_time_step_scaling_factor\n theta\n numerical_jacobian_epsilon\n"
@test StringsVectorAllocated_expected == StringsVectorAllocated_out

set_external_state_variable!(get_final_state(d), "Temperature", 293.15)
VariablesVectorAllocated_out = @capture_out show(get_external_state_variables(b))
VariablesVectorAllocated_expected = "1-element VariablesVector\n Temperature\n"
@test VariablesVectorAllocated_expected == VariablesVectorAllocated_out
51 changes: 51 additions & 0 deletions test/test_vonmises_uniaxial.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using MFrontInterface
using Materials
using DelimitedFiles
using Suppressor
using Tensors
using Test

dtime = 0.25
mgis_bv = MFrontInterface.behaviour

function MaterialTest()
lib_path = "test_plasticity/libBehaviour.so"
behaviour_name = "IsotropicLinearHardeningPlasticity"
hypothesis = mgis_bv.Tridimensional

behaviour = load(lib_path, behaviour_name, hypothesis)
behaviour_data = BehaviourData(behaviour)

ext_variable_names = [mgis_bv.get_name(mgis_bv.get_external_state_variables(behaviour)[i]) for i in 1:mgis_bv.length(mgis_bv.get_external_state_variables(behaviour))]
ext_variable_values = zeros(length(ext_variable_names))
ext_vatiable_state = MFrontExternalVariableState(names=ext_variable_names, values=ext_variable_values)

return MFrontMaterial(behaviour=behaviour, behaviour_data=behaviour_data, external_variables=ext_vatiable_state)
end

mat = MaterialTest()

times = [mat.drivers.time]
stresses = [copy(tovoigt(mat.variables.stress))]
stresses_expected = [[50.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[100.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[150.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[100.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[-100.0, 0.0, 0.0, 0.0, 0.0, 0.0]]
dstrain11 = 1e-9*dtime
strains_expected = [[dstrain11, -0.3*dstrain11, -0.3*dstrain11, 0.0, 0.0, 0.0],
[2*dstrain11, -0.3*dstrain11*2, -0.3*dstrain11*2, 0.0, 0.0, 0.0],
[3*dstrain11, -0.3*dstrain11*2 - 0.3*dstrain11, -0.3*dstrain11*2 - 0.3*dstrain11, 0.0, 0.0, 0.0],
[2*dstrain11, -0.3*dstrain11 - 0.3*dstrain11, -0.3*dstrain11 - 0.3*dstrain11, 0.0, 0.0, 0.0],
[-2*dstrain11, 0.3*dstrain11*2, 0.3*dstrain11*2, 0.0, 0.0, 0.0]]
dtimes = [dtime, dtime, dtime, dtime, 1.0]
dstrains11 = [dstrain11, dstrain11, dstrain11, -dstrain11, -4*dstrain11]
for i in 1:length(dtimes)
dstrain11 = dstrains11[i]
dtime = dtimes[i]
uniaxial_increment!(mat, dstrain11, dtime)
update_material!(mat)
@test isapprox(tovoigt(mat.variables.stress), stresses_expected[i])
#@info(tovoigt(mat.drivers.strain; offdiagscale=2.0), strains_expected[i])
@test isapprox(tovoigt(mat.drivers.strain; offdiagscale=2.0), strains_expected[i])
end

0 comments on commit 44ce243

Please sign in to comment.