# Exercise 2: a recharging chamber, and a stronger roof K = 8000.0 # MPa per unit fractional volume change (rough value, check) CHAMBER = 10.0 # km3 def years_to_eruption(strength, inject_per_year): over = 0.0 for yr in range(1, 1000): over += K * inject_per_year / CHAMBER if over >= strength: return yr, over return None, over for strength in (10, 20): for rate in (0.001, 0.002): yr, over = years_to_eruption(strength, rate) print(f"roof {strength} MPa, {rate} km3/yr -> erupts in year {yr} (overpressure {over:.1f} MPa)") # roof 10 MPa, 0.001 km3/yr -> erupts in year 13 (overpressure 10.4 MPa) # roof 10 MPa, 0.002 km3/yr -> erupts in year 7 (overpressure 11.2 MPa) # roof 20 MPa, 0.001 km3/yr -> erupts in year 25 (overpressure 20.0 MPa) # roof 20 MPa, 0.002 km3/yr -> erupts in year 13 (overpressure 20.8 MPa) # Doubling the roof strength or halving the supply rate roughly doubles the # waiting time. A strong roof lets more pressure build up, so when it finally # fails the eruption tends to be bigger.