ODE solver for second Order ODE with Stiffness and Mass Matrices

Click For Summary

Discussion Overview

The discussion revolves around solving a second-order ordinary differential equation (ODE) represented in matrix form, specifically M*u'' + K*u = F(t), where M is the mass matrix, K is the stiffness matrix, and u is the displacement. Participants are exploring how to implement a solution using MATLAB's ODE45 function, addressing initial conditions and the structure of the input functions.

Discussion Character

  • Homework-related
  • Technical explanation

Main Points Raised

  • One participant expresses their inexperience with MATLAB and requests assistance in coding a solution for the given second-order ODE.
  • Another participant asks for a definition of the vector F(t), seeking clarification on the external force applied to the system.
  • A participant provides the definition of F(t) as [F0*sin(w*t), 0, 0, 0] and notes that both M and K are 4x4 matrices.
  • One participant emphasizes the necessity of initial conditions for the ODE solver and offers a similar example problem along with a code snippet to illustrate how to structure the solution.
  • The provided code includes a suggestion to save the function used by ODE45 in a separate script and mentions potential complexities in getting the code to run correctly.

Areas of Agreement / Disagreement

Participants generally agree on the need for initial conditions and the structure of the matrices involved, but there is no consensus on the best practices for implementing the solution in MATLAB, as different approaches are suggested.

Contextual Notes

The discussion does not clarify the specific initial conditions required for the problem, nor does it resolve the potential complexities in coding the solution effectively. There may be assumptions regarding the definitions of the matrices and the function structure that are not explicitly stated.

Who May Find This Useful

This discussion may be useful for individuals learning MATLAB, particularly those interested in solving differential equations in matrix form, as well as those seeking to understand the implementation of ODE solvers in computational contexts.

ihebmtir
Messages
3
Reaction score
0
TL;DR
i have encoutered this Problem where i need to solve an ordinary differential Equation using ODE45 for M*u''+K*u=f(t)
i am new to MATLAB and and as shown below I have a second order differential equation M*u''+K*u=F(t) where M is the mass matrix and K is the stifness matrix and u is the displacement.
and i have to write a code for MATLAB using ODE45 to get a solution for u. there was not so much information on how to solve an ODE that´'s written on Matrix form, i would be really thankful for you help
 

Attachments

  • frage.png
    frage.png
    4.5 KB · Views: 201
Engineering news on Phys.org
Do you have a definition for the vector {f(t)}?
 
yes F(t)=[F0*sin(w*t), 0, 0, 0]
and Both M and K are 4X4 Matrices
 
Obviously you will need some initial conditions as well. I will attach a similar example problem and solution code.

It can be a little tricky getting the code to run. You should save the lower function in a separate script (called "f" in this case - since that's what the ode45 function calls) in the working folder. The upper part is what you will run and it calls the other function. There's probably a more elegant way of doing it, but I don't know it.
1624567411995.png

1624567424651.png

xo=[0; 0.1; 1; 0];
ts=[0 20];
[t,x]=ode45('f',ts,xo);
plot(t,x(:,1),t,x(:,2),'--')
%------------------------------------------
function v=f(t,x)
M=[2 0; 0 1];
C=[3 -0.5; -0.5 0.5];
K=[3 -1; -1 1];
B=[1; 1];
w=2;
A1=[zeros(2) eye(2); -inv(M)*K -inv(M)*C];
f=inv(M)*B;
v=A1*x+[0;0; f]*sin(w*t);
 

Similar threads

Replies
4
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
5K