提交 ab279f2b 编写于 作者: 三月三net's avatar 三月三net

太阳系三体模拟器

上级 fc200058
...@@ -29,4 +29,7 @@ from bodies.fixed_stars.betelgeuse import Betelgeuse ...@@ -29,4 +29,7 @@ from bodies.fixed_stars.betelgeuse import Betelgeuse
from bodies.fixed_stars.bellatrix import Bellatrix from bodies.fixed_stars.bellatrix import Bellatrix
from bodies.fixed_stars.aldebaran import Aldebaran from bodies.fixed_stars.aldebaran import Aldebaran
from bodies.fixed_stars.vy_canis_majoris import VYCanisMajoris from bodies.fixed_stars.vy_canis_majoris import VYCanisMajoris
from bodies.fixed_stars.uy_scuti import UYScuti from bodies.fixed_stars.uy_scuti import UYScuti
\ No newline at end of file from bodies.fixed_stars.eta_carinae import EtaCarinae
from bodies.fixed_stars.y_canum_venaticorum import YCanumVenaticorum
from bodies.fixed_stars.carinae_v382 import CarinaeV382
...@@ -59,13 +59,7 @@ class Alcyone(FixedStar): ...@@ -59,13 +59,7 @@ class Alcyone(FixedStar):
if __name__ == '__main__': if __name__ == '__main__':
from bodies import Sun
import math
fixed_star = Alcyone() fixed_star = Alcyone()
sun = Sun()
print(fixed_star) print(fixed_star)
print("质量倍数", fixed_star.mass / sun.mass) fixed_star.compare_with_sun()
print("半径倍数", fixed_star.raduis / sun.raduis) fixed_star.density_by_radius(num_sun_raduis=10)
r = 10
print("密度換算", fixed_star.mass / 1e9 / (4 / 3 * math.pi * pow(r * sun.raduis, 3)))
\ No newline at end of file
...@@ -39,7 +39,7 @@ class Aldebaran(FixedStar): ...@@ -39,7 +39,7 @@ class Aldebaran(FixedStar):
平均密度: 1.408×10³ kg/m³ 平均密度: 1.408×10³ kg/m³
""" """
def __init__(self, name="毕宿五", mass=1.16 * MO, def __init__(self, name="毕宿五", mass=11.3 * MO,
init_position=[0, 0, 0], init_position=[0, 0, 0],
init_velocity=[0, 0, 0], init_velocity=[0, 0, 0],
color=(250, 195, 47), color=(250, 195, 47),
...@@ -50,7 +50,7 @@ class Aldebaran(FixedStar): ...@@ -50,7 +50,7 @@ class Aldebaran(FixedStar):
"mass": mass, "mass": mass,
"init_position": init_position, "init_position": init_position,
"init_velocity": init_velocity, "init_velocity": init_velocity,
"density": 0.019, "density": 0.29,
"color": color, "color": color,
"texture": texture, "texture": texture,
"size_scale": size_scale, "size_scale": size_scale,
...@@ -69,5 +69,5 @@ if __name__ == '__main__': ...@@ -69,5 +69,5 @@ if __name__ == '__main__':
print(fixed_star) print(fixed_star)
print("质量倍数", fixed_star.mass / sun.mass) print("质量倍数", fixed_star.mass / sun.mass)
print("半径倍数", fixed_star.raduis / sun.raduis) print("半径倍数", fixed_star.raduis / sun.raduis)
r = 44.13 r = 38
print("密度換算", fixed_star.mass / 1e9 / (4 / 3 * math.pi * pow(r * sun.raduis, 3))) print("密度換算", fixed_star.mass / 1e9 / (4 / 3 * math.pi * pow(r * sun.raduis, 3)))
...@@ -33,7 +33,7 @@ class CarinaeV382(FixedStar): ...@@ -33,7 +33,7 @@ class CarinaeV382(FixedStar):
def __init__(self, name="船底座V382", mass=20 * MO, def __init__(self, name="船底座V382", mass=20 * MO,
init_position=[0, 0, 0], init_position=[0, 0, 0],
init_velocity=[0, 0, 0], init_velocity=[0, 0, 0],
color=(0xFF, 0xBF, 0x00), color=(255, 244, 89),
texture="fixed_star.png", size_scale=1.0, distance_scale=1.0, texture="fixed_star.png", size_scale=1.0, distance_scale=1.0,
rotation_speed=0.1, ignore_mass=False): rotation_speed=0.1, ignore_mass=False):
params = { params = {
...@@ -41,7 +41,7 @@ class CarinaeV382(FixedStar): ...@@ -41,7 +41,7 @@ class CarinaeV382(FixedStar):
"mass": mass, "mass": mass,
"init_position": init_position, "init_position": init_position,
"init_velocity": init_velocity, "init_velocity": init_velocity,
"density": 1.408e3, "density": 0.000656,
"color": color, "color": color,
"texture": texture, "texture": texture,
"size_scale": size_scale, "size_scale": size_scale,
...@@ -53,9 +53,7 @@ class CarinaeV382(FixedStar): ...@@ -53,9 +53,7 @@ class CarinaeV382(FixedStar):
if __name__ == '__main__': if __name__ == '__main__':
from bodies import Sun
fixed_star = CarinaeV382() fixed_star = CarinaeV382()
sun = Sun()
print(fixed_star) print(fixed_star)
print("质量倍数", fixed_star.mass / sun.mass) fixed_star.compare_with_sun()
print("半径倍数", fixed_star.raduis / sun.raduis) fixed_star.density_by_radius(num_sun_raduis=350)
\ No newline at end of file
...@@ -14,7 +14,7 @@ class EtaCarinae(FixedStar): ...@@ -14,7 +14,7 @@ class EtaCarinae(FixedStar):
""" """
TODO: 海山二/船底座(Eta Carinae) TODO: 海山二/船底座(Eta Carinae)
质量:100 太阳质量 质量:100 太阳质量
大小:500 太阳半径 大小:277 太阳半径
颜色:0xFF, 0xD7, 0x00 颜色:0xFF, 0xD7, 0x00
密度:0.002 g/cm³ 密度:0.002 g/cm³
...@@ -35,7 +35,7 @@ class EtaCarinae(FixedStar): ...@@ -35,7 +35,7 @@ class EtaCarinae(FixedStar):
def __init__(self, name="海山二", mass=100 * MO, def __init__(self, name="海山二", mass=100 * MO,
init_position=[0, 0, 0], init_position=[0, 0, 0],
init_velocity=[0, 0, 0], init_velocity=[0, 0, 0],
color=(0xFF, 0xD7, 0x00), color=(111,140,255),
texture="fixed_star.png", size_scale=1.0, distance_scale=1.0, texture="fixed_star.png", size_scale=1.0, distance_scale=1.0,
rotation_speed=0.1, ignore_mass=False): rotation_speed=0.1, ignore_mass=False):
params = { params = {
...@@ -43,7 +43,7 @@ class EtaCarinae(FixedStar): ...@@ -43,7 +43,7 @@ class EtaCarinae(FixedStar):
"mass": mass, "mass": mass,
"init_position": init_position, "init_position": init_position,
"init_velocity": init_velocity, "init_velocity": init_velocity,
"density": 1.408e3, "density": 0.0065,
"color": color, "color": color,
"texture": texture, "texture": texture,
"size_scale": size_scale, "size_scale": size_scale,
...@@ -56,8 +56,13 @@ class EtaCarinae(FixedStar): ...@@ -56,8 +56,13 @@ class EtaCarinae(FixedStar):
if __name__ == '__main__': if __name__ == '__main__':
from bodies import Sun from bodies import Sun
import math
fixed_star = EtaCarinae() fixed_star = EtaCarinae()
sun = Sun() sun = Sun()
print(fixed_star) print(fixed_star)
print("质量倍数", fixed_star.mass / sun.mass) print("质量倍数", fixed_star.mass / sun.mass)
print("半径倍数", fixed_star.raduis / sun.raduis) print("半径倍数", fixed_star.raduis / sun.raduis)
\ No newline at end of file # print((386809200/sun.diameter))
r = 277.8
print("密度換算", fixed_star.mass / 1e9 / (4 / 3 * math.pi * pow(r * sun.raduis, 3)))
...@@ -77,6 +77,27 @@ class FixedStar(Body): ...@@ -77,6 +77,27 @@ class FixedStar(Body):
""" """
return True return True
def compare_with_sun(self):
from bodies import Sun
sun = Sun()
print("质量倍数", self.mass / sun.mass)
print("半径倍数", self.raduis / sun.raduis)
def density_by_radius(self, raduis=None, num_sun_raduis=None):
"""
密度換算
@param raduis: 半径的长度(km)
@param num_sun_raduis: 多少个太阳半径
@return:
"""
from bodies import Sun
import math
sun = Sun()
if num_sun_raduis is not None:
raduis = num_sun_raduis * sun.raduis
print("密度換算", self.mass / 1e9 / (4 / 3 * math.pi * pow(raduis, 3)))
if __name__ == '__main__': if __name__ == '__main__':
print(FixedStar()) print(FixedStar())
...@@ -13,10 +13,10 @@ from common.consts import MO ...@@ -13,10 +13,10 @@ from common.consts import MO
class Stephenson_2_18(FixedStar): class Stephenson_2_18(FixedStar):
""" """
史蒂文森2-18 (Stephenson 2-18) 史蒂文森2-18 (Stephenson 2-18)
质量:40.0 太阳质量 ? TODO: 14.28e5 * MO ?? 质量:40.0 太阳质量 ?
大小:2150 太阳半径 大小:2150 太阳半径
颜色:0xFF, 0xFF, 0xFF 颜色:0xFF, 0xFF, 0xFF
密度:0.0002 g/cm³ >> TODO:??? 密度:0.0002 g/cm³
半径:2158R☉ 半径:2158R☉
......
# -*- coding:utf-8 -*-
# title :参宿七
# description :参宿七
# author :Python超人
# date :2023-02-11
# link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from bodies import FixedStar
from common.consts import MO
class YCanumVenaticorum(FixedStar):
"""
中文名猎犬座Y外文名Y Canum Venaticorum
别 名La Superba
分 类红巨星,碳星,变星
质 量3M⊙
直 径 299280000 km
表面温度2800K反照率不是行星视星等4.99赤 经12时45分07.83秒赤 纬+45°26′24.92″距地距离1000Ly光 度5800L⊙光 谱N3U-B色指数6.62B-V色指数2.54变星类型SRb编 号HR4846,HD110914,HIP62223
------------------------
== 太阳参数 ==
自转周期: 24.47 地球日,自转角速度约为 0.6130 度/小时 = 360/(24.47*24)
天体质量: 1.9891×10³⁰ kg
平均密度: 1.408×10³ kg/m³
"""
def __init__(self, name="猎犬座Y", mass=3 * MO,
init_position=[0, 0, 0],
init_velocity=[0, 0, 0],
color=(255,55,18),
texture="fixed_star.png", size_scale=1.0, distance_scale=1.0,
rotation_speed=0.1, ignore_mass=False):
params = {
"name": name,
"mass": mass,
"init_position": init_position,
"init_velocity": init_velocity,
"density": 0.000425,
"color": color,
"texture": texture,
"size_scale": size_scale,
"distance_scale": distance_scale,
"rotation_speed": rotation_speed,
"ignore_mass": ignore_mass
}
super().__init__(**params)
if __name__ == '__main__':
from bodies import Sun
import math
fixed_star = YCanumVenaticorum()
sun = Sun()
print(fixed_star)
print("质量倍数", fixed_star.mass / sun.mass)
print("半径倍数", fixed_star.raduis / sun.raduis)
r = 215
print("密度換算", fixed_star.mass / 1e9 / (4 / 3 * math.pi * pow(r * sun.raduis, 3)))
print((299280000 / sun.diameter))
\ No newline at end of file
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# python_version :3.8 # python_version :3.8
# ============================================================================== # ==============================================================================
from bodies import Sun, Earth, Sirius, Rigel, Bellatrix, Alcyone, Antares, Arcturus, Aldebaran, Betelgeuse from bodies import Sun, Earth, Sirius, Rigel, Bellatrix, Alcyone, Antares, Arcturus, Aldebaran, Betelgeuse
from bodies import VYCanisMajoris, UYScuti, Stephenson_2_18 from bodies import EtaCarinae, YCanumVenaticorum, VYCanisMajoris, UYScuti, CarinaeV382, Stephenson_2_18
from common.consts import SECONDS_PER_WEEK, SECONDS_PER_MONTH, SECONDS_PER_YEAR, SECONDS_PER_DAY from common.consts import SECONDS_PER_WEEK, SECONDS_PER_MONTH, SECONDS_PER_YEAR, SECONDS_PER_DAY
from scenes.func import mayavi_run, mpl_run, ursina_run from scenes.func import mayavi_run, mpl_run, ursina_run
from bodies.body import Body, AU from bodies.body import Body, AU
...@@ -22,24 +22,30 @@ if __name__ == '__main__': ...@@ -22,24 +22,30 @@ if __name__ == '__main__':
bodies = [ bodies = [
Earth(size_scale=1, init_velocity=[0, 29.79, 0], distance_scale=0.0006), Earth(size_scale=1, init_velocity=[0, 29.79, 0], distance_scale=0.0006),
Sun(size_scale=SIZE_SCALE), # 太阳 Sun(size_scale=SIZE_SCALE), # 太阳
Sirius(size_scale=SIZE_SCALE, ignore_mass=True), # 天狼星A 质量倍数 2.06 半径倍数 1.71 Sirius(size_scale=SIZE_SCALE, ignore_mass=True), # 天狼星A 质量倍数 2.06 半径倍数 1.71
Bellatrix(size_scale=SIZE_SCALE, ignore_mass=True), # 参宿五 质量倍数 8.6 半径倍数 5.75 Bellatrix(size_scale=SIZE_SCALE, ignore_mass=True), # 参宿五 质量倍数 8.6 半径倍数 5.75
Alcyone(size_scale=SIZE_SCALE, ignore_mass=True), # 昴宿六 质量倍数 7 半径倍数 10 Alcyone(size_scale=SIZE_SCALE, ignore_mass=True), # 昴宿六 质量倍数 7 半径倍数 10
Arcturus(size_scale=SIZE_SCALE, ignore_mass=True), # 大角星 质量倍数 1.08 半径倍数 25.42 Arcturus(size_scale=SIZE_SCALE, ignore_mass=True), # 大角星 质量倍数 1.08 半径倍数 25.42
Aldebaran(size_scale=SIZE_SCALE, ignore_mass=True), # 毕宿五 质量倍数 1.16 半径倍数 44.13 Aldebaran(size_scale=SIZE_SCALE, ignore_mass=True), # 毕宿五 质量倍数 11.3 半径倍数 38
Rigel(size_scale=SIZE_SCALE, ignore_mass=True), # 参宿七 质量倍数 21 半径倍数 78.9 Rigel(size_scale=SIZE_SCALE, ignore_mass=True), # 参宿七 质量倍数 21 半径倍数 78.9
Antares(size_scale=SIZE_SCALE, ignore_mass=True), # 心宿二 质量倍数 12 半径倍数 770 YCanumVenaticorum(size_scale=SIZE_SCALE, ignore_mass=True), # 猎犬座Y 质量倍数 3.0 半径倍数 215
Betelgeuse(size_scale=SIZE_SCALE, ignore_mass=True), # 参宿四 质量倍数 11.6 半径倍数 887 EtaCarinae(size_scale=SIZE_SCALE, ignore_mass=True), # 海山二 质量倍数 100.0 半径倍数 278
VYCanisMajoris(size_scale=SIZE_SCALE, ignore_mass=True), # 大犬座VY 质量倍数 25 半径倍数 1419.75 CarinaeV382(size_scale=SIZE_SCALE, ignore_mass=True), # 船底座V382 质量倍数 20.0 半径倍数 350
UYScuti(size_scale=SIZE_SCALE, ignore_mass=True), # 盾牌座 UY 质量倍数 10.0 半径倍数 1706.7
Stephenson_2_18(size_scale=SIZE_SCALE, ignore_mass=True) # 史蒂文森2-18 质量倍数 40.0 半径倍数 2158.5
Antares(size_scale=SIZE_SCALE, ignore_mass=True), # 心宿二 质量倍数 12 半径倍数 770
Betelgeuse(size_scale=SIZE_SCALE, ignore_mass=True), # 参宿四 质量倍数 11.6 半径倍数 887
VYCanisMajoris(size_scale=SIZE_SCALE, ignore_mass=True), # 大犬座VY 质量倍数 25 半径倍数 1419.75
UYScuti(size_scale=SIZE_SCALE, ignore_mass=True), # 盾牌座 UY 质量倍数 10.0 半径倍数 1706.7
Stephenson_2_18(size_scale=SIZE_SCALE, ignore_mass=True) # 史蒂文森2-18 质量倍数 40.0 半径倍数 2158.5
] ]
distance_sum = 0 distance_sum = 0
for idx, body in enumerate(bodies): for idx, body in enumerate(bodies):
body.rotation_speed /= 10 body.rotation_speed /= 10
if idx > 1: if idx > 1:
body.light_on = False # 关闭灯光效果,只有太阳对地球有灯光效果 body.light_on = False # 关闭灯光效果,只有太阳对地球有灯光效果
d = pow((body.diameter + bodies[idx - 1].diameter) * SIZE_SCALE, 0.75) * 120 d = pow((body.diameter + bodies[idx - 1].diameter) * SIZE_SCALE, 0.75) * 80
# d = (body.diameter + bodies[idx - 1].diameter) * SIZE_SCALE * 1.1 + D # d = (body.diameter + bodies[idx - 1].diameter) * SIZE_SCALE * 1.1 + D
body.init_position = [(distance_sum + d) / 2, (distance_sum + d), 0] body.init_position = [(distance_sum + d) / 2, (distance_sum + d), 0]
distance_sum += d distance_sum += d
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册