# How Flight Works 4, Exercise 2: how much damping settles a disturbance? # Reuse the chapter's pitch model (stiffness 2.0) and scan the damping # value. Count how many times the nose crosses level after a 5 degree gust. # Illustrative model only, not data for a real aircraft. def crossings(stiffness, damping, steps=400, dt=0.05): angle, rate = 5.0, 0.0 history = [] for _ in range(steps): accel = -stiffness * angle - damping * rate rate += accel * dt angle += rate * dt history.append(angle) return sum(1 for a, b in zip(history, history[1:]) if a * b < 0) for damping in (0.1, 0.5, 1.0, 2.0, 3.0): print("damping", damping, "-> crossings", crossings(2.0, damping)) # Output when run: # damping 0.1 -> crossings 9 # damping 0.5 -> crossings 9 # damping 1.0 -> crossings 8 # damping 2.0 -> crossings 6 # damping 3.0 -> crossings 0 # # More damping means fewer swings before the nose settles, and by 3.0 # it does not swing at all. With very # little damping the aircraft bobs for a long time, which is tiring to fly.