“Failure is an option here. If things are not failing, you are not innovating enough.”——Elon Musk

过程概述

发射阶段(Liftoff)

  • 火箭继续以倾角 $\theta_0$ 上升,速度逐渐增加。
  • 空气阻力与速度方向相反,需要考虑空气阻力的影响。
  • 火箭的姿态可能会随时间调整(例如通过控制舵面或推力矢量控制)。

相关公式:

  • 推力:
    $
    F = \dot{m} v_e + A_e (P_e - P_0)
    $
    其中,$ \dot{m} $ 为推进剂流量,$ v_e $ 为喷射气体速度,$ A_e $ 为喷口面积,$ P_e $ 和 $ P_0 $ 分别为喷口出口压力和大气压力。

  • 质量变化:
    $
    m(t) = m_0 - \dot{m} t
    $
    其中,$ m_0 $ 为火箭的初始质量。

  • 加速度:
    $
    a = \frac{F}{m} - g - \frac{1}{2} C_D \rho v^2 A / m
    $
    其中,$ C_D $ 为阻力系数,$ \rho $ 为空气密度,$ v $ 为火箭的速度,$ A $ 为火箭的迎风面积,$ g $ 为重力加速度。

  • 速度:
    $
    v(t) = \int a \, dt
    $

  • 位置:
    $
    h(t) = \int v \, dt
    $


倾斜上升阶段(Inclined Ascent)

  • 火箭继续以倾角 $\theta_0$ 上升,速度逐渐增加。
  • 空气阻力与速度方向相反,需要考虑空气阻力的影响。
  • 火箭的姿态可能会随时间调整(例如通过控制舵面或推力矢量控制)。

相关公式:

  • 推力:
    $
    F = \dot{m} v_e + A_e (P_e - P_0)
    $

  • 质量变化:
    $
    m(t) = m_0 - \dot{m} t
    $

  • 加速度:
    $
    a = \frac{F}{m} - g - \frac{1}{2} C_D \rho v^2 A / m
    $

  • 速度:
    $
    v(t) = \int a \, dt
    $

  • 位置:
    $
    h(t) = \int v \, dt
    $


重力转弯阶段(Gravity Turn)

  • 火箭在倾斜上升过程中,重力会逐渐改变火箭的飞行方向,使其轨迹向水平方向弯曲。
  • 这一过程通常不需要额外的控制输入,而是由重力和火箭的初始倾角自然形成。

相关公式:

  • 重力转弯角度变化:
    $
    \frac{d\gamma}{dt} = \frac{F_T \sin(\theta)}{m v} - g \cos(\gamma)
    $
    其中,$\gamma$ 为俯仰角,$ F_T $ 为推力,$ m $ 为火箭质量,$ v $ 为火箭速度,$ \theta $ 为倾角,$ g $ 为重力加速度。

  • 速度变化:
    $
    \mathbf{v} = \int a \, dt
    $
    此处 $a$ 为重力转弯阶段的加速度。


空速下降阶段(Airspeed Descent)

  • 火箭在重力转弯后,开始以空速下降,速度逐渐减小。
  • 空气阻力与速度方向相反,需要考虑空气阻力的影响。
  • 火箭的姿态可能会随时间调整(例如通过控制舵面或推力矢量控制)。

相关公式:

  • 空气阻力:
    $
    F_D = \frac{1}{2} C_D \rho v^2 A
    $
    其中,$ v $ 为火箭的空速,$ C_D $ 为阻力系数,$ \rho $ 为空气密度,$ A $ 为迎风面积。

  • 速度变化:
    $
    v(t) = \int \left( \frac{F_T}{m} - g - \frac{1}{2} C_D \rho v^2 A / m \right) dt
    $

  • 位置变化:
    $
    h(t) = \int v \, dt
    $


空速着陆阶段(Airspeed Landing)

  • 火箭在空速下降后,开始以空速着陆,速度逐渐减小。
  • 空气阻力与速度方向相反,需要考虑空气阻力的影响。
  • 火箭的姿态可能会随时间调整(例如通过控制舵面或推力矢量控制)。

相关公式:

  • 空气阻力:
    $
    F_D = \frac{1}{2} C_D \rho v^2 A
    $

  • 速度变化:
    $
    v(t) = \int \left( - g - \frac{1}{2} C_D \rho v^2 A / m \right) dt
    $

  • 位置变化:
    $
    h(t) = \int v \, dt
    $


着陆阶段(Landing)

  • 火箭在空速着陆后,开始以着陆速度着陆,速度逐渐减小。
  • 空气阻力与速度方向相反,需要考虑空气阻力的影响。

相关公式:

  • 空气阻力:
    $
    F_D = \frac{1}{2} C_D \rho v^2 A
    $

  • 速度变化:
    $
    v(t) = \int \left( - g - \frac{1}{2} C_D \rho v^2 A / m \right) dt
    $

  • 位置变化:
    $
    h(t) = \int v \, dt
    $


火箭六阶段运动仿真方程(刚体物理 + 空气动力学)

火箭模型假设

  • 几何形状: 圆柱 + 圆锥组合
  • 质心变化: 由于燃料燃烧,质心沿纵轴下降
  • 空气动力学: 考虑空气阻力、风力、重力、推力
  • 旋转动力学: 考虑火箭的角动量变化(绕质心旋转)

