/ proof-of-concept / steelsim21
Sign in
proof-of-concept / steelsim21
steelsim21 / matching / modes.py
17 lines · 615 BCodeBlameHistory
98b9eb0Matching scripts: bands-per-octave option, linear mode frequencies, partial listingJeremy Magland 1"""Mode frequencies from the stiffness written by modes.ts.
3Usage: python3 modes.py K.bin META.json [fmax]
4Prints the frequencies (Hz) of the modes below fmax, excluding the six rigid modes.
5"""
6import sys, json, numpy as np
8K = np.fromfile(sys.argv[1], dtype="<f8")
9meta = json.load(open(sys.argv[2]))
10n = meta["n"]
11K = K.reshape(n, n)
12K = 0.5 * (K + K.T)
13ev = np.linalg.eigvalsh(K)
14f = np.sqrt(np.clip(ev, 0, None)) / (2 * np.pi)
15fmax = float(sys.argv[3]) if len(sys.argv) > 3 else 1500
16modes = f[(f > 5) & (f < fmax)]
17print(json.dumps({"params": meta["params"], "modes": [round(float(v), 1) for v in modes]}))
↑↓ move↵openescclose