Skip to content

jmlane8/lightning

Repository files navigation

The following README was generated by ChatGPT 4o.

Thunder Propagation in a Standard Atmosphere

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.

Overview

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.

Atmospheric Model

The base atmospheric data is structured as:

(height (m), pressure (Pa), temperatureC), 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)
]

Key Equations

1. Density of Humid Air

The air density is computed using:

$$ \rho = \frac{(p_d \cdot M_d) + (p_v \cdot M_v)}{R \cdot T} $$

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

2. Speed of Sound

For a given pressure and density:

$$ c = \sqrt{\kappa \cdot \frac{p}{\rho}} $$

Where:

  • ( \kappa = 1.402 ): adiabatic index
  • ( p ): pressure
  • ( \rho ): density

3. Snell's Law for Refraction

To compute refraction angle across layers:

$$ \frac{\sin(\theta_1)}{v_1} = \frac{\sin(\theta_2)}{v_2} \quad \Rightarrow \quad \theta_2 = \arcsin\left(\frac{v_2}{v_1} \cdot \sin(\theta_1)\right) $$

Where:

  • ( \theta_1 ): incident angle
  • ( \theta_2 ): refracted angle
  • ( v_1, v_2 ): speeds of sound in the respective layers

How It Works

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

Output

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.py

The resulting image will be saved as:

thunder_propagation.png

Requirements

  • Python 3
  • matplotlib

Install dependencies:

pip install matplotlib

About

Plot propagation of thunder through standard atmosphere

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages