Skip to content

Instantly share code, notes, and snippets.

@Vyryn
Last active October 22, 2020 15:48
Show Gist options
  • Select an option

  • Save Vyryn/9177fae2900fa944599f32283d1fd5ce to your computer and use it in GitHub Desktop.

Select an option

Save Vyryn/9177fae2900fa944599f32283d1fd5ce to your computer and use it in GitHub Desktop.
Calculates the expected emission spectra for a dyson sphere of various size.
from math import pi
"""
Licensed by Vyryn under the MIT License.
This script simplistically calculates emission temperature and peak emission wavelength for a Dyson sphere of varying
parameters.
The US energy sector is ~$350B while US GDP is ~20T
That's 1.75%, for simplicity let's say 2%.
We can perhaps scale up to a solar system economy and assume the same portion of resources spent on energy
production for a first order approximation of what that might be. I'll assume our solar system composition is
average and *no* stellar engineering/starlifting - which is likely pessimistic - but harvesting of 50% of the
system's planetary mass.
Available mass: 1.9E27 kg Jupiter, all other planets combined are another 40% on top of that, so 2.66E27 kg. 2% of
50% of that is 2.7E25 kg. A K2 would probably want to use less, but for a mature K2.7+ this seems fair.
So 2.7E25 kg is perhaps a reasonable estimate of the per-solar system energy mass budget of a ~K3 civ. Yeah,
insane sentence but hey.
We also need a thickness, we'll vary that and show results for a variety because it turns out to be the main deciding
factor.
For density, I have no clue what's resonable beyong it likely being somewhere between silicon (one of the lightest
materials with desirable properties @2.3) and tungsten (one of the densest materials with desirable properties @19.3)
"""
# Some constants
sigma = 5.670_374_419E-8
b_prop = 2.897_771_955E-3
cmb = 2.7 # Cosmic microwave background temperature, in K. this is the best possible heat sink
# Parameters you can adjust
mass_avail = 1.9E27 * 1.4 # Jupiter's mass in kg, * 1.4 for the rest of the planets
mass_fraction_exploited = 0.1 # The fraction of potentially available mass exploited by the civilization
fraction_for_energy = 0.02 # The fraction of that mass used for energy production
# thickness = 0.01 # Thickness of the Dyson sphere. (Defined below in a range as this is more or less the independent
# variable)
civ_eff = 1 # The achieved efficiency as a fraction of the thermodynamically optimal carnot efficiency
sun_radius = 696_340_000 # meters
sun_temp = 5778 # Kelvin
mass_used_for_energy = mass_avail * fraction_for_energy * mass_fraction_exploited
print(
f'With an available mass of {mass_avail}kg and {fraction_for_energy * mass_fraction_exploited * 100}% of that used '
f'for energy production, {mass_used_for_energy}kg is available.')
def volume_from_t_and_r(t, r_):
"""
Of an optimal Dyson Sphere.
"""
a = r_ + t / 2
b = r_ - t / 2
v = pi * 4 / 3 * (a ** 3 - b ** 3)
return v
def mass_from_density_and_vol(d, v):
"""
Of an optimal Dyson Sphere
"""
m = d * v
return m
def vol_from_mass_and_density(m, d):
"""
Of an optimal Dyson Sphere.
"""
v = m / d
return v
def radius_from_t_and_v(t, v):
"""
Gives the possible radius of a dyson sphere from the thickness and volume it occupies.
"""
# v/pi*3/4 = (r+t/2) ** 3 - (r-t/2) ** 3
nominator = (3 * v - pi * t ** 3) ** 0.5
denominator = 2 * (3 * pi) ** 0.5 * t ** 0.5
return nominator / denominator
def g_cm_3_to_kg_m_3(density):
return density * 1000
def meters_to_au(dist):
return dist * 6.685E-12
def au_to_meters(dist):
return dist / 6.685E-12
def radius_from_mass_density_and_thickness(m, d, t, au=False):
"""
The name is pretty self-explanatory.
"""
v = vol_from_mass_and_density(m, g_cm_3_to_kg_m_3(d))
radius = radius_from_t_and_v(t, v)
if au:
return meters_to_au(radius)
return radius
def carnot(h, c=cmb, eff=civ_eff):
"""
The theoretically achievable heat pump efficiency with the given hot and cold temperatures. eff is assumed to be
1 by default but could be less, you can set that above.
"""
if c < cmb:
c = cmb
if h > c:
return (1 - c / h) * eff
else:
return (1 - h / c) * eff
def round_(val, places):
"""
A helper method that rounds to the specified number of places after the decimal point.
"""
return round(val * 10 ** places) / 10 ** places
def best_radiative_eff(radius, temp, cmb_=cmb):
"""
The ideal radiator at distance radius from the sun and solar temperature temp.
"""
sa = 4 * pi * radius ** 2
waste_t = (temp ** 4 / sa * 1/civ_eff) ** (1 / 4)
if waste_t > temp:
return temp
if waste_t < cmb_:
return cmb_
return waste_t
def t_at_dist_and_lum(d_, au=True):
"""
Temperature at distance and luminosity. AU is whether the units are in AU (default) or m (SI).
"""
if au:
d_ = au_to_meters(d_)
t = sun_temp * (sun_radius/2*d_) ** 0.5
# t = (luminosity_ / (16 * pi * sigma * d_ ** 2)) ** (1 / 4)
return t
def peak_black_body_wavelength(temp_):
"""
The peak emission wavelength at the given black body temperature.
"""
lambda_peak = b_prop / temp_
return lambda_peak * 10**9 # nm
def spectra(wavelength):
"""
Converts a wavelength in nanometers to a spectrum name.
"""
if wavelength > 1E8:
return 'Radio'
elif wavelength > 1E6:
return 'Microwave'
elif wavelength > 10_000:
return 'Far IR'
elif wavelength > 2_500:
return 'Mid IR'
elif wavelength > 750:
return 'Near IR'
elif wavelength > 380:
return 'Visible'
elif wavelength > 315:
return 'UV-A'
elif wavelength > 280:
return 'UV-B'
elif wavelength > 100:
return 'UV-C'
elif wavelength > 10:
return 'EUV'
elif wavelength > 10:
return 'EUV'
elif wavelength > 0.2:
return 'Soft X-Ray'
elif wavelength > 0.01:
return 'Hard X-Ray'
else:
return 'Gamma Ray'
def results(mass_, thickness_, density_, t_sun=sun_temp):
"""
A "Make it pretty" printout summary at the given parameters.
"""
d = radius_from_mass_density_and_thickness(mass_, density_, thickness_, au=True)
t = t_at_dist_and_lum(d)
t_waste = best_radiative_eff(d, t_sun)
eff = carnot(t, c=t_waste) * 100
emission_lambda = peak_black_body_wavelength(t_waste)
prefix = ''
if thickness_ < 1E-5:
thickness_ *= 10E6
thickness_ = round_(thickness_, 3)
prefix = 'n'
print(f'With a {thickness_} {prefix}m thick shell at {density_} g/cm^3 density, the shell is'
f' {round_(d, 3)} AU distant.'
f' Temp is {round_(t_waste, 2)}K. Carnot efficiency would be '
f'{round_(carnot(t_sun, c=t_waste) * 100, 2)}% and peak '
f'emissions at the {round(emission_lambda, 2)}nm ({spectra(emission_lambda)}) wavelength')
def show_silicon_and_tungsten_radii(mass_, thickness_):
"""
Simply a helper method to display both silicon and tungsten for the given mass and thickness.
"""
results(mass_, thickness_, 2.3)
results(mass_, thickness_, 19.3)
thickness = 0.1
for i in range(11):
show_silicon_and_tungsten_radii(mass_used_for_energy, thickness)
thickness /= 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment