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):
"""Calculates semi-major axis using Kepler's Third Law."""
period_secs = period_yrs * secs_in_year
kepler_const = 4 * math.pi**2 / (G * m_sun)
return math.pow(period_secs**2 / kepler_const, 1/3)
# 2. Constants & Data
G = 6.674e-11
secs_in_year = 365.25 * 24 * 60 * 60
m_sun = 1.989e30
m_moon = 7.342e22
dia_moon = 3.474e06
dwarfs = {
# Name: (diameter_%_moon, mass_%_moon, orbit_period_yrs)
"Ceres": (27, 1.3, 4.6),
"Pluto": (66, 17.8, 248),
"Haumea": (36, 5.5, 283),
"Makemake": (46, 5.4, 310),
"Eris": (67, 22.7, 557)
}
# 3. Conversions and Calculations
# Convert relative moon data to absolute SI units
dwarfs_actual = {
name: (
(dia_moon / 2) * (d_pct / 100), # Radius (m)
m_moon * (m_pct / 100), # Mass (kg)
p # Period (yrs)
) for name, (d_pct, m_pct, p) in dwarfs.items()
}
# Calculate Volume, Mass, Actual Density, and Orbital Distance
dwarfs_calc = {
name: (
vol_sphere(rad),
m,
m / vol_sphere(rad),
orbit(tp)
) for name, (rad, m, tp) in dwarfs_actual.items()
}
# 4. Output Physical Data
print(f"{'Name':<10} | {'Density':>8} | {'Distance (AU)':>12}")
print("-" * 40)
for dwarf, (vol, m, d, a) in dwarfs_calc.items():
# Convert meters to Astronomical Units (AU) for readability
dist_au = a / 1.496e11
print(f"{dwarf:<10} | {d:>6.0f} kg/m³ | {dist_au:>10.2f} AU")
# 5. Composition Simulation
simulation = []
print("\n--- Running Composition Simulation ---")
for rf in range(0, 101, 10):
rock_p = rf / 100
theo_den = calc_density(rock_p)
for nm, (vol, m, dens, orb) in dwarfs_calc.items():
diff = abs(dens - theo_den)
simulation.append((nm, rf, diff))
# 6. Analyze Results (Find Best Fit)
print("\n--- Most Likely Composition (Best Fit) ---")
for name in dwarfs.keys():
# Find the rock percentage with the smallest density difference
planet_data = [item for item in simulation if item[0] == name]
best_fit = min(planet_data, key=lambda x: x[2])
print(f"{name:<10}: Approximately {best_fit[1]}% Rock / {100-best_fit[1]}% Ice")
"Computational solutions for the curious mind. Exploring the intersection of Python programming and rigorous science, featuring solved problems in NASA physics, chemistry, and beyond."
Friday, 3 April 2026
Dwarf Planets
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
Subscribe to:
Post Comments (Atom)
Visualizing Particle Kinematics with Python
Understanding the relationship between position, velocity, and acceleration is fundamental to physics. However, seeing how these variables e...
-
The important source of aerosols in the stratosphere is the formation of carbonyl sulfide (COS) droplets. These droplets are more dangerou...
-
This code in python demonstrates how to calculate molecular weights, physical properties like mole fractions, partial pressure calculations ...
-
The code is based on finding volume, density and orbit radius of some dwarf planets. Further we tried to match these densities with one'...

No comments:
Post a Comment