HaomingLuo commited on
Commit
d22f9ea
·
verified ·
1 Parent(s): cc9644a

Add reproducible same-strain different-stress training-data example

Browse files
MEMORY_EXAMPLE.md ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Same strain, different stress
2
+
3
+ ![Two zero-strain states](example/material-memory.png)
4
+
5
+ The material returns to zero total strain twice. Its stress does not return to
6
+ the same value: **−481.3 MPa at A, +551.1 MPa at B**. Plastic strain has changed
7
+ between the two states. A model that sees only the current strain and material
8
+ parameters cannot distinguish them.
9
+
10
+ ## Run it
11
+
12
+ ```sh
13
+ pip install numpy h5py matplotlib huggingface_hub
14
+ python show_material_memory.py
15
+ ```
16
+
17
+ Download [the script](show_material_memory.py) first. It fetches one pinned HDF5
18
+ shard (not the entire dataset), checks its SHA-256, and produces a PNG, a CSV
19
+ containing all 121 states, and a JSON evidence record. The figure displays
20
+ states 0–60 so the two returns are easy to follow. No solver, GPU, model weights
21
+ or paid service is required.
22
+
23
+ Already have the data?
24
+
25
+ ```sh
26
+ python show_material_memory.py --shard data/t2_material_loading_memory_v1/shards/part-00002.h5
27
+ ```
28
+
29
+ ## What the figure means
30
+
31
+ This is synthetic J2 plasticity under prescribed **proportional deviatoric
32
+ strain**, not a uniaxial tensile test. The vertical axis uses the dataset's
33
+ signed equivalent stress, not the always-positive von Mises stress. The
34
+ horizontal loading-state index is not physical time.
35
+
36
+ The example uses training trajectory `00252`, the first training member of the
37
+ symmetric-cyclic J2 cohort. A and B are its first two noninitial returns to zero
38
+ strain (states 36 and 60); they were not chosen by maximizing the stress gap.
39
+ All nine components of their total-strain tensors match within `1e-12`. Their
40
+ accumulated equivalent plastic strains are approximately 0.01042 and 0.02210.
41
+ The input data are unchanged; no interpolation, training or neural prediction
42
+ is performed. This demonstrates why history matters, not DENIM accuracy.
43
+
44
+ Try a prediction before running: will B have the same stress as A, zero stress,
45
+ or stress of the opposite sign? Then inspect the CSV to trace how it got there.
46
+
47
+ ## 中文
48
+
49
+ 材料两次回到零应变,应力却分别为 **−481.3 MPa 和 +551.1 MPa**。
50
+ 原因是中间发生了塑性变形,材料内部状态已经改变。只告诉模型“现在的应变”,
51
+ 不足以确定此刻的应力,还需要加载历史或内部状态。
52
+
53
+ 这是合成材料点数据中的一个训练样本,不是实测数据,也不是 DENIM 的预测结果。
54
+ 运行脚本即可生成图、完整历程表和校验记录。图中使用有符号等效应力;加载步
55
+ 不是实际时间。没有读取封存测试集,也没有修改训练、验证或测试划分。
56
+
57
+ [Explore the interactive lab](https://lab.haoming-luo.com/material-memory/) ·
58
+ [DENIM model](https://huggingface.co/HaomingLuo/AgentFEM-DENIM) ·
59
+ [AgentFEM](https://github.com/haoming-luo/agentfem)
60
+
61
+ Data: Haoming Luo / AgentFEM, CC BY 4.0. Code: Apache-2.0, see `CODE_LICENSE`.
62
+ Pinned source revision and checksum are included in the script and JSON output.
README.md CHANGED
@@ -29,6 +29,7 @@ repository contains six staged, explicitly separated releases.
29
 
30
  | Goal | Recommended entry |
31
  |---|---|
 
32
  | Understand the current dataset | This page and the [sealed-test data card](data/t2_denim_sealed_test_v1/README.md) |
33
  | Train or benchmark a constitutive model | [DENIM start guide](DENIM_START_HERE.md) |
34
  | Reproduce the multiaxial baseline study | [Multiaxial v2 guide](T2_V2_START_HERE.md) |
 
29
 
30
  | Goal | Recommended entry |
31
  |---|---|
32
+ | See why loading history matters | [Run the two-state memory example](MEMORY_EXAMPLE.md) |
33
  | Understand the current dataset | This page and the [sealed-test data card](data/t2_denim_sealed_test_v1/README.md) |
34
  | Train or benchmark a constitutive model | [DENIM start guide](DENIM_START_HERE.md) |
35
  | Reproduce the multiaxial baseline study | [Multiaxial v2 guide](T2_V2_START_HERE.md) |
example/material-memory.png ADDED

Git LFS Details

  • SHA256: a759761a426cda5a23034c50f13e777250ca8da4a5a55eac142417fa5237f7fe
  • Pointer size: 131 Bytes
  • Size of remote file: 160 kB
example/memory-evidence.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "repository": "HaomingLuo/AgentFEM-Material-Loading-Memory",
3
+ "revision": "cc9644aa5b51ac4f0ff5cccc9a42452de0d220a3",
4
+ "shard_sha256": "952b90eed1ce3ac288487cf31180384fc12f79aa03d95e4885bfd73b85c9a46d",
5
+ "sample_id": "00252",
6
+ "case_id": "fd6ba3b5c8c72f940c60",
7
+ "split": "train",
8
+ "selection": "First two noninitial returns to zero strain; no interpolation",
9
+ "states": [
10
+ {
11
+ "index": 36,
12
+ "signed_equivalent_strain": 0.0,
13
+ "signed_equivalent_stress_MPa": -481.2623476804613,
14
+ "equivalent_plastic_strain": 0.010416983542376664
15
+ },
16
+ {
17
+ "index": 60,
18
+ "signed_equivalent_strain": 0.0,
19
+ "signed_equivalent_stress_MPa": 551.1334859108593,
20
+ "equivalent_plastic_strain": 0.02210042415668055
21
+ }
22
+ ],
23
+ "stress_difference_MPa": 1032.3958335913208,
24
+ "scope": "Synthetic proportional deviatoric J2 material-point history; not experiment or model accuracy."
25
+ }
example/memory-history.csv ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ state,signed_equivalent_strain,signed_equivalent_stress_MPa,equivalent_plastic_strain
2
+ 0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00
3
+ 1.000000000000000000e+00,3.568031928734854042e-04,7.420118321578229370e+01,0.000000000000000000e+00
4
+ 2.000000000000000000e+00,7.136063857469708083e-04,1.484023664315645874e+02,0.000000000000000000e+00
5
+ 3.000000000000000000e+00,1.070409578620456267e-03,2.226035496473469095e+02,0.000000000000000000e+00
6
+ 4.000000000000000000e+00,1.427212771493941617e-03,2.968047328631291748e+02,0.000000000000000000e+00
7
+ 5.000000000000000000e+00,1.784015964367426967e-03,3.710059160789114117e+02,0.000000000000000000e+00
8
+ 6.000000000000000000e+00,2.140819157240912533e-03,4.196986236154887706e+02,1.226598441322449310e-04
9
+ 7.000000000000000000e+00,2.497622350114397666e-03,4.217727869491141064e+02,4.694892324394810915e-04
10
+ 8.000000000000000000e+00,2.854425542987883233e-03,4.238469502827396127e+02,8.163186207467171707e-04
11
+ 9.000000000000000000e+00,3.211228735861368800e-03,4.259211136163650622e+02,1.163148009053953467e-03
12
+ 1.000000000000000000e+01,3.568031928734853933e-03,4.279952769499903980e+02,1.509977397361189329e-03
13
+ 1.100000000000000000e+01,3.924835121608339500e-03,4.300694402836159043e+02,1.856806785668425625e-03
14
+ 1.200000000000000000e+01,4.281638314481825067e-03,4.321436036172414106e+02,2.203636173975661271e-03
15
+ 1.300000000000000000e+01,4.638441507355310633e-03,4.342177669508666895e+02,2.550465562282897350e-03
16
+ 1.400000000000000000e+01,4.995244700228795333e-03,4.362919302844921958e+02,2.897294950590133429e-03
17
+ 1.500000000000000000e+01,5.352047893102280900e-03,4.383660936181175884e+02,3.244124338897369508e-03
18
+ 1.600000000000000000e+01,5.708851085975766466e-03,4.404402569517429811e+02,3.590953727204606021e-03
19
+ 1.700000000000000000e+01,6.065654278849252033e-03,4.425144202853684305e+02,3.937783115511842534e-03
20
+ 1.800000000000000000e+01,6.422457471722737600e-03,4.445885836189938800e+02,4.284612503819078613e-03
21
+ 1.900000000000000000e+01,6.779260664596223167e-03,4.466627469526192726e+02,4.631441892126313825e-03
22
+ 2.000000000000000000e+01,7.136063857469707866e-03,4.487369102862447221e+02,4.978271280433550772e-03
23
+ 2.100000000000000000e+01,7.492867050343193433e-03,4.508110736198701716e+02,5.325100668740786851e-03
24
+ 2.200000000000000000e+01,7.849670243216679000e-03,4.528852369534956210e+02,5.671930057048022930e-03
25
+ 2.300000000000000000e+01,8.206473436090164567e-03,4.549594002871210705e+02,6.018759445355259009e-03
26
+ 2.400000000000000000e+01,8.563276628963650133e-03,4.570335636207463494e+02,6.365588833662495089e-03
27
+ 2.500000000000000000e+01,7.849670243216679000e-03,3.086311971891819326e+02,6.365588833662495089e-03
28
+ 2.600000000000000000e+01,7.136063857469708734e-03,1.602288307576174020e+02,6.365588833662495089e-03
29
+ 2.700000000000000000e+01,6.422457471722737600e-03,1.182646432605276843e+01,6.365588833662495089e-03
30
+ 2.800000000000000000e+01,5.708851085975766466e-03,-1.365759021055116875e+02,6.365588833662495089e-03
31
+ 2.900000000000000000e+01,4.995244700228796200e-03,-2.849782685370763602e+02,6.365588833662495089e-03
32
+ 3.000000000000000000e+01,4.281638314481825067e-03,-4.333806349686410613e+02,6.365588833662495089e-03
33
+ 3.100000000000000000e+01,3.568031928734854800e-03,-4.605207143442070219e+02,6.948689659304298737e-03
34
+ 3.200000000000000000e+01,2.854425542987883233e-03,-4.646690410114578071e+02,7.642348435918771762e-03
35
+ 3.300000000000000000e+01,2.140819157240912533e-03,-4.688173676787087061e+02,8.336007212533245656e-03
36
+ 3.400000000000000000e+01,1.427212771493942267e-03,-4.729656943459595482e+02,9.029665989147717814e-03
37
+ 3.500000000000000000e+01,7.136063857469711336e-04,-4.771140210132103903e+02,9.723324765762191707e-03
38
+ 3.600000000000000000e+01,0.000000000000000000e+00,-4.812623476804612892e+02,1.041698354237666387e-02
39
+ 3.700000000000000000e+01,-7.136063857469711336e-04,-4.854106743477121313e+02,1.111064231899113602e-02
40
+ 3.800000000000000000e+01,-1.427212771493940532e-03,-4.895590010149630302e+02,1.180430109560560645e-02
41
+ 3.900000000000000000e+01,-2.140819157240911666e-03,-4.937073276822139292e+02,1.249795987222007861e-02
42
+ 4.000000000000000000e+01,-2.854425542987882800e-03,-4.978556543494646576e+02,1.319161864883455250e-02
43
+ 4.100000000000000000e+01,-3.568031928734853933e-03,-5.020039810167154997e+02,1.388527742544902466e-02
44
+ 4.200000000000000000e+01,-4.281638314481825067e-03,-5.061523076839663986e+02,1.457893620206349682e-02
45
+ 4.300000000000000000e+01,-4.995244700228794466e-03,-5.103006343512172975e+02,1.527259497867796897e-02
46
+ 4.400000000000000000e+01,-5.708851085975765599e-03,-5.144489610184681396e+02,1.596625375529244287e-02
47
+ 4.500000000000000000e+01,-6.422457471722736733e-03,-5.185972876857190386e+02,1.665991253190691676e-02
48
+ 4.600000000000000000e+01,-7.136063857469707866e-03,-5.227456143529699375e+02,1.735357130852139065e-02
49
+ 4.700000000000000000e+01,-7.849670243216679000e-03,-5.268939410202207227e+02,1.804723008513586455e-02
50
+ 4.800000000000000000e+01,-8.563276628963650133e-03,-5.310422676874715080e+02,1.874088886175033844e-02
51
+ 4.900000000000000000e+01,-7.849670243216679000e-03,-3.826399012559068638e+02,1.874088886175033844e-02
52
+ 5.000000000000000000e+01,-7.136063857469708734e-03,-2.342375348243424185e+02,1.874088886175033844e-02
53
+ 5.100000000000000000e+01,-6.422457471722737600e-03,-8.583516839277776000e+01,1.874088886175033844e-02
54
+ 5.200000000000000000e+01,-5.708851085975766466e-03,6.256719803878672082e+01,1.874088886175033844e-02
55
+ 5.300000000000000000e+01,-4.995244700228796200e-03,2.109695644703513722e+02,1.874088886175033844e-02
56
+ 5.400000000000000000e+01,-4.281638314481825067e-03,3.593719309019160164e+02,1.874088886175033844e-02
57
+ 5.500000000000000000e+01,-3.568031928734854800e-03,5.077742973334806038e+02,1.874088886175033844e-02
58
+ 5.600000000000000000e+01,-2.854425542987883233e-03,5.345401792418558671e+02,1.932578905022265883e-02
59
+ 5.700000000000000000e+01,-2.140819157240912533e-03,5.386885059091067660e+02,2.001944782683713273e-02
60
+ 5.800000000000000000e+01,-1.427212771493942267e-03,5.428368325763575513e+02,2.071310660345160315e-02
61
+ 5.900000000000000000e+01,-7.136063857469711336e-04,5.469851592436084502e+02,2.140676538006607704e-02
62
+ 6.000000000000000000e+01,0.000000000000000000e+00,5.511334859108593491e+02,2.210042415668055094e-02
63
+ 6.100000000000000000e+01,7.136063857469711336e-04,5.552818125781102481e+02,2.279408293329502483e-02
64
+ 6.200000000000000000e+01,1.427212771493940532e-03,5.594301392453610333e+02,2.348774170990949525e-02
65
+ 6.300000000000000000e+01,2.140819157240911666e-03,5.635784659126119323e+02,2.418140048652396915e-02
66
+ 6.400000000000000000e+01,2.854425542987882800e-03,5.677267925798628312e+02,2.487505926313844304e-02
67
+ 6.500000000000000000e+01,3.568031928734853933e-03,5.718751192471137301e+02,2.556871803975291693e-02
68
+ 6.600000000000000000e+01,4.281638314481825067e-03,5.760234459143646291e+02,2.626237681636739082e-02
69
+ 6.700000000000000000e+01,4.995244700228794466e-03,5.801717725816154143e+02,2.695603559298186125e-02
70
+ 6.800000000000000000e+01,5.708851085975765599e-03,5.843200992488661996e+02,2.764969436959633514e-02
71
+ 6.900000000000000000e+01,6.422457471722736733e-03,5.884684259161170985e+02,2.834335314621080903e-02
72
+ 7.000000000000000000e+01,7.136063857469707866e-03,5.926167525833679974e+02,2.903701192282528293e-02
73
+ 7.100000000000000000e+01,7.849670243216679000e-03,5.967650792506186690e+02,2.973067069943975682e-02
74
+ 7.200000000000000000e+01,8.563276628963650133e-03,6.009134059178697953e+02,3.042432947605422724e-02
75
+ 7.300000000000000000e+01,7.849670243216679000e-03,4.525110394863050942e+02,3.042432947605422724e-02
76
+ 7.400000000000000000e+01,7.136063857469708734e-03,3.041086730547406773e+02,3.042432947605422724e-02
77
+ 7.500000000000000000e+01,6.422457471722737600e-03,1.557063066231760331e+02,3.042432947605422724e-02
78
+ 7.600000000000000000e+01,5.708851085975766466e-03,7.303940191611565602e+00,3.042432947605422724e-02
79
+ 7.700000000000000000e+01,4.995244700228796200e-03,-1.410984262399531133e+02,3.042432947605422724e-02
80
+ 7.800000000000000000e+01,4.281638314481825067e-03,-2.895007926715177291e+02,3.042432947605422724e-02
81
+ 7.900000000000000000e+01,3.568031928734854800e-03,-4.379031591030823165e+02,3.042432947605422724e-02
82
+ 8.000000000000000000e+01,2.854425542987883233e-03,-5.863055255346469039e+02,3.042432947605422724e-02
83
+ 8.100000000000000000e+01,2.140819157240912533e-03,-6.046533950282280330e+02,3.104970844905633950e-02
84
+ 8.200000000000000000e+01,1.427212771493942267e-03,-6.088017216954789319e+02,3.174336722567080993e-02
85
+ 8.300000000000000000e+01,7.136063857469711336e-04,-6.129500483627298308e+02,3.243702600228528382e-02
86
+ 8.400000000000000000e+01,0.000000000000000000e+00,-6.170983750299806161e+02,3.313068477889975771e-02
87
+ 8.500000000000000000e+01,-7.136063857469711336e-04,-6.212467016972314013e+02,3.382434355551423161e-02
88
+ 8.600000000000000000e+01,-1.427212771493940532e-03,-6.253950283644824140e+02,3.451800233212870550e-02
89
+ 8.700000000000000000e+01,-2.140819157240911666e-03,-6.295433550317333129e+02,3.521166110874317939e-02
90
+ 8.800000000000000000e+01,-2.854425542987882800e-03,-6.336916816989840981e+02,3.590531988535765329e-02
91
+ 8.900000000000000000e+01,-3.568031928734853933e-03,-6.378400083662349971e+02,3.659897866197212718e-02
92
+ 9.000000000000000000e+01,-4.281638314481825067e-03,-6.419883350334858960e+02,3.729263743858660107e-02
93
+ 9.100000000000000000e+01,-4.995244700228794466e-03,-6.461366617007367950e+02,3.798629621520107497e-02
94
+ 9.200000000000000000e+01,-5.708851085975765599e-03,-6.502849883679875802e+02,3.867995499181554886e-02
95
+ 9.300000000000000000e+01,-6.422457471722736733e-03,-6.544333150352384791e+02,3.937361376843002275e-02
96
+ 9.400000000000000000e+01,-7.136063857469707866e-03,-6.585816417024893781e+02,4.006727254504449665e-02
97
+ 9.500000000000000000e+01,-7.849670243216679000e-03,-6.627299683697401633e+02,4.076093132165897054e-02
98
+ 9.600000000000000000e+01,-8.563276628963650133e-03,-6.668782950369911759e+02,4.145459009827344443e-02
99
+ 9.700000000000000000e+01,-7.849670243216679000e-03,-5.184759286054264749e+02,4.145459009827344443e-02
100
+ 9.800000000000000000e+01,-7.136063857469708734e-03,-3.700735621738620011e+02,4.145459009827344443e-02
101
+ 9.900000000000000000e+01,-6.422457471722737600e-03,-2.216711957422973001e+02,4.145459009827344443e-02
102
+ 1.000000000000000000e+02,-5.708851085975766466e-03,-7.326882931073281213e+01,4.145459009827344443e-02
103
+ 1.010000000000000000e+02,-4.995244700228796200e-03,7.513353712083184632e+01,4.145459009827344443e-02
104
+ 1.020000000000000000e+02,-4.281638314481825067e-03,2.235359035523964621e+02,4.145459009827344443e-02
105
+ 1.030000000000000000e+02,-3.568031928734854800e-03,3.719382699839609927e+02,4.145459009827344443e-02
106
+ 1.040000000000000000e+02,-2.854425542987883233e-03,5.203406364155256369e+02,4.145459009827344443e-02
107
+ 1.050000000000000000e+02,-2.140819157240912533e-03,6.669304196581900896e+02,4.146330607072994112e-02
108
+ 1.060000000000000000e+02,-1.427212771493942267e-03,6.710787463254406475e+02,4.215696484734441501e-02
109
+ 1.070000000000000000e+02,-7.136063857469711336e-04,6.752270729926916601e+02,4.285062362395888891e-02
110
+ 1.080000000000000000e+02,0.000000000000000000e+00,6.793753996599425591e+02,4.354428240057336280e-02
111
+ 1.090000000000000000e+02,7.136063857469711336e-04,6.835237263271933443e+02,4.423794117718783669e-02
112
+ 1.100000000000000000e+02,1.427212771493940532e-03,6.876720529944441296e+02,4.493159995380231059e-02
113
+ 1.110000000000000000e+02,2.140819157240911666e-03,6.918203796616951422e+02,4.562525873041678448e-02
114
+ 1.120000000000000000e+02,2.854425542987882800e-03,6.959687063289461548e+02,4.631891750703125837e-02
115
+ 1.130000000000000000e+02,3.568031928734853933e-03,7.001170329961967127e+02,4.701257628364573227e-02
116
+ 1.140000000000000000e+02,4.281638314481825067e-03,7.042653596634477253e+02,4.770623506026020616e-02
117
+ 1.150000000000000000e+02,4.995244700228794466e-03,7.084136863306986243e+02,4.839989383687468005e-02
118
+ 1.160000000000000000e+02,5.708851085975765599e-03,7.125620129979495232e+02,4.909355261348915395e-02
119
+ 1.170000000000000000e+02,6.422457471722736733e-03,7.167103396652001948e+02,4.978721139010362784e-02
120
+ 1.180000000000000000e+02,7.136063857469707866e-03,7.208586663324512074e+02,5.048087016671810173e-02
121
+ 1.190000000000000000e+02,7.849670243216679000e-03,7.250069929997022200e+02,5.117452894333257563e-02
122
+ 1.200000000000000000e+02,8.563276628963650133e-03,7.291553196669530053e+02,5.186818771994704952e-02
show_material_memory.py ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Show two zero-strain states with different stresses in published train data.
3
+
4
+ Install: pip install numpy h5py matplotlib huggingface_hub
5
+ Run: python show_material_memory.py
6
+ Offline: python show_material_memory.py --shard /path/to/part-00002.h5
7
+ Code: Apache-2.0; source data: CC BY 4.0, Haoming Luo / AgentFEM.
8
+ This reads a synthetic material-point history, not a DENIM prediction.
9
+ """
10
+ import argparse
11
+ import hashlib
12
+ import json
13
+ from pathlib import Path
14
+
15
+ import h5py
16
+ import numpy as np
17
+
18
+ REPO = "HaomingLuo/AgentFEM-Material-Loading-Memory"
19
+ REVISION = "cc9644aa5b51ac4f0ff5cccc9a42452de0d220a3"
20
+ FILE = "data/t2_material_loading_memory_v1/shards/part-00002.h5"
21
+ SHA256 = "952b90eed1ce3ac288487cf31180384fc12f79aa03d95e4885bfd73b85c9a46d"
22
+ SAMPLE = "00252" # First training trajectory in the symmetric-cyclic J2 cohort.
23
+
24
+
25
+ def read_sample(path):
26
+ digest = hashlib.sha256(Path(path).read_bytes()).hexdigest()
27
+ if digest != SHA256:
28
+ raise ValueError("Shard checksum mismatch; use the pinned published file.")
29
+ with h5py.File(path, "r") as f:
30
+ g = f[SAMPLE]
31
+ if str(g.attrs["split"]) != "train":
32
+ raise ValueError("Illustration must use training data only.")
33
+ arrays = {name: g[name][:] for name in (
34
+ "total_strain", "signed_equivalent_strain",
35
+ "signed_equivalent_stress_pa", "equivalent_plastic_strain")}
36
+ case_id = str(g.attrs["case_id"])
37
+ if not all(np.isfinite(a).all() for a in arrays.values()):
38
+ raise ValueError("Non-finite trajectory.")
39
+ # First two returns to zero after the virgin state, not maximum-gap selection.
40
+ zero = np.flatnonzero(np.max(np.abs(arrays["total_strain"]), axis=(1, 2)) < 1e-12)
41
+ zero = zero[zero > 0]
42
+ if len(zero) < 2:
43
+ raise ValueError("No two noninitial zero-strain states.")
44
+ a, b = map(int, zero[:2])
45
+ if not np.allclose(arrays["total_strain"][a], arrays["total_strain"][b], atol=1e-12, rtol=0):
46
+ raise ValueError("The complete strain tensors differ.")
47
+ return arrays, a, b, case_id
48
+
49
+
50
+ def main():
51
+ parser = argparse.ArgumentParser(description=__doc__)
52
+ parser.add_argument("--shard", type=Path)
53
+ parser.add_argument("--out", type=Path, default=Path("memory-example"))
54
+ args = parser.parse_args()
55
+ if args.shard is None:
56
+ from huggingface_hub import hf_hub_download
57
+ args.shard = Path(hf_hub_download(REPO, FILE, repo_type="dataset", revision=REVISION))
58
+ d, a, b, case_id = read_sample(args.shard)
59
+ strain = d["signed_equivalent_strain"] * 100
60
+ stress = d["signed_equivalent_stress_pa"] / 1e6
61
+ report = {"repository": REPO, "revision": REVISION, "shard_sha256": SHA256,
62
+ "sample_id": SAMPLE, "case_id": case_id, "split": "train",
63
+ "selection": "First two noninitial returns to zero strain; no interpolation",
64
+ "states": [{"index": i, "signed_equivalent_strain": float(strain[i]/100),
65
+ "signed_equivalent_stress_MPa": float(stress[i]),
66
+ "equivalent_plastic_strain": float(d["equivalent_plastic_strain"][i])}
67
+ for i in (a, b)],
68
+ "stress_difference_MPa": float(abs(stress[b]-stress[a])),
69
+ "scope": "Synthetic proportional deviatoric J2 material-point history; not experiment or model accuracy."}
70
+ args.out.mkdir(parents=True, exist_ok=True)
71
+ (args.out / "memory-evidence.json").write_text(json.dumps(report, indent=2)+"\n")
72
+ np.savetxt(args.out / "memory-history.csv", np.column_stack((np.arange(len(strain)), strain/100, stress,
73
+ d["equivalent_plastic_strain"])), delimiter=",", comments="",
74
+ header="state,signed_equivalent_strain,signed_equivalent_stress_MPa,equivalent_plastic_strain")
75
+ import matplotlib
76
+ matplotlib.use("Agg")
77
+ import matplotlib.pyplot as plt
78
+ plt.rcParams.update({"font.family": "DejaVu Sans", "font.size": 11})
79
+ bg, panel, fg, muted = "#081418", "#102127", "#edf3f1", "#97afb2"
80
+ colors = ["#85d6cb", "#e9b16d"]
81
+ fig, axes = plt.subplots(1, 2, figsize=(12, 5.7), facecolor=bg)
82
+ fig.subplots_adjust(left=.085, right=.97, bottom=.23, top=.76, wspace=.3)
83
+ for ax in axes:
84
+ ax.set_facecolor(panel)
85
+ ax.tick_params(colors=muted)
86
+ ax.xaxis.label.set_color(fg); ax.yaxis.label.set_color(fg)
87
+ for spine in ax.spines.values(): spine.set_color("#344a50")
88
+ ax.grid(alpha=.12, color=muted)
89
+ steps = np.arange(b+1)
90
+ axes[0].plot(steps, strain[:b+1], color=fg, lw=2)
91
+ axes[0].axhline(0, color=muted, lw=.8, ls="--")
92
+ axes[0].set(xlabel="Loading state (not physical time)", ylabel="Signed equivalent strain / %")
93
+ axes[1].plot(strain[:a+1], stress[:a+1], color=colors[0], lw=2)
94
+ axes[1].plot(strain[a:b+1], stress[a:b+1], color=colors[1], lw=2)
95
+ axes[1].axvline(0, color=muted, lw=.8, ls="--")
96
+ axes[1].set(xlabel="Signed equivalent strain / %", ylabel="Signed equivalent stress / MPa")
97
+ for label, i, color in zip(["A", "B"], (a, b), colors):
98
+ axes[0].scatter(i, strain[i], color=color, s=65, zorder=5)
99
+ axes[0].annotate(label, (i, strain[i]), xytext=(0, 12), textcoords="offset points", ha="center", color=color)
100
+ axes[1].scatter(strain[i], stress[i], color=color, s=65, zorder=5)
101
+ axes[1].annotate(f"{label} {stress[i]:+.1f} MPa", (strain[i], stress[i]),
102
+ xytext=(12, 5), textcoords="offset points", color=color, fontsize=10,
103
+ bbox={"facecolor": panel, "edgecolor": "none", "pad": 2})
104
+ fig.text(.085, .92, "Same strain. Different stress.", color=fg, size=25, weight="bold")
105
+ fig.text(.085, .85, "The loading path leaves a material memory.", color=muted, size=14)
106
+ fig.text(.085, .105, "A and B: zero total strain, different plastic states. No interpolation or neural prediction.", color=fg, size=10)
107
+ fig.text(.085, .055, "AgentFEM | Synthetic J2 training history 00252 | Data: CC BY 4.0", color=muted, size=9)
108
+ fig.savefig(args.out / "material-memory.png", dpi=160, facecolor=bg)
109
+ plt.close(fig)
110
+ print(json.dumps(report, indent=2))
111
+
112
+
113
+ if __name__ == "__main__":
114
+ main()