Skip to content

Commit

Permalink
Fixed temp. dependent damage model #215
Browse files Browse the repository at this point in the history
  • Loading branch information
JTHesse committed Jan 9, 2025
1 parent ac1d260 commit 2d2419b
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 33 deletions.
24 changes: 10 additions & 14 deletions src/Models/Damage/Energy_release.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include("../../Support/Geometry.jl")
include("../../Support/Helpers.jl")
using .Material
using .Geometry
using .Helpers: rotate, fastdot, sub_in_place!, div_in_place!, mul_in_place!
using .Helpers: rotate, fastdot, sub_in_place!, div_in_place!, mul_in_place!, is_dependent
using LinearAlgebra
using StaticArrays
export compute_model
Expand Down Expand Up @@ -79,17 +79,9 @@ function compute_model(
damage_parameter["Critical Value"]
quad_horizons = datamanager.get_field("Quad Horizon")
inverse_nlist = datamanager.get_inverse_nlist()
dependend_value::Bool = false
if haskey(damage_parameter, "Temperature dependend")
if !datamanager.has_key(damage_parameter["Temperature dependend"]["Field key"])
@error "Critical Value key " *
damage_parameter["Temperature dependend"]["Field key"] *
" does not exist for value interpolation in damage model."
return nothing
end
field = datamanager.get_field(damage_parameter["Critical Value"]["Field key"])
dependend_value = true
end

dependend_value, dependent_field =
is_dependent("Critical Value", damage_parameter, datamanager)

# for anisotropic damage models
rotation::Bool = datamanager.get_rotation()
Expand Down Expand Up @@ -126,6 +118,7 @@ function compute_model(
relative_displacement::Vector{Float64} = zeros(Float64, dof)

sub_in_place!(bond_displacements, deformed_bond, undeformed_bond)
warning_flag = true

for iID in nodes
nlist_temp = nlist[iID]
Expand Down Expand Up @@ -163,8 +156,11 @@ function compute_model(
bond_energy = 0.25 * product

if dependend_value
critical_energy =
interpol_data(field[iID], damage_parameter["Temperature dependend"])
critical_energy = interpol_data(
dependent_field[iID],
damage_parameter["Critical Value"]["Data"],
warning_flag,
)
end

@views crit_energy =
Expand Down
12 changes: 10 additions & 2 deletions src/Models/Model_Factory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ function get_block_model_definition(
blocks::Vector{Int64},
prop_keys::Vector{String},
properties,
directory::String = "",
)
# properties function from datamanager

Expand All @@ -364,7 +365,7 @@ function get_block_model_definition(
properties(
block_id,
model,
get_model_parameter(params, model, block[model]),
get_model_parameter(params, model, block[model], directory),
)
end
end
Expand All @@ -389,7 +390,14 @@ function read_properties(params::Dict, datamanager::Module, material_model::Bool
datamanager.init_properties()
blocks = datamanager.get_block_list()
prop_keys = datamanager.init_properties()
get_block_model_definition(params, blocks, prop_keys, datamanager.set_properties)
directory = datamanager.get_directory()
get_block_model_definition(
params,
blocks,
prop_keys,
datamanager.set_properties,
directory,
)
if material_model
dof = datamanager.get_dof()
for block in blocks
Expand Down
26 changes: 21 additions & 5 deletions src/Support/Helpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,18 @@ function find_inverse_bond_id(nlist::Vector{Vector{Int64}})
return inverse_nlist
end

function is_dependent(field_name::String, damage_parameter::Dict, datamanager::Module)
if damage_parameter[field_name] isa Dict
if !datamanager.has_key(damage_parameter[field_name]["Field"] * "NP1")
@error "$(damage_parameter[field_name]["Field"]) does not exist for value interpolation."
return nothing
end
field = datamanager.get_field(damage_parameter[field_name]["Field"], "NP1")
return true, field
end
return false, nothing
end

function interpolation(
x::Union{Vector{Float64},Vector{Int64}},
y::Union{Vector{Float64},Vector{Int64}},
Expand All @@ -461,12 +473,16 @@ end
function interpol_data(
x::Union{Vector{Float64},Vector{Int64},Float64,Int64},
values::Dict{String,Any},
warning_flag::Bool = true,
)
if values["min"] > minimum(x)
@warn "Interpolation value is below interpolation range. Using minimum value of dataset."
end
if values["max"] < maximum(x)
@warn "Interpolation value is above interpolation range. Using maximum value of dataset."
if warning_flag
if values["min"] > minimum(x)
@warn "Interpolation value is below interpolation range. Using minimum value of dataset."
end
if values["max"] < maximum(x)
@warn "Interpolation value is above interpolation range. Using maximum value of dataset."
end
warning_flag = false
end
return evaluate(values["spl"], x)
end
Expand Down
3 changes: 2 additions & 1 deletion src/Support/Parameters/parameter_handling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ global expected_structure = Dict(
Dict{Any,Any}(
"Any" => [
Dict{Any,Any}(
"Critical Value" => [Union{Float64,Int64}, true],
"Critical Value" => [Union{Float64,Int64,String}, true],
"Damage Model" => [String, true],
"Interblock Damage" => [
Dict{Any,Any}(
Expand Down Expand Up @@ -297,6 +297,7 @@ global expected_structure = Dict(
],
"Pre Calculation Global" => [
Dict{Any,Any}(
"Bond Associated Deformation Gradient" => [Bool, false],
"Bond Associated Correspondence" => [Bool, false],
"Deformation Gradient" => [Bool, false],
"Deformed Bond Geometry" => [Bool, false],
Expand Down
18 changes: 14 additions & 4 deletions src/Support/Parameters/parameter_handling_models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ else
println("Parameter not found.")
end
"""
function get_model_parameter(params::Dict, model::String, id::String)
function get_model_parameter(
params::Dict,
model::String,
id::String,
directory::String = "",
)
if !haskey(params["Models"], model * "s")
@error model *
" is defined in blocks, but no " *
Expand All @@ -64,8 +69,12 @@ function get_model_parameter(params::Dict, model::String, id::String)
if haskey(params["Models"][model*"s"], id)
file_keys = find_data_files(params["Models"][model*"s"][id])
for file_key in file_keys
data = csv_reader_temporary(params["Models"][model*"s"][id][file_key])
params["Models"][model*"s"][id][file_key] =
data, header = csv_reader_temporary(
joinpath(directory, params["Models"][model*"s"][id][file_key]),
)
params["Models"][model*"s"][id][file_key] = Dict()
params["Models"][model*"s"][id][file_key]["Field"] = header[1]
params["Models"][model*"s"][id][file_key]["Data"] =
interpolation(data[!, 1], data[!, 2])
end
return params["Models"][model*"s"][id]
Expand All @@ -89,7 +98,8 @@ function csv_reader_temporary(filename::String)
header = header,
skipto = header_line + 1,
comment = "#",
)
),
header
end


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ PeriLab:
BC_3:
Variable: "Temperature"
Node Set: "Node Set 3"
Value: "0"
Value: 250000.0 * t
Type: Dirichlet
Compute Class Parameters:
External_Forces:
Expand Down Expand Up @@ -93,14 +93,13 @@ PeriLab:
Number of Neighbors: true
External_Forces: True
External_Displacements: True
Strain: True
Temperature: True
Models:
Damage Models:
Damage:
Damage Model: Critical Energy
Critical Value: 0.0035714285714285716
#Temperature dependend: "crictical_energy_temperature_depended.txt"
Critical Value: crictical_energy_temperature_depended.txt #0.0035714285714285716
# Temperature dependend: "crictical_energy_temperature_depended.txt"
Thermal Models:
Temp:
Thermal Model: "Thermal Flow"
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Christian Willberg <[email protected]>, Jan-Timo Hesse <[email protected]>

SPDX-License-Identifier: BSD-3-Clause
1 change: 1 addition & 0 deletions test/fullscale_tests/test_DCB/test_DCB.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ cd("fullscale_tests/" * folder_name) do
run_perilab("DCBmodel_correspondence", 1, true, folder_name)
# run_perilab("DCBmodel_UMAT", 1, true, folder_name)
run_perilab("DCBmodel_PD_solid", 1, true, folder_name)
run_perilab("DCBmodel_PD_solid_temp_depended", 1, true, folder_name)
#TODO: Fix DCBmodel_correspondence_bond_associated, number of neighbors seems to be wrong
# run_perilab("DCBmodel_correspondence_bond_associated", 1, true, folder_name)

Expand Down
7 changes: 4 additions & 3 deletions test/unit_tests/Support/Parameters/ut_parameter_handling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -846,10 +846,11 @@ end
@test testData["Material Model"]["sa"] == [3.2, 2, 3]
@test testData["Material Model"]["d"] == "true"
test_dict = testData["Material Model"]["test_file_B"]
@test test_dict["max"] == 0.5
@test test_dict["min"] == -2.5
@test test_dict["Field"] == "Temperature"
@test test_dict["Data"]["max"] == 0.5
@test test_dict["Data"]["min"] == -2.5

@test typeof(test_dict["spl"]) == Dierckx.Spline1D
@test typeof(test_dict["Data"]["spl"]) == Dierckx.Spline1D
testData["Damage Model"] =
PeriLab.Solver_control.Parameter_Handling.get_model_parameter(
params,
Expand Down

0 comments on commit 2d2419b

Please sign in to comment.