AgentFEM-Material-Loading-Memory / tests /test_t2_graybox_closure.py
HaomingLuo's picture
Add DENIM incomplete-physics closure dataset and evidence
bbe9b3e verified
Raw History Blame Contribute Delete
857 Bytes
import numpy as np
from src.generate_t2_graybox_closure import closure_design, material, solve
def test_reference_is_intentionally_richer_than_closure_state():
law = material()
assert law.backstress_count == 3
assert law.isotropic_hardening is not None
assert len(law.isotropic_hardening.equivalent_plastic_strain) == 7
def test_closure_cohort_preserves_total_reference_backstress():
row = closure_design(4)[0]
nine_points = 9
result = solve(row, points=nine_points)
assert result["strain"].shape == (nine_points, 6)
assert result["truth_memories_pa"].shape == (nine_points, 3, 6)
assert result["memories_pa"].shape == (nine_points, 2, 6)
np.testing.assert_allclose(
result["memories_pa"].sum(axis=1),
result["truth_memories_pa"].sum(axis=1),
rtol=1.0e-12,
atol=1.0e-5,
)