Solution of a 2nd order non linear implicit differential equation using ode15i implicit solver
This is a nonlinear differential equation of 2nd order and implicit
I am providing the code I have tried but Iam not getting hoe the velocity changes with time at different time what is the value of velocity.
% Initial conditions
y0 = [0 2]; % initial displacement and velocity
yp0_guess = [0; 0]; % Initial guess for derivatives
% Time span
tspan = [0 20]; % time span for the solution
% Solve using ode15i
[t, y] = ode15i(@implicitODE, tspan, y0, yp0_guess);
% Plot the displacement over time
figure;
subplot(2,1,1);
plot(t, y(:,1));
xlabel(‘Time (s)’);
ylabel(‘Displacement (y)’);
title(‘Displacement vs Time’);
% Plot the velocity over time
subplot(2,1,2);
plot(t,y(:,2)); % y(:,2) corresponds to the velocity (dy/dt)
xlabel(‘Time (s)’);
ylabel(‘Velocity (dy/dt)’);
title(‘Velocity vs Time’);
function res = implicitODE(t, y, yp)
% Constants
pi = 3.141592653589793;
k1 = 4.4049e-18;
k2 = 0.1101;
a = 17.71e-3;
% Extract variables
y1 = y(1); % y1 corresponds to y(t)
y2 = y(2); % y2 corresponds to dy/dt
yp1 = yp(1); % yp1 corresponds to y2
yp2 = yp(2); % yp2 corresponds to y2′
% Compute the residuals
res = zeros(2,1);
res(1) = yp1 – y2; % y1′ = y2
res(2) = yp2 – (-k1 * y1^2 * y2 / (a^2 + y1^2)^2.5 / k2)-9.81; % y2′ equation
endThis is a nonlinear differential equation of 2nd order and implicit
I am providing the code I have tried but Iam not getting hoe the velocity changes with time at different time what is the value of velocity.
% Initial conditions
y0 = [0 2]; % initial displacement and velocity
yp0_guess = [0; 0]; % Initial guess for derivatives
% Time span
tspan = [0 20]; % time span for the solution
% Solve using ode15i
[t, y] = ode15i(@implicitODE, tspan, y0, yp0_guess);
% Plot the displacement over time
figure;
subplot(2,1,1);
plot(t, y(:,1));
xlabel(‘Time (s)’);
ylabel(‘Displacement (y)’);
title(‘Displacement vs Time’);
% Plot the velocity over time
subplot(2,1,2);
plot(t,y(:,2)); % y(:,2) corresponds to the velocity (dy/dt)
xlabel(‘Time (s)’);
ylabel(‘Velocity (dy/dt)’);
title(‘Velocity vs Time’);
function res = implicitODE(t, y, yp)
% Constants
pi = 3.141592653589793;
k1 = 4.4049e-18;
k2 = 0.1101;
a = 17.71e-3;
% Extract variables
y1 = y(1); % y1 corresponds to y(t)
y2 = y(2); % y2 corresponds to dy/dt
yp1 = yp(1); % yp1 corresponds to y2
yp2 = yp(2); % yp2 corresponds to y2′
% Compute the residuals
res = zeros(2,1);
res(1) = yp1 – y2; % y1′ = y2
res(2) = yp2 – (-k1 * y1^2 * y2 / (a^2 + y1^2)^2.5 / k2)-9.81; % y2′ equation
end This is a nonlinear differential equation of 2nd order and implicit
I am providing the code I have tried but Iam not getting hoe the velocity changes with time at different time what is the value of velocity.
% Initial conditions
y0 = [0 2]; % initial displacement and velocity
yp0_guess = [0; 0]; % Initial guess for derivatives
% Time span
tspan = [0 20]; % time span for the solution
% Solve using ode15i
[t, y] = ode15i(@implicitODE, tspan, y0, yp0_guess);
% Plot the displacement over time
figure;
subplot(2,1,1);
plot(t, y(:,1));
xlabel(‘Time (s)’);
ylabel(‘Displacement (y)’);
title(‘Displacement vs Time’);
% Plot the velocity over time
subplot(2,1,2);
plot(t,y(:,2)); % y(:,2) corresponds to the velocity (dy/dt)
xlabel(‘Time (s)’);
ylabel(‘Velocity (dy/dt)’);
title(‘Velocity vs Time’);
function res = implicitODE(t, y, yp)
% Constants
pi = 3.141592653589793;
k1 = 4.4049e-18;
k2 = 0.1101;
a = 17.71e-3;
% Extract variables
y1 = y(1); % y1 corresponds to y(t)
y2 = y(2); % y2 corresponds to dy/dt
yp1 = yp(1); % yp1 corresponds to y2
yp2 = yp(2); % yp2 corresponds to y2′
% Compute the residuals
res = zeros(2,1);
res(1) = yp1 – y2; % y1′ = y2
res(2) = yp2 – (-k1 * y1^2 * y2 / (a^2 + y1^2)^2.5 / k2)-9.81; % y2′ equation
end ode15i, 2nd order ode, nonlinear ode, implicit solution MATLAB Answers — New Questions