Posts

Showing posts from April, 2026

Why Galaxies Don’t Fly Apart: Modeling M101 with Python

Image
In this post, I use Python to model the orbital mechanics of stars within a galaxy (using M-101 as a template). By defining a custom velocity function and using calculus to find the peak velocity point, we can visualize how star speeds change with distance and calculate the billions of years required for a single galactic orbit. Stars inside a galaxy continuously orbit to prevent falling into the center of galaxy.  The galaxy has a radius of about 90000 light years. We used numpy arrays to hold distances, speeds of stars. The data was also plotted using matplotlib.  Here is the code import numpy as np import matplotlib.pyplot as plt # Constants LY_TO_KM = 9.461e12 # More precise Light Year to KM YR_TO_SEC = 365.25 * 24 * 60 * 60 # Include leap year fraction def vel_star(x_frac): """ Models orbital speed v(x) = 350x / (1 + x^2)^(3/4) x_frac: distance in units of 10,000 ly """ return (350 * x_frac) / np.power((1 + x_frac**2), 0.75)...

Speeding Galaxies

Introduction  Universe is not a static thing. It is dynamic.  We all know galaxies are still moving away as the universe is expanding.   We took data provided by NASA for educational purposes for 7 galaxies.  It consisted of names, distances,and speeds of the galaxies.  The data was plotted on XY plot and linear regression analysis were done. Plotting was done using numpy library and matplotlib.  Coding was done in python language.  One obvious conclusion from the plots is that more distant galaxies are moving with more speed.  import numpy as np import matplotlib.pyplot as plt # 1. Constants & Data ONE_MPC_LY = 3.26 galaxies = { "NGC-5357": (0.45, 200), "NGC-3627": (0.9, 650), "NGC-5236": (0.9, 500), "NGC-4151": (1.7, 960), "NGC-4472": (2.0, 850), "NGC-4486": (2.0, 800), "NGC-4649": (2.0, 1090), } # Convert data for calculation dist_mpc = np.array([d[0] for d in galaxies.values()]) speed_kms = ...

The Chemistry and Code of Sulfur Recovery

In industrial chemistry, removing sulfur from "sour gas" (natural gas containing H_2S) is a critical safety and environmental task. One of the most elegant ways to do this is the Claus Process. Today, we’ll use Python to model this reaction, balancing the stoichiometry and calculating the physical volumes of our products. The Reaction ​We are looking at the reaction where sulfur dioxide (SO2)—often from coal burning—is neutralized by hydrogen sulfide (H2S): SO2 +H2S -> 3S + 2H2O The Python Script """ Project: The 70-Year-Old Coder Topic: Stoichiometry & Physics of the Claus Process """ # 1. Chemical Constants atwts = {"S": 32.06, "O": 15.999, "H": 1.008} stoichiometry = {"SO2": 1, "H2S": 2, "S": 3, "H2O": 2} def mol_weight(chem): return sum([v * atwts.get(c.upper()) for c, v in chem.items()]) species_data = { "SO2": {"s": 1, "o"...

The Cosmic Delivery: Did Icy Invaders Build Our Oceans?

Introduction ​For decades, scientists have looked at the vast, blue expanse of our oceans and asked one simple, profound question: Where did all this water come from? While some believe water was "baked" into the rocks of Earth during its formation, a competing theory suggests a much more violent and spectacular origin. The Comet Impact Hypothesis proposes that Earth was once a dry, rocky wasteland until it was bombarded by a relentless "cosmic delivery service"—trillions of tons of pure water-ice arriving via meteors and comet nuclei. ​But does the math actually hold up? If Earth were struck by icy bodies of varying sizes—from small 2 km "scouts" to massive 200 km "titans"—how long would it take to fill the basins of our world? In this post, we use Python to simulate the deposition rates of three distinct types of comet nuclei to see if 400 million years of bombardment is enough to create the world as we know it. ​The Hypothesis: Three Tiers of ...

Physical Properties of Planets Using python

