Skip to content

Commit 44ce243

Browse files
Merge pull request #25 from JuliaFEM/uniaxial
Adding uniaxial_increment! testing to ensure Materials.jl compatibility.
2 parents 7523639 + 66eb37d commit 44ce243

File tree

3 files changed

+77
-18
lines changed

3 files changed

+77
-18
lines changed

test/runtests.jl

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ eps = 1.e-12
1414
include("test_binary_dependencies.jl")
1515
if Sys.islinux()
1616
@testset "Norton model" begin include("test_norton_model.jl") end
17-
include("test_show_methods.jl")
17+
18+
@testset "show methods" begin include("test_show_methods.jl") end
1819

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

3132
@testset "test MFront together with JuAFEM" begin
3233
include("test_mfront_juafem_3dbeam.jl")
34+
35+
@testset "test plasticity with uniaxial_increment!" begin
36+
include("test_vonmises_uniaxial.jl")
37+
end
3338
end
3439
end
3540
end

test/test_show_methods.jl

+20-17
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
@testset "show methods" begin
2-
b = load("test_show_methods/libBehaviour.so","Norton",mbv.Tridimensional)
3-
BehaviourAllocated_out = @capture_out show(b)
4-
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."
5-
@test BehaviourAllocated_out == BehaviourAllocated_expected
1+
using MFrontInterface
2+
using DelimitedFiles
3+
using Suppressor
4+
using Test
65

7-
d = BehaviourData(b)
8-
RealsVectorRef_out = @capture_out show(get_internal_state_variables(get_initial_state(d)))
9-
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"
10-
@test RealsVectorRef_expected == RealsVectorRef_out
6+
b = load("test_show_methods/libBehaviour.so","Norton",mbv.Tridimensional)
7+
BehaviourAllocated_out = @capture_out show(b)
8+
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."
9+
@test BehaviourAllocated_out == BehaviourAllocated_expected
1110

12-
StringsVectorAllocated_out = @capture_out show(get_parameters(b))
13-
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"
14-
@test StringsVectorAllocated_expected == StringsVectorAllocated_out
11+
d = BehaviourData(b)
12+
RealsVectorRef_out = @capture_out show(get_internal_state_variables(get_initial_state(d)))
13+
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"
14+
@test RealsVectorRef_expected == RealsVectorRef_out
1515

16-
set_external_state_variable!(get_final_state(d), "Temperature", 293.15)
17-
VariablesVectorAllocated_out = @capture_out show(get_external_state_variables(b))
18-
VariablesVectorAllocated_expected = "1-element VariablesVector\n Temperature\n"
19-
@test VariablesVectorAllocated_expected == VariablesVectorAllocated_out
20-
end
16+
StringsVectorAllocated_out = @capture_out show(get_parameters(b))
17+
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"
18+
@test StringsVectorAllocated_expected == StringsVectorAllocated_out
19+
20+
set_external_state_variable!(get_final_state(d), "Temperature", 293.15)
21+
VariablesVectorAllocated_out = @capture_out show(get_external_state_variables(b))
22+
VariablesVectorAllocated_expected = "1-element VariablesVector\n Temperature\n"
23+
@test VariablesVectorAllocated_expected == VariablesVectorAllocated_out

test/test_vonmises_uniaxial.jl

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using MFrontInterface
2+
using Materials
3+
using DelimitedFiles
4+
using Suppressor
5+
using Tensors
6+
using Test
7+
8+
dtime = 0.25
9+
mgis_bv = MFrontInterface.behaviour
10+
11+
function MaterialTest()
12+
lib_path = "test_plasticity/libBehaviour.so"
13+
behaviour_name = "IsotropicLinearHardeningPlasticity"
14+
hypothesis = mgis_bv.Tridimensional
15+
16+
behaviour = load(lib_path, behaviour_name, hypothesis)
17+
behaviour_data = BehaviourData(behaviour)
18+
19+
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))]
20+
ext_variable_values = zeros(length(ext_variable_names))
21+
ext_vatiable_state = MFrontExternalVariableState(names=ext_variable_names, values=ext_variable_values)
22+
23+
return MFrontMaterial(behaviour=behaviour, behaviour_data=behaviour_data, external_variables=ext_vatiable_state)
24+
end
25+
26+
mat = MaterialTest()
27+
28+
times = [mat.drivers.time]
29+
stresses = [copy(tovoigt(mat.variables.stress))]
30+
stresses_expected = [[50.0, 0.0, 0.0, 0.0, 0.0, 0.0],
31+
[100.0, 0.0, 0.0, 0.0, 0.0, 0.0],
32+
[150.0, 0.0, 0.0, 0.0, 0.0, 0.0],
33+
[100.0, 0.0, 0.0, 0.0, 0.0, 0.0],
34+
[-100.0, 0.0, 0.0, 0.0, 0.0, 0.0]]
35+
dstrain11 = 1e-9*dtime
36+
strains_expected = [[dstrain11, -0.3*dstrain11, -0.3*dstrain11, 0.0, 0.0, 0.0],
37+
[2*dstrain11, -0.3*dstrain11*2, -0.3*dstrain11*2, 0.0, 0.0, 0.0],
38+
[3*dstrain11, -0.3*dstrain11*2 - 0.3*dstrain11, -0.3*dstrain11*2 - 0.3*dstrain11, 0.0, 0.0, 0.0],
39+
[2*dstrain11, -0.3*dstrain11 - 0.3*dstrain11, -0.3*dstrain11 - 0.3*dstrain11, 0.0, 0.0, 0.0],
40+
[-2*dstrain11, 0.3*dstrain11*2, 0.3*dstrain11*2, 0.0, 0.0, 0.0]]
41+
dtimes = [dtime, dtime, dtime, dtime, 1.0]
42+
dstrains11 = [dstrain11, dstrain11, dstrain11, -dstrain11, -4*dstrain11]
43+
for i in 1:length(dtimes)
44+
dstrain11 = dstrains11[i]
45+
dtime = dtimes[i]
46+
uniaxial_increment!(mat, dstrain11, dtime)
47+
update_material!(mat)
48+
@test isapprox(tovoigt(mat.variables.stress), stresses_expected[i])
49+
#@info(tovoigt(mat.drivers.strain; offdiagscale=2.0), strains_expected[i])
50+
@test isapprox(tovoigt(mat.drivers.strain; offdiagscale=2.0), strains_expected[i])
51+
end

0 commit comments

Comments
 (0)