Skip to content

Li/differentiable plastic system - #1631

Open
lihanyu97 wants to merge 28 commits into
developfrom
li/differentiable_plastic_system
Open

lihanyu97 wants to merge 28 commits into
developfrom
li/differentiable_plastic_system

Conversation

@lihanyu97

Copy link
Copy Markdown
Contributor

Introduce differentiable plasticity solver using staggered solver that updates displacement and internal variables (plastic strain and deformation gradient) seqentially, which mimics the classic plastic return map. The internal variables are represented by DG nodal fields which makes then differentiable through functional. The internal variables are computed via the return map with the latest estimate of displacement. The updated internal variables then feed back to produce the next estimate of the displacement. Convergence is achieved when all residuals evaluated with updated variables are below tolerance.

@white238
white238 requested a lite review from Copilot September 9, 2026 17:15
Comment thread .github/workflows/ci-tests.yml Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

There are several concrete fixups needed (notably release-notes update plus correctness/maintainability cleanups in the newly added plastic mechanics system and plasticity tests) before this can be safely approved.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adds a differentiable plasticity capability to Smith’s differentiable-numerics stack and refactors the block-coupling infrastructure so weak forms can depend on the same solved field in multiple argument slots (while keeping history inputs distinct). It also tightens Jacobian API validation and expands test coverage for the new coupling/indexing semantics.

Changes:

  • Introduces a new PlasticMechanicsSystem and a differentiable plasticity regression test exercising staggered displacement/internal-variable solves and gradient checks.
  • Reworks block indexing from “single slot per (row,col)” to “slot list per (row,col)”, updating FieldStore, SystemSolver, and block_solve accordingly (plus new tests for repeated dependencies and explicit unknown-vs-test fields).
  • Adds Jacobian weight-size validation and tests that cover multi-weight Jacobian assembly.
File summaries
File Description
src/smith/physics/tests/test_functional_weak_form.cpp Adds a body source and a new test to verify Jacobian-weight linearity across multiple arguments.
src/smith/physics/functional_weak_form.hpp Adds runtime validation that jacobian_weights.size() matches fields.size().
src/smith/differentiable_numerics/thermal_system.hpp Updates FieldType construction to match the new FieldType interface (no is_unknown flag).
src/smith/differentiable_numerics/tests/test_porous_heat_sink.cpp Updates block_solve callsites to the new BlockArgumentMap slot-list format.
src/smith/differentiable_numerics/tests/test_multiphysics_time_integrator.cpp Adds solver/test utilities and expands tests for repeated dependencies and explicit unknown/test separation; updates naming and assumptions after field-name refactor.
src/smith/differentiable_numerics/tests/test_mixed_poisson.cpp Updates block_solve callsites to the new BlockArgumentMap slot-list format.
src/smith/differentiable_numerics/tests/test_differentiable_plasticity.cpp New differentiable plasticity regression tests (primal + internal variables, plus finite-difference gradient checks).
src/smith/differentiable_numerics/tests/CMakeLists.txt Registers the new differentiable plasticity test in the test build.
src/smith/differentiable_numerics/system_solver.hpp Updates SystemSolver::solve signature to accept BlockArgumentMap and clarifies docstring meaning.
src/smith/differentiable_numerics/system_solver.cpp Implements validation and propagation logic using slot lists rather than name-based routing; adds optional staggered-progress logging.
src/smith/differentiable_numerics/system_base.hpp Clarifies semantics of solve_result_field_names.
src/smith/differentiable_numerics/system_base.cpp Updates solve/index-map construction and reaction evaluation to use explicit unknown/test field names and slot lists.
src/smith/differentiable_numerics/state_variable_system.hpp Updates FieldType construction to match the new FieldType interface.
src/smith/differentiable_numerics/solid_mechanics_system.hpp Updates FieldType construction to match the new FieldType interface.
src/smith/differentiable_numerics/plastic_mechanics_system.hpp New plastic mechanics system definition and factory, wired for staggered solve of displacement + internal variables.
src/smith/differentiable_numerics/nonlinear_solve.hpp Introduces BlockArgumentIndices/BlockArgumentMap and updates block_solve signatures/docs.
src/smith/differentiable_numerics/nonlinear_solve.cpp Implements slot-list driven assembly (inputs, Jacobians, sensitivities) with additional index validation.
src/smith/differentiable_numerics/nonlinear_block_solver.hpp Adds printLevel() API to support optional staggered-progress logging.
src/smith/differentiable_numerics/multiphysics_time_integrator.cpp Switches unknown tracking from reaction/test field to explicit solver-owned unknown field name.
src/smith/differentiable_numerics/field_store.hpp Removes per-FieldType is_unknown flag; introduces explicit {unknown,test} naming, new indexMap() return type, and updated weak-form registration helpers.
src/smith/differentiable_numerics/field_store.cpp Implements explicit unknown/test name registration and slot-list indexMap() generation with ownership checks.
src/smith/differentiable_numerics/differentiable_test_utils.hpp Adds optional gradient printout for debugging finite-difference checks.
src/smith/differentiable_numerics/CMakeLists.txt Installs the new plastic_mechanics_system.hpp header.
.github/workflows/ci-tests.yml Increases CI build/test job timeout.
Review details
  • Files reviewed: 24/24 changed files
  • Comments generated: 8
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/smith/differentiable_numerics/plastic_mechanics_system.hpp
Comment thread src/smith/differentiable_numerics/plastic_mechanics_system.hpp
Comment on lines +170 to +171
auto [epsilon_current, epsilon_dot] = captured_strain_rule->interpolate(t_info, epsilon_p, epsilon_p_old);
auto dt = t_info.dt();
Comment on lines +286 to +305
state_nonlin_opts.print_level = 0;
primal_nonlin_opts.print_level = 0;

int serial_refinement = 0;
int parallel_refinement = 0;

static constexpr int dim = 3;
static constexpr int order = 1;

axom::sidre::DataStore datastore;
StateManager::initialize(datastore, "plasticity_small_strain");

std::string filename = SMITH_REPO_DIR "/data/meshes/beam-hex.mesh";
const std::string meshtag = "mesh";
auto mesh = std::make_shared<Mesh>(buildMeshFromFile(filename), meshtag, serial_refinement, parallel_refinement);

auto staggered_coupled_solver = std::make_shared<SystemSolver>(100);
auto primal_block_solver = buildNonlinearBlockSolver(primal_nonlin_opts, primal_lin_opts, *mesh);
auto strain_block_solver = buildNonlinearBlockSolver(state_nonlin_opts, state_lin_opts, *mesh);
auto defgrad_block_solver = buildNonlinearBlockSolver(state_nonlin_opts, state_lin_opts, *mesh);
combined_system.hpp
system_base.hpp
differentiable_test_utils.hpp
plastic_mechanics_system.hpp

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so close to what i wanted.. but it does mark it as user facing and you need to do a release notes. I was hoping it would suggest the change to the release notes file. I'll see if i can tweak it .

Comment thread src/smith/differentiable_numerics/plastic_mechanics_system.hpp
Comment thread src/smith/differentiable_numerics/plastic_mechanics_system.hpp Outdated
Comment thread src/smith/differentiable_numerics/plastic_mechanics_system.hpp
lihanyu97 and others added 3 commits September 9, 2026 13:19
Co-authored-by: Chris White <white238@llnl.gov>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
lihanyu97 and others added 3 commits September 10, 2026 11:53
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants