Release AgentFEM Material Loading Memory v1
Browse files- .pytest_cache/.gitignore +2 -0
- .pytest_cache/CACHEDIR.TAG +4 -0
- .pytest_cache/README.md +8 -0
- .pytest_cache/v/cache/nodeids +12 -0
- CODE_LICENSE +159 -0
- DATA_LICENSE.md +12 -0
- README.md +106 -0
- SHA256SUMS +28 -0
- artifacts/t2_material_loading_memory_v1/QUALITY_REPORT.md +34 -0
- artifacts/t2_material_loading_memory_v1/baseline_metrics.json +88 -0
- artifacts/t2_material_loading_memory_v1/baseline_models.pt +3 -0
- artifacts/t2_material_loading_memory_v1/baseline_predictions.png +3 -0
- artifacts/t2_material_loading_memory_v1/hysteresis_preview.png +3 -0
- artifacts/t2_material_loading_memory_v1/quality.json +206 -0
- configs/t2_material_loading_memory_pilot.json +51 -0
- configs/t2_material_loading_memory_v1.json +53 -0
- data/t2_material_loading_memory_v1/design.jsonl +0 -0
- data/t2_material_loading_memory_v1/index.jsonl +0 -0
- data/t2_material_loading_memory_v1/manifest.json +75 -0
- data/t2_material_loading_memory_v1/shards/part-00000.h5 +3 -0
- data/t2_material_loading_memory_v1/shards/part-00001.h5 +3 -0
- data/t2_material_loading_memory_v1/shards/part-00002.h5 +3 -0
- data/t2_material_loading_memory_v1/shards/part-00003.h5 +3 -0
- data/t2_material_loading_memory_v1/shards/part-00004.h5 +3 -0
- data/t2_material_loading_memory_v1/shards/part-00005.h5 +3 -0
- data/t2_material_loading_memory_v1/shards/part-00006.h5 +3 -0
- data/t2_material_loading_memory_v1/shards/part-00007.h5 +3 -0
- src/baseline_t2_material_loading_memory.py +337 -0
- src/load_t2_material_loading_memory.py +79 -0
- src/t2_material_loading_memory.py +770 -0
- src/t2_material_loading_memory_v1.py +743 -0
- tests/test_t2_material_loading_memory.py +112 -0
- tests/test_t2_material_loading_memory_v1.py +72 -0
.pytest_cache/.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Created by pytest automatically.
|
| 2 |
+
*
|
.pytest_cache/CACHEDIR.TAG
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Signature: 8a477f597d28d172789f06886806bc55
|
| 2 |
+
# This file is a cache directory tag created by pytest.
|
| 3 |
+
# For information about cache directory tags, see:
|
| 4 |
+
# https://bford.info/cachedir/spec.html
|
.pytest_cache/README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# pytest cache directory #
|
| 2 |
+
|
| 3 |
+
This directory contains data from the pytest's cache plugin,
|
| 4 |
+
which provides the `--lf` and `--ff` options, as well as the `cache` fixture.
|
| 5 |
+
|
| 6 |
+
**Do not** commit this to version control.
|
| 7 |
+
|
| 8 |
+
See [the docs](https://docs.pytest.org/en/stable/how-to/cache.html) for more information.
|
.pytest_cache/v/cache/nodeids
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
"tests/test_t2_material_loading_memory.py::test_t2_agentfem_material_point_smoke_paths_are_physical",
|
| 3 |
+
"tests/test_t2_material_loading_memory.py::test_t2_design_is_unique_balanced_and_split_by_trajectory",
|
| 4 |
+
"tests/test_t2_material_loading_memory.py::test_t2_j2_monotonic_path_matches_closed_form",
|
| 5 |
+
"tests/test_t2_material_loading_memory.py::test_t2_packaged_pilot_is_readable_when_present",
|
| 6 |
+
"tests/test_t2_material_loading_memory.py::test_t2_prescribed_histories_have_fixed_size_and_required_reversals",
|
| 7 |
+
"tests/test_t2_material_loading_memory.py::test_t2_refined_paths_are_nested_at_every_coarse_state",
|
| 8 |
+
"tests/test_t2_material_loading_memory_v1.py::test_v1_design_is_unique_balanced_and_stratified",
|
| 9 |
+
"tests/test_t2_material_loading_memory_v1.py::test_v1_histories_preserve_reversals_under_refinement",
|
| 10 |
+
"tests/test_t2_material_loading_memory_v1.py::test_v1_packaged_data_and_lightweight_reader_when_present",
|
| 11 |
+
"tests/test_t2_material_loading_memory_v1.py::test_v1_parameter_ranges_and_model_labels_are_explicit"
|
| 12 |
+
]
|
CODE_LICENSE
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
|
DATA_LICENSE.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Dataset license
|
| 2 |
+
|
| 3 |
+
The dataset files, metadata, figures and accompanying dataset documentation in
|
| 4 |
+
this repository are licensed under the Creative Commons Attribution 4.0
|
| 5 |
+
International License (CC BY 4.0).
|
| 6 |
+
|
| 7 |
+
License text and terms: https://creativecommons.org/licenses/by/4.0/legalcode
|
| 8 |
+
|
| 9 |
+
SPDX identifier: `CC-BY-4.0`
|
| 10 |
+
|
| 11 |
+
Attribution should identify the dataset as **AgentFEM Layered Thermoelastic
|
| 12 |
+
Bending 2D** and link to this repository.
|
README.md
CHANGED
|
@@ -1,3 +1,109 @@
|
|
| 1 |
---
|
| 2 |
license: cc-by-4.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: cc-by-4.0
|
| 3 |
+
task_categories:
|
| 4 |
+
- time-series-forecasting
|
| 5 |
+
- other
|
| 6 |
+
tags:
|
| 7 |
+
- constitutive-modeling
|
| 8 |
+
- computational-mechanics
|
| 9 |
+
- scientific-machine-learning
|
| 10 |
+
- hysteresis
|
| 11 |
+
- agentfem
|
| 12 |
+
pretty_name: AgentFEM Material Loading Memory
|
| 13 |
+
size_categories:
|
| 14 |
+
- 1K<n<10K
|
| 15 |
---
|
| 16 |
+
|
| 17 |
+
# AgentFEM Material Loading Memory v1
|
| 18 |
+
|
| 19 |
+
This dataset contains 1,008 verified synthetic material-point trajectories for
|
| 20 |
+
path-dependent small-strain plasticity. It is designed for sequence models,
|
| 21 |
+
constitutive surrogates, loading-path generalization, material-model discovery
|
| 22 |
+
and reproducible scientific-ML studies.
|
| 23 |
+
|
| 24 |
+

|
| 25 |
+
|
| 26 |
+
## Dataset summary
|
| 27 |
+
|
| 28 |
+
- 504 J2 linear-isotropic-hardening trajectories.
|
| 29 |
+
- 504 Chaboche combined-hardening trajectories.
|
| 30 |
+
- Six balanced loading families: monotonic tension, unload/reload,
|
| 31 |
+
tension/compression, symmetric cycling, mean-shifted cycling and variable
|
| 32 |
+
amplitude.
|
| 33 |
+
- 121 ordered states per trajectory; frames are not counted as independent
|
| 34 |
+
samples.
|
| 35 |
+
- Trajectory-level split: 768 train, 120 validation and 120 test cases.
|
| 36 |
+
- Eight HDF5 shards with 126 independent trajectories per shard.
|
| 37 |
+
- SI units, deterministic Sobol parameter design and stable case IDs.
|
| 38 |
+
|
| 39 |
+
Every HDF5 group stores prescribed strain, stress, plastic strain, equivalent
|
| 40 |
+
plastic strain, plastic multiplier increments, elastic/plastic flags, trial and
|
| 41 |
+
corrected yield information, Chaboche backstress state, raw work diagnostics,
|
| 42 |
+
material parameters and split metadata.
|
| 43 |
+
|
| 44 |
+
## Verification
|
| 45 |
+
|
| 46 |
+
All 1,008 trajectories passed finite-value, initial-state, plastic
|
| 47 |
+
incompressibility, nondecreasing-PEEQ, plastic-excitation and yield-surface
|
| 48 |
+
checks. The maximum yield-surface relative residual was `2.166e-11`; the
|
| 49 |
+
maximum J2 monotonic analytical relative error was `4.714e-16`. Twenty-four
|
| 50 |
+
representative 121-to-241-state refinement audits produced maximum stress and
|
| 51 |
+
PEEQ changes of 0.387% and 0.129%, respectively. Every HDF5 shard is recorded
|
| 52 |
+
with a SHA-256 digest in `manifest.json`.
|
| 53 |
+
|
| 54 |
+
The complete evidence is in
|
| 55 |
+
`artifacts/t2_material_loading_memory_v1/QUALITY_REPORT.md`.
|
| 56 |
+
|
| 57 |
+
## Baselines
|
| 58 |
+
|
| 59 |
+
Two compact PyTorch baselines were trained using complete-trajectory splits and
|
| 60 |
+
train-only normalization. A pointwise MLP sees the current prescribed strain
|
| 61 |
+
and material parameters but no loading history. A GRU sees the ordered strain
|
| 62 |
+
history.
|
| 63 |
+
|
| 64 |
+
| Baseline | Test RMSE | Test MAE | Test R2 |
|
| 65 |
+
|---|---:|---:|---:|
|
| 66 |
+
| Pointwise MLP | 244.54 MPa | 198.82 MPa | 0.4316 |
|
| 67 |
+
| History-aware GRU | 16.52 MPa | 12.01 MPa | 0.9974 |
|
| 68 |
+
|
| 69 |
+
The comparison demonstrates that the response is not a single-valued function
|
| 70 |
+
of current strain and parameters; loading history contains essential predictive
|
| 71 |
+
information. These are reproducible reference baselines, not claims of an
|
| 72 |
+
optimal architecture.
|
| 73 |
+
|
| 74 |
+

