"""The linear model on a 16 inch crash: modes, decay times, a strike, a WAV file and a few plots.""" import matplotlib.pyplot as plt import cymsim from cymsim import plot plate = cymsim.presets.crash_16().evaluate(spacing=0.008) print(plate.summary()) modes = cymsim.compute_modes(plate, fmax=16000) print(f"{modes.count} modes in {modes.seconds:.1f} s") print(modes.table(12)) strike = cymsim.Strike(x=0.9, y=0.5, velocity=3.0) listener = cymsim.Listener(distance=0.5, angle=30) sound = cymsim.synthesize(modes, strike, listener, duration=4.0, movie=True) print(sound, f"peak force {sound.info['peak_force']:.0f} N, contact {sound.info['contact_time'] * 1e3:.2f} ms") sound.to_wav("crash_linear.wav") fig, axes = plt.subplots(2, 2, figsize=(12, 9)) plot.plate(plate, ax=axes[0, 0], strike=strike, listener=listener) plot.mode(modes, 5, ax=axes[0, 1]) plot.spectrogram(sound, ax=axes[1, 0], modes=modes, fmax=16000) plot.decay_times(modes, ax=axes[1, 1]) fig.tight_layout() fig.savefig("crash_linear.png", dpi=120) print("wrote crash_linear.wav and crash_linear.png")