Skip to main content

sva_formula/modal/
string.rs

1// Concern: a stiff string's inharmonic eigenfrequencies and per-mode decay | Non-concern: the excitation multiplying them (mod.rs) | IO: (StringGeom, count) -> Vec<Mode>
2
3use crate::closed_form::Mode;
4use crate::modal::damping::Damping;
5use crate::modal::mode;
6
7pub struct StringGeom {
8    pub f0: f64,
9    pub inharmonicity: f64,
10    pub strike: f64,
11    pub damping: Damping,
12}
13
14/// Fletcher & Rossing 2e, sec. 2.18, after Fletcher, JASA 36 (1964) 203.
15pub fn inharmonicity(young: f64, diameter: f64, tension: f64, length: f64) -> f64 {
16    std::f64::consts::PI.powi(3) * young * diameter.powi(4) / (64.0 * tension * length * length)
17}
18
19/// The struck-string amplitude is Fletcher & Rossing 2e, sec. 2.6.
20pub fn modes(g: &StringGeom, count: usize) -> Vec<Mode> {
21    (1..=count)
22        .map(|n| {
23            let n = n as f64;
24            let hz = n * g.f0 * (1.0 + g.inharmonicity * n * n).sqrt();
25            let amp = (n * std::f64::consts::PI * g.strike).sin() / (n * n);
26            mode(hz, amp, g.damping)
27        })
28        .collect()
29}