"""Compare three candidate origami bodies driven by a 100 mm SMA wire (4 % strain). A accordion (pleated) bellows, wire along the axis B lambda / omega lever body with a split front leg (two muscles -> steering) C waterbomb tessellation strip (unit of Onal et al.'s worm), wire along the axis """ import json, os import numpy as np import matplotlib; matplotlib.use("Agg") import matplotlib.pyplot as plt from mpl_toolkits.mplot3d.art3d import Poly3DCollection import origami as og HERE = os.path.dirname(__file__); FIG = os.path.join(HERE, "..", "..", "docs", "figures") K_WIRE = 5.0 # N/mm, 0.10 mm NiTi, 100 mm long (EA/L, austenite) STRAIN = 0.04 KC = dict(low=0.05, mid=0.2, high=0.5) # crease stiffness, N.mm/rad per mm of crease BIAS_N, PULL_N = 0.56, 1.40 # 0.10 mm Flexinol: needed return force, max pull out = {} # ------------------------------------------------------------------ A accordion def accordion(kc, n=8, p=15.0, alpha=np.radians(35), w=40.0): prof = [(k * p * np.cos(alpha), (k % 2) * p * np.sin(alpha)) for k in range(n + 1)] ys = [0, w / 2, w] X, tris, idx = og.strip_mesh(prof, ys) row = {v: r for (r, c), v in idx.items()} def hk(i, j, l): if row[i] == row[j] and 0 < row[i] < n: return kc * l return og.D_PANEL * l / (p / 2) fixed = {idx[0, c]: (0, 1, 2) for c in range(3)} fixed.update({idx[n, c]: (1, 2) for c in range(3)}) m = og.Model(X, tris, hk, fixed, [(idx[0, 1], idx[n, 1], K_WIRE)]) return m, [idx[n, c] for c in range(3)] # -------------------------------------------------------------- B lambda lever def lam(kc, flange=470.0, leaf=0.0, L=100.0, a=62.5, sin_t=0.8, W=50.0, gap=6.0): """Twin lambda: two side-by-side lever bodies (left/right muscle), tied at the apex. leaf = stiffness (N.mm/rad per half) of a flat plastic leaf spring taped over the apex.""" cos_t = np.sqrt(1 - sin_t**2) ax_, az = L * sin_t, L * cos_t prof = [(ax_ - L * sin_t, 0.0), (ax_ - a * sin_t, az - a * cos_t), (ax_, az), (ax_ + a * sin_t, az - a * cos_t), (ax_ + L * sin_t, 0.0)] hw = (W - gap) / 2 X, tris, apex, feet_r, feet_f, wires, inner = [], [], set(), [], {}, [], [] for name, y0 in (("L", 0.0), ("R", hw + gap)): Xh, th, idx = og.strip_mesh(prof, [y0, y0 + hw / 2, y0 + hw]) o = len(X); X += list(map(tuple, Xh)); tris += [tuple(v + o for v in t) for t in th] apex |= {idx[2, c] + o for c in range(3)} feet_r += [idx[0, c] + o for c in range(3)] feet_f[name] = [idx[4, c] + o for c in range(3)] wires.append((idx[1, 1] + o, idx[3, 1] + o, K_WIRE)) inner.append(idx[2, 2 if name == "L" else 0] + o) wires.append((inner[0], inner[1], 50.0)) # paper bridge tying the two apexes X = np.array(X) def hk(i, j, l): if i in apex and j in apex: return kc * l + leaf * l / hw return og.D_PANEL * l / 50.0 * flange fixed = {n: (0, 1, 2) for n in feet_r} for name in "LR": fixed.update({n: (2,) for n in feet_f[name]}) m = og.Model(X, tris, hk, fixed, wires) if leaf: # leaf spring is flat when relaxed for h, (i, j, _, _) in enumerate(m.H): if i in apex and j in apex: l = np.linalg.norm(X[j] - X[i]) m.phi0[h] *= kc * l / (kc * l + leaf * l / hw) return m, feet_f["L"], feet_f["R"] # -------------------------------------------------------------- C waterbomb def waterbomb_pattern(s=20.0, nc=3, nr=4): P, tris, creases = {}, [], {} def node(x, y): return P.setdefault((round(x, 6), round(y, 6)), len(P)) Wd = nc * s for r in range(nr): off = -s / 2 if r % 2 else 0.0 for c in range(nc + (r % 2)): x0, y0 = off + c * s, r * s c0 = (x0 + s / 2, y0 + s / 2) bl, br, tl, tr = (x0, y0), (x0 + s, y0), (x0, y0 + s), (x0 + s, y0 + s) bm, tm = (x0 + s / 2, y0), (x0 + s / 2, y0 + s) for t in ((bl, tl, c0), (br, tr, c0), (bl, bm, c0), (bm, br, c0), (tl, tm, c0), (tm, tr, c0)): if 0 < np.mean([q[0] for q in t]) < Wd: tris.append(tuple(node(*q) for q in t)) for p_, q_, a in ((bl, c0, "M"), (br, c0, "M"), (tl, c0, "M"), (tr, c0, "M"), (bm, c0, "V"), (tm, c0, "V"), (bl, tl, "M"), (br, tr, "M")): if all(0 <= q[0] <= Wd for q in (p_, q_)) and not (p_[0] == q_[0] and p_[0] in (0, Wd)): i, j = node(*p_), node(*q_) creases[(min(i, j), max(i, j))] = a V = np.array(sorted(P, key=P.get)) return V, tris, creases def waterbomb(kc, fold=1.0): V, tris, creases = waterbomb_pattern() rng = np.random.default_rng(1) X = np.c_[V, 0.3 * rng.standard_normal(len(V))] find = lambda x, y: int(np.argmin(np.hypot(V[:, 0] - x, V[:, 1] - y))) a, b, c = find(30, 0), find(30, 80), find(0, 40) fixed = {a: (0, 1, 2), b: (0, 2), c: (2,)} hk = lambda i, j, l: (kc * l if (i, j) in creases else og.D_PANEL * l / 10.0) m = og.Model(X, tris, hk, fixed, [(a, b, K_WIRE)]) sign = np.array([{"M": -1.0, "V": 1.0}.get(creases.get((i, j)), 0.0) for i, j, _, _ in m.H]) Xc = X for f in np.linspace(0.1, fold, 10): # fold gradually from flat m.phi0 = sign * f Xc, _ = m.solve([0.0], Xc) m.reset_rest(Xc) return m, (a, b), V, creases def draw(ax, m, X0, X1, title, wires=True): for X, fc, al in ((X0, "#bbbbbb", 0.25), (X1, "#e9c46a", 0.9)): ax.add_collection3d(Poly3DCollection([X[list(t)] for t in m.tris], facecolor=fc, edgecolor="k", linewidths=0.4, alpha=al)) if wires: for i, j, k in m.wires: if k > 10: continue ax.plot(*np.c_[X1[i], X1[j]], color="red", lw=2) lim = np.r_[X0, X1]; c = lim.mean(0); r = np.ptp(lim, axis=0).max() / 2 * 0.62 ax.set(xlim=(c[0] - r, c[0] + r), ylim=(c[1] - r, c[1] + r), zlim=(c[2] - r, c[2] + r), title=title) ax.set_axis_off(); ax.view_init(22, -60) fig = plt.figure(figsize=(15, 9)) eps = np.linspace(0, STRAIN, 9) # A m, endn = accordion(KC["mid"]) X1, T = m.solve([STRAIN]) strokeA = -(X1[endn, 0] - m.X0[endn, 0]).mean() TA = {k: accordion(v)[0].solve([STRAIN])[1][0] for k, v in KC.items()} out["A accordion"] = dict(stroke_mm=round(strokeA, 2), amplification=round(strokeA / 4.0, 2), return_force_N={k: round(v, 3) for k, v in TA.items()}, body_len_mm=round(np.ptp(m.X0[:, 0]), 1)) draw(fig.add_subplot(2, 3, 1, projection="3d"), m, m.X0, X1, "A accordion bellows") curveA = [-(accordion(KC["mid"])[0].solve([e])[0][endn, 0] - m.X0[endn, 0]).mean() for e in eps] # B LEAF = 20.0 # N.mm/rad, 10 x 0.5 mm PET strip m, fl, fr = lam(KC["mid"]) X1, T = m.solve([STRAIN, STRAIN, 0]) strokeB = -(X1[fl + fr, 0] - m.X0[fl + fr, 0]).mean() TB = {k: lam(v)[0].solve([STRAIN, STRAIN, 0])[1][0] for k, v in KC.items()} ml, fl, fr = lam(KC["mid"], leaf=LEAF) # with the bias leaf spring T0 = ml.solve([0, 0, 0])[1][0] Xl, Tl = ml.solve([STRAIN, STRAIN, 0]) strokeB_leaf = -(Xl[fl + fr, 0] - ml.X0[fl + fr, 0]).mean() Xs, _ = ml.solve([STRAIN, 0.0, 0]) # steer: left muscle only dl = -(Xs[fl, 0] - ml.X0[fl, 0]).mean(); dr = -(Xs[fr, 0] - ml.X0[fr, 0]).mean() mf, fl2, fr2 = lam(KC["mid"], flange=1.0, leaf=LEAF) # no stiffening flanges Xf, _ = mf.solve([STRAIN, STRAIN, 0]) strokeB_flat = -(Xf[fl2 + fr2, 0] - mf.X0[fl2 + fr2, 0]).mean() out["B lambda lever"] = dict(stroke_mm=round(strokeB, 2), amplification=round(strokeB / 4.0, 2), return_force_N={k: round(v, 3) for k, v in TB.items()}, with_leaf_spring=dict(leaf_Nmm_per_rad=LEAF, wire_preload_N=round(T0, 2), wire_force_at_4pct_N=round(Tl[0], 2), stroke_mm=round(strokeB_leaf, 2), stroke_without_flanges_mm=round(strokeB_flat, 2)), steer_left_only_mm=dict(left_foot=round(dl, 2), right_foot=round(dr, 2)), body_len_mm=round(np.ptp(m.X0[:, 0]), 1), apex_rise_mm=round((X1[:, 2].max() - m.X0[:, 2].max()), 2)) draw(fig.add_subplot(2, 3, 2, projection="3d"), ml, ml.X0, Xl, "B twin lambda lever (two muscles)") curveB = [-(ml.solve([e, e, 0])[0][fl + fr, 0] - ml.X0[fl + fr, 0]).mean() for e in eps] curveB = [c - curveB[0] for c in curveB] draw(fig.add_subplot(2, 3, 4, projection="3d"), ml, ml.X0, Xs, "B steering: left muscle only") # C m, (a, b), V, creases = waterbomb(KC["mid"]) X1, T = m.solve([STRAIN]) gap = lambda X: np.linalg.norm(X[b] - X[a]) strokeC = gap(m.X0) - gap(X1) TC = {} for k, v in KC.items(): mm, _, _, _ = waterbomb(v); TC[k] = mm.solve([STRAIN])[1][0] rep = og.flat_foldability(V, [(i, j, s) for (i, j), s in creases.items()]) out["C waterbomb"] = dict(stroke_mm=round(strokeC, 2), amplification=round(strokeC / (STRAIN * gap(m.X0)), 2), wire_len_mm=round(gap(m.X0), 1), return_force_N={k: round(v, 3) for k, v in TC.items()}, width_change_mm=round(np.ptp(X1[:, 0]) - np.ptp(m.X0[:, 0]), 2), interior_vertices=len(rep), maekawa_ok=all(r["maekawa"] for r in rep), kawasaki_ok=all(r["kawasaki"] for r in rep), crease_count=len(creases)) draw(fig.add_subplot(2, 3, 3, projection="3d"), m, m.X0, X1, "C waterbomb strip") curveC = [gap(m.X0) - gap(m.solve([e])[0]) for e in eps] ax = fig.add_subplot(2, 3, 5) ax.plot(eps * 100, curveA, "o-", label="A accordion"); ax.plot(eps * 100, curveB, "s-", label="B lambda lever") ax.plot(eps * 100, curveC, "^-", label="C waterbomb"); ax.plot(eps * 100, eps * 100, "k:", label="wire contraction (100 mm wire)") ax.set(xlabel="SMA strain (%)", ylabel="foot / end stroke (mm)", title="Stroke delivered to the feet"); ax.grid(alpha=.3); ax.legend(fontsize=8) ax = fig.add_subplot(2, 3, 6) x = np.arange(3); wd = 0.25 for n, (k, col) in enumerate(zip(KC, ("#9ecae1", "#4292c6", "#084594"))): ax.bar(x + (n - 1) * wd, [TA[k], TB[k], TC[k]], wd, color=col, label=f"crease k = {KC[k]} N/rad") ax.bar([1 + 2 * wd], [Tl[0]], wd, color="#f4a261", label="B + PET leaf spring") ax.axhline(BIAS_N, color="r", ls="--"); ax.text(1.45, BIAS_N * 1.12, "needed to reset 0.10 mm wire: 0.56 N", color="r", fontsize=8) ax.set_ylim(2e-3, 3) ax.set_yscale("log"); ax.set_xticks(x); ax.set_xticklabels(["A", "B", "C"]) ax.set(ylabel="return force on the wire at 4 % (N)", title="Can paper creases alone reset the muscle?"); ax.legend(fontsize=7, loc="lower left") fig.tight_layout(); fig.savefig(os.path.join(FIG, "sim_origami_compare.png"), dpi=150) print(json.dumps(out, indent=1)) json.dump(out, open(os.path.join(HERE, "results_origami.json"), "w"), indent=1)