Add DENIM capability extension v4
Browse filesAdd 1,000 long-cycle, full-3D, AgentFEM-derived and discretization/observation trajectories with checksums and quality evidence.
- DENIM_CAPABILITY_V4_SHA256SUMS +17 -0
- README.md +23 -1
- artifacts/t2_denim_capability_v4/QUALITY_REPORT.md +51 -0
- artifacts/t2_denim_capability_v4/audit.json +11 -0
- artifacts/t2_denim_capability_v4/capability_extension_preview.png +3 -0
- artifacts/t2_denim_capability_v4/capability_summary.json +86 -0
- artifacts/t2_denim_capability_v4/quality.json +71 -0
- configs/t2_denim_capability_v4.json +49 -0
- data/t2_denim_capability_v4/README.md +56 -0
- data/t2_denim_capability_v4/cohort.h5 +3 -0
- data/t2_denim_capability_v4/index.csv +0 -0
- data/t2_denim_capability_v4/index.jsonl +0 -0
- data/t2_denim_capability_v4/manifest.json +71 -0
- data/t2_denim_capability_v4/structure_bases.npz +3 -0
- docs/T2_DENIM_CAPABILITY_V4.md +27 -0
- src/analyze_t2_denim_capability_v4.py +184 -0
- src/generate_t2_denim_capability_v4.py +824 -0
- tests/test_t2_denim_capability_v4.py +78 -0
DENIM_CAPABILITY_V4_SHA256SUMS
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
79265c6bbe4fbeef4f9f8f2923bbf57392e9d08b15ade2c382e9d4dbc358bc1c README.md
|
| 2 |
+
43127dea2e4c342ac230cc941358f70b50f8d9b57af7955c6e1ad185b45ddc77 artifacts/t2_denim_capability_v4/QUALITY_REPORT.md
|
| 3 |
+
fa15c3bb35e7ad34cdabfff5bfceae32fb4503529ba95c9ea5bc861a3077c652 artifacts/t2_denim_capability_v4/audit.json
|
| 4 |
+
40dbfe5ac92c84acf207ecf0748cbaf1575fbbb471a7839dac9d1d90dc9606c6 artifacts/t2_denim_capability_v4/capability_extension_preview.png
|
| 5 |
+
4ea985601b0e596d41ed3df747b86b15483deb6b4e249b44b3bca09739ca1add artifacts/t2_denim_capability_v4/capability_summary.json
|
| 6 |
+
cc39a7c9fcd1756f80deb5eaacf97082e83c6c1c073657b451c68f1cafba5125 artifacts/t2_denim_capability_v4/quality.json
|
| 7 |
+
ac79f463be9a13c7d8382b8ac2465f333bbae65d07c94d0034e5e869bbe55604 configs/t2_denim_capability_v4.json
|
| 8 |
+
b6f797a38bfdfa964093fccc844c5ce6a548d630d30cf7f90c152d3cc5990c97 data/t2_denim_capability_v4/README.md
|
| 9 |
+
d41b5f62b89f0bd5ad29b6682093add0eeaf0a30fbfd76d7e62f310c039c32f1 data/t2_denim_capability_v4/cohort.h5
|
| 10 |
+
49b454971df8f9b0d4f9311baad211d154240a2c7ced6c4cf6e98b893ca9cc2f data/t2_denim_capability_v4/index.csv
|
| 11 |
+
4a1f97a775d7168f068f2d6e5b21c27a0f1a872b5fe0de63b2f1ce71c713f972 data/t2_denim_capability_v4/index.jsonl
|
| 12 |
+
cc39a7c9fcd1756f80deb5eaacf97082e83c6c1c073657b451c68f1cafba5125 data/t2_denim_capability_v4/manifest.json
|
| 13 |
+
4f2f33836b38188f5f0d6c5a309b0764a3eaa1893b2a1b387e4ca56ced9ab9a9 data/t2_denim_capability_v4/structure_bases.npz
|
| 14 |
+
3af402ecc46919436ec2dea1c07426dff8e6782fb10a4dd681e1d3683d89e799 docs/T2_DENIM_CAPABILITY_V4.md
|
| 15 |
+
1fbc923311b7279b10f7db38c7e4e720a9f027b38eca4fb52e34b95b01d6429c src/analyze_t2_denim_capability_v4.py
|
| 16 |
+
038c9018d5c8c154f5cbd2cb00cccca6df7ea18eb97bde7b73e7086524104f7d src/generate_t2_denim_capability_v4.py
|
| 17 |
+
5b6ba71f89aa9b3967327954a7fab047fdbbce270278520802dee99912a43073 tests/test_t2_denim_capability_v4.py
|
README.md
CHANGED
|
@@ -35,8 +35,11 @@ repository contains four related, explicitly separated research protocols.
|
|
| 35 |
two-memory DENIM model must learn the missing internal-variable closure.
|
| 36 |
- **T2 DENIM boundary v1:** 500 additional trajectories for training-density,
|
| 37 |
path, amplitude, long-history and integration-resolution boundaries.
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
-
The repository
|
| 40 |
are used as a staged evidence chain; they are not presented as 2,660
|
| 41 |
exchangeable samples from one training distribution.
|
| 42 |
|
|
@@ -107,6 +110,25 @@ Expanded-DENIM RMSE on matched 61/121/481/961-state histories was
|
|
| 107 |
- Full metrics: `artifacts/t2_denim_boundary_v1/model_metrics.json`
|
| 108 |
- All-data usage: `docs/T2_ALL_DATA_STAGE_SUMMARY.md`
|
| 109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
## AgentFEM runtime validation
|
| 111 |
|
| 112 |
The expanded DENIM checkpoint is also available as a checksum-authenticated
|
|
|
|
| 35 |
two-memory DENIM model must learn the missing internal-variable closure.
|
| 36 |
- **T2 DENIM boundary v1:** 500 additional trajectories for training-density,
|
| 37 |
path, amplitude, long-history and integration-resolution boundaries.
|
| 38 |
+
- **T2 DENIM capability v4:** 1,000 trajectories for 100-cycle horizons,
|
| 39 |
+
full six-component loading, AgentFEM-derived structural paths and paired
|
| 40 |
+
discretization/noisy-observation tests.
|
| 41 |
|
| 42 |
+
The repository now contains **3,660 complete trajectories**. The original 2,660-role protocol remains frozen; the v4 extension has separate train/validation/test roles and does not retroactively alter published scores. Releases
|
| 43 |
are used as a staged evidence chain; they are not presented as 2,660
|
| 44 |
exchangeable samples from one training distribution.
|
| 45 |
|
|
|
|
| 110 |
- Full metrics: `artifacts/t2_denim_boundary_v1/model_metrics.json`
|
| 111 |
- All-data usage: `docs/T2_ALL_DATA_STAGE_SUMMARY.md`
|
| 112 |
|
| 113 |
+
|
| 114 |
+
## DENIM capability extension v4
|
| 115 |
+
|
| 116 |
+

