HaomingLuo commited on
Commit
07af0b5
·
verified ·
1 Parent(s): 11f4b68

Release v0.1 verified programmable rod data and native FE checks

Browse files
Files changed (44) hide show
  1. LICENSE-CODE +159 -0
  2. LICENSE-DATA +8 -0
  3. README.md +163 -0
  4. SCHEMA.md +127 -0
  5. SHA256SUMS.json +45 -0
  6. assets/overview.png +3 -0
  7. cases/fig9/agentfem.toml +8 -0
  8. cases/fig9/case.py +369 -0
  9. cases/fig9/paper_reference.py +107 -0
  10. native_fe/figures/native_agentfem_vs_paper.png +3 -0
  11. native_fe/native_fe_metrics.csv +4 -0
  12. native_fe/paraview/native_agentfem_fig9.pvd +8 -0
  13. native_fe/paraview/native_agentfem_fig9000000.pvtu +20 -0
  14. native_fe/paraview/native_agentfem_fig9000001.pvtu +20 -0
  15. native_fe/paraview/native_agentfem_fig9000002.pvtu +20 -0
  16. native_fe/paraview/native_agentfem_fig9_p0_000000.vtu +0 -0
  17. native_fe/paraview/native_agentfem_fig9_p0_000001.vtu +0 -0
  18. native_fe/paraview/native_agentfem_fig9_p0_000002.vtu +0 -0
  19. native_fe/paraview_checks.json +90 -0
  20. native_fe/scientific/p2_coefficients.h5 +3 -0
  21. native_fe/xdmf/native_agentfem_fig9.h5 +3 -0
  22. native_fe/xdmf/native_agentfem_fig9.xdmf +61 -0
  23. reports/additional_baselines.json +625 -0
  24. reports/baselines.json +184 -0
  25. reports/environment.json +11 -0
  26. reports/generation.json +30 -0
  27. reports/inverse_checks.json +0 -0
  28. reports/validation.json +40 -0
  29. requirements.txt +6 -0
  30. src/generate.py +98 -0
  31. src/inference.py +27 -0
  32. src/inverse.py +41 -0
  33. src/package.py +68 -0
  34. src/rod.py +104 -0
  35. src/train.py +68 -0
  36. states/parameter_ood.jsonl.gz +3 -0
  37. states/test.jsonl.gz +3 -0
  38. states/train.jsonl.gz +3 -0
  39. states/validation.jsonl.gz +3 -0
  40. tests/check_paraview.py +25 -0
  41. tests/evaluate_release.py +42 -0
  42. tests/validate.py +85 -0
  43. validation/paired_resolution.jsonl.gz +3 -0
  44. validation/rejected_attempts.json +1 -0