火箭模型参数

  • 质量: $ m(t) = m_0 - \dot{m} t $(线性减少,假设均匀燃烧)
  • 质心位置: $ r_c(t) $ 逐渐向下(圆锥部分燃尽后下降)
  • 惯性矩: $ I = I{cone} + I{cylinder} $(绕质心计算)
    • $ I{cone} = \frac{3}{10} m{cone} R^2 $
    • $ I{cylinder} = \frac{1}{2} m{cylinder} R^2 $
  • 空气阻力(沿速度方向): $ F_D = \frac{1}{2} C_D \rho v^2 A $
  • 风力作用: $ F_W = \frac{1}{2} C_L \rho v_w^2 A $,其中 $ C_L $ 是升力系数, $ v_w $ 是风速
  • 推力 $ F_T $ 的方向随火箭姿态变化: $ F_T = \dot{m} v_e $,其中 $ v_e $ 是喷射气体速度

六阶段运动方程

1. 发射阶段(Liftoff)

  • 火箭从地面垂直升起,初始倾角 $ \theta_0 $
  • 受推力、重力、空气阻力影响

平动方程(牛顿第二定律):

角动量方程(Euler方程):

2. 倾斜上升阶段(Inclined Ascent)

  • 火箭倾角 $ \theta $ 逐渐增大,风力影响显著
  • 受推力、重力、空气阻力、风力作用

平动方程:

角动量方程:

其中:

  • 风力矩: $ M_{\text{wind}} = r_c \times F_W $
  • 推力矩: $ M_{\text{thrust}} = d \times F_T $(假设推力偏离质心)

3. 重力转弯阶段(Gravity Turn)

  • 火箭逐渐由垂直转向水平
  • 主要受重力和空气阻力影响

角加速度方程:

4. 推进剂耗尽阶段(Burnout)

  • 推力消失,仅受重力和空气阻力影响

平动方程:

5. 自由飞行阶段(Free Flight)

  • 进入弹道飞行或轨道
  • 仅受重力和空气阻力作用

平动方程:

6. 降落阶段(Descent)

  • 考虑风力和空气阻力

平动方程:


XYZ 三轴运动方程

1. 三轴加速度

2. 三轴速度

3. 三轴位矢

程序初步仿真

本人还不是挺懂这个物理模型,所以就没有用具体的流体力学的粒子模型,而是用简单的空气阻力模型,所以可能和实际有误差。

这里很推荐一个plotly的库:
这个库可以将三维数据可视化,并且可以动态展示。
接口也很简单,可以参考这个链接
它还有其他很好玩的功能,我认为是现代matlab可视化的一个很好的替代品。

具体模拟程序如下:

利用了scipysolve_ivp函数,这个函数可以用来求解常微分方程,还有plotly库来可视化结果。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
import numpy as np
from scipy.integrate import solve_ivp
import plotly.graph_objects as go
from plotly.subplots import make_subplots

# ----------------------------
# 常量与参数设置
# ----------------------------
g = 9.81 # 重力加速度 (m/s^2)
rho = 1.225 # 海平面空气密度 (kg/m^3)
m0 = 20.0
m_final = 5.0 # 火箭初始/燃尽质量 (kg)
burn_time = 3.0 # 燃烧时间 (s)
m_dot_val = (m0 - m_final) / burn_time # 质量流失率 (kg/s)
v_e = 1500.0 # 有效排气速度 (m/s)
F_T_const = m_dot_val * v_e # 推力 (N) = m_dot * v_e
C_D = 0.75
diameter = 0.2 # 空气阻力系数与迎风面积
A = np.pi * (diameter/2)**2 # 迎风面积
v_w = np.array([-3.0, 4.0, 0.0]) # 风速 (m/s),例如:[-3, 4, 0] 表示在 x 负方向和 y 正方向上

# 发射角度设置:与正北夹角 87.4°,仰角 85°
azimuth_deg = 87.4
elevation_deg = 85.0
azimuth = np.deg2rad(azimuth_deg)
elevation = np.deg2rad(elevation_deg)

# 推力方向 (单位矢量),坐标:x正东、y正北、z正上
thrust_dir = np.array([
np.cos(elevation) * np.sin(azimuth),
np.cos(elevation) * np.cos(azimuth),
np.sin(elevation)
])
thrust_dir = thrust_dir / np.linalg.norm(thrust_dir)

# ----------------------------
# 定义火箭动力学模型(ODE)
# 状态变量: [x, y, z, vx, vy, vz, m]
# ----------------------------
def rocket_dynamics(t, state):
x, y, z, vx, vy, vz, m = state
vel = np.array([vx, vy, vz])
if t < burn_time:
F_thrust = F_T_const * thrust_dir
dm_dt = -m_dot_val
else:
F_thrust = np.array([0.0, 0.0, 0.0])
dm_dt = 0.0
v_rel = vel - v_w
v_rel_norm = np.linalg.norm(v_rel)
if v_rel_norm < 1e-6:
F_drag = np.array([0.0, 0.0, 0.0])
else:
F_drag = -0.5 * C_D * rho * v_rel_norm**2 * A * (v_rel / v_rel_norm)
F_gravity = np.array([0.0, 0.0, -m*g])
F_total = F_thrust + F_drag + F_gravity
accel = F_total / m

return [vx, vy, vz, accel[0], accel[1], accel[2], dm_dt]

# ----------------------------
# 定义事件函数:火箭落地(z <= 0)时终止积分
# ----------------------------
def hit_ground(t, state):
return state[2] # z 分量

hit_ground.terminal = True
hit_ground.direction = -1

