Datasets:
Tasks:
Other
Formats:
json
Size:
10K - 100K
Tags:
agentfem
soft-robotics
programmable-matter
structural-mechanics
inverse-design
scientific-machine-learning
License:
Add runnable same-load equilibrium-branch visualization
Browse filesFiles changed (3)
- README.md+28
- compare_branches.pyAdded+106
- rod-branches.pngAdded
104 unmodified lines105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138104 unmodified lines sample = json.loads(next(f))```
## Same loading, different shapes
Run [compare_branches.py](compare_branches.py) to plot three stored equilibria atidentical controls, alongside their equilibrium branches. It downloads only thepinned test partition; no FEM installation or model checkpoint is needed.
```bashpip install numpy matplotlib huggingface_hubpython compare_branches.py# Offline: python compare_branches.py --data states/test.jsonl.gz```

The default example has tip y/L = +0.7923, -0.7923 and 0. The bent states are locallystable; the straight state is unstable under the dataset's discrete Hessian test.The script checks identical controls and complete branch triplets across all 225test microforce load points (9 scenes × 25 samples). This checks data pairing, notindependent solver accuracy. These are quasi-static solutions, not a sequence ofphysical motion, and the plot does not run the neural predictor.
Try `--step 0` or `--step 24` to inspect another stored load. A branch label addsinformation: a single-valued predictor given only these controls cannot uniquelychoose among the three equilibria.
中文:运行脚本即可看到同一组载荷下的三种平衡形状。虚线表示不稳定的直杆解,不是杆运动经过的轨迹。示例不需要安装有限元软件,也不运行神经网络。
## Validation
- Axial extension and constant-curvature analytic checks pass.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106"""Plot stored equilibria at identical controls; no solver or neural model runs.
Copyright 2026 Haoming Luo. SPDX-License-Identifier: Apache-2.0Data and generated figures: CC BY 4.0. See the dataset card for attribution."""import argparseimport gzipimport jsonfrom pathlib import Path
import matplotlibmatplotlib.use("Agg")import matplotlib.pyplot as pltimport numpy as np
REPO = "HaomingLuo/AgentFEM-Programmable-Soft-Rods"REVISION = "dcd30783bc4dad627f5c7d732d2adabf312d60cd"
def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--data", type=Path, help="Offline states/test.jsonl.gz") parser.add_argument("--scene", default="microforce_001") parser.add_argument("--step", type=int, default=12) parser.add_argument("--output", type=Path, default=Path("rod-branches.png")) args = parser.parse_args() path = args.data if path is None: from huggingface_hub import hf_hub_download path = hf_hub_download(REPO, "states/test.jsonl.gz", repo_type="dataset", revision=REVISION) with gzip.open(path, "rt", encoding="utf-8") as stream: rows = [json.loads(line) for line in stream if line.strip()] groups = {} for row in rows: if row["family"] != "microforce": continue if row["split"] != "test": raise ValueError("Expected test split") key = (row["scene_id"], row["step"]) group = groups.setdefault(key, {}) branch = row["branch"] if branch in group: raise ValueError(f"Duplicate branch at {key}") group[branch] = row for key, group in groups.items(): if set(group) != {"up", "down", "straight"}: raise ValueError(f"Incomplete branch triplet: {key}") ref = group["straight"] for row in group.values(): if row["controls"] != ref["controls"]: raise ValueError(f"Different controls: {key}") xy = np.asarray(row["centerline"], dtype=float) if xy.shape != (65, 2) or not np.isfinite(xy).all(): raise ValueError(f"Invalid centerline: {row['id']}") np.testing.assert_allclose(xy[-1], row["tip"], atol=1e-12) key = (args.scene, args.step) if key not in groups: parser.error("Unknown scene/step. Test scenes: " + ", ".join(sorted({k[0] for k in groups}))) group = groups[key] plt.rcParams.update({"font.family": "DejaVu Sans", "font.size": 11}) fig, (shape, branchplot) = plt.subplots(1, 2, figsize=(12, 5.6), layout="constrained") colors = {"up": "#148b87", "down": "#b16b31", "straight": "#737b85"} for name in ("up", "down", "straight"): row = group[name] xy = np.asarray(row["centerline"]) style = "--" if row["stability"] == "unstable" else "-" shape.plot(*xy.T, style, color=colors[name], lw=2.5, label=f"{name} ({row['stability']})") shape.scatter(*xy[-1], color=colors[name], s=30) sweep = sorted((r for r in rows if r["scene_id"] == args.scene and r["branch"] == name), key=lambda r: r["step"]) branchplot.plot([r["controls"]["fx"] / r["controls"]["chi"] for r in sweep], [r["tip"][1] for r in sweep], color=colors[name], linestyle=style, lw=2, label=name) control = group["straight"]["controls"] selected = control["fx"] / control["chi"] branchplot.axvline(selected, color="#adb5bd", ls=":", label="selected load") shape.set(title="Same controls, three equilibria", xlabel="x / L", ylabel="y / L") shape.set_aspect("equal", adjustable="box") shape.legend(loc="best", fontsize=9) branchplot.set(title="Stored equilibrium branches", xlabel="End force p / chi", ylabel="Tip y / L") branchplot.text(selected + .04, .02, "selected load", fontsize=9, rotation=90, color="#626970", va="bottom") for ax in (shape, branchplot): ax.grid(alpha=.15) ax.spines[["top", "right"]].set_visible(False) fig.suptitle(f"AgentFEM | {args.scene} | sample {args.step}", fontweight="bold") fig.supxlabel("Quasi-static angle-FE data. Dashed straight branch is unstable; not a motion trajectory.", fontsize=10) args.output.parent.mkdir(parents=True, exist_ok=True) fig.savefig(args.output, dpi=180) plt.close(fig) print(json.dumps({"validated_triplets": len(groups), "scene": args.scene, "step": args.step, "controls": control, "branches": {name: {k: row[k] for k in ("id", "tip", "stability", "lambda_min_over_chi", "residual")} for name, row in group.items()}, "output": str(args.output)}, indent=2))
if __name__ == "__main__": main()README.md+28
compare_branches.pyAdded+106
rod-branches.pngAdded

Large File Pointer Details
- SHA256: 8a5101d5af4c9ddf56de30776d631d04afe84ad5aa1d6116722d4ff10f310483
- Pointer size: 131 Bytes
- Size of remote file: 125 kB