





rho_e = 1620;
R = 337;
chi = 0.98;
varphi1 = 0.95;
gamma = 1.3;
D_id = 0.0025;
R_ex = 0.025;
a = 0.009 * 1e-2;
b = 0.05 * 1e-2;
n = 1;
T = 3400;
p0 = 2e6;
rho0 = p0 / (R * T);
e0 = 0;
V0 = pi * (R_ex/2)^2 * D_id;
y0 = [V0; e0; rho0; p0];
diameters = [0.002, 0.005, 0.010, 0.08];
colors = ['r', 'g', 'b', 'm'];
labels = {'2mm', '5mm', '10mm', '15mm'};
figure('Color','w','Position',[100,100,900,500]);
hold on; grid on;
results = cell(length(diameters), 1);
for i = 1:length(diameters)
A_t = pi * (diameters(i)/2)^2;
tspan = [0, 0.1];
options = odeset('RelTol',1e-6,'AbsTol',1e-8,'NonNegative',[1,2,3,4]);
try
[t, y] = ode45(@(t,y) combustion_ode_paper(t,y,rho_e,R,chi,varphi1,gamma,D_id,R_ex,A_t,a,b,n,T), ...
tspan, y0, options);
p = y(:,4)/1e6;
plot(t, p, ['-', colors(i)], 'LineWidth',1.5, 'DisplayName', labels{i});
results{i} = struct('t', t, 'p', p, 'diameter', diameters(i));
catch ME
warning('直径 %.3f m 计算失败: %s', diameters(i), ME.message);
end
end
xlabel('时间 (s)','FontSize',12);
ylabel('压力 (MPa)','FontSize',12);
title('不同泄压孔直径下TNT密闭燃烧压力变化曲线(论文公式)','FontSize',14);
legend('Location','best','FontSize',10);
ylim([0, 100]);
xlim([0, 10]);
yline(90, 'k--', 'LineWidth', 1.5, 'DisplayName', '安全阈值(90MPa)');
set(gca,'FontSize',10);
grid on;
fprintf('\n=== 安全阈值分析 (90MPa) ===\n');
for i = 1:length(results)
if ~isempty(results{i})
max_p = max(results{i}.p);
is_safe = max_p < 90;
status = '安全';
if ~is_safe
status = '危险(可能爆炸)';
end
fprintf('直径 %.1f mm: 最大压力 = %.2f MPa, 状态: %s\n', ...
diameters(i)*1000, max_p, status);
end
end
if exist('results', 'var') && ~isempty(results)
figure('Color','w','Position',[100,100,1200,400]);
subplot(1,2,1);
hold on; grid on;
for i = 1:length(results)
if ~isempty(results{i})
t = results{i}.t;
e = interp1(results{1}.t, results{1}.y(:,2), t);
A_b = pi * D_id * (R_ex + 2*e);
plot(t, A_b, ['-', colors(i)], 'LineWidth',1.5, 'DisplayName', labels{i});
end
end
xlabel('时间 (s)','FontSize',12);
ylabel('燃烧面积 (m²)','FontSize',12);
title('燃烧面积随时间变化','FontSize',14);
legend('Location','best','FontSize',10);
subplot(1,2,2);
hold on; grid on;
for i = 1:length(results)
if ~isempty(results{i})
t = results{i}.t;
e = interp1(results{1}.t, results{1}.y(:,2), t);
plot(t, e*1000, ['-', colors(i)], 'LineWidth',1.5, 'DisplayName', labels{i});
end
end
xlabel('时间 (s)','FontSize',12);
ylabel('已燃厚度 (mm)','FontSize',12);
title('已燃厚度随时间变化','FontSize',14);
legend('Location','best','FontSize',10);
end
function dydt = combustion_ode_paper(~, y, rho_e, R, chi, varphi1, gamma, D_id, R_ex, A_t, a, b, n, T)
V1 = y(1);
e = y(2);
rho1 = y(3);
p1 = y(4);
A_b = pi * D_id * (R_ex + 2*e);
u_e = a + b * p1^n;
m_dot_in = rho_e * A_b * u_e;
term1 = sqrt(gamma / (R * T));
term2 = (2 / (gamma + 1))^((gamma + 1) / (2 * (gamma - 1)));
m_dot_out = varphi1 * A_t * p1 * term1 * term2;
drho1_dt = (rho_e * A_b * u_e - m_dot_out) / V1;
energy_in = m_dot_in * R * chi * T * gamma;
energy_out_term = p1 * ((gamma+1)/2) * (1/(gamma-1)) * ...
sqrt(2*gamma*R*T/(gamma+1)) * varphi1 * gamma * R * T * A_t;
dp1_dt = (energy_in - energy_out_term) / V1;
dV1_dt = A_b * u_e;
de_dt = u_e;
dydt = [dV1_dt; de_dt; drho1_dt; dp1_dt];
dydt(3) = max(dydt(3), -rho1/1e-3);
dydt(4) = max(dydt(4), -p1/1e-3);
dydt(1) = max(dydt(1), 0);
dydt(2) = max(dydt(2), 0);
end