# ----------------------------
# 初始条件与数值积分
# ----------------------------
initial_state = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, m0]
t_span = (0, 60)

sol = solve_ivp(rocket_dynamics, t_span, initial_state,
events=hit_ground, max_step=0.01, rtol=1e-8, atol=1e-8)

t_vals = sol.t
x_vals = sol.y[0]
y_vals = sol.y[1]
z_vals = sol.y[2]
vx_vals = sol.y[3]
vy_vals = sol.y[4]
vz_vals = sol.y[5]
m_vals = sol.y[6]

# 计算速度大小 speed(t)
speed_vals = np.sqrt(vx_vals**2 + vy_vals**2 + vz_vals**2)

# 计算加速度 (ax, ay, az) 以及加速度大小
acc_array = np.zeros((3, len(t_vals)))
for i in range(len(t_vals)):
dxdt = rocket_dynamics(t_vals[i], sol.y[:, i])
# dxdt = [vx, vy, vz, ax, ay, az, dm_dt]
acc_array[0, i] = dxdt[3]
acc_array[1, i] = dxdt[4]
acc_array[2, i] = dxdt[5]
acc_mag = np.sqrt(acc_array[0]**2 + acc_array[1]**2 + acc_array[2]**2)

print(f"仿真结束时间:{t_vals[-1]:.2f} s")
print(f"落地时火箭位置:x={x_vals[-1]:.2f} m, y={y_vals[-1]:.2f} m")
print(f"最远水平距离:{np.sqrt(x_vals[-1]**2 + y_vals[-1]**2):.2f} m")

# ----------------------------
# 准备 3D 轨迹图的 hover 信息 (位置、速度、加速度)
# ----------------------------
hover_texts = []
for i in range(len(t_vals)):
hover_texts.append(
f"time = {t_vals[i]:.2f} s<br>"
f"x = {x_vals[i]:.2f} m, y = {y_vals[i]:.2f} m, z = {z_vals[i]:.2f} m<br>"
f"vx = {vx_vals[i]:.2f}, vy = {vy_vals[i]:.2f}, vz = {vz_vals[i]:.2f} (m/s)<br>"
f"ax = {acc_array[0, i]:.2f}, ay = {acc_array[1, i]:.2f}, az = {acc_array[2, i]:.2f} (m/s^2)"
)

# ----------------------------
# 1) 绘制火箭 3D 轨迹图
# ----------------------------
fig3d = go.Figure(data=[go.Scatter3d(
x=x_vals, y=y_vals, z=z_vals,
mode='lines',
line=dict(
width=4,
color=speed_vals,
colorscale='Turbo',
cmin=0,
cmax=speed_vals.max(),
colorbar=dict(title='Speed (m/s)'),
showscale=True
),
text=hover_texts,
hoverinfo='text',
name='火箭轨迹'
)])
fig3d.update_layout(
title="火箭三维运动轨迹图",
scene=dict(
xaxis_title='x (正东方向)',
yaxis_title='y (正北方向)',
zaxis_title='z (竖直向上)'
),
width=800,
height=800
)

# ----------------------------
# 2) 绘制 x-t, y-t, z-t
# ----------------------------
fig_xyz = make_subplots(rows=3, cols=1,
subplot_titles=["x(t)", "y(t)", "z(t)"])
fig_xyz.add_trace(go.Scatter(x=t_vals, y=x_vals, mode='lines', name='x(t)'), row=1, col=1)
fig_xyz.add_trace(go.Scatter(x=t_vals, y=y_vals, mode='lines', name='y(t)'), row=2, col=1)
fig_xyz.add_trace(go.Scatter(x=t_vals, y=z_vals, mode='lines', name='z(t)'), row=3, col=1)

fig_xyz.update_layout(height=900, width=800, title_text="火箭位置随时间变化")
fig_xyz.update_xaxes(title_text="时间 (s)", row=3, col=1)
fig_xyz.update_yaxes(title_text="x (m)", row=1, col=1)
fig_xyz.update_yaxes(title_text="y (m)", row=2, col=1)
fig_xyz.update_yaxes(title_text="z (m)", row=3, col=1)

# ----------------------------
# 3) 绘制速度 (v-t) 图
# ----------------------------
fig_v = make_subplots(rows=4, cols=1,
subplot_titles=["vx(t)", "vy(t)", "vz(t)", "speed(t)"])
fig_v.add_trace(go.Scatter(x=t_vals, y=vx_vals, mode='lines', name='vx'), row=1, col=1)
fig_v.add_trace(go.Scatter(x=t_vals, y=vy_vals, mode='lines', name='vy'), row=2, col=1)
fig_v.add_trace(go.Scatter(x=t_vals, y=vz_vals, mode='lines', name='vz'), row=3, col=1)
fig_v.add_trace(go.Scatter(x=t_vals, y=speed_vals, mode='lines', name='|v|'), row=4, col=1)

fig_v.update_layout(height=900, width=800, title_text="火箭速度随时间变化")
fig_v.update_xaxes(title_text="时间 (s)", row=4, col=1)
fig_v.update_yaxes(title_text="速度 (m/s)", row=1, col=1)
fig_v.update_yaxes(title_text="速度 (m/s)", row=2, col=1)
fig_v.update_yaxes(title_text="速度 (m/s)", row=3, col=1)
fig_v.update_yaxes(title_text="速度 (m/s)", row=4, col=1)