LICENSE-CODE ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright
13
+ owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities
16
+ that control, are controlled by, or are under common control with that entity.
17
+ For the purposes of this definition, "control" means (i) the power, direct or
18
+ indirect, to cause the direction or management of such entity, whether by
19
+ contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
+ outstanding shares, or (iii) beneficial ownership of such entity.
21
+
22
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
23
+ permissions granted by this License.
24
+
25
+ "Source" form shall mean the preferred form for making modifications, including
26
+ but not limited to software source code, documentation source, and configuration
27
+ files.
28
+
29
+ "Object" form shall mean any form resulting from mechanical transformation or
30
+ translation of a Source form, including but not limited to compiled object code,
31
+ generated documentation, and conversions to other media types.
32
+
33
+ "Work" shall mean the work of authorship, whether in Source or Object form,
34
+ made available under the License, as indicated by a copyright notice that is
35
+ included in or attached to the work.
36
+
37
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
38
+ is based on (or derived from) the Work and for which the editorial revisions,
39
+ annotations, elaborations, or other modifications represent, as a whole, an
40
+ original work of authorship. For the purposes of this License, Derivative Works
41
+ shall not include works that remain separable from, or merely link (or bind by
42
+ name) to the interfaces of, the Work and Derivative Works thereof.
43
+
44
+ "Contribution" shall mean any work of authorship, including the original
45
+ version of the Work and any modifications or additions to that Work or
46
+ Derivative Works thereof, that is intentionally submitted to Licensor for
47
+ inclusion in the Work by the copyright owner or by an individual or Legal Entity
48
+ authorized to submit on behalf of the copyright owner. For the purposes of this
49
+ definition, "submitted" means any form of electronic, verbal, or written
50
+ communication sent to the Licensor or its representatives, including but not
51
+ limited to communication on electronic mailing lists, source code control
52
+ systems, and issue tracking systems that are managed by, or on behalf of, the
53
+ Licensor for the purpose of discussing and improving the Work, but excluding
54
+ communication that is conspicuously marked or otherwise designated in writing by
55
+ the copyright owner as "Not a Contribution."
56
+
57
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
58
+ of whom a Contribution has been received by Licensor and subsequently
59
+ incorporated within the Work.
60
+
61
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
62
+ License, each Contributor hereby grants to You a perpetual, worldwide,
63
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
64
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
65
+ sublicense, and distribute the Work and such Derivative Works in Source or
66
+ Object form.
67
+
68
+ 3. Grant of Patent License. Subject to the terms and conditions of this License,
69
+ each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
70
+ no-charge, royalty-free, irrevocable (except as stated in this section) patent
71
+ license to make, have made, use, offer to sell, sell, import, and otherwise
72
+ transfer the Work, where such license applies only to those patent claims
73
+ licensable by such Contributor that are necessarily infringed by their
74
+ Contribution(s) alone or by combination of their Contribution(s) with the Work
75
+ to which such Contribution(s) was submitted. If You institute patent litigation
76
+ against any entity (including a cross-claim or counterclaim in a lawsuit)
77
+ alleging that the Work or a Contribution incorporated within the Work
78
+ constitutes direct or contributory patent infringement, then any patent licenses
79
+ granted to You under this License for that Work shall terminate as of the date
80
+ such litigation is filed.
81
+
82
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
83
+ Derivative Works thereof in any medium, with or without modifications, and in
84
+ Source or Object form, provided that You meet the following conditions:
85
+
86
+ (a) You must give any other recipients of the Work or Derivative Works a copy
87
+ of this License; and
88
+
89
+ (b) You must cause any modified files to carry prominent notices stating that
90
+ You changed the files; and
91
+
92
+ (c) You must retain, in the Source form of any Derivative Works that You
93
+ distribute, all copyright, patent, trademark, and attribution notices from the
94
+ Source form of the Work, excluding those notices that do not pertain to any part
95
+ of the Derivative Works; and
96
+
97
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then
98
+ any Derivative Works that You distribute must include a readable copy of the
99
+ attribution notices contained within such NOTICE file, excluding those notices
100
+ that do not pertain to any part of the Derivative Works, in at least one of the
101
+ following places: within a NOTICE text file distributed as part of the
102
+ Derivative Works; within the Source form or documentation, if provided along
103
+ with the Derivative Works; or, within a display generated by the Derivative
104
+ Works, if and wherever such third-party notices normally appear. The contents of
105
+ the NOTICE file are for informational purposes only and do not modify the
106
+ License. You may add Your own attribution notices within Derivative Works that
107
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
108
+ provided that such additional attribution notices cannot be construed as
109
+ modifying the License.
110
+
111
+ You may add Your own copyright statement to Your modifications and may provide
112
+ additional or different license terms and conditions for use, reproduction, or
113
+ distribution of Your modifications, or for any such Derivative Works as a
114
+ whole, provided Your use, reproduction, and distribution of the Work otherwise
115
+ complies with the conditions stated in this License.
116
+
117
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
118
+ Contribution intentionally submitted for inclusion in the Work by You to the
119
+ Licensor shall be under the terms and conditions of this License, without any
120
+ additional terms or conditions. Notwithstanding the above, nothing herein shall
121
+ supersede or modify the terms of any separate license agreement you may have
122
+ executed with Licensor regarding such Contributions.
123
+
124
+ 6. Trademarks. This License does not grant permission to use the trade names,
125
+ trademarks, service marks, or product names of the Licensor, except as required
126
+ for reasonable and customary use in describing the origin of the Work and
127
+ reproducing the content of the NOTICE file.
128
+
129
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
130
+ writing, Licensor provides the Work (and each Contributor provides its
131
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
132
+ KIND, either express or implied, including, without limitation, any warranties or
133
+ conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
134
+ PARTICULAR PURPOSE. You are solely responsible for determining the
135
+ appropriateness of using or redistributing the Work and assume any risks
136
+ associated with Your exercise of permissions under this License.
137
+
138
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
139
+ tort (including negligence), contract, or otherwise, unless required by
140
+ applicable law (such as deliberate and grossly negligent acts) or agreed to in
141
+ writing, shall any Contributor be liable to You for damages, including any
142
+ direct, indirect, special, incidental, or consequential damages of any character
143
+ arising as a result of this License or out of the use or inability to use the
144
+ Work (including but not limited to damages for loss of goodwill, work stoppage,
145
+ computer failure or malfunction, or any and all other commercial damages or
146
+ losses), even if such Contributor has been advised of the possibility of such
147
+ damages.
148
+
149
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or
150
+ Derivative Works thereof, You may choose to offer, and charge a fee for,
151
+ acceptance of support, warranty, indemnity, or other liability obligations
152
+ and/or rights consistent with this License. However, in accepting such
153
+ obligations, You may act only on Your own behalf and on Your sole
154
+ responsibility, not on behalf of any other Contributor, and only if You agree to
155
+ indemnify, defend, and hold each Contributor harmless for any liability incurred
156
+ by, or claims asserted against, such Contributor by reason of your accepting any
157
+ such warranty or additional liability.
158
+
159
+ END OF TERMS AND CONDITIONS
LICENSE-DATA ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ Data and original generated figures: Copyright 2026 Haoming Luo.
2
+ Licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
3
+ https://creativecommons.org/licenses/by/4.0/
4
+ Legal terms: https://creativecommons.org/licenses/by/4.0/legalcode
5
+
6
+ Attribute AgentFEM Morph Lab, the dataset version/revision, and indicate changes.
7
+ Code is separately Apache-2.0 (LICENSE-CODE). The cited JMPS article and its figures
8
+ are not distributed here and are not relicensed by this dataset.
README.md ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ language:
4
+ - en
5
+ - zh
6
+ task_categories:
7
+ - other
8
+ size_categories:
9
+ - 10K<n<100K
10
+ tags:
11
+ - agentfem
12
+ - soft-robotics
13
+ - programmable-matter
14
+ - structural-mechanics
15
+ - inverse-design
16
+ - scientific-machine-learning
17
+ pretty_name: AgentFEM Programmable Soft Rods
18
+ configs:
19
+ - config_name: equilibria
20
+ data_files:
21
+ - split: train
22
+ path: states/train.jsonl.gz
23
+ - split: validation
24
+ path: states/validation.jsonl.gz
25
+ - split: test
26
+ path: states/test.jsonl.gz
27
+ - split: parameter_ood
28
+ path: states/parameter_ood.jsonl.gz
29
+ ---
30
+
31
+ # AgentFEM · Programmable Soft Rods
32
+
33
+ **Learn shapes. Distinguish branches. Design actuation.**
34
+
35
+ ![Three families of computed flexible-rod shapes](assets/overview.png)
36
+
37
+ **216 physical scenarios · 648 equilibrium sweeps · 16,200 states**
38
+
39
+ Planar flexible rods driven by end loads, three-zone intrinsic curvature, and
40
+ microscale forces. Each state contains its centerline, angle and strain fields,
41
+ control parameters, local stability, and solver evidence.
42
+
43
+ [Models & solver](https://huggingface.co/HaomingLuo/AgentFEM-Morph-Rod-Surrogates) ·
44
+ [AgentFEM](https://github.com/haoming-luo/agentfem) · [Mechanics & schema](SCHEMA.md)
45
+
46
+ ## What can you study?
47
+
48
+ - Shape prediction under different actuation mechanisms.
49
+ - Multi-solution regression: identical loading can admit straight, up-bent and down-bent states.
50
+ - Bounded inverse design of endpoint positions or complete centerlines.
51
+ - Resolution sensitivity and local equilibrium stability.
52
+
53
+ This is the first data release of **AgentFEM Morph Lab**, a project on programmable
54
+ flexible structures. The JMPS microforce rod is one featured mechanism, alongside
55
+ conventional loading and distributed eigen-curvature actuation.
56
+
57
+ ## Contents
58
+
59
+ | Collection | Included |
60
+ |---|---|
61
+ | End-force / end-moment rods | 72 scenarios, 5,400 equilibrium samples |
62
+ | Three-zone intrinsic-curvature rods | 72 scenarios, 5,400 equilibrium samples |
63
+ | Microforce rods | 72 scenarios, 5,400 samples across up/down/straight branches |
64
+ | Paired resolution checks | 216 pairs, 48 vs 96 angle elements |
65
+ | Native AgentFEM solids | 3 independent Figure 9 cases, actual downward solutions |
66
+ | Reproducibility | Source, tests, schema, numerical reports, hashes |
67
+
68
+ The 1D corpus is produced by the supplied NumPy/SciPy angle-FE solver. The three
69
+ 2D checks use native AgentFEM/FEniCSx. Sample frames are not independent scenarios;
70
+ reversible sweeps can revisit the same shape.
71
+
72
+ ## Load a sample
73
+
74
+ ```python
75
+ from datasets import load_dataset
76
+ data = load_dataset("HaomingLuo/AgentFEM-Programmable-Soft-Rods", "equilibria")
77
+ sample = data["test"][0]
78
+ print(sample["controls"], sample["tip"], sample["stability"])
79
+ ```
80
+
81
+ Without the datasets library:
82
+
83
+ ```python
84
+ import gzip, json
85
+ from huggingface_hub import hf_hub_download
86
+ path = hf_hub_download("HaomingLuo/AgentFEM-Programmable-Soft-Rods",
87
+ "states/test.jsonl.gz", repo_type="dataset")
88
+ with gzip.open(path, "rt") as f:
89
+ sample = json.loads(next(f))
90
+ ```
91
+
92
+ ## Validation
93
+
94
+ - Axial extension and constant-curvature analytic checks pass.
95
+ - Energy gradient and tangent verified by finite differences.
96
+ - First continuum bifurcation load: absolute discrepancy **1.09e-8** in dimensionless p.
97
+ - Figure 9 independent BVP vs 96-element rod: centerline RMSE below **5.87e-5 L**.
98
+ - All 216 resolution pairs: maximum centerline RMSE **1.72e-4 L**.
99
+ - Three 2D equivalent-solid vs paper-continuum errors: **0.758%, 0.176%, 0.394% of L**.
100
+ - PVD and XDMF both opened and warped in ParaView; all three fields share one geometry.
101
+
102
+ Full evidence: [validation](reports/validation.json), [generation](reports/generation.json),
103
+ [native FE metrics](native_fe/native_fe_metrics.csv), [ParaView checks](native_fe/paraview_checks.json).
104
+ These measurements apply to the stated checks, not an accuracy guarantee for arbitrary rods.
105
+
106
+ ## Splits and baselines
107
+
108
+ 126 training / 27 validation / 27 test / 36 stiffness-OOD scenes. All sweeps,
109
+ mirrored branches and mesh pairs of a scene stay in the same partition. The test
110
+ split was not used for fitting or checkpoint selection; there is no sealed test
111
+ or geometry-OOD benchmark in this release.
112
+
113
+ | Predictor | Supplied branch? | Test centerline RMSE / L |
114
+ |---|---:|---:|
115
+ | Ordinary MLP | No | 0.27097 |
116
+ | Branch-conditioned nearest neighbor | Yes | 0.13899 |
117
+ | Branch-conditioned MLP | Yes | 0.00661 |
118
+
119
+ The ordinary MLP receives ambiguous multi-solution inputs; this is an input
120
+ identifiability demonstration, not proof of a superior neural architecture.
121
+ The conditioned MLP's mean test endpoint error is **0.00784 L**. Stiffness-OOD
122
+ centerline RMSE is **0.00941 L**. See [all baseline results](reports/baselines.json).
123
+
124
+ ## Physical scope
125
+
126
+ Dimensionless, conservative planar rods; fixed clamp; force control. Stability
127
+ labels come from the constrained discrete energy Hessian. Sweeps are quasi-static
128
+ equilibria, not physical-time trajectories. The supplied inverse examples use
129
+ bounded intrinsic curvature and numerical forward verification. They do not
130
+ establish general reachability, snap-through dynamics, contact or robot hardware control.
131
+
132
+ See [SCHEMA.md](SCHEMA.md) for equations, normalization, sampling, branch semantics,
133
+ and the difference between the paper's end force p and effective resultant p+2h.
134
+
135
+ ## 中文
136
+
137
+ **可编程柔性杆:从形状预测到驱动设计。**
138
+
139
+ 首批包含三类问题:端力/端矩驱动、三段本征曲率驱动,以及 JMPS 论文中的
140
+ 微结构驱动。216 个独立场景、648 条平衡状态扫描、16,200 个采样状态;另有
141
+ 216 组网格加密对照和 3 个 AgentFEM 二维实体核验算例。
142
+
143
+ 数据可用于形状预测、多解回归和逆向设计。上下弯分支及同场景的不同路径不跨
144
+ 训练/测试划分。三段本征曲率是一种理想化驱动模型;当前不含真实跳跃动力学、
145
+ 接触或硬件实验。二维结果实际求解得到下弯形状,未在绘图时翻转。
146
+
147
+ 下载 `native_fe/paraview/` 后打开 PVD,使用 `U` 做 Warp By Vector;XDMF 的
148
+ 位移为 P1 插值副本,完整 Q2 系数另存于 `native_fe/scientific/`。
149
+
150
+ ## Reproduce and cite
151
+
152
+ Version **0.1.0**, seed **20261014**. Install `requirements.txt`, then follow
153
+ [SCHEMA.md](SCHEMA.md#reproduction). Native FE additionally requires AgentFEM/FEniCSx.
154
+
155
+ Data and generated figures: **CC BY 4.0**. Code: **Apache-2.0**. The paper is cited,
156
+ not redistributed or relicensed.
157
+
158
+ Theory reference: Yang Ye, Andrea Piccolroaz, Davide Bigoni,
159
+ *Three Homogenization Models for a Nonlinear Heterogeneous Rod with Microscale Dead Loading*,
160
+ [DOI: 10.1016/j.jmps.2026.106870](https://doi.org/10.1016/j.jmps.2026.106870).
161
+
162
+ Please cite **Haoming Luo, AgentFEM Morph Lab: Programmable Soft Rods, v0.1.0 (2026)**,
163
+ the dataset URL and revision, and the theory reference when using the microforce cases.
SCHEMA.md ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Morph Rods v0.1: mechanics and data contract
2
+
3
+ ## Scope and units
4
+
5
+ Planar unshearable, extensible, conservative elastic rods, clamped at s=0.
6
+ All coordinates are divided by reference length L; forces by EA; moments by EA L;
7
+ curvature is kappa L; potential energy by EA L. `chi = EI/(EA L^2)`.
8
+ Positive fx denotes tension; positive fy points upward. No gravity, contact,
9
+ friction, inertia, material hysteresis, or physical-time evolution is included.
10
+
11
+ The generated 1D data use this project's angle finite-element implementation in
12
+ NumPy/SciPy. They are NOT 16,200 AgentFEM solid-FE runs. Three separately packaged
13
+ 2D cases use native AgentFEM/FEniCSx. The hinge chain is a separate reference.
14
+
15
+ ## Energy
16
+
17
+ Let a=fx+2h, g=4h delta, theta be the rod tangent angle, and
18
+ f(theta)=a cos(theta)+fy sin(theta). Axial strain is eliminated exactly as
19
+ epsilon=f(theta). With prescribed intrinsic curvature kappa0(s), the reduced
20
+ energy is, up to an additive control-dependent constant:
21
+
22
+ Pi = integral[ chi/2 (theta' - kappa0)^2
23
+ - f(theta) - f(theta)^2/2 + g cos(theta) ] ds
24
+ - moment * theta(1).
25
+
26
+ For h=0 this is a conventional extensible elastica with eigen-curvature. For
27
+ kappa0=0 and moment=fy=0, the microforce term reproduces the homogenized Model (i)
28
+ of Ye, Piccolroaz & Bigoni, DOI 10.1016/j.jmps.2026.106870. The theory belongs to
29
+ those authors. Our additions are the implementation, checks, data organization,
30
+ surrogate baselines, and bounded inverse-design example.
31
+
32
+ Theta uses linear FE nodes; strain and potential terms use midpoint quadrature.
33
+ The clamp angle is eliminated. The default is 48 elements, with 96-element paired
34
+ checks. Three constant intrinsic-curvature regions partition the reference length
35
+ equally. They describe idealized actuation, not a calibrated pneumatic actuator.
36
+
37
+ For the paper's original chain, theta of the first cell is fixed and n-1 hinge
38
+ rotations remain; kr=chi*n. Do not interpret chain cell count as continuum FE
39
+ resolution. The paper reference uses n=15,30,60,120 in validation.
40
+
41
+ ## Fields
42
+
43
+ - `scene_id`, `split`: a physical parameter draw and its fixed partition.
44
+ - `path_id`, `step`, `path_parameter`: ordered equilibrium samples, NOT seconds.
45
+ - `family`: end_load, intrinsic_curvature, or microforce.
46
+ - `controls`: chi, fx, fy, moment, h, delta, k1, k2, k3.
47
+ - `z`: 48 free angle DOFs; append theta(0)=0 at the front.
48
+ - `angle`, `strain`: 48 element-midpoint values.
49
+ - `centerline`: 65 [x/L,y/L] points at uniformly spaced reference coordinate s/L.
50
+ - `tip`: endpoint [x/L,y/L].
51
+ - `energy`: reduced total potential with the convention above. Do not interpret
52
+ its difference across changed controls as dissipated work.
53
+ - `residual`: infinity norm of the reduced free-angle energy gradient.
54
+ - `lambda_min_over_chi`: smallest generalized Hessian eigenvalue divided by chi.
55
+ Angular mass is the same midpoint quadrature matrix, not physical inertia.
56
+ - `stability`: stable if eigenvalue>1e-4, unstable if < -1e-4, critical otherwise.
57
+ This is LOCAL stability under fixed dead loads and the stated clamp, in this
58
+ discretized conservative model; it is not a hardware safety margin.
59
+ - `branch`: coarse descriptor up/down by tip y, or straight if max|z|<1e-5.
60
+ This is not a universal enumeration of every nonlinear equilibrium branch.
61
+ - `seed_source`, `solver_trace`, `fallback_nfev`: numerical initialization,
62
+ residual/step evidence, optional root-solver work count.
63
+ - `previous_id`, `continuous_stable_pair`: adjacent accepted stable samples with
64
+ max angle-DOF change<0.2 rad. This heuristic does NOT certify the unsampled
65
+ interval or prove reachability from the unloaded state.
66
+
67
+ ## Sampling and partitions
68
+
69
+ 216 scenes, 72 per family: 60 ID + 12 stiffness-OOD. Each scene has three ordered
70
+ sweeps and 25 samples per sweep, giving 648 sweeps and 16,200 states. Reversible
71
+ sweeps and unloaded endpoints may repeat shapes: these are NOT 16,200 independent
72
+ scenarios or unique geometries.
73
+
74
+ Each family uses 42 training, 9 validation, 9 test and 12 OOD scenes. All mirrored
75
+ branches, all sweeps, and paired resolutions stay with their parent scene.
76
+ Parameter-OOD increases chi beyond the training interval; it does not establish
77
+ geometry, path, or discretization OOD capability. Test is held out from fitting
78
+ and checkpoint selection, but is not a permanently sealed benchmark.
79
+
80
+ ID chi: log-uniform [1e-4,10^-2.5]; OOD chi: log-uniform [10^-2.5,10^-2.1].
81
+ End loads: fx/chi in [0,2], fy/chi in [-2,2], moment/chi in [-1,1].
82
+ Curvature controls: each ki in [-2.4,2.4].
83
+ Microforce scenes: h/chi in [4,30], delta in [.05,.35], p starts at pcr-.2chi
84
+ and decreases to pcr-c chi with c in [2,8]. Here p=fx and pcr is the first
85
+ continuum bifurcation root. Up/down/straight solutions are deliberately seeded.
86
+ The unstable straight states are retained, not followed as a physical motion.
87
+
88
+ No initial-imperfection distribution, subcritical branch atlas, snap dynamics,
89
+ self-contact validation, or hardware data are provided in v0.1.
90
+
91
+ ## Native 2D evidence
92
+
93
+ Three Figure 9 cases: Q2 plane-stress Saint-Venant--Kirchhoff solid, nu=0,
94
+ EA=1, thickness=sqrt(12 chi), plus the paper's orientation potential. This is an
95
+ equivalent finite-thickness realization, not a resolved hinge microstructure.
96
+ `U` is solved downward, not reflected for plotting. PVD/VTU carries Q2 displacement
97
+ and DG0 MISES/microforce potential. XDMF/HDF5 carries P1-interpolated U and DG0 fields
98
+ on a single geometry per case. Exact serial Q2 coefficients, coordinates and cell
99
+ DOF maps are retained in scientific/p2_coefficients.h5. These coefficients require
100
+ the supplied element convention/case to interpret; they are not a universal restart.
101
+ Case indices 0,1,2 are independent loads, NOT a transient trajectory.
102
+
103
+ ## Baselines
104
+
105
+ Ordinary and branch-conditioned MLP: two hidden layers of width 96 with tanh,
106
+ 48 angle outputs, Adam, seed14, 401 epochs; checkpoint selected by validation
107
+ angle MSE. Only training data define input normalization. Branch conditioning is
108
+ supplied information, not predicted by a hidden classifier. The ordinary baseline
109
+ is intentionally ambiguous on mirrored multi-solution inputs: its worse result
110
+ demonstrates the missing-input problem, not architectural superiority.
111
+ The branch-conditioned 1-nearest-neighbor baseline receives the same branch label.
112
+ Raw neural estimates require mechanical correction before equilibrium/stability
113
+ claims. The correction can change a predicted branch; check the returned state.
114
+
115
+ ## Reproduction
116
+
117
+ python tests/validate.py
118
+ python src/generate.py
119
+ python src/train.py
120
+ python tests/evaluate_release.py
121
+ python src/inverse.py
122
+
123
+ Native FE requires AgentFEM/FEniCSx separately:
124
+
125
+ agentfem run --project cases/fig9 --name downward
126
+
127
+ Dependencies and measured versions are in requirements.txt and reports/environment.json.
SHA256SUMS.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "LICENSE-CODE": "4a8e89fe65965e0b5ab34a6a1b8faa412666e426ce92500dba6af0c8f3e0ca0b",
3
+ "LICENSE-DATA": "6717316458f84621b0f3f1201d7099d8df9fd9545b50c302b120c342833d0094",
4
+ "README.md": "a7b9aa8f31be88c2261cf35b7d06dfff543aa6fa6e250942e80e16a7e249ac79",
5
+ "SCHEMA.md": "6c85472623acf231c460ece0b03288fd4b04558ef089a654c35108fcc97ae098",
6
+ "assets/overview.png": "844ed9eef3ca4f32b13513bfe21de96f27d4ef5113a07bad7117556d15d9fa52",
7
+ "cases/fig9/agentfem.toml": "97f65c98b01ed94ebd331cdc4be2f5d76db8dcefbcc9aa0ffbd1589fd82af6d9",
8
+ "cases/fig9/case.py": "51684e93a66cd75ca9e688dd2210b1252c16d439763ba60de0f7d533e82311fa",
9
+ "cases/fig9/paper_reference.py": "e6797a4f82b5018503b8c659f494ccf91204321cb9b5bf41a63b79924c206526",
10
+ "native_fe/figures/native_agentfem_vs_paper.png": "aab6e9ddc1d9624e726319b555f77163a944eee2261b00f728990b6584cd5c6d",
11
+ "native_fe/native_fe_metrics.csv": "6f6d6e5973d75bff4dc4edab12540971fe324ddf23ba601ca0679f79c644bef2",
12
+ "native_fe/paraview/native_agentfem_fig9.pvd": "bfd9cb9607222d716791d948140a13147ec84d887fd88b6e2e640dd5cfeed06e",
13
+ "native_fe/paraview/native_agentfem_fig9000000.pvtu": "9740e14ecbc8b1cc63897005cd853aa1e4330549a9794b1a2a09c3473b3a6567",
14
+ "native_fe/paraview/native_agentfem_fig9000001.pvtu": "761ce2c62cfb600069aa8b48141917872620065b1fa36114ad4019c1370e1237",
15
+ "native_fe/paraview/native_agentfem_fig9000002.pvtu": "560a09d9b844906bf21c3751aa7802d0b9764f2790c18bd9d785ebe1f837e6af",
16
+ "native_fe/paraview/native_agentfem_fig9_p0_000000.vtu": "b080e8bc0150257c78959bab88ad74ae859d35724d8dbdf1c040fb9ccbb4a92b",
17
+ "native_fe/paraview/native_agentfem_fig9_p0_000001.vtu": "1f0acd4f1b14a49da74310a401ccae0046770edab3ceeec6f7167cd29954595a",
18
+ "native_fe/paraview/native_agentfem_fig9_p0_000002.vtu": "54b40de06d684d2d8142d1af6fc0a3f31a2b945ccc582c53e2524e6869401ff5",
19
+ "native_fe/paraview_checks.json": "b0848ab988da2ea49769e813e340e072ae046c6cb173f39019d2b4d31d7a11a3",
20
+ "native_fe/scientific/p2_coefficients.h5": "5492eef2a5f5bb0d713f8ba21c512e9f677835e0395b11900dfd4d13b08d89e1",
21
+ "native_fe/xdmf/native_agentfem_fig9.h5": "9be172050b961662fb54b57be1abffcd7698520308e804bd164677025b1d58e7",
22
+ "native_fe/xdmf/native_agentfem_fig9.xdmf": "b25d10a258de002e3b546e9813fba94245d2514f530c106103f5484c649be335",
23
+ "reports/additional_baselines.json": "7184e6e33f23dd9cd73da4e35131d7e4ac2906627932b62eea1ae8b1c3482bf9",
24
+ "reports/baselines.json": "32b6297c11b6a5e1134222b4e88bba5edca922940bb895cd89b1cf97044a2e81",
25
+ "reports/environment.json": "0f80f1c3fb99529e87e892c5d418ee7def8b72695d14fa325809d35904eeb9e1",
26
+ "reports/generation.json": "1343aff2e6b4e2e46fbb15e50159084671a9dbba7718f92807088b599d88041a",
27
+ "reports/inverse_checks.json": "1e4714f41a076aef394cdcfb60965546c72852f57ff8b423f3e8b1fc9704eaa7",
28
+ "reports/validation.json": "77ba910278c57771a3944eb81e2df17b262fe6e903e37f412c171f9a73755fe7",
29
+ "requirements.txt": "109b4a8df3c120bd4301525eab1bd89f974e95291aeb1c441b4c3c8db5edb098",
30
+ "src/generate.py": "2d7b2866400386f3e0d73e796f534b6aed8e493a7e6c646b71ade698fe82a00b",
31
+ "src/inference.py": "b07695dcfaaa90493a2efafc6944b2e708a48a8c16dc27b497218c59b9b7598a",
32
+ "src/inverse.py": "6e34886daf04dfefbcd241060c91505006704c3aaf9edeca9fa38f66d35242dc",
33
+ "src/package.py": "1fd297836c20bcfd9cc51f4b2ed62204b8de9027f5dd33fcd3075d6548ae53b8",
34
+ "src/rod.py": "4011c7f72047d0de9da63f18187abf818ed49c711ebe349c1b285e763ddad12a",
35
+ "src/train.py": "57090fde92cc3e80e28f54856534817bb447708d1095d82a33f6c13492741be2",
36
+ "states/parameter_ood.jsonl.gz": "7795bd454c08eaaf2c93a86e54a60354337bf3e52a94c8c91d039b82811d631a",
37
+ "states/test.jsonl.gz": "ce1c3a1bfa3d141ee188041664e8043f611fd218612e609aa8ec090f14bae379",
38
+ "states/train.jsonl.gz": "60ce6d411294a8bcffe96cd893a66b8b5eb539c2cdef3fad6fa2a1a3fc55d537",
39
+ "states/validation.jsonl.gz": "235cf1d9221fc6ffa31e20ca186ab15db2cf06ca8d575c4157eeead88b3f9f10",
40
+ "tests/check_paraview.py": "3575e185754a68aa3482537dd750cb6cbc280f26dc6eb41375bc8ce2931c4fa6",
41
+ "tests/evaluate_release.py": "657e5d01c8246a1c140bbdf8b7dcdf1c1f94fe09df71163f076e3846b5f7b973",
42
+ "tests/validate.py": "12ac0c9f9ff841142bb79e5eb53af1cde1d699ae259d723bb568725d7c4b7fa1",
43
+ "validation/paired_resolution.jsonl.gz": "68a217ba0ad15b5a6bc5119b61577eddd7e6126f6edd2fa6acbb3d07d50615cd",
44
+ "validation/rejected_attempts.json": "37517e5f3dc66819f61f5a7bb8ace1921282415f10551d2defa5c3eb0985b570"
45
+ }
assets/overview.png ADDED

Git LFS Details

  • SHA256: 844ed9eef3ca4f32b13513bfe21de96f27d4ef5113a07bad7117556d15d9fa52
  • Pointer size: 130 Bytes
  • Size of remote file: 96.2 kB
cases/fig9/agentfem.toml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "ye_2026_fig9_reproduction"
3
+ entrypoint = "case.py"
4
+ schema_version = "0.2.0"
5
+
6
+ [run]
7
+ output_directory = "outputs"
8
+
cases/fig9/case.py ADDED
@@ -0,0 +1,369 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Native AgentFEM FE reproduction of Ye et al. (2026), Figure 9.
2
+
3
+ The paper's homogenized orientational potential is added to a finite-thickness
4
+ Saint-Venant--Kirchhoff solid. AgentFEM owns the mesh, P2 displacement field,
5
+ material, boundary conditions, Newton solve, DG0 projections, ParaView series,
6
+ result manifest and run provenance. The paper equations are used only as an
7
+ independent reference and as the Newton initial guess.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ from pathlib import Path
13
+ import sys
14
+ sys.path.insert(0, str(Path(__file__).resolve().parent))
15
+
16
+ import matplotlib.pyplot as plt
17
+ import numpy as np
18
+ import h5py
19
+ import copy
20
+ import xml.etree.ElementTree as ET
21
+ import ufl
22
+ from dolfinx import fem
23
+
24
+ from agentfem import (
25
+ constitutive,
26
+ fields,
27
+ io,
28
+ mesh,
29
+ models,
30
+ problems,
31
+ project,
32
+ results,
33
+ solvers,
34
+ studies,
35
+ )
36
+ from agentfem.constitutive import geometric_elasticity, hyperelasticity
37
+
38
+ from paper_reference import (
39
+ CHI,
40
+ DELTA,
41
+ H,
42
+ LOADS,
43
+ critical_load_continuum,
44
+ critical_load_discrete,
45
+ solve_continuum,
46
+ solve_discrete,
47
+ )
48
+
49
+
50
+ def build_native_model(*, nx=100, ny=4):
51
+ thickness = float(np.sqrt(12.0 * CHI))
52
+ young = 1.0 / thickness
53
+ domain = mesh.rectangle(
54
+ (0.0, -0.5 * thickness),
55
+ (1.0, 0.5 * thickness),
56
+ (nx, ny),
57
+ cell_type="quadrilateral",
58
+ )
59
+ model = models.create(
60
+ study=studies.static_solid(
61
+ dimension=2,
62
+ assumption="plane_stress",
63
+ nonlinear=True,
64
+ ),
65
+ mesh=domain,
66
+ name="homogenized_microforce_rod",
67
+ )
68
+ displacement = model.field(fields.displacement(domain, degree=2))
69
+ displacement.value.name = "U"
70
+ material = model.material(
71
+ constitutive.saint_venant_kirchhoff(
72
+ young=young,
73
+ poisson=0.0,
74
+ plane_stress=True,
75
+ name="EA=1_EI=chi",
76
+ )
77
+ )
78
+ left = mesh.boundary(domain, lambda x: np.isclose(x[0], 0.0), name="clamp")
79
+ right = mesh.boundary(domain, lambda x: np.isclose(x[0], 1.0), name="loaded_end")
80
+ model.clamp(displacement, on=left)
81
+
82
+ u = displacement.value
83
+ F = ufl.Identity(2) + ufl.grad(u)
84
+ axial_vector = ufl.dot(F, ufl.as_vector((1.0, 0.0)))
85
+ axial_stretch = ufl.sqrt(ufl.dot(axial_vector, axial_vector))
86
+ cosine = axial_vector[0] / axial_stretch
87
+ load_p = fem.Constant(domain, 0.0)
88
+ elastic_density = geometric_elasticity.energy(F, material)
89
+ microforce_density = -4.0 * H * DELTA / thickness * (1.0 - cosine)
90
+ effective_force = load_p + 2.0 * H
91
+ potential = (
92
+ (elastic_density + microforce_density) * ufl.dx
93
+ - (effective_force / thickness) * u[0] * right.measure
94
+ )
95
+ residual = ufl.derivative(potential, u, displacement.test)
96
+ jacobian = ufl.derivative(residual, u, displacement.trial)
97
+ nonlinear = problems.nonlinear(
98
+ residual,
99
+ u,
100
+ jacobian=jacobian,
101
+ constraints=model.constraints,
102
+ solver_options=solvers.NewtonSolverOptions(
103
+ absolute_tolerance=1.0e-9,
104
+ relative_tolerance=1.0e-9,
105
+ maximum_iterations=80,
106
+ line_search="basic",
107
+ ),
108
+ name="ye_2026_model_i_native_fe",
109
+ )
110
+
111
+ sigma = hyperelasticity.cauchy_stress(u, material)
112
+ mises_expression = ufl.sqrt(
113
+ sigma[0, 0] ** 2
114
+ - sigma[0, 0] * sigma[1, 1]
115
+ + sigma[1, 1] ** 2
116
+ + 3.0 * sigma[0, 1] ** 2
117
+ )
118
+ mises = results.prepare_projection(
119
+ mises_expression,
120
+ domain=domain,
121
+ family="DG",
122
+ degree=0,
123
+ name="MISES",
124
+ )
125
+ orientation_energy = results.prepare_projection(
126
+ microforce_density,
127
+ domain=domain,
128
+ family="DG",
129
+ degree=0,
130
+ name="MICROFORCE_POTENTIAL",
131
+ )
132
+ return {
133
+ "domain": domain,
134
+ "model": model,
135
+ "displacement": displacement,
136
+ "material": material,
137
+ "problem": nonlinear,
138
+ "load_p": load_p,
139
+ "mises": mises,
140
+ "orientation_energy": orientation_energy,
141
+ "thickness": thickness,
142
+ "young": young,
143
+ "nx": nx,
144
+ "ny": ny,
145
+ }
146
+
147
+
148
+ def seed_from_reference(displacement, p):
149
+ sample, theta, center_x, center_y = solve_continuum(float(p))
150
+
151
+ def initial(x):
152
+ s = np.clip(x[0], 0.0, 1.0)
153
+ xc = np.interp(s, sample, center_x)
154
+ yc = np.interp(s, sample, center_y)
155
+ angle = np.interp(s, sample, theta)
156
+ transverse = x[1]
157
+ return np.vstack(
158
+ (
159
+ xc - s - transverse * np.sin(angle),
160
+ yc + transverse * np.cos(angle) - transverse,
161
+ )
162
+ )
163
+
164
+ displacement.value.interpolate(initial)
165
+ return sample, center_x, center_y
166
+
167
+
168
+ def sample_centerline(displacement, count=301):
169
+ s = np.linspace(0.0, 1.0, count)
170
+ values = np.asarray(
171
+ [results.probe(displacement, at=(float(x), 0.0)) for x in s],
172
+ dtype=float,
173
+ )
174
+ return s, s + values[:, 0], values[:, 1]
175
+
176
+
177
+ def comparison_plot(path: Path, cases):
178
+ figure, axes = plt.subplots(1, 3, figsize=(13.4, 4.7), constrained_layout=True)
179
+ for axis, case in zip(axes, cases):
180
+ axis.plot(
181
+ case["reference_x"],
182
+ case["reference_y"],
183
+ color="#e31a1c",
184
+ lw=3.2,
185
+ label="Paper Model (i)",
186
+ )
187
+ axis.plot(
188
+ case["fe_x"],
189
+ case["fe_y"],
190
+ color="#00a6a6",
191
+ lw=2.0,
192
+ ls="--",
193
+ label="AgentFEM P2 solid",
194
+ )
195
+ axis.plot(
196
+ case["discrete_x"],
197
+ case["discrete_y"],
198
+ "o-",
199
+ color="#111827",
200
+ markerfacecolor="#facc15",
201
+ markeredgecolor="#1d4ed8",
202
+ lw=1.1,
203
+ ms=3.0,
204
+ label="Paper discrete n=15",
205
+ )
206
+ axis.set_aspect("equal", adjustable="box")
207
+ axis.grid(alpha=0.18)
208
+ axis.set_xlabel(r"$x/L$")
209
+ axis.set_ylabel(r"$y/L$")
210
+ axis.set_title(
211
+ rf"$p={case['p']:.6f}$" + "\n" + rf"AgentFEM vs Model (i): {100*case['fe_nrmse']:.3f}%",
212
+ fontsize=11,
213
+ )
214
+ handles, labels = axes[0].get_legend_handles_labels()
215
+ figure.legend(handles, labels, loc="lower center", ncol=3, frameon=False)
216
+ figure.suptitle(
217
+ "Native AgentFEM finite-element reproduction of Ye et al. (2026), Figure 9\n"
218
+ + rf"P2 StVK solid; $\chi=10^{{-4}},\;\delta=0.1,\;h=0.01$",
219
+ fontsize=14,
220
+ )
221
+ figure.savefig(path, dpi=220, bbox_inches="tight", facecolor="white")
222
+ plt.close(figure)
223
+
224
+
225
+ def main():
226
+ run = project.current_run()
227
+ native = build_native_model(nx=100, ny=4)
228
+ cases = []
229
+ pvd = run.artifact("paraview/native_agentfem_fig9.pvd")
230
+ xdmf = run.artifact("xdmf/native_agentfem_fig9.xdmf")
231
+ exact = run.artifact("scientific/p2_coefficients.h5")
232
+ exact.parent.mkdir(parents=True, exist_ok=True)
233
+ with io.ParaViewTimeSeries(pvd, native["domain"]) as writer, io.XDMFTimeSeries(xdmf, native["domain"]) as xwriter, h5py.File(exact, "w") as h5:
234
+ h5.attrs["note"] = "Independent load cases, not physical time. Exact P2 coefficients; XDMF U is interpolated to P1."
235
+ h5.create_dataset("dof_coordinates", data=native["displacement"].value.function_space.tabulate_dof_coordinates())
236
+ h5.create_dataset("cell_dofs", data=native["displacement"].value.function_space.dofmap.list)
237
+ h5.attrs["element"] = "Q2 vector, block size 2, serial coefficients"
238
+ for frame, p in enumerate(LOADS):
239
+ sample, reference_x, reference_y = seed_from_reference(
240
+ native["displacement"], float(p)
241
+ )
242
+ native["load_p"].value = float(p)
243
+ native["problem"].solve()
244
+ group = h5.create_group(f"case_{frame}")
245
+ group.attrs["p"] = float(p)
246
+ group.create_dataset("U_P2", data=native["displacement"].value.x.array)
247
+ mises = native["mises"].solve()
248
+ orientation = native["orientation_energy"].solve()
249
+ xwriter.write_fields(float(frame), io.interpolate_for_xdmf(native["displacement"], name="U"), mises, orientation)
250
+ writer.write_fields(
251
+ float(frame),
252
+ native["displacement"],
253
+ mises,
254
+ orientation,
255
+ )
256
+
257
+ s, fe_x, fe_y = sample_centerline(native["displacement"])
258
+ assert fe_y[-1] < 0.0, "FE must solve the downward branch, not flip it in plotting"
259
+ group.create_dataset("centerline", data=np.column_stack([s, fe_x, fe_y]))
260
+ target_x = np.interp(s, sample, reference_x)
261
+ target_y = np.interp(s, sample, reference_y)
262
+ fe_nrmse = float(
263
+ np.sqrt(np.mean((fe_x - target_x) ** 2 + (fe_y - target_y) ** 2))
264
+ )
265
+ _, discrete_x, discrete_y = solve_discrete(float(p))
266
+ cases.append(
267
+ {
268
+ "p": float(p),
269
+ "reference_x": reference_x,
270
+ "reference_y": reference_y,
271
+ "fe_x": fe_x,
272
+ "fe_y": fe_y,
273
+ "discrete_x": discrete_x,
274
+ "discrete_y": discrete_y,
275
+ "fe_nrmse": fe_nrmse,
276
+ "fe_tip_error": float(
277
+ np.hypot(fe_x[-1] - reference_x[-1], fe_y[-1] - reference_y[-1])
278
+ ),
279
+ "newton_iterations": int(native["problem"].last_solve_info.iterations),
280
+ "residual_norm": float(native["problem"].last_solve_info.function_norm),
281
+ }
282
+ )
283
+
284
+ # DOLFINx emits one temporal collection per field. Merge attributes onto
285
+ # one geometry per case so readers do not display undeformed duplicates.
286
+ original = ET.parse(xdmf).getroot().find("Domain")
287
+ base = original.find("Grid")
288
+ merged = ET.Element("Xdmf", Version="3.0")
289
+ domain_xml = ET.SubElement(merged, "Domain")
290
+ series = ET.SubElement(domain_xml, "Grid", Name="Independent_cases", GridType="Collection", CollectionType="Temporal")
291
+ for frame in range(len(LOADS)):
292
+ grid = ET.SubElement(series, "Grid", Name=f"case_{frame}", GridType="Uniform")
293
+ grid.append(copy.deepcopy(base.find("Topology")))
294
+ grid.append(copy.deepcopy(base.find("Geometry")))
295
+ ET.SubElement(grid, "Time", Value=str(frame))
296
+ for collection in original.findall("Grid[@CollectionType='Temporal']"):
297
+ grid.append(copy.deepcopy(collection.findall("Grid")[frame].find("Attribute")))
298
+ ET.indent(merged)
299
+ ET.ElementTree(merged).write(xdmf, encoding="utf-8", xml_declaration=True)
300
+
301
+ table = np.asarray(
302
+ [
303
+ [
304
+ item["p"],
305
+ item["fe_nrmse"],
306
+ item["fe_tip_error"],
307
+ item["newton_iterations"],
308
+ item["residual_norm"],
309
+ ]
310
+ for item in cases
311
+ ]
312
+ )
313
+ metrics_path = run.artifact("native_fe_metrics.csv")
314
+ np.savetxt(
315
+ metrics_path,
316
+ table,
317
+ delimiter=",",
318
+ header="p,agentfem_centerline_nrmse_over_L,tip_error_over_L,newton_iterations,residual_norm",
319
+ comments="",
320
+ )
321
+ figure_path = run.artifact("figures/native_agentfem_vs_paper.png")
322
+ comparison_plot(figure_path, cases)
323
+
324
+ result = results.SimulationResult(
325
+ "ye_2026_fig9_native_fe",
326
+ metadata={
327
+ "paper": {
328
+ "title": "Three Homogenization Models for a Nonlinear Heterogeneous Rod with Microscale Dead Loading",
329
+ "doi": "10.1016/j.jmps.2026.106870",
330
+ "target": "Figure 9 / homogenized Model (i)",
331
+ },
332
+ "formulation": {
333
+ "mesh": f"{native['nx']} x {native['ny']} quadrilateral",
334
+ "field": "P2 displacement",
335
+ "material": "plane-stress Saint-Venant--Kirchhoff",
336
+ "microforce_term": "Eq. (42) orientation potential",
337
+ "solver": "AgentFEM Newton",
338
+ "EA": 1.0,
339
+ "EI": CHI,
340
+ "thickness": native["thickness"],
341
+ "young": native["young"],
342
+ },
343
+ },
344
+ )
345
+ result.add_history(
346
+ "centerline_nrmse",
347
+ LOADS,
348
+ np.asarray([item["fe_nrmse"] for item in cases]),
349
+ abscissa_name="dimensionless_load_p",
350
+ abscissa_unit=None,
351
+ description="RMS centerline distance normalized by L against paper Model (i).",
352
+ )
353
+ result.add_quantity("continuum_critical_load", critical_load_continuum())
354
+ result.add_quantity("discrete_n15_critical_load", critical_load_discrete())
355
+ result.add_field(
356
+ "native_agentfem_fields",
357
+ artifact=pvd,
358
+ description="ParaView PVD series containing U, MISES and MICROFORCE_POTENTIAL.",
359
+ )
360
+ result.add_artifact("comparison_figure", figure_path)
361
+ result.add_artifact("metrics", metrics_path)
362
+ result.add_artifact("exact_p2_coefficients", exact)
363
+ result.add_artifact("xdmf_p1_visualization", xdmf)
364
+ run.publish(result)
365
+ return result
366
+
367
+
368
+ if __name__ == "__main__":
369
+ main()
cases/fig9/paper_reference.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Published reduced-order reference equations for Ye et al. (2026), Fig. 9."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import numpy as np
6
+ from scipy.integrate import solve_bvp
7
+ from scipy.optimize import root
8
+
9
+
10
+ N_CELLS = 15
11
+ CHI = 1.0e-4
12
+ DELTA = 0.1
13
+ H = 0.01
14
+ LOADS = np.asarray([-0.017159, -0.016428, -0.016316])
15
+
16
+
17
+ def critical_load_continuum() -> float:
18
+ discriminant = 1.0 - np.pi**2 * CHI + 16.0 * H * DELTA
19
+ return -0.5 * (1.0 + 4.0 * H - np.sqrt(discriminant))
20
+
21
+
22
+ def critical_load_discrete() -> float:
23
+ omega2 = 4.0 * np.sin(np.pi / (2.0 * (2 * N_CELLS - 1))) ** 2
24
+ discriminant = 1.0 - 4.0 * CHI * N_CELLS**2 * omega2 + 16.0 * H * DELTA
25
+ return -0.5 * (1.0 + 4.0 * H - np.sqrt(discriminant))
26
+
27
+
28
+ def discrete_residual(unknown: np.ndarray, p: float) -> np.ndarray:
29
+ theta = np.concatenate(([0.0], np.asarray(unknown, dtype=float)))
30
+ epsilon = (p + 2.0 * H) * np.cos(theta)
31
+ l0 = 1.0 / N_CELLS
32
+ kr = CHI / l0
33
+ force_term = (
34
+ p * l0 * (1.0 + epsilon)
35
+ + 2.0 * H * l0 * (1.0 - 2.0 * DELTA + epsilon)
36
+ ) * np.sin(theta)
37
+ residual = np.empty(N_CELLS - 1)
38
+ for i in range(1, N_CELLS - 1):
39
+ residual[i - 1] = (
40
+ kr * (theta[i + 1] - 2.0 * theta[i] + theta[i - 1])
41
+ - force_term[i]
42
+ )
43
+ residual[-1] = kr * (-theta[-1] + theta[-2]) - force_term[-1]
44
+ return residual
45
+
46
+
47
+ def solve_discrete(p: float):
48
+ index = np.arange(1, N_CELLS)
49
+ mode = np.sin(np.pi * index / (2 * N_CELLS - 1))
50
+ accepted = []
51
+ for amplitude in (0.25, 0.5, 0.9, 1.4, 2.0, 2.7):
52
+ solved = root(discrete_residual, amplitude * mode, args=(p,), tol=1.0e-11)
53
+ if solved.success and np.linalg.norm(discrete_residual(solved.x, p), ord=np.inf) < 1.0e-8:
54
+ if np.max(np.abs(solved.x)) > 1.0e-3:
55
+ accepted.append(solved.x)
56
+ if not accepted:
57
+ raise RuntimeError(f"No nontrivial discrete equilibrium for p={p}")
58
+ accepted.sort(key=lambda value: np.max(np.abs(value)))
59
+ selected = accepted[0]
60
+ if np.mean(selected) > 0.0:
61
+ selected = -selected
62
+ theta = np.concatenate(([0.0], selected))
63
+ epsilon = (p + 2.0 * H) * np.cos(theta)
64
+ segment = (1.0 / N_CELLS) * (1.0 + epsilon)
65
+ x = np.concatenate(([0.0], np.cumsum(segment * np.cos(theta))))
66
+ y = np.concatenate(([0.0], np.cumsum(segment * np.sin(theta))))
67
+ return theta, x, y
68
+
69
+
70
+ def solve_continuum(p: float):
71
+ xi = np.linspace(0.0, 1.0, 401)
72
+ a = p + 2.0 * H
73
+
74
+ def ode(_, state):
75
+ theta, curvature, _, _ = state
76
+ stretch = 1.0 + a * np.cos(theta)
77
+ coefficient = (a + a**2 * np.cos(theta) - 4.0 * H * DELTA) / CHI
78
+ return np.vstack(
79
+ (
80
+ curvature,
81
+ coefficient * np.sin(theta),
82
+ stretch * np.cos(theta),
83
+ stretch * np.sin(theta),
84
+ )
85
+ )
86
+
87
+ def boundary(left, right):
88
+ return np.asarray([left[0], right[1], left[2], left[3]])
89
+
90
+ candidates = []
91
+ for amplitude in (0.35, 0.7, 1.2, 1.8, 2.5, 3.0):
92
+ initial = np.zeros((4, xi.size))
93
+ initial[0] = -amplitude * np.sin(0.5 * np.pi * xi)
94
+ initial[1] = -amplitude * 0.5 * np.pi * np.cos(0.5 * np.pi * xi)
95
+ initial[2] = xi
96
+ initial[3] = -0.15 * amplitude * xi**2
97
+ solved = solve_bvp(ode, boundary, xi, initial, tol=2.0e-8, max_nodes=30000)
98
+ if solved.success and np.max(np.abs(solved.y[0])) > 1.0e-3:
99
+ candidates.append(solved)
100
+ if not candidates:
101
+ raise RuntimeError(f"No nontrivial continuum equilibrium for p={p}")
102
+ candidates.sort(key=lambda item: np.max(np.abs(item.y[0])))
103
+ dense = np.linspace(0.0, 1.0, 601)
104
+ theta, _, x, y = candidates[0].sol(dense)
105
+ if y[-1] >= 0.0:
106
+ raise RuntimeError("Expected a genuinely downward BVP solution")
107
+ return dense, theta, x, y
native_fe/figures/native_agentfem_vs_paper.png ADDED

Git LFS Details

  • SHA256: aab6e9ddc1d9624e726319b555f77163a944eee2261b00f728990b6584cd5c6d
  • Pointer size: 131 Bytes
  • Size of remote file: 266 kB
native_fe/native_fe_metrics.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ p,agentfem_centerline_nrmse_over_L,tip_error_over_L,newton_iterations,residual_norm
2
+ -1.715900000000000064e-02,7.575428453639602815e-03,1.119233677119880511e-02,4.000000000000000000e+00,6.895025525547140624e-10
3
+ -1.642800000000000163e-02,1.757494573423452888e-03,3.422975216107892408e-03,4.000000000000000000e+00,2.715729605228601333e-13
4
+ -1.631600000000000064e-02,3.939945259508586747e-03,8.022228083031593057e-03,5.000000000000000000e+00,1.384756571661825286e-12
native_fe/paraview/native_agentfem_fig9.pvd ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <VTKFile type="Collection" version="1.0">
3
+ <Collection>
4
+ <DataSet timestep="0" part="0" file="native_agentfem_fig9000000.pvtu" />
5
+ <DataSet timestep="1" part="0" file="native_agentfem_fig9000001.pvtu" />
6
+ <DataSet timestep="2" part="0" file="native_agentfem_fig9000002.pvtu" />
7
+ </Collection>
8
+ </VTKFile>
native_fe/paraview/native_agentfem_fig9000000.pvtu ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <VTKFile type="PUnstructuredGrid" version="1.0">
3
+ <PUnstructuredGrid GhostLevel="1">
4
+ <PPointData>
5
+ <PDataArray type="Int64" Name="vtkOriginalPointIds" IdType="1" />
6
+ <PDataArray type="UInt8" Name="vtkGhostType" />
7
+ <PDataArray type="Float64" Name="U" NumberOfComponents="3" />
8
+ </PPointData>
9
+ <PCellData>
10
+ <PDataArray type="UInt8" Name="vtkGhostType" />
11
+ <PDataArray type="Int64" Name="vtkOriginalCellIds" IdType="1" />
12
+ <PDataArray type="Float64" Name="MISES" NumberOfComponents="1" />
13
+ <PDataArray type="Float64" Name="MICROFORCE_POTENTIAL" NumberOfComponents="1" />
14
+ </PCellData>
15
+ <PPoints>
16
+ <PDataArray type="Float64" NumberOfComponents="3" />
17
+ </PPoints>
18
+ <Piece Source="native_agentfem_fig9_p0_000000.vtu" />
19
+ </PUnstructuredGrid>
20
+ </VTKFile>
native_fe/paraview/native_agentfem_fig9000001.pvtu ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <VTKFile type="PUnstructuredGrid" version="1.0">
3
+ <PUnstructuredGrid GhostLevel="1">
4
+ <PPointData>
5
+ <PDataArray type="Int64" Name="vtkOriginalPointIds" IdType="1" />
6
+ <PDataArray type="UInt8" Name="vtkGhostType" />
7
+ <PDataArray type="Float64" Name="U" NumberOfComponents="3" />
8
+ </PPointData>
9
+ <PCellData>
10
+ <PDataArray type="UInt8" Name="vtkGhostType" />
11
+ <PDataArray type="Int64" Name="vtkOriginalCellIds" IdType="1" />
12
+ <PDataArray type="Float64" Name="MISES" NumberOfComponents="1" />
13
+ <PDataArray type="Float64" Name="MICROFORCE_POTENTIAL" NumberOfComponents="1" />
14
+ </PCellData>
15
+ <PPoints>
16
+ <PDataArray type="Float64" NumberOfComponents="3" />
17
+ </PPoints>
18
+ <Piece Source="native_agentfem_fig9_p0_000001.vtu" />
19
+ </PUnstructuredGrid>
20
+ </VTKFile>
native_fe/paraview/native_agentfem_fig9000002.pvtu ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <VTKFile type="PUnstructuredGrid" version="1.0">
3
+ <PUnstructuredGrid GhostLevel="1">
4
+ <PPointData>
5
+ <PDataArray type="Int64" Name="vtkOriginalPointIds" IdType="1" />
6
+ <PDataArray type="UInt8" Name="vtkGhostType" />
7
+ <PDataArray type="Float64" Name="U" NumberOfComponents="3" />
8
+ </PPointData>
9
+ <PCellData>
10
+ <PDataArray type="UInt8" Name="vtkGhostType" />
11
+ <PDataArray type="Int64" Name="vtkOriginalCellIds" IdType="1" />
12
+ <PDataArray type="Float64" Name="MISES" NumberOfComponents="1" />
13
+ <PDataArray type="Float64" Name="MICROFORCE_POTENTIAL" NumberOfComponents="1" />
14
+ </PCellData>
15
+ <PPoints>
16
+ <PDataArray type="Float64" NumberOfComponents="3" />
17
+ </PPoints>
18
+ <Piece Source="native_agentfem_fig9_p0_000002.vtu" />
19
+ </PUnstructuredGrid>
20
+ </VTKFile>
native_fe/paraview/native_agentfem_fig9_p0_000000.vtu ADDED
The diff for this file is too large to render. See raw diff
 
native_fe/paraview/native_agentfem_fig9_p0_000001.vtu ADDED
The diff for this file is too large to render. See raw diff
 
native_fe/paraview/native_agentfem_fig9_p0_000002.vtu ADDED
The diff for this file is too large to render. See raw diff
 
native_fe/paraview_checks.json ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "file": "paraview/native_agentfem_fig9.pvd",
4
+ "frames": [
5
+ {
6
+ "case_index": 0.0,
7
+ "points": 1809,
8
+ "cells": 400,
9
+ "warped_bounds": [
10
+ -0.4102637698244209,
11
+ 0.17193084453662033,
12
+ -0.5912272501257055,
13
+ 0.01732050807568877,
14
+ 0.0,
15
+ 0.0
16
+ ]
17
+ },
18
+ {
19
+ "case_index": 1.0,
20
+ "points": 1809,
21
+ "cells": 400,
22
+ "warped_bounds": [
23
+ -8.326672684688674e-19,
24
+ 0.33781986720525436,
25
+ -0.8120184934245555,
26
+ 0.01732050807568877,
27
+ 0.0,
28
+ 0.0
29
+ ]
30
+ },
31
+ {
32
+ "case_index": 2.0,
33
+ "points": 1809,
34
+ "cells": 400,
35
+ "warped_bounds": [
36
+ -8.326672684688674e-19,
37
+ 0.6275646846141524,
38
+ -0.6970659159573344,
39
+ 0.01732050807568877,
40
+ 0.0,
41
+ 0.0
42
+ ]
43
+ }
44
+ ]
45
+ },
46
+ {
47
+ "file": "xdmf/native_agentfem_fig9.xdmf",
48
+ "frames": [
49
+ {
50
+ "case_index": 0.0,
51
+ "points": 505,
52
+ "cells": 400,
53
+ "warped_bounds": [
54
+ -0.4102637767791748,
55
+ 0.17193083465099335,
56
+ -0.5912272334098816,
57
+ 0.017320508137345314,
58
+ 0.0,
59
+ 0.0
60
+ ]
61
+ },
62
+ {
63
+ "case_index": 1.0,
64
+ "points": 505,
65
+ "cells": 400,
66
+ "warped_bounds": [
67
+ -5.418929016846788e-20,
68
+ 0.3378198742866516,
69
+ -0.8120185136795044,
70
+ 0.017320508137345314,
71
+ 0.0,
72
+ 0.0
73
+ ]
74
+ },
75
+ {
76
+ "case_index": 2.0,
77
+ "points": 505,
78
+ "cells": 400,
79
+ "warped_bounds": [
80
+ -3.4813637682224506e-20,
81
+ 0.6275646686553955,
82
+ -0.6970659494400024,
83
+ 0.017320508137345314,
84
+ 0.0,
85
+ 0.0
86
+ ]
87
+ }
88
+ ]
89
+ }
90
+ ]
native_fe/scientific/p2_coefficients.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5492eef2a5f5bb0d713f8ba21c512e9f677835e0395b11900dfd4d13b08d89e1
3
+ size 178608
native_fe/xdmf/native_agentfem_fig9.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9be172050b961662fb54b57be1abffcd7698520308e804bd164677025b1d58e7
3
+ size 88096
native_fe/xdmf/native_agentfem_fig9.xdmf ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version='1.0' encoding='utf-8'?>
2
+ <Xdmf Version="3.0">
3
+ <Domain>
4
+ <Grid Name="Independent_cases" GridType="Collection" CollectionType="Temporal">
5
+ <Grid Name="case_0" GridType="Uniform">
6
+ <Topology TopologyType="Quadrilateral" NumberOfElements="400" NodesPerElement="4">
7
+ <DataItem Dimensions="400 4" NumberType="Int" Format="HDF">native_agentfem_fig9.h5:/Mesh/mesh/topology</DataItem>
8
+ </Topology>
9
+ <Geometry GeometryType="XY">
10
+ <DataItem Dimensions="505 2" Format="HDF">native_agentfem_fig9.h5:/Mesh/mesh/geometry</DataItem>
11
+ </Geometry>
12
+ <Time Value="0" />
13
+ <Attribute Name="U" AttributeType="Vector" Center="Node">
14
+ <DataItem Dimensions="505 3" Format="HDF">native_agentfem_fig9.h5:/Function/U/0</DataItem>
15
+ </Attribute>
16
+ <Attribute Name="MISES" AttributeType="Scalar" Center="Cell">
17
+ <DataItem Dimensions="400 1" Format="HDF">native_agentfem_fig9.h5:/Function/MISES/0</DataItem>
18
+ </Attribute>
19
+ <Attribute Name="MICROFORCE_POTENTIAL" AttributeType="Scalar" Center="Cell">
20
+ <DataItem Dimensions="400 1" Format="HDF">native_agentfem_fig9.h5:/Function/MICROFORCE_POTENTIAL/0</DataItem>
21
+ </Attribute>
22
+ </Grid>
23
+ <Grid Name="case_1" GridType="Uniform">
24
+ <Topology TopologyType="Quadrilateral" NumberOfElements="400" NodesPerElement="4">
25
+ <DataItem Dimensions="400 4" NumberType="Int" Format="HDF">native_agentfem_fig9.h5:/Mesh/mesh/topology</DataItem>
26
+ </Topology>
27
+ <Geometry GeometryType="XY">
28
+ <DataItem Dimensions="505 2" Format="HDF">native_agentfem_fig9.h5:/Mesh/mesh/geometry</DataItem>
29
+ </Geometry>
30
+ <Time Value="1" />
31
+ <Attribute Name="U" AttributeType="Vector" Center="Node">
32
+ <DataItem Dimensions="505 3" Format="HDF">native_agentfem_fig9.h5:/Function/U/1</DataItem>
33
+ </Attribute>
34
+ <Attribute Name="MISES" AttributeType="Scalar" Center="Cell">
35
+ <DataItem Dimensions="400 1" Format="HDF">native_agentfem_fig9.h5:/Function/MISES/1</DataItem>
36
+ </Attribute>
37
+ <Attribute Name="MICROFORCE_POTENTIAL" AttributeType="Scalar" Center="Cell">
38
+ <DataItem Dimensions="400 1" Format="HDF">native_agentfem_fig9.h5:/Function/MICROFORCE_POTENTIAL/1</DataItem>
39
+ </Attribute>
40
+ </Grid>
41
+ <Grid Name="case_2" GridType="Uniform">
42
+ <Topology TopologyType="Quadrilateral" NumberOfElements="400" NodesPerElement="4">
43
+ <DataItem Dimensions="400 4" NumberType="Int" Format="HDF">native_agentfem_fig9.h5:/Mesh/mesh/topology</DataItem>
44
+ </Topology>
45
+ <Geometry GeometryType="XY">
46
+ <DataItem Dimensions="505 2" Format="HDF">native_agentfem_fig9.h5:/Mesh/mesh/geometry</DataItem>
47
+ </Geometry>
48
+ <Time Value="2" />
49
+ <Attribute Name="U" AttributeType="Vector" Center="Node">
50
+ <DataItem Dimensions="505 3" Format="HDF">native_agentfem_fig9.h5:/Function/U/2</DataItem>
51
+ </Attribute>
52
+ <Attribute Name="MISES" AttributeType="Scalar" Center="Cell">
53
+ <DataItem Dimensions="400 1" Format="HDF">native_agentfem_fig9.h5:/Function/MISES/2</DataItem>
54
+ </Attribute>
55
+ <Attribute Name="MICROFORCE_POTENTIAL" AttributeType="Scalar" Center="Cell">
56
+ <DataItem Dimensions="400 1" Format="HDF">native_agentfem_fig9.h5:/Function/MICROFORCE_POTENTIAL/2</DataItem>
57
+ </Attribute>
58
+ </Grid>
59
+ </Grid>
60
+ </Domain>
61
+ </Xdmf>
reports/additional_baselines.json ADDED
@@ -0,0 +1,625 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "branch_conditioned_1nn": {
3
+ "centerline_rmse_over_L": 0.13898504238123274,
4
+ "tip_mean_error_over_L": 0.15082045203689934
5
+ },
6
+ "neural_batched_ms_per_state": 0.0008765032387101182,
7
+ "corrector_median_ms": 0.34977076575160027,
8
+ "corrector_checks": [
9
+ {
10
+ "id": "end_load_000_ramp_00",
11
+ "accepted": true,
12
+ "branch_preserved": true,
13
+ "tip_error": 5.713519573546008e-17
14
+ },
15
+ {
16
+ "id": "end_load_000_ramp_20",
17
+ "accepted": true,
18
+ "branch_preserved": true,
19
+ "tip_error": 1.1997663265215437e-10
20
+ },
21
+ {
22
+ "id": "end_load_000_unload_15",
23
+ "accepted": true,
24
+ "branch_preserved": true,
25
+ "tip_error": 7.290108295062502e-11
26
+ },
27
+ {
28
+ "id": "end_load_000_staged_10",
29
+ "accepted": true,
30
+ "branch_preserved": true,
31
+ "tip_error": 9.712210605662558e-11
32
+ },
33
+ {
34
+ "id": "end_load_012_ramp_05",
35
+ "accepted": true,
36
+ "branch_preserved": true,
37
+ "tip_error": 4.4713741996549127e-07
38
+ },
39
+ {
40
+ "id": "end_load_012_unload_00",
41
+ "accepted": true,
42
+ "branch_preserved": true,
43
+ "tip_error": 2.349724530588667e-11
44
+ },
45
+ {
46
+ "id": "end_load_012_unload_20",
47
+ "accepted": true,
48
+ "branch_preserved": true,
49
+ "tip_error": 1.6299620512787293e-07
50
+ },
51
+ {
52
+ "id": "end_load_012_staged_15",
53
+ "accepted": true,
54
+ "branch_preserved": true,
55
+ "tip_error": 2.8376611541645903e-12
56
+ },
57
+ {
58
+ "id": "end_load_015_ramp_10",
59
+ "accepted": true,
60
+ "branch_preserved": true,
61
+ "tip_error": 1.1892927603218958e-06
62
+ },
63
+ {
64
+ "id": "end_load_015_unload_05",
65
+ "accepted": true,
66
+ "branch_preserved": true,
67
+ "tip_error": 3.666454743459296e-12
68
+ },
69
+ {
70
+ "id": "end_load_015_staged_00",
71
+ "accepted": true,
72
+ "branch_preserved": true,
73
+ "tip_error": 3.815883427380623e-18
74
+ },
75
+ {
76
+ "id": "end_load_015_staged_20",
77
+ "accepted": true,
78
+ "branch_preserved": true,
79
+ "tip_error": 4.010247463629644e-12
80
+ },
81
+ {
82
+ "id": "end_load_017_ramp_15",
83
+ "accepted": true,
84
+ "branch_preserved": true,
85
+ "tip_error": 6.638475515026393e-10
86
+ },
87
+ {
88
+ "id": "end_load_017_unload_10",
89
+ "accepted": true,
90
+ "branch_preserved": true,
91
+ "tip_error": 6.2649249971295e-10
92
+ },
93
+ {
94
+ "id": "end_load_017_staged_05",
95
+ "accepted": true,
96
+ "branch_preserved": true,
97
+ "tip_error": 5.139535805398536e-07
98
+ },
99
+ {
100
+ "id": "end_load_034_ramp_00",
101
+ "accepted": true,
102
+ "branch_preserved": true,
103
+ "tip_error": 4.910984090454133e-17
104
+ },
105
+ {
106
+ "id": "end_load_034_ramp_20",
107
+ "accepted": true,
108
+ "branch_preserved": true,
109
+ "tip_error": 1.2253298143879764e-11
110
+ },
111
+ {
112
+ "id": "end_load_034_unload_15",
113
+ "accepted": true,
114
+ "branch_preserved": true,
115
+ "tip_error": 4.665351948252804e-06
116
+ },
117
+ {
118
+ "id": "end_load_034_staged_10",
119
+ "accepted": true,
120
+ "branch_preserved": true,
121
+ "tip_error": 5.873060257541643e-13
122
+ },
123
+ {
124
+ "id": "end_load_037_ramp_05",
125
+ "accepted": true,
126
+ "branch_preserved": true,
127
+ "tip_error": 7.259387172620046e-08
128
+ },
129
+ {
130
+ "id": "end_load_037_unload_00",
131
+ "accepted": true,
132
+ "branch_preserved": true,
133
+ "tip_error": 3.1549746482562244e-09
134
+ },
135
+ {
136
+ "id": "end_load_037_unload_20",
137
+ "accepted": true,
138
+ "branch_preserved": true,
139
+ "tip_error": 8.430107338688936e-08
140
+ },
141
+ {
142
+ "id": "end_load_037_staged_15",
143
+ "accepted": true,
144
+ "branch_preserved": true,
145
+ "tip_error": 2.333017023396121e-07
146
+ },
147
+ {
148
+ "id": "end_load_040_ramp_10",
149
+ "accepted": true,
150
+ "branch_preserved": true,
151
+ "tip_error": 1.6542147378324227e-09
152
+ },
153
+ {
154
+ "id": "end_load_040_unload_05",
155
+ "accepted": true,
156
+ "branch_preserved": true,
157
+ "tip_error": 2.123356214112997e-09
158
+ },
159
+ {
160
+ "id": "end_load_040_staged_00",
161
+ "accepted": true,
162
+ "branch_preserved": true,
163
+ "tip_error": 1.0089630592240623e-16
164
+ },
165
+ {
166
+ "id": "end_load_040_staged_20",
167
+ "accepted": true,
168
+ "branch_preserved": true,
169
+ "tip_error": 2.1906716409310014e-09
170
+ },
171
+ {
172
+ "id": "end_load_050_ramp_15",
173
+ "accepted": true,
174
+ "branch_preserved": true,
175
+ "tip_error": 2.745436766772867e-06
176
+ },
177
+ {
178
+ "id": "end_load_050_unload_10",
179
+ "accepted": true,
180
+ "branch_preserved": true,
181
+ "tip_error": 3.6682109332775024e-06
182
+ },
183
+ {
184
+ "id": "end_load_050_staged_05",
185
+ "accepted": true,
186
+ "branch_preserved": true,
187
+ "tip_error": 9.55561598569722e-07
188
+ },
189
+ {
190
+ "id": "end_load_054_ramp_00",
191
+ "accepted": true,
192
+ "branch_preserved": true,
193
+ "tip_error": 1.189347195671338e-17
194
+ },
195
+ {
196
+ "id": "end_load_054_ramp_20",
197
+ "accepted": true,
198
+ "branch_preserved": true,
199
+ "tip_error": 2.0095102567616816e-06
200
+ },
201
+ {
202
+ "id": "end_load_054_unload_15",
203
+ "accepted": true,
204
+ "branch_preserved": true,
205
+ "tip_error": 2.9869502978294934e-06
206
+ },
207
+ {
208
+ "id": "end_load_054_staged_10",
209
+ "accepted": true,
210
+ "branch_preserved": true,
211
+ "tip_error": 1.1405695879619652e-06
212
+ },
213
+ {
214
+ "id": "intrinsic_curvature_001_ramp_05",
215
+ "accepted": true,
216
+ "branch_preserved": true,
217
+ "tip_error": 1.2188344440854238e-11
218
+ },
219
+ {
220
+ "id": "intrinsic_curvature_001_unload_00",
221
+ "accepted": true,
222
+ "branch_preserved": true,
223
+ "tip_error": 6.070421348564216e-09
224
+ },
225
+ {
226
+ "id": "intrinsic_curvature_001_unload_20",
227
+ "accepted": true,
228
+ "branch_preserved": true,
229
+ "tip_error": 6.279524867416008e-12
230
+ },
231
+ {
232
+ "id": "intrinsic_curvature_001_staged_15",
233
+ "accepted": true,
234
+ "branch_preserved": true,
235
+ "tip_error": 1.0282430084674248e-10
236
+ },
237
+ {
238
+ "id": "intrinsic_curvature_002_ramp_10",
239
+ "accepted": true,
240
+ "branch_preserved": true,
241
+ "tip_error": 2.830062791762887e-12
242
+ },
243
+ {
244
+ "id": "intrinsic_curvature_002_unload_05",
245
+ "accepted": true,
246
+ "branch_preserved": true,
247
+ "tip_error": 1.7045955868265643e-11
248
+ },
249
+ {
250
+ "id": "intrinsic_curvature_002_staged_00",
251
+ "accepted": true,
252
+ "branch_preserved": true,
253
+ "tip_error": 2.5989229576287947e-17
254
+ },
255
+ {
256
+ "id": "intrinsic_curvature_002_staged_20",
257
+ "accepted": true,
258
+ "branch_preserved": true,
259
+ "tip_error": 2.2576685904069937e-10
260
+ },
261
+ {
262
+ "id": "intrinsic_curvature_007_ramp_15",
263
+ "accepted": true,
264
+ "branch_preserved": true,
265
+ "tip_error": 7.550331073633704e-11
266
+ },
267
+ {
268
+ "id": "intrinsic_curvature_007_unload_10",
269
+ "accepted": true,
270
+ "branch_preserved": true,
271
+ "tip_error": 7.436805524774105e-11
272
+ },
273
+ {
274
+ "id": "intrinsic_curvature_007_staged_05",
275
+ "accepted": true,
276
+ "branch_preserved": true,
277
+ "tip_error": 3.481135094081288e-07
278
+ },
279
+ {
280
+ "id": "intrinsic_curvature_014_ramp_00",
281
+ "accepted": true,
282
+ "branch_preserved": true,
283
+ "tip_error": 2.3030261147212925e-17
284
+ },
285
+ {
286
+ "id": "intrinsic_curvature_014_ramp_20",
287
+ "accepted": true,
288
+ "branch_preserved": true,
289
+ "tip_error": 2.7479332855005862e-09
290
+ },
291
+ {
292
+ "id": "intrinsic_curvature_014_unload_15",
293
+ "accepted": true,
294
+ "branch_preserved": true,
295
+ "tip_error": 2.950730575812304e-11
296
+ },
297
+ {
298
+ "id": "intrinsic_curvature_014_staged_10",
299
+ "accepted": true,
300
+ "branch_preserved": true,
301
+ "tip_error": 1.5207153454372993e-09
302
+ },
303
+ {
304
+ "id": "intrinsic_curvature_026_ramp_05",
305
+ "accepted": true,
306
+ "branch_preserved": true,
307
+ "tip_error": 6.561980104684226e-07
308
+ },
309
+ {
310
+ "id": "intrinsic_curvature_026_unload_00",
311
+ "accepted": true,
312
+ "branch_preserved": true,
313
+ "tip_error": 1.1102247340114048e-08
314
+ },
315
+ {
316
+ "id": "intrinsic_curvature_026_unload_20",
317
+ "accepted": true,
318
+ "branch_preserved": true,
319
+ "tip_error": 5.208375532011217e-07
320
+ },
321
+ {
322
+ "id": "intrinsic_curvature_026_staged_15",
323
+ "accepted": true,
324
+ "branch_preserved": true,
325
+ "tip_error": 7.364085678097339e-09
326
+ },
327
+ {
328
+ "id": "intrinsic_curvature_030_ramp_10",
329
+ "accepted": true,
330
+ "branch_preserved": true,
331
+ "tip_error": 1.1005130722312953e-11
332
+ },
333
+ {
334
+ "id": "intrinsic_curvature_030_unload_05",
335
+ "accepted": true,
336
+ "branch_preserved": true,
337
+ "tip_error": 1.1405395889319545e-10
338
+ },
339
+ {
340
+ "id": "intrinsic_curvature_030_staged_00",
341
+ "accepted": true,
342
+ "branch_preserved": true,
343
+ "tip_error": 3.219402825924145e-17
344
+ },
345
+ {
346
+ "id": "intrinsic_curvature_030_staged_20",
347
+ "accepted": true,
348
+ "branch_preserved": true,
349
+ "tip_error": 2.3063564718432202e-10
350
+ },
351
+ {
352
+ "id": "intrinsic_curvature_034_ramp_15",
353
+ "accepted": true,
354
+ "branch_preserved": true,
355
+ "tip_error": 4.394481302590971e-11
356
+ },
357
+ {
358
+ "id": "intrinsic_curvature_034_unload_10",
359
+ "accepted": true,
360
+ "branch_preserved": true,
361
+ "tip_error": 1.7996602804957778e-11
362
+ },
363
+ {
364
+ "id": "intrinsic_curvature_034_staged_05",
365
+ "accepted": true,
366
+ "branch_preserved": true,
367
+ "tip_error": 8.773624015527173e-13
368
+ },
369
+ {
370
+ "id": "intrinsic_curvature_036_ramp_00",
371
+ "accepted": true,
372
+ "branch_preserved": true,
373
+ "tip_error": 4.634964287375531e-18
374
+ },
375
+ {
376
+ "id": "intrinsic_curvature_036_ramp_20",
377
+ "accepted": true,
378
+ "branch_preserved": true,
379
+ "tip_error": 1.348864169653577e-11
380
+ },
381
+ {
382
+ "id": "intrinsic_curvature_036_unload_15",
383
+ "accepted": true,
384
+ "branch_preserved": true,
385
+ "tip_error": 1.2003039457884168e-11
386
+ },
387
+ {
388
+ "id": "intrinsic_curvature_036_staged_10",
389
+ "accepted": true,
390
+ "branch_preserved": true,
391
+ "tip_error": 2.857402141123093e-09
392
+ },
393
+ {
394
+ "id": "intrinsic_curvature_049_ramp_05",
395
+ "accepted": true,
396
+ "branch_preserved": true,
397
+ "tip_error": 6.077877782048024e-08
398
+ },
399
+ {
400
+ "id": "intrinsic_curvature_049_unload_00",
401
+ "accepted": true,
402
+ "branch_preserved": true,
403
+ "tip_error": 1.9982613712293267e-09
404
+ },
405
+ {
406
+ "id": "intrinsic_curvature_049_unload_20",
407
+ "accepted": true,
408
+ "branch_preserved": true,
409
+ "tip_error": 6.836604854617364e-08
410
+ },
411
+ {
412
+ "id": "intrinsic_curvature_049_staged_15",
413
+ "accepted": true,
414
+ "branch_preserved": true,
415
+ "tip_error": 4.083441044428953e-07
416
+ },
417
+ {
418
+ "id": "microforce_001_down_10",
419
+ "accepted": true,
420
+ "branch_preserved": true,
421
+ "tip_error": 2.7517764614967345e-06
422
+ },
423
+ {
424
+ "id": "microforce_001_straight_05",
425
+ "accepted": true,
426
+ "branch_preserved": true,
427
+ "tip_error": 5.768912148970819e-07
428
+ },
429
+ {
430
+ "id": "microforce_001_up_00",
431
+ "accepted": true,
432
+ "branch_preserved": true,
433
+ "tip_error": 1.3670849271572689e-06
434
+ },
435
+ {
436
+ "id": "microforce_001_up_20",
437
+ "accepted": true,
438
+ "branch_preserved": true,
439
+ "tip_error": 1.1095390603831054e-07
440
+ },
441
+ {
442
+ "id": "microforce_009_down_15",
443
+ "accepted": true,
444
+ "branch_preserved": true,
445
+ "tip_error": 1.791408572988469e-07
446
+ },
447
+ {
448
+ "id": "microforce_009_straight_10",
449
+ "accepted": true,
450
+ "branch_preserved": true,
451
+ "tip_error": 4.8630567980386464e-08
452
+ },
453
+ {
454
+ "id": "microforce_009_up_05",
455
+ "accepted": true,
456
+ "branch_preserved": true,
457
+ "tip_error": 1.0718840963745841e-07
458
+ },
459
+ {
460
+ "id": "microforce_010_down_00",
461
+ "accepted": true,
462
+ "branch_preserved": true,
463
+ "tip_error": 3.480849816897002e-08
464
+ },
465
+ {
466
+ "id": "microforce_010_down_20",
467
+ "accepted": true,
468
+ "branch_preserved": true,
469
+ "tip_error": 1.1958511977095623e-08
470
+ },
471
+ {
472
+ "id": "microforce_010_straight_15",
473
+ "accepted": true,
474
+ "branch_preserved": true,
475
+ "tip_error": 9.700193205386223e-11
476
+ },
477
+ {
478
+ "id": "microforce_010_up_10",
479
+ "accepted": true,
480
+ "branch_preserved": true,
481
+ "tip_error": 7.186442512894125e-07
482
+ },
483
+ {
484
+ "id": "microforce_029_down_05",
485
+ "accepted": true,
486
+ "branch_preserved": true,
487
+ "tip_error": 2.8097916963807202e-09
488
+ },
489
+ {
490
+ "id": "microforce_029_straight_00",
491
+ "accepted": true,
492
+ "branch_preserved": true,
493
+ "tip_error": 1.5923767705948783e-08
494
+ },
495
+ {
496
+ "id": "microforce_029_straight_20",
497
+ "accepted": true,
498
+ "branch_preserved": true,
499
+ "tip_error": 1.1465258978568242e-08
500
+ },
501
+ {
502
+ "id": "microforce_029_up_15",
503
+ "accepted": true,
504
+ "branch_preserved": true,
505
+ "tip_error": 1.4023108406382885e-07
506
+ },
507
+ {
508
+ "id": "microforce_031_down_10",
509
+ "accepted": true,
510
+ "branch_preserved": true,
511
+ "tip_error": 2.1323890663030994e-06
512
+ },
513
+ {
514
+ "id": "microforce_031_straight_05",
515
+ "accepted": true,
516
+ "branch_preserved": true,
517
+ "tip_error": 1.8737178237880017e-07
518
+ },
519
+ {
520
+ "id": "microforce_031_up_00",
521
+ "accepted": true,
522
+ "branch_preserved": true,
523
+ "tip_error": 1.1751143881128007e-06
524
+ },
525
+ {
526
+ "id": "microforce_031_up_20",
527
+ "accepted": true,
528
+ "branch_preserved": true,
529
+ "tip_error": 4.2569030372265784e-08
530
+ },
531
+ {
532
+ "id": "microforce_033_down_15",
533
+ "accepted": true,
534
+ "branch_preserved": true,
535
+ "tip_error": 9.136252812365038e-08
536
+ },
537
+ {
538
+ "id": "microforce_033_straight_10",
539
+ "accepted": true,
540
+ "branch_preserved": true,
541
+ "tip_error": 2.240343447720724e-08
542
+ },
543
+ {
544
+ "id": "microforce_033_up_05",
545
+ "accepted": true,
546
+ "branch_preserved": true,
547
+ "tip_error": 2.6297745247689965e-09
548
+ },
549
+ {
550
+ "id": "microforce_037_down_00",
551
+ "accepted": true,
552
+ "branch_preserved": true,
553
+ "tip_error": 1.134554997372794e-06
554
+ },
555
+ {
556
+ "id": "microforce_037_down_20",
557
+ "accepted": true,
558
+ "branch_preserved": true,
559
+ "tip_error": 1.1229456873087092e-07
560
+ },
561
+ {
562
+ "id": "microforce_037_straight_15",
563
+ "accepted": true,
564
+ "branch_preserved": true,
565
+ "tip_error": 1.0649448688240376e-07
566
+ },
567
+ {
568
+ "id": "microforce_037_up_10",
569
+ "accepted": true,
570
+ "branch_preserved": true,
571
+ "tip_error": 2.4869383910580255e-06
572
+ },
573
+ {
574
+ "id": "microforce_047_down_05",
575
+ "accepted": true,
576
+ "branch_preserved": true,
577
+ "tip_error": 3.152254769359579e-06
578
+ },
579
+ {
580
+ "id": "microforce_047_straight_00",
581
+ "accepted": true,
582
+ "branch_preserved": true,
583
+ "tip_error": 7.818380700057634e-09
584
+ },
585
+ {
586
+ "id": "microforce_047_straight_20",
587
+ "accepted": true,
588
+ "branch_preserved": true,
589
+ "tip_error": 1.5431327401546222e-08
590
+ },
591
+ {
592
+ "id": "microforce_047_up_15",
593
+ "accepted": true,
594
+ "branch_preserved": true,
595
+ "tip_error": 3.8964605452957895e-07
596
+ },
597
+ {
598
+ "id": "microforce_055_down_10",
599
+ "accepted": true,
600
+ "branch_preserved": true,
601
+ "tip_error": 2.6380689401879157e-06
602
+ },
603
+ {
604
+ "id": "microforce_055_straight_05",
605
+ "accepted": true,
606
+ "branch_preserved": true,
607
+ "tip_error": 8.820089710383261e-08
608
+ },
609
+ {
610
+ "id": "microforce_055_up_00",
611
+ "accepted": true,
612
+ "branch_preserved": true,
613
+ "tip_error": 6.329517053747379e-07
614
+ },
615
+ {
616
+ "id": "microforce_055_up_20",
617
+ "accepted": true,
618
+ "branch_preserved": true,
619
+ "tip_error": 8.086550582849113e-08
620
+ }
621
+ ],
622
+ "number_scenes": 216,
623
+ "number_paths": 648,
624
+ "sampled_stable_pairs": 13654
625
+ }
reports/baselines.json ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "ordinary": {
3
+ "training_seconds": 9.469062707852572,
4
+ "best_validation_angle_mse": 0.5325946807861328,
5
+ "best_epoch": 175,
6
+ "splits": {
7
+ "train": {
8
+ "states": 9450,
9
+ "centerline_rmse_over_L": 0.2876402123158852,
10
+ "tip_mean_error_over_L": 0.2758412063003781,
11
+ "tip_p95_error_over_L": 1.3709718723783264,
12
+ "branch_accuracy": 0.7560846560846561,
13
+ "families": {
14
+ "end_load": {
15
+ "centerline_rmse_over_L": 0.008660688386444413,
16
+ "tip_mean_error_over_L": 0.010720162702538583
17
+ },
18
+ "intrinsic_curvature": {
19
+ "centerline_rmse_over_L": 0.017302987509425837,
20
+ "tip_mean_error_over_L": 0.02753935074302976
21
+ },
22
+ "microforce": {
23
+ "centerline_rmse_over_L": 0.4978315722443727,
24
+ "tip_mean_error_over_L": 0.789264105455566
25
+ }
26
+ }
27
+ },
28
+ "validation": {
29
+ "states": 2025,
30
+ "centerline_rmse_over_L": 0.2772618309801568,
31
+ "tip_mean_error_over_L": 0.26522754817754857,
32
+ "tip_p95_error_over_L": 1.350459783369911,
33
+ "branch_accuracy": 0.7550617283950617,
34
+ "families": {
35
+ "end_load": {
36
+ "centerline_rmse_over_L": 0.0054981715867303375,
37
+ "tip_mean_error_over_L": 0.007655388366930514
38
+ },
39
+ "intrinsic_curvature": {
40
+ "centerline_rmse_over_L": 0.02199192544955959,
41
+ "tip_mean_error_over_L": 0.029069048383501175
42
+ },
43
+ "microforce": {
44
+ "centerline_rmse_over_L": 0.4796962518924147,
45
+ "tip_mean_error_over_L": 0.758958207782214
46
+ }
47
+ }
48
+ },
49
+ "test": {
50
+ "states": 2025,
51
+ "centerline_rmse_over_L": 0.27097307618454236,
52
+ "tip_mean_error_over_L": 0.26332069407816006,
53
+ "tip_p95_error_over_L": 1.324666341267705,
54
+ "branch_accuracy": 0.7595061728395062,
55
+ "families": {
56
+ "end_load": {
57
+ "centerline_rmse_over_L": 0.01258676348938492,
58
+ "tip_mean_error_over_L": 0.017343709033959896
59
+ },
60
+ "intrinsic_curvature": {
61
+ "centerline_rmse_over_L": 0.018546808034216416,
62
+ "tip_mean_error_over_L": 0.028707976863230157
63
+ },
64
+ "microforce": {
65
+ "centerline_rmse_over_L": 0.46880359783959163,
66
+ "tip_mean_error_over_L": 0.7439103963372901
67
+ }
68
+ }
69
+ },
70
+ "parameter_ood": {
71
+ "states": 2700,
72
+ "centerline_rmse_over_L": 0.31099709293692207,
73
+ "tip_mean_error_over_L": 0.3105775533562281,
74
+ "tip_p95_error_over_L": 1.4254575954845419,
75
+ "branch_accuracy": 0.7307407407407407,
76
+ "families": {
77
+ "end_load": {
78
+ "centerline_rmse_over_L": 0.016934717319539314,
79
+ "tip_mean_error_over_L": 0.026384041569860444
80
+ },
81
+ "intrinsic_curvature": {
82
+ "centerline_rmse_over_L": 0.034150610882093556,
83
+ "tip_mean_error_over_L": 0.051634731786840624
84
+ },
85
+ "microforce": {
86
+ "centerline_rmse_over_L": 0.5373123175317468,
87
+ "tip_mean_error_over_L": 0.8537138867119832
88
+ }
89
+ }
90
+ }
91
+ }
92
+ },
93
+ "branch_conditioned": {
94
+ "training_seconds": 10.021918333135545,
95
+ "best_validation_angle_mse": 0.0003538956225384027,
96
+ "best_epoch": 373,
97
+ "splits": {
98
+ "train": {
99
+ "states": 9450,
100
+ "centerline_rmse_over_L": 0.0036564542466527806,
101
+ "tip_mean_error_over_L": 0.004660886595197838,
102
+ "tip_p95_error_over_L": 0.013352837772448264,
103
+ "branch_accuracy": 0.951005291005291,
104
+ "families": {
105
+ "end_load": {
106
+ "centerline_rmse_over_L": 0.001954592498102367,
107
+ "tip_mean_error_over_L": 0.002872378421773722
108
+ },
109
+ "intrinsic_curvature": {
110
+ "centerline_rmse_over_L": 0.0030893070908413777,
111
+ "tip_mean_error_over_L": 0.004508324274736663
112
+ },
113
+ "microforce": {
114
+ "centerline_rmse_over_L": 0.005171530028766592,
115
+ "tip_mean_error_over_L": 0.006601957089083131
116
+ }
117
+ }
118
+ },
119
+ "validation": {
120
+ "states": 2025,
121
+ "centerline_rmse_over_L": 0.007790775422665098,
122
+ "tip_mean_error_over_L": 0.00850362012458513,
123
+ "tip_p95_error_over_L": 0.030204327965714442,
124
+ "branch_accuracy": 0.9432098765432099,
125
+ "families": {
126
+ "end_load": {
127
+ "centerline_rmse_over_L": 0.002559192870527483,
128
+ "tip_mean_error_over_L": 0.0036740723304681737
129
+ },
130
+ "intrinsic_curvature": {
131
+ "centerline_rmse_over_L": 0.012074923761816205,
132
+ "tip_mean_error_over_L": 0.014751192088026343
133
+ },
134
+ "microforce": {
135
+ "centerline_rmse_over_L": 0.005453007707401057,
136
+ "tip_mean_error_over_L": 0.007085595955260876
137
+ }
138
+ }
139
+ },
140
+ "test": {
141
+ "states": 2025,
142
+ "centerline_rmse_over_L": 0.006606571244686814,
143
+ "tip_mean_error_over_L": 0.00783664011337499,
144
+ "tip_p95_error_over_L": 0.027372971794891447,
145
+ "branch_accuracy": 0.9274074074074075,
146
+ "families": {
147
+ "end_load": {
148
+ "centerline_rmse_over_L": 0.004345665533552764,
149
+ "tip_mean_error_over_L": 0.005946189596474241
150
+ },
151
+ "intrinsic_curvature": {
152
+ "centerline_rmse_over_L": 0.009162369474475147,
153
+ "tip_mean_error_over_L": 0.010607649815447867
154
+ },
155
+ "microforce": {
156
+ "centerline_rmse_over_L": 0.005301558970441207,
157
+ "tip_mean_error_over_L": 0.006956080928202864
158
+ }
159
+ }
160
+ },
161
+ "parameter_ood": {
162
+ "states": 2700,
163
+ "centerline_rmse_over_L": 0.009411141971015478,
164
+ "tip_mean_error_over_L": 0.010912692785005286,
165
+ "tip_p95_error_over_L": 0.042834881364826174,
166
+ "branch_accuracy": 0.9022222222222223,
167
+ "families": {
168
+ "end_load": {
169
+ "centerline_rmse_over_L": 0.0038858871588121832,
170
+ "tip_mean_error_over_L": 0.0060025543991917025
171
+ },
172
+ "intrinsic_curvature": {
173
+ "centerline_rmse_over_L": 0.014754143191724783,
174
+ "tip_mean_error_over_L": 0.018902846975711853
175
+ },
176
+ "microforce": {
177
+ "centerline_rmse_over_L": 0.00573793684723761,
178
+ "tip_mean_error_over_L": 0.007832676980112299
179
+ }
180
+ }
181
+ }
182
+ }
183
+ }
184
+ }
reports/environment.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "numpy": "2.4.6",
3
+ "scipy": "1.17.1",
4
+ "torch": "2.13.0",
5
+ "safetensors": "0.8.0",
6
+ "matplotlib": "3.11.0",
7
+ "h5py": "3.16.0",
8
+ "python": "3.11.15",
9
+ "platform": "macOS-26.6.2-arm64-arm-64bit",
10
+ "agentfem_commit": "36f4c1b06ce8a37988eea50bd139fd2d3513985d"
11
+ }
reports/generation.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "0.1.0",
3
+ "seed": 20261014,
4
+ "accepted_states": 16200,
5
+ "rejected_attempts": 0,
6
+ "scenes": 216,
7
+ "paired_resolution_cases": 216,
8
+ "seconds": 7.868317000102252,
9
+ "splits": {
10
+ "train": 9450,
11
+ "validation": 2025,
12
+ "test": 2025,
13
+ "parameter_ood": 2700
14
+ },
15
+ "families": {
16
+ "end_load": 5400,
17
+ "intrinsic_curvature": 5400,
18
+ "microforce": 5400
19
+ },
20
+ "stability": {
21
+ "stable": 14400,
22
+ "unstable": 1800,
23
+ "critical": 0
24
+ },
25
+ "max_residual": 9.981284949452698e-11,
26
+ "mesh_audit_max_rmse": 0.00017190907534690302,
27
+ "mesh_audit_median_rmse": 4.567330866247305e-05,
28
+ "python": "3.11.15",
29
+ "numpy": "2.4.6"
30
+ }
reports/inverse_checks.json ADDED
The diff for this file is too large to render. See raw diff
 
