-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from JuliaFEM/uniaxial
Adding uniaxial_increment! testing to ensure Materials.jl compatibility.
- Loading branch information
Showing
3 changed files
with
77 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |