一段简单的MATLAB代码实现初步的火箭发射架长度计算,便于初步选取火箭初始推重比。
探空火箭通常是无主动控制、气动稳定的火箭,出架速度对于火箭发射的稳定很重要,通常取30-40m/s,且出架速度和发射架长度正相关,但由于运输、制造限制,发射架并不能做的过长,所以需要仔细权衡推重比和发射架长度的关系(对于液体火箭更为严峻,出于总体性能考虑,推重比不能做很大)。于是编写的以下简单代码实现初步选取:
由于火箭发射架长度相对于整个弹道很短,因此不考虑空气密度变化、不考虑阻力系数变化。
% 参数设置 mass_initial = 25; % 初始火箭质量 (kg) thrust = 1500; % 发动机推力 (N) drag_coefficient = 0.32; % 阻力系数 diameter = 0.16; % 火箭直径 (m) area = pi * (diameter / 2)^2; % 火箭迎风面积 (m^2) air_density = 1.225; % 空气密度 (kg/m^3) g = 9.81; % 重力加速度 (m/s^2) min_exit_velocity = 30; % 预设最小出架速度 (m/s) mass_flow_rate = 0.5; % 发动机质量流量 (kg/s) % 初始条件 velocity_initial = 0; % 初始速度 (m/s) time_step = 0.01; % 时间步长 (s) min_rail_length = 6; % 最小发射架长度 (m) max_rail_length = 12; % 最大发射架长度 (m) rail_step = 0.1; % 发射架长度步长 (m) % 记录结果 rail_lengths = min_rail_length:rail_step:max_rail_length; exit_velocities = zeros(size(rail_lengths)); exit_times = zeros(size(rail_lengths)); found = false; % 记录是否找到满足条件的发射架长度 optimal_rail_length = inf; % 最优发射架长度初始化 % 发射架长度迭代计算 for i = 1:length(rail_lengths) rail_length = rail_lengths(i); velocity = velocity_initial; position = 0; time = 0; mass = mass_initial; % 重置初始质量
% 使用数值积分方法计算速度 while position < rail_length drag = 0.5 air_density velocity^2 drag_coefficient area; acceleration = (thrust - drag - mass * g) / mass; velocity = velocity + acceleration * time_step; position = position + velocity * time_step; time = time + time_step; mass = mass_initial - mass_flow_rate * time; % 更新质量 end
% 记录当前发射架长度下的出架速度和时间 exit_velocities(i) = velocity; exit_times(i) = time;
% 检查是否满足预设最小出架速度 if velocity >= min_exit_velocity && ~found % 输出最短发射架长度 fprintf('达到 %.2f m/s 的最短发射架长度: %.2f m\n', min_exit_velocity, rail_length); fprintf('最优发射架长度 %.2f m 对应的出架时间: %.2f s\n', rail_length, time); optimal_rail_length = rail_length; % 记录最优发射架长度 optimal_velocity = velocity; % 记录最优速度 optimal_time = time; % 记录最优时间 found = true; % 找到满足条件的发射架长度 end end % 报错处理 if ~found error('没有找到满足预设最小出架速度的发射架长度,请调整参数范围。'); end % 绘制发射架长度与出架速度关系图,并平滑曲线 smooth_exit_velocities = smooth(exit_velocities); hFig = figure; subplot(2,1,1); plot(rail_lengths, smooth_exit_velocities, 'LineWidth', 1, 'Color', [246/255, 0, 254/255]); hold on; plot(optimal_rail_length, optimal_velocity, 'go', 'MarkerSize', 5, 'LineWidth', 2); % 标记最优点 hold off; xlabel('发射架长度 (m)', 'FontSize', 12); ylabel('出架速度 (m/s)', 'FontSize', 12); title('发射架长度与出架速度的关系 ', 'FontSize', 14); grid on; % 绘制发射架长度与出架时间关系图 smooth_exit_times = smooth(exit_times); subplot(2,1,2); plot(rail_lengths, smooth_exit_times, 'LineWidth', 1, 'Color', [0, 100/255, 0.8]); hold on; plot(optimal_rail_length, optimal_time, 'go', 'MarkerSize', 5, 'LineWidth', 2); % 标记最优点 hold off; xlabel('发射架长度 (m)', 'FontSize', 12); ylabel('出架时间 (s)', 'FontSize', 12); title('发射架长度与出架时间的关系', 'FontSize', 14); grid on; |
可直接拷贝到MATLAB中运行。
由于未经飞行验证,计算结果请谨慎对待,欢迎指出问题。