Conversation
…-stress postprocessing BUG-004: `fext` was allocated once outside the time loop and never cleared, so `apply!(fext, lh, t)` added each step's load onto the running total instead of replacing it, ending with 10x the intended final load after the 20-step history. Fixed by `fill!(fext, 0)` before each `apply!` call. BUG-005: `calculate_stress` computed plane-stress output by zero-padding the in-plane strain's out-of-plane components and applying the full 3d elastic stiffness tensor directly, which is only correct for plane strain, not plane stress (whose eliminated out-of-plane strain must satisfy sigma_33 = 0). Fixed by delegating to `MaterialModelsBase.material_response` on the actual stress state + material pair for the elastic case (which performs the same plane-stress-consistent solve used during assembly), and, for the plastic case, using the already-converged 3d plastic strain (reduced to in-plane components) to form the elastic strain directly rather than re-invoking `Plastic`'s own `material_response` a second time (which would otherwise double-advance the already-converged state during postprocessing). Added hidden (`#src`) regression checks: per-timestep verification that `fext` matches a freshly evaluated load vector, an elastic plane-stress analytical reference check (matches E/(1-nu^2) form) including an out-of-plane stress check, and a pinned end-to-end regression value for the full solve's postprocessed stresses. Verified numerically against MaterialModelsBase.material_response directly: for E=210e3, nu=0.3, eps11=0.01, the corrected formula gives (sigma11, sigma22) = (2307.69, 692.31), matching the documented correct reference (vs. the buggy (2826.92, 1211.54)). Test results: full Pkg.test() suite passes (3236 assertions across all testsets). All 5 unaffected tutorials, all 6 how-tos, and the fixed mixed_materials tutorial (with its new #src regression tests) run successfully. Full docs build succeeds with only the pre-existing benign viscoelasticity image-size-threshold warning. Independent Codex review (plan + final diff, same thread) raised one remaining medium finding both times: mixed_materials.png is a downloaded external asset (via FerriteAssembly.asset_url) rather than a file generated by the docs build, so this PR's fix does not regenerate the published tutorial image, which will keep showing results from the old, incorrect loading/postprocessing until that asset is separately replaced upstream. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KySgpVgJ5fWR9AvPK1JQoU
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #94 +/- ##
=======================================
Coverage 97.17% 97.17%
=======================================
Files 32 32
Lines 1347 1347
=======================================
Hits 1309 1309
Misses 38 38 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
3 tasks
This branch has not been deployed
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.
Summary
fextaccumulated across time steps in the mixed-materials tutorial (never cleared beforeapply!(fext, lh, t)), so the solver applied the sum of all previous loads instead of the current one. Fixed withfill!(fext, 0)before each step'sapply!.calculate_stresspostprocessing zero-padded the out-of-plane strain and applied the full 3d elastic stiffness directly, which is only valid for plane strain, not plane stress (whose eliminated out-of-plane strain must satisfy σ33 = 0). Fixed by delegating toMaterialModelsBase.material_responseon the actual(stress_state, material)pair for the elastic response, and by using the already-converged 3d plastic strain (reduced to in-plane) to form the elastic strain for the plastic branch — without re-invokingPlastic's ownmaterial_responsea second time, which would otherwise double-advance the already-converged state during postprocessing.#src) regression checks: per-timestepfextreconstruction check, an elastic plane-stress analytical reference (E/(1-ν²) form) plus an out-of-plane-stress check, and a pinned end-to-end regression value for the full solve's postprocessed stresses.Verified the corrected formula numerically against
MaterialModelsBase.material_responsedirectly: forE=210e3, ν=0.3, ϵ11=0.01, it gives(σ11, σ22) = (2307.69, 692.31), matching the documented correct reference (vs. the buggy(2826.92, 1211.54)).Test plan
Pkg.test()— full suite passes (3236 assertions, no failures)heat_equation,iga,incompressible_elasticity,mixed_materials,viscoelasticity) run successfully, each in an isolated moduleautomatic_differentiation,local_constraints,robin_bc,surface_integral,threaded_assembly,volume_integral) run successfullydocs/make.jlbuild succeeds (only the pre-existing benign viscoelasticity image-size-threshold warning)Remaining risk
Codex's review flagged (medium, both passes) that
docs/src/literate_tutorials/mixed_materials.pngis a downloaded external asset (viaFerriteAssembly.asset_url, not tracked in this repo / not regenerated by the docs build), so this PR does not update the published tutorial image — it will keep showing results from the old, incorrect loading/postprocessing until that asset is separately regenerated and republished upstream.🤖 Generated with Claude Code
https://claude.ai/code/session_01KySgpVgJ5fWR9AvPK1JQoU