Image
Our solar system is truly amazing. Planets have different composition and different environments. Those near the sun, for example are hotter than Earth and the ones far away are cold.  In this python code we have calculated many physical parameters using radii, mass, distance from sun, and albedo data.  The physics used is mostly classical mechanics and thermodynamics.   Parameters calculated are volumes, densities, orbital speeds, orbital periods, equilibrium temperatures and these properties were compared to Earth.  We used dictionary with names as keys, and basic parameters are tuples. All calculations were done using functions. Numpy arrays were used to make the work easier. Function argmax was used to tie the names of planet with it's properties.  Code is given below: import numpy as np """ Solar System Physical & Orbital Dynamics A comparison of planetary characteristics relative to Earth. """ # --- CONSTANTS --- G = 6.674e-11 # Universa...

The Evaporating Giant: Modeling Atmosphere Loss on HD 189733b

We are looking at HD 189733b, one of the most well-studied "Hot Jupiters". Since it orbits so close to its parent star, its atmosphere is essentially being "boiled off" by intense X-ray and UV radiation.  HD 189733b looks like a peaceful blue marble from a distance, but don't let the color fool you. Located 63 light-years away, this "Hot Jupiter" is a nightmare world where winds howl at seven times the speed of sound and the rain is made of molten glass. We used the following physics and mathematics  The Shell Method: To find the volume of just the "air" around the planet, we subtract the volume of the solid core (r - t) from the total volume (r). Density Context: The density used (50) gm/cc is a simplified estimate for the upper thermosphere where the escape happens; for comparison, Earth's sea-level density is about 1,225 g/m3. ​ The Big Picture: While 6 times 10^8 kg/sec sounds like a catastrophic amount of lost gas, your code reveals ...

The Loneliness of the Long-Distance Atom

Image
In my years as a scientist, I’ve often found that scientific notation (10^25) is too efficient—it hides the "physicality" of the universe. To truly feel the scale of the atmosphere, we need to see the zeros. ​In this post, I use a simple Python script to perform a thought experiment: If we take a massive square, 1,000 kilometers on each side, and divide it into tiny 1 cm² tiles, how many molecules would we find in each tile at different altitudes? The transition from the crowded "metropolis" of our breath to the desolate "vacuum" of the Van Allen radiation belt is a humbling reminder of how thin our veil of life really is. In my years as a scientist, I’ve often found that scientific notation (10^{25}) is too efficient—it hides the "physicality" of the universe. To truly feel the scale of the atmosphere, we need to see the zeros. ​In this post, I use a simple Python script to perform a thought experiment: If we take a massive square, 1,000 kilomet...

Tracking LADEE: The Physics of a Lunar Journey

On September 6, 2013, NASA’s Lunar Atmosphere and Dust Environment Explorer (LADEE) lit up the night sky over Virginia. While the mission was designed to study the moon’s thin atmosphere, the most intense part of its journey began at the Wallops Flight Facility. ​ Using trajectory data from the launch, we can use Python to "reverse engineer" the rocket's performance. By applying linear regression to the altitude, range, and velocity, we can see exactly how much power it takes to break free from Earth's grip. The Raw Data ​We analyzed a 20-second window starting at 190 seconds after launch. At this stage, the rocket is already roughly 150 \text{ km} high—well into the thermosphere—and moving at hypersonic speeds. ​1. Vertical Ascent: Climbing the Gravity Well ​First, we look at the Altitude vs. Time. By fitting a linear trendline to the data, we can determine the vertical component of the rocket's velocity. ​The Equation: A...

The Cosmic Tug-of-War

Image
Roche Limit is the point of no return. If a moon gets too close to its planet, the side facing the planet is pulled much harder than the side facing away. Eventually, this "stretch" (tidal force) becomes stronger than the gravity holding the moon together. ​The Math: Why the Cube Root? ​Since we live in a 3D universe, gravitational influence spreads out over a volume. When we convert that volume back into a linear distance (radius), we use the cube root. ​ Real-World Examples: ​Saturn's Rings: These are basically "failed moons" or shattered debris that live inside Saturn's Roche limit. They can never clump together to form a moon because Saturn's gravity keeps shredding them. ​The Moon: Briefly mention that the Moon is safely outside our Roche limit and is actually moving away from us at about 3.8 cm per year. Python Code: Code is based on NASA problem which calculates tidal force radii for Earth, Saturn, and Black holes. Respective targets are Moon, Pan...

