In: Mechanical Engineering
Write an Matlab Program for Wankel Engine Gemontry.
State your and assumptions and post the code
clear; clc;
R1 = 2; % Radius of fixed circle R2 = (3/2)*R1; % Radius of moving circle (circle 2 which is rolling on the inner side of cirle 1) E = 7; % Excentricity: This is the distance between the drawing/tracking point and the center of circle 2
df1 = 1; % The angel step size of the center of circle 2 regarding center to the center of cirle 1 [°] df2 = df1 * (1 - R1/R2); % Rotation of circle 2
z0 = (R1-R2) + 0i; % Position of center of circle 2 (as a complex number z=x+y*i) (i=imaginary unit)
c1 = E * exp ( i * 0 * (pi/180)); % Position of the first drawing/tracking point (first corner of the piston) c2 = E * exp ( i * 120 * (pi/180)); % Position of the second drawing/tracking point (second corner of the piston) c3 = E * exp ( i * 240 * (pi/180)); % Position of the third drawing/tracking point (third corner of the piston)
Piston = [c1 c2 c3]; % The piston is the triangle created by the three corners c1, c2 & c3 Piston = Piston + z0; HoleInPiston = R2 * exp([0:3:360] * i * (pi/180)); CrankShaft = R1 * exp([0:3:360] * i * (pi/180));
figure(1); hold on; grid on; box on; axis equal; xlim([-13 13]) ylim([-13 13]) ScreenShot = getframe;
for k = 1 : 3*360 % 'k' because i already used for imaginary no.
    % Pure translation of the center of circle 2:
        z0 = z0 * exp ( i * df1 * (pi/180)); 
    % Whole triangle (piston) has to follow the center:
        Piston = Piston - mean(Piston) + z0;
        HoleInPiston = HoleInPiston - mean(HoleInPiston) + z0;
    % Final step: Pure rotation of circle 2 ( = pure rotation of the piston)
    %   Step is: Bring whole piston to the center of cirle 1, rotate it and bring it back to old position
        Piston = (Piston - z0) * exp ( i * df2 * (pi/180)) + z0;
    plot( real(Piston(1)) , imag(Piston(1)), 'r.')
    plot( real(Piston(2)) , imag(Piston(2)), 'b.')
    plot( real(Piston(3)) , imag(Piston(3)), 'g.')
    fill( real(Piston) , imag(Piston), 'y');     % Deleting the piston from the figure
    fill( real(HoleInPiston) , imag(HoleInPiston), 'w')
    fill( real(CrankShaft) , imag(CrankShaft), 'k')
ScreenShot(end+1) = getframe;
    TheCurrentAxisOfTheDiagram = get(gca);
    AllCurvesInTheFigure = TheCurrentAxisOfTheDiagram.Children;
    delete (  AllCurvesInTheFigure(1) ); %Deleting the  from the figure
    delete (  AllCurvesInTheFigure(2) ); %Deleting the  from the figure
    delete (  AllCurvesInTheFigure(3) ); %Deleting the piston from the figure
end
fill( real(Piston) , imag(Piston), 'y'); % Deleting the piston from the figure fill( real(HoleInPiston) , imag(HoleInPiston), 'w') fill( real(CrankShaft) , imag(CrankShaft), 'k')