Reputation: 3
As you can see on the heading, I would like to ask something about ODE's. Our teacher has uploaded some examples on internet but they just consist of the solutions.
Here is one of them, which about to solution of following equations.
m_1 l^2 ϕ''_1 + m_1glϕ_1 + cl(ϕ_1 - ϕ_2) = 0
m_2 l^2 ϕ''_2 + m_2glϕ_2 + cl(ϕ_2 - ϕ_1) = 0
The point that I want to ask, as you can see on the solution there is a D matrix has defined. So, first row of this D matrix generally consist of 1 and 0s and the rest of it consists the constants which occured after the leaving dy/dt alone. What is this D matrix based on ? How I have to define that?
%m1=100*m2
% Parametres
m_2=1;
m_1=100*m_2;
l=1;
c=1;
g=10;
% Initial Conditions
phi_1=1;
phi_2=-0.5;
dphi_1=0;
dphi_2=0;
% Iteration Parameters
dt=0.01;
t_end=10;
% Time Vector
t=0:dt:t_end;
n_max=t_end/dt;
y(:,1)=[phi_1;phi_2;dphi_1;dphi_2];
D=[0 0 1 0;0 0 0 1;-g/l-c/(m_1*l) c/(m_1*l) 0 0;c/(m_2*l) -g/l-c/m_2/l 0 0];
y_exp=y;
for n = 1:n_max
y_exp(:,n+1)=dt*D*y_exp(:,n)+y_exp(:,n);
end
y_imp=y;
for n = 1:n_max
y_imp(:,n+1)=inv(eye(4)-D*dt)*y_imp(:,n);
end
Upvotes: 0
Views: 40
Reputation: 25982
Your system is linear with constant coefficients of order 2 and dimension 2. That makes, for the purposes of numerical integration, a system of order 1 and dimension 4 in the variables
y = [ phi_1; phi_2; dphi_1; dphi_2 ]
The matrix D
is the Jacobian of that order 1 system, resp. the matrix when formulating as
y' = D * y
following the expanded equations
phi_1' = dphi_1
phi_2' = dphi_2
dphi_1' = - (m_1*g*l * phi_1 + c*l * (phi_1 - phi_2) ) / (m_1 * l^2 )
dphi_2' = - (m_2*g*l * phi_2 + c*l * (phi_2 - phi_1) ) / (m_2 * l^2 )
Upvotes: 1