Download conditional_v2/tests/test_t2_denim_conditional.py from HaomingLuo/AgentFEM-Material-Loading-Memory: direct link, hf CLI and curl.
- Browser
- Download file 2.33 kB
-
https://huggingface.co/datasets/HaomingLuo/AgentFEM-Material-Loading-Memory/resolve/main/conditional_v2/tests/test_t2_denim_conditional.py
- Command line
-
hf download hf://datasets/HaomingLuo/AgentFEM-Material-Loading-Memory/conditional_v2/tests/test_t2_denim_conditional.py
-
curl -L -o test_t2_denim_conditional.py https://huggingface.co/datasets/HaomingLuo/AgentFEM-Material-Loading-Memory/resolve/main/conditional_v2/tests/test_t2_denim_conditional.py
2.33 kB
| from __future__ import annotations | |
| import torch | |
| from src.t2_denim_conditional import ConditionalDENIM, material_descriptor, rollout | |
| def test_descriptor_hides_incomplete_parameters() -> None: | |
| descriptor = material_descriptor( | |
| { | |
| "material_model": "hidden_three_memory_tabulated_hardening", | |
| "young_pa": 190.0e9, | |
| "poisson": 0.3, | |
| "yield_stress_pa": 280.0e6, | |
| "backstress_c1_pa": 99.0e9, | |
| } | |
| ) | |
| assert descriptor.shape == (13,) | |
| assert torch.count_nonzero(descriptor[3:10]) == 0 | |
| assert torch.equal(descriptor[-3:], torch.tensor([0.0, 0.0, 1.0])) | |
| def test_conditional_rollout_preserves_hard_constraints() -> None: | |
| torch.manual_seed(7) | |
| model = ConditionalDENIM() | |
| strain = torch.zeros((2, 17, 6), dtype=torch.float32) | |
| strain[:, :, 0] = torch.linspace(0.0, 0.006, 17) | |
| descriptor = torch.stack( | |
| [ | |
| material_descriptor( | |
| { | |
| "material_model": "j2_linear_isotropic", | |
| "young_pa": 200.0e9, | |
| "poisson": 0.3, | |
| "yield_stress_pa": 300.0e6, | |
| "hardening_modulus_pa": 2.0e9, | |
| } | |
| ), | |
| material_descriptor( | |
| { | |
| "material_model": "chaboche_combined", | |
| "young_pa": 190.0e9, | |
| "poisson": 0.29, | |
| "yield_stress_pa": 280.0e6, | |
| "backstress_c1_pa": 25.0e9, | |
| "backstress_gamma1": 70.0, | |
| "backstress_c2_pa": 8.0e9, | |
| "backstress_gamma2": 12.0, | |
| "isotropic_saturation_pa": 60.0e6, | |
| "isotropic_rate": 8.0, | |
| } | |
| ), | |
| ] | |
| ) | |
| result = rollout( | |
| strain, | |
| torch.tensor([200.0e9, 190.0e9]), | |
| torch.tensor([0.3, 0.29]), | |
| torch.tensor([300.0e6, 280.0e6]), | |
| descriptor, | |
| model, | |
| bisection_iterations=8, | |
| ) | |
| assert torch.isfinite(result["stress"]).all() | |
| assert torch.diff(result["peeq"], dim=1).min() >= 0.0 | |
| assert result["plastic_strain"][..., :3].sum(dim=-1).abs().max() < 1.0e-6 | |
| active = result["plastic_increment"] > 0.0 | |
| assert result["yield_residual"][active].abs().max() < 5.0e6 | |