reports/validation.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "gradient_fd_max_abs": 9.39636538607562e-13,
3
+ "hessian_fd_max_abs": 8.915951310584092e-12,
4
+ "axial_tip_error": 4.440892098500626e-16,
5
+ "circular_tip_errors_n24_48_96": [
6
+ 9.803535554763446e-05,
7
+ 2.4507498546971404e-05,
8
+ 6.1267908707274595e-06
9
+ ],
10
+ "critical_load_analytic": -0.016260722307687474,
11
+ "critical_load_discrete_rod96": -0.016260733236409513,
12
+ "critical_load_error": 1.092872203845019e-08,
13
+ "fig9_rod96_centerline_rmse_over_L": [
14
+ 5.866723365639996e-05,
15
+ 3.3195723854766535e-05,
16
+ 4.0061907625982e-05
17
+ ],
18
+ "fig9_chain_tip_errors_n15_30_60_120": [
19
+ [
20
+ 0.06878181113063606,
21
+ 0.03458991708982865,
22
+ 0.017347626270992015,
23
+ 0.00868715805212931
24
+ ],
25
+ [
26
+ 0.10183627474426794,
27
+ 0.05039220186844308,
28
+ 0.02507094317590472,
29
+ 0.012504879101960199
30
+ ],
31
+ [
32
+ 0.16309490255187659,
33
+ 0.07830363538498472,
34
+ 0.03844061583017705,
35
+ 0.01905561851287658
36
+ ]
37
+ ],
38
+ "chain_critical_eigenvalue": -1.412907187228135e-13,
39
+ "passed": true
40
+ }
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ numpy>=2.0,<3
2
+ scipy>=1.14,<2
3
+ torch>=2.4,<3
4
+ safetensors>=0.4,<1
5
+ matplotlib>=3.8,<4
6
+ h5py>=3.10,<4
src/generate.py ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Grouped deterministic equilibrium dataset; no physical-time claims."""
2
+ from pathlib import Path
3
+ from dataclasses import asdict
4
+ import json,time,platform,hashlib
5
+ import numpy as np
6
+ from rod import Rod,Controls,serial
7
+
8
+ ROOT=Path(__file__).resolve().parents[1]
9
+
10
+ def generate():
11
+ rng=np.random.default_rng(20261014)
12
+ r=Rod(48); records=[]; rejected=[]; audits=[]
13
+ start=time.perf_counter()
14
+ # Each family has 60 ID scenes and 12 parameter-OOD scenes; all paths and
15
+ # mirrored branches of a scene share a single split.
16
+ for family in ['end_load','intrinsic_curvature','microforce']:
17
+ order=rng.permutation(60)
18
+ assignment={int(j):('train' if i<42 else 'validation' if i<51 else 'test') for i,j in enumerate(order)}
19
+ for j in range(72):
20
+ split=assignment[j] if j<60 else 'parameter_ood'
21
+ scene=f'{family}_{j:03d}'
22
+ chi=float(10**rng.uniform(-4,-2.5)) if j<60 else float(10**rng.uniform(-2.5,-2.1))
23
+ base=Controls(chi=chi)
24
+ if family=='microforce':
25
+ base.h=float(chi*rng.uniform(4,30));base.delta=float(rng.uniform(.05,.35))
26
+ pc=(-1+np.sqrt(1+16*base.h*base.delta-np.pi**2*chi))/2-2*base.h
27
+ paths=['down','straight','up']
28
+ maxcompression=float(rng.uniform(2,8))
29
+ else:
30
+ fx=float(chi*rng.uniform(0,2));fy=float(chi*rng.uniform(-2,2));moment=float(chi*rng.uniform(-1,1))
31
+ ks=rng.uniform(-2.4,2.4,3) if family=='intrinsic_curvature' else np.zeros(3)
32
+ paths=['ramp','unload','staged']
33
+ for path in paths:
34
+ prev=None
35
+ for step,t in enumerate(np.linspace(0,1,25)):
36
+ c=Controls(**asdict(base))
37
+ seed_source='previous_equilibrium' if prev is not None else 'zero'
38
+ seed=None if prev is None else prev['z']
39
+ if family=='microforce':
40
+ # All points below the first critical load; these are branch
41
+ # sweeps, NOT claims about spontaneous branch selection.
42
+ c.fx=float(pc-chi*(.2+(maxcompression-.2)*t))
43
+ sign={'down':-1,'straight':0,'up':1}[path]
44
+ if prev is None:
45
+ seed=r.mode_seed(sign*1.2);seed_source='signed_mode_initialization'
46
+ if sign==0:seed=np.zeros(r.d);seed_source='exact_straight'
47
+ else:
48
+ alpha=float(1-t if path=='unload' else t)
49
+ c.fx=fx*alpha;c.fy=fy*alpha;c.moment=moment*alpha
50
+ ramps=np.clip(3*alpha-np.arange(3),0,1) if path=='staged' else np.full(3,alpha)
51
+ c.k1,c.k2,c.k3=map(float,ks*ramps)
52
+ result=r.solve(c,seed)
53
+ if family=='microforce' and path!='straight' and (result['tip'][1]*sign<1e-4 or not result['accepted']):
54
+ for amp in [.6,1.6,2.5,3.]:
55
+ result=r.solve(c,r.mode_seed(sign*amp));seed_source='signed_mode_retry'
56
+ if result['accepted'] and result['tip'][1]*sign>1e-4:break
57
+ valid=result['accepted']
58
+ if family=='microforce' and path!='straight':valid &= result['tip'][1]*sign>1e-4
59
+ row=dict(id=f'{scene}_{path}_{step:02d}',scene_id=scene,split=split,family=family,
60
+ path_id=f'{scene}_{path}',path_kind=path,step=step,path_parameter=float(t),
61
+ controls=asdict(c),model='angle_FE_midpoint_n48',seed_source=seed_source,**serial(result))
62
+ row['branch']='straight' if np.max(np.abs(result['z']))<1e-5 else ('up' if result['tip'][1]>0 else 'down')
63
+ row['previous_id']=None if prev is None else prev['id']
64
+ row['continuous_stable_pair']=bool(prev is not None and prev['stability']=='stable' and result['stability']=='stable' and np.max(np.abs(prev['z']-result['z']))<.2)
65
+ if valid:
66
+ records.append(row);prev={**result,'id':row['id']}
67
+ else:
68
+ rejected.append(row);prev=None
69
+ # One paired mesh audit per scenario, assigned the same scene/split.
70
+ if path==paths[-1] and prev is not None:
71
+ fine=Rod(96)
72
+ seed=np.interp(np.linspace(0,1,97)[1:],np.linspace(0,1,49),np.r_[0,prev['z']])
73
+ f=fine.solve(c,seed)
74
+ audits.append(dict(scene_id=scene,split=split,coarse_id=prev['id'],controls=asdict(c),
75
+ fine=serial(f),centerline_rmse=float(np.sqrt(np.mean(np.sum((f['centerline']-prev['centerline'])**2,axis=1))))))
76
+ if j%12==0:print(f'{family} {j}/72: accepted={len(records)} rejected={len(rejected)}',flush=True)
77
+ out=ROOT/'data';out.mkdir(exist_ok=True)
78
+ for name,rows in [('equilibria',records),('rejected_attempts',rejected),('paired_resolution',audits)]:
79
+ with (out/f'{name}.jsonl').open('w') as f:
80
+ for row in rows:f.write(json.dumps(row,allow_nan=False,separators=(',',':'))+'\n')
81
+ summary=dict(version='0.1.0',seed=20261014,accepted_states=len(records),rejected_attempts=len(rejected),scenes=216,
82
+ paired_resolution_cases=len(audits),seconds=time.perf_counter()-start,
83
+ splits={s:sum(v['split']==s for v in records) for s in ['train','validation','test','parameter_ood']},
84
+ families={s:sum(v['family']==s for v in records) for s in ['end_load','intrinsic_curvature','microforce']},
85
+ stability={s:sum(v['stability']==s for v in records) for s in ['stable','unstable','critical']},
86
+ max_residual=max(v['residual'] for v in records),
87
+ mesh_audit_max_rmse=max(v['centerline_rmse'] for v in audits),
88
+ mesh_audit_median_rmse=float(np.median([v['centerline_rmse'] for v in audits])),
89
+ python=platform.python_version(),numpy=np.__version__)
90
+ # Guard against leakage and malformed paths before publication.
91
+ grouped={}
92
+ for v in records:grouped.setdefault(v['scene_id'],set()).add(v['split'])
93
+ assert all(len(s)==1 for s in grouped.values())
94
+ assert all(v['fine']['accepted'] for v in audits)
95
+ (ROOT/'reports/generation.json').write_text(json.dumps(summary,indent=2))
96
+ print(json.dumps(summary,indent=2))
97
+
98
+ if __name__=='__main__':generate()
src/inference.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Load safetensors baseline; optionally correct using the released mechanics."""
2
+ from pathlib import Path
3
+ import json
4
+ import numpy as np
5
+ import torch
6
+ from safetensors.torch import load_file
7
+ from train import features,network
8
+ from rod import Rod,Controls
9
+
10
+ def predict(controls,branch='down',model_dir=None,correct=False):
11
+ folder=Path(model_dir) if model_dir else Path(__file__).resolve().parents[1]/'models'
12
+ name='branch_conditioned' if branch is not None else 'ordinary'
13
+ config=json.loads((folder/f'{name}.json').read_text())
14
+ net=network(config['architecture'][0]);net.load_state_dict(load_file(str(folder/f'{name}.safetensors')));net.eval()
15
+ x=(np.array(features(controls,branch))-config['mean'])/config['std']
16
+ with torch.no_grad():z=net(torch.tensor(x,dtype=torch.float32)).numpy()
17
+ rod=Rod(48);c=Controls(**controls)
18
+ if correct:return rod.solve(c,z)
19
+ th=rod.A@z;stretch=1+(c.fx+2*c.h)*np.cos(th)+c.fy*np.sin(th)
20
+ xy=np.vstack([np.zeros(2),np.cumsum(stretch[:,None]*np.column_stack([np.cos(th),np.sin(th)])/48,axis=0)])
21
+ return dict(z=z,centerline=xy,tip=xy[-1],note='Raw neural estimate; stability is not certified.')
22
+
23
+ if __name__=='__main__':
24
+ c=dict(chi=.0001,fx=-.016428,fy=0.,moment=0.,h=.01,delta=.1,k1=0.,k2=0.,k3=0.)
25
+ for corrected in [False,True]:
26
+ r=predict(c,'down',correct=corrected)
27
+ print('corrected' if corrected else 'neural','tip',r['tip'],'residual',r.get('residual'),'stability',r.get('stability'))
src/inverse.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Mechanics-based bounded intrinsic-curvature design; no neural claims."""
2
+ from dataclasses import asdict
3
+ import numpy as np
4
+ from scipy.optimize import least_squares
5
+ from rod import Rod,Controls,serial
6
+
7
+ def forward(k):
8
+ r=Rod(48)
9
+ c=Controls(chi=.001,fx=.0003,fy=-.0001,k1=float(k[0]),k2=float(k[1]),k3=float(k[2]))
10
+ seed=np.cumsum(np.repeat(k,16))/48
11
+ return r.solve(c,seed),c
12
+
13
+ def design(target,shape=False):
14
+ target=np.asarray(target)
15
+ def residual(k):
16
+ result,_=forward(k)
17
+ mismatch=result['centerline']-target if shape else result['tip']-target
18
+ return np.r_[mismatch.ravel()*20,.002*k]
19
+ candidates=[least_squares(residual,np.full(3,s),bounds=(-2.4,2.4),max_nfev=70,ftol=1e-10,xtol=1e-10,gtol=1e-10) for s in [-1.,0.,1.]]
20
+ best=min(candidates,key=lambda r:np.linalg.norm(residual(r.x)))
21
+ state,c=forward(best.x)
22
+ path=[]
23
+ for t in np.linspace(0,1,25):
24
+ step,cc=forward(t*best.x)
25
+ path.append(dict(t=float(t),controls=asdict(cc),**serial(step)))
26
+ err=float(np.linalg.norm(state['tip']-target)) if not shape else float(np.sqrt(np.mean(np.sum((state['centerline']-target)**2,axis=1))))
27
+ return dict(target=target.tolist(),controls=asdict(c),error_over_L=err,matched=bool(err<.005 and state['accepted']),stable_sampled_path=all(p['accepted'] and p['stability']=='stable' for p in path),path=path)
28
+
29
+ if __name__=='__main__':
30
+ from pathlib import Path
31
+ import json
32
+ rng=np.random.default_rng(50);results=[]
33
+ for i in range(12):
34
+ known,_=forward(rng.uniform(-2,2,3))
35
+ shape=i>=8
36
+ result=design(known['centerline'] if shape else known['tip'],shape)
37
+ result['task']='shape' if shape else 'tip'
38
+ assert result['matched'] and result['stable_sampled_path']
39
+ results.append(result)
40
+ (Path(__file__).resolve().parents[1]/'reports/inverse_checks.json').write_text(json.dumps(results))
41
+ print('Inverse checks:',len(results),'max error/L:',max(r['error_over_L'] for r in results))
src/package.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Explicit publication whitelist, generated summaries and figures."""
2
+ from pathlib import Path
3
+ import json,gzip,shutil,hashlib,platform,importlib.metadata
4
+ import numpy as np
5
+ import matplotlib
6
+ matplotlib.use('Agg')
7
+ import matplotlib.pyplot as plt
8
+ R=Path(__file__).resolve().parents[1]
9
+
10
+ def main():
11
+ rows=[json.loads(l) for l in (R/'data/equilibria.jsonl').open()]
12
+ dataset=R/'release/dataset';model=R/'release/model'
13
+ for root in [dataset,model]:
14
+ for d in ['src','tests','reports','assets']: (root/d).mkdir(parents=True,exist_ok=True)
15
+ for folder in ['src','tests']:
16
+ for p in (R/folder).glob('*.py'):shutil.copy2(p,root/folder/p.name)
17
+ for p in (R/'reports').glob('*.json'):shutil.copy2(p,root/'reports'/p.name)
18
+ for name in ['SCHEMA.md','requirements.txt','LICENSE-CODE','LICENSE-DATA']:shutil.copy2(R/name,root/name)
19
+ (dataset/'states').mkdir(exist_ok=True)
20
+ for split in ['train','validation','test','parameter_ood']:
21
+ with gzip.open(dataset/f'states/{split}.jsonl.gz','wt') as f:
22
+ for row in rows:
23
+ if row['split']==split:f.write(json.dumps(row,allow_nan=False,separators=(',',':'))+'\n')
24
+ (dataset/'validation').mkdir(exist_ok=True)
25
+ with gzip.open(dataset/'validation/paired_resolution.jsonl.gz','wt') as f:f.write((R/'data/paired_resolution.jsonl').read_text())
26
+ (dataset/'validation/rejected_attempts.json').write_text('[]\n')
27
+ native=R/'cases/fig9/outputs/003-downward-single-geometry'
28
+ for folder in ['paraview','xdmf','scientific','figures']:
29
+ shutil.copytree(native/folder,dataset/'native_fe'/folder,dirs_exist_ok=True)
30
+ for name in ['native_fe_metrics.csv','paraview_checks.json']:shutil.copy2(native/name,dataset/'native_fe'/name)
31
+ (dataset/'cases/fig9').mkdir(parents=True,exist_ok=True)
32
+ for name in ['case.py','paper_reference.py','agentfem.toml']:shutil.copy2(R/'cases/fig9'/name,dataset/'cases/fig9'/name)
33
+ shutil.copytree(R/'models',model/'models',dirs_exist_ok=True)
34
+ environment={name:importlib.metadata.version(name) for name in ['numpy','scipy','torch','safetensors','matplotlib','h5py']}
35
+ environment.update(python=platform.python_version(),platform=platform.platform(),agentfem_commit='36f4c1b06ce8a37988eea50bd139fd2d3513985d')
36
+ for root in [R,dataset,model]:(root/'reports/environment.json').write_text(json.dumps(environment,indent=2))
37
+ plt.rcParams.update({'font.family':'DejaVu Sans','text.color':'#e6efed','axes.labelcolor':'#8fa5a7','xtick.color':'#61777c','ytick.color':'#61777c'})
38
+ fig,axes=plt.subplots(1,3,figsize=(15,6),facecolor='#091317')
39
+ titles=['Driven by force','Programmed curvature','One load. Three branches.']
40
+ families=['end_load','intrinsic_curvature','microforce']
41
+ for ax,family,title in zip(axes,families,titles):
42
+ ax.set_facecolor('#091317');ax.set_aspect('equal');ax.set_xlim(-.55,1.1);ax.set_ylim(-1.05,1.05)
43
+ ax.set_xticks([]);ax.set_yticks([])
44
+ for sp in ax.spines.values():sp.set_visible(False)
45
+ ax.axhline(0,color='#244048',lw=.5);ax.axvline(0,color='#244048',lw=.5)
46
+ if family=='microforce':
47
+ chosen=[v for v in rows if v['scene_id']=='microforce_000' and v['step']==16]
48
+ else:
49
+ chosen=[v for v in rows if v['family']==family and v['path_kind']=='ramp' and v['step']==24][::5][:12]
50
+ for i,v in enumerate(chosen):
51
+ xy=np.array(v['centerline']);color='#e3ac72' if v['branch']=='straight' else '#78d6ca'
52
+ ax.plot(*xy.T,color=color,alpha=.3+.7*(i+1)/len(chosen),lw=2.2)
53
+ ax.scatter(*xy[-1],s=12,color=color,zorder=4)
54
+ ax.scatter(0,0,s=40,color='#f1f5ed',zorder=5)
55
+ ax.set_title(title,fontsize=13,loc='left',pad=20,color='#eff6f1')
56
+ fig.text(.055,.93,'AgentFEM / MORPH LAB',color='#78d6ca',fontsize=12,weight='bold')
57
+ fig.text(.055,.055,'Programmable rods · Equilibrium branches · Inverse shape design',fontsize=15,color='#f1f5ed')
58
+ fig.subplots_adjust(top=.82,bottom=.15,wspace=.14,left=.055,right=.97)
59
+ for root in [dataset,model]:fig.savefig(root/'assets/overview.png',dpi=140,facecolor=fig.get_facecolor())
60
+ plt.close(fig)
61
+ # Only original code/data/figures enter release. Never include paper PDF,
62
+ # authentication, failed-run scratch, local absolute-path execution logs.
63
+ for root in [dataset,model]:
64
+ hashes={str(p.relative_to(root)):hashlib.sha256(p.read_bytes()).hexdigest() for p in sorted(root.rglob('*')) if p.is_file() and p.name!='SHA256SUMS.json'}
65
+ (root/'SHA256SUMS.json').write_text(json.dumps(hashes,indent=2))
66
+ print('Packaged',len(rows),'states')
67
+
68
+ if __name__=='__main__':main()
src/rod.py ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Conservative planar extensible rod. L=EA=1; chi=EI/(EA L^2).
2
+
3
+ Rod: linear angle FE, midpoint axial elimination. Chain: Ye et al. (2026)
4
+ cell rotations, first cell clamped; kr=chi*n. Independent implementations
5
+ share ONLY the reduced local energy density. No contact or dynamics.
6
+ SPDX-License-Identifier: Apache-2.0
7
+ """
8
+ from dataclasses import dataclass, asdict
9
+ import numpy as np
10
+ from scipy.linalg import solve, eigh
11
+ from scipy.optimize import root
12
+
13
+ @dataclass
14
+ class Controls:
15
+ chi: float = .001
16
+ fx: float = 0.
17
+ fy: float = 0.
18
+ moment: float = 0.
19
+ h: float = 0.
20
+ delta: float = .1
21
+ k1: float = 0.
22
+ k2: float = 0.
23
+ k3: float = 0.
24
+
25
+ class Rod:
26
+ def __init__(self, n=48, kind="rod"):
27
+ self.n, self.kind, self.ds = n, kind, 1/n
28
+ if kind == "rod":
29
+ self.d = n
30
+ A = np.zeros((n,n+1)); B = A.copy()
31
+ for i in range(n):
32
+ A[i,i:i+2] = .5
33
+ B[i,i:i+2] = [-n,n]
34
+ self.A,self.B = A[:,1:],B[:,1:]
35
+ self.mass = (A[:,1:].T@A[:,1:])/n
36
+ elif kind == "chain":
37
+ self.d = n-1
38
+ self.A = np.eye(n)[:,1:]
39
+ self.B = np.diff(np.eye(n),axis=0)[:,1:]*n
40
+ self.mass = np.eye(n-1)/n
41
+ else: raise ValueError(kind)
42
+ self.s = (np.arange(n)+.5)/n
43
+
44
+ def terms(self, z, c):
45
+ angle=self.A@z
46
+ intrinsic=np.array([c.k1,c.k2,c.k3])[np.minimum((np.arange(self.B.shape[0])+.5)*3/self.B.shape[0],2).astype(int)]
47
+ curvature=self.B@z-intrinsic
48
+ a=c.fx+2*c.h
49
+ f=a*np.cos(angle)+c.fy*np.sin(angle)
50
+ fp=-a*np.sin(angle)+c.fy*np.cos(angle)
51
+ g=4*c.h*c.delta
52
+ density=-f-.5*f*f+g*np.cos(angle)
53
+ energy=self.ds*(.5*c.chi*(curvature@curvature)+density.sum())-c.moment*z[-1]
54
+ local_g=-(1+f)*fp-g*np.sin(angle)
55
+ local_h=(1+f)*f-fp*fp-g*np.cos(angle)
56
+ grad=self.ds*(c.chi*self.B.T@curvature+self.A.T@local_g)
57
+ grad[-1]-=c.moment
58
+ tangent=self.ds*(c.chi*self.B.T@self.B+self.A.T@(local_h[:,None]*self.A))
59
+ return energy,grad,tangent
60
+
61
+ def solve(self,c,seed=None):
62
+ z=np.zeros(self.d) if seed is None else np.array(seed,dtype=float).copy()
63
+ it=0; trace=[]; fallback_nfev=0
64
+ for it in range(60):
65
+ _,r,K=self.terms(z,c)
66
+ trace.append(dict(iteration=it,residual_inf=float(np.max(np.abs(r)))))
67
+ if np.max(np.abs(r))<1e-10: break
68
+ try: dz=solve(K,-r,assume_a='sym')
69
+ except Exception: break
70
+ old=np.linalg.norm(r)
71
+ step=1.
72
+ for _ in range(16):
73
+ trial=z+step*dz
74
+ if np.linalg.norm(self.terms(trial,c)[1])<old: break
75
+ step*=.5
76
+ else: break
77
+ z=trial
78
+ trace[-1]['accepted_step_scale']=step
79
+ residual=float(np.max(np.abs(self.terms(z,c)[1])))
80
+ if residual>1e-9:
81
+ sol=root(lambda v:self.terms(v,c)[1],z,jac=lambda v:self.terms(v,c)[2],tol=1e-10)
82
+ z=sol.x; fallback_nfev=sol.nfev
83
+ energy,r,K=self.terms(z,c)
84
+ residual=float(np.max(np.abs(r)))
85
+ angle=self.A@z
86
+ stretch=1+(c.fx+2*c.h)*np.cos(angle)+c.fy*np.sin(angle)
87
+ admissible=bool(np.min(stretch)>(2*c.delta if c.h!=0 else 0))
88
+ good=bool(residual<1e-9 and admissible and np.all(np.isfinite(z)))
89
+ eig=float(eigh(K,self.mass,subset_by_index=[0,0],eigvals_only=True)[0]/c.chi) if good else None
90
+ stability='unknown' if eig is None else ('stable' if eig>1e-4 else 'unstable' if eig< -1e-4 else 'critical')
91
+ segments=self.ds*stretch[:,None]*np.column_stack([np.cos(angle),np.sin(angle)])
92
+ xy=np.vstack([np.zeros(2),np.cumsum(segments,axis=0)])
93
+ # Output resampled on reference coordinate, not current arc length.
94
+ center=np.column_stack([np.interp(np.linspace(0,1,65),np.linspace(0,1,self.n+1),xy[:,j]) for j in range(2)])
95
+ return dict(z=z,centerline=center,angle=angle,strain=stretch-1,energy=float(energy),residual=residual,
96
+ iterations=it+1,accepted=good,lambda_min_over_chi=eig,stability=stability,
97
+ tip=center[-1],min_stretch=float(stretch.min()),solver_trace=trace,fallback_nfev=fallback_nfev)
98
+
99
+ def mode_seed(self,amplitude):
100
+ s=np.arange(1,self.d+1)/self.n
101
+ return amplitude*np.sin(np.pi*s/2)
102
+
103
+ def serial(result):
104
+ return {k:(v.tolist() if isinstance(v,np.ndarray) else v) for k,v in result.items()}
src/train.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Matched ordinary/branch-conditioned MLP baselines. Grouped splits only."""
2
+ import os
3
+ os.environ.setdefault('OMP_NUM_THREADS','1')
4
+ from pathlib import Path
5
+ import json,time
6
+ import numpy as np
7
+ import torch
8
+ from torch import nn
9
+ from safetensors.torch import save_file
10
+ ROOT=Path(__file__).resolve().parents[1]
11
+ torch.set_num_threads(2)
12
+
13
+ def features(c,branch=None):
14
+ chi=c['chi'];a=c['fx']+2*c['h']
15
+ x=[np.log10(chi),a/chi,c['fy']/chi,c['moment']/chi,4*c['h']*c['delta']/chi,c['k1'],c['k2'],c['k3']]
16
+ if branch is not None:x += [float(branch==b) for b in ['down','straight','up']]
17
+ return x
18
+
19
+ def network(d):return nn.Sequential(nn.Linear(d,96),nn.Tanh(),nn.Linear(96,96),nn.Tanh(),nn.Linear(96,48))
20
+
21
+ def reconstruct(z,rows):
22
+ full=np.column_stack([np.zeros(len(z)),z]);th=(full[:,1:]+full[:,:-1])/2
23
+ a=np.array([v['controls']['fx']+2*v['controls']['h'] for v in rows])[:,None]
24
+ fy=np.array([v['controls']['fy'] for v in rows])[:,None]
25
+ stretch=1+a*np.cos(th)+fy*np.sin(th)
26
+ xy=np.stack([np.cos(th),np.sin(th)],axis=-1)*stretch[:,:,None]/48
27
+ xy=np.concatenate([np.zeros((len(z),1,2)),np.cumsum(xy,axis=1)],axis=1)
28
+ return xy
29
+
30
+ def main():
31
+ rows=[json.loads(l) for l in (ROOT/'data/equilibria.jsonl').open()]
32
+ splits={s:np.array([i for i,r in enumerate(rows) if r['split']==s]) for s in ['train','validation','test','parameter_ood']}
33
+ truth=np.array([r['z'] for r in rows],dtype='float32')
34
+ out=ROOT/'models';out.mkdir(exist_ok=True);report={}
35
+ for conditioned in [False,True]:
36
+ name='branch_conditioned' if conditioned else 'ordinary'
37
+ torch.manual_seed(14);rng=np.random.default_rng(14)
38
+ x=np.array([features(r['controls'],r['branch'] if conditioned else None) for r in rows],dtype='float32')
39
+ mean=x[splits['train']].mean(0);std=x[splits['train']].std(0);std[std<1e-6]=1
40
+ X=torch.from_numpy((x-mean)/std);Y=torch.from_numpy(truth)
41
+ net=network(x.shape[1]);opt=torch.optim.Adam(net.parameters(),lr=.002)
42
+ best=float('inf');best_epoch=0;start=time.perf_counter()
43
+ for epoch in range(401):
44
+ net.train()
45
+ for idx in np.array_split(rng.permutation(splits['train']),19):
46
+ opt.zero_grad();loss=(net(X[idx])-Y[idx]).square().mean();loss.backward();opt.step()
47
+ net.eval()
48
+ with torch.no_grad():val=float((net(X[splits['validation']])-Y[splits['validation']]).square().mean())
49
+ if val<best:
50
+ best=val;best_epoch=epoch;weights={k:v.clone().contiguous() for k,v in net.state_dict().items()}
51
+ if epoch%100==0:print(name,epoch,'val angle MSE',val,flush=True)
52
+ net.load_state_dict(weights);save_file(weights,str(out/f'{name}.safetensors'))
53
+ (out/f'{name}.json').write_text(json.dumps(dict(mean=mean.tolist(),std=std.tolist(),conditioned=conditioned,architecture=[x.shape[1],96,96,48],activation='tanh',n=48,features='see inference.py / features',best_epoch=best_epoch),indent=2))
54
+ with torch.no_grad():pred=net(X).numpy()
55
+ predicted=reconstruct(pred,rows);target=reconstruct(truth,rows)
56
+ result={'training_seconds':time.perf_counter()-start,'best_validation_angle_mse':best,'best_epoch':best_epoch,'splits':{}}
57
+ for s,idx in splits.items():
58
+ dist=np.linalg.norm(predicted[idx]-target[idx],axis=2)
59
+ br=np.where(np.max(np.abs(pred[idx]),axis=1)<.01,'straight',np.where(predicted[idx,-1,1]>0,'up','down'))
60
+ result['splits'][s]=dict(states=len(idx),centerline_rmse_over_L=float(np.sqrt(np.mean(dist**2))),tip_mean_error_over_L=float(np.mean(dist[:,-1])),tip_p95_error_over_L=float(np.quantile(dist[:,-1],.95)),branch_accuracy=float(np.mean(br==np.array([rows[i]['branch'] for i in idx]))))
61
+ result['splits'][s]['families']={}
62
+ for family in ['end_load','intrinsic_curvature','microforce']:
63
+ select=np.array([rows[i]['family']==family for i in idx])
64
+ result['splits'][s]['families'][family]=dict(centerline_rmse_over_L=float(np.sqrt(np.mean(dist[select]**2))),tip_mean_error_over_L=float(np.mean(dist[select,-1])))
65
+ report[name]=result
66
+ (ROOT/'reports/baselines.json').write_text(json.dumps(report,indent=2));print(json.dumps(report,indent=2))
67
+
68
+ if __name__=='__main__':main()
states/parameter_ood.jsonl.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7795bd454c08eaaf2c93a86e54a60354337bf3e52a94c8c91d039b82811d631a
3
+ size 6410565
states/test.jsonl.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ce1c3a1bfa3d141ee188041664e8043f611fd218612e609aa8ec090f14bae379
3
+ size 4826022
states/train.jsonl.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:60ce6d411294a8bcffe96cd893a66b8b5eb539c2cdef3fad6fa2a1a3fc55d537
3
+ size 22495011
states/validation.jsonl.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:235cf1d9221fc6ffa31e20ca186ab15db2cf06ca8d575c4157eeead88b3f9f10
3
+ size 4836446
tests/check_paraview.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Verify native exported fields and warp the actual negative branch."""
2
+ import json,sys
3
+ from pathlib import Path
4
+ from paraview.simple import OpenDataFile,UpdatePipeline,WarpByVector,Delete
5
+ root=Path(sys.argv[1]);checks=[]
6
+ for relative in ['paraview/native_agentfem_fig9.pvd','xdmf/native_agentfem_fig9.xdmf']:
7
+ source=OpenDataFile(str(root/relative));UpdatePipeline(proxy=source)
8
+ times=list(source.TimestepValues)
9
+ assert len(times)==3
10
+ frames=[]
11
+ for t in times:
12
+ source.UpdatePipeline(t)
13
+ assert 'U' in source.PointData.keys()
14
+ # XDMF readers may expose scalar DG0 grids as blocks; the single-geometry
15
+ # guarantee is specifically tested for the PVD delivery.
16
+ assert 'MISES' in source.CellData.keys()
17
+ assert 'MICROFORCE_POTENTIAL' in source.CellData.keys()
18
+ assert source.GetDataInformation().GetNumberOfCells()==400
19
+ warp=WarpByVector(Input=source);warp.Vectors=['POINTS','U'];warp.ScaleFactor=1
20
+ warp.UpdatePipeline(t);bounds=list(warp.GetDataInformation().GetBounds())
21
+ assert bounds[2]<-.05
22
+ frames.append(dict(case_index=t,points=warp.GetDataInformation().GetNumberOfPoints(),cells=warp.GetDataInformation().GetNumberOfCells(),warped_bounds=bounds))
23
+ Delete(warp)
24
+ checks.append(dict(file=relative,frames=frames));Delete(source)
25
+ (root/'paraview_checks.json').write_text(json.dumps(checks,indent=2));print(json.dumps(checks,indent=2))
tests/evaluate_release.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Additional same-information baseline and exact-solver timing."""
2
+ from pathlib import Path
3
+ import json,sys,time
4
+ import numpy as np
5
+ from scipy.spatial import cKDTree
6
+ sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'src'))
7
+ from train import features,reconstruct,network
8
+ from rod import Rod,Controls
9
+ from safetensors.torch import load_file
10
+ import torch
11
+ R=Path(__file__).resolve().parents[1]
12
+ rows=[json.loads(l) for l in (R/'data/equilibria.jsonl').open()]
13
+ train=[v for v in rows if v['split']=='train'];test=[v for v in rows if v['split']=='test']
14
+ x=np.array([features(v['controls']) for v in train]);mean=x.mean(0);std=x.std(0);std[std<1e-6]=1
15
+ pred=[]
16
+ for v in test:
17
+ allowed=np.array([t['branch']==v['branch'] for t in train])
18
+ subset=np.flatnonzero(allowed)
19
+ distances=np.sum(((x[subset]-features(v['controls']))/std)**2,axis=1)
20
+ pred.append(train[subset[np.argmin(distances)]]['z'])
21
+ p=reconstruct(np.array(pred),test);true=reconstruct(np.array([v['z'] for v in test]),test)
22
+ report={'branch_conditioned_1nn':{'centerline_rmse_over_L':float(np.sqrt(np.mean(np.sum((p-true)**2,axis=2)))),'tip_mean_error_over_L':float(np.mean(np.linalg.norm(p[:,-1]-true[:,-1],axis=1)))}}
23
+ config=json.loads((R/'models/branch_conditioned.json').read_text());net=network(11);net.load_state_dict(load_file(str(R/'models/branch_conditioned.safetensors')));net.eval()
24
+ sample=test[::20];xt=torch.tensor((np.array([features(v['controls'],v['branch']) for v in sample])-config['mean'])/config['std'],dtype=torch.float32)
25
+ with torch.no_grad():
26
+ for _ in range(10):net(xt)
27
+ start=time.perf_counter()
28
+ for _ in range(100):z=net(xt)
29
+ report['neural_batched_ms_per_state']=(time.perf_counter()-start)*1000/(100*len(sample))
30
+ r=Rod();times=[];corr=[]
31
+ for i,v in enumerate(sample):
32
+ start=time.perf_counter();result=r.solve(Controls(**v['controls']),z[i].numpy());times.append(time.perf_counter()-start)
33
+ corr.append(dict(id=v['id'],accepted=result['accepted'],branch_preserved=bool((v['branch']=='straight' and np.max(np.abs(result['z']))<1e-5) or (v['branch']=='up' and result['tip'][1]>1e-5) or (v['branch']=='down' and result['tip'][1]<-1e-5)),tip_error=float(np.linalg.norm(result['tip']-v['tip']))))
34
+ report['corrector_median_ms']=float(1000*np.median(times));report['corrector_checks']=corr
35
+ assert all(c['accepted'] and c['branch_preserved'] for c in corr)
36
+ # Exact duplicate geometries can occur at zero load and on reversible sweeps;
37
+ # scene-disjoint split is guaranteed, shape-disjointness is NOT claimed.
38
+ report['number_scenes']=len({r['scene_id'] for r in rows})
39
+ report['number_paths']=len({r['path_id'] for r in rows})
40
+ report['sampled_stable_pairs']=sum(r['continuous_stable_pair'] for r in rows)
41
+ (R/'reports/additional_baselines.json').write_text(json.dumps(report,indent=2))
42
+ print({k:v for k,v in report.items() if k!='corrector_checks'})
tests/validate.py ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Independent checks, mandatory before data publication."""
2
+ import sys,json
3
+ from pathlib import Path
4
+ sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'src'))
5
+ from rod import Rod,Controls
6
+ import numpy as np
7
+ from scipy.integrate import solve_bvp
8
+ from scipy.optimize import brentq
9
+
10
+ def run():
11
+ checks={}
12
+ r=Rod(24); c=Controls(chi=.004,fx=.005,fy=.002,h=.001,k1=.3,k2=-.2,k3=.6)
13
+ z=.4*np.sin(np.linspace(0,np.pi/2,r.d)); e,g,K=r.terms(z,c)
14
+ eps=1e-6; eye=np.eye(r.d)
15
+ gn=np.array([(r.terms(z+eps*v,c)[0]-r.terms(z-eps*v,c)[0])/(2*eps) for v in eye])
16
+ Kn=np.column_stack([(r.terms(z+eps*v,c)[1]-r.terms(z-eps*v,c)[1])/(2*eps) for v in eye])
17
+ checks['gradient_fd_max_abs']=float(np.max(np.abs(g-gn)))
18
+ checks['hessian_fd_max_abs']=float(np.max(np.abs(K-Kn)))
19
+ assert checks['gradient_fd_max_abs']<1e-8 and checks['hessian_fd_max_abs']<1e-8
20
+ axial=r.solve(Controls(fx=.03))
21
+ checks['axial_tip_error']=float(np.linalg.norm(axial['tip']-[1.03,0]))
22
+ assert checks['axial_tip_error']<1e-12
23
+ circular=[]
24
+ for n in [24,48,96]:
25
+ rr=Rod(n); cc=Controls(k1=1.2,k2=1.2,k3=1.2)
26
+ ans=rr.solve(cc,np.linspace(0,1.2,n+1)[1:])
27
+ exact=np.array([np.sin(1.2)/1.2,(1-np.cos(1.2))/1.2])
28
+ circular.append(float(np.linalg.norm(ans['tip']-exact)))
29
+ checks['circular_tip_errors_n24_48_96']=circular
30
+ assert circular[2]<circular[1]<circular[0] and circular[-1]<1e-5
31
+ rr=Rod(96); cc=Controls(chi=1e-4,h=.01,delta=.1)
32
+ pc=(-1+np.sqrt(1+16*cc.h*cc.delta-np.pi**2*cc.chi))/2-2*cc.h
33
+ def eig(p):
34
+ cc.fx=p
35
+ return rr.solve(cc)['lambda_min_over_chi']
36
+ pn=brentq(eig,pc-.001,pc+.001,xtol=1e-13)
37
+ checks['critical_load_analytic']=pc; checks['critical_load_discrete_rod96']=pn
38
+ checks['critical_load_error']=abs(pc-pn)
39
+ assert abs(pc-pn)<1e-7
40
+ # Independent solve_bvp of paper Eqs.52-53, negative branch. Not our FE energy.
41
+ errors=[]; chain_errors=[]
42
+ for p in [-.017159,-.016428,-.016316]:
43
+ chi,h,d=1e-4,.01,.1; a=p+2*h
44
+ s=np.linspace(0,1,101)
45
+ def fun(s,y):
46
+ th=y[0]; stretch=1+a*np.cos(th)
47
+ return np.vstack([y[1],(a*stretch-4*h*d)*np.sin(th)/chi,stretch*np.cos(th),stretch*np.sin(th)])
48
+ def bc(l,r): return [l[0],r[1],l[2],l[3]]
49
+ candidates=[]
50
+ for amp in [-.3,-1.,-2.]:
51
+ y=np.vstack([amp*np.sin(np.pi*s/2),amp*np.pi/2*np.cos(np.pi*s/2),s,amp*s*s/2])
52
+ b=solve_bvp(fun,bc,s,y,tol=1e-9,max_nodes=10000)
53
+ if b.success and b.y[3,-1]<-1e-3: candidates.append(b)
54
+ assert candidates
55
+ b=min(candidates,key=lambda b:abs(b.y[0,-1]))
56
+ target=b.sol(np.linspace(0,1,65))[2:4].T
57
+ c=Controls(chi=chi,h=h,delta=d,fx=p)
58
+ arod=Rod(96); out=arod.solve(c,b.sol(np.linspace(0,1,97))[0,1:])
59
+ assert out['accepted'] and out['tip'][1]<0 and out['stability']=='stable'
60
+ errors.append(float(np.sqrt(np.mean(np.sum((out['centerline']-target)**2,axis=1)))))
61
+ one=[]
62
+ for n in [15,30,60,120]:
63
+ rc=Rod(n,'chain'); v=rc.solve(c,b.sol(np.arange(1,n)/n)[0])
64
+ assert v['accepted'] and v['tip'][1]<0
65
+ one.append(float(np.linalg.norm(v['tip']-target[-1])))
66
+ assert one[-1]<one[0]
67
+ chain_errors.append(one)
68
+ checks['fig9_rod96_centerline_rmse_over_L']=errors
69
+ checks['fig9_chain_tip_errors_n15_30_60_120']=chain_errors
70
+ assert max(errors)<.001
71
+ # Exact chain linear critical load verifies the independently assembled hinge boundary.
72
+ rc=Rod(15,'chain'); c=Controls(chi=1e-4,h=.01)
73
+ omega2=4*np.sin(np.pi/(2*(2*15-1)))**2
74
+ expected=(-1+np.sqrt(1-4*c.chi*15**2*omega2+16*c.h*c.delta))/2-2*c.h
75
+ c.fx=expected; v=rc.solve(c)
76
+ checks['chain_critical_eigenvalue']=v['lambda_min_over_chi']
77
+ assert abs(v['lambda_min_over_chi'])<1e-8
78
+ checks['passed']=True
79
+ return checks
80
+
81
+ if __name__=='__main__':
82
+ checks=run()
83
+ p=Path(__file__).resolve().parents[1]/'reports/validation.json'
84
+ p.write_text(json.dumps(checks,indent=2))
85
+ print(json.dumps(checks,indent=2))
validation/paired_resolution.jsonl.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:68a217ba0ad15b5a6bc5119b61577eddd7e6126f6edd2fa6acbb3d07d50615cd
3
+ size 868150
validation/rejected_attempts.json ADDED
@@ -0,0 +1 @@
 
 
1
+ []