90 likes | 223 Views
Numerical Integration. non-idealized loading functions variable parameters multi-segment systems non-linear kinetics. CE5504 – Surface Water Quality Modeling. The Euler Method. CE5504 – Surface Water Quality Modeling. The Effect of Step Size. (Spain 1982, Figure 5.1).
E N D
Numerical Integration • non-idealized loading functions • variable parameters • multi-segment systems • non-linear kinetics CE5504 – Surface Water Quality Modeling
The Euler Method CE5504 – Surface Water Quality Modeling
The Effect of Step Size (Spain 1982, Figure 5.1) CE5504 – Surface Water Quality Modeling
Code CE5504 – Surface Water Quality Modeling
Code (continued) CE5504 – Surface Water Quality Modeling
Code (continued) CE5504 – Surface Water Quality Modeling
Advanced Numerical Techniques The Heun’s Method For i = 0 To tmax For j = 1 To 1 / dt k1 = mu * x X1 = x + dt * k1 k2 = mu * X1 x = x + (k1 + k2) / 2 * dt Next j Next i CE5504 – Surface Water Quality Modeling
Advanced Numerical Techniques The 4th Order Runge Kutta Method For i = 0 To tmax For j = 1 To 1 / dt k1 = mu * x X1 = x + 0.5 * dt * k1 k2 = mu * X1 X2 = x + 0.5 * dt * k2 k3 = mu * X2 X3 = x + dt * k3 k4 = mu * X3 x = x + (k1 + 2 * k2 + 2 * k3 + k4) / 6 * dt Next j Next i CE5504 – Surface Water Quality Modeling
Advanced Numerical Techniques Error Comparison Error (%)for various values of dt at t = 5 days dt Euler Heun 4th RK 1 98.90 85.81 23.70 0.5 95.35 56.70 3.60 0.1 58.68 5.58 0.01 0.01 9.40 0.07 0.001 0.99 0.001 0.0001 0.10 0.00001 0.02 0.000001 0.001 Error criterion:<=0.01 % CE5504 – Surface Water Quality Modeling