Marty Seamus
S:22:57:06 25.12
R:00:00:00 00.00
👨💻 • step);
%% 5. Построение графиков
% График 1: Закон движения поршня
figure('Name', 'Piston Motion', 'Color', 'w', 'Position', [100 100 1000 600]);
subplot(2,1,1);
plot(hist_t, hist_xp, 'LineWidth', 1.5, 'Color', 'b');
hold on;
yline(x_p_min, '--r', 'LineWidth', 1, 'DisplayName', 'Границы');
yline(x_p_max, '--r', 'LineWidth', 1);
hold off;
ylabel('x, м'); grid on;
title('Закон движения поршня x(t)');
legend('x_{piston}', 'Location', 'best');
subplot(2,1,2);
plot(hist_t, hist_vp, 'LineWidth', 1.5, 'Color', 'r');
xlabel('Время t, с'); ylabel('Скорость v, м/с'); grid on;
title('Скорость поршня v(t)');
% График 2: Параметры газа в центре участка А
figure('Name', 'Parameters at Center A', 'Color', 'w', 'Position', [150 150 1000 700]);
subplot(3,1,1);
plot(hist_t, hist_pA/1e5, 'LineWidth', 1.5, 'Color', 'b');
ylabel('p, бар'); grid on;
title('Давление в центре участка А');
subplot(3,1,2);
plot(hist_t, hist_rhoA, 'LineWidth', 1.5, 'Color', 'g');
ylabel('\rho, кг/м^3'); grid on;
title('Плотность в центре участка А');
subplot(3,1,3);
plot(hist_t, hist_vA, 'LineWidth', 1.5, 'Color', 'r');
xlabel('Время t, с'); ylabel('u, м/с'); grid on;
title('Скорость газа в центре участка А');
% График 3: Профили давления
figure('Name', 'Pressure Profiles', 'Color', 'w', 'Position', [200 200 1000 600]);
hold on;
p_init = ones(size(p))*p0;
p_init(idx_A) = p_high;
plot(x_centers, p_init/1e5, 'k--', 'LineWidth', 1.2, 'DisplayName', 't=0');
colors = lines(length(profiles_p));
for i = 1:length(profiles_p)
plot(x_centers, profiles_p{i}/1e5, 'Color', colors(i,:), 'LineWidth', 1.5, ...
'DisplayName', sprintf('t=%.3f с', save_times(i)));
end
xlabel('Координата x, м'); ylabel('Давление p, бар');
title('Распределение давления по длине трубы (кольцевая)');
legend('show', 'Location', 'best');
grid on;
hold off;
% График 4: Контроль CFL-условия
figure('Name', 'CFL Control', 'Color', 'w', 'Position', [300 300 1000 600]);
subplot(2,1,1);
plot(hist_t, hist_dt*1e4, 'LineWidth', 1.5, 'Color', 'b');
ylabel('dt, ×10^{-4} с'); grid on;
title('Шаг по времени (должен быть фиксированным)');
subplot(2,1,2);
plot(hist_t, hist_sigma, 'LineWidth', 1.5, 'Color', 'r');
hold on;
yline(1.0, '--k', 'LineWidth', 1.5, 'DisplayName', 'σ = 1 (граница CFL)');
yline(CFL_fixed, '--g', 'LineWidth', 1.5, 'DisplayName', sprintf('σ = CFL = %.3f', CFL_fixed));
hold off;
xlabel('Время t, с'); ylabel('σ = (|u|+a)·Δt/Δx');
title('Число Куранта во времени (должно быть σ ≤ CFL)');
legend('show', 'Location', 'best');
grid on;
fprintf('\n✓ All plots created successfully!\n');
fprintf('CFL_fixed = %.3f\n', CFL_fixed);
fprintf('dt = %.5e с\n', dt);
fprintf('Средний σ = %.4f\n', mean(hist_sigma));
fprintf('max(σ) = %.4f\n', max(hist_sigma));
end =