Clear Filters
Clear Filters

Modelling of 2 stage reciprocating compressor

13 views (last 30 days)
Nai  Shi Jie
Nai Shi Jie on 2 Apr 2022
Answered: Varun on 25 Jan 2024
Hi, is it possible to model a 2 stage reciprocating air compressor by Matlab fully without Simulink? Because I found out most of the modelling and simulation work are done using Simulink. I would like to know whether I can use Matlab fully for compressor modelling.

Answers (1)

Varun
Varun on 25 Jan 2024
Hi Nai,
Looks like you want to model a 2-stage reciprocating air compressor by using only MATLAB and not Simulink.
You can use MATLAB exclusively to model a 2-stage reciprocating air compressor by coding the mathematical equations and implementing the necessary solvers in MATLAB scripts or functions.
Please consider the following example code snippet:
function compressorSimulation()
% Parameters
V1 = 0.01; % Volume of first stage (m^3)
V2 = 0.005; % Volume of second stage (m^3)
P0 = 1; % Initial pressure (atmospheric pressure)
gamma = 1.4; % Ratio of specific heats
% Time parameters
tspan = 0:0.01:5; % Simulation time span
% Initial conditions
initialConditions = [P0, V1, P0, V2];
% Solve ODEs
options = odeset('RelTol', 1e-6, 'AbsTol', 1e-9);
[t, state] = ode45(@compressorODE, tspan, initialConditions, options, gamma);
% Plot results
figure;
subplot(2, 1, 1);
plot(t, state(:, 1), 'LineWidth', 2);
xlabel('Time');
ylabel('Pressure (Pa)');
title('Pressure vs Time');
subplot(2, 1, 2);
plot(t, state(:, 2), 'LineWidth', 2);
hold on;
plot(t, state(:, 4), 'LineWidth', 2);
hold off;
xlabel('Time');
ylabel('Volume (m^3)');
legend('Stage 1', 'Stage 2');
title('Volume vs Time');
end
function dydt = compressorODE(t, y, gamma)
% State variables
P1 = y(1);
V1 = y(2);
P2 = y(3);
V2 = y(4);
% Compression process (simplified isentropic compression)
dV1dt = 0; % Assume no volume change in first stage
dP1dt = -gamma * P1 * dV1dt / V1;
dV2dt = 0; % Assume no volume change in second stage
dP2dt = -gamma * P2 * dV2dt / V2;
dydt = [dP1dt; dV1dt; dP2dt; dV2dt];
end
Please note that this is a very basic model. Depending on your specific requirements, you may need to introduce additional features and refine the model accordingly. Additionally, ensure that the physical units and constants used in your model align with your system's specifications.
You can also refer to the following documentations, might be helpful for your task:
Hope it helps.

Categories

Find more on Fluid Dynamics in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!