Repository navigation
Conversation
…on (#217) Callbacks declare partials() / independent_of() next to reads(); the engine plans a requested derivative over the target's upstream and accumulates the Mandel-packed partials. Hosts request derivatives via material_context and material_point. check_partials() verifies declared partials by central differences. thermal_eigenstrain and linear_elasticity declare their partials, giving the first DDSDDT.
linear_stress, isotropic_tangent, isotropic_moduli, incremental_linear_elasticity, the state functions, strain_threshold_yield, the scalar damage laws and isotropic_damage declare their partials; isotropic_damage splits the damaged stress from the damaged tangent so the stress carries a derivative. The accumulated derivative equals the hand-written tangents to 1e-12 along the report load paths and the existing test models, loading and unloading. All existing tangent outputs stay.
With the partials requested, a rerun at a perturbed read refilled the blocks, so a later partial of the same callback was compared at the perturbed state. Found while building #218.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #219 (epic #221): the checklist items Elasticity and stress producers and Damage. Stacked on #227 (partials API, #217), which sits on #223. Merge after #223 and #227.
What / why
The elastic producers and the damage chain declare their partials, so
material_point::derivative("…::stress" / "…::damaged_stress", "strain")accumulates the tangent from the graph instead of the hand-written chain rule inisotropic_damage.linear_stressisotropic_tangentisotropic_moduliincremental_linear_elasticityvon_mises_state_function,vector_strain_state_functiond_equivalent_strain)strain_energy_state_functionstrain_threshold_yielddetail/scalar_damage_law.h)isotropic_damagelinear_elasticityandthermal_eigenstrain(also the curing shrinkage) already declare theirs in #227.All existing outputs stay:
tangent,damaged_tangent,d_damage,d_equivalent_strain, and theis_yieldingread. Removing them is a follow-up once the hosts read derivatives.Decisions
isotropic_damagenow has two callbacks. One computesdamaged_stressfrom (σ, D) and declares its partials. The other computesdamaged_tangentfrom the old reads. Partials are declared per callback. With a single callback, a derivative ofdamaged_stresswould have to pass throughd_equivalent_strain,d_damageand the tangent. Those reads would then need Hessians, or anindependent_of()that would be false fordamaged_tangent.neo_hookeandhencky_elasticityare not migrated. Partial derivatives: per-callback declarations and forward accumulation (#217) #227 packs only symmetric tensors: tensor2 is a 6-component Mandel block, and packing projects onto the symmetric part. P and F are not symmetric, so declaring dP/dF would silently give the symmetrised derivative. Also,external_deformation_gradient_sourcesetsinverseanddeterminantinbind(), without a callback, so they carry no derivative from F. This needs the 9-component layout from the Property engine: partial derivatives per callback, chain rule by forward accumulation #217 table in the engine, which is a follow-up to Property engine: partial derivatives per callback, chain rule by forward accumulation #217.incremental_linear_elasticity::copy_tangentdeclares nothing, because it would need a rank-8 identity. A derivative through a strain-dependent tangent throws and names that path.isotropic_moduliusesreads(m_C)instead ofreads_all_inputs(). C is its only input; the change lets the callback declare partials.test_material_conformance: the finite-difference model now covers every new material. Its state is scaled to strains of about 0.1, so central differences of the nonlinear state functions stay within 1e-6. The header scan also counts materials that include adetail/base that declares partials (the damage laws).Tests
Gate from the issue: the accumulated derivative equals the hand-written tangent to 1e-12 (relative) at every step, for loading, unloading and reloading.
test_accumulated_tangents: runs the load cases of the report deckslinear_elasticity,incremental_linear_elasticity,isotropic_damage,mean_field_damage(phases at their local strains),short_fibre_damage(all 50 fibre chains, linear and nonlinear localisation),mean_field_composite_global,…_rule_of_mixtureandshort_fibre_composite. The cases go through zero to compression and back, under strain and stress control, with fewer steps than the reports.short_fibre_damageruns only its uniaxial-strain case: its nonlinear localisation needs small steps.test_damage(the stepper model, and the chain over all three state functions),test_damage_laws(each law againstis_yielding · d_damage · d_equivalent_strain, up to the cap),test_mean_field_damage,test_orientation_phases(damaging fibres, both localisations),test_curing_eigenstrain(∂σ/∂ε and ∂σ/∂ξ = −C:βI),test_uncovered_materials(state functions) andtest_incremental_elasticity.stepper::strain -> state_func::equivalent_strain -> state_func::d_equivalent_strain -> damaged::damaged_stress.No accumulated tangent differed from the hand-written one.
Gate
GCC 14 (
-DNUMSIM_PREFER_SIBLINGS=OFF, reports on): BUILD=0, 1540/1540 ctest tests passed (incl. ASan variants and report decks), 0 warnings.