Skip to content

tests: cover the five materials that had none - #38

Open
petlenz wants to merge 2 commits into
feature/live-deck-constantsfrom
test/uncovered-materials
Open

tests: cover the five materials that had none#38
petlenz wants to merge 2 commits into
feature/live-deck-constantsfrom
test/uncovered-materials

Conversation

@petlenz

@petlenz petlenz commented Aug 22, 2026

Copy link
Copy Markdown
Member

Closes #34.

Asserted against closed forms rather than recorded output:

material assertion
exponential_isotropic_hardening H = K_inf(1-e^{-δκ}), dH = K_inf δ e^{-δκ}, plus the saturation distinguishing it from linear hardening
linear_damage_law all three branches, including the 0.999 cap that keeps (1-d) away from zero, and a zero range not dividing by zero
scalar_complement_weight value = 1 - source
strain_energy_state_function d(ε_eq)/dε against a central difference
vector_strain_state_function |n·ε·m|, and that the derivative carries the sign the measure discards

The hardening and damage materials read a specific producer property, so the tests use a small stub publishing one scalar under a chosen name. That isolates the material rather than testing it behind a full plasticity model, and one context per value also shows it is a pure function of its input.

Two of my own assertions were wrong first

I read hardening_modulus as H when it is dH — the material publishes H as hardening_stress — and asserted H < K_inf at κ=20, which is mathematically true and numerically false once exp(-160) underflows. Both are fixed; recording them because a test written from a guessed property name is worth less than no test.

weighted_sum, also listed in #34, is covered on #29 and not duplicated here.

exponential_isotropic_hardening, linear_damage_law, scalar_complement_weight,
strain_energy_state_function and vector_strain_state_function were referenced by
no test. Three are the SECOND of a pair whose first is well covered -- the
exponential hardening beside the linear one, the linear damage law beside the
exponential one, the complement weight beside the identity weight. The first of
a pair gets a test when it is written and the second inherits the assumption
that it is the same shape.

Asserted against the closed forms rather than against recorded output:

  exponential hardening  H = K_inf (1 - e^-dk), dH = K_inf d e^-dk, plus the
                         saturation that distinguishes it from linear hardening
  linear damage law      all three branches, including the 0.999 cap that keeps
                         (1-d) away from zero, and a zero range not dividing by 0
  complement weight      value = 1 - source
  strain energy          d(eps_eq)/d(eps) against a central difference
  vector strain          |n.eps.m|, and that the derivative carries the sign the
                         measure discards

The two hardening/damage materials take their input from a specific producer
property, so the tests use a small stub publishing one scalar under a chosen
name. That isolates the material instead of testing it behind a full plasticity
model, and building one context per value also shows it is a pure function of
its input.

Two of my own assertions were wrong first and are worth recording: I read
'hardening_modulus' as H when it is dH -- the material publishes H as
'hardening_stress' -- and asserted H < K_inf at kappa = 20, which is
mathematically true and numerically false once exp(-160) underflows.

weighted_sum, also listed in #34, is covered on feature/tangent-source-consumers
and is not duplicated here.

Closes #34.
@petlenz

petlenz commented Aug 23, 2026

Copy link
Copy Markdown
Member Author

Critical review. No findings. What I probed:

  • Each assertion is against a closed form, not recorded output, so a changed formula fails rather than a changed number being blessed.
  • The scalar_source_stub builds one context per value, so each material is shown to be a pure function of its input rather than of call order.
  • The finite-difference check on strain_energy_state_function uses a central difference at h=1e-6 against an analytic derivative — tightening the tolerance to 1e-7 still passes, so it is not passing on a loose bound.
  • The three-branch damage test crosses all three branches, asserted by construction rather than assumed from the increment.

The two errors worth keeping visible are already in the PR body: I read hardening_modulus as H when it is dH, and asserted H < K_inf at kappa=20, which is mathematically true and numerically false once exp(-160) underflows. Both failed loudly rather than passing wrongly, which is the only reason they were cheap.

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.

1 participant