Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
be4d6217
宇宙模拟器
项目概览
Python_超人
/
宇宙模拟器
通知
19
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
宇宙模拟器
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
be4d6217
编写于
6月 29, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
96694cd3
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
106 addition
and
6 deletion
+106
-6
bodies/__init__.py
bodies/__init__.py
+1
-0
bodies/habitable_zone.py
bodies/habitable_zone.py
+58
-0
sim_scenes/solar_system/solar_system_habitable_zone.py
sim_scenes/solar_system/solar_system_habitable_zone.py
+34
-0
simulators/calc_simulator.py
simulators/calc_simulator.py
+1
-1
simulators/mpl_simulator.py
simulators/mpl_simulator.py
+1
-1
simulators/ursina/entities/planet.py
simulators/ursina/entities/planet.py
+9
-2
simulators/views/mayavi_view.py
simulators/views/mayavi_view.py
+1
-1
simulators/views/mpl_view.py
simulators/views/mpl_view.py
+1
-1
未找到文件。
bodies/__init__.py
浏览文件 @
be4d6217
...
...
@@ -12,6 +12,7 @@ from bodies.venus import Venus
from
bodies.moon
import
Moon
from
bodies.asteroid
import
Asteroid
from
bodies.asteroids
import
Asteroids
from
bodies.habitable_zone
import
HabitableZone
# 戴森球
from
bodies.dysen_sphere
import
DysenSphere
...
...
bodies/habitable_zone.py
0 → 100644
浏览文件 @
be4d6217
# -*- coding:utf-8 -*-
# title :小行星
# description :小行星
# author :Python超人
# date :2023-07-01
# link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies.body
import
Body
,
AU
class
HabitableZone
(
Body
):
"""
模拟太阳系宜居带:
目前认为 太阳系 的宜居带范围是从距离太阳0.95个天文单位 (约1.42亿千米)到 2.4个天文单位(约3.59亿千米)的范围为宜居带,
其宽度约为2.17亿千米, 按照这个标准,太阳系的宜居带中只有三个大型天体,分别是地球、 月球 以及火星(1.52天文单位)。
"""
def
__init__
(
self
,
name
=
"宜居带"
,
mass
=
1.9891e30
,
init_position
=
[
0
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
],
texture
=
"green_alpha_1.png"
,
size_scale
=
1.0
,
distance_scale
=
1.0
,
rotation_speed
=
0.1
,
parent
=
None
):
params
=
{
"name"
:
name
,
"mass"
:
mass
,
"init_position"
:
init_position
,
"init_velocity"
:
init_velocity
,
"density"
:
1.408e3
,
"color"
:
(
179
,
231
,
255
),
"texture"
:
texture
,
"size_scale"
:
size_scale
,
"distance_scale"
:
distance_scale
,
"rotation_speed"
:
rotation_speed
,
"parent"
:
parent
}
super
().
__init__
(
**
params
)
# 环状带(inner_radius, outer_radius, subdivisions)
self
.
torus_zone
=
0.95
,
2.4
,
64
def
ignore_gravity_with
(
self
,
body
):
"""
是否忽略指定天体的引力
@param body:
@return:
"""
# 小行星只对恒星有引力,忽略其他行星的引力
# if body.is_fixed_star:
return
True
# return True
if
__name__
==
'__main__'
:
asteroids
=
Asteroids
()
print
(
asteroids
)
sim_scenes/solar_system/solar_system_habitable_zone.py
0 → 100644
浏览文件 @
be4d6217
# -*- coding:utf-8 -*-
# title :太阳系宜居带模拟场景
# description :太阳系宜居带模拟场景(展示的效果为太阳系真实的距离)
# author :Python超人
# date :2023-07-01
# link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Moon
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
,
HabitableZone
,
Asteroids
from
common.consts
import
SECONDS_PER_WEEK
,
SECONDS_PER_DAY
,
SECONDS_PER_YEAR
,
AU
from
sim_scenes.func
import
mayavi_run
,
ursina_run
if
__name__
==
'__main__'
:
# 目前认为 太阳系 的宜居带范围是从距离太阳0.95个天文单位 (约1.42亿千米)到 2.4个天文单位(约3.59亿千米)的范围为宜居带,
# 其宽度约为2.17亿千米, 按照这个标准,太阳系的宜居带中只有三个大型天体,分别是地球、 月球 以及火星(1.52天文单位)。
sun
=
Sun
(
name
=
"太阳"
,
size_scale
=
0.5e2
)
# 太阳放大 80 倍,距离保持不变
bodies
=
[
sun
,
Venus
(
name
=
"金星"
,
size_scale
=
1.5e3
),
# 金星放大 4000 倍,距离保持不变
Earth
(
name
=
"地球"
,
size_scale
=
1.5e3
),
# 地球放大 4000 倍,距离保持不变
Moon
(
name
=
"月球"
,
size_scale
=
2e3
),
# 地球放大 4000 倍,距离保持不变
Mars
(
name
=
"火星"
,
size_scale
=
2e3
),
# 火星放大 4000 倍,距离保持不变
Asteroids
(
name
=
"小行星群"
,
size_scale
=
3.2e2
,
parent
=
sun
),
# 小行星群模拟(仅 ursina 模拟器支持)
HabitableZone
(
name
=
"宜居带"
,
size_scale
=
1e2
,
parent
=
sun
),
# 小行星群模拟(仅 ursina 模拟器支持)
Jupiter
(
name
=
"木星"
,
size_scale
=
2e2
),
# 木星放大 800 倍,距离保持不变
]
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run
(
bodies
,
1
,
position
=
(
0
,
2
*
AU
,
-
11
*
AU
),
bg_music
=
"sounds/interstellar.mp3"
)
simulators/calc_simulator.py
浏览文件 @
be4d6217
...
...
@@ -22,7 +22,7 @@ class CalcView(BodyView):
pass
def
appear
(
self
):
if
hasattr
(
self
.
body
,
"torus_stars"
):
if
hasattr
(
self
.
body
,
"torus_stars"
)
or
hasattr
(
self
.
body
,
"torus_zone"
)
:
# 暂不支持环状小行星群
return
...
...
simulators/mpl_simulator.py
浏览文件 @
be4d6217
...
...
@@ -94,7 +94,7 @@ class MplSimulator(Simulator):
update_ax
(
ax
,
styles
)
for
idx
,
body
in
enumerate
(
bodies
):
if
hasattr
(
body
,
"torus_stars"
):
if
hasattr
(
body
,
"torus_stars"
)
or
hasattr
(
body
,
"torus_zone"
)
:
# 暂不支持环状小行星群
continue
...
...
simulators/ursina/entities/planet.py
浏览文件 @
be4d6217
...
...
@@ -63,6 +63,13 @@ class Planet(Entity):
# 创建一个星环小天体群(主要模拟小行星群,非一个天体)
model
=
create_torus
(
0.83
,
1.05
,
64
,
1
)
rotation
=
(
90
,
0
,
0
)
elif
hasattr
(
self
.
body
,
"torus_zone"
):
# 创建一个星环小天体群(主要模拟环形带,非一个天体)
inner_radius
,
outer_radius
,
subdivisions
=
self
.
body
.
torus_zone
if
subdivisions
is
None
:
subdivisions
=
64
model
=
create_torus
(
inner_radius
,
outer_radius
,
subdivisions
,
1
)
rotation
=
(
90
,
0
,
0
)
else
:
# 创建一个天体
subdivisions
=
32
...
...
@@ -126,7 +133,7 @@ class Planet(Entity):
axis_color
=
color
.
rgba
(
*
axis_color
)
self
.
create_rotate_line
(
axis_color
)
if
hasattr
(
self
.
body
,
"torus_stars"
):
if
hasattr
(
self
.
body
,
"torus_stars"
)
or
hasattr
(
self
.
body
,
"torus_zone"
)
:
# 星环小天体群(主要模拟小行星群,非一个天体)
self
.
set_light_off
()
self
.
double_sided
=
True
...
...
@@ -193,7 +200,7 @@ class Planet(Entity):
len_scale
=
line_scale
,
color
=
line_color
,
thickness
=
2
)
def
change_body_scale
(
self
):
if
hasattr
(
self
.
body
,
"torus_stars"
):
if
hasattr
(
self
.
body
,
"torus_stars"
)
or
hasattr
(
self
.
body
,
"torus_zone"
)
:
# 星环小天体群(主要模拟小行星群,非一个天体)不受 body_size_factor 影响
self
.
scale
=
self
.
init_scale
else
:
...
...
simulators/views/mayavi_view.py
浏览文件 @
be4d6217
...
...
@@ -85,7 +85,7 @@ class MayaviView(BodyView):
天体显示的操作,比如:构建天体视图对象
@return:
"""
if
hasattr
(
self
.
body
,
"torus_stars"
):
if
hasattr
(
self
.
body
,
"torus_stars"
)
or
hasattr
(
self
.
body
,
"torus_zone"
)
:
# 暂不支持环状小行星群
return
...
...
simulators/views/mpl_view.py
浏览文件 @
be4d6217
...
...
@@ -23,7 +23,7 @@ class MplView(BodyView):
pass
def
appear
(
self
):
if
hasattr
(
self
.
body
,
"torus_stars"
):
if
hasattr
(
self
.
body
,
"torus_stars"
)
or
hasattr
(
self
.
body
,
"torus_zone"
)
:
# 暂不支持环状小行星群
return
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录