From ab279f2b5757f4568d63c5f8aade8186e2db11e6 Mon Sep 17 00:00:00 2001 From: march3 Date: Wed, 22 Mar 2023 19:00:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=AA=E9=98=B3=E7=B3=BB=E4=B8=89=E4=BD=93?= =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bodies/__init__.py | 5 +- bodies/fixed_stars/alcyone.py | 10 +--- bodies/fixed_stars/aldebaran.py | 6 +-- bodies/fixed_stars/carinae_v382.py | 10 ++-- bodies/fixed_stars/eta_carinae.py | 13 +++-- bodies/fixed_stars/fixed_star.py | 21 ++++++++ bodies/fixed_stars/stephenson_2_18.py | 4 +- bodies/fixed_stars/y_canum_venaticorum.py | 62 +++++++++++++++++++++++ scenes/fixed_stars.py | 32 +++++++----- 9 files changed, 126 insertions(+), 37 deletions(-) create mode 100644 bodies/fixed_stars/y_canum_venaticorum.py diff --git a/bodies/__init__.py b/bodies/__init__.py index 68e0d9b..19d9f39 100644 --- a/bodies/__init__.py +++ b/bodies/__init__.py @@ -29,4 +29,7 @@ from bodies.fixed_stars.betelgeuse import Betelgeuse from bodies.fixed_stars.bellatrix import Bellatrix from bodies.fixed_stars.aldebaran import Aldebaran from bodies.fixed_stars.vy_canis_majoris import VYCanisMajoris -from bodies.fixed_stars.uy_scuti import UYScuti \ No newline at end of file +from bodies.fixed_stars.uy_scuti import UYScuti +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 diff --git a/bodies/fixed_stars/alcyone.py b/bodies/fixed_stars/alcyone.py index 37fd2de..ce568a4 100644 --- a/bodies/fixed_stars/alcyone.py +++ b/bodies/fixed_stars/alcyone.py @@ -59,13 +59,7 @@ class Alcyone(FixedStar): if __name__ == '__main__': - from bodies import Sun - import math - fixed_star = Alcyone() - sun = Sun() print(fixed_star) - print("质量倍数", fixed_star.mass / sun.mass) - print("半径倍数", fixed_star.raduis / sun.raduis) - r = 10 - print("密度換算", fixed_star.mass / 1e9 / (4 / 3 * math.pi * pow(r * sun.raduis, 3))) \ No newline at end of file + fixed_star.compare_with_sun() + fixed_star.density_by_radius(num_sun_raduis=10) diff --git a/bodies/fixed_stars/aldebaran.py b/bodies/fixed_stars/aldebaran.py index ef60da0..9661c8d 100644 --- a/bodies/fixed_stars/aldebaran.py +++ b/bodies/fixed_stars/aldebaran.py @@ -39,7 +39,7 @@ class Aldebaran(FixedStar): 平均密度: 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_velocity=[0, 0, 0], color=(250, 195, 47), @@ -50,7 +50,7 @@ class Aldebaran(FixedStar): "mass": mass, "init_position": init_position, "init_velocity": init_velocity, - "density": 0.019, + "density": 0.29, "color": color, "texture": texture, "size_scale": size_scale, @@ -69,5 +69,5 @@ if __name__ == '__main__': print(fixed_star) print("质量倍数", fixed_star.mass / sun.mass) 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))) diff --git a/bodies/fixed_stars/carinae_v382.py b/bodies/fixed_stars/carinae_v382.py index 5ad1c0a..fd8fab2 100644 --- a/bodies/fixed_stars/carinae_v382.py +++ b/bodies/fixed_stars/carinae_v382.py @@ -33,7 +33,7 @@ class CarinaeV382(FixedStar): def __init__(self, name="船底座V382", mass=20 * MO, init_position=[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, rotation_speed=0.1, ignore_mass=False): params = { @@ -41,7 +41,7 @@ class CarinaeV382(FixedStar): "mass": mass, "init_position": init_position, "init_velocity": init_velocity, - "density": 1.408e3, + "density": 0.000656, "color": color, "texture": texture, "size_scale": size_scale, @@ -53,9 +53,7 @@ class CarinaeV382(FixedStar): if __name__ == '__main__': - from bodies import Sun fixed_star = CarinaeV382() - sun = Sun() print(fixed_star) - print("质量倍数", fixed_star.mass / sun.mass) - print("半径倍数", fixed_star.raduis / sun.raduis) \ No newline at end of file + fixed_star.compare_with_sun() + fixed_star.density_by_radius(num_sun_raduis=350) diff --git a/bodies/fixed_stars/eta_carinae.py b/bodies/fixed_stars/eta_carinae.py index f13b24c..251a76c 100644 --- a/bodies/fixed_stars/eta_carinae.py +++ b/bodies/fixed_stars/eta_carinae.py @@ -14,7 +14,7 @@ class EtaCarinae(FixedStar): """ TODO: 海山二/船底座(Eta Carinae) 质量:100 太阳质量 - 大小:500 太阳半径 + 大小:277 太阳半径 颜色:0xFF, 0xD7, 0x00 密度:0.002 g/cm³ @@ -35,7 +35,7 @@ class EtaCarinae(FixedStar): def __init__(self, name="海山二", mass=100 * MO, init_position=[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, rotation_speed=0.1, ignore_mass=False): params = { @@ -43,7 +43,7 @@ class EtaCarinae(FixedStar): "mass": mass, "init_position": init_position, "init_velocity": init_velocity, - "density": 1.408e3, + "density": 0.0065, "color": color, "texture": texture, "size_scale": size_scale, @@ -56,8 +56,13 @@ class EtaCarinae(FixedStar): if __name__ == '__main__': from bodies import Sun + import math + fixed_star = EtaCarinae() sun = Sun() print(fixed_star) print("质量倍数", fixed_star.mass / sun.mass) - print("半径倍数", fixed_star.raduis / sun.raduis) \ No newline at end of file + print("半径倍数", fixed_star.raduis / sun.raduis) + # print((386809200/sun.diameter)) + r = 277.8 + print("密度換算", fixed_star.mass / 1e9 / (4 / 3 * math.pi * pow(r * sun.raduis, 3))) diff --git a/bodies/fixed_stars/fixed_star.py b/bodies/fixed_stars/fixed_star.py index e1d3b3b..a503f6e 100644 --- a/bodies/fixed_stars/fixed_star.py +++ b/bodies/fixed_stars/fixed_star.py @@ -77,6 +77,27 @@ class FixedStar(Body): """ 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__': print(FixedStar()) diff --git a/bodies/fixed_stars/stephenson_2_18.py b/bodies/fixed_stars/stephenson_2_18.py index 1f85c06..c17fd6b 100644 --- a/bodies/fixed_stars/stephenson_2_18.py +++ b/bodies/fixed_stars/stephenson_2_18.py @@ -13,10 +13,10 @@ from common.consts import MO class Stephenson_2_18(FixedStar): """ 史蒂文森2-18 (Stephenson 2-18) - 质量:40.0 太阳质量 ? TODO: 14.28e5 * MO ?? + 质量:40.0 太阳质量 ? 大小:2150 太阳半径 颜色:0xFF, 0xFF, 0xFF - 密度:0.0002 g/cm³ >> TODO:??? + 密度:0.0002 g/cm³ 半径:2158R☉ diff --git a/bodies/fixed_stars/y_canum_venaticorum.py b/bodies/fixed_stars/y_canum_venaticorum.py new file mode 100644 index 0000000..8982793 --- /dev/null +++ b/bodies/fixed_stars/y_canum_venaticorum.py @@ -0,0 +1,62 @@ +# -*- 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 diff --git a/scenes/fixed_stars.py b/scenes/fixed_stars.py index d540fff..9e0edf3 100644 --- a/scenes/fixed_stars.py +++ b/scenes/fixed_stars.py @@ -7,7 +7,7 @@ # python_version :3.8 # ============================================================================== 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 scenes.func import mayavi_run, mpl_run, ursina_run from bodies.body import Body, AU @@ -22,24 +22,30 @@ if __name__ == '__main__': bodies = [ Earth(size_scale=1, init_velocity=[0, 29.79, 0], distance_scale=0.0006), Sun(size_scale=SIZE_SCALE), # 太阳 - 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 - Alcyone(size_scale=SIZE_SCALE, ignore_mass=True), # 昴宿六 质量倍数 7 半径倍数 10 - Arcturus(size_scale=SIZE_SCALE, ignore_mass=True), # 大角星 质量倍数 1.08 半径倍数 25.42 - Aldebaran(size_scale=SIZE_SCALE, ignore_mass=True), # 毕宿五 质量倍数 1.16 半径倍数 44.13 - Rigel(size_scale=SIZE_SCALE, ignore_mass=True), # 参宿七 质量倍数 21 半径倍数 78.9 - 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 + 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 + Alcyone(size_scale=SIZE_SCALE, ignore_mass=True), # 昴宿六 质量倍数 7 半径倍数 10 + Arcturus(size_scale=SIZE_SCALE, ignore_mass=True), # 大角星 质量倍数 1.08 半径倍数 25.42 + Aldebaran(size_scale=SIZE_SCALE, ignore_mass=True), # 毕宿五 质量倍数 11.3 半径倍数 38 + Rigel(size_scale=SIZE_SCALE, ignore_mass=True), # 参宿七 质量倍数 21 半径倍数 78.9 + YCanumVenaticorum(size_scale=SIZE_SCALE, ignore_mass=True), # 猎犬座Y 质量倍数 3.0 半径倍数 215 + EtaCarinae(size_scale=SIZE_SCALE, ignore_mass=True), # 海山二 质量倍数 100.0 半径倍数 278 + CarinaeV382(size_scale=SIZE_SCALE, ignore_mass=True), # 船底座V382 质量倍数 20.0 半径倍数 350 + + + + 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 for idx, body in enumerate(bodies): body.rotation_speed /= 10 if idx > 1: 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 body.init_position = [(distance_sum + d) / 2, (distance_sum + d), 0] distance_sum += d -- GitLab