More PDEs: Realistic Waves on Strings Include Friction & Gravity Rubin H Landau Sally Haerer, Producer-Director Based on A Survey of Computational Physics by Landau, Páez, & Bordeianu with Support from the National Science Foundation Course: Computational Physics II 1 / 1
Numerical Solution of Wave Equations Many PDE Wave Equations y ( x , t ) First standard “wave equation”, then beyond texts Again t-stepping, leapfrog algorithm Also quantum wave packets (complex), E&M vector Also CFD: dispersion, shocks, solitons 2 / 1
Theory: Hyperbolic Wave Equation y(x,t) x L Recall standing & travel wave demo (do!) L = length, fastened at ends ρ = density = mass/length = constant T = tension = constant = high, no g sag No friction y ( x , t ) = small vertical displacement (1D) 3 / 1
Derive Hyperbolic (Linear) Wave Equation ∆ y(x,t) θ x L ∆ Isolate section ∆ x Small y L Restoring force = ∆ T y Small slope ∂ y ∂ x � c = T /ρ � = string velocity sin θ ≃ tan θ = ∂ y ∂ x = ∂ y /∂ t F y = ρ ∆ x ∂ 2 y � ( F = ma ) (1) ∂ t 2 ≃ T ∂ 2 y � � F y = T sin θ x +∆ x − T sin θ x = T ∂ y − T ∂ y � � � ∂ x 2 ∆ x (2) � � ∂ x ∂ x � � x +∆ x x ∂ 2 y ( x , t ) ∂ 2 y ( x , t ) = 1 (3) ⇒ ∂ x 2 c 2 ∂ t 2 4 / 1
Boundary & Initial Conditions on Solution ∂ 2 y ( x , t ) ∂ 2 y ( x , t ) = 1 (1) ∂ x 2 c 2 ∂ t 2 PDE: two independent variables x and t Initial condition = triangular “pluck”: � 1 . 25 x / L , x ≤ 0 . 8 L , y ( x , t = 0 ) = (2) ( 5 − 5 x / L ) , x > 0 . 8 L , 2 nd O ( t ) ⇒ need 2 nd IC Released from rest: ∂ y ∂ t ( x , t = 0 ) = 0 , (initial condition 2) (3) Boundary conditions for all times y ( 0 , t ) ≡ 0 , y ( L , t ) ≡ 0 (4) 5 / 1
Normal-Mode Solution (Analytic But ∞ ) Assume y ( x , t ) = X ( x ) T ( t ) 1 i) Substitute, ii) ÷ y , iii) iff: 2 d 2 T ( t ) d 2 X ( x ) = ω + ω 2 T ( t ) = 0 , + k 2 X ( x ) = 0 , def k (1) dt 2 dt 2 c Determine ω & k via BC 3 k n = π ( n + 1 ) ⇒ X n ( x ) = A n sin k n x , , n = 0 , 1 , . . . (2) L T n ( t ) = C n sin ω n t + D n cos ω n t (3) Zero velocity IC2 ⇒ C n = 0; linear superposition 4 ∞ � y ( x , t ) = B n sin nk 0 x cos ω n t (4) n B m = 6 . 25 sin ( 0 . 8 m π ) / m 2 π 2 (5) 6 / 1
Algorithm: Discretized Wave Equation X Solve on space-time grid: ( x , t ) = ( i ∆ x , j ∆ t ) BC: vertical white dots i, j-1 t i-1, j i, j i+1, j IC: top row white dots i, j+1 Can’t relax Central-difference derivatives ∂ 2 y ∂ 2 y ∂ t 2 ≃ y i , j + 1 + y i , j − 1 − 2 y i , j ∂ x 2 ≃ y i + 1 , j + y i − 1 , j − 2 y i , j , (1) (∆ t ) 2 (∆ x ) 2 Discretized (difference) wave equation: y i , j + 1 + y i , j − 1 − 2 y i , j = y i + 1 , j + y i − 1 , j − 2 y i , j (2) c 2 (∆ t ) 2 (∆ x ) 2 7 / 1
Wave Equation Algorithm: Time-Stepping y i , j + 1 + y i , j − 1 − 2 y i , j = y i + 1 , j + y i − 1 , j − 2 y i , j (1) c 2 (∆ t ) 2 (∆ x ) 2 X NB: only 3 times enter i, j-1 (j+1, j, j-1) = (future, present, past) t i-1, j i, j i+1, j i, j+1 Predict future: y i , j + 1 = 2 y i , j − y i , j − 1 + c 2 c ′ 2 [ y i + 1 , j + y i − 1 , j − 2 y i , j ] (2) c ′ def = ∆ x / ∆ t c ′ c determines stability 8 / 1
Discussion: Time Stepping Algorithm Generalities Leapfrog vs relaxation X Store only 3 time values Very small ∆ t for high precision i, j-1 Starting requires t < 0 t i-1, j i, j i+1, j i, j+1 “At rest” IC + CD: ∂ y ∂ t ( x , 0 ) ≃ y ( x , ∆ t ) − y ( x , − ∆ t ) = 0 2 ∆ t ⇒ y i , 0 = y i , 2 9 / 1
von Neumann (Courant) Stability Condition y i , j + 1 + y i , j − 1 − 2 y i , j = y i + 1 , j + y i − 1 , j − 2 y i , j (1) c 2 (∆ t ) 2 (∆ x ) 2 General Truth: Can’t pick arbitrary ∆ x , ∆ t Substitute into (1) y m , j = ξ j exp ( ikm ∆ x ) Avoid exponential growth in time | ξ | > 1 (unstable) True generally for transport equations (Press): c ≤ c ′ = ∆ x (Courant condition) (2) ∆ t Better: smaller ∆ t ; worse smaller ∆ x (1) = symmetric, yet IC, BC � = symmetric 10 / 1
Non Computational Exercises Suggest an algorithm to solve wave equation in 1 step. 1 How much memory is required? 1 How does this compare with the memory required for the 2 leapfrog method? Suggest an algorithm to solve the wave equation via 2 relaxation (like Laplace’s equation). What would you take as the initial guess? 1 How would you know when the procedure has converged? 2 How would you know if the solution is correct? 3 11 / 1
Wave Equation Implementation Study EqString.py , outlining the structure You will need to modify this code to add new physics. NB: L = 1 ⇒ y / L ≪ 1 not OK ( L = 1000 better) ρ = 0 . 01 kg/m, T = 40 N, ∆ = 0 . 01 cm 12 / 1
Assessment Solve wave equation 1 Make surface or animation y ( x , t ) 2 Explore ∆ x & ∆ t combos 3 Is stability condition obeyed? 4 Compare "analytic" vs numeric 5 solutions � T Estimate c via graphs, compare 6 ρ Choose IC for single normal mode: 7 ∂ y y ( x , t = 0 ) = 0 . 001 sin 2 π x , ∂ t ( x , t = 0 ) = 0 Do 2 near modes beat? 8 Interference if plucked in middle? 9 13 / 1
Recommend
More recommend