|
| 117 |
+
|
| 118 |
+
The v4 increment adds 1,000 complete trajectories: 300 long-cycle, 300 full
|
| 119 |
+
six-component non-proportional, 200 AgentFEM-derived local structural paths and
|
| 120 |
+
200 matched discretization/observation trajectories. The 100-cycle histories
|
| 121 |
+
contain 2,001 accepted material states. Fifty continuous paths are integrated
|
| 122 |
+
at 61, 121, 241 and 481 states and carry explicit group IDs; noisy and sparse
|
| 123 |
+
observations are fields paired with clean truth, not separately counted cases.
|
| 124 |
+
|
| 125 |
+
The structure-derived cohort uses local strain bases from twelve AgentFEM
|
| 126 |
+
linear-elastic unit-load solves on four perforated/notched plates, followed by
|
| 127 |
+
nonlinear reference-material replay. It does not claim coupled elastoplastic
|
| 128 |
+
redistribution. See `data/t2_denim_capability_v4/README.md` for the exact
|
| 129 |
+
protocol and `artifacts/t2_denim_capability_v4/capability_summary.json` for
|
| 130 |
+
machine-readable boundary statistics.
|
| 131 |
+
|
| 132 |
## AgentFEM runtime validation
|
| 133 |
|
| 134 |
The expanded DENIM checkpoint is also available as a checksum-authenticated
|
artifacts/t2_denim_capability_v4/QUALITY_REPORT.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DENIM能力边界扩展v4质量报告
|
| 2 |
+
|
| 3 |
+
## 数据规模
|
| 4 |
+
|
| 5 |
+
- 新增完整轨迹:1,000条;
|
| 6 |
+
- 长循环:300条,其中训练10/25循环、验证50循环、测试100循环;
|
| 7 |
+
- 完整三维非比例加载:300条,覆盖六个路径族;
|
| 8 |
+
- AgentFEM结构来源路径:200条,来自4个几何、12次单位载荷有限元求解;
|
| 9 |
+
- 步长与观测鲁棒性:200条,即50个连续路径分别采用61/121/241/481个状态点;
|
| 10 |
+
- 正式HDF5大小:111,577,525 bytes;
|
| 11 |
+
- 生成时间:450.10 s;AgentFEM提交`40c965225fc3b8d12a93a68e0d6b01dd35d47d82`。
|
| 12 |
+
|
| 13 |
+
## 数据完整性和物理门
|
| 14 |
+
|
| 15 |
+
- 1,000/1,000轨迹组完整,case ID全部唯一;
|
| 16 |
+
- 缺失必需字段:0;非有限数组:0;
|
| 17 |
+
- 最大屈服面相对残差:`9.35e-11`;
|
| 18 |
+
- 塑性应变最大绝对迹:`1.84e-17`;
|
| 19 |
+
- PEEQ最小增量:0;
|
| 20 |
+
- 每条轨迹至少包含35个塑性增量;
|
| 21 |
+
- HDF5 SHA-256:`d41b5f62b89f0bd5ad29b6682093add0eeaf0a30fbfd76d7e62f310c039c32f1`。
|
| 22 |
+
|
| 23 |
+
## 能力边界统计
|
| 24 |
+
|
| 25 |
+
完整三维队列的中位活跃Voigt分量数为6,83.33%的轨迹六个分量均有显著变化;
|
| 26 |
+
仅三剪切旋转族按设计只激活三个剪切分量。长循环测试包含80条100循环、每条
|
| 27 |
+
2,001状态的轨迹,终态PEEQ中位值为2.308,属于主动施加的严苛累积塑性压力测试。
|
| 28 |
+
|
| 29 |
+
以481点轨迹为参考,配对路径的应力RMSE中位值分别为:61点2.641 MPa、
|
| 30 |
+
121点1.221 MPa、241点0.431 MPa。该结果说明时间步离散误差不可忽略,也使
|
| 31 |
+
数据能够区分模型误差和参考积分误差。
|
| 32 |
+
|
| 33 |
+
观测协议实际保留17.4%—73.6%的状态点,中位保留率43.1%;应变噪声相对RMSE
|
| 34 |
+
中位值为0.184%,应力噪声RMSE中位值为0.886 MPa。干净真值、带噪观测和掩码
|
| 35 |
+
同时保存,噪声副本不计作新的物理轨迹。
|
| 36 |
+
|
| 37 |
+
## 结构来源说明
|
| 38 |
+
|
| 39 |
+
结构路径来自两种孔径的中心孔板和两种缺口深度的双边缺口板。每个结构由
|
| 40 |
+
AgentFEM求解右侧拉伸、右侧剪切和顶部拉伸三个线弹性单位载荷工况,保留50个
|
| 41 |
+
DG0局部应变探针,再组合加载系数并通过隐藏参考材料回放。
|
| 42 |
+
|
| 43 |
+
这种方法提供有限元几何和边界条件产生的局部多轴路径,同时保持生成成本可控。
|
| 44 |
+
它是单向结构路径提取,不包含塑性变形引起的全局应力重分布,因此不能表述为
|
| 45 |
+
200个完整非线性结构有限元算例。
|
| 46 |
+
|
| 47 |
+
## 结论
|
| 48 |
+
|
| 49 |
+
本批数据通过完整性和材料积分物理门,并补齐长期状态、六分量加载、结构局部路径、
|
| 50 |
+
时间离散及不完整观测五类边界。它可直接作为独立测试协议,也可使用明确标记的
|
| 51 |
+
训练/验证子集扩展后续条件化DENIM;既有2,660条冻结协议和已发布模型成绩不改变。
|
artifacts/t2_denim_capability_v4/audit.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"case_id_unique": true,
|
| 3 |
+
"data_sha256_matches_manifest": true,
|
| 4 |
+
"grouped_resolution_protocol": true,
|
| 5 |
+
"hdf5_group_count": 1000,
|
| 6 |
+
"missing_required_fields": [],
|
| 7 |
+
"nonfinite_required_field_count": 0,
|
| 8 |
+
"passed": true,
|
| 9 |
+
"sample_count": 1000,
|
| 10 |
+
"structure_group_count": 4
|
| 11 |
+
}
|
artifacts/t2_denim_capability_v4/capability_extension_preview.png
ADDED
|
Git LFS Details
|
artifacts/t2_denim_capability_v4/capability_summary.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cohort_counts": {
|
| 3 |
+
"discretization_and_observation": 200,
|
| 4 |
+
"full_3d_nonproportional": 300,
|
| 5 |
+
"long_cycle": 300,
|
| 6 |
+
"structure_derived": 200
|
| 7 |
+
},
|
| 8 |
+
"full_3d_component_coverage": {
|
| 9 |
+
"all_six_components_active_fraction": 0.8333333333333334,
|
| 10 |
+
"median_active_voigt_components": 6.0,
|
| 11 |
+
"minimum_active_voigt_components": 3
|
| 12 |
+
},
|
| 13 |
+
"long_cycle_final_peeq": {
|
| 14 |
+
"test_long_cycle_ood": {
|
| 15 |
+
"count": 80,
|
| 16 |
+
"maximum": 5.581917596143634,
|
| 17 |
+
"median": 2.3076562056597267
|
| 18 |
+
},
|
| 19 |
+
"train_long_cycle": {
|
| 20 |
+
"count": 180,
|
| 21 |
+
"maximum": 1.4800164833029583,
|
| 22 |
+
"median": 0.32780349102780304
|
| 23 |
+
},
|
| 24 |
+
"validation_long_cycle": {
|
| 25 |
+
"count": 40,
|
| 26 |
+
"maximum": 2.9068227791273844,
|
| 27 |
+
"median": 1.2485704946120229
|
| 28 |
+
}
|
| 29 |
+
},
|
| 30 |
+
"matched_resolution_stress_rmse_mpa_against_481": {
|
| 31 |
+
"121": {
|
| 32 |
+
"maximum": 2.406609951745476,
|
| 33 |
+
"median": 1.2205367812383774
|
| 34 |
+
},
|
| 35 |
+
"241": {
|
| 36 |
+
"maximum": 0.8241333324801416,
|
| 37 |
+
"median": 0.4308617630836392
|
| 38 |
+
},
|
| 39 |
+
"481": {
|
| 40 |
+
"maximum": 0.0,
|
| 41 |
+
"median": 0.0
|
| 42 |
+
},
|
| 43 |
+
"61": {
|
| 44 |
+
"maximum": 9.097942729314207,
|
| 45 |
+
"median": 2.6405965053574985
|
| 46 |
+
}
|
| 47 |
+
},
|
| 48 |
+
"observation_protocol": {
|
| 49 |
+
"relative_strain_noise_rmse_median": 0.0018371038946513683,
|
| 50 |
+
"retained_fraction_maximum": 0.7355371900826446,
|
| 51 |
+
"retained_fraction_median": 0.43064366791262304,
|
| 52 |
+
"retained_fraction_minimum": 0.17427385892116182,
|
| 53 |
+
"stress_noise_rmse_mpa_median": 0.8856837636279857
|
| 54 |
+
},
|
| 55 |
+
"quality": {
|
| 56 |
+
"all_finite_failures": 0,
|
| 57 |
+
"maximum_plastic_strain_trace": 1.8431436932253575e-17,
|
| 58 |
+
"maximum_yield_surface_relative_residual": 9.34668949672154e-11,
|
| 59 |
+
"minimum_peeq_increment": 0.0,
|
| 60 |
+
"minimum_plastic_step_count": 35
|
| 61 |
+
},
|
| 62 |
+
"sample_count": 1000,
|
| 63 |
+
"schema": "agentfem.physics-data.denim-capability-extension.analysis",
|
| 64 |
+
"structure_derived": {
|
| 65 |
+
"central_hole_r018": {
|
| 66 |
+
"maximum_absolute_stress_mpa": 2306.726179813209,
|
| 67 |
+
"maximum_peeq": 0.06563635906127516,
|
| 68 |
+
"trajectory_count": 50
|
| 69 |
+
},
|
| 70 |
+
"central_hole_r026": {
|
| 71 |
+
"maximum_absolute_stress_mpa": 1988.2837702754796,
|
| 72 |
+
"maximum_peeq": 0.049314129288541834,
|
| 73 |
+
"trajectory_count": 50
|
| 74 |
+
},
|
| 75 |
+
"double_notch_r016": {
|
| 76 |
+
"maximum_absolute_stress_mpa": 2415.98591600656,
|
| 77 |
+
"maximum_peeq": 0.057808976722212205,
|
| 78 |
+
"trajectory_count": 50
|
| 79 |
+
},
|
| 80 |
+
"double_notch_r024": {
|
| 81 |
+
"maximum_absolute_stress_mpa": 2633.793143427893,
|
| 82 |
+
"maximum_peeq": 0.06691511987967692,
|
| 83 |
+
"trajectory_count": 50
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
}
|
artifacts/t2_denim_capability_v4/quality.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"agentfem_commit": "40c965225fc3b8d12a93a68e0d6b01dd35d47d82",
|
| 3 |
+
"cohort_counts": {
|
| 4 |
+
"discretization_and_observation": 200,
|
| 5 |
+
"full_3d_nonproportional": 300,
|
| 6 |
+
"long_cycle": 300,
|
| 7 |
+
"structure_derived": 200
|
| 8 |
+
},
|
| 9 |
+
"complete_release": true,
|
| 10 |
+
"counting_rule": "One sample is one complete trajectory. Observation noise/masks are fields, not extra samples. Matched resolutions are explicitly grouped.",
|
| 11 |
+
"data_bytes": 111577525,
|
| 12 |
+
"data_sha256": "d41b5f62b89f0bd5ad29b6682093add0eeaf0a30fbfd76d7e62f310c039c32f1",
|
| 13 |
+
"generation_seconds": 450.09614487504587,
|
| 14 |
+
"group_count": 654,
|
| 15 |
+
"index_csv_sha256": "49b454971df8f9b0d4f9311baad211d154240a2c7ced6c4cf6e98b893ca9cc2f",
|
| 16 |
+
"index_jsonl_sha256": "4a1f97a775d7168f068f2d6e5b21c27a0f1a872b5fe0de63b2f1ce71c713f972",
|
| 17 |
+
"path_family_counts": {
|
| 18 |
+
"biaxial_torsion_reversal": 50,
|
| 19 |
+
"fe_random_load_blocks": 40,
|
| 20 |
+
"fe_reversed_mixed_cycle": 40,
|
| 21 |
+
"fe_rotating_load_vector": 40,
|
| 22 |
+
"fe_tension_bending_sequence": 40,
|
| 23 |
+
"fe_tension_shear_lissajous": 40,
|
| 24 |
+
"hydro_deviatoric_sequence": 50,
|
| 25 |
+
"nonproportional_square": 99,
|
| 26 |
+
"orthogonal_cross": 24,
|
| 27 |
+
"out_of_phase_lissajous": 99,
|
| 28 |
+
"principal_axis_rotation_3d": 50,
|
| 29 |
+
"proportional_axial_cycle": 103,
|
| 30 |
+
"proportional_shear_cycle": 28,
|
| 31 |
+
"random_direction_blocks": 24,
|
| 32 |
+
"rotating_principal_cycle": 24,
|
| 33 |
+
"sequential_axial_shear": 99,
|
| 34 |
+
"six_component_random_blocks": 50,
|
| 35 |
+
"three_shear_rotation": 50,
|
| 36 |
+
"triaxial_phase_lissajous": 50
|
| 37 |
+
},
|
| 38 |
+
"point_count_distribution": {
|
| 39 |
+
"1001": 40,
|
| 40 |
+
"121": 50,
|
| 41 |
+
"2001": 80,
|
| 42 |
+
"201": 90,
|
| 43 |
+
"241": 550,
|
| 44 |
+
"481": 50,
|
| 45 |
+
"501": 90,
|
| 46 |
+
"61": 50
|
| 47 |
+
},
|
| 48 |
+
"quality": {
|
| 49 |
+
"all_finite_failures": 0,
|
| 50 |
+
"maximum_plastic_strain_trace": 1.8431436932253575e-17,
|
| 51 |
+
"maximum_yield_surface_relative_residual": 9.34668949672154e-11,
|
| 52 |
+
"minimum_peeq_increment": 0.0,
|
| 53 |
+
"minimum_plastic_step_count": 35
|
| 54 |
+
},
|
| 55 |
+
"reference_material": "hidden three-memory Chaboche with tabulated isotropic hardening",
|
| 56 |
+
"sample_count": 1000,
|
| 57 |
+
"schema": "agentfem.physics-data.denim-capability-extension",
|
| 58 |
+
"schema_version": "4.0.0",
|
| 59 |
+
"split_counts": {
|
| 60 |
+
"test_discretization_observation": 200,
|
| 61 |
+
"test_full_3d_ood": 100,
|
| 62 |
+
"test_long_cycle_ood": 80,
|
| 63 |
+
"test_structure_derived": 200,
|
| 64 |
+
"train_full_3d": 144,
|
| 65 |
+
"train_long_cycle": 180,
|
| 66 |
+
"validation_full_3d": 56,
|
| 67 |
+
"validation_long_cycle": 40
|
| 68 |
+
},
|
| 69 |
+
"structure_bases_sha256": "4f2f33836b38188f5f0d6c5a309b0764a3eaa1893b2a1b387e4ca56ced9ab9a9",
|
| 70 |
+
"structure_fidelity": "AgentFEM linear-elastic unit-load strain bases with one-way nonlinear material replay; no coupled elastoplastic redistribution claim"
|
| 71 |
+
}
|
configs/t2_denim_capability_v4.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "agentfem.physics-data.denim-capability-extension",
|
| 3 |
+
"schema_version": "4.0.0",
|
| 4 |
+
"seed": 20260925,
|
| 5 |
+
"sample_count": 1000,
|
| 6 |
+
"cohorts": {
|
| 7 |
+
"long_cycle": 300,
|
| 8 |
+
"full_3d_nonproportional": 300,
|
| 9 |
+
"structure_derived": 200,
|
| 10 |
+
"discretization_and_observation": 200
|
| 11 |
+
},
|
| 12 |
+
"long_cycle": {
|
| 13 |
+
"train": {"count": 180, "cycle_counts": [10, 25], "increments_per_cycle": 20},
|
| 14 |
+
"validation": {"count": 40, "cycle_counts": [50], "increments_per_cycle": 20},
|
| 15 |
+
"test": {"count": 80, "cycle_counts": [100], "increments_per_cycle": 20}
|
| 16 |
+
},
|
| 17 |
+
"full_3d_nonproportional": {
|
| 18 |
+
"points_per_trajectory": 241,
|
| 19 |
+
"families": [
|
| 20 |
+
"triaxial_phase_lissajous",
|
| 21 |
+
"principal_axis_rotation_3d",
|
| 22 |
+
"three_shear_rotation",
|
| 23 |
+
"hydro_deviatoric_sequence",
|
| 24 |
+
"six_component_random_blocks",
|
| 25 |
+
"biaxial_torsion_reversal"
|
| 26 |
+
],
|
| 27 |
+
"samples_per_family": 50
|
| 28 |
+
},
|
| 29 |
+
"structure_derived": {
|
| 30 |
+
"points_per_trajectory": 241,
|
| 31 |
+
"structures": [
|
| 32 |
+
{"name": "central_hole_r018", "kind": "central_hole", "radius": 0.18},
|
| 33 |
+
{"name": "central_hole_r026", "kind": "central_hole", "radius": 0.26},
|
| 34 |
+
{"name": "double_notch_r016", "kind": "double_edge_notch", "radius": 0.16},
|
| 35 |
+
{"name": "double_notch_r024", "kind": "double_edge_notch", "radius": 0.24}
|
| 36 |
+
],
|
| 37 |
+
"probe_trajectories_per_structure": 50,
|
| 38 |
+
"load_modes": ["right_tension", "right_shear", "top_tension"],
|
| 39 |
+
"source_model": "AgentFEM linear-elastic unit-load basis followed by nonlinear reference-material replay"
|
| 40 |
+
},
|
| 41 |
+
"discretization_and_observation": {
|
| 42 |
+
"matched_path_groups": 50,
|
| 43 |
+
"resolutions": [61, 121, 241, 481],
|
| 44 |
+
"strain_noise_fraction_range": [0.0005, 0.003],
|
| 45 |
+
"stress_noise_fraction_range": [0.0005, 0.005],
|
| 46 |
+
"observation_keep_fraction_range": [0.2, 0.65]
|
| 47 |
+
},
|
| 48 |
+
"scope": "Synthetic small-strain, rate-independent material histories from a fixed hidden three-memory tabulated-hardening reference. Structure-derived histories use AgentFEM linear-elastic unit-load bases and one-way constitutive replay; they are not coupled nonlinear structural solutions."
|
| 49 |
+
}
|
data/t2_denim_capability_v4/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DENIM Capability Extension v4
|
| 2 |
+
|
| 3 |
+
This increment adds 1,000 complete trajectories to the staged AgentFEM
|
| 4 |
+
Material Loading Memory dataset. It targets capability boundaries that were
|
| 5 |
+
underrepresented in the frozen 2,660-trajectory release.
|
| 6 |
+
|
| 7 |
+
## Cohorts
|
| 8 |
+
|
| 9 |
+
| Cohort | Trajectories | Purpose |
|
| 10 |
+
|---|---:|---|
|
| 11 |
+
| Long-cycle | 300 | 10, 25, 50 and held-out 100-cycle state evolution |
|
| 12 |
+
| Full 3D non-proportional | 300 | Six Voigt components, rotating axes, hydrostatic/deviatoric sequencing and random blocks |
|
| 13 |
+
| Structure-derived | 200 | Local histories from four AgentFEM perforated/notched plate unit-load bases |
|
| 14 |
+
| Discretization and observation | 200 | 50 paths at 61/121/241/481 states with clean truth plus noisy sparse observations |
|
| 15 |
+
|
| 16 |
+
One sample is one complete trajectory. Noise and observation masks are stored
|
| 17 |
+
as additional fields and are not counted as separate physical samples.
|
| 18 |
+
Matched time resolutions share an explicit `group_id` and must remain together
|
| 19 |
+
when constructing evaluation protocols.
|
| 20 |
+
|
| 21 |
+
## Structure-derived fidelity
|
| 22 |
+
|
| 23 |
+
AgentFEM solves three linear-elastic unit-load cases on each of four 2D
|
| 24 |
+
structures. Local DG0 strain bases are superposed under time-dependent load
|
| 25 |
+
coefficients and replayed through the hidden nonlinear reference material.
|
| 26 |
+
These are genuine finite-element-derived local path shapes, but they do not
|
| 27 |
+
include coupled elastoplastic stress redistribution. They are therefore a
|
| 28 |
+
bridge between hand-designed material-point paths and global nonlinear FEM,
|
| 29 |
+
not a substitute for the latter.
|
| 30 |
+
|
| 31 |
+
## Main files
|
| 32 |
+
|
| 33 |
+
- `cohort.h5`: lossless trajectories and provenance fields;
|
| 34 |
+
- `index.jsonl` and `index.csv`: viewer-friendly trajectory metadata;
|
| 35 |
+
- `manifest.json`: counts, hashes, physical quality gates and AgentFEM commit;
|
| 36 |
+
- `structure_bases.npz`: the four groups of AgentFEM local strain bases;
|
| 37 |
+
- `configs/t2_denim_capability_v4.json`: frozen design;
|
| 38 |
+
- `src/generate_t2_denim_capability_v4.py`: complete generator;
|
| 39 |
+
- `src/analyze_t2_denim_capability_v4.py`: paired-resolution and observation audit.
|
| 40 |
+
|
| 41 |
+
## Fields
|
| 42 |
+
|
| 43 |
+
Every trajectory contains tensor-shear Voigt arrays in the order
|
| 44 |
+
`xx, yy, zz, xy, yz, xz`: total strain, stress, plastic strain, two visible
|
| 45 |
+
memory channels, three reference memory channels, PEEQ, plastic increment,
|
| 46 |
+
isotropic radius and normalized history coordinate. Observation trajectories
|
| 47 |
+
also contain `observed_strain`, `observed_stress_pa`, and `observation_mask`.
|
| 48 |
+
Structure-derived trajectories additionally retain the source coordinate,
|
| 49 |
+
cell index, three local unit-load strain bases and load-mode coefficients.
|
| 50 |
+
|
| 51 |
+
## Scope
|
| 52 |
+
|
| 53 |
+
The data are synthetic, small-strain and rate-independent. The reference is a
|
| 54 |
+
fixed three-memory Chaboche-type material with tabulated isotropic hardening.
|
| 55 |
+
The release is not experimental calibration, fatigue-life data, damage data,
|
| 56 |
+
finite-strain plasticity, or a certified material card.
|
data/t2_denim_capability_v4/cohort.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d41b5f62b89f0bd5ad29b6682093add0eeaf0a30fbfd76d7e62f310c039c32f1
|
| 3 |
+
size 111577525
|
data/t2_denim_capability_v4/index.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/t2_denim_capability_v4/index.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/t2_denim_capability_v4/manifest.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"agentfem_commit": "40c965225fc3b8d12a93a68e0d6b01dd35d47d82",
|
| 3 |
+
"cohort_counts": {
|
| 4 |
+
"discretization_and_observation": 200,
|
| 5 |
+
"full_3d_nonproportional": 300,
|
| 6 |
+
"long_cycle": 300,
|
| 7 |
+
"structure_derived": 200
|
| 8 |
+
},
|
| 9 |
+
"complete_release": true,
|
| 10 |
+
"counting_rule": "One sample is one complete trajectory. Observation noise/masks are fields, not extra samples. Matched resolutions are explicitly grouped.",
|
| 11 |
+
"data_bytes": 111577525,
|
| 12 |
+
"data_sha256": "d41b5f62b89f0bd5ad29b6682093add0eeaf0a30fbfd76d7e62f310c039c32f1",
|
| 13 |
+
"generation_seconds": 450.09614487504587,
|
| 14 |
+
"group_count": 654,
|
| 15 |
+
"index_csv_sha256": "49b454971df8f9b0d4f9311baad211d154240a2c7ced6c4cf6e98b893ca9cc2f",
|
| 16 |
+
"index_jsonl_sha256": "4a1f97a775d7168f068f2d6e5b21c27a0f1a872b5fe0de63b2f1ce71c713f972",
|
| 17 |
+
"path_family_counts": {
|
| 18 |
+
"biaxial_torsion_reversal": 50,
|
| 19 |
+
"fe_random_load_blocks": 40,
|
| 20 |
+
"fe_reversed_mixed_cycle": 40,
|
| 21 |
+
"fe_rotating_load_vector": 40,
|
| 22 |
+
"fe_tension_bending_sequence": 40,
|
| 23 |
+
"fe_tension_shear_lissajous": 40,
|
| 24 |
+
"hydro_deviatoric_sequence": 50,
|
| 25 |
+
"nonproportional_square": 99,
|
| 26 |
+
"orthogonal_cross": 24,
|
| 27 |
+
"out_of_phase_lissajous": 99,
|
| 28 |
+
"principal_axis_rotation_3d": 50,
|
| 29 |
+
"proportional_axial_cycle": 103,
|
| 30 |
+
"proportional_shear_cycle": 28,
|
| 31 |
+
"random_direction_blocks": 24,
|
| 32 |
+
"rotating_principal_cycle": 24,
|
| 33 |
+
"sequential_axial_shear": 99,
|
| 34 |
+
"six_component_random_blocks": 50,
|
| 35 |
+
"three_shear_rotation": 50,
|
| 36 |
+
"triaxial_phase_lissajous": 50
|
| 37 |
+
},
|
| 38 |
+
"point_count_distribution": {
|
| 39 |
+
"1001": 40,
|
| 40 |
+
"121": 50,
|
| 41 |
+
"2001": 80,
|
| 42 |
+
"201": 90,
|
| 43 |
+
"241": 550,
|
| 44 |
+
"481": 50,
|
| 45 |
+
"501": 90,
|
| 46 |
+
"61": 50
|
| 47 |
+
},
|
| 48 |
+
"quality": {
|
| 49 |
+
"all_finite_failures": 0,
|
| 50 |
+
"maximum_plastic_strain_trace": 1.8431436932253575e-17,
|
| 51 |
+
"maximum_yield_surface_relative_residual": 9.34668949672154e-11,
|
| 52 |
+
"minimum_peeq_increment": 0.0,
|
| 53 |
+
"minimum_plastic_step_count": 35
|
| 54 |
+
},
|
| 55 |
+
"reference_material": "hidden three-memory Chaboche with tabulated isotropic hardening",
|
| 56 |
+
"sample_count": 1000,
|
| 57 |
+
"schema": "agentfem.physics-data.denim-capability-extension",
|
| 58 |
+
"schema_version": "4.0.0",
|
| 59 |
+
"split_counts": {
|
| 60 |
+
"test_discretization_observation": 200,
|
| 61 |
+
"test_full_3d_ood": 100,
|
| 62 |
+
"test_long_cycle_ood": 80,
|
| 63 |
+
"test_structure_derived": 200,
|
| 64 |
+
"train_full_3d": 144,
|
| 65 |
+
"train_long_cycle": 180,
|
| 66 |
+
"validation_full_3d": 56,
|
| 67 |
+
"validation_long_cycle": 40
|
| 68 |
+
},
|
| 69 |
+
"structure_bases_sha256": "4f2f33836b38188f5f0d6c5a309b0764a3eaa1893b2a1b387e4ca56ced9ab9a9",
|
| 70 |
+
"structure_fidelity": "AgentFEM linear-elastic unit-load strain bases with one-way nonlinear material replay; no coupled elastoplastic redistribution claim"
|
| 71 |
+
}
|
data/t2_denim_capability_v4/structure_bases.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4f2f33836b38188f5f0d6c5a309b0764a3eaa1893b2a1b387e4ca56ced9ab9a9
|
| 3 |
+
size 23114
|
docs/T2_DENIM_CAPABILITY_V4.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DENIM能力边界扩展v4
|
| 2 |
+
|
| 3 |
+
现有2,660条冻结数据已能支撑材料记忆、路径OOD、不完备物理闭合和少样本材料适配。
|
| 4 |
+
本次新增1,000条,目标从“增加同类曲线”转向补齐明确的工程边界。
|
| 5 |
+
|
| 6 |
+
| 新增队列 | 数量 | 核心价值 |
|
| 7 |
+
|---|---:|---|
|
| 8 |
+
| 长循环 | 300 | 训练10/25循环,验证50循环,冻结测试100循环 |
|
| 9 |
+
| 六分量非比例加载 | 300 | 主轴旋转、三剪切旋转、静水—偏应变切换和六分量随机块 |
|
| 10 |
+
| 结构来源路径 | 200 | 4个带孔/缺口几何的局部有限元应变路径 |
|
| 11 |
+
| 步长与观测鲁棒性 | 200 | 50条路径的4种积分分辨率,并保存带噪稀疏观测 |
|
| 12 |
+
|
| 13 |
+
数据总量由2,660条增至3,660条。原条件化DENIM v2的1,484/407/769角色继续冻结;
|
| 14 |
+
本批独立提供324条训练、96条验证和580条边界测试轨迹,后续模型升级应明确区分
|
| 15 |
+
“原协议成绩”和“吸收v4训练子集后的新协议成绩”。
|
| 16 |
+
|
| 17 |
+
本批最重要的新信息不是数量,而是:100循环的长期演化、六维路径几何、由结构
|
| 18 |
+
有限元产生的局部加载形状、积分步长误差以及现实观测中的噪声和缺失。结构来源
|
| 19 |
+
队列采用AgentFEM线弹性单位载荷基加非线性材料回放,未声称包含耦合塑性重分布。
|
| 20 |
+
|
| 21 |
+
机器证据:
|
| 22 |
+
|
| 23 |
+
- `data/t2_denim_capability_v4/manifest.json`
|
| 24 |
+
- `artifacts/t2_denim_capability_v4/quality.json`
|
| 25 |
+
- `artifacts/t2_denim_capability_v4/audit.json`
|
| 26 |
+
- `artifacts/t2_denim_capability_v4/capability_summary.json`
|
| 27 |
+
- `artifacts/t2_denim_capability_v4/capability_extension_preview.png`
|
src/analyze_t2_denim_capability_v4.py
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Analyze and visualize DENIM capability-extension v4 without model claims."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import json
|
| 6 |
+
from collections import defaultdict
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
import h5py
|
| 10 |
+
import matplotlib.pyplot as plt
|
| 11 |
+
import numpy as np
|
| 12 |
+
|
| 13 |
+
from src.generate_t2_denim_capability_v4 import (
|
| 14 |
+
ARTIFACT_DIR,
|
| 15 |
+
DATA_PATH,
|
| 16 |
+
INDEX_PATH,
|
| 17 |
+
MANIFEST_PATH,
|
| 18 |
+
_write_json,
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
ROOT = Path(__file__).resolve().parents[1]
|
| 23 |
+
SUMMARY_PATH = ARTIFACT_DIR / "capability_summary.json"
|
| 24 |
+
PREVIEW_PATH = ARTIFACT_DIR / "capability_extension_preview.png"
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def _rmse(left: np.ndarray, right: np.ndarray) -> float:
|
| 28 |
+
return float(np.sqrt(np.mean(np.square(np.asarray(left) - np.asarray(right)))))
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def analyze() -> dict[str, object]:
|
| 32 |
+
rows = [json.loads(line) for line in INDEX_PATH.read_text(encoding="utf-8").splitlines() if line]
|
| 33 |
+
manifest = json.loads(MANIFEST_PATH.read_text(encoding="utf-8"))
|
| 34 |
+
by_group: dict[str, list[tuple[int, dict[str, object]]]] = defaultdict(list)
|
| 35 |
+
for index, row in enumerate(rows):
|
| 36 |
+
by_group[str(row["group_id"])].append((index, row))
|
| 37 |
+
|
| 38 |
+
resolution_errors: dict[int, list[float]] = defaultdict(list)
|
| 39 |
+
active_components = []
|
| 40 |
+
observation_keep = []
|
| 41 |
+
strain_noise = []
|
| 42 |
+
stress_noise_mpa = []
|
| 43 |
+
structure_metrics: dict[str, dict[str, float | int]] = {}
|
| 44 |
+
long_metrics: dict[str, list[float]] = defaultdict(list)
|
| 45 |
+
|
| 46 |
+
with h5py.File(DATA_PATH, "r") as h5:
|
| 47 |
+
for group_id, members in by_group.items():
|
| 48 |
+
if not group_id.startswith("matched-resolution-"):
|
| 49 |
+
continue
|
| 50 |
+
reference_index, _ = next((item for item in members if int(item[1]["points"]) == 481))
|
| 51 |
+
reference = h5[f"{reference_index:05d}"]
|
| 52 |
+
reference_time = reference["time_coordinate"][...]
|
| 53 |
+
reference_stress = reference["stress_pa"][...]
|
| 54 |
+
for index, row in members:
|
| 55 |
+
points = int(row["points"])
|
| 56 |
+
group = h5[f"{index:05d}"]
|
| 57 |
+
time = group["time_coordinate"][...]
|
| 58 |
+
stress = group["stress_pa"][...]
|
| 59 |
+
interpolated = np.column_stack(
|
| 60 |
+
[np.interp(time, reference_time, reference_stress[:, component]) for component in range(6)]
|
| 61 |
+
)
|
| 62 |
+
resolution_errors[points].append(_rmse(stress, interpolated) / 1.0e6)
|
| 63 |
+
mask = group["observation_mask"][...].astype(bool)
|
| 64 |
+
observation_keep.append(float(mask.mean()))
|
| 65 |
+
strain_noise.append(
|
| 66 |
+
_rmse(group["observed_strain"][...], group["strain"][...])
|
| 67 |
+
/ max(float(np.max(np.abs(group["strain"][...]))), 1.0e-15)
|
| 68 |
+
)
|
| 69 |
+
stress_noise_mpa.append(
|
| 70 |
+
_rmse(group["observed_stress_pa"][...], group["stress_pa"][...]) / 1.0e6
|
| 71 |
+
)
|
| 72 |
+
|
| 73 |
+
for index, row in enumerate(rows):
|
| 74 |
+
group = h5[f"{index:05d}"]
|
| 75 |
+
cohort = str(row["cohort"])
|
| 76 |
+
if cohort == "full_3d_nonproportional":
|
| 77 |
+
strain = group["strain"][...]
|
| 78 |
+
maxima = np.max(np.abs(strain), axis=0)
|
| 79 |
+
threshold = 0.01 * max(float(maxima.max()), 1.0e-15)
|
| 80 |
+
active_components.append(int(np.count_nonzero(maxima > threshold)))
|
| 81 |
+
elif cohort == "structure_derived":
|
| 82 |
+
entry = structure_metrics.setdefault(
|
| 83 |
+
str(row["group_id"]),
|
| 84 |
+
{"trajectory_count": 0, "maximum_peeq": 0.0, "maximum_absolute_stress_mpa": 0.0},
|
| 85 |
+
)
|
| 86 |
+
entry["trajectory_count"] = int(entry["trajectory_count"]) + 1
|
| 87 |
+
entry["maximum_peeq"] = max(float(entry["maximum_peeq"]), float(np.max(group["peeq"][...])))
|
| 88 |
+
entry["maximum_absolute_stress_mpa"] = max(
|
| 89 |
+
float(entry["maximum_absolute_stress_mpa"]),
|
| 90 |
+
float(np.max(np.abs(group["stress_pa"][...]))) / 1.0e6,
|
| 91 |
+
)
|
| 92 |
+
elif cohort == "long_cycle":
|
| 93 |
+
long_metrics[str(row["split"])].append(float(group["peeq"][-1]))
|
| 94 |
+
|
| 95 |
+
summary: dict[str, object] = {
|
| 96 |
+
"schema": "agentfem.physics-data.denim-capability-extension.analysis",
|
| 97 |
+
"sample_count": len(rows),
|
| 98 |
+
"cohort_counts": manifest["cohort_counts"],
|
| 99 |
+
"quality": manifest["quality"],
|
| 100 |
+
"long_cycle_final_peeq": {
|
| 101 |
+
split: {
|
| 102 |
+
"count": len(values),
|
| 103 |
+
"median": float(np.median(values)),
|
| 104 |
+
"maximum": float(np.max(values)),
|
| 105 |
+
}
|
| 106 |
+
for split, values in sorted(long_metrics.items())
|
| 107 |
+
},
|
| 108 |
+
"full_3d_component_coverage": {
|
| 109 |
+
"minimum_active_voigt_components": int(min(active_components)),
|
| 110 |
+
"median_active_voigt_components": float(np.median(active_components)),
|
| 111 |
+
"all_six_components_active_fraction": float(np.mean(np.asarray(active_components) == 6)),
|
| 112 |
+
},
|
| 113 |
+
"structure_derived": structure_metrics,
|
| 114 |
+
"matched_resolution_stress_rmse_mpa_against_481": {
|
| 115 |
+
str(points): {
|
| 116 |
+
"median": float(np.median(values)),
|
| 117 |
+
"maximum": float(np.max(values)),
|
| 118 |
+
}
|
| 119 |
+
for points, values in sorted(resolution_errors.items())
|
| 120 |
+
},
|
| 121 |
+
"observation_protocol": {
|
| 122 |
+
"retained_fraction_minimum": float(np.min(observation_keep)),
|
| 123 |
+
"retained_fraction_median": float(np.median(observation_keep)),
|
| 124 |
+
"retained_fraction_maximum": float(np.max(observation_keep)),
|
| 125 |
+
"relative_strain_noise_rmse_median": float(np.median(strain_noise)),
|
| 126 |
+
"stress_noise_rmse_mpa_median": float(np.median(stress_noise_mpa)),
|
| 127 |
+
},
|
| 128 |
+
}
|
| 129 |
+
_write_json(SUMMARY_PATH, summary)
|
| 130 |
+
return summary
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def plot() -> Path:
|
| 134 |
+
ARTIFACT_DIR.mkdir(parents=True, exist_ok=True)
|
| 135 |
+
with h5py.File(DATA_PATH, "r") as h5:
|
| 136 |
+
long = h5["00299"]
|
| 137 |
+
full3d = h5["00300"]
|
| 138 |
+
structural = h5["00600"]
|
| 139 |
+
observed = h5["00801"]
|
| 140 |
+
|
| 141 |
+
figure, axes = plt.subplots(2, 2, figsize=(13.0, 8.2), constrained_layout=True)
|
| 142 |
+
|
| 143 |
+
axes[0, 0].plot(long["time_coordinate"][...], long["stress_pa"][:, 0] / 1.0e6, lw=1.0, color="#1f6feb")
|
| 144 |
+
axes[0, 0].set_title("100-cycle long-horizon response")
|
| 145 |
+
axes[0, 0].set_xlabel("normalized history coordinate")
|
| 146 |
+
axes[0, 0].set_ylabel(r"$\sigma_{xx}$ (MPa)")
|
| 147 |
+
|
| 148 |
+
strain = full3d["strain"][...]
|
| 149 |
+
labels = ("xx", "yy", "zz", "xy", "yz", "xz")
|
| 150 |
+
for component, label in enumerate(labels):
|
| 151 |
+
axes[0, 1].plot(full3d["time_coordinate"][...], 100.0 * strain[:, component], lw=1.1, label=label)
|
| 152 |
+
axes[0, 1].set_title("Full six-component non-proportional path")
|
| 153 |
+
axes[0, 1].set_xlabel("normalized history coordinate")
|
| 154 |
+
axes[0, 1].set_ylabel("tensor strain (%)")
|
| 155 |
+
axes[0, 1].legend(ncol=3, fontsize=8, frameon=False)
|
| 156 |
+
|
| 157 |
+
axes[1, 0].plot(100.0 * structural["strain"][:, 0], structural["stress_pa"][:, 0] / 1.0e6, lw=1.5, color="#d97706")
|
| 158 |
+
axes[1, 0].set_title("AgentFEM-derived local structural path")
|
| 159 |
+
axes[1, 0].set_xlabel(r"$\varepsilon_{xx}$ (%)")
|
| 160 |
+
axes[1, 0].set_ylabel(r"$\sigma_{xx}$ (MPa)")
|
| 161 |
+
|
| 162 |
+
time = observed["time_coordinate"][...]
|
| 163 |
+
mask = observed["observation_mask"][...].astype(bool)
|
| 164 |
+
axes[1, 1].plot(time, observed["stress_pa"][:, 0] / 1.0e6, lw=1.5, color="#22c55e", label="clean truth")
|
| 165 |
+
axes[1, 1].scatter(
|
| 166 |
+
time[mask], observed["observed_stress_pa"][mask, 0] / 1.0e6,
|
| 167 |
+
s=10, alpha=0.65, color="#ef4444", label="noisy sparse observation",
|
| 168 |
+
)
|
| 169 |
+
axes[1, 1].set_title("Paired observation robustness protocol")
|
| 170 |
+
axes[1, 1].set_xlabel("normalized history coordinate")
|
| 171 |
+
axes[1, 1].set_ylabel(r"$\sigma_{xx}$ (MPa)")
|
| 172 |
+
axes[1, 1].legend(frameon=False, fontsize=8)
|
| 173 |
+
|
| 174 |
+
for axis in axes.ravel():
|
| 175 |
+
axis.grid(alpha=0.20)
|
| 176 |
+
figure.suptitle("AgentFEM DENIM capability extension v4", fontsize=16, fontweight="bold")
|
| 177 |
+
figure.savefig(PREVIEW_PATH, dpi=180)
|
| 178 |
+
plt.close(figure)
|
| 179 |
+
return PREVIEW_PATH
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
if __name__ == "__main__":
|
| 183 |
+
print(json.dumps(analyze(), indent=2, sort_keys=True))
|
| 184 |
+
print(plot())
|
src/generate_t2_denim_capability_v4.py
ADDED
|
@@ -0,0 +1,824 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Generate the 1,000-trajectory DENIM capability extension v4.
|
| 2 |
+
|
| 3 |
+
The extension targets four gaps left by the frozen 2,660-trajectory release:
|
| 4 |
+
long-cycle state drift, full six-component loading, finite-element-derived local
|
| 5 |
+
paths, and paired time-discretization/observation robustness. Existing data
|
| 6 |
+
and splits are never overwritten. One sample remains one complete history.
|
| 7 |
+
|
| 8 |
+
The structure-derived cohort is deliberately explicit about its fidelity: an
|
| 9 |
+
AgentFEM linear-elastic solve supplies three local unit-load strain bases for
|
| 10 |
+
four perforated/notched plates. Time-dependent load coefficients are then
|
| 11 |
+
superposed and replayed through the same nonlinear hidden reference material
|
| 12 |
+
used by the DENIM closure study. This produces genuine FE-derived local path
|
| 13 |
+
shapes without claiming fully coupled elastoplastic redistribution.
|
| 14 |
+
"""
|
| 15 |
+
|
| 16 |
+
from __future__ import annotations
|
| 17 |
+
|
| 18 |
+
import argparse
|
| 19 |
+
import csv
|
| 20 |
+
import hashlib
|
| 21 |
+
import json
|
| 22 |
+
import math
|
| 23 |
+
import os
|
| 24 |
+
import subprocess
|
| 25 |
+
import time
|
| 26 |
+
from collections import Counter
|
| 27 |
+
from pathlib import Path
|
| 28 |
+
from typing import Iterable
|
| 29 |
+
|
| 30 |
+
import h5py
|
| 31 |
+
import numpy as np
|
| 32 |
+
|
| 33 |
+
from src.generate_t2_denim_boundary_v1 import quality as boundary_quality
|
| 34 |
+
from src.generate_t2_graybox_closure import MATERIAL, material
|
| 35 |
+
from src.t2_multiaxial_ood_v2 import PATH_FAMILIES, strain_history, tensor_to_voigt
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
ROOT = Path(__file__).resolve().parents[1]
|
| 39 |
+
CONFIG_PATH = ROOT / "configs" / "t2_denim_capability_v4.json"
|
| 40 |
+
DATA_DIR = ROOT / "data" / "t2_denim_capability_v4"
|
| 41 |
+
DATA_PATH = DATA_DIR / "cohort.h5"
|
| 42 |
+
INDEX_PATH = DATA_DIR / "index.jsonl"
|
| 43 |
+
INDEX_CSV_PATH = DATA_DIR / "index.csv"
|
| 44 |
+
MANIFEST_PATH = DATA_DIR / "manifest.json"
|
| 45 |
+
STRUCTURE_BASIS_PATH = DATA_DIR / "structure_bases.npz"
|
| 46 |
+
ARTIFACT_DIR = ROOT / "artifacts" / "t2_denim_capability_v4"
|
| 47 |
+
AGENTFEM_ROOT = Path("/Users/luo/Desktop/开发环境/fenicsx-code/agentfem")
|
| 48 |
+
|
| 49 |
+
FULL_3D_FAMILIES = (
|
| 50 |
+
"triaxial_phase_lissajous",
|
| 51 |
+
"principal_axis_rotation_3d",
|
| 52 |
+
"three_shear_rotation",
|
| 53 |
+
"hydro_deviatoric_sequence",
|
| 54 |
+
"six_component_random_blocks",
|
| 55 |
+
"biaxial_torsion_reversal",
|
| 56 |
+
)
|
| 57 |
+
RESOLUTIONS = (61, 121, 241, 481)
|
| 58 |
+
STRUCTURE_SPECS = (
|
| 59 |
+
("central_hole_r018", "central_hole", 0.18),
|
| 60 |
+
("central_hole_r026", "central_hole", 0.26),
|
| 61 |
+
("double_notch_r016", "double_edge_notch", 0.16),
|
| 62 |
+
("double_notch_r024", "double_edge_notch", 0.24),
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def load_config() -> dict[str, object]:
|
| 67 |
+
return json.loads(CONFIG_PATH.read_text(encoding="utf-8"))
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
def _sha256(path: Path) -> str:
|
| 71 |
+
digest = hashlib.sha256()
|
| 72 |
+
with path.open("rb") as handle:
|
| 73 |
+
for block in iter(lambda: handle.read(1024 * 1024), b""):
|
| 74 |
+
digest.update(block)
|
| 75 |
+
return digest.hexdigest()
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def _write_json(path: Path, value: object) -> None:
|
| 79 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 80 |
+
temporary = path.with_suffix(path.suffix + ".tmp")
|
| 81 |
+
temporary.write_text(json.dumps(value, indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
| 82 |
+
os.replace(temporary, path)
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def _polyline(anchors: np.ndarray, count: int) -> np.ndarray:
|
| 86 |
+
anchors = np.asarray(anchors, dtype=float)
|
| 87 |
+
distances = np.linalg.norm(np.diff(anchors, axis=0), axis=1)
|
| 88 |
+
cumulative = np.concatenate(([0.0], np.cumsum(distances)))
|
| 89 |
+
if cumulative[-1] <= 0.0:
|
| 90 |
+
return np.repeat(anchors[:1], count, axis=0)
|
| 91 |
+
target = np.linspace(0.0, cumulative[-1], count)
|
| 92 |
+
return np.column_stack(
|
| 93 |
+
[np.interp(target, cumulative, anchors[:, column]) for column in range(anchors.shape[1])]
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def _symmetric_from_voigt(values: np.ndarray) -> np.ndarray:
|
| 98 |
+
selected = np.asarray(values, dtype=float)
|
| 99 |
+
tensor = np.zeros((*selected.shape[:-1], 3, 3), dtype=float)
|
| 100 |
+
tensor[..., 0, 0] = selected[..., 0]
|
| 101 |
+
tensor[..., 1, 1] = selected[..., 1]
|
| 102 |
+
tensor[..., 2, 2] = selected[..., 2]
|
| 103 |
+
tensor[..., 0, 1] = tensor[..., 1, 0] = selected[..., 3]
|
| 104 |
+
tensor[..., 1, 2] = tensor[..., 2, 1] = selected[..., 4]
|
| 105 |
+
tensor[..., 0, 2] = tensor[..., 2, 0] = selected[..., 5]
|
| 106 |
+
return tensor
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def _equivalent_strain(strains: np.ndarray) -> np.ndarray:
|
| 110 |
+
selected = np.asarray(strains, dtype=float)
|
| 111 |
+
trace = np.trace(selected, axis1=-2, axis2=-1)[..., None, None]
|
| 112 |
+
dev = selected - trace / 3.0 * np.eye(3)
|
| 113 |
+
return np.sqrt(np.maximum(2.0 / 3.0 * np.sum(dev * dev, axis=(-2, -1)), 0.0))
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
def _scale_history(strains: np.ndarray, amplitude: float) -> np.ndarray:
|
| 117 |
+
selected = np.asarray(strains, dtype=float)
|
| 118 |
+
selected = 0.5 * (selected + np.swapaxes(selected, -1, -2))
|
| 119 |
+
scale = float(np.max(_equivalent_strain(selected)))
|
| 120 |
+
if scale <= np.finfo(float).eps:
|
| 121 |
+
raise ValueError("History has zero equivalent-strain amplitude.")
|
| 122 |
+
return selected * (float(amplitude) / scale)
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
def _base_parameters(
|
| 126 |
+
*, index: int, family: str, amplitude: float, seed: int, points: int
|
| 127 |
+
) -> dict[str, object]:
|
| 128 |
+
rng = np.random.default_rng(seed)
|
| 129 |
+
return {
|
| 130 |
+
**MATERIAL,
|
| 131 |
+
"case_id": f"denim-capability-v4-{index:05d}",
|
| 132 |
+
"material_model": "hidden_three_memory_tabulated_hardening",
|
| 133 |
+
"path_family": family,
|
| 134 |
+
"path_seed": int(seed),
|
| 135 |
+
"path_shape_a": float(rng.random()),
|
| 136 |
+
"path_shape_b": float(rng.random()),
|
| 137 |
+
"path_shape_c": float(rng.random()),
|
| 138 |
+
"yield_design_coordinate": float(rng.random()),
|
| 139 |
+
"maximum_equivalent_strain": float(amplitude),
|
| 140 |
+
"points": int(points),
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
def design(seed: int = 20260925) -> list[dict[str, object]]:
|
| 145 |
+
"""Create exactly 1,000 deterministic records with frozen cohort roles."""
|
| 146 |
+
|
| 147 |
+
rng = np.random.default_rng(seed)
|
| 148 |
+
rows: list[dict[str, object]] = []
|
| 149 |
+
|
| 150 |
+
# 300 long-cycle histories. Training sees 10/25 cycles, validation 50,
|
| 151 |
+
# and the frozen test remains a true 100-cycle horizon extrapolation.
|
| 152 |
+
long_roles = (
|
| 153 |
+
(180, "train_long_cycle", (10, 25)),
|
| 154 |
+
(40, "validation_long_cycle", (50,)),
|
| 155 |
+
(80, "test_long_cycle_ood", (100,)),
|
| 156 |
+
)
|
| 157 |
+
for count, split, cycle_options in long_roles:
|
| 158 |
+
for local in range(count):
|
| 159 |
+
cycles = int(cycle_options[local % len(cycle_options)])
|
| 160 |
+
points = cycles * 20 + 1
|
| 161 |
+
family = PATH_FAMILIES[(len(rows) + local) % len(PATH_FAMILIES)]
|
| 162 |
+
row = _base_parameters(
|
| 163 |
+
index=len(rows),
|
| 164 |
+
family=family,
|
| 165 |
+
amplitude=float(rng.uniform(0.003, 0.010)),
|
| 166 |
+
seed=int(seed + len(rows) * 104729),
|
| 167 |
+
points=points,
|
| 168 |
+
)
|
| 169 |
+
row.update(
|
| 170 |
+
cohort="long_cycle",
|
| 171 |
+
split=split,
|
| 172 |
+
group_id=row["case_id"],
|
| 173 |
+
cycle_count=cycles,
|
| 174 |
+
increments_per_cycle=20,
|
| 175 |
+
observation_protocol="clean",
|
| 176 |
+
)
|
| 177 |
+
rows.append(row)
|
| 178 |
+
|
| 179 |
+
# 300 full six-component histories. Four families are available to train,
|
| 180 |
+
# principal-axis rotation validates, and random six-component blocks are
|
| 181 |
+
# held out as a shape-OOD family.
|
| 182 |
+
for family in FULL_3D_FAMILIES:
|
| 183 |
+
for local in range(50):
|
| 184 |
+
if family in FULL_3D_FAMILIES[:4]:
|
| 185 |
+
split = "train_full_3d" if local < 36 else "validation_full_3d"
|
| 186 |
+
elif family == "principal_axis_rotation_3d":
|
| 187 |
+
split = "validation_full_3d"
|
| 188 |
+
else:
|
| 189 |
+
split = "test_full_3d_ood"
|
| 190 |
+
row = _base_parameters(
|
| 191 |
+
index=len(rows),
|
| 192 |
+
family=family,
|
| 193 |
+
amplitude=float(rng.uniform(0.003, 0.014)),
|
| 194 |
+
seed=int(seed + len(rows) * 130363),
|
| 195 |
+
points=241,
|
| 196 |
+
)
|
| 197 |
+
row.update(
|
| 198 |
+
cohort="full_3d_nonproportional",
|
| 199 |
+
split=split,
|
| 200 |
+
group_id=row["case_id"],
|
| 201 |
+
cycle_count=1,
|
| 202 |
+
observation_protocol="clean",
|
| 203 |
+
)
|
| 204 |
+
rows.append(row)
|
| 205 |
+
|
| 206 |
+
# 200 structure-derived probe histories, 50 from each FE source group.
|
| 207 |
+
for structure_name, structure_kind, radius in STRUCTURE_SPECS:
|
| 208 |
+
for probe_index in range(50):
|
| 209 |
+
family = (
|
| 210 |
+
"fe_tension_shear_lissajous",
|
| 211 |
+
"fe_tension_bending_sequence",
|
| 212 |
+
"fe_reversed_mixed_cycle",
|
| 213 |
+
"fe_random_load_blocks",
|
| 214 |
+
"fe_rotating_load_vector",
|
| 215 |
+
)[probe_index % 5]
|
| 216 |
+
row = _base_parameters(
|
| 217 |
+
index=len(rows),
|
| 218 |
+
family=family,
|
| 219 |
+
amplitude=float(rng.uniform(0.003, 0.012)),
|
| 220 |
+
seed=int(seed + len(rows) * 15485863),
|
| 221 |
+
points=241,
|
| 222 |
+
)
|
| 223 |
+
row.update(
|
| 224 |
+
cohort="structure_derived",
|
| 225 |
+
split="test_structure_derived",
|
| 226 |
+
group_id=structure_name,
|
| 227 |
+
structure_name=structure_name,
|
| 228 |
+
structure_kind=structure_kind,
|
| 229 |
+
structure_radius=float(radius),
|
| 230 |
+
probe_index=int(probe_index),
|
| 231 |
+
cycle_count=1,
|
| 232 |
+
observation_protocol="clean",
|
| 233 |
+
)
|
| 234 |
+
rows.append(row)
|
| 235 |
+
|
| 236 |
+
# 50 unique continuous paths at four matched resolutions = 200 records.
|
| 237 |
+
# Noise and sparse observation masks are fields, not extra fake samples.
|
| 238 |
+
for matched_index in range(50):
|
| 239 |
+
family = PATH_FAMILIES[matched_index % len(PATH_FAMILIES)]
|
| 240 |
+
shared_seed = int(seed + 900_000 + matched_index * 32452843)
|
| 241 |
+
shared_rng = np.random.default_rng(shared_seed)
|
| 242 |
+
amplitude = float(shared_rng.uniform(0.003, 0.012))
|
| 243 |
+
shared_shapes = shared_rng.random(3)
|
| 244 |
+
for points in RESOLUTIONS:
|
| 245 |
+
row = _base_parameters(
|
| 246 |
+
index=len(rows),
|
| 247 |
+
family=family,
|
| 248 |
+
amplitude=amplitude,
|
| 249 |
+
seed=shared_seed,
|
| 250 |
+
points=points,
|
| 251 |
+
)
|
| 252 |
+
row["path_shape_a"], row["path_shape_b"], row["path_shape_c"] = (
|
| 253 |
+
float(value) for value in shared_shapes
|
| 254 |
+
)
|
| 255 |
+
row.update(
|
| 256 |
+
cohort="discretization_and_observation",
|
| 257 |
+
split="test_discretization_observation",
|
| 258 |
+
group_id=f"matched-resolution-{matched_index:03d}",
|
| 259 |
+
matched_path_id=f"matched-resolution-{matched_index:03d}",
|
| 260 |
+
cycle_count=1,
|
| 261 |
+
observation_protocol="noisy_sparse_paired",
|
| 262 |
+
strain_noise_fraction=float(shared_rng.uniform(0.0005, 0.0030)),
|
| 263 |
+
stress_noise_fraction=float(shared_rng.uniform(0.0005, 0.0050)),
|
| 264 |
+
observation_keep_fraction=float(shared_rng.uniform(0.20, 0.65)),
|
| 265 |
+
)
|
| 266 |
+
rows.append(row)
|
| 267 |
+
|
| 268 |
+
if len(rows) != 1000:
|
| 269 |
+
raise RuntimeError(f"Capability extension must contain 1,000 rows, got {len(rows)}.")
|
| 270 |
+
if len({str(row["case_id"]) for row in rows}) != len(rows):
|
| 271 |
+
raise RuntimeError("Case IDs are not unique.")
|
| 272 |
+
return rows
|
| 273 |
+
|
| 274 |
+
|
| 275 |
+
def _long_cycle_history(row: dict[str, object]) -> np.ndarray:
|
| 276 |
+
cycles = int(row["cycle_count"])
|
| 277 |
+
per_cycle = int(row["increments_per_cycle"]) + 1
|
| 278 |
+
_, one_cycle = strain_history(row, points=per_cycle)
|
| 279 |
+
pieces = [one_cycle]
|
| 280 |
+
pieces.extend(one_cycle[1:] for _ in range(cycles - 1))
|
| 281 |
+
history = np.concatenate(pieces, axis=0)
|
| 282 |
+
if len(history) != int(row["points"]):
|
| 283 |
+
raise RuntimeError("Long-cycle path length does not match the design.")
|
| 284 |
+
return history
|
| 285 |
+
|
| 286 |
+
|
| 287 |
+
def _rotation(axis: np.ndarray, angle: np.ndarray) -> np.ndarray:
|
| 288 |
+
axis = np.asarray(axis, dtype=float)
|
| 289 |
+
axis /= np.linalg.norm(axis)
|
| 290 |
+
cross = np.asarray(
|
| 291 |
+
((0.0, -axis[2], axis[1]), (axis[2], 0.0, -axis[0]), (-axis[1], axis[0], 0.0))
|
| 292 |
+
)
|
| 293 |
+
outer = np.outer(axis, axis)
|
| 294 |
+
rotations = []
|
| 295 |
+
for value in np.asarray(angle, dtype=float):
|
| 296 |
+
rotations.append(
|
| 297 |
+
np.cos(value) * np.eye(3)
|
| 298 |
+
+ (1.0 - np.cos(value)) * outer
|
| 299 |
+
+ np.sin(value) * cross
|
| 300 |
+
)
|
| 301 |
+
return np.asarray(rotations)
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
def _full_3d_history(row: dict[str, object]) -> np.ndarray:
|
| 305 |
+
count = int(row["points"])
|
| 306 |
+
time_coordinate = np.linspace(0.0, 1.0, count)
|
| 307 |
+
phase = 2.0 * np.pi * time_coordinate
|
| 308 |
+
family = str(row["path_family"])
|
| 309 |
+
a = float(row["path_shape_a"])
|
| 310 |
+
b = float(row["path_shape_b"])
|
| 311 |
+
c = float(row["path_shape_c"])
|
| 312 |
+
rng = np.random.default_rng(int(row["path_seed"]))
|
| 313 |
+
|
| 314 |
+
if family == "triaxial_phase_lissajous":
|
| 315 |
+
values = np.column_stack(
|
| 316 |
+
(
|
| 317 |
+
np.sin(phase),
|
| 318 |
+
0.75 * np.sin(2.0 * phase + 0.3 + a),
|
| 319 |
+
0.55 * np.sin(3.0 * phase + 0.7 + b),
|
| 320 |
+
0.45 * np.sin(phase + np.pi / 3.0),
|
| 321 |
+
0.35 * np.sin(2.0 * phase + np.pi / 5.0),
|
| 322 |
+
0.30 * np.sin(3.0 * phase + np.pi / 7.0),
|
| 323 |
+
)
|
| 324 |
+
)
|
| 325 |
+
return _scale_history(_symmetric_from_voigt(values), float(row["maximum_equivalent_strain"]))
|
| 326 |
+
|
| 327 |
+
if family == "principal_axis_rotation_3d":
|
| 328 |
+
principal = np.column_stack(
|
| 329 |
+
(
|
| 330 |
+
np.sin(phase),
|
| 331 |
+
-0.55 * np.sin(phase),
|
| 332 |
+
-0.45 * np.sin(phase),
|
| 333 |
+
)
|
| 334 |
+
)
|
| 335 |
+
rotations = _rotation(np.asarray((1.0, 1.0 + a, 0.5 + b)), 2.0 * phase)
|
| 336 |
+
diagonal = np.asarray([np.diag(value) for value in principal])
|
| 337 |
+
tensors = np.einsum("nij,njk,nlk->nil", rotations, diagonal, rotations)
|
| 338 |
+
return _scale_history(tensors, float(row["maximum_equivalent_strain"]))
|
| 339 |
+
|
| 340 |
+
if family == "three_shear_rotation":
|
| 341 |
+
values = np.column_stack(
|
| 342 |
+
(
|
| 343 |
+
np.zeros(count),
|
| 344 |
+
np.zeros(count),
|
| 345 |
+
np.zeros(count),
|
| 346 |
+
np.sin(phase),
|
| 347 |
+
np.sin(phase + 2.0 * np.pi / 3.0),
|
| 348 |
+
np.sin(phase + 4.0 * np.pi / 3.0),
|
| 349 |
+
)
|
| 350 |
+
)
|
| 351 |
+
return _scale_history(_symmetric_from_voigt(values), float(row["maximum_equivalent_strain"]))
|
| 352 |
+
|
| 353 |
+
if family == "hydro_deviatoric_sequence":
|
| 354 |
+
amplitude = 0.6 + 0.4 * a
|
| 355 |
+
anchors = np.asarray(
|
| 356 |
+
(
|
| 357 |
+
(0, 0, 0, 0, 0, 0),
|
| 358 |
+
(1, 1, 1, 0, 0, 0),
|
| 359 |
+
(1 + amplitude, 1 - amplitude, 1, 0, 0, 0),
|
| 360 |
+
(-0.7, -0.7, -0.7, 0.6, 0, 0),
|
| 361 |
+
(0.8, -0.4, -0.4, 0, 0.55, 0.35),
|
| 362 |
+
(0, 0, 0, 0, 0, 0),
|
| 363 |
+
),
|
| 364 |
+
dtype=float,
|
| 365 |
+
)
|
| 366 |
+
return _scale_history(_symmetric_from_voigt(_polyline(anchors, count)), float(row["maximum_equivalent_strain"]))
|
| 367 |
+
|
| 368 |
+
if family == "six_component_random_blocks":
|
| 369 |
+
directions = rng.normal(size=(9, 6))
|
| 370 |
+
directions /= np.linalg.norm(directions, axis=1, keepdims=True)
|
| 371 |
+
directions[1::2] *= -1.0
|
| 372 |
+
directions[:, :3] += 0.15 * rng.normal(size=(9, 1))
|
| 373 |
+
anchors = np.vstack((np.zeros(6), directions, np.zeros(6)))
|
| 374 |
+
return _scale_history(_symmetric_from_voigt(_polyline(anchors, count)), float(row["maximum_equivalent_strain"]))
|
| 375 |
+
|
| 376 |
+
if family == "biaxial_torsion_reversal":
|
| 377 |
+
ratio = 0.4 + 0.4 * c
|
| 378 |
+
anchors = np.asarray(
|
| 379 |
+
(
|
| 380 |
+
(0, 0, 0, 0, 0, 0),
|
| 381 |
+
(1, -0.4, 0, ratio, 0, 0),
|
| 382 |
+
(-0.8, 0.5, 0, ratio, 0.5, 0),
|
| 383 |
+
(0.6, 0.2, -0.5, -ratio, 0, 0.45),
|
| 384 |
+
(-0.5, -0.3, 0.4, 0, -0.55, -0.25),
|
| 385 |
+
(0, 0, 0, 0, 0, 0),
|
| 386 |
+
),
|
| 387 |
+
dtype=float,
|
| 388 |
+
)
|
| 389 |
+
return _scale_history(_symmetric_from_voigt(_polyline(anchors, count)), float(row["maximum_equivalent_strain"]))
|
| 390 |
+
|
| 391 |
+
raise ValueError(f"Unknown full-3D family: {family}")
|
| 392 |
+
|
| 393 |
+
|
| 394 |
+
def _load_coefficients(row: dict[str, object]) -> np.ndarray:
|
| 395 |
+
count = int(row["points"])
|
| 396 |
+
t = np.linspace(0.0, 1.0, count)
|
| 397 |
+
phase = 2.0 * np.pi * t
|
| 398 |
+
family = str(row["path_family"])
|
| 399 |
+
rng = np.random.default_rng(int(row["path_seed"]))
|
| 400 |
+
if family == "fe_tension_shear_lissajous":
|
| 401 |
+
return np.column_stack((np.sin(phase), 0.75 * np.sin(2.0 * phase + 0.4), 0.35 * np.sin(phase + 1.1)))
|
| 402 |
+
if family == "fe_tension_bending_sequence":
|
| 403 |
+
return _polyline(np.asarray(((0, 0, 0), (1, 0, 0), (0.6, 0, 0.8), (-0.5, 0.7, 0.6), (0, 0, 0))), count)
|
| 404 |
+
if family == "fe_reversed_mixed_cycle":
|
| 405 |
+
return _polyline(np.asarray(((0, 0, 0), (1, 0.4, 0), (-0.8, 0.4, 0.5), (0.7, -0.6, -0.4), (-0.4, 0.3, 0.7), (0, 0, 0))), count)
|
| 406 |
+
if family == "fe_random_load_blocks":
|
| 407 |
+
anchors = rng.normal(size=(8, 3))
|
| 408 |
+
anchors /= np.maximum(np.linalg.norm(anchors, axis=1, keepdims=True), 1.0e-15)
|
| 409 |
+
anchors[1::2] *= -1.0
|
| 410 |
+
return _polyline(np.vstack((np.zeros(3), anchors, np.zeros(3))), count)
|
| 411 |
+
if family == "fe_rotating_load_vector":
|
| 412 |
+
return np.column_stack((np.sin(phase), np.cos(phase) - 1.0, 0.6 * np.sin(2.0 * phase)))
|
| 413 |
+
raise ValueError(f"Unknown FE load-coefficient family: {family}")
|
| 414 |
+
|
| 415 |
+
|
| 416 |
+
def _make_gmsh_domain(kind: str, radius: float):
|
| 417 |
+
import gmsh
|
| 418 |
+
|
| 419 |
+
from agentfem import mesh
|
| 420 |
+
|
| 421 |
+
if not gmsh.isInitialized():
|
| 422 |
+
gmsh.initialize()
|
| 423 |
+
gmsh.clear()
|
| 424 |
+
gmsh.option.setNumber("General.Terminal", 0)
|
| 425 |
+
gmsh.model.add(f"denim_v4_{kind}_{radius:.3f}")
|
| 426 |
+
length, height = 2.0, 1.0
|
| 427 |
+
plate = gmsh.model.occ.addRectangle(0.0, 0.0, 0.0, length, height)
|
| 428 |
+
if kind == "central_hole":
|
| 429 |
+
tool = gmsh.model.occ.addDisk(1.0, 0.5, 0.0, radius, radius)
|
| 430 |
+
surfaces, _ = gmsh.model.occ.cut([(2, plate)], [(2, tool)])
|
| 431 |
+
elif kind == "double_edge_notch":
|
| 432 |
+
lower = gmsh.model.occ.addDisk(1.0, 0.0, 0.0, radius, radius)
|
| 433 |
+
upper = gmsh.model.occ.addDisk(1.0, 1.0, 0.0, radius, radius)
|
| 434 |
+
surfaces, _ = gmsh.model.occ.cut([(2, plate)], [(2, lower), (2, upper)])
|
| 435 |
+
else:
|
| 436 |
+
raise ValueError(f"Unknown structure kind: {kind}")
|
| 437 |
+
gmsh.model.occ.synchronize()
|
| 438 |
+
gmsh.model.addPhysicalGroup(2, [tag for _, tag in surfaces], 1)
|
| 439 |
+
gmsh.option.setNumber("Mesh.MeshSizeMin", 0.045)
|
| 440 |
+
gmsh.option.setNumber("Mesh.MeshSizeMax", 0.10)
|
| 441 |
+
gmsh.model.mesh.generate(2)
|
| 442 |
+
return mesh.import_gmsh_model(gmsh.model, gdim=2).domain
|
| 443 |
+
|
| 444 |
+
|
| 445 |
+
def _solve_unit_strain(domain, *, traction: tuple[float, float], side: str) -> tuple[np.ndarray, np.ndarray]:
|
| 446 |
+
from agentfem import constitutive, fields, mesh, models, studies
|
| 447 |
+
from agentfem.solvers import LinearSolverOptions
|
| 448 |
+
|
| 449 |
+
model = models.create(
|
| 450 |
+
study=studies.static_solid(dimension=2, assumption="plane_stress"),
|
| 451 |
+
mesh=domain,
|
| 452 |
+
)
|
| 453 |
+
displacement = model.field(fields.displacement(domain, degree=1))
|
| 454 |
+
model.material(constitutive.isotropic_elastic(young=190.0e9, poisson=0.30, density=7800.0))
|
| 455 |
+
left = mesh.boundary(domain, lambda x: np.isclose(x[0], 0.0), tag=101)
|
| 456 |
+
model.fix(displacement, on=left, value=0.0)
|
| 457 |
+
if side == "right":
|
| 458 |
+
boundary = mesh.boundary(domain, lambda x: np.isclose(x[0], 2.0), tag=102)
|
| 459 |
+
elif side == "top":
|
| 460 |
+
boundary = mesh.boundary(domain, lambda x: np.isclose(x[1], 1.0), tag=103)
|
| 461 |
+
else:
|
| 462 |
+
raise ValueError(f"Unknown loaded side: {side}")
|
| 463 |
+
model.traction(traction, on=boundary)
|
| 464 |
+
result = model.step(
|
| 465 |
+
target=displacement,
|
| 466 |
+
solver_options=LinearSolverOptions(ksp_type="preonly", pc_type="lu"),
|
| 467 |
+
).solve_result(field_variables=("E",))
|
| 468 |
+
result.verify("engineering").require()
|
| 469 |
+
field = result.fields["E"].field
|
| 470 |
+
coordinates = field.function_space.tabulate_dof_coordinates()
|
| 471 |
+
raw = np.asarray(field.x.array, dtype=float).reshape((-1, 4))
|
| 472 |
+
tensor = np.zeros((len(raw), 3, 3), dtype=float)
|
| 473 |
+
tensor[:, 0, 0] = raw[:, 0]
|
| 474 |
+
tensor[:, 0, 1] = tensor[:, 1, 0] = 0.5 * (raw[:, 1] + raw[:, 2])
|
| 475 |
+
tensor[:, 1, 1] = raw[:, 3]
|
| 476 |
+
return np.asarray(coordinates, dtype=float), tensor
|
| 477 |
+
|
| 478 |
+
|
| 479 |
+
def build_structure_bases(*, force: bool = False) -> dict[str, dict[str, np.ndarray]]:
|
| 480 |
+
"""Solve 12 AgentFEM unit-load cases and retain 50 probe bases per structure."""
|
| 481 |
+
|
| 482 |
+
if STRUCTURE_BASIS_PATH.exists() and not force:
|
| 483 |
+
loaded = np.load(STRUCTURE_BASIS_PATH, allow_pickle=False)
|
| 484 |
+
result: dict[str, dict[str, np.ndarray]] = {}
|
| 485 |
+
for name, _, _ in STRUCTURE_SPECS:
|
| 486 |
+
result[name] = {
|
| 487 |
+
"coordinates": loaded[f"{name}__coordinates"],
|
| 488 |
+
"basis": loaded[f"{name}__basis"],
|
| 489 |
+
"cell_indices": loaded[f"{name}__cell_indices"],
|
| 490 |
+
}
|
| 491 |
+
return result
|
| 492 |
+
|
| 493 |
+
collected: dict[str, np.ndarray] = {}
|
| 494 |
+
result = {}
|
| 495 |
+
for name, kind, radius in STRUCTURE_SPECS:
|
| 496 |
+
domain = _make_gmsh_domain(kind, radius)
|
| 497 |
+
mode_outputs = (
|
| 498 |
+
_solve_unit_strain(domain, traction=(1.0e6, 0.0), side="right"),
|
| 499 |
+
_solve_unit_strain(domain, traction=(0.0, 1.0e6), side="right"),
|
| 500 |
+
_solve_unit_strain(domain, traction=(0.0, 1.0e6), side="top"),
|
| 501 |
+
)
|
| 502 |
+
coordinates = mode_outputs[0][0]
|
| 503 |
+
if any(not np.allclose(coordinates, item[0]) for item in mode_outputs[1:]):
|
| 504 |
+
raise RuntimeError("DG0 strain-field coordinates changed between unit-load modes.")
|
| 505 |
+
bases = np.stack([item[1] for item in mode_outputs], axis=1)
|
| 506 |
+
score = np.linalg.norm(bases.reshape((len(bases), -1)), axis=1)
|
| 507 |
+
valid = np.flatnonzero(score > np.quantile(score, 0.20))
|
| 508 |
+
order = valid[np.argsort(score[valid])]
|
| 509 |
+
positions = np.linspace(0, len(order) - 1, 50).round().astype(int)
|
| 510 |
+
selected = order[positions]
|
| 511 |
+
selected_coordinates = coordinates[selected]
|
| 512 |
+
selected_bases = bases[selected]
|
| 513 |
+
result[name] = {
|
| 514 |
+
"coordinates": selected_coordinates,
|
| 515 |
+
"basis": selected_bases,
|
| 516 |
+
"cell_indices": selected.astype(np.int64),
|
| 517 |
+
}
|
| 518 |
+
collected[f"{name}__coordinates"] = selected_coordinates
|
| 519 |
+
collected[f"{name}__basis"] = selected_bases
|
| 520 |
+
collected[f"{name}__cell_indices"] = selected.astype(np.int64)
|
| 521 |
+
DATA_DIR.mkdir(parents=True, exist_ok=True)
|
| 522 |
+
np.savez_compressed(STRUCTURE_BASIS_PATH, **collected)
|
| 523 |
+
return result
|
| 524 |
+
|
| 525 |
+
|
| 526 |
+
def _structure_history(row: dict[str, object], bases: dict[str, dict[str, np.ndarray]]) -> tuple[np.ndarray, dict[str, np.ndarray]]:
|
| 527 |
+
source = bases[str(row["structure_name"])]
|
| 528 |
+
probe = int(row["probe_index"])
|
| 529 |
+
basis = source["basis"][probe]
|
| 530 |
+
coefficients = _load_coefficients(row)
|
| 531 |
+
strains = np.einsum("nm,mij->nij", coefficients, basis)
|
| 532 |
+
strains = _scale_history(strains, float(row["maximum_equivalent_strain"]))
|
| 533 |
+
metadata = {
|
| 534 |
+
"source_strain_basis": tensor_to_voigt(basis),
|
| 535 |
+
"load_mode_coefficients": coefficients,
|
| 536 |
+
"source_coordinate": source["coordinates"][probe],
|
| 537 |
+
"source_cell_index": np.asarray([source["cell_indices"][probe]], dtype=np.int64),
|
| 538 |
+
}
|
| 539 |
+
return strains, metadata
|
| 540 |
+
|
| 541 |
+
|
| 542 |
+
def _standard_history(row: dict[str, object]) -> np.ndarray:
|
| 543 |
+
_, strains = strain_history(row, points=int(row["points"]))
|
| 544 |
+
return strains
|
| 545 |
+
|
| 546 |
+
|
| 547 |
+
def _integrate_reference(strains: np.ndarray) -> dict[str, np.ndarray]:
|
| 548 |
+
law = material()
|
| 549 |
+
count = len(strains)
|
| 550 |
+
stress = np.empty_like(strains)
|
| 551 |
+
plastic = np.empty_like(strains)
|
| 552 |
+
peeq = np.empty(count)
|
| 553 |
+
increment = np.empty(count)
|
| 554 |
+
truth_memories = np.empty((count, 3, 3, 3))
|
| 555 |
+
latent_memories = np.empty((count, 2, 3, 3))
|
| 556 |
+
radius = np.empty(count)
|
| 557 |
+
state = None
|
| 558 |
+
for point, strain in enumerate(strains):
|
| 559 |
+
update = law.update(strain, state, linearization="none")
|
| 560 |
+
state = update.state
|
| 561 |
+
stress[point] = update.stress
|
| 562 |
+
plastic[point] = state.plastic_strain
|
| 563 |
+
peeq[point] = state.equivalent_plastic_strain
|
| 564 |
+
increment[point] = update.plastic_multiplier_increment
|
| 565 |
+
truth_memories[point] = state.backstresses
|
| 566 |
+
latent_memories[point, 0] = state.backstresses[0]
|
| 567 |
+
latent_memories[point, 1] = state.backstresses[1] + state.backstresses[2]
|
| 568 |
+
radius[point] = law.current_yield_stress(peeq[point]) - law.yield_stress
|
| 569 |
+
return {
|
| 570 |
+
"strain": tensor_to_voigt(strains),
|
| 571 |
+
"stress_pa": tensor_to_voigt(stress),
|
| 572 |
+
"plastic_strain": tensor_to_voigt(plastic),
|
| 573 |
+
"peeq": peeq,
|
| 574 |
+
"plastic_increment": increment,
|
| 575 |
+
"memories_pa": tensor_to_voigt(latent_memories),
|
| 576 |
+
"truth_memories_pa": tensor_to_voigt(truth_memories),
|
| 577 |
+
"isotropic_radius_pa": radius,
|
| 578 |
+
"time_coordinate": np.linspace(0.0, 1.0, count),
|
| 579 |
+
}
|
| 580 |
+
|
| 581 |
+
|
| 582 |
+
def _add_observations(row: dict[str, object], arrays: dict[str, np.ndarray]) -> None:
|
| 583 |
+
if row["cohort"] != "discretization_and_observation":
|
| 584 |
+
return
|
| 585 |
+
rng = np.random.default_rng(int(row["path_seed"]) + int(row["points"]) * 1009)
|
| 586 |
+
strain = arrays["strain"]
|
| 587 |
+
stress = arrays["stress_pa"]
|
| 588 |
+
strain_scale = max(float(np.max(np.abs(strain))), 1.0e-12)
|
| 589 |
+
stress_scale = max(float(np.max(np.abs(stress))), 1.0)
|
| 590 |
+
observed_strain = strain + rng.normal(
|
| 591 |
+
scale=float(row["strain_noise_fraction"]) * strain_scale,
|
| 592 |
+
size=strain.shape,
|
| 593 |
+
)
|
| 594 |
+
observed_stress = stress + rng.normal(
|
| 595 |
+
scale=float(row["stress_noise_fraction"]) * stress_scale,
|
| 596 |
+
size=stress.shape,
|
| 597 |
+
)
|
| 598 |
+
keep = float(row["observation_keep_fraction"])
|
| 599 |
+
mask = rng.random(len(strain)) < keep
|
| 600 |
+
mask[0] = True
|
| 601 |
+
mask[-1] = True
|
| 602 |
+
arrays["observed_strain"] = observed_strain
|
| 603 |
+
arrays["observed_stress_pa"] = observed_stress
|
| 604 |
+
arrays["observation_mask"] = mask.astype(np.uint8)
|
| 605 |
+
|
| 606 |
+
|
| 607 |
+
def solve_row(row: dict[str, object], bases: dict[str, dict[str, np.ndarray]]) -> tuple[dict[str, np.ndarray], dict[str, float | bool]]:
|
| 608 |
+
cohort = str(row["cohort"])
|
| 609 |
+
extras: dict[str, np.ndarray] = {}
|
| 610 |
+
if cohort == "long_cycle":
|
| 611 |
+
strains = _long_cycle_history(row)
|
| 612 |
+
elif cohort == "full_3d_nonproportional":
|
| 613 |
+
strains = _full_3d_history(row)
|
| 614 |
+
elif cohort == "structure_derived":
|
| 615 |
+
strains, extras = _structure_history(row, bases)
|
| 616 |
+
elif cohort == "discretization_and_observation":
|
| 617 |
+
strains = _standard_history(row)
|
| 618 |
+
else:
|
| 619 |
+
raise ValueError(f"Unknown cohort: {cohort}")
|
| 620 |
+
arrays = _integrate_reference(strains)
|
| 621 |
+
arrays.update(extras)
|
| 622 |
+
_add_observations(row, arrays)
|
| 623 |
+
metrics = boundary_quality(arrays)
|
| 624 |
+
metrics["maximum_equivalent_total_strain"] = float(np.max(_equivalent_strain(strains)))
|
| 625 |
+
metrics["trajectory_point_count"] = int(len(strains))
|
| 626 |
+
metrics["plastic_step_count"] = int(np.count_nonzero(arrays["plastic_increment"] > 1.0e-12))
|
| 627 |
+
return arrays, metrics
|
| 628 |
+
|
| 629 |
+
|
| 630 |
+
def _agentfem_commit() -> str:
|
| 631 |
+
return subprocess.run(
|
| 632 |
+
("git", "rev-parse", "HEAD"),
|
| 633 |
+
cwd=AGENTFEM_ROOT,
|
| 634 |
+
check=True,
|
| 635 |
+
capture_output=True,
|
| 636 |
+
text=True,
|
| 637 |
+
).stdout.strip()
|
| 638 |
+
|
| 639 |
+
|
| 640 |
+
def _record(row: dict[str, object], metrics: dict[str, float | bool]) -> dict[str, object]:
|
| 641 |
+
return {
|
| 642 |
+
"sample_id": str(row["case_id"]),
|
| 643 |
+
"cohort": str(row["cohort"]),
|
| 644 |
+
"split": str(row["split"]),
|
| 645 |
+
"group_id": str(row["group_id"]),
|
| 646 |
+
"path_family": str(row["path_family"]),
|
| 647 |
+
"points": int(row["points"]),
|
| 648 |
+
"cycle_count": int(row["cycle_count"]),
|
| 649 |
+
"maximum_equivalent_strain": float(row["maximum_equivalent_strain"]),
|
| 650 |
+
"all_finite": bool(metrics["all_finite"]),
|
| 651 |
+
"plastic_step_count": int(metrics["plastic_step_count"]),
|
| 652 |
+
"maximum_absolute_stress_pa": float(metrics["maximum_absolute_stress_pa"]),
|
| 653 |
+
"maximum_peeq": float(metrics["maximum_peeq"]),
|
| 654 |
+
"maximum_yield_surface_relative_residual": float(metrics["maximum_yield_surface_relative_residual"]),
|
| 655 |
+
"minimum_peeq_increment": float(metrics["minimum_peeq_increment"]),
|
| 656 |
+
"maximum_plastic_strain_trace": float(metrics["maximum_plastic_strain_trace"]),
|
| 657 |
+
"observation_protocol": str(row["observation_protocol"]),
|
| 658 |
+
}
|
| 659 |
+
|
| 660 |
+
|
| 661 |
+
def generate(*, force: bool = False, limit: int | None = None) -> dict[str, object]:
|
| 662 |
+
rows = design()
|
| 663 |
+
if limit is not None:
|
| 664 |
+
rows = rows[: int(limit)]
|
| 665 |
+
DATA_DIR.mkdir(parents=True, exist_ok=True)
|
| 666 |
+
ARTIFACT_DIR.mkdir(parents=True, exist_ok=True)
|
| 667 |
+
if DATA_PATH.exists() and not force:
|
| 668 |
+
raise FileExistsError(f"{DATA_PATH} exists; pass --force to replace it.")
|
| 669 |
+
need_structures = any(row["cohort"] == "structure_derived" for row in rows)
|
| 670 |
+
bases = build_structure_bases(force=force) if need_structures else {}
|
| 671 |
+
temporary = DATA_PATH.with_suffix(".h5.tmp")
|
| 672 |
+
records: list[dict[str, object]] = []
|
| 673 |
+
started = time.perf_counter()
|
| 674 |
+
with h5py.File(temporary, "w") as h5:
|
| 675 |
+
h5.attrs["schema"] = "agentfem.physics-data.denim-capability-extension"
|
| 676 |
+
h5.attrs["schema_version"] = "4.0.0"
|
| 677 |
+
h5.attrs["material_json"] = json.dumps(MATERIAL, sort_keys=True)
|
| 678 |
+
h5.attrs["scope"] = str(load_config()["scope"])
|
| 679 |
+
for index, row in enumerate(rows):
|
| 680 |
+
arrays, metrics = solve_row(row, bases)
|
| 681 |
+
if not bool(metrics["all_finite"]):
|
| 682 |
+
raise RuntimeError(f"Non-finite trajectory at index {index}.")
|
| 683 |
+
if float(metrics["minimum_peeq_increment"]) < -1.0e-12:
|
| 684 |
+
raise RuntimeError(f"PEEQ decreased at index {index}.")
|
| 685 |
+
if float(metrics["maximum_yield_surface_relative_residual"]) > 1.0e-8:
|
| 686 |
+
raise RuntimeError(f"Yield residual failed at index {index}.")
|
| 687 |
+
group = h5.create_group(f"{index:05d}")
|
| 688 |
+
for key in (
|
| 689 |
+
"case_id",
|
| 690 |
+
"cohort",
|
| 691 |
+
"split",
|
| 692 |
+
"group_id",
|
| 693 |
+
"path_family",
|
| 694 |
+
"observation_protocol",
|
| 695 |
+
):
|
| 696 |
+
group.attrs[key] = str(row[key])
|
| 697 |
+
group.attrs["points"] = int(row["points"])
|
| 698 |
+
group.attrs["cycle_count"] = int(row["cycle_count"])
|
| 699 |
+
group.attrs["parameters_json"] = json.dumps(row, sort_keys=True)
|
| 700 |
+
group.attrs["quality_json"] = json.dumps(metrics, sort_keys=True)
|
| 701 |
+
for name, value in arrays.items():
|
| 702 |
+
group.create_dataset(name, data=value, compression="gzip", shuffle=True)
|
| 703 |
+
records.append(_record(row, metrics))
|
| 704 |
+
if (index + 1) % 50 == 0 or index + 1 == len(rows):
|
| 705 |
+
print(f"generated {index + 1}/{len(rows)}", flush=True)
|
| 706 |
+
os.replace(temporary, DATA_PATH)
|
| 707 |
+
INDEX_PATH.write_text(
|
| 708 |
+
"".join(json.dumps(record, sort_keys=True) + "\n" for record in records),
|
| 709 |
+
encoding="utf-8",
|
| 710 |
+
)
|
| 711 |
+
with INDEX_CSV_PATH.open("w", newline="", encoding="utf-8") as handle:
|
| 712 |
+
writer = csv.DictWriter(handle, fieldnames=list(records[0]))
|
| 713 |
+
writer.writeheader()
|
| 714 |
+
writer.writerows(records)
|
| 715 |
+
manifest: dict[str, object] = {
|
| 716 |
+
"schema": "agentfem.physics-data.denim-capability-extension",
|
| 717 |
+
"schema_version": "4.0.0",
|
| 718 |
+
"sample_count": len(records),
|
| 719 |
+
"complete_release": len(records) == 1000,
|
| 720 |
+
"cohort_counts": dict(sorted(Counter(record["cohort"] for record in records).items())),
|
| 721 |
+
"split_counts": dict(sorted(Counter(record["split"] for record in records).items())),
|
| 722 |
+
"path_family_counts": dict(sorted(Counter(record["path_family"] for record in records).items())),
|
| 723 |
+
"point_count_distribution": dict(sorted(Counter(str(record["points"]) for record in records).items())),
|
| 724 |
+
"group_count": len({record["group_id"] for record in records}),
|
| 725 |
+
"data_sha256": _sha256(DATA_PATH),
|
| 726 |
+
"index_jsonl_sha256": _sha256(INDEX_PATH),
|
| 727 |
+
"index_csv_sha256": _sha256(INDEX_CSV_PATH),
|
| 728 |
+
"structure_bases_sha256": _sha256(STRUCTURE_BASIS_PATH) if STRUCTURE_BASIS_PATH.exists() else None,
|
| 729 |
+
"data_bytes": DATA_PATH.stat().st_size,
|
| 730 |
+
"generation_seconds": time.perf_counter() - started,
|
| 731 |
+
"agentfem_commit": _agentfem_commit(),
|
| 732 |
+
"reference_material": "hidden three-memory Chaboche with tabulated isotropic hardening",
|
| 733 |
+
"quality": {
|
| 734 |
+
"all_finite_failures": sum(not bool(record["all_finite"]) for record in records),
|
| 735 |
+
"maximum_yield_surface_relative_residual": max(float(record["maximum_yield_surface_relative_residual"]) for record in records),
|
| 736 |
+
"minimum_peeq_increment": min(float(record["minimum_peeq_increment"]) for record in records),
|
| 737 |
+
"maximum_plastic_strain_trace": max(float(record["maximum_plastic_strain_trace"]) for record in records),
|
| 738 |
+
"minimum_plastic_step_count": min(int(record["plastic_step_count"]) for record in records),
|
| 739 |
+
},
|
| 740 |
+
"structure_fidelity": "AgentFEM linear-elastic unit-load strain bases with one-way nonlinear material replay; no coupled elastoplastic redistribution claim",
|
| 741 |
+
"counting_rule": "One sample is one complete trajectory. Observation noise/masks are fields, not extra samples. Matched resolutions are explicitly grouped.",
|
| 742 |
+
}
|
| 743 |
+
_write_json(MANIFEST_PATH, manifest)
|
| 744 |
+
_write_json(ARTIFACT_DIR / "quality.json", manifest)
|
| 745 |
+
return manifest
|
| 746 |
+
|
| 747 |
+
|
| 748 |
+
def audit() -> dict[str, object]:
|
| 749 |
+
manifest = json.loads(MANIFEST_PATH.read_text(encoding="utf-8"))
|
| 750 |
+
rows = [json.loads(line) for line in INDEX_PATH.read_text(encoding="utf-8").splitlines() if line]
|
| 751 |
+
with h5py.File(DATA_PATH, "r") as h5:
|
| 752 |
+
groups = list(h5.keys())
|
| 753 |
+
finite_failures = 0
|
| 754 |
+
missing = []
|
| 755 |
+
for group_name in groups:
|
| 756 |
+
group = h5[group_name]
|
| 757 |
+
required = (
|
| 758 |
+
"strain",
|
| 759 |
+
"stress_pa",
|
| 760 |
+
"plastic_strain",
|
| 761 |
+
"peeq",
|
| 762 |
+
"plastic_increment",
|
| 763 |
+
"memories_pa",
|
| 764 |
+
"truth_memories_pa",
|
| 765 |
+
"isotropic_radius_pa",
|
| 766 |
+
"time_coordinate",
|
| 767 |
+
)
|
| 768 |
+
for name in required:
|
| 769 |
+
if name not in group:
|
| 770 |
+
missing.append(f"{group_name}:{name}")
|
| 771 |
+
elif not np.isfinite(group[name][...]).all():
|
| 772 |
+
finite_failures += 1
|
| 773 |
+
if group.attrs["cohort"] == "discretization_and_observation":
|
| 774 |
+
for name in ("observed_strain", "observed_stress_pa", "observation_mask"):
|
| 775 |
+
if name not in group:
|
| 776 |
+
missing.append(f"{group_name}:{name}")
|
| 777 |
+
if group.attrs["cohort"] == "structure_derived":
|
| 778 |
+
for name in ("source_strain_basis", "load_mode_coefficients", "source_coordinate"):
|
| 779 |
+
if name not in group:
|
| 780 |
+
missing.append(f"{group_name}:{name}")
|
| 781 |
+
audit_result = {
|
| 782 |
+
"sample_count": len(rows),
|
| 783 |
+
"hdf5_group_count": len(groups),
|
| 784 |
+
"case_id_unique": len({row["sample_id"] for row in rows}) == len(rows),
|
| 785 |
+
"missing_required_fields": missing,
|
| 786 |
+
"nonfinite_required_field_count": finite_failures,
|
| 787 |
+
"data_sha256_matches_manifest": _sha256(DATA_PATH) == manifest["data_sha256"],
|
| 788 |
+
"grouped_resolution_protocol": all(
|
| 789 |
+
len([row for row in rows if row["group_id"] == group_id]) == 4
|
| 790 |
+
for group_id in {row["group_id"] for row in rows if row["cohort"] == "discretization_and_observation"}
|
| 791 |
+
),
|
| 792 |
+
"structure_group_count": len({row["group_id"] for row in rows if row["cohort"] == "structure_derived"}),
|
| 793 |
+
}
|
| 794 |
+
audit_result["passed"] = bool(
|
| 795 |
+
audit_result["sample_count"] == 1000
|
| 796 |
+
and audit_result["hdf5_group_count"] == 1000
|
| 797 |
+
and audit_result["case_id_unique"]
|
| 798 |
+
and not audit_result["missing_required_fields"]
|
| 799 |
+
and audit_result["nonfinite_required_field_count"] == 0
|
| 800 |
+
and audit_result["data_sha256_matches_manifest"]
|
| 801 |
+
and audit_result["grouped_resolution_protocol"]
|
| 802 |
+
and audit_result["structure_group_count"] == 4
|
| 803 |
+
)
|
| 804 |
+
_write_json(ARTIFACT_DIR / "audit.json", audit_result)
|
| 805 |
+
return audit_result
|
| 806 |
+
|
| 807 |
+
|
| 808 |
+
def main() -> None:
|
| 809 |
+
parser = argparse.ArgumentParser()
|
| 810 |
+
parser.add_argument("--force", action="store_true")
|
| 811 |
+
parser.add_argument("--limit", type=int)
|
| 812 |
+
parser.add_argument("--audit-only", action="store_true")
|
| 813 |
+
args = parser.parse_args()
|
| 814 |
+
if args.audit_only:
|
| 815 |
+
report = audit()
|
| 816 |
+
else:
|
| 817 |
+
report = generate(force=args.force, limit=args.limit)
|
| 818 |
+
if args.limit is None:
|
| 819 |
+
report = {"generation": report, "audit": audit()}
|
| 820 |
+
print(json.dumps(report, indent=2, sort_keys=True))
|
| 821 |
+
|
| 822 |
+
|
| 823 |
+
if __name__ == "__main__":
|
| 824 |
+
main()
|
tests/test_t2_denim_capability_v4.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from collections import Counter, defaultdict
|
| 4 |
+
|
| 5 |
+
import numpy as np
|
| 6 |
+
|
| 7 |
+
from src.generate_t2_denim_capability_v4 import (
|
| 8 |
+
FULL_3D_FAMILIES,
|
| 9 |
+
RESOLUTIONS,
|
| 10 |
+
design,
|
| 11 |
+
solve_row,
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def test_v4_design_counts_and_unique_ids():
|
| 16 |
+
rows = design()
|
| 17 |
+
assert len(rows) == 1000
|
| 18 |
+
assert len({row["case_id"] for row in rows}) == 1000
|
| 19 |
+
assert Counter(row["cohort"] for row in rows) == {
|
| 20 |
+
"long_cycle": 300,
|
| 21 |
+
"full_3d_nonproportional": 300,
|
| 22 |
+
"structure_derived": 200,
|
| 23 |
+
"discretization_and_observation": 200,
|
| 24 |
+
}
|
| 25 |
+
assert Counter(row["path_family"] for row in rows if row["cohort"] == "full_3d_nonproportional") == {
|
| 26 |
+
family: 50 for family in FULL_3D_FAMILIES
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def test_v4_resolution_groups_are_complete_and_isolated():
|
| 31 |
+
rows = [row for row in design() if row["cohort"] == "discretization_and_observation"]
|
| 32 |
+
grouped = defaultdict(list)
|
| 33 |
+
for row in rows:
|
| 34 |
+
grouped[row["group_id"]].append(row)
|
| 35 |
+
assert len(grouped) == 50
|
| 36 |
+
for values in grouped.values():
|
| 37 |
+
assert tuple(sorted(row["points"] for row in values)) == RESOLUTIONS
|
| 38 |
+
assert len({row["split"] for row in values}) == 1
|
| 39 |
+
assert len({row["path_seed"] for row in values}) == 1
|
| 40 |
+
assert len({row["maximum_equivalent_strain"] for row in values}) == 1
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def test_v4_long_cycle_split_is_true_horizon_ood():
|
| 44 |
+
rows = [row for row in design() if row["cohort"] == "long_cycle"]
|
| 45 |
+
assert {row["cycle_count"] for row in rows if row["split"] == "train_long_cycle"} == {10, 25}
|
| 46 |
+
assert {row["cycle_count"] for row in rows if row["split"] == "validation_long_cycle"} == {50}
|
| 47 |
+
assert {row["cycle_count"] for row in rows if row["split"] == "test_long_cycle_ood"} == {100}
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def test_v4_material_point_smoke_without_structure_solver():
|
| 51 |
+
rows = design()
|
| 52 |
+
selected = (
|
| 53 |
+
next(row for row in rows if row["cohort"] == "long_cycle"),
|
| 54 |
+
next(row for row in rows if row["cohort"] == "full_3d_nonproportional"),
|
| 55 |
+
next(row for row in rows if row["cohort"] == "discretization_and_observation"),
|
| 56 |
+
)
|
| 57 |
+
for row in selected:
|
| 58 |
+
arrays, metrics = solve_row(row, {})
|
| 59 |
+
assert metrics["all_finite"]
|
| 60 |
+
assert metrics["minimum_peeq_increment"] >= -1.0e-12
|
| 61 |
+
assert metrics["maximum_yield_surface_relative_residual"] < 1.0e-8
|
| 62 |
+
assert arrays["strain"].shape == (row["points"], 6)
|
| 63 |
+
assert arrays["stress_pa"].shape == (row["points"], 6)
|
| 64 |
+
observed, _ = solve_row(selected[-1], {})
|
| 65 |
+
assert observed["observation_mask"].dtype == np.uint8
|
| 66 |
+
assert observed["observation_mask"][0] == 1
|
| 67 |
+
assert observed["observation_mask"][-1] == 1
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
def test_every_full_3d_family_is_symmetric_and_integrable():
|
| 71 |
+
rows = [row for row in design() if row["cohort"] == "full_3d_nonproportional"]
|
| 72 |
+
for family in FULL_3D_FAMILIES:
|
| 73 |
+
row = next(value for value in rows if value["path_family"] == family)
|
| 74 |
+
arrays, metrics = solve_row(row, {})
|
| 75 |
+
strain = arrays["strain"]
|
| 76 |
+
assert np.isfinite(strain).all()
|
| 77 |
+
assert metrics["all_finite"]
|
| 78 |
+
assert metrics["maximum_yield_surface_relative_residual"] < 1.0e-8
|