Skip to content

Elastic-constant and rotation helpers - #127

Merged
petlenz merged 20 commits into
mainfrom
feature/elliptic-integrals-and-constants
Oct 27, 2026
Merged

petlenz merged 20 commits into
mainfrom
feature/elliptic-integrals-and-constants

Conversation

@petlenz

@petlenz petlenz commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Closes #95, closes #103. First PR of the uvwmaterial port (#94); stacked on #93 because it uses core/tensor_identities.h from there and the composites that follow ship reports.

core/elastic_constants.h: bulk_modulus(E, nu), shear_modulus, youngs_modulus(K, G), poisson_ratio, lame_lambda, isotropic_stiffness<T, Dim>(K, G) (the K I⊗I form of plasticity_utils), rotate for rank 2 (R A Rᵀ) and rank 4 (one tmech expression through otimesu(R, R)), rotation(axis, angle) (Rodrigues, with [axis]ₓ = −(ε · axis) from tmech's permutation tensor) and rotation_to(direction) (e₁ onto a direction; the parallel and antiparallel branches are taken at 8 ε of the scalar type). All pure helpers are [[nodiscard]].

Elliptic integrals: the Carlson port of the first version is gone; the Eshelby tensors (#128) and the orientation average (#132) call Boost.Math's ellint_rd directly, and #128 adds that dependency where it is first used.

Tests (test_elastic_constants, 7): round trips, invariance of an isotropic tensor, a fibre tensor moving from e₁ to e₂, axis–angle against the explicit z rotation, orthogonality and rotation_to typed over float and double for the parallel, antiparallel and generic directions.

736/736 tests pass (GCC 14, reports on).

@petlenz

petlenz commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Rebased: the first commit had dropped the five test targets of the base branch (drivers, report, core utilities) from tests/CMakeLists.txt while resolving a conflict; they are restored in a second commit, and every PR of the stack is rebased on it. Test counts in the PR texts below #138 are from before the restore; the top of the stack runs 885 tests.

@petlenz

petlenz commented Oct 17, 2026

Copy link
Copy Markdown
Member Author

Review findings (design, tmech expressions instead of component loops, modern C++, comments, tests, correctness). Severity: must = wrong result, hang, build break or unreachable feature; should = design, duplication, accuracy; nit = style.

elliptic integrals + elastic constants — needs changes

  • [must] core/elliptic_integrals.h:106 T{0.75} * c1 * ed → T{0.75} * c3 * ed (Carlson/NR3 C5 = 0.75·C3 = 9/88). Effect: 4th- instead of 6th-order truncation, ≈4e-12 worst case; tests pass because Carlson's table points exit early.
  • [must] rf/rc/rd/rj hang on inf or near-overflow input (rf(inf,1,1), rf(1e308,1e308,1) verified); orientation.h feeds exp() into rd. Add isfinite + sum bound to require.
  • [must] core/elastic_constants.h:66,69 c > 1 - T{1e-14} is c > 1 for float → rotation_to<float>(±e1) all-NaN. Use 8·eps<T>; std::numbers::pi_v<T>.
  • [should] rotation matrix built component-wise → cos·I − sin·(levi_civita<T,3>() * axis) + (1−cos)·otimes(axis,axis) (verified to 0.0).
  • [should] DRY: umat::rotate (8-deep loop, comment claims no single-call spelling) duplicates the new one-liner; plasticity_utils.h:38 builds isotropic stiffness by hand.
  • [should] rotate/rotation/rotation_to belong in core/rotation.h, not elastic_constants.h; template <typename T> void require with unused T → inline; [[nodiscard]] missing; two Dim=2 isotropic-stiffness conventions (K I⊗I vs 3K Pvol) coexist.
  • [nit] NR3 double tolerances for all T; magic 166666.67 in tests; no float instantiation, no rotation_to(−e1), no complete_k(1).

@petlenz petlenz changed the title Carlson elliptic integrals and elastic-constant helpers Elastic-constant and rotation helpers Oct 17, 2026
@petlenz

petlenz commented Oct 17, 2026

Copy link
Copy Markdown
Member Author

Review findings addressed in 17946ba:

Left for a follow-up: umat::rotate and plasticity_utils reusing these helpers (files of the base branch), and a separate core/rotation.h.

@petlenz
petlenz force-pushed the feature/elliptic-integrals-and-constants branch 2 times, most recently from 4313828 to bb455b7 Compare October 18, 2026 13:41
@petlenz
petlenz force-pushed the feature/material-reports branch from f3ce58b to 11e21ff Compare October 18, 2026 20:03
@petlenz
petlenz force-pushed the feature/elliptic-integrals-and-constants branch from bb455b7 to 56e0364 Compare October 18, 2026 20:03
@petlenz
petlenz force-pushed the feature/material-reports branch from 11e21ff to 707809a Compare October 18, 2026 20:22
@petlenz
petlenz force-pushed the feature/elliptic-integrals-and-constants branch from 56e0364 to 25c92c6 Compare October 18, 2026 20:22
load_driver runs one material point under mixed strain/stress control
(uniaxial stress solves the five lateral strains with the material tangent)
and records the Newton residuals; material_report runs the load cases of a
case.json and writes CSV; reports/make_report.py turns them into figures and
the results section of docs/materials/<material>/README.md.
The correction solves (P:C:P + Isym - P + Iskw) : d_eps = -P:(sigma - sigma*)
with tmech::invf instead of a hand-written 6x6 elimination; Iskw makes the
operator regular on the full 9x9 space. Strain, stress and tangent are
tensors, converted to and from the evaluator buffers with tensor_conversion.
A report document holds the model graph, the material point, recorded
columns wired to any graph property ("material::property[i,j]"), the load
cases, the figures and the checks. Includes merge shared cases and figures;
"$name" strings take parameters. material_report writes resolved.json,
graph.json (materials, parameters, produced and consumed properties) and
CSV per case; make_report.py evaluates the checks against closed forms,
draws the figures and writes the results with the wiring diagram. Every
report is a ctest (checks only).
C++: load_control (stress/strain projectors), load_path (steps as a view),
report_json (parsing into value types), case_runner (material_point and
run_case over a step_sink concept), csv_sink, graph_description; the tool
is now an entry point. load_driver keeps no per-step state: a step_result
carries its start state, so tangent_error works for any earlier step.
Produced properties are listed by name (the registry orders by address).

Python: dataclasses for runs, cases and check results; expressions, checks,
panel renderers (registry by kind) and Markdown sections as separate
functions; unit tests in reports/test_make_report.py (ctest report_script).
The Markdown pages and committed figures are removed. make_report.py
--out <dir> writes <material>.html with embedded figures and an index;
nothing generated is committed. Each report starts with the parameters of
report.json, where each one is used (material, case or check), the derived
values and the material parameters as resolved. resolve_report records
the substitutions in "parameter_usage".
- core/tensor_identities.h: sym/skew identities, volumetric and deviatoric
  projectors, the symmetric 3D basis in Abaqus order; used by
  linear_elasticity, saint_venant_kirchhoff and plasticity_utils
  (make_IIdev / cached_IIdev now delegate; make_isotropic_tangent keeps
  its K I(x)I form).
- core/property_value.h: value of a plain or history property; used by
  material_point_evaluator::resolve_property and the report columns.
- core/graph_description.h: materials with produced (history flag, sorted)
  and consumed properties; the report adds types and parameters.
- umat/load_control.h and umat/material_point_driver.h (was
  report/load_driver.h): mixed strain/stress control of a material point.
make_report.py is the entry point of reports/numsim_report. Expressions
own the document; Raw marks unescaped cells; ReportSummary replaces the
index tuples; axis labels show tensor components as symbols. Tests per
module in reports/tests (ctest report_script discovers them).
parse_point and parse_columns live in report_json.h; step_record and the
step_sink concept in step_record.h, so csv_sink no longer includes the
model builder. load_path::at checks its range, include nesting is capped
at 16 levels, and the finite-difference step of tangent_error is a driver
option (fd_step).
A plain output "iterations", so reports can record the return-map
convergence of the material next to the driver's own Newton.
A check with "plot" draws value and expected per case next to its error
against the tolerance (relative for relative checks); the separate
closed-form figures are gone. Cases take tangent_every (default 1, 0 =
never); the standard cases check every fifth step. The J2 reports record
solver::iterations and show the return map next to the driver's Newton.
…n_property)

Every small-strain consumer took the strain from the fixed property "strain"
of its source. The composites that follow produce one strain per phase
("strain_matrix", "strain_<phase>"), and the phase materials have to read
those. strain_property (default "strain") names the property next to the
existing strain_source / strain_producer_name, the same way tangent_property
and nu_property do; nothing changes for existing documents.

linear_elasticity, linear_stress, j2_plasticity, drucker_prager_plasticity and
the three state functions; tests wire a material to another's stress under
the new name and check the default and a missing property.
"studies" rerun a case with several step counts; the error of a final
quantity against the finest run is fitted with a power of the step size,
and errors below ten times the driver tolerance count as exact. Cases take
"points" (strain states in order) for non-proportional paths; the load
step carries its segment and fraction. The J2 reports show the radial
return exact on a proportional path and first order on tension followed
by shear.
core/elliptic_integrals.h: R_F, R_C, R_D, R_J by Carlson's duplication
algorithm and the complete integrals K, E, so the Eshelby tensors of
ellipsoids and the orientation averaging need no Boost.
core/elastic_constants.h: K, G, E, nu, lambda conversions, the isotropic
stiffness, rotation of rank-2 and rank-4 tensors, rotations from axis and
angle and onto a direction.
umat/deformation_gradient_driver.h drives a material point by F under
mixed F / P control, Newton on the full nine components with dP/dF;
deformation_control names them (21, 31, 32 included). A report whose point
has a deformation_gradient_source records F and P with nine components,
the Cauchy stress as stress_11..23 and J; tensors in cases may have nine
components. Reports for neo_hooke and saint_venant_kirchhoff with exact
checks (S = F^-1 P under uniaxial stress, simple shear, volumetric).
…ses, projectors of the controls, load path accessors
…n tensor, float-safe rotation_to

The elliptic integrals come from Boost.Math where they are first used (the
Eshelby tensors). rotation() builds [axis]_x as -(epsilon . axis); rotation_to()
uses 8 eps of the scalar type instead of 1e-14, which did not compile for float
and would have been c > 1 there. [[nodiscard]] on the pure helpers.
@petlenz
petlenz force-pushed the feature/material-reports branch from 707809a to 4549791 Compare October 19, 2026 04:06
Main has the reviewed split of this branch (#199-#203), so main's version is
taken everywhere; the branch no longer differs from main.
…ls-and-constants

# Conflicts:
#	tests/CMakeLists.txt
@petlenz
petlenz changed the base branch from feature/material-reports to main October 24, 2026 21:16
@petlenz
petlenz marked this pull request as ready for review October 27, 2026 17:49
@petlenz
petlenz merged commit 8a5d4cb into main Oct 27, 2026
2 checks passed
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.

Elastic constants and rotation helpers (core/elastic_constants.h) Carlson elliptic integrals R_F, R_D, R_J (core/elliptic_integrals.h)

1 participant