# ----------------------------
# 4) 绘制加速度 (a-t) 图
# ----------------------------
fig_a = make_subplots(rows=4, cols=1,
subplot_titles=["ax(t)", "ay(t)", "az(t)", "acc magnitude(t)"])
fig_a.add_trace(go.Scatter(x=t_vals, y=acc_array[0], mode='lines', name='ax'), row=1, col=1)
fig_a.add_trace(go.Scatter(x=t_vals, y=acc_array[1], mode='lines', name='ay'), row=2, col=1)
fig_a.add_trace(go.Scatter(x=t_vals, y=acc_array[2], mode='lines', name='az'), row=3, col=1)
fig_a.add_trace(go.Scatter(x=t_vals, y=acc_mag, mode='lines', name='|a|'), row=4, col=1)

fig_a.update_layout(height=900, width=800, title_text="火箭加速度随时间变化")
fig_a.update_xaxes(title_text="时间 (s)", row=4, col=1)
fig_a.update_yaxes(title_text="加速度 (m/s^2)", row=1, col=1)
fig_a.update_yaxes(title_text="加速度 (m/s^2)", row=2, col=1)
fig_a.update_yaxes(title_text="加速度 (m/s^2)", row=3, col=1)
fig_a.update_yaxes(title_text="加速度 (m/s^2)", row=4, col=1)

# ----------------------------
# 显示图像
# ----------------------------
fig3d.show()
fig_xyz.show()
fig_v.show()
fig_a.show()

其流程图如下:

flowchart TD
    B[定义常量与参数] --> C[定义火箭动力学模型]
    C --> D[定义事件函数]
    D --> E[设置初始条件]
    E --> F[数值积分求解]
    F --> G[提取仿真结果]
    G --> H[计算速度和加速度]
    H --> I[绘制图表]
    I --> J[显示图像]

该程序的缺点:

  1. 没有考虑火箭的旋转,所以火箭的飞行轨迹是直线,没有倾斜。
  2. 落地事件未考虑地形或其他障碍物的影响。如果火箭在仿真时间内未落地,程序会继续运行到最大时间,可能导致不必要的计算。
  3. 3D 轨迹图仅显示火箭的路径,未显示其他信息(如推力方向、风速等)
  4. 未提供动画功能,无法直观展示火箭的运动过程。
  5. 未考虑火箭开伞时的降落过程。

提升空间:

  1. 添加火箭旋转模型,使火箭的飞行轨迹更加真实,并考虑火箭开伞时的降落过程,使仿真更加准确。
  2. 添加其他信息(如推力方向、风速等)到 3D 轨迹图中,使图表更加直观。
  3. 添加动画功能,使火箭的运动过程更加直观。
  4. 加入RK45积分方法,提高积分精度,并加入实时轨迹更新功能,以及加入统计学的预测模型,对火箭的飞行轨迹进行预测。

2025

03-11

更新了基于node.js的前端页面,让用户输入更可视化。(至于为什么之前我不写到blog上或者发布到GitHub上,是因为没时间啊!今天(3月30号)才想起这事)

更新的代码

结构:
rock-sim/
├── static/
│ ├── index.css
│ ├── index.html
│ └── simulation.js
├── package-lock.json
├── package.json
├── rocket_sim.py
└── server.js

下面是具体的代码:

server.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/**
* server.js
* 使用 Express 提供静态页面,同时定义 /simulate 接口调用 Python 脚本,
* 将火箭仿真数据(JSON 格式)返回给前端。
*/
const express = require('express');
const { spawn } = require('child_process');
const path = require('path');

const app = express();
app.use(express.json());

// 提供 static 目录下的静态文件
app.use(express.static(path.join(__dirname, 'static')));

app.post('/simulate', (req, res) => {
// 从请求中获取参数
const {
m0,
m_final,
burn_time,
v_e,
C_D,
diameter,
azimuth_deg,
elevation_deg,
wind_x,
wind_y,
wind_z,
total_time
} = req.body;

// 将参数依次传入 Python 脚本
const pyArgs = [
String(m0),
String(m_final),
String(burn_time),
String(v_e),
String(C_D),
String(diameter),
String(azimuth_deg),
String(elevation_deg),
String(wind_x),
String(wind_y),
String(wind_z),
String(total_time)
];

// 调用 Python 脚本 rocket_sim.py
const pyProcess = spawn('python', [path.join(__dirname, 'rocket_sim.py'), ...pyArgs]);

let outputData = '';
let errorData = '';

pyProcess.stdout.on('data', (data) => {
outputData += data.toString();
});
pyProcess.stderr.on('data', (data) => {
errorData += data.toString();
});
pyProcess.on('close', (code) => {
if (code !== 0) {
console.error('Python script error:', errorData);
return res.status(500).json({ error: errorData || 'Python script failed' });
}
try {
const result = JSON.parse(outputData);
res.json(result);
} catch (err) {
console.error('JSON parse error:', err);
res.status(500).json({ error: 'Invalid JSON output from Python' });
}
});
});

// 启动服务器
const PORT = 3000;
app.listen(PORT, () => {
console.log(`Server started on http://localhost:${PORT}`);
});

