Challenge

Week 3 - Solving second order ODEs

% Air standard Cycle 
clear all
close all
clc

%Input value of gamma
gamma = 1.4;

%Input value of t3
t3=2300;

% State Variables 
p1 = 101325;
t1= 500;

%Input value of bore, Stroke,cr and con_rod
bore=0.1;
stroke=0.1;
con_rod=0.15;
cr=12;


% Calculating swept volume and clearance volume 
v_swept =   (pi/4)*bore^2*stroke;
v_clearance = v_swept/(cr -1);

v1 = v_swept + v_clearance; 
v2 = v_clearance; 

%State variable at state point 2 
p2 = p1*cr^gamma;

t2 = p2*v2*t1/(p1*v1);

c=p1*v1^gamma;
V_compression = engine_kinematics(bore, stroke,con_rod,cr,180,0)

P_compression = c./V_compression.^gamma;

%State variable at state point 3 
v3 = v2;


p3 = p2*t3/t2;

c=p3*v3^gamma;
V_expansion = engine_kinematics(bore, stroke,con_rod,cr,0,180)

P_expansion = c./V_expansion.^gamma;

%State variable at state point 4
v4 = v1;

p4 = p3*(v3/v4)^gamma;


%For Calculating Efficiency 

cond_temp = 100;
steam_temp = 1000;
effi = (1 - (cond_temp)./(steam_temp)) * 100

%Points Generate 
figure(1)
hold on 
plot (v1,p1,'*','color','g')
plot(V_compression, P_compression)
plot (v2,p2,'*','color','r')
plot (v3,p3,'*','color','r')
plot(V_expansion, P_expansion)
plot (v4,p4,'*','color','b')
plot([v2,v3],[p2,p3])
plot([v4 v41],[p4,p1])

% Printing with joining the lines from the points
figure (2)
plot([v1 v2 v3 v4 v1],[p1 p2 p3 p4 p1],'color','b')
xlabel('V')
ylabel('P')
title('Plot P and V')


function [dtheta_dt] = ode_function(t,theta,b,g,l,m) %initializing the function
    theta1 = theta(1);
    theta2 = theta(2);
    dtheta1_dt = theta2;
    dtheta2_dt = -(b/m)*theta2-(g/l)*sin(theta1);
    dtheta_dt = [dtheta1_dt;dtheta2_dt];
end
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.