The following README was generated by ChatGPT 4o.
This Python simulation models the propagation path of thunder through a stratified atmosphere using refraction principles. It calculates how sound waves bend due to varying speeds of sound in different atmospheric layers.
The simulation:
- Uses a simplified standard atmosphere model with discrete layers.
- Calculates sound speed based on dry and saturated air densities.
- Applies Snell's Law to model sound refraction.
- Traces propagation angles and distances.
- Visualizes the paths for a range of initial angles.
The base atmospheric data is structured as:
(height (m), pressure (Pa), temperature (°C), saturation vapor pressure (Pa))Example:
std_atm = [
(0, 101325, 15, 17.1),
(1000, 89880, 8.50, 11.1),
(2000, 79500, 2.00, 7.1),
(3000, 70012, -4.49, 0),
(4000, 61660, -10.98, 0)
]The air density is computed using:
Where:
- ( p_d = ) dry air pressure ( = p - p_v )
- ( p_v = ) partial pressure of water vapor
- ( M_d = 0.0289654 ) kg/mol (molar mass of dry air)
- ( M_v = 0.018016 ) kg/mol (molar mass of water vapor)
- ( R = 287.05 ) J/(kg·K) (specific gas constant)
- ( T = ) temperature in Kelvin
For a given pressure and density:
Where:
- ( \kappa = 1.402 ): adiabatic index
- ( p ): pressure
- ( \rho ): density
To compute refraction angle across layers:
Where:
- ( \theta_1 ): incident angle
- ( \theta_2 ): refracted angle
- ( v_1, v_2 ): speeds of sound in the respective layers
The script starts from a base height (e.g., 4000 m), simulates sound paths at angles between 0° and 84° in 4° increments, and calculates the path of each ray as it traverses or reflects within layers.
A ray's path continues until it either:
- Exits the atmosphere
- Returns above the starting height after being refracted
The simulation generates and saves a plot:
- X-axis: Horizontal distance (m)
- Y-axis: Altitude (m)
- Lines: Ray paths for different initial angles
python thunder_simulation.pyThe resulting image will be saved as:
thunder_propagation.png
- Python 3
matplotlib
Install dependencies:
pip install matplotlib