Tracking the Thaw: Modeling the Antarctic Ice Cap with Python

Image
The Antarctic ice cap is one of the most critical barometers for our planet’s climate health. But when we look at 45 years of satellite data, how do we differentiate between yearly "noise" and a definitive trend? Today, we’re using Linear and Quadratic Regression to analyze ice cap area data from 1979 to 2024 and project what the horizon looks like for 2030. ​Starting in 1979, the September ice cap area sat at roughly 7.2 Million sq km. Fast forward to the 2020s, and we are frequently seeing measurements dip below 4.5 Million sq km. ​To make sense of this, we’ve written a script to calculate the "Goodness of Fit" (R^2) and project future values. import numpy as np import matplotlib.pyplot as plt plt.cla() def r_squared(actual,predicted): ss_res=np.sum((actual-predicted)**2) ss_tot=np.sum((actual-np.mean(actual))**2) return 1-(ss_res/ss_tot) def curve_fit(x,y,deg=1): return np.polyfit(x,y, deg) #antarctic ice cap in septembe4 ice_cap_area=[ ...

Carbonyl Sulphide COS

The important source of aerosols in the stratosphere is the formation of carbonyl sulfide (COS) droplets. These droplets are more dangerous than carbon dioxide.   Although volcanism injects millions of tons of SO2 into the atmosphere every few years, scientists have found that during other times, COS is by far the biggest source of sulfur compounds in the stratosphere, leading to the production of sulphuric acid aerosols.  NASA has tabulated the sources and sinks of COS. At present,  the sinks outnumber the sources.  From this table, we created a python dictionary with sources names as keys and tuples with rate and type as values. We then created lists of sources, sinks, types using comprehension. We also calculated the number of molecules of COS using avagadro number and volume of atmosphetre. For formatting we used the length of longest name.    # Constants for Atmospheric Calculations AVOGADRO = 6.023e23 # molecules/mole MOL_WT_...

Dwarf Planets

Image
The code is based on finding volume, density and orbit radius of some dwarf planets. Further we tried to match these densities with one's calculated for different mixtures of granite and ice. Based on the results following conclusions can be drawn. Eris is a "rock star"—likely over 70% of granite rock. Pluto is the "balanced" one—roughly a 50/50 split. Ceres is surprisingly light—suggesting either more ice or a lot of trapped salts and clays (brines). Here is the code import math # 1. Helper Functions def vol_sphere(r): """Calculates volume of a sphere given radius.""" return (4/3) * math.pi * r**3 def calc_density(rock_frac): """Calculates theoretical density based on rock/ice mix.""" rho_rock = 3000 # kg/m3 (Granite-like) rho_ice = 900 # kg/m3 (Water ice) return rock_frac * rho_rock + (1 - rock_frac) * rho_ice def orbit(period_yrs): """Calcul...

The Universal Geyser: Mapping Energy Across the Solar System

Image
Welcome back to the workbench! One of the most beautiful aspects of physics is its universality—the same math we use to calculate the efficiency of a hydroelectric turbine at Nevada Falls applies to the towering plumes of Enceladus.  In this session, we’re looking at the "Many Faces of Energy." We start by calculating the massive power output of Earth's falling water, then take that same energy budget to the stars. By keeping our mass and energy fixed, we can see exactly how the varying gravitational pulls of different celestial bodies dictate the height and duration of a geyser’s arc. Whether you're calculating E = mgh for a local power grid or a moon-hopping adventure, the logic remains as steady as the stars.  Summary of the Script's Logic The script operates on a few core physical principles:  Newton’s Law of Gravitation: We calculate local gravity (g) using the mass and radius of the target world:  Conservation of Energy: By setting Kinetic Energy equal to ...