Add PYEXT: constitutive laws written in Python, driven by the C++ solver - #106
Open
chemiskyy wants to merge 2 commits into
Open
Add PYEXT: constitutive laws written in Python, driven by the C++ solver#106chemiskyy wants to merge 2 commits into
chemiskyy wants to merge 2 commits into
Conversation
A law implementing simcoon.PythonUMAT is registered under the name PYEXT for the
duration of a call and integrated by the C++ material-point solver exactly like a
built-in kernel: same 24-argument convention, same start-of-increment rollback (so
all history must live in statev), same step-cut protocol (raise StepCut).
Core, free of Python: umat_callback.{hpp,cpp} holds the callback slot and the free
function umat_callback_M, dispatched from select_umat_M and select_umat_M_finite
under id 300. PYEXT joins kirchhoff_box, so the finite-strain dispatcher does not
apply a second J factor to a small-strain box.
Bindings: pyumat.{hpp,cpp} bridges numpy and armadillo, re-acquires the GIL that
solver_run releases, validates shapes and finiteness before committing anything to
the caller's buffers, and maps StepCut onto tnew_dt. launch_umat serves PYEXT
through a serial loop, the parallel helper forbidding Python in its region.
Solver: step::compute_inc now returns a status instead of calling exit(0), which
killed the interpreter; its callers propagate it through the existing abort path.
Also in this layer: python -m simcoon.doctor reports the OpenMP runtimes actually
loaded in the process, and simcoon.identify gains the mape and wmape metrics.
Claude-Session: https://claude.ai/code/session_01Ni71E8DCPGa3NpbLZ3YboR
test_linear_elastic_matches_eliso[uniaxial] failed on ubuntu-latest: six of a hundred and fifty stress entries differed by about 1e-9 while the field itself reaches 1e7. Those are the transverse components that mixed control drives to zero; they sit in the same array as values sixteen orders of magnitude larger, and the Python law and ELISO reach them through a different order of floating-point operations — a difference the platform's BLAS changes. A fixed atol of 1e-9 is therefore below the resolution of the array it is applied to. The absolute tolerance now follows the field, atol + rtol * max|reference|, which is 1e-3 on a 1e7 stress field and unchanged on a strain field of order 1e-2. The comparison stays at 1e-10 of the field, so it still catches any real discrepancy in the bridge. Claude-Session: https://claude.ai/code/session_01Ni71E8DCPGa3NpbLZ3YboR
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.
A law implementing simcoon.PythonUMAT is registered under the name PYEXT for the duration of a call and integrated by the C++ material-point solver exactly like a built-in kernel: same 24-argument convention, same start-of-increment rollback (so all history must live in statev), same step-cut protocol (raise StepCut).
Core, free of Python: umat_callback.{hpp,cpp} holds the callback slot and the free function umat_callback_M, dispatched from select_umat_M and select_umat_M_finite under id 300. PYEXT joins kirchhoff_box, so the finite-strain dispatcher does not apply a second J factor to a small-strain box.
Bindings: pyumat.{hpp,cpp} bridges numpy and armadillo, re-acquires the GIL that solver_run releases, validates shapes and finiteness before committing anything to the caller's buffers, and maps StepCut onto tnew_dt. launch_umat serves PYEXT through a serial loop, the parallel helper forbidding Python in its region.
Solver: step::compute_inc now returns a status instead of calling exit(0), which killed the interpreter; its callers propagate it through the existing abort path.
Also in this layer: python -m simcoon.doctor reports the OpenMP runtimes actually loaded in the process, and simcoon.identify gains the mape and wmape metrics.