File size: 2,331 Bytes
0ef4ba2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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