|
| 75 |
+
|
| 76 |
+
## Lightweight use
|
| 77 |
+
|
| 78 |
+
The reader requires only NumPy and h5py:
|
| 79 |
+
|
| 80 |
+
```python
|
| 81 |
+
from src.load_t2_material_loading_memory import load_trajectory
|
| 82 |
+
|
| 83 |
+
sample = load_trajectory("data/t2_material_loading_memory_v1", 0)
|
| 84 |
+
strain = sample["history"]["signed_equivalent_strain"]
|
| 85 |
+
stress = sample["history"]["signed_equivalent_stress_pa"]
|
| 86 |
+
print(sample["material_model"], sample["path_family"], strain.shape, stress.shape)
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
## Scope and limitations
|
| 90 |
+
|
| 91 |
+
The data are synthetic three-dimensional small-strain material-point histories
|
| 92 |
+
under prescribed proportional deviatoric strain. They are not structural
|
| 93 |
+
finite-element fields, experimental material calibration or fatigue-life
|
| 94 |
+
labels. Damage, temperature dependence, finite strain and non-proportional
|
| 95 |
+
multiaxial loading are outside v1.
|
| 96 |
+
|
| 97 |
+
Chaboche is explicitly marked as an experimental AgentFEM capability. Raw
|
| 98 |
+
stress work on plastic strain is retained as a diagnostic, but it is not named
|
| 99 |
+
thermodynamic dissipation because the current material-point contract does not
|
| 100 |
+
expose a complete backstress storage/recovery energy split.
|
| 101 |
+
|
| 102 |
+
## Reproducibility and license
|
| 103 |
+
|
| 104 |
+
The dataset was generated with AgentFEM `0.3.7.dev0`, exact commit
|
| 105 |
+
`058faecc05aeda143d014fd229401003a9258bbb`. The frozen configuration,
|
| 106 |
+
restartable generator, lightweight reader, baseline and tests are included.
|
| 107 |
+
|
| 108 |
+
Dataset contents are released under CC BY 4.0. Included source code is released
|
| 109 |
+
under Apache-2.0.
|
SHA256SUMS
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
4a8e89fe65965e0b5ab34a6a1b8faa412666e426ce92500dba6af0c8f3e0ca0b CODE_LICENSE
|
| 2 |
+
cdd59472c82b98d55f37288e0dd5994059194134fba6568029052eeff64faee4 DATA_LICENSE.md
|
| 3 |
+
0a423180979b86b932b153be5cd1538fb33a288643ab4a457b716916008b7933 README.md
|
| 4 |
+
b06a19ffe36df25bbeedf35ccb8df9a9afff6df28870a354bf5c0dfc245fd948 artifacts/t2_material_loading_memory_v1/QUALITY_REPORT.md
|
| 5 |
+
d19cc739e61edff4182ed700e924af7b051f24d37f07fbfa6581eff5e589483a artifacts/t2_material_loading_memory_v1/baseline_metrics.json
|
| 6 |
+
0537f7cd76aae72abfa644761b8eec2f58903e66b8b2c040354f71650cfe0615 artifacts/t2_material_loading_memory_v1/baseline_models.pt
|
| 7 |
+
9fc457b15d4e838a7dffd1d98d92fc002ee7d4e44f919c5ce1cf37e1bad75e8b artifacts/t2_material_loading_memory_v1/baseline_predictions.png
|
| 8 |
+
d671538e1fe482de5ee12496185a7c2f65363d1376af4174016a902b1d8cb24d artifacts/t2_material_loading_memory_v1/hysteresis_preview.png
|
| 9 |
+
4986bb10e002c1c2c1648b8ff3ee20676b2982215494e7f7eafaabdf7eeda298 artifacts/t2_material_loading_memory_v1/quality.json
|
| 10 |
+
5054d2c6e6d289c928e91c67b1c2535b7fc765d00ed7e05c39ec364c35981851 configs/t2_material_loading_memory_pilot.json
|
| 11 |
+
50eb2dee418aba303e20ba6c219fb7d201d0a5a2391b933da2f3651e767191f5 configs/t2_material_loading_memory_v1.json
|
| 12 |
+
d2523144f022f78b71c0f5b006c03a393123dc8bcad190e23375a994a248330d data/t2_material_loading_memory_v1/design.jsonl
|
| 13 |
+
86ce6e7fa60f668736906c7158dfe0d5e3a8d40ca8a7e8d4e93df1d6a9afadfd data/t2_material_loading_memory_v1/index.jsonl
|
| 14 |
+
0c863700bb310edbe6363ad3ca143015279226b7d1af9db25599ae79f7beb297 data/t2_material_loading_memory_v1/manifest.json
|
| 15 |
+
bf77420e04584151af10ea6e503fe4ab09946aa8c52d097ac8d4c902362387d3 data/t2_material_loading_memory_v1/shards/part-00000.h5
|
| 16 |
+
7278e897caf225f3cb3a6e34e65881fc2c87f310f730245ab4bffb54ace475b3 data/t2_material_loading_memory_v1/shards/part-00001.h5
|
| 17 |
+
952b90eed1ce3ac288487cf31180384fc12f79aa03d95e4885bfd73b85c9a46d data/t2_material_loading_memory_v1/shards/part-00002.h5
|
| 18 |
+
5de72c7a4aba0594945cb381c33696c25c58c6f72c873098852ce68e0f447094 data/t2_material_loading_memory_v1/shards/part-00003.h5
|
| 19 |
+
37edc592132c17f9c0e0f186cf2f0fab60d7abf6135ed31834003ed3d6595801 data/t2_material_loading_memory_v1/shards/part-00004.h5
|
| 20 |
+
7039ab13425efac4e7bbdd415d31a5276acd3617a22163ad563c6817fca7360e data/t2_material_loading_memory_v1/shards/part-00005.h5
|
| 21 |
+
67739a62d001131729ce506bb575a48555dd7dbbf393ac5a30cacf5094636854 data/t2_material_loading_memory_v1/shards/part-00006.h5
|
| 22 |
+
37d8caa79a1cb672288f38e1625b4837671bfb9210416b10ce4a60ad5a912ef8 data/t2_material_loading_memory_v1/shards/part-00007.h5
|
| 23 |
+
d36bef7aa852e850a524e22f4b9689325b40320ad3046004d2f31df4c7605e26 src/baseline_t2_material_loading_memory.py
|
| 24 |
+
21158e37d8742b20ef5817bb314fb0dfe926f9633b82087a063447d8e863f9fe src/load_t2_material_loading_memory.py
|
| 25 |
+
79eddf3174eb343ef1e8dc4aef2df0a7be62819a03c594aaa22886fd49f57c2d src/t2_material_loading_memory.py
|
| 26 |
+
604bc6283e7a461073d03a3b69440873d46809baf9e2ca4c79dfbeaa0704a5d7 src/t2_material_loading_memory_v1.py
|
| 27 |
+
05c9cc11d32f54c88d3769b394b15f14bc283dc1f10b33b187b9e59166c676d6 tests/test_t2_material_loading_memory.py
|
| 28 |
+
de16ddbac7c1e9dd020d2fff57da76d56ffd4ba2ce3b1ef61b41f02295c89e5a tests/test_t2_material_loading_memory_v1.py
|
artifacts/t2_material_loading_memory_v1/QUALITY_REPORT.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# T2 material-loading-memory v1 quality report
|
| 2 |
+
|
| 3 |
+
Status: **accepted**
|
| 4 |
+
Independent trajectories: 1008
|
| 5 |
+
Quality failures: 0
|
| 6 |
+
|
| 7 |
+
## Coverage
|
| 8 |
+
|
| 9 |
+
- J2 linear isotropic hardening: 504
|
| 10 |
+
- Chaboche combined hardening: 504
|
| 11 |
+
- Six loading-path families: 168 trajectories each
|
| 12 |
+
- Train/validation/test trajectories: 768/120/120
|
| 13 |
+
- Points per trajectory: 121
|
| 14 |
+
- Packaged HDF5 shards: 8
|
| 15 |
+
|
| 16 |
+
## Verification
|
| 17 |
+
|
| 18 |
+
- Maximum yield-surface relative residual: 2.166e-11
|
| 19 |
+
- Maximum plastic-strain trace: 0.000e+00
|
| 20 |
+
- Maximum J2 monotonic analytical relative error: 4.714e-16
|
| 21 |
+
- Minimum repeated-zero-strain stress contrast in symmetric cycles: 193.713 MPa
|
| 22 |
+
- Maximum 121-to-241-point stress change across 24 audits: 0.387%
|
| 23 |
+
- Maximum 121-to-241-point PEEQ change across 24 audits: 0.129%
|
| 24 |
+
- Minimum raw `stress:plastic-strain-increment` diagnostic: -1.428e+05 J/m^3
|
| 25 |
+
- All case IDs unique: True
|
| 26 |
+
|
| 27 |
+
The data are synthetic three-dimensional small-strain material-point histories under
|
| 28 |
+
prescribed proportional deviatoric strain. They are not structural FEM fields, an
|
| 29 |
+
experimental material calibration, or fatigue-life labels. Chaboche remains explicitly
|
| 30 |
+
labelled as an experimental AgentFEM capability. For Chaboche, raw stress work on plastic
|
| 31 |
+
strain is recorded but is not labelled as thermodynamic dissipation because the current
|
| 32 |
+
material-point contract does not expose a complete backstress storage/recovery energy split.
|
| 33 |
+
|
| 34 |
+

|
artifacts/t2_material_loading_memory_v1/baseline_metrics.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"history_gru": {
|
| 3 |
+
"chaboche_combined": {
|
| 4 |
+
"mae_mpa": 12.837212656481174,
|
| 5 |
+
"r2": 0.997053655627979,
|
| 6 |
+
"range_normalized_rmse": 0.011501122865380178,
|
| 7 |
+
"rmse_mpa": 17.32188453340398
|
| 8 |
+
},
|
| 9 |
+
"j2_linear_isotropic": {
|
| 10 |
+
"mae_mpa": 11.17908518287917,
|
| 11 |
+
"r2": 0.9977184826561191,
|
| 12 |
+
"range_normalized_rmse": 0.012058524381695452,
|
| 13 |
+
"rmse_mpa": 15.672277397346926
|
| 14 |
+
},
|
| 15 |
+
"overall": {
|
| 16 |
+
"mae_mpa": 12.008148919680172,
|
| 17 |
+
"r2": 0.9974064908954444,
|
| 18 |
+
"range_normalized_rmse": 0.010967163901429768,
|
| 19 |
+
"rmse_mpa": 16.517686923537017
|
| 20 |
+
}
|
| 21 |
+
},
|
| 22 |
+
"normalization": {
|
| 23 |
+
"parameter_mean": [
|
| 24 |
+
191097290059.1636,
|
| 25 |
+
0.29465488306948845,
|
| 26 |
+
314705026.3470009,
|
| 27 |
+
2082437937.673601,
|
| 28 |
+
18496297278.725273,
|
| 29 |
+
34.82776667457074,
|
| 30 |
+
4271141687.4747887,
|
| 31 |
+
5.228669154967065,
|
| 32 |
+
35494605.25018125,
|
| 33 |
+
5.595684179708769
|
| 34 |
+
],
|
| 35 |
+
"parameter_names": [
|
| 36 |
+
"young_pa",
|
| 37 |
+
"poisson",
|
| 38 |
+
"yield_stress_pa",
|
| 39 |
+
"hardening_modulus_pa",
|
| 40 |
+
"backstress_c1_pa",
|
| 41 |
+
"backstress_gamma1",
|
| 42 |
+
"backstress_c2_pa",
|
| 43 |
+
"backstress_gamma2",
|
| 44 |
+
"isotropic_saturation_pa",
|
| 45 |
+
"isotropic_rate"
|
| 46 |
+
],
|
| 47 |
+
"parameter_scale": [
|
| 48 |
+
22764894888.991604,
|
| 49 |
+
0.02591473412611028,
|
| 50 |
+
76635956.73250286,
|
| 51 |
+
2579853541.284986,
|
| 52 |
+
20671344586.386173,
|
| 53 |
+
40.363554335079115,
|
| 54 |
+
4997449643.931367,
|
| 55 |
+
6.547008002361187,
|
| 56 |
+
41055780.03282887,
|
| 57 |
+
6.6352674608519955
|
| 58 |
+
],
|
| 59 |
+
"strain_scale": 0.013482345574567714,
|
| 60 |
+
"stress_scale_pa": 325595658.3862858
|
| 61 |
+
},
|
| 62 |
+
"pointwise_mlp": {
|
| 63 |
+
"chaboche_combined": {
|
| 64 |
+
"mae_mpa": 174.96636413415263,
|
| 65 |
+
"r2": 0.5650588979566006,
|
| 66 |
+
"range_normalized_rmse": 0.13973774001891945,
|
| 67 |
+
"rmse_mpa": 210.4595373772259
|
| 68 |
+
},
|
| 69 |
+
"j2_linear_isotropic": {
|
| 70 |
+
"mae_mpa": 222.68187339076022,
|
| 71 |
+
"r2": 0.3005172750573124,
|
| 72 |
+
"range_normalized_rmse": 0.2111401254033973,
|
| 73 |
+
"rmse_mpa": 274.415551214186
|
| 74 |
+
},
|
| 75 |
+
"overall": {
|
| 76 |
+
"mae_mpa": 198.8241187624564,
|
| 77 |
+
"r2": 0.43156604542855415,
|
| 78 |
+
"range_normalized_rmse": 0.1623642652154708,
|
| 79 |
+
"rmse_mpa": 244.5374323301256
|
| 80 |
+
}
|
| 81 |
+
},
|
| 82 |
+
"split_policy": "complete trajectories; normalization fitted on train only",
|
| 83 |
+
"status": "completed",
|
| 84 |
+
"task": "signed-equivalent-stress history prediction",
|
| 85 |
+
"test_trajectory_count": 120,
|
| 86 |
+
"torch_version": "2.13.0",
|
| 87 |
+
"wall_seconds": 23.655544749926776
|
| 88 |
+
}
|
artifacts/t2_material_loading_memory_v1/baseline_models.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0537f7cd76aae72abfa644761b8eec2f58903e66b8b2c040354f71650cfe0615
|
| 3 |
+
size 87167
|
artifacts/t2_material_loading_memory_v1/baseline_predictions.png
ADDED
|
Git LFS Details
|
artifacts/t2_material_loading_memory_v1/hysteresis_preview.png
ADDED
|
Git LFS Details
|
artifacts/t2_material_loading_memory_v1/quality.json
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"agentfem_commit": "058faecc05aeda143d014fd229401003a9258bbb",
|
| 3 |
+
"agentfem_version": "0.3.7.dev0",
|
| 4 |
+
"all_case_ids_unique": true,
|
| 5 |
+
"data_bytes": 76029327,
|
| 6 |
+
"material_models": {
|
| 7 |
+
"chaboche_combined": 504,
|
| 8 |
+
"j2_linear_isotropic": 504
|
| 9 |
+
},
|
| 10 |
+
"maximum_j2_analytical_relative_error": 4.713687395585475e-16,
|
| 11 |
+
"maximum_plastic_strain_trace": 0.0,
|
| 12 |
+
"maximum_refined_peeq_relative_change": 0.0012918014334128156,
|
| 13 |
+
"maximum_refined_stress_relative_change": 0.0038699701283640207,
|
| 14 |
+
"maximum_yield_surface_relative_residual": 2.16579096075354e-11,
|
| 15 |
+
"minimum_plastic_work_increment_j_m3": -142826.47301995277,
|
| 16 |
+
"minimum_symmetric_zero_strain_memory_contrast_pa": 193713300.83466035,
|
| 17 |
+
"path_families": {
|
| 18 |
+
"mean_shifted_cyclic": 168,
|
| 19 |
+
"monotonic_tension": 168,
|
| 20 |
+
"symmetric_cyclic": 168,
|
| 21 |
+
"tension_compression": 168,
|
| 22 |
+
"unload_reload": 168,
|
| 23 |
+
"variable_amplitude": 168
|
| 24 |
+
},
|
| 25 |
+
"points_per_trajectory": 121,
|
| 26 |
+
"preview": "artifacts/t2_material_loading_memory_v1/hysteresis_preview.png",
|
| 27 |
+
"quality_failure_count": 0,
|
| 28 |
+
"quality_failures": [],
|
| 29 |
+
"refinement_audits": [
|
| 30 |
+
{
|
| 31 |
+
"index": 0,
|
| 32 |
+
"material_model": "j2_linear_isotropic",
|
| 33 |
+
"maximum_peeq_relative_change": 1.9691100487952772e-16,
|
| 34 |
+
"maximum_stress_relative_change": 4.0495326567019173e-16,
|
| 35 |
+
"path_family": "monotonic_tension"
|
| 36 |
+
},
|
| 37 |
+
{
|
| 38 |
+
"index": 83,
|
| 39 |
+
"material_model": "j2_linear_isotropic",
|
| 40 |
+
"maximum_peeq_relative_change": 2.2141051965947146e-16,
|
| 41 |
+
"maximum_stress_relative_change": 3.2491654772037307e-16,
|
| 42 |
+
"path_family": "monotonic_tension"
|
| 43 |
+
},
|
| 44 |
+
{
|
| 45 |
+
"index": 84,
|
| 46 |
+
"material_model": "j2_linear_isotropic",
|
| 47 |
+
"maximum_peeq_relative_change": 5.872047860997571e-16,
|
| 48 |
+
"maximum_stress_relative_change": 4.809200195348651e-16,
|
| 49 |
+
"path_family": "unload_reload"
|
| 50 |
+
},
|
| 51 |
+
{
|
| 52 |
+
"index": 167,
|
| 53 |
+
"material_model": "j2_linear_isotropic",
|
| 54 |
+
"maximum_peeq_relative_change": 9.455615721006915e-16,
|
| 55 |
+
"maximum_stress_relative_change": 3.5057748529466403e-16,
|
| 56 |
+
"path_family": "unload_reload"
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"index": 168,
|
| 60 |
+
"material_model": "j2_linear_isotropic",
|
| 61 |
+
"maximum_peeq_relative_change": 7.195511936407169e-16,
|
| 62 |
+
"maximum_stress_relative_change": 4.1591366364598886e-16,
|
| 63 |
+
"path_family": "tension_compression"
|
| 64 |
+
},
|
| 65 |
+
{
|
| 66 |
+
"index": 251,
|
| 67 |
+
"material_model": "j2_linear_isotropic",
|
| 68 |
+
"maximum_peeq_relative_change": 5.03263695603114e-16,
|
| 69 |
+
"maximum_stress_relative_change": 4.134529023380189e-16,
|
| 70 |
+
"path_family": "tension_compression"
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"index": 252,
|
| 74 |
+
"material_model": "j2_linear_isotropic",
|
| 75 |
+
"maximum_peeq_relative_change": 2.4080288084231124e-15,
|
| 76 |
+
"maximum_stress_relative_change": 1.1444269888020809e-15,
|
| 77 |
+
"path_family": "symmetric_cyclic"
|
| 78 |
+
},
|
| 79 |
+
{
|
| 80 |
+
"index": 335,
|
| 81 |
+
"material_model": "j2_linear_isotropic",
|
| 82 |
+
"maximum_peeq_relative_change": 1.0883566441967917e-15,
|
| 83 |
+
"maximum_stress_relative_change": 6.111208028918634e-16,
|
| 84 |
+
"path_family": "symmetric_cyclic"
|
| 85 |
+
},
|
| 86 |
+
{
|
| 87 |
+
"index": 336,
|
| 88 |
+
"material_model": "j2_linear_isotropic",
|
| 89 |
+
"maximum_peeq_relative_change": 3.185831716980416e-16,
|
| 90 |
+
"maximum_stress_relative_change": 3.2417814226270937e-16,
|
| 91 |
+
"path_family": "mean_shifted_cyclic"
|
| 92 |
+
},
|
| 93 |
+
{
|
| 94 |
+
"index": 419,
|
| 95 |
+
"material_model": "j2_linear_isotropic",
|
| 96 |
+
"maximum_peeq_relative_change": 2.9976886982131045e-15,
|
| 97 |
+
"maximum_stress_relative_change": 7.126659468347532e-16,
|
| 98 |
+
"path_family": "mean_shifted_cyclic"
|
| 99 |
+
},
|
| 100 |
+
{
|
| 101 |
+
"index": 420,
|
| 102 |
+
"material_model": "j2_linear_isotropic",
|
| 103 |
+
"maximum_peeq_relative_change": 1.8132803564402278e-15,
|
| 104 |
+
"maximum_stress_relative_change": 6.008433503440595e-16,
|
| 105 |
+
"path_family": "variable_amplitude"
|
| 106 |
+
},
|
| 107 |
+
{
|
| 108 |
+
"index": 503,
|
| 109 |
+
"material_model": "j2_linear_isotropic",
|
| 110 |
+
"maximum_peeq_relative_change": 4.926407148119625e-16,
|
| 111 |
+
"maximum_stress_relative_change": 5.465031339597028e-16,
|
| 112 |
+
"path_family": "variable_amplitude"
|
| 113 |
+
},
|
| 114 |
+
{
|
| 115 |
+
"index": 504,
|
| 116 |
+
"material_model": "chaboche_combined",
|
| 117 |
+
"maximum_peeq_relative_change": 4.7689064477326605e-05,
|
| 118 |
+
"maximum_stress_relative_change": 3.623405365425279e-05,
|
| 119 |
+
"path_family": "monotonic_tension"
|
| 120 |
+
},
|
| 121 |
+
{
|
| 122 |
+
"index": 587,
|
| 123 |
+
"material_model": "chaboche_combined",
|
| 124 |
+
"maximum_peeq_relative_change": 5.291163194442036e-05,
|
| 125 |
+
"maximum_stress_relative_change": 8.5340277015935e-05,
|
| 126 |
+
"path_family": "monotonic_tension"
|
| 127 |
+
},
|
| 128 |
+
{
|
| 129 |
+
"index": 588,
|
| 130 |
+
"material_model": "chaboche_combined",
|
| 131 |
+
"maximum_peeq_relative_change": 0.00022050968191946916,
|
| 132 |
+
"maximum_stress_relative_change": 0.00035889290512209027,
|
| 133 |
+
"path_family": "unload_reload"
|
| 134 |
+
},
|
| 135 |
+
{
|
| 136 |
+
"index": 671,
|
| 137 |
+
"material_model": "chaboche_combined",
|
| 138 |
+
"maximum_peeq_relative_change": 0.00019081420746639962,
|
| 139 |
+
"maximum_stress_relative_change": 0.0004410244818224862,
|
| 140 |
+
"path_family": "unload_reload"
|
| 141 |
+
},
|
| 142 |
+
{
|
| 143 |
+
"index": 672,
|
| 144 |
+
"material_model": "chaboche_combined",
|
| 145 |
+
"maximum_peeq_relative_change": 0.00022023114380788846,
|
| 146 |
+
"maximum_stress_relative_change": 0.0004410479264523355,
|
| 147 |
+
"path_family": "tension_compression"
|
| 148 |
+
},
|
| 149 |
+
{
|
| 150 |
+
"index": 755,
|
| 151 |
+
"material_model": "chaboche_combined",
|
| 152 |
+
"maximum_peeq_relative_change": 0.00020046996696709512,
|
| 153 |
+
"maximum_stress_relative_change": 0.00033472825896666594,
|
| 154 |
+
"path_family": "tension_compression"
|
| 155 |
+
},
|
| 156 |
+
{
|
| 157 |
+
"index": 756,
|
| 158 |
+
"material_model": "chaboche_combined",
|
| 159 |
+
"maximum_peeq_relative_change": 0.0008566275658290944,
|
| 160 |
+
"maximum_stress_relative_change": 0.0007693778418125614,
|
| 161 |
+
"path_family": "symmetric_cyclic"
|
| 162 |
+
},
|
| 163 |
+
{
|
| 164 |
+
"index": 839,
|
| 165 |
+
"material_model": "chaboche_combined",
|
| 166 |
+
"maximum_peeq_relative_change": 0.001033225845075327,
|
| 167 |
+
"maximum_stress_relative_change": 0.0038699701283640207,
|
| 168 |
+
"path_family": "symmetric_cyclic"
|
| 169 |
+
},
|
| 170 |
+
{
|
| 171 |
+
"index": 840,
|
| 172 |
+
"material_model": "chaboche_combined",
|
| 173 |
+
"maximum_peeq_relative_change": 0.0012918014334128156,
|
| 174 |
+
"maximum_stress_relative_change": 0.001690629833999976,
|
| 175 |
+
"path_family": "mean_shifted_cyclic"
|
| 176 |
+
},
|
| 177 |
+
{
|
| 178 |
+
"index": 923,
|
| 179 |
+
"material_model": "chaboche_combined",
|
| 180 |
+
"maximum_peeq_relative_change": 0.0003638695281148608,
|
| 181 |
+
"maximum_stress_relative_change": 0.00037712200092439026,
|
| 182 |
+
"path_family": "mean_shifted_cyclic"
|
| 183 |
+
},
|
| 184 |
+
{
|
| 185 |
+
"index": 924,
|
| 186 |
+
"material_model": "chaboche_combined",
|
| 187 |
+
"maximum_peeq_relative_change": 0.0008002457139733245,
|
| 188 |
+
"maximum_stress_relative_change": 0.001113976631730561,
|
| 189 |
+
"path_family": "variable_amplitude"
|
| 190 |
+
},
|
| 191 |
+
{
|
| 192 |
+
"index": 1007,
|
| 193 |
+
"material_model": "chaboche_combined",
|
| 194 |
+
"maximum_peeq_relative_change": 0.0007903616798123826,
|
| 195 |
+
"maximum_stress_relative_change": 0.002678974417237217,
|
| 196 |
+
"path_family": "variable_amplitude"
|
| 197 |
+
}
|
| 198 |
+
],
|
| 199 |
+
"sample_count": 1008,
|
| 200 |
+
"splits": {
|
| 201 |
+
"test": 120,
|
| 202 |
+
"train": 768,
|
| 203 |
+
"validation": 120
|
| 204 |
+
},
|
| 205 |
+
"status": "accepted"
|
| 206 |
+
}
|
configs/t2_material_loading_memory_pilot.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "agentfem.physics-data.material-loading-memory",
|
| 3 |
+
"schema_version": "0.1.0",
|
| 4 |
+
"dataset_version": "pilot-0.1",
|
| 5 |
+
"seed": 20260925,
|
| 6 |
+
"sample_count": 96,
|
| 7 |
+
"points_per_trajectory": 121,
|
| 8 |
+
"material_models": {
|
| 9 |
+
"j2_linear_isotropic": 48,
|
| 10 |
+
"chaboche_combined": 48
|
| 11 |
+
},
|
| 12 |
+
"path_families": {
|
| 13 |
+
"monotonic_tension": 16,
|
| 14 |
+
"unload_reload": 16,
|
| 15 |
+
"tension_compression": 16,
|
| 16 |
+
"symmetric_cyclic": 16,
|
| 17 |
+
"mean_shifted_cyclic": 16,
|
| 18 |
+
"variable_amplitude": 16
|
| 19 |
+
},
|
| 20 |
+
"splits": {
|
| 21 |
+
"train": 72,
|
| 22 |
+
"validation": 12,
|
| 23 |
+
"test": 12
|
| 24 |
+
},
|
| 25 |
+
"ranges": {
|
| 26 |
+
"young_pa": [150000000000.0, 230000000000.0],
|
| 27 |
+
"poisson": [0.25, 0.34],
|
| 28 |
+
"yield_stress_pa": [180000000.0, 450000000.0],
|
| 29 |
+
"maximum_equivalent_strain": [0.003, 0.012],
|
| 30 |
+
"j2_hardening_modulus_pa": [500000000.0, 8000000000.0],
|
| 31 |
+
"chaboche_c1_pa": [15000000000.0, 60000000000.0],
|
| 32 |
+
"chaboche_gamma1": [20.0, 120.0],
|
| 33 |
+
"chaboche_c2_pa": [2000000000.0, 15000000000.0],
|
| 34 |
+
"chaboche_gamma2": [1.0, 20.0],
|
| 35 |
+
"chaboche_isotropic_saturation_pa": [20000000.0, 120000000.0],
|
| 36 |
+
"chaboche_isotropic_rate": [2.0, 20.0]
|
| 37 |
+
},
|
| 38 |
+
"quality_thresholds": {
|
| 39 |
+
"initial_stress_pa": 0.001,
|
| 40 |
+
"plastic_strain_trace": 1e-10,
|
| 41 |
+
"equivalent_plastic_strain_decrease": 1e-12,
|
| 42 |
+
"yield_surface_relative_residual": 1e-8,
|
| 43 |
+
"j2_monotonic_analytical_relative_error": 1e-10,
|
| 44 |
+
"zero_strain_memory_contrast_pa": 1000000.0,
|
| 45 |
+
"refined_stress_relative_change": 0.02,
|
| 46 |
+
"refined_peeq_relative_change": 0.05,
|
| 47 |
+
"j2_plastic_work_negative_tolerance_j_m3": 0.01,
|
| 48 |
+
"final_plastic_work_minimum_j_m3": 0.0
|
| 49 |
+
},
|
| 50 |
+
"scope": "Synthetic three-dimensional small-strain material-point trajectories under prescribed proportional deviatoric strain. J2 linear isotropic hardening and experimental Chaboche combined hardening are separate labels. No experimental calibration, fatigue-life label, damage, temperature dependence, finite-strain claim or structural FEM field claim."
|
| 51 |
+
}
|
configs/t2_material_loading_memory_v1.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "agentfem.physics-data.material-loading-memory",
|
| 3 |
+
"schema_version": "1.0.0",
|
| 4 |
+
"dataset_version": "1.0.0",
|
| 5 |
+
"seed": 20260925,
|
| 6 |
+
"sample_count": 1008,
|
| 7 |
+
"samples_per_stratum": 84,
|
| 8 |
+
"points_per_trajectory": 121,
|
| 9 |
+
"shard_count": 8,
|
| 10 |
+
"material_models": {
|
| 11 |
+
"j2_linear_isotropic": 504,
|
| 12 |
+
"chaboche_combined": 504
|
| 13 |
+
},
|
| 14 |
+
"path_families": {
|
| 15 |
+
"monotonic_tension": 168,
|
| 16 |
+
"unload_reload": 168,
|
| 17 |
+
"tension_compression": 168,
|
| 18 |
+
"symmetric_cyclic": 168,
|
| 19 |
+
"mean_shifted_cyclic": 168,
|
| 20 |
+
"variable_amplitude": 168
|
| 21 |
+
},
|
| 22 |
+
"splits": {
|
| 23 |
+
"train": 768,
|
| 24 |
+
"validation": 120,
|
| 25 |
+
"test": 120
|
| 26 |
+
},
|
| 27 |
+
"ranges": {
|
| 28 |
+
"young_pa": [150000000000.0, 230000000000.0],
|
| 29 |
+
"poisson": [0.25, 0.34],
|
| 30 |
+
"yield_stress_pa": [180000000.0, 450000000.0],
|
| 31 |
+
"maximum_equivalent_strain": [0.003, 0.012],
|
| 32 |
+
"j2_hardening_modulus_pa": [500000000.0, 8000000000.0],
|
| 33 |
+
"chaboche_c1_pa": [15000000000.0, 60000000000.0],
|
| 34 |
+
"chaboche_gamma1": [20.0, 120.0],
|
| 35 |
+
"chaboche_c2_pa": [2000000000.0, 15000000000.0],
|
| 36 |
+
"chaboche_gamma2": [1.0, 20.0],
|
| 37 |
+
"chaboche_isotropic_saturation_pa": [20000000.0, 120000000.0],
|
| 38 |
+
"chaboche_isotropic_rate": [2.0, 20.0]
|
| 39 |
+
},
|
| 40 |
+
"quality_thresholds": {
|
| 41 |
+
"initial_stress_pa": 0.001,
|
| 42 |
+
"plastic_strain_trace": 1e-10,
|
| 43 |
+
"equivalent_plastic_strain_decrease": 1e-12,
|
| 44 |
+
"yield_surface_relative_residual": 1e-8,
|
| 45 |
+
"j2_monotonic_analytical_relative_error": 1e-10,
|
| 46 |
+
"zero_strain_memory_contrast_pa": 1000000.0,
|
| 47 |
+
"refined_stress_relative_change": 0.02,
|
| 48 |
+
"refined_peeq_relative_change": 0.05,
|
| 49 |
+
"j2_plastic_work_negative_tolerance_j_m3": 0.01,
|
| 50 |
+
"final_plastic_work_minimum_j_m3": 0.0
|
| 51 |
+
},
|
| 52 |
+
"scope": "Synthetic three-dimensional small-strain material-point trajectories under prescribed proportional deviatoric strain. J2 linear isotropic hardening and experimental Chaboche combined hardening are separate labels. No experimental calibration, fatigue-life label, damage, temperature dependence, finite-strain claim or structural FEM field claim."
|
| 53 |
+
}
|
data/t2_material_loading_memory_v1/design.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/t2_material_loading_memory_v1/index.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/t2_material_loading_memory_v1/manifest.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"agentfem_commit": "058faecc05aeda143d014fd229401003a9258bbb",
|
| 3 |
+
"agentfem_version": "0.3.7.dev0",
|
| 4 |
+
"dataset_version": "1.0.0",
|
| 5 |
+
"points_per_trajectory": 121,
|
| 6 |
+
"sample_count": 1008,
|
| 7 |
+
"schema": "agentfem.physics-data.material-loading-memory",
|
| 8 |
+
"schema_version": "1.0.0",
|
| 9 |
+
"shards": [
|
| 10 |
+
{
|
| 11 |
+
"bytes": 9088040,
|
| 12 |
+
"first_id": "00000",
|
| 13 |
+
"last_id": "00125",
|
| 14 |
+
"path": "data/t2_material_loading_memory_v1/shards/part-00000.h5",
|
| 15 |
+
"sample_count": 126,
|
| 16 |
+
"sha256": "bf77420e04584151af10ea6e503fe4ab09946aa8c52d097ac8d4c902362387d3"
|
| 17 |
+
},
|
| 18 |
+
{
|
| 19 |
+
"bytes": 9153896,
|
| 20 |
+
"first_id": "00126",
|
| 21 |
+
"last_id": "00251",
|
| 22 |
+
"path": "data/t2_material_loading_memory_v1/shards/part-00001.h5",
|
| 23 |
+
"sample_count": 126,
|
| 24 |
+
"sha256": "7278e897caf225f3cb3a6e34e65881fc2c87f310f730245ab4bffb54ace475b3"
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"bytes": 8964284,
|
| 28 |
+
"first_id": "00252",
|
| 29 |
+
"last_id": "00377",
|
| 30 |
+
"path": "data/t2_material_loading_memory_v1/shards/part-00002.h5",
|
| 31 |
+
"sample_count": 126,
|
| 32 |
+
"sha256": "952b90eed1ce3ac288487cf31180384fc12f79aa03d95e4885bfd73b85c9a46d"
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"bytes": 9141402,
|
| 36 |
+
"first_id": "00378",
|
| 37 |
+
"last_id": "00503",
|
| 38 |
+
"path": "data/t2_material_loading_memory_v1/shards/part-00003.h5",
|
| 39 |
+
"sample_count": 126,
|
| 40 |
+
"sha256": "5de72c7a4aba0594945cb381c33696c25c58c6f72c873098852ce68e0f447094"
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"bytes": 9889328,
|
| 44 |
+
"first_id": "00504",
|
| 45 |
+
"last_id": "00629",
|
| 46 |
+
"path": "data/t2_material_loading_memory_v1/shards/part-00004.h5",
|
| 47 |
+
"sample_count": 126,
|
| 48 |
+
"sha256": "37edc592132c17f9c0e0f186cf2f0fab60d7abf6135ed31834003ed3d6595801"
|
| 49 |
+
},
|
| 50 |
+
{
|
| 51 |
+
"bytes": 9964093,
|
| 52 |
+
"first_id": "00630",
|
| 53 |
+
"last_id": "00755",
|
| 54 |
+
"path": "data/t2_material_loading_memory_v1/shards/part-00005.h5",
|
| 55 |
+
"sample_count": 126,
|
| 56 |
+
"sha256": "7039ab13425efac4e7bbdd415d31a5276acd3617a22163ad563c6817fca7360e"
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"bytes": 9860839,
|
| 60 |
+
"first_id": "00756",
|
| 61 |
+
"last_id": "00881",
|
| 62 |
+
"path": "data/t2_material_loading_memory_v1/shards/part-00006.h5",
|
| 63 |
+
"sample_count": 126,
|
| 64 |
+
"sha256": "67739a62d001131729ce506bb575a48555dd7dbbf393ac5a30cacf5094636854"
|
| 65 |
+
},
|
| 66 |
+
{
|
| 67 |
+
"bytes": 9967445,
|
| 68 |
+
"first_id": "00882",
|
| 69 |
+
"last_id": "01007",
|
| 70 |
+
"path": "data/t2_material_loading_memory_v1/shards/part-00007.h5",
|
| 71 |
+
"sample_count": 126,
|
| 72 |
+
"sha256": "37d8caa79a1cb672288f38e1625b4837671bfb9210416b10ce4a60ad5a912ef8"
|
| 73 |
+
}
|
| 74 |
+
]
|
| 75 |
+
}
|
data/t2_material_loading_memory_v1/shards/part-00000.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bf77420e04584151af10ea6e503fe4ab09946aa8c52d097ac8d4c902362387d3
|
| 3 |
+
size 9088040
|
data/t2_material_loading_memory_v1/shards/part-00001.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7278e897caf225f3cb3a6e34e65881fc2c87f310f730245ab4bffb54ace475b3
|
| 3 |
+
size 9153896
|
data/t2_material_loading_memory_v1/shards/part-00002.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:952b90eed1ce3ac288487cf31180384fc12f79aa03d95e4885bfd73b85c9a46d
|
| 3 |
+
size 8964284
|
data/t2_material_loading_memory_v1/shards/part-00003.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5de72c7a4aba0594945cb381c33696c25c58c6f72c873098852ce68e0f447094
|
| 3 |
+
size 9141402
|
data/t2_material_loading_memory_v1/shards/part-00004.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:37edc592132c17f9c0e0f186cf2f0fab60d7abf6135ed31834003ed3d6595801
|
| 3 |
+
size 9889328
|
data/t2_material_loading_memory_v1/shards/part-00005.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7039ab13425efac4e7bbdd415d31a5276acd3617a22163ad563c6817fca7360e
|
| 3 |
+
size 9964093
|
data/t2_material_loading_memory_v1/shards/part-00006.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:67739a62d001131729ce506bb575a48555dd7dbbf393ac5a30cacf5094636854
|
| 3 |
+
size 9860839
|
data/t2_material_loading_memory_v1/shards/part-00007.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:37d8caa79a1cb672288f38e1625b4837671bfb9210416b10ce4a60ad5a912ef8
|
| 3 |
+
size 9967445
|
src/baseline_t2_material_loading_memory.py
ADDED
|
@@ -0,0 +1,337 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Train pointwise-MLP and history-aware GRU baselines for T2 v1."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import argparse
|
| 6 |
+
import json
|
| 7 |
+
import time
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
import matplotlib
|
| 11 |
+
|
| 12 |
+
matplotlib.use("Agg")
|
| 13 |
+
import matplotlib.pyplot as plt
|
| 14 |
+
import numpy as np
|
| 15 |
+
import torch
|
| 16 |
+
from torch import nn
|
| 17 |
+
from torch.utils.data import DataLoader, TensorDataset
|
| 18 |
+
|
| 19 |
+
try:
|
| 20 |
+
from src.load_t2_material_loading_memory import iter_trajectories
|
| 21 |
+
except ModuleNotFoundError:
|
| 22 |
+
from load_t2_material_loading_memory import iter_trajectories
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
ROOT = Path(__file__).resolve().parents[1]
|
| 26 |
+
DATA_DIR = ROOT / "data" / "t2_material_loading_memory_v1"
|
| 27 |
+
ARTIFACT_DIR = ROOT / "artifacts" / "t2_material_loading_memory_v1"
|
| 28 |
+
PARAMETER_NAMES = (
|
| 29 |
+
"young_pa",
|
| 30 |
+
"poisson",
|
| 31 |
+
"yield_stress_pa",
|
| 32 |
+
"hardening_modulus_pa",
|
| 33 |
+
"backstress_c1_pa",
|
| 34 |
+
"backstress_gamma1",
|
| 35 |
+
"backstress_c2_pa",
|
| 36 |
+
"backstress_gamma2",
|
| 37 |
+
"isotropic_saturation_pa",
|
| 38 |
+
"isotropic_rate",
|
| 39 |
+
)
|
| 40 |
+
MODEL_NAMES = ("j2_linear_isotropic", "chaboche_combined")
|
| 41 |
+
PATH_FAMILIES = (
|
| 42 |
+
"monotonic_tension",
|
| 43 |
+
"unload_reload",
|
| 44 |
+
"tension_compression",
|
| 45 |
+
"symmetric_cyclic",
|
| 46 |
+
"mean_shifted_cyclic",
|
| 47 |
+
"variable_amplitude",
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
class PointwiseMLP(nn.Module):
|
| 52 |
+
def __init__(self, input_size: int) -> None:
|
| 53 |
+
super().__init__()
|
| 54 |
+
self.network = nn.Sequential(
|
| 55 |
+
nn.Linear(input_size, 64),
|
| 56 |
+
nn.Tanh(),
|
| 57 |
+
nn.Linear(64, 64),
|
| 58 |
+
nn.Tanh(),
|
| 59 |
+
nn.Linear(64, 1),
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
def forward(self, values: torch.Tensor) -> torch.Tensor:
|
| 63 |
+
return self.network(values)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
class HistoryGRU(nn.Module):
|
| 67 |
+
def __init__(self, input_size: int) -> None:
|
| 68 |
+
super().__init__()
|
| 69 |
+
self.recurrent = nn.GRU(input_size, 64, batch_first=True)
|
| 70 |
+
self.output = nn.Linear(64, 1)
|
| 71 |
+
|
| 72 |
+
def forward(self, values: torch.Tensor) -> torch.Tensor:
|
| 73 |
+
hidden, _ = self.recurrent(values)
|
| 74 |
+
return self.output(hidden)
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def _load_arrays() -> dict[str, object]:
|
| 78 |
+
samples = list(iter_trajectories(DATA_DIR))
|
| 79 |
+
parameters = np.asarray(
|
| 80 |
+
[[float(sample["parameters"][name]) for name in PARAMETER_NAMES] for sample in samples],
|
| 81 |
+
dtype=np.float64,
|
| 82 |
+
)
|
| 83 |
+
model_one_hot = np.zeros((len(samples), len(MODEL_NAMES)), dtype=np.float64)
|
| 84 |
+
for index, sample in enumerate(samples):
|
| 85 |
+
model_one_hot[index, MODEL_NAMES.index(sample["material_model"])] = 1.0
|
| 86 |
+
strain = np.asarray(
|
| 87 |
+
[sample["history"]["signed_equivalent_strain"] for sample in samples],
|
| 88 |
+
dtype=np.float64,
|
| 89 |
+
)
|
| 90 |
+
stress = np.asarray(
|
| 91 |
+
[sample["history"]["signed_equivalent_stress_pa"] for sample in samples],
|
| 92 |
+
dtype=np.float64,
|
| 93 |
+
)
|
| 94 |
+
splits = np.asarray([sample["split"] for sample in samples])
|
| 95 |
+
train = splits == "train"
|
| 96 |
+
parameter_mean = parameters[train].mean(axis=0)
|
| 97 |
+
parameter_scale = parameters[train].std(axis=0)
|
| 98 |
+
parameter_scale[parameter_scale < 1.0e-15] = 1.0
|
| 99 |
+
normalized_parameters = (parameters - parameter_mean) / parameter_scale
|
| 100 |
+
strain_scale = float(np.max(np.abs(strain[train])))
|
| 101 |
+
normalized_strain = strain / strain_scale
|
| 102 |
+
delta = np.diff(normalized_strain, axis=1, prepend=normalized_strain[:, :1])
|
| 103 |
+
constant = np.concatenate((normalized_parameters, model_one_hot), axis=1)
|
| 104 |
+
repeated = np.repeat(constant[:, None, :], strain.shape[1], axis=1)
|
| 105 |
+
pointwise = np.concatenate((normalized_strain[:, :, None], repeated), axis=2)
|
| 106 |
+
history = np.concatenate(
|
| 107 |
+
(normalized_strain[:, :, None], delta[:, :, None], repeated), axis=2
|
| 108 |
+
)
|
| 109 |
+
stress_scale = float(np.std(stress[train]))
|
| 110 |
+
target = stress / stress_scale
|
| 111 |
+
return {
|
| 112 |
+
"samples": samples,
|
| 113 |
+
"pointwise": pointwise.astype(np.float32),
|
| 114 |
+
"history": history.astype(np.float32),
|
| 115 |
+
"target": target.astype(np.float32),
|
| 116 |
+
"stress_pa": stress,
|
| 117 |
+
"splits": splits,
|
| 118 |
+
"normalization": {
|
| 119 |
+
"parameter_names": list(PARAMETER_NAMES),
|
| 120 |
+
"parameter_mean": parameter_mean.tolist(),
|
| 121 |
+
"parameter_scale": parameter_scale.tolist(),
|
| 122 |
+
"strain_scale": strain_scale,
|
| 123 |
+
"stress_scale_pa": stress_scale,
|
| 124 |
+
},
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
def _train_pointwise(
|
| 129 |
+
features: np.ndarray,
|
| 130 |
+
target: np.ndarray,
|
| 131 |
+
train: np.ndarray,
|
| 132 |
+
validation: np.ndarray,
|
| 133 |
+
*,
|
| 134 |
+
epochs: int,
|
| 135 |
+
) -> PointwiseMLP:
|
| 136 |
+
model = PointwiseMLP(features.shape[-1])
|
| 137 |
+
optimizer = torch.optim.Adam(model.parameters(), lr=2.0e-3)
|
| 138 |
+
criterion = nn.MSELoss()
|
| 139 |
+
x_train = torch.from_numpy(features[train].reshape(-1, features.shape[-1]))
|
| 140 |
+
y_train = torch.from_numpy(target[train].reshape(-1, 1))
|
| 141 |
+
loader = DataLoader(TensorDataset(x_train, y_train), batch_size=4096, shuffle=True)
|
| 142 |
+
x_validation = torch.from_numpy(
|
| 143 |
+
features[validation].reshape(-1, features.shape[-1])
|
| 144 |
+
)
|
| 145 |
+
y_validation = torch.from_numpy(target[validation].reshape(-1, 1))
|
| 146 |
+
best: dict[str, torch.Tensor] | None = None
|
| 147 |
+
best_loss = float("inf")
|
| 148 |
+
remaining = 6
|
| 149 |
+
for _ in range(epochs):
|
| 150 |
+
model.train()
|
| 151 |
+
for x_batch, y_batch in loader:
|
| 152 |
+
optimizer.zero_grad()
|
| 153 |
+
loss = criterion(model(x_batch), y_batch)
|
| 154 |
+
loss.backward()
|
| 155 |
+
optimizer.step()
|
| 156 |
+
model.eval()
|
| 157 |
+
with torch.no_grad():
|
| 158 |
+
loss = float(criterion(model(x_validation), y_validation))
|
| 159 |
+
if loss < best_loss - 1.0e-6:
|
| 160 |
+
best_loss = loss
|
| 161 |
+
best = {name: value.detach().clone() for name, value in model.state_dict().items()}
|
| 162 |
+
remaining = 6
|
| 163 |
+
else:
|
| 164 |
+
remaining -= 1
|
| 165 |
+
if remaining == 0:
|
| 166 |
+
break
|
| 167 |
+
if best is not None:
|
| 168 |
+
model.load_state_dict(best)
|
| 169 |
+
return model
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
def _train_gru(
|
| 173 |
+
features: np.ndarray,
|
| 174 |
+
target: np.ndarray,
|
| 175 |
+
train: np.ndarray,
|
| 176 |
+
validation: np.ndarray,
|
| 177 |
+
*,
|
| 178 |
+
epochs: int,
|
| 179 |
+
) -> HistoryGRU:
|
| 180 |
+
model = HistoryGRU(features.shape[-1])
|
| 181 |
+
optimizer = torch.optim.Adam(model.parameters(), lr=2.0e-3)
|
| 182 |
+
criterion = nn.MSELoss()
|
| 183 |
+
loader = DataLoader(
|
| 184 |
+
TensorDataset(torch.from_numpy(features[train]), torch.from_numpy(target[train, :, None])),
|
| 185 |
+
batch_size=32,
|
| 186 |
+
shuffle=True,
|
| 187 |
+
)
|
| 188 |
+
x_validation = torch.from_numpy(features[validation])
|
| 189 |
+
y_validation = torch.from_numpy(target[validation, :, None])
|
| 190 |
+
best: dict[str, torch.Tensor] | None = None
|
| 191 |
+
best_loss = float("inf")
|
| 192 |
+
remaining = 8
|
| 193 |
+
for _ in range(epochs):
|
| 194 |
+
model.train()
|
| 195 |
+
for x_batch, y_batch in loader:
|
| 196 |
+
optimizer.zero_grad()
|
| 197 |
+
loss = criterion(model(x_batch), y_batch)
|
| 198 |
+
loss.backward()
|
| 199 |
+
optimizer.step()
|
| 200 |
+
model.eval()
|
| 201 |
+
with torch.no_grad():
|
| 202 |
+
loss = float(criterion(model(x_validation), y_validation))
|
| 203 |
+
if loss < best_loss - 1.0e-6:
|
| 204 |
+
best_loss = loss
|
| 205 |
+
best = {name: value.detach().clone() for name, value in model.state_dict().items()}
|
| 206 |
+
remaining = 8
|
| 207 |
+
else:
|
| 208 |
+
remaining -= 1
|
| 209 |
+
if remaining == 0:
|
| 210 |
+
break
|
| 211 |
+
if best is not None:
|
| 212 |
+
model.load_state_dict(best)
|
| 213 |
+
return model
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
def _predict(model: nn.Module, features: np.ndarray, *, batch_size: int) -> np.ndarray:
|
| 217 |
+
model.eval()
|
| 218 |
+
chunks: list[np.ndarray] = []
|
| 219 |
+
with torch.no_grad():
|
| 220 |
+
for start in range(0, len(features), batch_size):
|
| 221 |
+
chunks.append(model(torch.from_numpy(features[start : start + batch_size])).numpy())
|
| 222 |
+
return np.concatenate(chunks, axis=0).squeeze(-1)
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
def _metrics(reference: np.ndarray, prediction: np.ndarray) -> dict[str, float]:
|
| 226 |
+
error = prediction - reference
|
| 227 |
+
rmse = float(np.sqrt(np.mean(error**2)))
|
| 228 |
+
mae = float(np.mean(np.abs(error)))
|
| 229 |
+
centered = reference - float(np.mean(reference))
|
| 230 |
+
r2 = 1.0 - float(np.sum(error**2) / np.sum(centered**2))
|
| 231 |
+
scale = float(np.max(reference) - np.min(reference))
|
| 232 |
+
return {
|
| 233 |
+
"rmse_mpa": rmse / 1.0e6,
|
| 234 |
+
"mae_mpa": mae / 1.0e6,
|
| 235 |
+
"range_normalized_rmse": rmse / scale,
|
| 236 |
+
"r2": r2,
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
def train(*, mlp_epochs: int = 40, gru_epochs: int = 60) -> dict[str, object]:
|
| 241 |
+
torch.manual_seed(20260925)
|
| 242 |
+
np.random.seed(20260925)
|
| 243 |
+
torch.set_num_threads(min(4, torch.get_num_threads()))
|
| 244 |
+
torch.use_deterministic_algorithms(True)
|
| 245 |
+
arrays = _load_arrays()
|
| 246 |
+
splits = arrays["splits"]
|
| 247 |
+
train_mask = splits == "train"
|
| 248 |
+
validation_mask = splits == "validation"
|
| 249 |
+
test_mask = splits == "test"
|
| 250 |
+
started = time.perf_counter()
|
| 251 |
+
mlp = _train_pointwise(
|
| 252 |
+
arrays["pointwise"],
|
| 253 |
+
arrays["target"],
|
| 254 |
+
train_mask,
|
| 255 |
+
validation_mask,
|
| 256 |
+
epochs=mlp_epochs,
|
| 257 |
+
)
|
| 258 |
+
gru = _train_gru(
|
| 259 |
+
arrays["history"],
|
| 260 |
+
arrays["target"],
|
| 261 |
+
train_mask,
|
| 262 |
+
validation_mask,
|
| 263 |
+
epochs=gru_epochs,
|
| 264 |
+
)
|
| 265 |
+
stress_scale = arrays["normalization"]["stress_scale_pa"]
|
| 266 |
+
mlp_prediction = _predict(mlp, arrays["pointwise"], batch_size=128) * stress_scale
|
| 267 |
+
gru_prediction = _predict(gru, arrays["history"], batch_size=64) * stress_scale
|
| 268 |
+
reference = arrays["stress_pa"]
|
| 269 |
+
metrics: dict[str, object] = {
|
| 270 |
+
"status": "completed",
|
| 271 |
+
"task": "signed-equivalent-stress history prediction",
|
| 272 |
+
"split_policy": "complete trajectories; normalization fitted on train only",
|
| 273 |
+
"test_trajectory_count": int(np.count_nonzero(test_mask)),
|
| 274 |
+
"pointwise_mlp": {"overall": _metrics(reference[test_mask], mlp_prediction[test_mask])},
|
| 275 |
+
"history_gru": {"overall": _metrics(reference[test_mask], gru_prediction[test_mask])},
|
| 276 |
+
"wall_seconds": float(time.perf_counter() - started),
|
| 277 |
+
"torch_version": torch.__version__,
|
| 278 |
+
"normalization": arrays["normalization"],
|
| 279 |
+
}
|
| 280 |
+
samples = arrays["samples"]
|
| 281 |
+
for model_name in MODEL_NAMES:
|
| 282 |
+
mask = test_mask & np.asarray(
|
| 283 |
+
[sample["material_model"] == model_name for sample in samples]
|
| 284 |
+
)
|
| 285 |
+
metrics["pointwise_mlp"][model_name] = _metrics(reference[mask], mlp_prediction[mask])
|
| 286 |
+
metrics["history_gru"][model_name] = _metrics(reference[mask], gru_prediction[mask])
|
| 287 |
+
|
| 288 |
+
ARTIFACT_DIR.mkdir(parents=True, exist_ok=True)
|
| 289 |
+
(ARTIFACT_DIR / "baseline_metrics.json").write_text(
|
| 290 |
+
json.dumps(metrics, indent=2, sort_keys=True) + "\n", encoding="utf-8"
|
| 291 |
+
)
|
| 292 |
+
torch.save(
|
| 293 |
+
{
|
| 294 |
+
"pointwise_mlp": mlp.state_dict(),
|
| 295 |
+
"history_gru": gru.state_dict(),
|
| 296 |
+
"normalization": arrays["normalization"],
|
| 297 |
+
"parameter_names": PARAMETER_NAMES,
|
| 298 |
+
"model_names": MODEL_NAMES,
|
| 299 |
+
},
|
| 300 |
+
ARTIFACT_DIR / "baseline_models.pt",
|
| 301 |
+
)
|
| 302 |
+
|
| 303 |
+
fig, axes = plt.subplots(2, 3, figsize=(12.0, 7.2), constrained_layout=True)
|
| 304 |
+
for axis, family in zip(axes.flat, PATH_FAMILIES, strict=True):
|
| 305 |
+
index = next(
|
| 306 |
+
idx
|
| 307 |
+
for idx, sample in enumerate(samples)
|
| 308 |
+
if test_mask[idx]
|
| 309 |
+
and sample["material_model"] == "chaboche_combined"
|
| 310 |
+
and sample["path_family"] == family
|
| 311 |
+
)
|
| 312 |
+
strain = 100.0 * samples[index]["history"]["signed_equivalent_strain"]
|
| 313 |
+
axis.plot(strain, reference[index] / 1.0e6, color="#111827", lw=2.0, label="AgentFEM")
|
| 314 |
+
axis.plot(strain, mlp_prediction[index] / 1.0e6, color="#f59e0b", lw=1.2, label="Pointwise MLP")
|
| 315 |
+
axis.plot(strain, gru_prediction[index] / 1.0e6, color="#2563eb", lw=1.5, label="History GRU")
|
| 316 |
+
axis.set_title(family.replace("_", " ").title(), fontsize=10)
|
| 317 |
+
axis.set_xlabel("Signed equivalent strain (%)")
|
| 318 |
+
axis.set_ylabel("Signed equivalent stress (MPa)")
|
| 319 |
+
axis.grid(alpha=0.22)
|
| 320 |
+
axes.flat[0].legend(frameon=False, fontsize=8)
|
| 321 |
+
fig.suptitle("T2 v1 baseline comparison on held-out Chaboche trajectories", fontsize=13)
|
| 322 |
+
fig.savefig(ARTIFACT_DIR / "baseline_predictions.png", dpi=180)
|
| 323 |
+
plt.close(fig)
|
| 324 |
+
print(json.dumps(metrics, indent=2, sort_keys=True))
|
| 325 |
+
return metrics
|
| 326 |
+
|
| 327 |
+
|
| 328 |
+
def main() -> None:
|
| 329 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 330 |
+
parser.add_argument("--mlp-epochs", type=int, default=40)
|
| 331 |
+
parser.add_argument("--gru-epochs", type=int, default=60)
|
| 332 |
+
args = parser.parse_args()
|
| 333 |
+
train(mlp_epochs=args.mlp_epochs, gru_epochs=args.gru_epochs)
|
| 334 |
+
|
| 335 |
+
|
| 336 |
+
if __name__ == "__main__":
|
| 337 |
+
main()
|
src/load_t2_material_loading_memory.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Lightweight reader for T2 material-loading-memory HDF5 shards."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import json
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
from typing import Iterator
|
| 8 |
+
|
| 9 |
+
import h5py
|
| 10 |
+
import numpy as np
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def load_manifest(dataset_root: str | Path) -> dict[str, object]:
|
| 14 |
+
root = Path(dataset_root)
|
| 15 |
+
return json.loads((root / "manifest.json").read_text(encoding="utf-8"))
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def _resolve_shard(root: Path, relative_path: str) -> Path:
|
| 19 |
+
candidate = root / "shards" / Path(relative_path).name
|
| 20 |
+
if candidate.exists():
|
| 21 |
+
return candidate
|
| 22 |
+
return root.parents[1] / relative_path
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def _group_to_sample(sample_id: str, group: h5py.Group) -> dict[str, object]:
|
| 26 |
+
return {
|
| 27 |
+
"id": sample_id,
|
| 28 |
+
"case_id": str(group.attrs["case_id"]),
|
| 29 |
+
"split": str(group.attrs["split"]),
|
| 30 |
+
"material_model": str(group.attrs["material_model"]),
|
| 31 |
+
"path_family": str(group.attrs["path_family"]),
|
| 32 |
+
"parameters": json.loads(str(group.attrs["parameters_json"])),
|
| 33 |
+
"metrics": json.loads(str(group.attrs["metrics_json"])),
|
| 34 |
+
"history": {name: np.asarray(group[name]) for name in group.keys()},
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def iter_trajectories(
|
| 39 |
+
dataset_root: str | Path,
|
| 40 |
+
*,
|
| 41 |
+
split: str | None = None,
|
| 42 |
+
material_model: str | None = None,
|
| 43 |
+
path_family: str | None = None,
|
| 44 |
+
) -> Iterator[dict[str, object]]:
|
| 45 |
+
"""Yield copied histories, optionally filtered by trajectory metadata."""
|
| 46 |
+
|
| 47 |
+
root = Path(dataset_root)
|
| 48 |
+
manifest = load_manifest(root)
|
| 49 |
+
for shard in manifest["shards"]:
|
| 50 |
+
with h5py.File(_resolve_shard(root, shard["path"]), "r") as h5:
|
| 51 |
+
for sample_id in sorted(h5.keys()):
|
| 52 |
+
group = h5[sample_id]
|
| 53 |
+
if split is not None and str(group.attrs["split"]) != split:
|
| 54 |
+
continue
|
| 55 |
+
if (
|
| 56 |
+
material_model is not None
|
| 57 |
+
and str(group.attrs["material_model"]) != material_model
|
| 58 |
+
):
|
| 59 |
+
continue
|
| 60 |
+
if (
|
| 61 |
+
path_family is not None
|
| 62 |
+
and str(group.attrs["path_family"]) != path_family
|
| 63 |
+
):
|
| 64 |
+
continue
|
| 65 |
+
yield _group_to_sample(sample_id, group)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def load_trajectory(
|
| 69 |
+
dataset_root: str | Path, sample_id: str | int
|
| 70 |
+
) -> dict[str, object]:
|
| 71 |
+
target = f"{int(sample_id):05d}"
|
| 72 |
+
root = Path(dataset_root)
|
| 73 |
+
manifest = load_manifest(root)
|
| 74 |
+
for shard in manifest["shards"]:
|
| 75 |
+
if shard["first_id"] <= target <= shard["last_id"]:
|
| 76 |
+
with h5py.File(_resolve_shard(root, shard["path"]), "r") as h5:
|
| 77 |
+
if target in h5:
|
| 78 |
+
return _group_to_sample(target, h5[target])
|
| 79 |
+
raise KeyError(f"Unknown trajectory id: {target}")
|
src/t2_material_loading_memory.py
ADDED
|
@@ -0,0 +1,770 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Generate the T2 material-loading-memory pilot dataset.
|
| 2 |
+
|
| 3 |
+
The sample unit is one complete material-point trajectory. Time frames are not
|
| 4 |
+
counted as independent samples. The pilot deliberately keeps J2 linear
|
| 5 |
+
isotropic hardening and Chaboche combined hardening as separate model labels.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
from __future__ import annotations
|
| 9 |
+
|
| 10 |
+
import argparse
|
| 11 |
+
import hashlib
|
| 12 |
+
import json
|
| 13 |
+
import os
|
| 14 |
+
import platform
|
| 15 |
+
import time
|
| 16 |
+
from pathlib import Path
|
| 17 |
+
|
| 18 |
+
import h5py
|
| 19 |
+
import matplotlib
|
| 20 |
+
|
| 21 |
+
matplotlib.use("Agg")
|
| 22 |
+
import matplotlib.pyplot as plt
|
| 23 |
+
import numpy as np
|
| 24 |
+
from scipy.stats import qmc
|
| 25 |
+
|
| 26 |
+
import agentfem
|
| 27 |
+
from agentfem import campaigns, constitutive
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
ROOT = Path(__file__).resolve().parents[1]
|
| 31 |
+
CONFIG_PATH = ROOT / "configs" / "t2_material_loading_memory_pilot.json"
|
| 32 |
+
DATA_DIR = ROOT / "data" / "t2_material_loading_memory_pilot"
|
| 33 |
+
ARTIFACT_DIR = ROOT / "artifacts" / "t2_material_loading_memory_pilot"
|
| 34 |
+
DATA_PATH = DATA_DIR / "t2_material_loading_memory_pilot.h5"
|
| 35 |
+
DESIGN_PATH = DATA_DIR / "design.jsonl"
|
| 36 |
+
INDEX_PATH = DATA_DIR / "index.jsonl"
|
| 37 |
+
|
| 38 |
+
AGENTFEM_COMMIT = "058faecc05aeda143d014fd229401003a9258bbb"
|
| 39 |
+
MATERIAL_MODELS = ("j2_linear_isotropic", "chaboche_combined")
|
| 40 |
+
PATH_FAMILIES = (
|
| 41 |
+
"monotonic_tension",
|
| 42 |
+
"unload_reload",
|
| 43 |
+
"tension_compression",
|
| 44 |
+
"symmetric_cyclic",
|
| 45 |
+
"mean_shifted_cyclic",
|
| 46 |
+
"variable_amplitude",
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def load_config() -> dict[str, object]:
|
| 51 |
+
return json.loads(CONFIG_PATH.read_text(encoding="utf-8"))
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def _scale(value: float, bounds: list[float]) -> float:
|
| 55 |
+
return float(bounds[0] + value * (bounds[1] - bounds[0]))
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def design_parameters(seed: int | None = None) -> tuple[dict[str, object], ...]:
|
| 59 |
+
"""Return a deterministic balanced 96-trajectory Sobol design."""
|
| 60 |
+
|
| 61 |
+
config = load_config()
|
| 62 |
+
actual_seed = int(config["seed"] if seed is None else seed)
|
| 63 |
+
ranges = config["ranges"]
|
| 64 |
+
unit = qmc.Sobol(12, scramble=True, seed=actual_seed).random_base2(7)
|
| 65 |
+
rows: list[dict[str, object]] = []
|
| 66 |
+
cursor = 0
|
| 67 |
+
for material_model in MATERIAL_MODELS:
|
| 68 |
+
for path_family in PATH_FAMILIES:
|
| 69 |
+
for replicate in range(8):
|
| 70 |
+
u = unit[cursor]
|
| 71 |
+
cursor += 1
|
| 72 |
+
row: dict[str, object] = {
|
| 73 |
+
"material_model": material_model,
|
| 74 |
+
"path_family": path_family,
|
| 75 |
+
"replicate": replicate,
|
| 76 |
+
"young_pa": _scale(u[0], ranges["young_pa"]),
|
| 77 |
+
"poisson": _scale(u[1], ranges["poisson"]),
|
| 78 |
+
"yield_stress_pa": _scale(u[2], ranges["yield_stress_pa"]),
|
| 79 |
+
"maximum_equivalent_strain": _scale(
|
| 80 |
+
u[3], ranges["maximum_equivalent_strain"]
|
| 81 |
+
),
|
| 82 |
+
"path_shape_a": float(u[10]),
|
| 83 |
+
"path_shape_b": float(u[11]),
|
| 84 |
+
}
|
| 85 |
+
if material_model == "j2_linear_isotropic":
|
| 86 |
+
row.update(
|
| 87 |
+
{
|
| 88 |
+
"hardening_modulus_pa": _scale(
|
| 89 |
+
u[4], ranges["j2_hardening_modulus_pa"]
|
| 90 |
+
),
|
| 91 |
+
"backstress_c1_pa": 0.0,
|
| 92 |
+
"backstress_gamma1": 0.0,
|
| 93 |
+
"backstress_c2_pa": 0.0,
|
| 94 |
+
"backstress_gamma2": 0.0,
|
| 95 |
+
"isotropic_saturation_pa": 0.0,
|
| 96 |
+
"isotropic_rate": 0.0,
|
| 97 |
+
}
|
| 98 |
+
)
|
| 99 |
+
else:
|
| 100 |
+
row.update(
|
| 101 |
+
{
|
| 102 |
+
"hardening_modulus_pa": 0.0,
|
| 103 |
+
"backstress_c1_pa": _scale(
|
| 104 |
+
u[4], ranges["chaboche_c1_pa"]
|
| 105 |
+
),
|
| 106 |
+
"backstress_gamma1": _scale(
|
| 107 |
+
u[5], ranges["chaboche_gamma1"]
|
| 108 |
+
),
|
| 109 |
+
"backstress_c2_pa": _scale(
|
| 110 |
+
u[6], ranges["chaboche_c2_pa"]
|
| 111 |
+
),
|
| 112 |
+
"backstress_gamma2": _scale(
|
| 113 |
+
u[7], ranges["chaboche_gamma2"]
|
| 114 |
+
),
|
| 115 |
+
"isotropic_saturation_pa": _scale(
|
| 116 |
+
u[8], ranges["chaboche_isotropic_saturation_pa"]
|
| 117 |
+
),
|
| 118 |
+
"isotropic_rate": _scale(
|
| 119 |
+
u[9], ranges["chaboche_isotropic_rate"]
|
| 120 |
+
),
|
| 121 |
+
}
|
| 122 |
+
)
|
| 123 |
+
rows.append(row)
|
| 124 |
+
if len(rows) != int(config["sample_count"]):
|
| 125 |
+
raise RuntimeError("T2 design size differs from the frozen configuration.")
|
| 126 |
+
return tuple(rows)
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
def case_identity(parameters: dict[str, object]) -> str:
|
| 130 |
+
return campaigns.case_id("t2_material_loading_memory_pilot", parameters)
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def split_assignments(parameters: tuple[dict[str, object], ...]) -> dict[int, str]:
|
| 134 |
+
"""Create 6/1/1 train/validation/test splits within every stratum."""
|
| 135 |
+
|
| 136 |
+
seed = int(load_config()["seed"])
|
| 137 |
+
result: dict[int, str] = {}
|
| 138 |
+
for model_index, material_model in enumerate(MATERIAL_MODELS):
|
| 139 |
+
for path_index, path_family in enumerate(PATH_FAMILIES):
|
| 140 |
+
members = np.asarray(
|
| 141 |
+
[
|
| 142 |
+
index
|
| 143 |
+
for index, row in enumerate(parameters)
|
| 144 |
+
if row["material_model"] == material_model
|
| 145 |
+
and row["path_family"] == path_family
|
| 146 |
+
],
|
| 147 |
+
dtype=int,
|
| 148 |
+
)
|
| 149 |
+
rng = np.random.default_rng(seed + 100 * model_index + path_index)
|
| 150 |
+
members = rng.permutation(members)
|
| 151 |
+
for index in members[:6]:
|
| 152 |
+
result[int(index)] = "train"
|
| 153 |
+
result[int(members[6])] = "validation"
|
| 154 |
+
result[int(members[7])] = "test"
|
| 155 |
+
return result
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
def path_anchors(parameters: dict[str, object]) -> np.ndarray:
|
| 159 |
+
"""Return signed equivalent-deviatoric-strain control points."""
|
| 160 |
+
|
| 161 |
+
amplitude = float(parameters["maximum_equivalent_strain"])
|
| 162 |
+
a = float(parameters["path_shape_a"])
|
| 163 |
+
b = float(parameters["path_shape_b"])
|
| 164 |
+
family = str(parameters["path_family"])
|
| 165 |
+
if family == "monotonic_tension":
|
| 166 |
+
values = (0.0, amplitude)
|
| 167 |
+
elif family == "unload_reload":
|
| 168 |
+
unload = amplitude * (-0.25 + 0.60 * a)
|
| 169 |
+
reload = amplitude * (0.85 + 0.30 * b)
|
| 170 |
+
values = (0.0, amplitude, unload, reload)
|
| 171 |
+
elif family == "tension_compression":
|
| 172 |
+
reverse = -amplitude * (0.70 + 0.45 * a)
|
| 173 |
+
values = (0.0, amplitude, reverse)
|
| 174 |
+
elif family == "symmetric_cyclic":
|
| 175 |
+
values = (0.0, amplitude, -amplitude, amplitude, -amplitude, amplitude)
|
| 176 |
+
elif family == "mean_shifted_cyclic":
|
| 177 |
+
lower = -amplitude * (0.25 + 0.40 * a)
|
| 178 |
+
upper = amplitude * (0.90 + 0.10 * b)
|
| 179 |
+
values = (0.0, upper, lower, upper, lower, upper)
|
| 180 |
+
elif family == "variable_amplitude":
|
| 181 |
+
first_reverse = -amplitude * (0.55 + 0.30 * a)
|
| 182 |
+
second_reverse = -amplitude * (0.25 + 0.35 * b)
|
| 183 |
+
values = (
|
| 184 |
+
0.0,
|
| 185 |
+
0.45 * amplitude,
|
| 186 |
+
first_reverse,
|
| 187 |
+
amplitude,
|
| 188 |
+
second_reverse,
|
| 189 |
+
0.75 * amplitude,
|
| 190 |
+
-amplitude,
|
| 191 |
+
0.20 * amplitude,
|
| 192 |
+
)
|
| 193 |
+
else:
|
| 194 |
+
raise ValueError(f"Unknown path family: {family}")
|
| 195 |
+
return np.asarray(values, dtype=float)
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
def prescribed_history(
|
| 199 |
+
parameters: dict[str, object], *, points: int | None = None
|
| 200 |
+
) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
|
| 201 |
+
"""Return a path that samples every reversal anchor exactly.
|
| 202 |
+
|
| 203 |
+
The 241-point refinement doubles the interval count of every 121-point
|
| 204 |
+
segment. Therefore every coarse state is present at ``fine[::2]`` and the
|
| 205 |
+
refinement audit measures constitutive integration, not a missed path
|
| 206 |
+
extremum.
|
| 207 |
+
"""
|
| 208 |
+
|
| 209 |
+
base_count = int(load_config()["points_per_trajectory"])
|
| 210 |
+
count = int(base_count if points is None else points)
|
| 211 |
+
if count < 3 or count % 2 == 0:
|
| 212 |
+
raise ValueError("points must be an odd integer of at least three.")
|
| 213 |
+
anchors = path_anchors(parameters)
|
| 214 |
+
segments = len(anchors) - 1
|
| 215 |
+
|
| 216 |
+
def allocated(intervals: int) -> np.ndarray:
|
| 217 |
+
if intervals < segments:
|
| 218 |
+
raise ValueError("points must provide at least one interval per segment.")
|
| 219 |
+
values = np.full(segments, intervals // segments, dtype=int)
|
| 220 |
+
values[: intervals % segments] += 1
|
| 221 |
+
return values
|
| 222 |
+
|
| 223 |
+
base_segments = allocated(base_count - 1)
|
| 224 |
+
if (count - 1) % (base_count - 1) == 0:
|
| 225 |
+
segment_intervals = base_segments * ((count - 1) // (base_count - 1))
|
| 226 |
+
else:
|
| 227 |
+
segment_intervals = allocated(count - 1)
|
| 228 |
+
pieces: list[np.ndarray] = []
|
| 229 |
+
for index, intervals in enumerate(segment_intervals):
|
| 230 |
+
values = np.linspace(anchors[index], anchors[index + 1], intervals + 1)
|
| 231 |
+
pieces.append(values if index == 0 else values[1:])
|
| 232 |
+
scalar_strain = np.concatenate(pieces)
|
| 233 |
+
if len(scalar_strain) != count:
|
| 234 |
+
raise RuntimeError("Piecewise path allocation produced the wrong point count.")
|
| 235 |
+
time_coordinate = np.linspace(0.0, 1.0, count)
|
| 236 |
+
return time_coordinate, scalar_strain, anchors
|
| 237 |
+
|
| 238 |
+
|
| 239 |
+
def _strain_tensor(signed_equivalent_strain: float) -> np.ndarray:
|
| 240 |
+
value = float(signed_equivalent_strain)
|
| 241 |
+
return np.diag((value, -0.5 * value, -0.5 * value))
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
def _material(parameters: dict[str, object]):
|
| 245 |
+
if parameters["material_model"] == "j2_linear_isotropic":
|
| 246 |
+
return constitutive.J2LinearIsotropicHardening(
|
| 247 |
+
young=float(parameters["young_pa"]),
|
| 248 |
+
poisson=float(parameters["poisson"]),
|
| 249 |
+
yield_stress=float(parameters["yield_stress_pa"]),
|
| 250 |
+
hardening_modulus=float(parameters["hardening_modulus_pa"]),
|
| 251 |
+
)
|
| 252 |
+
return constitutive.chaboche(
|
| 253 |
+
young=float(parameters["young_pa"]),
|
| 254 |
+
poisson=float(parameters["poisson"]),
|
| 255 |
+
yield_stress=float(parameters["yield_stress_pa"]),
|
| 256 |
+
backstresses=(
|
| 257 |
+
(
|
| 258 |
+
float(parameters["backstress_c1_pa"]),
|
| 259 |
+
float(parameters["backstress_gamma1"]),
|
| 260 |
+
),
|
| 261 |
+
(
|
| 262 |
+
float(parameters["backstress_c2_pa"]),
|
| 263 |
+
float(parameters["backstress_gamma2"]),
|
| 264 |
+
),
|
| 265 |
+
),
|
| 266 |
+
isotropic_saturation=float(parameters["isotropic_saturation_pa"]),
|
| 267 |
+
isotropic_rate=float(parameters["isotropic_rate"]),
|
| 268 |
+
)
|
| 269 |
+
|
| 270 |
+
|
| 271 |
+
def solve_trajectory(
|
| 272 |
+
parameters: dict[str, object], *, points: int | None = None
|
| 273 |
+
) -> tuple[dict[str, np.ndarray], dict[str, float | int | bool]]:
|
| 274 |
+
"""Integrate one committed material-point path through AgentFEM."""
|
| 275 |
+
|
| 276 |
+
time_coordinate, scalar_strain, anchors = prescribed_history(
|
| 277 |
+
parameters, points=points
|
| 278 |
+
)
|
| 279 |
+
material = _material(parameters)
|
| 280 |
+
count = len(time_coordinate)
|
| 281 |
+
total_strain = np.empty((count, 3, 3), dtype=float)
|
| 282 |
+
stress = np.empty((count, 3, 3), dtype=float)
|
| 283 |
+
plastic_strain = np.empty((count, 3, 3), dtype=float)
|
| 284 |
+
peeq = np.empty(count, dtype=float)
|
| 285 |
+
signed_stress = np.empty(count, dtype=float)
|
| 286 |
+
mises = np.empty(count, dtype=float)
|
| 287 |
+
shifted_mises = np.empty(count, dtype=float)
|
| 288 |
+
yield_radius = np.empty(count, dtype=float)
|
| 289 |
+
trial_yield = np.empty(count, dtype=float)
|
| 290 |
+
plastic_increment = np.empty(count, dtype=float)
|
| 291 |
+
elastic = np.empty(count, dtype=np.uint8)
|
| 292 |
+
backstress = np.zeros((count, 3, 3), dtype=float)
|
| 293 |
+
backstress_components = np.zeros((count, 2, 3, 3), dtype=float)
|
| 294 |
+
state = None
|
| 295 |
+
|
| 296 |
+
for index, value in enumerate(scalar_strain):
|
| 297 |
+
strain = _strain_tensor(value)
|
| 298 |
+
update = material.update(strain, state)
|
| 299 |
+
state = update.state
|
| 300 |
+
total_strain[index] = strain
|
| 301 |
+
stress[index] = update.stress
|
| 302 |
+
plastic_strain[index] = state.plastic_strain
|
| 303 |
+
peeq[index] = state.equivalent_plastic_strain
|
| 304 |
+
signed_stress[index] = update.stress[0, 0] - update.stress[1, 1]
|
| 305 |
+
mises[index] = constitutive.von_mises(update.stress)
|
| 306 |
+
trial_yield[index] = update.yield_function_trial
|
| 307 |
+
plastic_increment[index] = update.plastic_multiplier_increment
|
| 308 |
+
elastic[index] = np.uint8(update.elastic)
|
| 309 |
+
if parameters["material_model"] == "chaboche_combined":
|
| 310 |
+
backstress[index] = state.total_backstress
|
| 311 |
+
backstress_components[index] = state.backstresses
|
| 312 |
+
shifted_mises[index] = constitutive.von_mises(
|
| 313 |
+
update.stress - backstress[index]
|
| 314 |
+
)
|
| 315 |
+
yield_radius[index] = material.current_yield_stress(peeq[index])
|
| 316 |
+
|
| 317 |
+
plastic_work_increment = np.zeros(count, dtype=float)
|
| 318 |
+
external_work_increment = np.zeros(count, dtype=float)
|
| 319 |
+
for index in range(1, count):
|
| 320 |
+
mean_stress = 0.5 * (stress[index] + stress[index - 1])
|
| 321 |
+
plastic_work_increment[index] = float(
|
| 322 |
+
np.tensordot(
|
| 323 |
+
mean_stress,
|
| 324 |
+
plastic_strain[index] - plastic_strain[index - 1],
|
| 325 |
+
)
|
| 326 |
+
)
|
| 327 |
+
external_work_increment[index] = float(
|
| 328 |
+
np.tensordot(
|
| 329 |
+
mean_stress,
|
| 330 |
+
total_strain[index] - total_strain[index - 1],
|
| 331 |
+
)
|
| 332 |
+
)
|
| 333 |
+
arrays = {
|
| 334 |
+
"time_coordinate": time_coordinate,
|
| 335 |
+
"path_anchors": anchors,
|
| 336 |
+
"signed_equivalent_strain": scalar_strain,
|
| 337 |
+
"total_strain": total_strain,
|
| 338 |
+
"stress_pa": stress,
|
| 339 |
+
"signed_equivalent_stress_pa": signed_stress,
|
| 340 |
+
"mises_stress_pa": mises,
|
| 341 |
+
"plastic_strain": plastic_strain,
|
| 342 |
+
"equivalent_plastic_strain": peeq,
|
| 343 |
+
"plastic_multiplier_increment": plastic_increment,
|
| 344 |
+
"elastic_step": elastic,
|
| 345 |
+
"trial_yield_function_pa": trial_yield,
|
| 346 |
+
"yield_radius_pa": yield_radius,
|
| 347 |
+
"shifted_mises_stress_pa": shifted_mises,
|
| 348 |
+
"backstress_pa": backstress,
|
| 349 |
+
"backstress_components_pa": backstress_components,
|
| 350 |
+
"plastic_work_increment_j_m3": plastic_work_increment,
|
| 351 |
+
"cumulative_plastic_work_j_m3": np.cumsum(plastic_work_increment),
|
| 352 |
+
"external_work_increment_j_m3": external_work_increment,
|
| 353 |
+
"cumulative_external_work_j_m3": np.cumsum(external_work_increment),
|
| 354 |
+
}
|
| 355 |
+
plastic_mask = plastic_increment > 0.0
|
| 356 |
+
zero_strain_mask = np.abs(scalar_strain) <= 1.0e-14
|
| 357 |
+
residual = np.abs(shifted_mises - yield_radius) / np.maximum(
|
| 358 |
+
yield_radius, 1.0
|
| 359 |
+
)
|
| 360 |
+
metrics: dict[str, float | int | bool] = {
|
| 361 |
+
"maximum_absolute_stress_pa": float(np.max(np.abs(signed_stress))),
|
| 362 |
+
"final_equivalent_plastic_strain": float(peeq[-1]),
|
| 363 |
+
"maximum_equivalent_plastic_strain": float(np.max(peeq)),
|
| 364 |
+
"final_cumulative_plastic_work_j_m3": float(
|
| 365 |
+
np.sum(plastic_work_increment)
|
| 366 |
+
),
|
| 367 |
+
"plastic_step_count": int(np.count_nonzero(plastic_mask)),
|
| 368 |
+
"maximum_plastic_strain_trace": float(
|
| 369 |
+
np.max(np.abs(np.trace(plastic_strain, axis1=1, axis2=2)))
|
| 370 |
+
),
|
| 371 |
+
"maximum_yield_surface_relative_residual": float(
|
| 372 |
+
np.max(residual[plastic_mask]) if np.any(plastic_mask) else 0.0
|
| 373 |
+
),
|
| 374 |
+
"minimum_peeq_increment": float(np.min(np.diff(peeq))),
|
| 375 |
+
"minimum_plastic_work_increment_j_m3": float(
|
| 376 |
+
np.min(plastic_work_increment)
|
| 377 |
+
),
|
| 378 |
+
"zero_strain_stress_range_pa": float(
|
| 379 |
+
np.ptp(signed_stress[zero_strain_mask])
|
| 380 |
+
if np.count_nonzero(zero_strain_mask) >= 2
|
| 381 |
+
else 0.0
|
| 382 |
+
),
|
| 383 |
+
"all_finite": bool(
|
| 384 |
+
all(np.all(np.isfinite(value)) for value in arrays.values())
|
| 385 |
+
),
|
| 386 |
+
}
|
| 387 |
+
return arrays, metrics
|
| 388 |
+
|
| 389 |
+
|
| 390 |
+
def _j2_monotonic_reference(parameters: dict[str, object]) -> tuple[float, float]:
|
| 391 |
+
strain = float(parameters["maximum_equivalent_strain"])
|
| 392 |
+
young = float(parameters["young_pa"])
|
| 393 |
+
poisson = float(parameters["poisson"])
|
| 394 |
+
shear = young / (2.0 * (1.0 + poisson))
|
| 395 |
+
yield_stress = float(parameters["yield_stress_pa"])
|
| 396 |
+
hardening = float(parameters["hardening_modulus_pa"])
|
| 397 |
+
trial = 3.0 * shear * strain
|
| 398 |
+
increment = max(0.0, (trial - yield_stress) / (3.0 * shear + hardening))
|
| 399 |
+
return yield_stress + hardening * increment, increment
|
| 400 |
+
|
| 401 |
+
|
| 402 |
+
def _sha256(path: Path) -> str:
|
| 403 |
+
digest = hashlib.sha256()
|
| 404 |
+
with path.open("rb") as stream:
|
| 405 |
+
for block in iter(lambda: stream.read(1024 * 1024), b""):
|
| 406 |
+
digest.update(block)
|
| 407 |
+
return digest.hexdigest()
|
| 408 |
+
|
| 409 |
+
|
| 410 |
+
def _write_json_atomic(path: Path, value: object) -> None:
|
| 411 |
+
temporary = path.with_suffix(path.suffix + ".tmp")
|
| 412 |
+
temporary.write_text(
|
| 413 |
+
json.dumps(value, indent=2, sort_keys=True) + "\n", encoding="utf-8"
|
| 414 |
+
)
|
| 415 |
+
os.replace(temporary, path)
|
| 416 |
+
|
| 417 |
+
|
| 418 |
+
def _write_jsonl_atomic(path: Path, rows: list[dict[str, object]]) -> None:
|
| 419 |
+
temporary = path.with_suffix(path.suffix + ".tmp")
|
| 420 |
+
with temporary.open("w", encoding="utf-8") as stream:
|
| 421 |
+
for row in rows:
|
| 422 |
+
stream.write(json.dumps(row, sort_keys=True) + "\n")
|
| 423 |
+
os.replace(temporary, path)
|
| 424 |
+
|
| 425 |
+
|
| 426 |
+
def _quality_failures(
|
| 427 |
+
parameters: tuple[dict[str, object], ...],
|
| 428 |
+
records: list[dict[str, object]],
|
| 429 |
+
refinements: list[dict[str, object]],
|
| 430 |
+
) -> list[dict[str, object]]:
|
| 431 |
+
thresholds = load_config()["quality_thresholds"]
|
| 432 |
+
failures: list[dict[str, object]] = []
|
| 433 |
+
for index, (row, record) in enumerate(zip(parameters, records, strict=True)):
|
| 434 |
+
metrics = record["metrics"]
|
| 435 |
+
checks = {
|
| 436 |
+
"all_finite": bool(metrics["all_finite"]),
|
| 437 |
+
"initial_stress": abs(float(record["initial_signed_stress_pa"]))
|
| 438 |
+
<= thresholds["initial_stress_pa"],
|
| 439 |
+
"plastic_incompressibility": metrics["maximum_plastic_strain_trace"]
|
| 440 |
+
<= thresholds["plastic_strain_trace"],
|
| 441 |
+
"peeq_monotone": metrics["minimum_peeq_increment"]
|
| 442 |
+
>= -thresholds["equivalent_plastic_strain_decrease"],
|
| 443 |
+
"yield_surface": metrics["maximum_yield_surface_relative_residual"]
|
| 444 |
+
<= thresholds["yield_surface_relative_residual"],
|
| 445 |
+
"positive_total_plastic_work": metrics[
|
| 446 |
+
"final_cumulative_plastic_work_j_m3"
|
| 447 |
+
]
|
| 448 |
+
> thresholds["final_plastic_work_minimum_j_m3"],
|
| 449 |
+
"plastic_excitation": metrics["plastic_step_count"] > 0,
|
| 450 |
+
}
|
| 451 |
+
if row["material_model"] == "j2_linear_isotropic":
|
| 452 |
+
checks["j2_nonnegative_plastic_work_increment"] = metrics[
|
| 453 |
+
"minimum_plastic_work_increment_j_m3"
|
| 454 |
+
] >= -thresholds["j2_plastic_work_negative_tolerance_j_m3"]
|
| 455 |
+
if (
|
| 456 |
+
row["material_model"] == "j2_linear_isotropic"
|
| 457 |
+
and row["path_family"] == "monotonic_tension"
|
| 458 |
+
):
|
| 459 |
+
checks["j2_analytical"] = (
|
| 460 |
+
record["j2_analytical_relative_error"]
|
| 461 |
+
<= thresholds["j2_monotonic_analytical_relative_error"]
|
| 462 |
+
)
|
| 463 |
+
if row["path_family"] == "symmetric_cyclic":
|
| 464 |
+
checks["history_memory_contrast"] = metrics[
|
| 465 |
+
"zero_strain_stress_range_pa"
|
| 466 |
+
] >= thresholds["zero_strain_memory_contrast_pa"]
|
| 467 |
+
failed = sorted(name for name, passed in checks.items() if not passed)
|
| 468 |
+
if failed:
|
| 469 |
+
failures.append({"index": index, "failed_checks": failed})
|
| 470 |
+
for item in refinements:
|
| 471 |
+
failed = []
|
| 472 |
+
if item["maximum_stress_relative_change"] > thresholds[
|
| 473 |
+
"refined_stress_relative_change"
|
| 474 |
+
]:
|
| 475 |
+
failed.append("refined_stress")
|
| 476 |
+
if item["maximum_peeq_relative_change"] > thresholds[
|
| 477 |
+
"refined_peeq_relative_change"
|
| 478 |
+
]:
|
| 479 |
+
failed.append("refined_peeq")
|
| 480 |
+
if failed:
|
| 481 |
+
failures.append({"index": item["index"], "failed_checks": failed})
|
| 482 |
+
return failures
|
| 483 |
+
|
| 484 |
+
|
| 485 |
+
def _plot_preview(
|
| 486 |
+
parameters: tuple[dict[str, object], ...],
|
| 487 |
+
stored: dict[int, dict[str, np.ndarray]],
|
| 488 |
+
) -> Path:
|
| 489 |
+
ARTIFACT_DIR.mkdir(parents=True, exist_ok=True)
|
| 490 |
+
fig, axes = plt.subplots(2, 3, figsize=(12.0, 7.2), constrained_layout=True)
|
| 491 |
+
colors = {"j2_linear_isotropic": "#2563eb", "chaboche_combined": "#dc2626"}
|
| 492 |
+
labels = {"j2_linear_isotropic": "J2 isotropic", "chaboche_combined": "Chaboche"}
|
| 493 |
+
for axis, family in zip(axes.flat, PATH_FAMILIES, strict=True):
|
| 494 |
+
for model in MATERIAL_MODELS:
|
| 495 |
+
index = next(
|
| 496 |
+
idx
|
| 497 |
+
for idx, row in enumerate(parameters)
|
| 498 |
+
if row["material_model"] == model
|
| 499 |
+
and row["path_family"] == family
|
| 500 |
+
and row["replicate"] == 0
|
| 501 |
+
)
|
| 502 |
+
arrays = stored[index]
|
| 503 |
+
axis.plot(
|
| 504 |
+
100.0 * arrays["signed_equivalent_strain"],
|
| 505 |
+
arrays["signed_equivalent_stress_pa"] / 1.0e6,
|
| 506 |
+
color=colors[model],
|
| 507 |
+
lw=1.8,
|
| 508 |
+
label=labels[model],
|
| 509 |
+
)
|
| 510 |
+
axis.axhline(0.0, color="#9ca3af", lw=0.6)
|
| 511 |
+
axis.axvline(0.0, color="#9ca3af", lw=0.6)
|
| 512 |
+
axis.set_title(family.replace("_", " ").title(), fontsize=10)
|
| 513 |
+
axis.set_xlabel("Signed equivalent strain (%)")
|
| 514 |
+
axis.set_ylabel("Signed equivalent stress (MPa)")
|
| 515 |
+
axis.grid(alpha=0.22)
|
| 516 |
+
axes.flat[0].legend(frameon=False, fontsize=9)
|
| 517 |
+
fig.suptitle(
|
| 518 |
+
"AgentFEM T2 pilot: path-dependent material memory\n"
|
| 519 |
+
"Representative independent cases; J2 and Chaboche parameters are not matched.",
|
| 520 |
+
fontsize=13,
|
| 521 |
+
)
|
| 522 |
+
output = ARTIFACT_DIR / "hysteresis_preview.png"
|
| 523 |
+
fig.savefig(output, dpi=180)
|
| 524 |
+
plt.close(fig)
|
| 525 |
+
return output
|
| 526 |
+
|
| 527 |
+
|
| 528 |
+
def generate() -> dict[str, object]:
|
| 529 |
+
config = load_config()
|
| 530 |
+
parameters = design_parameters()
|
| 531 |
+
splits = split_assignments(parameters)
|
| 532 |
+
DATA_DIR.mkdir(parents=True, exist_ok=True)
|
| 533 |
+
ARTIFACT_DIR.mkdir(parents=True, exist_ok=True)
|
| 534 |
+
design_rows: list[dict[str, object]] = []
|
| 535 |
+
records: list[dict[str, object]] = []
|
| 536 |
+
stored: dict[int, dict[str, np.ndarray]] = {}
|
| 537 |
+
started = time.perf_counter()
|
| 538 |
+
temporary = DATA_PATH.with_suffix(".h5.tmp")
|
| 539 |
+
with h5py.File(temporary, "w") as h5:
|
| 540 |
+
h5.attrs["schema"] = config["schema"]
|
| 541 |
+
h5.attrs["schema_version"] = config["schema_version"]
|
| 542 |
+
h5.attrs["dataset_version"] = config["dataset_version"]
|
| 543 |
+
h5.attrs["agentfem_version"] = agentfem.__version__
|
| 544 |
+
h5.attrs["agentfem_commit"] = AGENTFEM_COMMIT
|
| 545 |
+
h5.attrs["numpy_version"] = np.__version__
|
| 546 |
+
h5.attrs["python_version"] = platform.python_version()
|
| 547 |
+
for index, row in enumerate(parameters):
|
| 548 |
+
case_id = case_identity(row)
|
| 549 |
+
split = splits[index]
|
| 550 |
+
arrays, metrics = solve_trajectory(row)
|
| 551 |
+
reference_error = 0.0
|
| 552 |
+
if (
|
| 553 |
+
row["material_model"] == "j2_linear_isotropic"
|
| 554 |
+
and row["path_family"] == "monotonic_tension"
|
| 555 |
+
):
|
| 556 |
+
reference_stress, reference_peeq = _j2_monotonic_reference(row)
|
| 557 |
+
reference_error = max(
|
| 558 |
+
abs(arrays["signed_equivalent_stress_pa"][-1] - reference_stress)
|
| 559 |
+
/ max(reference_stress, 1.0),
|
| 560 |
+
abs(arrays["equivalent_plastic_strain"][-1] - reference_peeq)
|
| 561 |
+
/ max(reference_peeq, 1.0e-15),
|
| 562 |
+
)
|
| 563 |
+
record: dict[str, object] = {
|
| 564 |
+
"id": f"{index:05d}",
|
| 565 |
+
"case_id": case_id,
|
| 566 |
+
"split": split,
|
| 567 |
+
"parameters": row,
|
| 568 |
+
"metrics": metrics,
|
| 569 |
+
"initial_signed_stress_pa": float(
|
| 570 |
+
arrays["signed_equivalent_stress_pa"][0]
|
| 571 |
+
),
|
| 572 |
+
"j2_analytical_relative_error": float(reference_error),
|
| 573 |
+
}
|
| 574 |
+
group = h5.create_group(f"{index:05d}")
|
| 575 |
+
group.attrs["case_id"] = case_id
|
| 576 |
+
group.attrs["split"] = split
|
| 577 |
+
group.attrs["material_model"] = row["material_model"]
|
| 578 |
+
group.attrs["path_family"] = row["path_family"]
|
| 579 |
+
group.attrs["parameters_json"] = json.dumps(row, sort_keys=True)
|
| 580 |
+
group.attrs["metrics_json"] = json.dumps(metrics, sort_keys=True)
|
| 581 |
+
for name, value in arrays.items():
|
| 582 |
+
group.create_dataset(name, data=value, compression="gzip", shuffle=True)
|
| 583 |
+
design_rows.append(
|
| 584 |
+
{
|
| 585 |
+
"id": f"{index:05d}",
|
| 586 |
+
"case_id": case_id,
|
| 587 |
+
"split": split,
|
| 588 |
+
"parameters": row,
|
| 589 |
+
}
|
| 590 |
+
)
|
| 591 |
+
records.append(record)
|
| 592 |
+
if row["replicate"] == 0:
|
| 593 |
+
stored[index] = arrays
|
| 594 |
+
os.replace(temporary, DATA_PATH)
|
| 595 |
+
_write_jsonl_atomic(DESIGN_PATH, design_rows)
|
| 596 |
+
_write_jsonl_atomic(INDEX_PATH, records)
|
| 597 |
+
|
| 598 |
+
refinements: list[dict[str, object]] = []
|
| 599 |
+
for index, row in enumerate(parameters):
|
| 600 |
+
if row["replicate"] != 0:
|
| 601 |
+
continue
|
| 602 |
+
coarse = stored[index]
|
| 603 |
+
fine, _ = solve_trajectory(row, points=241)
|
| 604 |
+
fine_stress = fine["signed_equivalent_stress_pa"][::2]
|
| 605 |
+
fine_peeq = fine["equivalent_plastic_strain"][::2]
|
| 606 |
+
stress_scale = max(float(np.max(np.abs(fine_stress))), 1.0)
|
| 607 |
+
peeq_scale = max(float(np.max(fine_peeq)), 1.0e-15)
|
| 608 |
+
refinements.append(
|
| 609 |
+
{
|
| 610 |
+
"index": index,
|
| 611 |
+
"material_model": row["material_model"],
|
| 612 |
+
"path_family": row["path_family"],
|
| 613 |
+
"maximum_stress_relative_change": float(
|
| 614 |
+
np.max(
|
| 615 |
+
np.abs(
|
| 616 |
+
coarse["signed_equivalent_stress_pa"] - fine_stress
|
| 617 |
+
)
|
| 618 |
+
)
|
| 619 |
+
/ stress_scale
|
| 620 |
+
),
|
| 621 |
+
"maximum_peeq_relative_change": float(
|
| 622 |
+
np.max(
|
| 623 |
+
np.abs(coarse["equivalent_plastic_strain"] - fine_peeq)
|
| 624 |
+
)
|
| 625 |
+
/ peeq_scale
|
| 626 |
+
),
|
| 627 |
+
}
|
| 628 |
+
)
|
| 629 |
+
|
| 630 |
+
failures = _quality_failures(parameters, records, refinements)
|
| 631 |
+
preview = _plot_preview(parameters, stored)
|
| 632 |
+
summary = {
|
| 633 |
+
"status": "accepted" if not failures else "rejected",
|
| 634 |
+
"sample_count": len(parameters),
|
| 635 |
+
"material_models": {
|
| 636 |
+
model: sum(row["material_model"] == model for row in parameters)
|
| 637 |
+
for model in MATERIAL_MODELS
|
| 638 |
+
},
|
| 639 |
+
"path_families": {
|
| 640 |
+
family: sum(row["path_family"] == family for row in parameters)
|
| 641 |
+
for family in PATH_FAMILIES
|
| 642 |
+
},
|
| 643 |
+
"splits": {
|
| 644 |
+
name: sum(value == name for value in splits.values())
|
| 645 |
+
for name in ("train", "validation", "test")
|
| 646 |
+
},
|
| 647 |
+
"all_case_ids_unique": len({case_identity(row) for row in parameters})
|
| 648 |
+
== len(parameters),
|
| 649 |
+
"quality_failure_count": len(failures),
|
| 650 |
+
"quality_failures": failures,
|
| 651 |
+
"maximum_yield_surface_relative_residual": float(
|
| 652 |
+
max(
|
| 653 |
+
record["metrics"]["maximum_yield_surface_relative_residual"]
|
| 654 |
+
for record in records
|
| 655 |
+
)
|
| 656 |
+
),
|
| 657 |
+
"maximum_plastic_strain_trace": float(
|
| 658 |
+
max(
|
| 659 |
+
record["metrics"]["maximum_plastic_strain_trace"]
|
| 660 |
+
for record in records
|
| 661 |
+
)
|
| 662 |
+
),
|
| 663 |
+
"maximum_j2_analytical_relative_error": float(
|
| 664 |
+
max(record["j2_analytical_relative_error"] for record in records)
|
| 665 |
+
),
|
| 666 |
+
"minimum_symmetric_zero_strain_memory_contrast_pa": float(
|
| 667 |
+
min(
|
| 668 |
+
record["metrics"]["zero_strain_stress_range_pa"]
|
| 669 |
+
for record in records
|
| 670 |
+
if record["parameters"]["path_family"] == "symmetric_cyclic"
|
| 671 |
+
)
|
| 672 |
+
),
|
| 673 |
+
"maximum_refined_stress_relative_change": float(
|
| 674 |
+
max(item["maximum_stress_relative_change"] for item in refinements)
|
| 675 |
+
),
|
| 676 |
+
"maximum_refined_peeq_relative_change": float(
|
| 677 |
+
max(item["maximum_peeq_relative_change"] for item in refinements)
|
| 678 |
+
),
|
| 679 |
+
"minimum_plastic_work_increment_j_m3": float(
|
| 680 |
+
min(
|
| 681 |
+
record["metrics"]["minimum_plastic_work_increment_j_m3"]
|
| 682 |
+
for record in records
|
| 683 |
+
)
|
| 684 |
+
),
|
| 685 |
+
"wall_seconds": float(time.perf_counter() - started),
|
| 686 |
+
"data_file": str(DATA_PATH.relative_to(ROOT)),
|
| 687 |
+
"data_bytes": DATA_PATH.stat().st_size,
|
| 688 |
+
"data_sha256": _sha256(DATA_PATH),
|
| 689 |
+
"preview": str(preview.relative_to(ROOT)),
|
| 690 |
+
"agentfem_version": agentfem.__version__,
|
| 691 |
+
"agentfem_commit": AGENTFEM_COMMIT,
|
| 692 |
+
"refinement_audits": refinements,
|
| 693 |
+
}
|
| 694 |
+
_write_json_atomic(ARTIFACT_DIR / "quality.json", summary)
|
| 695 |
+
report = f"""# T2 material-loading-memory pilot quality report
|
| 696 |
+
|
| 697 |
+
Status: **{summary['status']}**
|
| 698 |
+
Independent trajectories: {summary['sample_count']}
|
| 699 |
+
Quality failures: {summary['quality_failure_count']}
|
| 700 |
+
|
| 701 |
+
## Coverage
|
| 702 |
+
|
| 703 |
+
- J2 linear isotropic hardening: {summary['material_models']['j2_linear_isotropic']}
|
| 704 |
+
- Chaboche combined hardening: {summary['material_models']['chaboche_combined']}
|
| 705 |
+
- Six loading-path families: 16 trajectories each
|
| 706 |
+
- Train/validation/test trajectories: 72/12/12
|
| 707 |
+
- Points per trajectory: {config['points_per_trajectory']}
|
| 708 |
+
|
| 709 |
+
## Verification
|
| 710 |
+
|
| 711 |
+
- Maximum yield-surface relative residual: {summary['maximum_yield_surface_relative_residual']:.3e}
|
| 712 |
+
- Maximum plastic-strain trace: {summary['maximum_plastic_strain_trace']:.3e}
|
| 713 |
+
- Maximum J2 monotonic analytical relative error: {summary['maximum_j2_analytical_relative_error']:.3e}
|
| 714 |
+
- Minimum repeated-zero-strain stress contrast in symmetric cycles: {summary['minimum_symmetric_zero_strain_memory_contrast_pa'] / 1.0e6:.3f} MPa
|
| 715 |
+
- Maximum 121-to-241-point stress change: {summary['maximum_refined_stress_relative_change']:.3%}
|
| 716 |
+
- Maximum 121-to-241-point PEEQ change: {summary['maximum_refined_peeq_relative_change']:.3%}
|
| 717 |
+
- Minimum raw `stress:plastic-strain-increment` diagnostic: {summary['minimum_plastic_work_increment_j_m3']:.3e} J/m^3
|
| 718 |
+
- All case IDs unique: {summary['all_case_ids_unique']}
|
| 719 |
+
|
| 720 |
+
The data are synthetic three-dimensional small-strain material-point histories under
|
| 721 |
+
prescribed proportional deviatoric strain. They are not structural FEM fields, an
|
| 722 |
+
experimental material calibration, or fatigue-life labels. Chaboche remains explicitly
|
| 723 |
+
labelled as an experimental AgentFEM capability. For Chaboche, raw stress work on plastic
|
| 724 |
+
strain is recorded but is not labelled as thermodynamic dissipation because the current
|
| 725 |
+
material-point contract does not expose a complete backstress storage/recovery energy split.
|
| 726 |
+
|
| 727 |
+

|
| 728 |
+
"""
|
| 729 |
+
(ARTIFACT_DIR / "QUALITY_REPORT.md").write_text(report, encoding="utf-8")
|
| 730 |
+
print(json.dumps(summary, indent=2, sort_keys=True))
|
| 731 |
+
if failures:
|
| 732 |
+
raise RuntimeError(f"T2 pilot failed {len(failures)} quality checks.")
|
| 733 |
+
return summary
|
| 734 |
+
|
| 735 |
+
|
| 736 |
+
def main() -> None:
|
| 737 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 738 |
+
parser.add_argument(
|
| 739 |
+
"--generate", action="store_true", help="Generate and verify the full pilot."
|
| 740 |
+
)
|
| 741 |
+
parser.add_argument(
|
| 742 |
+
"--design-only", action="store_true", help="Write only the frozen design."
|
| 743 |
+
)
|
| 744 |
+
args = parser.parse_args()
|
| 745 |
+
parameters = design_parameters()
|
| 746 |
+
splits = split_assignments(parameters)
|
| 747 |
+
if args.design_only:
|
| 748 |
+
DATA_DIR.mkdir(parents=True, exist_ok=True)
|
| 749 |
+
_write_jsonl_atomic(
|
| 750 |
+
DESIGN_PATH,
|
| 751 |
+
[
|
| 752 |
+
{
|
| 753 |
+
"id": f"{index:05d}",
|
| 754 |
+
"case_id": case_identity(row),
|
| 755 |
+
"split": splits[index],
|
| 756 |
+
"parameters": row,
|
| 757 |
+
}
|
| 758 |
+
for index, row in enumerate(parameters)
|
| 759 |
+
],
|
| 760 |
+
)
|
| 761 |
+
print(DESIGN_PATH)
|
| 762 |
+
return
|
| 763 |
+
if args.generate:
|
| 764 |
+
generate()
|
| 765 |
+
return
|
| 766 |
+
parser.error("Choose --generate or --design-only.")
|
| 767 |
+
|
| 768 |
+
|
| 769 |
+
if __name__ == "__main__":
|
| 770 |
+
main()
|
src/t2_material_loading_memory_v1.py
ADDED
|
@@ -0,0 +1,743 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Build the restartable T2 material-loading-memory v1 dataset.
|
| 2 |
+
|
| 3 |
+
One sample is one complete material-point trajectory. The 121 states within a
|
| 4 |
+
trajectory are never counted as independent samples. J2 linear isotropic
|
| 5 |
+
hardening and Chaboche combined hardening remain explicit model labels.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
from __future__ import annotations
|
| 9 |
+
|
| 10 |
+
import argparse
|
| 11 |
+
import hashlib
|
| 12 |
+
import json
|
| 13 |
+
import os
|
| 14 |
+
import platform
|
| 15 |
+
import time
|
| 16 |
+
from pathlib import Path
|
| 17 |
+
|
| 18 |
+
import h5py
|
| 19 |
+
import matplotlib
|
| 20 |
+
|
| 21 |
+
matplotlib.use("Agg")
|
| 22 |
+
import matplotlib.pyplot as plt
|
| 23 |
+
import numpy as np
|
| 24 |
+
from scipy.stats import qmc
|
| 25 |
+
|
| 26 |
+
import agentfem
|
| 27 |
+
from agentfem import campaigns
|
| 28 |
+
|
| 29 |
+
try:
|
| 30 |
+
from src import t2_material_loading_memory as core
|
| 31 |
+
except ModuleNotFoundError: # Direct execution from the src directory.
|
| 32 |
+
import t2_material_loading_memory as core
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
ROOT = Path(__file__).resolve().parents[1]
|
| 36 |
+
CONFIG_PATH = ROOT / "configs" / "t2_material_loading_memory_v1.json"
|
| 37 |
+
DATA_DIR = ROOT / "data" / "t2_material_loading_memory_v1"
|
| 38 |
+
SAMPLE_DIR = DATA_DIR / "samples"
|
| 39 |
+
RECORD_DIR = DATA_DIR / "records"
|
| 40 |
+
SHARD_DIR = DATA_DIR / "shards"
|
| 41 |
+
ARTIFACT_DIR = ROOT / "artifacts" / "t2_material_loading_memory_v1"
|
| 42 |
+
DESIGN_PATH = DATA_DIR / "design.jsonl"
|
| 43 |
+
INDEX_PATH = DATA_DIR / "index.jsonl"
|
| 44 |
+
MANIFEST_PATH = DATA_DIR / "manifest.json"
|
| 45 |
+
|
| 46 |
+
AGENTFEM_COMMIT = "058faecc05aeda143d014fd229401003a9258bbb"
|
| 47 |
+
MATERIAL_MODELS = core.MATERIAL_MODELS
|
| 48 |
+
PATH_FAMILIES = core.PATH_FAMILIES
|
| 49 |
+
REQUIRED_ARRAYS = (
|
| 50 |
+
"time_coordinate",
|
| 51 |
+
"path_anchors",
|
| 52 |
+
"signed_equivalent_strain",
|
| 53 |
+
"total_strain",
|
| 54 |
+
"stress_pa",
|
| 55 |
+
"signed_equivalent_stress_pa",
|
| 56 |
+
"mises_stress_pa",
|
| 57 |
+
"plastic_strain",
|
| 58 |
+
"equivalent_plastic_strain",
|
| 59 |
+
"plastic_multiplier_increment",
|
| 60 |
+
"elastic_step",
|
| 61 |
+
"trial_yield_function_pa",
|
| 62 |
+
"yield_radius_pa",
|
| 63 |
+
"shifted_mises_stress_pa",
|
| 64 |
+
"backstress_pa",
|
| 65 |
+
"backstress_components_pa",
|
| 66 |
+
"plastic_work_increment_j_m3",
|
| 67 |
+
"cumulative_plastic_work_j_m3",
|
| 68 |
+
"external_work_increment_j_m3",
|
| 69 |
+
"cumulative_external_work_j_m3",
|
| 70 |
+
)
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def load_config() -> dict[str, object]:
|
| 74 |
+
return json.loads(CONFIG_PATH.read_text(encoding="utf-8"))
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def _scale(value: float, bounds: list[float]) -> float:
|
| 78 |
+
return float(bounds[0] + value * (bounds[1] - bounds[0]))
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
def design_parameters(seed: int | None = None) -> tuple[dict[str, object], ...]:
|
| 82 |
+
"""Return a deterministic balanced 1,008-trajectory Sobol design."""
|
| 83 |
+
|
| 84 |
+
config = load_config()
|
| 85 |
+
actual_seed = int(config["seed"] if seed is None else seed)
|
| 86 |
+
ranges = config["ranges"]
|
| 87 |
+
per_stratum = int(config["samples_per_stratum"])
|
| 88 |
+
required = len(MATERIAL_MODELS) * len(PATH_FAMILIES) * per_stratum
|
| 89 |
+
exponent = int(np.ceil(np.log2(required)))
|
| 90 |
+
unit = qmc.Sobol(12, scramble=True, seed=actual_seed).random_base2(exponent)
|
| 91 |
+
rows: list[dict[str, object]] = []
|
| 92 |
+
cursor = 0
|
| 93 |
+
for material_model in MATERIAL_MODELS:
|
| 94 |
+
for path_family in PATH_FAMILIES:
|
| 95 |
+
for replicate in range(per_stratum):
|
| 96 |
+
u = unit[cursor]
|
| 97 |
+
cursor += 1
|
| 98 |
+
row: dict[str, object] = {
|
| 99 |
+
"material_model": material_model,
|
| 100 |
+
"path_family": path_family,
|
| 101 |
+
"replicate": replicate,
|
| 102 |
+
"young_pa": _scale(u[0], ranges["young_pa"]),
|
| 103 |
+
"poisson": _scale(u[1], ranges["poisson"]),
|
| 104 |
+
"yield_stress_pa": _scale(u[2], ranges["yield_stress_pa"]),
|
| 105 |
+
"maximum_equivalent_strain": _scale(
|
| 106 |
+
u[3], ranges["maximum_equivalent_strain"]
|
| 107 |
+
),
|
| 108 |
+
"path_shape_a": float(u[10]),
|
| 109 |
+
"path_shape_b": float(u[11]),
|
| 110 |
+
}
|
| 111 |
+
if material_model == "j2_linear_isotropic":
|
| 112 |
+
row.update(
|
| 113 |
+
{
|
| 114 |
+
"hardening_modulus_pa": _scale(
|
| 115 |
+
u[4], ranges["j2_hardening_modulus_pa"]
|
| 116 |
+
),
|
| 117 |
+
"backstress_c1_pa": 0.0,
|
| 118 |
+
"backstress_gamma1": 0.0,
|
| 119 |
+
"backstress_c2_pa": 0.0,
|
| 120 |
+
"backstress_gamma2": 0.0,
|
| 121 |
+
"isotropic_saturation_pa": 0.0,
|
| 122 |
+
"isotropic_rate": 0.0,
|
| 123 |
+
}
|
| 124 |
+
)
|
| 125 |
+
else:
|
| 126 |
+
row.update(
|
| 127 |
+
{
|
| 128 |
+
"hardening_modulus_pa": 0.0,
|
| 129 |
+
"backstress_c1_pa": _scale(
|
| 130 |
+
u[4], ranges["chaboche_c1_pa"]
|
| 131 |
+
),
|
| 132 |
+
"backstress_gamma1": _scale(
|
| 133 |
+
u[5], ranges["chaboche_gamma1"]
|
| 134 |
+
),
|
| 135 |
+
"backstress_c2_pa": _scale(
|
| 136 |
+
u[6], ranges["chaboche_c2_pa"]
|
| 137 |
+
),
|
| 138 |
+
"backstress_gamma2": _scale(
|
| 139 |
+
u[7], ranges["chaboche_gamma2"]
|
| 140 |
+
),
|
| 141 |
+
"isotropic_saturation_pa": _scale(
|
| 142 |
+
u[8], ranges["chaboche_isotropic_saturation_pa"]
|
| 143 |
+
),
|
| 144 |
+
"isotropic_rate": _scale(
|
| 145 |
+
u[9], ranges["chaboche_isotropic_rate"]
|
| 146 |
+
),
|
| 147 |
+
}
|
| 148 |
+
)
|
| 149 |
+
rows.append(row)
|
| 150 |
+
if len(rows) != int(config["sample_count"]):
|
| 151 |
+
raise RuntimeError("T2 v1 design size differs from the frozen configuration.")
|
| 152 |
+
return tuple(rows)
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
def case_identity(parameters: dict[str, object]) -> str:
|
| 156 |
+
return campaigns.case_id("t2_material_loading_memory_v1", parameters)
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
def split_assignments(parameters: tuple[dict[str, object], ...]) -> dict[int, str]:
|
| 160 |
+
"""Create 64/10/10 train/validation/test splits in every stratum."""
|
| 161 |
+
|
| 162 |
+
seed = int(load_config()["seed"])
|
| 163 |
+
result: dict[int, str] = {}
|
| 164 |
+
for model_index, material_model in enumerate(MATERIAL_MODELS):
|
| 165 |
+
for path_index, path_family in enumerate(PATH_FAMILIES):
|
| 166 |
+
members = np.asarray(
|
| 167 |
+
[
|
| 168 |
+
index
|
| 169 |
+
for index, row in enumerate(parameters)
|
| 170 |
+
if row["material_model"] == material_model
|
| 171 |
+
and row["path_family"] == path_family
|
| 172 |
+
],
|
| 173 |
+
dtype=int,
|
| 174 |
+
)
|
| 175 |
+
rng = np.random.default_rng(seed + 100 * model_index + path_index)
|
| 176 |
+
members = rng.permutation(members)
|
| 177 |
+
for index in members[:64]:
|
| 178 |
+
result[int(index)] = "train"
|
| 179 |
+
for index in members[64:74]:
|
| 180 |
+
result[int(index)] = "validation"
|
| 181 |
+
for index in members[74:84]:
|
| 182 |
+
result[int(index)] = "test"
|
| 183 |
+
return result
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
def _sha256(path: Path) -> str:
|
| 187 |
+
digest = hashlib.sha256()
|
| 188 |
+
with path.open("rb") as stream:
|
| 189 |
+
for block in iter(lambda: stream.read(1024 * 1024), b""):
|
| 190 |
+
digest.update(block)
|
| 191 |
+
return digest.hexdigest()
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
def _write_json_atomic(path: Path, value: object) -> None:
|
| 195 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 196 |
+
temporary = path.with_suffix(path.suffix + ".tmp")
|
| 197 |
+
temporary.write_text(
|
| 198 |
+
json.dumps(value, indent=2, sort_keys=True) + "\n", encoding="utf-8"
|
| 199 |
+
)
|
| 200 |
+
os.replace(temporary, path)
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
def _write_jsonl_atomic(path: Path, rows: list[dict[str, object]]) -> None:
|
| 204 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 205 |
+
temporary = path.with_suffix(path.suffix + ".tmp")
|
| 206 |
+
with temporary.open("w", encoding="utf-8") as stream:
|
| 207 |
+
for row in rows:
|
| 208 |
+
stream.write(json.dumps(row, sort_keys=True) + "\n")
|
| 209 |
+
os.replace(temporary, path)
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
def _write_npz_atomic(path: Path, arrays: dict[str, np.ndarray]) -> None:
|
| 213 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 214 |
+
temporary = path.with_suffix(path.suffix + ".tmp")
|
| 215 |
+
with temporary.open("wb") as stream:
|
| 216 |
+
np.savez_compressed(stream, **arrays)
|
| 217 |
+
os.replace(temporary, path)
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
def sample_paths(index: int) -> tuple[Path, Path]:
|
| 221 |
+
return SAMPLE_DIR / f"{index:05d}.npz", RECORD_DIR / f"{index:05d}.json"
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
def write_design() -> Path:
|
| 225 |
+
parameters = design_parameters()
|
| 226 |
+
splits = split_assignments(parameters)
|
| 227 |
+
rows = [
|
| 228 |
+
{
|
| 229 |
+
"id": f"{index:05d}",
|
| 230 |
+
"case_id": case_identity(row),
|
| 231 |
+
"split": splits[index],
|
| 232 |
+
"parameters": row,
|
| 233 |
+
}
|
| 234 |
+
for index, row in enumerate(parameters)
|
| 235 |
+
]
|
| 236 |
+
_write_jsonl_atomic(DESIGN_PATH, rows)
|
| 237 |
+
return DESIGN_PATH
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
def _sample_complete(index: int, expected_case_id: str) -> bool:
|
| 241 |
+
sample_path, record_path = sample_paths(index)
|
| 242 |
+
if not sample_path.exists() or not record_path.exists():
|
| 243 |
+
return False
|
| 244 |
+
try:
|
| 245 |
+
record = json.loads(record_path.read_text(encoding="utf-8"))
|
| 246 |
+
if record["case_id"] != expected_case_id:
|
| 247 |
+
return False
|
| 248 |
+
with np.load(sample_path) as arrays:
|
| 249 |
+
if set(REQUIRED_ARRAYS) - set(arrays.files):
|
| 250 |
+
return False
|
| 251 |
+
return all(np.isfinite(arrays[name]).all() for name in REQUIRED_ARRAYS)
|
| 252 |
+
except (OSError, ValueError, KeyError, json.JSONDecodeError):
|
| 253 |
+
return False
|
| 254 |
+
|
| 255 |
+
|
| 256 |
+
def _solve_record(
|
| 257 |
+
index: int, parameters: dict[str, object], split: str
|
| 258 |
+
) -> tuple[dict[str, np.ndarray], dict[str, object]]:
|
| 259 |
+
points = int(load_config()["points_per_trajectory"])
|
| 260 |
+
arrays, metrics = core.solve_trajectory(parameters, points=points)
|
| 261 |
+
reference_error = 0.0
|
| 262 |
+
if (
|
| 263 |
+
parameters["material_model"] == "j2_linear_isotropic"
|
| 264 |
+
and parameters["path_family"] == "monotonic_tension"
|
| 265 |
+
):
|
| 266 |
+
reference_stress, reference_peeq = core._j2_monotonic_reference(parameters)
|
| 267 |
+
reference_error = max(
|
| 268 |
+
abs(arrays["signed_equivalent_stress_pa"][-1] - reference_stress)
|
| 269 |
+
/ max(reference_stress, 1.0),
|
| 270 |
+
abs(arrays["equivalent_plastic_strain"][-1] - reference_peeq)
|
| 271 |
+
/ max(reference_peeq, 1.0e-15),
|
| 272 |
+
)
|
| 273 |
+
record: dict[str, object] = {
|
| 274 |
+
"id": f"{index:05d}",
|
| 275 |
+
"case_id": case_identity(parameters),
|
| 276 |
+
"split": split,
|
| 277 |
+
"parameters": parameters,
|
| 278 |
+
"metrics": metrics,
|
| 279 |
+
"initial_signed_stress_pa": float(arrays["signed_equivalent_stress_pa"][0]),
|
| 280 |
+
"j2_analytical_relative_error": float(reference_error),
|
| 281 |
+
}
|
| 282 |
+
return arrays, record
|
| 283 |
+
|
| 284 |
+
|
| 285 |
+
def generate_range(start: int, stop: int, *, force: bool = False) -> dict[str, object]:
|
| 286 |
+
parameters = design_parameters()
|
| 287 |
+
splits = split_assignments(parameters)
|
| 288 |
+
if start < 0 or stop > len(parameters) or start >= stop:
|
| 289 |
+
raise ValueError(f"Invalid range [{start}, {stop}) for {len(parameters)} samples.")
|
| 290 |
+
if not DESIGN_PATH.exists():
|
| 291 |
+
write_design()
|
| 292 |
+
started = time.perf_counter()
|
| 293 |
+
generated = 0
|
| 294 |
+
reused = 0
|
| 295 |
+
failures: list[dict[str, object]] = []
|
| 296 |
+
for index in range(start, stop):
|
| 297 |
+
row = parameters[index]
|
| 298 |
+
case_id = case_identity(row)
|
| 299 |
+
if not force and _sample_complete(index, case_id):
|
| 300 |
+
reused += 1
|
| 301 |
+
continue
|
| 302 |
+
sample_path, record_path = sample_paths(index)
|
| 303 |
+
try:
|
| 304 |
+
arrays, record = _solve_record(index, row, splits[index])
|
| 305 |
+
_write_npz_atomic(sample_path, arrays)
|
| 306 |
+
_write_json_atomic(record_path, record)
|
| 307 |
+
generated += 1
|
| 308 |
+
except Exception as exc: # Preserve failed identities instead of hiding them.
|
| 309 |
+
failures.append(
|
| 310 |
+
{
|
| 311 |
+
"id": f"{index:05d}",
|
| 312 |
+
"case_id": case_id,
|
| 313 |
+
"error_type": type(exc).__name__,
|
| 314 |
+
"error": str(exc),
|
| 315 |
+
}
|
| 316 |
+
)
|
| 317 |
+
summary = {
|
| 318 |
+
"start": start,
|
| 319 |
+
"stop": stop,
|
| 320 |
+
"generated": generated,
|
| 321 |
+
"reused": reused,
|
| 322 |
+
"failures": failures,
|
| 323 |
+
"wall_seconds": float(time.perf_counter() - started),
|
| 324 |
+
}
|
| 325 |
+
_write_json_atomic(ARTIFACT_DIR / f"range_{start:05d}_{stop:05d}.json", summary)
|
| 326 |
+
print(json.dumps(summary, indent=2, sort_keys=True))
|
| 327 |
+
if failures:
|
| 328 |
+
raise RuntimeError(f"Range [{start}, {stop}) had {len(failures)} failures.")
|
| 329 |
+
return summary
|
| 330 |
+
|
| 331 |
+
|
| 332 |
+
def _load_records() -> list[dict[str, object]]:
|
| 333 |
+
count = int(load_config()["sample_count"])
|
| 334 |
+
records: list[dict[str, object]] = []
|
| 335 |
+
missing: list[int] = []
|
| 336 |
+
for index in range(count):
|
| 337 |
+
_, record_path = sample_paths(index)
|
| 338 |
+
if not record_path.exists():
|
| 339 |
+
missing.append(index)
|
| 340 |
+
continue
|
| 341 |
+
records.append(json.loads(record_path.read_text(encoding="utf-8")))
|
| 342 |
+
if missing:
|
| 343 |
+
raise RuntimeError(f"Missing {len(missing)} records; first IDs: {missing[:8]}")
|
| 344 |
+
return records
|
| 345 |
+
|
| 346 |
+
|
| 347 |
+
def package_shards() -> dict[str, object]:
|
| 348 |
+
config = load_config()
|
| 349 |
+
parameters = design_parameters()
|
| 350 |
+
records = _load_records()
|
| 351 |
+
SHARD_DIR.mkdir(parents=True, exist_ok=True)
|
| 352 |
+
index_rows: list[dict[str, object]] = []
|
| 353 |
+
shard_rows: list[dict[str, object]] = []
|
| 354 |
+
for shard_index, members in enumerate(
|
| 355 |
+
np.array_split(np.arange(len(parameters), dtype=int), int(config["shard_count"]))
|
| 356 |
+
):
|
| 357 |
+
output = SHARD_DIR / f"part-{shard_index:05d}.h5"
|
| 358 |
+
temporary = output.with_suffix(".h5.tmp")
|
| 359 |
+
with h5py.File(temporary, "w") as h5:
|
| 360 |
+
h5.attrs["schema"] = config["schema"]
|
| 361 |
+
h5.attrs["schema_version"] = config["schema_version"]
|
| 362 |
+
h5.attrs["dataset_version"] = config["dataset_version"]
|
| 363 |
+
h5.attrs["agentfem_version"] = agentfem.__version__
|
| 364 |
+
h5.attrs["agentfem_commit"] = AGENTFEM_COMMIT
|
| 365 |
+
h5.attrs["numpy_version"] = np.__version__
|
| 366 |
+
h5.attrs["python_version"] = platform.python_version()
|
| 367 |
+
for index in members:
|
| 368 |
+
record = records[int(index)]
|
| 369 |
+
sample_path, _ = sample_paths(int(index))
|
| 370 |
+
if not _sample_complete(int(index), str(record["case_id"])):
|
| 371 |
+
raise RuntimeError(f"Incomplete sample: {int(index):05d}")
|
| 372 |
+
group = h5.create_group(f"{int(index):05d}")
|
| 373 |
+
group.attrs["case_id"] = record["case_id"]
|
| 374 |
+
group.attrs["split"] = record["split"]
|
| 375 |
+
group.attrs["material_model"] = record["parameters"]["material_model"]
|
| 376 |
+
group.attrs["path_family"] = record["parameters"]["path_family"]
|
| 377 |
+
group.attrs["parameters_json"] = json.dumps(
|
| 378 |
+
record["parameters"], sort_keys=True
|
| 379 |
+
)
|
| 380 |
+
group.attrs["metrics_json"] = json.dumps(record["metrics"], sort_keys=True)
|
| 381 |
+
with np.load(sample_path) as arrays:
|
| 382 |
+
for name in REQUIRED_ARRAYS:
|
| 383 |
+
group.create_dataset(
|
| 384 |
+
name, data=arrays[name], compression="gzip", shuffle=True
|
| 385 |
+
)
|
| 386 |
+
index_rows.append(
|
| 387 |
+
{
|
| 388 |
+
**record,
|
| 389 |
+
"shard": str(output.relative_to(ROOT)),
|
| 390 |
+
}
|
| 391 |
+
)
|
| 392 |
+
os.replace(temporary, output)
|
| 393 |
+
shard_rows.append(
|
| 394 |
+
{
|
| 395 |
+
"path": str(output.relative_to(ROOT)),
|
| 396 |
+
"first_id": f"{int(members[0]):05d}",
|
| 397 |
+
"last_id": f"{int(members[-1]):05d}",
|
| 398 |
+
"sample_count": int(len(members)),
|
| 399 |
+
"bytes": output.stat().st_size,
|
| 400 |
+
"sha256": _sha256(output),
|
| 401 |
+
}
|
| 402 |
+
)
|
| 403 |
+
index_rows.sort(key=lambda row: str(row["id"]))
|
| 404 |
+
_write_jsonl_atomic(INDEX_PATH, index_rows)
|
| 405 |
+
manifest = {
|
| 406 |
+
"schema": config["schema"],
|
| 407 |
+
"schema_version": config["schema_version"],
|
| 408 |
+
"dataset_version": config["dataset_version"],
|
| 409 |
+
"sample_count": len(parameters),
|
| 410 |
+
"points_per_trajectory": config["points_per_trajectory"],
|
| 411 |
+
"agentfem_version": agentfem.__version__,
|
| 412 |
+
"agentfem_commit": AGENTFEM_COMMIT,
|
| 413 |
+
"shards": shard_rows,
|
| 414 |
+
}
|
| 415 |
+
_write_json_atomic(MANIFEST_PATH, manifest)
|
| 416 |
+
print(json.dumps(manifest, indent=2, sort_keys=True))
|
| 417 |
+
return manifest
|
| 418 |
+
|
| 419 |
+
|
| 420 |
+
def _quality_failures(
|
| 421 |
+
parameters: tuple[dict[str, object], ...],
|
| 422 |
+
records: list[dict[str, object]],
|
| 423 |
+
refinements: list[dict[str, object]],
|
| 424 |
+
) -> list[dict[str, object]]:
|
| 425 |
+
thresholds = load_config()["quality_thresholds"]
|
| 426 |
+
failures: list[dict[str, object]] = []
|
| 427 |
+
for index, (row, record) in enumerate(zip(parameters, records, strict=True)):
|
| 428 |
+
metrics = record["metrics"]
|
| 429 |
+
checks = {
|
| 430 |
+
"all_finite": bool(metrics["all_finite"]),
|
| 431 |
+
"initial_stress": abs(float(record["initial_signed_stress_pa"]))
|
| 432 |
+
<= thresholds["initial_stress_pa"],
|
| 433 |
+
"plastic_incompressibility": metrics["maximum_plastic_strain_trace"]
|
| 434 |
+
<= thresholds["plastic_strain_trace"],
|
| 435 |
+
"peeq_monotone": metrics["minimum_peeq_increment"]
|
| 436 |
+
>= -thresholds["equivalent_plastic_strain_decrease"],
|
| 437 |
+
"yield_surface": metrics["maximum_yield_surface_relative_residual"]
|
| 438 |
+
<= thresholds["yield_surface_relative_residual"],
|
| 439 |
+
"positive_total_plastic_work": metrics[
|
| 440 |
+
"final_cumulative_plastic_work_j_m3"
|
| 441 |
+
]
|
| 442 |
+
> thresholds["final_plastic_work_minimum_j_m3"],
|
| 443 |
+
"plastic_excitation": metrics["plastic_step_count"] > 0,
|
| 444 |
+
}
|
| 445 |
+
if row["material_model"] == "j2_linear_isotropic":
|
| 446 |
+
checks["j2_nonnegative_plastic_work_increment"] = metrics[
|
| 447 |
+
"minimum_plastic_work_increment_j_m3"
|
| 448 |
+
] >= -thresholds["j2_plastic_work_negative_tolerance_j_m3"]
|
| 449 |
+
if (
|
| 450 |
+
row["material_model"] == "j2_linear_isotropic"
|
| 451 |
+
and row["path_family"] == "monotonic_tension"
|
| 452 |
+
):
|
| 453 |
+
checks["j2_analytical"] = record[
|
| 454 |
+
"j2_analytical_relative_error"
|
| 455 |
+
] <= thresholds["j2_monotonic_analytical_relative_error"]
|
| 456 |
+
if row["path_family"] == "symmetric_cyclic":
|
| 457 |
+
checks["history_memory_contrast"] = metrics[
|
| 458 |
+
"zero_strain_stress_range_pa"
|
| 459 |
+
] >= thresholds["zero_strain_memory_contrast_pa"]
|
| 460 |
+
failed = sorted(name for name, passed in checks.items() if not passed)
|
| 461 |
+
if failed:
|
| 462 |
+
failures.append({"index": index, "failed_checks": failed})
|
| 463 |
+
for item in refinements:
|
| 464 |
+
failed = []
|
| 465 |
+
if item["maximum_stress_relative_change"] > thresholds[
|
| 466 |
+
"refined_stress_relative_change"
|
| 467 |
+
]:
|
| 468 |
+
failed.append("refined_stress")
|
| 469 |
+
if item["maximum_peeq_relative_change"] > thresholds[
|
| 470 |
+
"refined_peeq_relative_change"
|
| 471 |
+
]:
|
| 472 |
+
failed.append("refined_peeq")
|
| 473 |
+
if failed:
|
| 474 |
+
failures.append({"index": item["index"], "failed_checks": failed})
|
| 475 |
+
return failures
|
| 476 |
+
|
| 477 |
+
|
| 478 |
+
def _refinement_audits(
|
| 479 |
+
parameters: tuple[dict[str, object], ...]
|
| 480 |
+
) -> list[dict[str, object]]:
|
| 481 |
+
selected = [
|
| 482 |
+
index
|
| 483 |
+
for index, row in enumerate(parameters)
|
| 484 |
+
if int(row["replicate"]) in (0, int(load_config()["samples_per_stratum"]) - 1)
|
| 485 |
+
]
|
| 486 |
+
refinements: list[dict[str, object]] = []
|
| 487 |
+
for index in selected:
|
| 488 |
+
row = parameters[index]
|
| 489 |
+
sample_path, _ = sample_paths(index)
|
| 490 |
+
with np.load(sample_path) as coarse:
|
| 491 |
+
coarse_stress = np.asarray(coarse["signed_equivalent_stress_pa"])
|
| 492 |
+
coarse_peeq = np.asarray(coarse["equivalent_plastic_strain"])
|
| 493 |
+
fine, _ = core.solve_trajectory(row, points=241)
|
| 494 |
+
fine_stress = fine["signed_equivalent_stress_pa"][::2]
|
| 495 |
+
fine_peeq = fine["equivalent_plastic_strain"][::2]
|
| 496 |
+
stress_scale = max(float(np.max(np.abs(fine_stress))), 1.0)
|
| 497 |
+
peeq_scale = max(float(np.max(fine_peeq)), 1.0e-15)
|
| 498 |
+
refinements.append(
|
| 499 |
+
{
|
| 500 |
+
"index": index,
|
| 501 |
+
"material_model": row["material_model"],
|
| 502 |
+
"path_family": row["path_family"],
|
| 503 |
+
"maximum_stress_relative_change": float(
|
| 504 |
+
np.max(np.abs(coarse_stress - fine_stress)) / stress_scale
|
| 505 |
+
),
|
| 506 |
+
"maximum_peeq_relative_change": float(
|
| 507 |
+
np.max(np.abs(coarse_peeq - fine_peeq)) / peeq_scale
|
| 508 |
+
),
|
| 509 |
+
}
|
| 510 |
+
)
|
| 511 |
+
return refinements
|
| 512 |
+
|
| 513 |
+
|
| 514 |
+
def _create_preview(parameters: tuple[dict[str, object], ...]) -> Path:
|
| 515 |
+
ARTIFACT_DIR.mkdir(parents=True, exist_ok=True)
|
| 516 |
+
fig, axes = plt.subplots(2, 3, figsize=(12.0, 7.2), constrained_layout=True)
|
| 517 |
+
colors = {"j2_linear_isotropic": "#2563eb", "chaboche_combined": "#dc2626"}
|
| 518 |
+
labels = {"j2_linear_isotropic": "J2 isotropic", "chaboche_combined": "Chaboche"}
|
| 519 |
+
for axis, family in zip(axes.flat, PATH_FAMILIES, strict=True):
|
| 520 |
+
for model in MATERIAL_MODELS:
|
| 521 |
+
index = next(
|
| 522 |
+
idx
|
| 523 |
+
for idx, row in enumerate(parameters)
|
| 524 |
+
if row["material_model"] == model
|
| 525 |
+
and row["path_family"] == family
|
| 526 |
+
and row["replicate"] == 0
|
| 527 |
+
)
|
| 528 |
+
sample_path, _ = sample_paths(index)
|
| 529 |
+
with np.load(sample_path) as arrays:
|
| 530 |
+
strain = np.asarray(arrays["signed_equivalent_strain"])
|
| 531 |
+
stress = np.asarray(arrays["signed_equivalent_stress_pa"])
|
| 532 |
+
axis.plot(100.0 * strain, stress / 1.0e6, color=colors[model], lw=1.8, label=labels[model])
|
| 533 |
+
axis.axhline(0.0, color="#9ca3af", lw=0.6)
|
| 534 |
+
axis.axvline(0.0, color="#9ca3af", lw=0.6)
|
| 535 |
+
axis.set_title(family.replace("_", " ").title(), fontsize=10)
|
| 536 |
+
axis.set_xlabel("Signed equivalent strain (%)")
|
| 537 |
+
axis.set_ylabel("Signed equivalent stress (MPa)")
|
| 538 |
+
axis.grid(alpha=0.22)
|
| 539 |
+
axes.flat[0].legend(frameon=False, fontsize=9)
|
| 540 |
+
fig.suptitle(
|
| 541 |
+
"AgentFEM T2 v1: path-dependent material memory\n"
|
| 542 |
+
"Representative independent cases; J2 and Chaboche parameters are not matched.",
|
| 543 |
+
fontsize=13,
|
| 544 |
+
)
|
| 545 |
+
output = ARTIFACT_DIR / "hysteresis_preview.png"
|
| 546 |
+
fig.savefig(output, dpi=180)
|
| 547 |
+
plt.close(fig)
|
| 548 |
+
return output
|
| 549 |
+
|
| 550 |
+
|
| 551 |
+
def audit_dataset() -> dict[str, object]:
|
| 552 |
+
config = load_config()
|
| 553 |
+
parameters = design_parameters()
|
| 554 |
+
splits = split_assignments(parameters)
|
| 555 |
+
records = _load_records()
|
| 556 |
+
manifest = json.loads(MANIFEST_PATH.read_text(encoding="utf-8"))
|
| 557 |
+
integrity_failures: list[dict[str, object]] = []
|
| 558 |
+
observed_ids: list[str] = []
|
| 559 |
+
for shard in manifest["shards"]:
|
| 560 |
+
path = ROOT / shard["path"]
|
| 561 |
+
if _sha256(path) != shard["sha256"]:
|
| 562 |
+
integrity_failures.append({"shard": shard["path"], "error": "sha256"})
|
| 563 |
+
continue
|
| 564 |
+
with h5py.File(path, "r") as h5:
|
| 565 |
+
observed_ids.extend(sorted(h5.keys()))
|
| 566 |
+
for sample_id, group in h5.items():
|
| 567 |
+
missing = sorted(set(REQUIRED_ARRAYS) - set(group.keys()))
|
| 568 |
+
nonfinite = [
|
| 569 |
+
name for name in REQUIRED_ARRAYS if name in group and not np.isfinite(group[name][:]).all()
|
| 570 |
+
]
|
| 571 |
+
if missing or nonfinite:
|
| 572 |
+
integrity_failures.append(
|
| 573 |
+
{"id": sample_id, "missing": missing, "nonfinite": nonfinite}
|
| 574 |
+
)
|
| 575 |
+
expected_ids = [f"{index:05d}" for index in range(len(parameters))]
|
| 576 |
+
if observed_ids != expected_ids:
|
| 577 |
+
integrity_failures.append({"error": "sample_id_coverage"})
|
| 578 |
+
refinements = _refinement_audits(parameters)
|
| 579 |
+
failures = _quality_failures(parameters, records, refinements)
|
| 580 |
+
failures.extend(integrity_failures)
|
| 581 |
+
preview = _create_preview(parameters)
|
| 582 |
+
summary = {
|
| 583 |
+
"status": "accepted" if not failures else "rejected",
|
| 584 |
+
"sample_count": len(parameters),
|
| 585 |
+
"points_per_trajectory": config["points_per_trajectory"],
|
| 586 |
+
"material_models": {
|
| 587 |
+
model: sum(row["material_model"] == model for row in parameters)
|
| 588 |
+
for model in MATERIAL_MODELS
|
| 589 |
+
},
|
| 590 |
+
"path_families": {
|
| 591 |
+
family: sum(row["path_family"] == family for row in parameters)
|
| 592 |
+
for family in PATH_FAMILIES
|
| 593 |
+
},
|
| 594 |
+
"splits": {
|
| 595 |
+
name: sum(value == name for value in splits.values())
|
| 596 |
+
for name in ("train", "validation", "test")
|
| 597 |
+
},
|
| 598 |
+
"all_case_ids_unique": len({case_identity(row) for row in parameters}) == len(parameters),
|
| 599 |
+
"quality_failure_count": len(failures),
|
| 600 |
+
"quality_failures": failures,
|
| 601 |
+
"maximum_yield_surface_relative_residual": float(
|
| 602 |
+
max(record["metrics"]["maximum_yield_surface_relative_residual"] for record in records)
|
| 603 |
+
),
|
| 604 |
+
"maximum_plastic_strain_trace": float(
|
| 605 |
+
max(record["metrics"]["maximum_plastic_strain_trace"] for record in records)
|
| 606 |
+
),
|
| 607 |
+
"maximum_j2_analytical_relative_error": float(
|
| 608 |
+
max(record["j2_analytical_relative_error"] for record in records)
|
| 609 |
+
),
|
| 610 |
+
"minimum_symmetric_zero_strain_memory_contrast_pa": float(
|
| 611 |
+
min(
|
| 612 |
+
record["metrics"]["zero_strain_stress_range_pa"]
|
| 613 |
+
for record in records
|
| 614 |
+
if record["parameters"]["path_family"] == "symmetric_cyclic"
|
| 615 |
+
)
|
| 616 |
+
),
|
| 617 |
+
"maximum_refined_stress_relative_change": float(
|
| 618 |
+
max(item["maximum_stress_relative_change"] for item in refinements)
|
| 619 |
+
),
|
| 620 |
+
"maximum_refined_peeq_relative_change": float(
|
| 621 |
+
max(item["maximum_peeq_relative_change"] for item in refinements)
|
| 622 |
+
),
|
| 623 |
+
"minimum_plastic_work_increment_j_m3": float(
|
| 624 |
+
min(record["metrics"]["minimum_plastic_work_increment_j_m3"] for record in records)
|
| 625 |
+
),
|
| 626 |
+
"data_bytes": int(sum(int(shard["bytes"]) for shard in manifest["shards"])),
|
| 627 |
+
"preview": str(preview.relative_to(ROOT)),
|
| 628 |
+
"agentfem_version": agentfem.__version__,
|
| 629 |
+
"agentfem_commit": AGENTFEM_COMMIT,
|
| 630 |
+
"refinement_audits": refinements,
|
| 631 |
+
}
|
| 632 |
+
_write_json_atomic(ARTIFACT_DIR / "quality.json", summary)
|
| 633 |
+
report = f"""# T2 material-loading-memory v1 quality report
|
| 634 |
+
|
| 635 |
+
Status: **{summary['status']}**
|
| 636 |
+
Independent trajectories: {summary['sample_count']}
|
| 637 |
+
Quality failures: {summary['quality_failure_count']}
|
| 638 |
+
|
| 639 |
+
## Coverage
|
| 640 |
+
|
| 641 |
+
- J2 linear isotropic hardening: {summary['material_models']['j2_linear_isotropic']}
|
| 642 |
+
- Chaboche combined hardening: {summary['material_models']['chaboche_combined']}
|
| 643 |
+
- Six loading-path families: 168 trajectories each
|
| 644 |
+
- Train/validation/test trajectories: 768/120/120
|
| 645 |
+
- Points per trajectory: {config['points_per_trajectory']}
|
| 646 |
+
- Packaged HDF5 shards: {len(manifest['shards'])}
|
| 647 |
+
|
| 648 |
+
## Verification
|
| 649 |
+
|
| 650 |
+
- Maximum yield-surface relative residual: {summary['maximum_yield_surface_relative_residual']:.3e}
|
| 651 |
+
- Maximum plastic-strain trace: {summary['maximum_plastic_strain_trace']:.3e}
|
| 652 |
+
- Maximum J2 monotonic analytical relative error: {summary['maximum_j2_analytical_relative_error']:.3e}
|
| 653 |
+
- Minimum repeated-zero-strain stress contrast in symmetric cycles: {summary['minimum_symmetric_zero_strain_memory_contrast_pa'] / 1.0e6:.3f} MPa
|
| 654 |
+
- Maximum 121-to-241-point stress change across 24 audits: {summary['maximum_refined_stress_relative_change']:.3%}
|
| 655 |
+
- Maximum 121-to-241-point PEEQ change across 24 audits: {summary['maximum_refined_peeq_relative_change']:.3%}
|
| 656 |
+
- Minimum raw `stress:plastic-strain-increment` diagnostic: {summary['minimum_plastic_work_increment_j_m3']:.3e} J/m^3
|
| 657 |
+
- All case IDs unique: {summary['all_case_ids_unique']}
|
| 658 |
+
|
| 659 |
+
The data are synthetic three-dimensional small-strain material-point histories under
|
| 660 |
+
prescribed proportional deviatoric strain. They are not structural FEM fields, an
|
| 661 |
+
experimental material calibration, or fatigue-life labels. Chaboche remains explicitly
|
| 662 |
+
labelled as an experimental AgentFEM capability. For Chaboche, raw stress work on plastic
|
| 663 |
+
strain is recorded but is not labelled as thermodynamic dissipation because the current
|
| 664 |
+
material-point contract does not expose a complete backstress storage/recovery energy split.
|
| 665 |
+
|
| 666 |
+

|
| 667 |
+
"""
|
| 668 |
+
(ARTIFACT_DIR / "QUALITY_REPORT.md").write_text(report, encoding="utf-8")
|
| 669 |
+
print(json.dumps(summary, indent=2, sort_keys=True))
|
| 670 |
+
if failures:
|
| 671 |
+
raise RuntimeError(f"T2 v1 failed {len(failures)} quality checks.")
|
| 672 |
+
return summary
|
| 673 |
+
|
| 674 |
+
|
| 675 |
+
def validate_design() -> dict[str, object]:
|
| 676 |
+
parameters = design_parameters()
|
| 677 |
+
splits = split_assignments(parameters)
|
| 678 |
+
config = load_config()
|
| 679 |
+
result = {
|
| 680 |
+
"sample_count": len(parameters),
|
| 681 |
+
"unique_case_ids": len({case_identity(row) for row in parameters}),
|
| 682 |
+
"splits": {
|
| 683 |
+
name: sum(value == name for value in splits.values())
|
| 684 |
+
for name in ("train", "validation", "test")
|
| 685 |
+
},
|
| 686 |
+
"strata": {
|
| 687 |
+
f"{model}/{family}": sum(
|
| 688 |
+
row["material_model"] == model and row["path_family"] == family
|
| 689 |
+
for row in parameters
|
| 690 |
+
)
|
| 691 |
+
for model in MATERIAL_MODELS
|
| 692 |
+
for family in PATH_FAMILIES
|
| 693 |
+
},
|
| 694 |
+
"expected": {
|
| 695 |
+
"sample_count": config["sample_count"],
|
| 696 |
+
"splits": config["splits"],
|
| 697 |
+
},
|
| 698 |
+
}
|
| 699 |
+
if result["sample_count"] != config["sample_count"]:
|
| 700 |
+
raise RuntimeError("Unexpected design size.")
|
| 701 |
+
if result["unique_case_ids"] != result["sample_count"]:
|
| 702 |
+
raise RuntimeError("Duplicate case IDs.")
|
| 703 |
+
if result["splits"] != config["splits"]:
|
| 704 |
+
raise RuntimeError("Unexpected split counts.")
|
| 705 |
+
print(json.dumps(result, indent=2, sort_keys=True))
|
| 706 |
+
return result
|
| 707 |
+
|
| 708 |
+
|
| 709 |
+
def main() -> None:
|
| 710 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 711 |
+
parser.add_argument("--design-only", action="store_true")
|
| 712 |
+
parser.add_argument("--validate-design", action="store_true")
|
| 713 |
+
parser.add_argument("--range", nargs=2, type=int, metavar=("START", "STOP"))
|
| 714 |
+
parser.add_argument("--force", action="store_true")
|
| 715 |
+
parser.add_argument("--package", action="store_true")
|
| 716 |
+
parser.add_argument("--audit", action="store_true")
|
| 717 |
+
parser.add_argument("--all", action="store_true")
|
| 718 |
+
args = parser.parse_args()
|
| 719 |
+
if args.design_only:
|
| 720 |
+
print(write_design())
|
| 721 |
+
return
|
| 722 |
+
if args.validate_design:
|
| 723 |
+
validate_design()
|
| 724 |
+
return
|
| 725 |
+
if args.range:
|
| 726 |
+
generate_range(args.range[0], args.range[1], force=args.force)
|
| 727 |
+
return
|
| 728 |
+
if args.package:
|
| 729 |
+
package_shards()
|
| 730 |
+
return
|
| 731 |
+
if args.audit:
|
| 732 |
+
audit_dataset()
|
| 733 |
+
return
|
| 734 |
+
if args.all:
|
| 735 |
+
generate_range(0, int(load_config()["sample_count"]), force=args.force)
|
| 736 |
+
package_shards()
|
| 737 |
+
audit_dataset()
|
| 738 |
+
return
|
| 739 |
+
parser.error("Choose --design-only, --validate-design, --range, --package, --audit or --all.")
|
| 740 |
+
|
| 741 |
+
|
| 742 |
+
if __name__ == "__main__":
|
| 743 |
+
main()
|
tests/test_t2_material_loading_memory.py
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
|
| 4 |
+
import h5py
|
| 5 |
+
import numpy as np
|
| 6 |
+
|
| 7 |
+
from src.t2_material_loading_memory import (
|
| 8 |
+
DATA_PATH,
|
| 9 |
+
MATERIAL_MODELS,
|
| 10 |
+
PATH_FAMILIES,
|
| 11 |
+
_j2_monotonic_reference,
|
| 12 |
+
case_identity,
|
| 13 |
+
design_parameters,
|
| 14 |
+
prescribed_history,
|
| 15 |
+
solve_trajectory,
|
| 16 |
+
split_assignments,
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def test_t2_design_is_unique_balanced_and_split_by_trajectory():
|
| 21 |
+
rows = design_parameters()
|
| 22 |
+
split = split_assignments(rows)
|
| 23 |
+
assert len(rows) == 96
|
| 24 |
+
assert len({case_identity(row) for row in rows}) == 96
|
| 25 |
+
assert sum(value == "train" for value in split.values()) == 72
|
| 26 |
+
assert sum(value == "validation" for value in split.values()) == 12
|
| 27 |
+
assert sum(value == "test" for value in split.values()) == 12
|
| 28 |
+
for model in MATERIAL_MODELS:
|
| 29 |
+
assert sum(row["material_model"] == model for row in rows) == 48
|
| 30 |
+
for family in PATH_FAMILIES:
|
| 31 |
+
indices = [
|
| 32 |
+
index
|
| 33 |
+
for index, row in enumerate(rows)
|
| 34 |
+
if row["material_model"] == model
|
| 35 |
+
and row["path_family"] == family
|
| 36 |
+
]
|
| 37 |
+
assert len(indices) == 8
|
| 38 |
+
assert sum(split[index] == "train" for index in indices) == 6
|
| 39 |
+
assert sum(split[index] == "validation" for index in indices) == 1
|
| 40 |
+
assert sum(split[index] == "test" for index in indices) == 1
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def test_t2_prescribed_histories_have_fixed_size_and_required_reversals():
|
| 44 |
+
for row in design_parameters():
|
| 45 |
+
time, strain, anchors = prescribed_history(row)
|
| 46 |
+
assert len(time) == len(strain) == 121
|
| 47 |
+
assert np.all(np.diff(time) > 0.0)
|
| 48 |
+
assert strain[0] == 0.0
|
| 49 |
+
assert np.max(np.abs(strain)) <= 1.15 * row["maximum_equivalent_strain"]
|
| 50 |
+
for anchor in anchors:
|
| 51 |
+
assert np.any(np.isclose(strain, anchor, rtol=0.0, atol=1.0e-15))
|
| 52 |
+
if row["path_family"] not in ("monotonic_tension", "unload_reload"):
|
| 53 |
+
assert np.min(anchors) < 0.0 < np.max(anchors)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def test_t2_refined_paths_are_nested_at_every_coarse_state():
|
| 57 |
+
for row in design_parameters():
|
| 58 |
+
_, coarse, _ = prescribed_history(row, points=121)
|
| 59 |
+
_, fine, _ = prescribed_history(row, points=241)
|
| 60 |
+
np.testing.assert_allclose(coarse, fine[::2], rtol=0.0, atol=1.0e-15)
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def test_t2_agentfem_material_point_smoke_paths_are_physical():
|
| 64 |
+
rows = design_parameters()
|
| 65 |
+
for model in MATERIAL_MODELS:
|
| 66 |
+
for family in PATH_FAMILIES:
|
| 67 |
+
row = next(
|
| 68 |
+
item
|
| 69 |
+
for item in rows
|
| 70 |
+
if item["material_model"] == model
|
| 71 |
+
and item["path_family"] == family
|
| 72 |
+
)
|
| 73 |
+
arrays, metrics = solve_trajectory(row, points=41)
|
| 74 |
+
assert metrics["all_finite"]
|
| 75 |
+
assert metrics["plastic_step_count"] > 0
|
| 76 |
+
assert metrics["maximum_plastic_strain_trace"] < 1.0e-10
|
| 77 |
+
assert metrics["minimum_peeq_increment"] >= -1.0e-12
|
| 78 |
+
assert metrics["maximum_yield_surface_relative_residual"] < 1.0e-8
|
| 79 |
+
assert arrays["signed_equivalent_stress_pa"][0] == 0.0
|
| 80 |
+
if family == "symmetric_cyclic":
|
| 81 |
+
assert metrics["zero_strain_stress_range_pa"] > 1.0e6
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
def test_t2_j2_monotonic_path_matches_closed_form():
|
| 85 |
+
row = next(
|
| 86 |
+
item
|
| 87 |
+
for item in design_parameters()
|
| 88 |
+
if item["material_model"] == "j2_linear_isotropic"
|
| 89 |
+
and item["path_family"] == "monotonic_tension"
|
| 90 |
+
)
|
| 91 |
+
arrays, _ = solve_trajectory(row, points=41)
|
| 92 |
+
stress, peeq = _j2_monotonic_reference(row)
|
| 93 |
+
np.testing.assert_allclose(
|
| 94 |
+
arrays["signed_equivalent_stress_pa"][-1], stress, rtol=1.0e-11
|
| 95 |
+
)
|
| 96 |
+
np.testing.assert_allclose(
|
| 97 |
+
arrays["equivalent_plastic_strain"][-1], peeq, rtol=1.0e-11
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
def test_t2_packaged_pilot_is_readable_when_present():
|
| 102 |
+
if not DATA_PATH.exists():
|
| 103 |
+
return
|
| 104 |
+
quality_path = DATA_PATH.parents[2] / "artifacts" / DATA_PATH.parent.name / "quality.json"
|
| 105 |
+
quality = json.loads(quality_path.read_text(encoding="utf-8"))
|
| 106 |
+
assert quality["status"] == "accepted"
|
| 107 |
+
with h5py.File(DATA_PATH, "r") as h5:
|
| 108 |
+
assert len(h5) == 96
|
| 109 |
+
for group in h5.values():
|
| 110 |
+
assert group["stress_pa"].shape == (121, 3, 3)
|
| 111 |
+
assert np.isfinite(group["stress_pa"][:]).all()
|
| 112 |
+
assert np.isfinite(group["equivalent_plastic_strain"][:]).all()
|
tests/test_t2_material_loading_memory_v1.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
from src.load_t2_material_loading_memory import load_trajectory
|
| 6 |
+
from src.t2_material_loading_memory import prescribed_history
|
| 7 |
+
from src.t2_material_loading_memory_v1 import (
|
| 8 |
+
DATA_DIR,
|
| 9 |
+
MATERIAL_MODELS,
|
| 10 |
+
PATH_FAMILIES,
|
| 11 |
+
case_identity,
|
| 12 |
+
design_parameters,
|
| 13 |
+
split_assignments,
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def test_v1_design_is_unique_balanced_and_stratified():
|
| 18 |
+
rows = design_parameters()
|
| 19 |
+
split = split_assignments(rows)
|
| 20 |
+
assert len(rows) == 1008
|
| 21 |
+
assert len({case_identity(row) for row in rows}) == 1008
|
| 22 |
+
assert sum(value == "train" for value in split.values()) == 768
|
| 23 |
+
assert sum(value == "validation" for value in split.values()) == 120
|
| 24 |
+
assert sum(value == "test" for value in split.values()) == 120
|
| 25 |
+
for model in MATERIAL_MODELS:
|
| 26 |
+
assert sum(row["material_model"] == model for row in rows) == 504
|
| 27 |
+
for family in PATH_FAMILIES:
|
| 28 |
+
indices = [
|
| 29 |
+
index
|
| 30 |
+
for index, row in enumerate(rows)
|
| 31 |
+
if row["material_model"] == model and row["path_family"] == family
|
| 32 |
+
]
|
| 33 |
+
assert len(indices) == 84
|
| 34 |
+
assert sum(split[index] == "train" for index in indices) == 64
|
| 35 |
+
assert sum(split[index] == "validation" for index in indices) == 10
|
| 36 |
+
assert sum(split[index] == "test" for index in indices) == 10
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def test_v1_parameter_ranges_and_model_labels_are_explicit():
|
| 40 |
+
rows = design_parameters()
|
| 41 |
+
for row in rows:
|
| 42 |
+
assert 150.0e9 <= row["young_pa"] <= 230.0e9
|
| 43 |
+
assert 0.25 <= row["poisson"] <= 0.34
|
| 44 |
+
assert 180.0e6 <= row["yield_stress_pa"] <= 450.0e6
|
| 45 |
+
assert 0.003 <= row["maximum_equivalent_strain"] <= 0.012
|
| 46 |
+
if row["material_model"] == "j2_linear_isotropic":
|
| 47 |
+
assert row["backstress_c1_pa"] == 0.0
|
| 48 |
+
assert row["isotropic_saturation_pa"] == 0.0
|
| 49 |
+
else:
|
| 50 |
+
assert row["hardening_modulus_pa"] == 0.0
|
| 51 |
+
assert row["backstress_c1_pa"] > 0.0
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def test_v1_histories_preserve_reversals_under_refinement():
|
| 55 |
+
for row in design_parameters()[::83]:
|
| 56 |
+
_, coarse, anchors = prescribed_history(row, points=121)
|
| 57 |
+
_, fine, _ = prescribed_history(row, points=241)
|
| 58 |
+
np.testing.assert_allclose(coarse, fine[::2], rtol=0.0, atol=1.0e-15)
|
| 59 |
+
for anchor in anchors:
|
| 60 |
+
assert np.any(np.isclose(coarse, anchor, rtol=0.0, atol=1.0e-15))
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def test_v1_packaged_data_and_lightweight_reader_when_present():
|
| 64 |
+
manifest_path = DATA_DIR / "manifest.json"
|
| 65 |
+
if not manifest_path.exists():
|
| 66 |
+
return
|
| 67 |
+
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
| 68 |
+
assert manifest["sample_count"] == 1008
|
| 69 |
+
assert len(manifest["shards"]) == 8
|
| 70 |
+
sample = load_trajectory(DATA_DIR, 0)
|
| 71 |
+
assert sample["history"]["stress_pa"].shape == (121, 3, 3)
|
| 72 |
+
assert np.isfinite(sample["history"]["stress_pa"]).all()
|