/ proof-of-concept / bead-percussion
Sign in
proof-of-concept / bead-percussion
bead-percussion / tests / twin.ts
18 lines · 1.1 KBCodeBlameHistory
ac09b0fDefault damping: every mode falls 60 dB in 2.5 s; examples at 2.5 s; twin separation relative to recent displacement; stronger chaos strikeJeremy Magland 1// Twin separation summary. Usage: tsx tests/twin.ts script.m duration [eps]
95f2216Minimal chaos example and perturbed-twin chaos test with separation plot and growth-rate fitJeremy Magland 2import { readFileSync, readdirSync } from "fs";
3import { runScript } from "../src/sim/runScript";
4import { simulate } from "../src/sim/solver";
6import { growthRate } from "../src/sim/analysis";
95f2216Minimal chaos example and perturbed-twin chaos test with separation plot and growth-rate fitJeremy Magland 7const helpers = readdirSync("matlab/helpers").map(name => ({ name, source: readFileSync("matlab/helpers/" + name, "utf8") }));
ac09b0fDefault damping: every mode falls 60 dB in 2.5 s; examples at 2.5 s; twin separation relative to recent displacement; stronger chaos strikeJeremy Magland 8const { sys } = runScript(readFileSync(process.argv[2], "utf8"), helpers, () => {});
10const eps = Number(process.argv[4] ?? 1e-9);
12const a = simulate(sys, { onFrame: (_f, _t, x) => saved.push(x.slice()) });
13const { sep } = runTwin(sys, saved, a.dt, eps);
15const step = Math.max(1, Math.floor(sep.length / 14));
16for (let i = 0; i < sep.length; i += step) out.push(`${a.frameTimes[i].toFixed(2)}:${Math.log10(sep[i] + 1e-30).toFixed(1)}`);
18console.log(`rate ${g?.toFixed(0) ?? "-"} drift ${a.energyDrift.toExponential(1)} | log10 sep: ${out.join(" ")}`);
↑↓ move↵openescclose