Differentation of a material
MaterialModelsBase.MaterialDerivatives — Type
MaterialDerivatives(m::AbstractMaterial)A struct that saves all derivative information using a Matrix{T} for each derivative, where T=get_vector_eltype(m). The dimensions are obtained from get_num_tensorcomponents, get_num_statevars, and get_vector_length. m must support tovector and fromvector, while the output of initial_material_state must support tovector, and in addition the element type of tovector(initial_material_state(m)) must respect the element type in tovector(m) for any m.
The values should be updated in differentiate_material! by direct access of the fields, where σ is the stress, ϵ the strain, s and ⁿs are the current and old state variables, and p the material parameter vector.
dσdϵdσdpdsdϵdsdp
MaterialModelsBase.StressStateDerivatives — Type
StressStateDerivatives(stress_state::AbstractStressState, m::AbstractMaterial)Create ssd::StressStateDerivatives object that allows differentiating the material response wrt material parameters through the differentiate_material!(ssd, args...) function. For standard 3d implementations of m, defining material_response(m) and differentiate_material!(::MaterialDerivatives, m, args...), differentiate_material!(ssd, args...) is defined already.
MaterialModelsBase.allocate_differentiation_output — Function
allocate_differentiation_output(::AbstractMaterial)When calculating the derivatives of a material, it can often be advantageous to have additional information from the solution procedure inside material_response. This can be obtained via an AbstractExtraOutput, and allocate_differentiation_output provides a standard function name for what extra_output::AbstractExtraOutput that should be allocated in such cases.
Defaults to an NoExtraOutput if not overloaded.
MaterialModelsBase.differentiate_material! — Function
differentiate_material!(
diff::MaterialDerivatives,
m::AbstractMaterial,
ϵ::Union{SecondOrderTensor, Vec},
old::AbstractMaterialState,
Δt,
cache::AbstractMaterialCache
extra::AbstractExtraOutput
dσdϵ::AbstractTensor,
)Calculate the derivatives and save them in diff, see MaterialDerivatives for a description of the fields in diff.
differentiate_material!(ssd::StressStateDerivatives, stress_state, m, args...)For material models implementing material_response(m, args...) and differentiate_material!(::MaterialDerivatives, m, args...), this method will work automatically by
- Calling
σ, dσdϵ, state = material_response(stress_state, m, args...)(except thatdσdϵ::FourthOrderTensor{dim = 3}is extracted) - Calling
differentiate_material!(ssd.mderiv::MaterialDerivatives, m, args..., dσdϵ::FourthOrderTensor{3}) - Updating
ssdaccording to the constraints imposed by thestress_state.
For material models that directly implement material_response(stress_state, m, args...), this function should be overloaded directly to calculate the derivatives in ssd. Here the user has full control and no modifications occur automatically, however, typically the (total) derivatives ssd.dσdp, ssd.dϵdp, and ssd.mderiv.dsdp should be updated. The exact interface of the StressStateDerivatives datastructure is still not fixed, and may change in the future.
MaterialModelsBase.reset_derivatives! — Function
reset_derivatives!(d::Union{MaterialDerivatives, StressStateDerivatives}, m::AbstractMaterial)Reset the derivatives to match the initial derivatives after construction of d with the material m.
reset_derivatives!(d::MaterialDerivatives, dprev::MaterialDerivatives)
reset_derivatives!(d::StressStateDerivatives, dprev::StressStateDerivatives)Reset the MaterialDerivatives to match the continuation from a previous set of derivatives. I.e. setting the values equal to the previous derivatives.
The StressStateDerivatives fields dϵdp and dσdp are not updated (these could be different due to different stress states in the different steps), and are set to NaNs. This means that implementations of differentiate_material!(ssd::StressStateDerivatives, args...) should not depend on the values stored in these field (i.e. write-only). The default implementation that should be used in most cases fulfills this.