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

太阳系三体模拟器

上级 52574dec
{
"bodies": [
{
"name": "红轨太阳A",
"mass": 2e+30,
"init_position": [
0.0,
518222240.0,
0.0
],
"init_velocity": [
-14.890000343322754,
0.0,
0.0
],
"density": 1408.0,
"color": [
255,
0,
0
],
"texture": "sun2.jpg",
"size_scale": 50.0,
"distance_scale": 1.0
},
{
"name": "绿轨太阳B",
"mass": 2e+30,
"init_position": [
-299195744.0,
0.0,
0.0
],
"init_velocity": [
7.445000171661377,
-12.895118713378906,
0.0
],
"density": 1408.0,
"color": [
0,
255,
0
],
"texture": "sun2.jpg",
"size_scale": 50.0,
"distance_scale": 1.0
},
{
"name": "蓝轨太阳C",
"mass": 2e+30,
"init_position": [
299195744.0,
0.0,
0.0
],
"init_velocity": [
7.445000171661377,
12.895118713378906,
0.0
],
"density": 1408.0,
"color": [
0,
0,
255
],
"texture": "sun2.jpg",
"size_scale": 50.0,
"distance_scale": 1.0
}
],
"params": {
"dt": 31536000,
"position": [
0,
149597870.7,
-1495978707.0
]
}
}
\ No newline at end of file
{
"bodies": [
{
"name": "红轨太阳A",
"mass": 2e+30,
"init_position": [
0.0,
518222240.0,
0.0
],
"init_velocity": [
-14.890000343322754,
0.0,
0.0
],
"density": 1408.0,
"color": [
255,
0,
0
],
"texture": "sun2.jpg",
"size_scale": 50.0,
"distance_scale": 1.0
},
{
"name": "绿轨太阳B",
"mass": 2e+30,
"init_position": [
-299195744.0,
0.0,
0.0
],
"init_velocity": [
7.445000171661377,
-12.895118713378906,
0.0
],
"density": 1408.0,
"color": [
0,
255,
0
],
"texture": "sun2.jpg",
"size_scale": 50.0,
"distance_scale": 1.0
},
{
"name": "蓝轨太阳C",
"mass": 2e+30,
"init_position": [
299195744.0,
0.0,
0.0
],
"init_velocity": [
7.445000171661377,
12.895118713378906,
0.0
],
"density": 1408.0,
"color": [
0,
0,
255
],
"texture": "sun2.jpg",
"size_scale": 50.0,
"distance_scale": 1.0
}
],
"params": {
"dt": 31536000,
"position": [
0,
149597870.7,
-1495978707.0
]
}
}
\ No newline at end of file
# -*- coding:utf-8 -*-
# title :三体场景模拟01
# description :三体场景模拟(3个太阳、1个地球)
# author :Python超人
# date :2023-02-11
# link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from bodies import Sun, Earth
from common.consts import SECONDS_PER_WEEK, SECONDS_PER_DAY, AU, SECONDS_PER_MONTH, SECONDS_PER_YEAR
from scenes.func import mayavi_run, ursina_run
if __name__ == '__main__':
"""
3个太阳、1个地球(效果1)
可以修改影响效果的参数为:
1、三个方向的初始位置 init_position[x, y, z]
2、三个方向的初始速度 init_velocity[x, y, z]
3、天体质量 mass
"""
import math
mass = 2e30
r = 2 * AU
# p = 12 # 三体转圆形花
p = 14.88 # 三体转圈近似圆形
# p = 16 # 三体转圆形花
# p = 18 # 三体转圆形花
# p = 19 # 三体转圆形花
bodies = [
Sun(name="红轨太阳A", mass=mass,
init_position=[0, math.sqrt(3) * r, 0],
init_velocity=[-p, 0, 0],
color=(255, 0, 0),
size_scale=5e1, texture="sun2.jpg"), # 太阳放大 100 倍
Sun(name="绿轨太阳B", mass=mass,
init_position=[-r, 0, 0],
init_velocity=[1 / 2 * p, -math.sqrt(3) / 2 * p, 0],
color=(0, 255, 0),
size_scale=5e1, texture="sun2.jpg"), # 太阳放大 100 倍
Sun(name="蓝轨太阳C", mass=mass,
init_position=[r, 0, 0],
init_velocity=[1 / 2 * p, math.sqrt(3) / 2 * p, 0],
color=(0, 0, 255),
size_scale=5e1, texture="sun2.jpg"), # 太阳放大 100 倍
# Earth(init_position=[0, -349597870.700, 0],
# init_velocity=[15.50, 0, 0],
# size_scale=4e3, distance_scale=1), # 地球放大 4000 倍,距离保持不变
]
# 使用 mayavi 查看的运行效果
# mayavi_run(bodies, SECONDS_PER_WEEK, view_azimuth=0)
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run(bodies, SECONDS_PER_YEAR, position=(3 * AU, AU, -4 * AU))
......@@ -18,8 +18,12 @@ if __name__ == '__main__':
# bodies, params = Body.build_bodies_from_json('../data/sun_earth.json')
# TODO: 去掉注释,在地球上看月相演示变化过程演示
# bodies, params = Body.build_bodies_from_json('../data/sun_earth_moon.json')
# TODO: 去掉注释,完美数据的三体模型的演示01
# TODO: 去掉注释,完美数据的三体模型的演示01(等边三角形)
# bodies, params = Body.build_bodies_from_json('../data/tri_bodies_sim_perfect_01.json')
# TODO: 去掉注释,完美数据的三体模型的演示02(等边三角形)
# bodies, params = Body.build_bodies_from_json('../data/tri_bodies_sim_perfect_02.json')
# TODO: 去掉注释,完美数据的三体模型的演示03(等边三角形)
bodies, params = Body.build_bodies_from_json('../data/tri_bodies_sim_perfect_03.json')
# TODO: 去掉注释,引力弹弓的演示
# bodies, params = Body.build_bodies_from_json('../data/gravity_slingshot.json')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册