rocket_sim.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
rocket_sim.py
-------------
命令行参数顺序:
m0, m_final, burn_time, v_e, C_D, diameter, azimuth_deg, elevation_deg, wind_x, wind_y, wind_z, total_time
如果未传入参数,则使用默认值:
20.0, 5.0, 3.0, 1500.0, 0.75, 0.2, 87.4, 85.0, -3.0, 4.0, 0.0, 60.0
输出 JSON 数据,包含:
t_vals, x_vals, y_vals, z_vals, vx_vals, vy_vals, vz_vals, speed_vals,
acc_array (二维列表: [ax_vals, ay_vals, az_vals]), acc_mag
"""

import sys
import json
import numpy as np
from scipy.integrate import solve_ivp

def simulate_rocket(m0, m_final, burn_time, v_e, C_D, diameter,
azimuth_deg, elevation_deg, wind_vector, total_time):
g = 9.81 # 重力加速度 (m/s^2)
rho = 1.225 # 空气密度 (kg/m^3)

# 计算燃料流失率与推力(简化公式 F = m_dot * v_e)
m_dot_val = (m0 - m_final) / burn_time
F_T_const = m_dot_val * v_e

# 迎风面积(火箭截面面积)
A = np.pi * (diameter / 2)**2

# 推力方向:由发射角度(水平投影与正北夹角)和仰角决定
azimuth = np.deg2rad(azimuth_deg)
elevation = np.deg2rad(elevation_deg)
thrust_dir = np.array([
np.cos(elevation) * np.sin(azimuth),
np.cos(elevation) * np.cos(azimuth),
np.sin(elevation)
])
thrust_dir = thrust_dir / np.linalg.norm(thrust_dir)

v_w = np.array(wind_vector)

def rocket_dynamics(t, state):
x, y, z, vx, vy, vz, m = state
vel = np.array([vx, vy, vz])
if t < burn_time:
F_thrust = F_T_const * thrust_dir
dm_dt = -m_dot_val
else:
F_thrust = np.array([0.0, 0.0, 0.0])
dm_dt = 0.0
v_rel = vel - v_w
v_rel_norm = np.linalg.norm(v_rel)
if v_rel_norm < 1e-6:
F_drag = np.array([0.0, 0.0, 0.0])
else:
F_drag = -0.5 * C_D * rho * (v_rel_norm**2) * A * (v_rel / v_rel_norm)
F_gravity = np.array([0.0, 0.0, -m * g])
F_total = F_thrust + F_drag + F_gravity
accel = F_total / m
return [vx, vy, vz, accel[0], accel[1], accel[2], dm_dt]

# 落地事件:当 z 从正变负时触发
def hit_ground(t, state):
return state[2]
hit_ground.terminal = True
hit_ground.direction = -1

initial_state = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, m0]
sol = solve_ivp(rocket_dynamics, (0, total_time), initial_state,
events=hit_ground, max_step=0.01, rtol=1e-8, atol=1e-8)

t_vals = sol.t.tolist()
x_vals = sol.y[0].tolist()
y_vals = sol.y[1].tolist()
z_vals = sol.y[2].tolist()
vx_vals = sol.y[3].tolist()
vy_vals = sol.y[4].tolist()
vz_vals = sol.y[5].tolist()

# 合速度
speed_vals = (np.sqrt(sol.y[3]**2 + sol.y[4]**2 + sol.y[5]**2)).tolist()

# 计算加速度:遍历每个时刻
n = len(t_vals)
ax_vals = []
ay_vals = []
az_vals = []
for i in range(n):
deriv = rocket_dynamics(t_vals[i], sol.y[:, i])
ax_vals.append(deriv[3])
ay_vals.append(deriv[4])
az_vals.append(deriv[5])
acc_mag = (np.sqrt(np.array(ax_vals)**2 + np.array(ay_vals)**2 + np.array(az_vals)**2)).tolist()

# 返回字典,注意把 numpy 数组转为普通列表
return {
"t_vals": t_vals,
"x_vals": x_vals,
"y_vals": y_vals,
"z_vals": z_vals,
"vx_vals": vx_vals,
"vy_vals": vy_vals,
"vz_vals": vz_vals,
"speed_vals": speed_vals,
"acc_array": [ax_vals, ay_vals, az_vals],
"acc_mag": acc_mag
}

def main():
# 如果命令行参数不足,则使用默认值
if len(sys.argv) < 13:
m0 = 20.0
m_final = 5.0
burn_time = 3.0
v_e = 1500.0
C_D = 0.75
diameter = 0.2
azimuth_deg = 87.4
elevation_deg = 85.0
wind_vector = [-3.0, 4.0, 0.0]
total_time = 60.0
else:
m0 = float(sys.argv[1])
m_final = float(sys.argv[2])
burn_time = float(sys.argv[3])
v_e = float(sys.argv[4])
C_D = float(sys.argv[5])
diameter = float(sys.argv[6])
azimuth_deg = float(sys.argv[7])
elevation_deg = float(sys.argv[8])
wind_x = float(sys.argv[9])
wind_y = float(sys.argv[10])
wind_z = float(sys.argv[11])
total_time = float(sys.argv[12])
wind_vector = [wind_x, wind_y, wind_z]

sim_data = simulate_rocket(m0, m_final, burn_time, v_e, C_D, diameter,
azimuth_deg, elevation_deg, wind_vector, total_time)
# 输出 JSON 数据
print(json.dumps(sim_data))

if __name__ == "__main__":
main()

package.json

1
2
3
4
5
6
7
8
9
10
11
12
{
"name": "rocket-sim",
"version": "1.0.0",
"description": "Rocket simulation using Node.js + Python + Plotly",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"express": "^4.18.2"
}
}

package-lock.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
{
"name": "rocket-sim",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "rocket-sim",
"version": "1.0.0",
"dependencies": {
"express": "^4.18.2"
}
},
"node_modules/accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
"license": "MIT",
"dependencies": {
"mime-types": "~2.1.34",
"negotiator": "0.6.3"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
"license": "MIT"
},
"node_modules/body-parser": {
"version": "1.20.3",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz",
"integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==",
"license": "MIT",
"dependencies": {
"bytes": "3.1.2",
"content-type": "~1.0.5",
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "1.2.0",
"http-errors": "2.0.0",
"iconv-lite": "0.4.24",
"on-finished": "2.4.1",
"qs": "6.13.0",
"raw-body": "2.5.2",
"type-is": "~1.6.18",
"unpipe": "1.0.0"
},
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/call-bind-apply-helpers": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/call-bound": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
"integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"get-intrinsic": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/content-disposition": {
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
"license": "MIT",
"dependencies": {
"safe-buffer": "5.2.1"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/content-type": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie": {
"version": "0.7.1",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz",
"integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie-signature": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
"integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==",
"license": "MIT"
},
"node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"license": "MIT",
"dependencies": {
"ms": "2.0.0"
}
},
"node_modules/depd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/destroy": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
"license": "MIT",
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.1",
"es-errors": "^1.3.0",
"gopd": "^1.2.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
"license": "MIT"
},
"node_modules/encodeurl": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/es-define-property": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-errors": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-object-atoms": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
"license": "MIT"
},
"node_modules/etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/express": {
"version": "4.21.2",
"resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz",
"integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==",
"license": "MIT",
"dependencies": {
"accepts": "~1.3.8",
"array-flatten": "1.1.1",
"body-parser": "1.20.3",
"content-disposition": "0.5.4",
"content-type": "~1.0.4",
"cookie": "0.7.1",
"cookie-signature": "1.0.6",
"debug": "2.6.9",
"depd": "2.0.0",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"finalhandler": "1.3.1",
"fresh": "0.5.2",
"http-errors": "2.0.0",
"merge-descriptors": "1.0.3",
"methods": "~1.1.2",
"on-finished": "2.4.1",
"parseurl": "~1.3.3",
"path-to-regexp": "0.1.12",
"proxy-addr": "~2.0.7",
"qs": "6.13.0",
"range-parser": "~1.2.1",
"safe-buffer": "5.2.1",
"send": "0.19.0",
"serve-static": "1.16.2",
"setprototypeof": "1.2.0",
"statuses": "2.0.1",
"type-is": "~1.6.18",
"utils-merge": "1.0.1",
"vary": "~1.1.2"
},
"engines": {
"node": ">= 0.10.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/finalhandler": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz",
"integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==",
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"on-finished": "2.4.1",
"parseurl": "~1.3.3",
"statuses": "2.0.1",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/fresh": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/function-bind": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-intrinsic": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"es-define-property": "^1.0.1",
"es-errors": "^1.3.0",
"es-object-atoms": "^1.1.1",
"function-bind": "^1.1.2",
"get-proto": "^1.0.1",
"gopd": "^1.2.0",
"has-symbols": "^1.1.0",
"hasown": "^2.0.2",
"math-intrinsics": "^1.1.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
"license": "MIT",
"dependencies": {
"dunder-proto": "^1.0.1",
"es-object-atoms": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/gopd": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-symbols": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/hasown": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
"license": "MIT",
"dependencies": {
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/http-errors": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
"integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==",
"license": "MIT",
"dependencies": {
"depd": "2.0.0",
"inherits": "2.0.4",
"setprototypeof": "1.2.0",
"statuses": "2.0.1",
"toidentifier": "1.0.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"license": "ISC"
},
"node_modules/ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
"license": "MIT",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/math-intrinsics": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/merge-descriptors": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
"integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"license": "MIT",
"bin": {
"mime": "cli.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"license": "MIT",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
"license": "MIT"
},
"node_modules/negotiator": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/object-inspect": {
"version": "1.13.4",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
"integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/on-finished": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
"license": "MIT",
"dependencies": {
"ee-first": "1.1.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/path-to-regexp": {
"version": "0.1.12",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz",
"integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==",
"license": "MIT"
},
"node_modules/proxy-addr": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
"integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
"license": "MIT",
"dependencies": {
"forwarded": "0.2.0",
"ipaddr.js": "1.9.1"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/qs": {
"version": "6.13.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz",
"integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==",
"license": "BSD-3-Clause",
"dependencies": {
"side-channel": "^1.0.6"
},
"engines": {
"node": ">=0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/raw-body": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz",
"integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
"license": "MIT",
"dependencies": {
"bytes": "3.1.2",
"http-errors": "2.0.0",
"iconv-lite": "0.4.24",
"unpipe": "1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"license": "MIT"
},
"node_modules/send": {
"version": "0.19.0",
"resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz",
"integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==",
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "1.2.0",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"fresh": "0.5.2",
"http-errors": "2.0.0",
"mime": "1.6.0",
"ms": "2.1.3",
"on-finished": "2.4.1",
"range-parser": "~1.2.1",
"statuses": "2.0.1"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/send/node_modules/encodeurl": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
"integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/send/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
},
"node_modules/serve-static": {
"version": "1.16.2",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz",
"integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==",
"license": "MIT",
"dependencies": {
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"parseurl": "~1.3.3",
"send": "0.19.0"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/setprototypeof": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
"license": "ISC"
},
"node_modules/side-channel": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",
"integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.3",
"side-channel-list": "^1.0.0",
"side-channel-map": "^1.0.1",
"side-channel-weakmap": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-list": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz",
"integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-map": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
"integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-weakmap": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
"integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3",
"side-channel-map": "^1.0.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/statuses": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
"integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/toidentifier": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
"license": "MIT",
"engines": {
"node": ">=0.6"
}
},
"node_modules/type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
"license": "MIT",
"dependencies": {
"media-typer": "0.3.0",
"mime-types": "~2.1.24"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
"license": "MIT",
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
}
}
}

index.css

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
.navbar {
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.section {
padding: 3rem 1.5rem;
}

.box {
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
transition: box-shadow 0.3s ease;
}

.box:hover {
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.button.is-primary {
transition: background-color 0.3s ease;
}

.button.is-primary:hover {
background-color: #3273dc;
}

.plot-container {
margin-top: 2rem;
}

/* 仿真结果部分样式 */
.section {
background-color: #f8f9fa;
padding: 4rem 1.5rem;
}

.section .title.is-2 {
color: #363636;
margin-bottom: 2rem;
text-align: center;
font-weight: bold;
}

.plot-container {
background-color: white;
border-radius: 10px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
margin-bottom: 2rem;
padding: 1.5rem;
transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.plot-container:hover {
transform: translateY(-5px); /* 悬停时轻微上移 */
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2); /* 悬停时阴影加深 */
}

/* 图表容器的内联样式保留,确保图表尺寸不变 */
.plot-container > div {
width: 100% !important;
height: auto;
}

@media (max-width: 768px) {
.section {
padding: 2rem 1rem; /* 小屏幕下减少内边距 */
}

.plot-container {
padding: 1rem;
}

#plot3d {
height: 500px !important;
}

#plotXYZ,
#plotV,
#plotA {
height: 400px !important;
}
}

index.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>火箭仿真</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css">
<link rel="stylesheet" href="index.css">
<script src="https://cdn.plot.ly/plotly-2.18.2.min.js"></script>
</head>
<body>
<nav class="navbar is-primary" role="navigation" aria-label="main navigation">
<div class="container">
<div class="navbar-brand">
<a class="navbar-item">
<h1 class="title is-3 has-text-white">火箭仿真演示</h1>
</a>
</div>
</div>
</nav>

<section class="section">
<div class="container">
<h1 class="title">输入参数,点击「开始仿真」</h1>
<form id="simForm" class="box">
<div class="columns">
<div class="column">
<div class="field">
<label class="label">初始质量 (kg)</label>
<div class="control">
<input class="input" type="number" id="m0" value="20.0" required>
</div>
</div>
<div class="field">
<label class="label">燃烧后质量 (kg)</label>
<div class="control">
<input class="input" type="number" id="m_final" value="5.0" required>
</div>
</div>
<div class="field">
<label class="label">燃烧时间 (s)</label>
<div class="control">
<input class="input" type="number" id="burn_time" value="3.0" required>
</div>
</div>
<div class="field">
<label class="label">排气速度 (m/s)</label>
<div class="control">
<input class="input" type="number" id="v_e" value="1500" required>
</div>
</div>
</div>
<div class="column">
<div class="field">
<label class="label">阻力系数 C_D</label>
<div class="control">
<input class="input" type="number" step="0.01" id="C_D" value="0.75" required>
</div>
</div>
<div class="field">
<label class="label">火箭直径 (m)</label>
<div class="control">
<input class="input" type="number" step="0.01" id="diameter" value="0.2" required>
</div>
</div>
<div class="field">
<label class="label">方位角 (°) <small>(与正北夹角)</small></label>
<div class="control">
<input class="input" type="number" id="azimuth_deg" value="87.4" required>
</div>
</div>
<div class="field">
<label class="label">仰角 (°)</label>
<div class="control">
<input class="input" type="number" id="elevation_deg" value="85" required>
</div>
</div>
</div>
<div class="column">
<div class="field">
<label class="label">xyz方向风速 (m/s)</label>
<label class="label">x正东、y正北、z正上</label>
<div class="field has-addons">
<div class="control">
<input class="input" type="number" id="wind_x" value="-3.0" required>
</div>
<div class="control">
<input class="input" type="number" id="wind_y" value="4.0" required>
</div>
<div class="control">
<input class="input" type="number" id="wind_z" value="0.0" required>
</div>
</div>
</div>
<div class="field">
<label class="label">仿真总时长 (s)</label>
<div class="control">
<input class="input" type="number" id="total_time" value="60" required>
</div>
</div>
<div class="field">
<div class="control">
<button class="button is-primary is-fullwidth" type="submit">开始仿真</button>
</div>
</div>
</div>
</div>
</form>
</div>
</section>

<section class="section">
<div class="container">
<h2 class="title is-2">仿真结果</h2>
<div class="plot-container">
<div id="plot3d" style="width: 100%; height: 800px;"></div>
</div>
<div class="plot-container">
<div id="plotXYZ" style="width: 100%; height: 600px;"></div>
</div>
<div class="plot-container">
<div id="plotV" style="width: 100%; height: 600px;"></div>
</div>
<div class="plot-container">
<div id="plotA" style="width: 100%; height: 600px;"></div>
</div>
</div>
</section>

<script src="simulation.js"></script>
</body>
</html>

simulation.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
document.getElementById('simForm').addEventListener('submit', async function (e) {
e.preventDefault();

// 获取输入参数
const m0 = parseFloat(document.getElementById('m0').value);
const m_final = parseFloat(document.getElementById('m_final').value);
const burn_time = parseFloat(document.getElementById('burn_time').value);
const v_e = parseFloat(document.getElementById('v_e').value);
const C_D = parseFloat(document.getElementById('C_D').value);
const diameter = parseFloat(document.getElementById('diameter').value);
const azimuth_deg = parseFloat(document.getElementById('azimuth_deg').value);
const elevation_deg = parseFloat(document.getElementById('elevation_deg').value);
const wind_x = parseFloat(document.getElementById('wind_x').value);
const wind_y = parseFloat(document.getElementById('wind_y').value);
const wind_z = parseFloat(document.getElementById('wind_z').value);
const total_time = parseFloat(document.getElementById('total_time').value);

try {
const resp = await fetch('/simulate', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
m0, m_final, burn_time, v_e, C_D, diameter,
azimuth_deg, elevation_deg,
wind_x, wind_y, wind_z,
total_time
})
});
const data = await resp.json();
const t_vals = data.t_vals;
const x_vals = data.x_vals;
const y_vals = data.y_vals;
const z_vals = data.z_vals;
const vx_vals = data.vx_vals;
const vy_vals = data.vy_vals;
const vz_vals = data.vz_vals;
const speed_vals = data.speed_vals;
const acc_array = data.acc_array; // acc_array[0]: ax, [1]: ay, [2]: az
const acc_mag = data.acc_mag;

// 1) 绘制 3D 轨迹图(颜色按速度大小着色)
const trace3d = {
x: x_vals,
y: y_vals,
z: z_vals,
mode: 'lines',
type: 'scatter3d',
line: {
width: 4,
color: speed_vals,
colorscale: 'Jet', // 可改成 'Viridis', 'Turbo' 等
cmin: 0,
cmax: Math.max(...speed_vals),
colorbar: { title: 'Speed (m/s)' },
showscale: true
},
text: x_vals.map((x, i) =>
`t=${t_vals[i].toFixed(2)} s<br>x=${x.toFixed(2)} m, y=${y_vals[i].toFixed(2)} m, z=${z_vals[i].toFixed(2)} m<br>vx=${vx_vals[i].toFixed(2)}, vy=${vy_vals[i].toFixed(2)}, vz=${vz_vals[i].toFixed(2)}`
),
hoverinfo: 'text',
name: '火箭轨迹'
};
const layout3d = {
title: '火箭三维轨迹图',
scene: {
xaxis: { title: 'x East(m)' },
yaxis: { title: 'y North(m)' },
zaxis: { title: 'z Vertical upwards(m)' }
}
};
Plotly.newPlot('plot3d', [trace3d], layout3d);

// 2) 绘制 x-t, y-t, z-t 图(独立显示)
const traceX = { x: t_vals, y: x_vals, mode: 'lines', name: 'x(t)' };
const traceY = { x: t_vals, y: y_vals, mode: 'lines', name: 'y(t)' };
const traceZ = { x: t_vals, y: z_vals, mode: 'lines', name: 'z(t)' };
const layoutXYZ = {
title: '位置随时间变化',
height: 600,
xaxis: { title: 'Time (s)' },
yaxis: { title: 'Position (m)' }
};
Plotly.newPlot('plotXYZ', [traceX, traceY, traceZ], layoutXYZ);

// 3) 绘制速度图:vx, vy, vz, |v|(独立显示)
const traceVx = { x: t_vals, y: vx_vals, mode: 'lines', name: 'vx(t)' };
const traceVy = { x: t_vals, y: vy_vals, mode: 'lines', name: 'vy(t)' };
const traceVz = { x: t_vals, y: vz_vals, mode: 'lines', name: 'vz(t)' };
const traceSpeed = { x: t_vals, y: speed_vals, mode: 'lines', name: '|v|(t)' };
const layoutV = {
title: '速度随时间变化',
height: 600,
xaxis: { title: 'Time (s)' },
yaxis: { title: 'Speed (m/s)' }
};
Plotly.newPlot('plotV', [traceVx, traceVy, traceVz, traceSpeed], layoutV);

// 4) 绘制加速度图:ax, ay, az, |a|(独立显示)
const traceAx = { x: t_vals, y: acc_array[0], mode: 'lines', name: 'ax(t)' };
const traceAy = { x: t_vals, y: acc_array[1], mode: 'lines', name: 'ay(t)' };
const traceAz = { x: t_vals, y: acc_array[2], mode: 'lines', name: 'az(t)' };
const traceA = { x: t_vals, y: acc_mag, mode: 'lines', name: '|a|(t)' };
const layoutA = {
title: '加速度随时间变化',
height: 600,
xaxis: { title: 'Time (s)' },
yaxis: { title: 'Acceleration (m/s²)' }
};
Plotly.newPlot('plotA', [traceAx, traceAy, traceAz, traceA], layoutA);
} catch (err) {
console.error('仿真出错:', err);
alert('仿真失败,请查看控制台日志。');
}
});

提示:

  • 首先在终端中运行 node server.js 启动服务器。具体步骤如下:
    1. 在终端中进入项目目录。
    2. 运行 npm install 安装依赖。
    3. 运行 npm start 启动服务器。
  • 然后在浏览器中打开npm给你的本地服务器地址(通常是 http://localhost:3000)。

需要注意的是,需要安装以下py的库:

  • numpy
  • scipy
  • matplotlib
  • plotly