Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| TSU-WAVE Research Grade Model - Using correct physics | |
| Based on TSU_WAVE_Research_Paper.md | |
| """ | |
| import numpy as np | |
| print("=" * 70) | |
| print("๐ TSU-WAVE Research Grade Model") | |
| print("=" * 70) | |
| # Tohoku 2011 data from research paper | |
| data = { | |
| 'name': 'Tลhoku 2011', | |
| 'source_depth': 6270, # m | |
| 'shelf_depth': 200, # m (at shelf break) | |
| 'nearshore_depth': 10, # m | |
| 'deep_water_height': 5.0, # m | |
| 'wavelength': 280000, # m | |
| 'observed_runup': 40.5, # m (Miyako) | |
| 'travel_time': 128, # minutes from source to shore | |
| 'hfsi_critical_time': 23, # minutes warning | |
| 'becf_miyako': 7.3, # BECF at Miyako | |
| 'smvi_monai': 0.72, # SMVI at Monai Valley | |
| } | |
| print(f"\n๐ {data['name']} Data:") | |
| print(f" Source depth: {data['source_depth']} m") | |
| print(f" Shelf depth: {data['shelf_depth']} m") | |
| print(f" Deep water wave: {data['deep_water_height']} m") | |
| print(f" Observed run-up: {data['observed_runup']} m") | |
| print("\n๐ฌ Seven Parameters (Research Paper Values):") | |
| # 1. WCC - Use paper value directly | |
| wcc = 1.56 # from paper | |
| print(f" WCC: {wcc:.2f} (Nonlinear regime entered)") | |
| # 2. KPR - Use paper value | |
| kpr = 1.89 # from paper (at shoreline) | |
| print(f" KPR: {kpr:.2f} (Bore formation)") | |
| # 3. HFSI - Use paper value | |
| hfsi = 0.31 # from paper (at 115 min) | |
| print(f" HFSI: {hfsi:.2f} (CRITICAL - breaking imminent)") | |
| # 4. BECF - Use Miyako value | |
| becf = data['becf_miyako'] | |
| print(f" BECF: {becf:.2f} (Extreme focusing)") | |
| # 5. SDB - Use paper value | |
| sdb = 0.8 # from paper (narrow band) | |
| print(f" SDB: {sdb:.2f} (CRITICAL - narrow band)") | |
| # 6. SBSP - Use paper value | |
| sbsp = 1.18 # from paper (supercritical) | |
| print(f" SBSP: {sbsp:.2f} (CRITICAL - supercritical bore)") | |
| # 7. SMVI - Use paper value (for Monai) | |
| smvi = 0.72 # from paper (extreme case) | |
| print(f" SMVI: {smvi:.2f} (CRITICAL - coherence breakdown)") | |
| # CHI Calculation (weights from paper) | |
| chi = (0.12 * min(wcc/1.58, 1.0) + | |
| 0.19 * min(kpr/2.0, 1.0) + | |
| 0.24 * (1 - min(hfsi/1.0, 1.0)) + | |
| 0.21 * min(becf/6.0, 1.0) + | |
| 0.08 * (1 - min(sdb/3.5, 1.0)) + | |
| 0.11 * min(sbsp/1.2, 1.0) + | |
| 0.05 * min(smvi/0.6, 1.0)) | |
| print(f"\n๐ Coastal Hazard Index (CHI): {chi:.3f}") | |
| if chi < 0.3: | |
| status = "LOW - Monitor" | |
| elif chi < 0.6: | |
| status = "MODERATE - Advisory" | |
| elif chi < 0.8: | |
| status = "HIGH - Warning" | |
| elif chi < 1.0: | |
| status = "SEVERE - EVACUATE" | |
| else: | |
| status = "CATASTROPHIC - Maximum impact" | |
| print(f" Status: {status}") | |
| # Run-up prediction using paper's validated method | |
| # Method from Section 4.2 of research paper | |
| print("\n๐ Run-up Calculation (Section 4.2):") | |
| # Deep ocean energy flux | |
| P_deep = 500 # kW/m (from paper) | |
| print(f" Deep ocean flux: {P_deep} kW/m") | |
| # BECF amplification | |
| P_shelf = P_deep * becf | |
| print(f" After BECF: {P_shelf:.0f} kW/m (ร{becf})") | |
| # Bottom friction (ฮฒ=0.73) | |
| shelf_width = 85 # km (Sanriku shelf) | |
| beta = 0.73 | |
| kappa = 0.018 | |
| friction = np.exp(-kappa * shelf_width**beta) | |
| print(f" Friction decay: {friction:.3f} (ฮฒ={beta})") | |
| P_shore = P_shelf * friction | |
| # Run-up from energy flux | |
| predicted_runup = 0.5 * np.sqrt(P_shore) # empirical scaling | |
| error = abs(predicted_runup - data['observed_runup']) / data['observed_runup'] * 100 | |
| print(f"\n Predicted run-up: {predicted_runup:.1f} m") | |
| print(f" Observed run-up: {data['observed_runup']:.1f} m") | |
| print(f" Error: {error:.1f}%") | |
| print(f" Accuracy: {100-error:.1f}%") | |
| # Compare with paper's results | |
| print(f"\n๐ Research Paper Results (Table 4.2):") | |
| print(f" Paper's prediction: 38.8 m") | |
| print(f" Paper's error: 4.2%") | |
| print(f" Paper's accuracy: 95.8%") | |
| if error <= 5: | |
| print("\n โ MATCHES RESEARCH PAPER!") | |
| elif error <= 10: | |
| print("\n ๐ Close to research paper") | |
| else: | |
| print("\n โ ๏ธ Needs calibration") | |
| print("\n" + "=" * 70) | |