1"""Write solutions/<challenge>/hermite-fem.json from the <tag>.meta.json files the solver leaves beside its wavs.
2Usage: python make_submission.py <challenge-id> <submission-id> <tag-in-order-of-increasing-accuracy> ..."""
3import json
4import sys
5from pathlib import Path
7ROOT = Path(__file__).resolve().parents[2]
8DESCRIPTIONS = {
9 "hermite-fem": "Displacement-based finite elements on a Cartesian grid masked to the annulus: bicubic Hermite (Bogner-Fox-Schmit) elements for u, v and w, lumped mass, explicit leapfrog at the in-plane stability limit, Hertz sticks as point masses stepped with the shell, Rayleigh integral accumulated at the retarded times, rigid motion held by the rigid reaction and projection. Chain ordered by grid spacing (8 mm, 5 mm).",
10 "hermite-modal": "The same finite element system as hermite-fem, solved in its eigenmodes below a cutoff frequency: exact propagation of the damped linear part, the nonlinear force evaluated at the Gauss points of the mesh and projected on the modes, Hertz sticks, Rayleigh integral by a retarded weight table. The rigid fields are excluded from the basis. Chain ordered by grid spacing, cutoff and step.",
11}
12cid = sys.argv[1]
13sid = sys.argv[2]
14tags = sys.argv[3:]
15out_dir = ROOT / "solutions" / cid / sid
16sols = []
17for k, tag in enumerate(tags):
18 m = json.load(open(out_dir / f"{tag}.meta.json"))
19 m.pop("peak_si", None)
20 sticks = m.pop("sticks", None)
21 m["notes"] = (f"Sticks: impulse {sticks['impulse_Ns']} N s, contact {sticks['contact_ms']} ms, peak force {sticks['peak_force_N']} N, "
22 f"rebound {sticks['rebound_mps']} m/s (bell, mid, rim)." if sticks else "")
23 m["more_accurate_than"] = tags[:k]
24 if "output" in m:
25 m["output"] = f"{sid}/{Path(m['output']).name}"
26 if "fields" in m:
27 m["fields"]["path"] = f"{sid}/{Path(m['fields']['path']).name}"
28 sols.append(m)
29sub = {
30 "schema_version": 1,
31 "submission_id": sid,
32 "challenge_id": cid,
33 "submitter": {"name": "Jeremy Magland", "url": "https://vault1.magland.org/challenges/cymbal2-solutions"},
34 "date": "2026-09-18",
35 "description": DESCRIPTIONS[sid],
36 "code_url": "https://vault1.magland.org/challenges/cymbal2-solutions/tree/main/solvers/hermite-fem",
37 "viz_url": "https://vault1.magland.org/challenges/cymbal2-solutions/site/",
38 "solutions": sols,
39}
40with open(ROOT / "solutions" / cid / "hermite-fem.json", "w") as fh:
41 json.dump(sub, fh, indent=1)
42print(ROOT / "solutions" / cid / "hermite-fem.json")