0% found this document useful (0 votes)
11 views

Modelling and Simulation_ Lecture 09

Uploaded by

Amr Farag
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Modelling and Simulation_ Lecture 09

Uploaded by

Amr Farag
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Modelling and Simulation

MPW331

Lecture 9

Dr. Eng. Mohamed Elsabahy


Ph.D. Energy Resources Engineering

Email: [email protected]
Introduction
Introduction to Basic System Models
✓ System model: A mathematical representation of a physical system that describes its behavior.

✓ Types of system models:


• Mechanical Systems
• Electrical Systems
• Hydraulic Systems
• Pneumatic Systems
• Thermal Systems

✓ Importance of system modeling in engineering analysis and design.


✓ MATLAB as a tool for system modeling and simulation.
Example: Mechanical Systems
Consider a mechanical system consisting of a mass m, a spring with spring constant k, and a damper with damping coefficient c. The
system is subjected to an external force F(t), and the displacement of the mass x(t) is to be determined over time. The system starts
from rest, i.e., the initial displacement and velocity are zero.

The equation of motion for the system is given by:


Where:
• m is the mass (in kg),
• c is the damping coefficient (in N·s/m),
• k is the spring constant (in N/m),
• F(t) is the external force applied to the mass (in N).
Tasks:
1.Write a MATLAB script to model the system using a state-space representation. Use the following states:
• 𝑦1 (𝑡) = 𝑥(𝑡) (displacement of the mass),
• 𝑦2 (𝑡) = 𝑥(𝑡)
ሶ (velocity of the mass).

2.Assume the following parameters for the system:


• 𝑚 = 1𝑘𝑔,
• 𝑐 = 0.5 𝑁𝑠/𝑚,
• 𝑘 = 10 𝑁/𝑚,
• 𝐹(𝑡) = 5sin(2𝑡) 𝑁 (sinusoidal external force).

3.Solve the system numerically using the ode45 solver for the time span t=0 to t=10 seconds with initial conditions:
• 𝑥(0) = 0,
• 𝑥(0)
ሶ = 0.

4.Plot the following results:


•Displacement 𝑥(0) vs. Time,
•Velocity 𝑥(𝑡)
ሶ vs. Time.
Example: Mechanical Systems
Solution:
✓ Use state-space form:
𝑦1ሶ = 𝑦2
1
𝑦2ሶ = (𝐹(𝑡) − 𝑐𝑦2 − 𝑘𝑦1 )
𝑚

✓ Define the system of equations as a function handle in MATLAB.

✓ Use the ode45 solver to simulate the system.

✓ Use MATLAB plotting functions to visualize the results.


Example: Mechanical Systems
Solution:
✓ change F to constant Value (e.g., 5)
Example: Mechanical Systems
Solution:
✓ increase damping c=2
Example: Mechanical Systems
Solution:
✓ increase damping c=5
Example: Electrical Systems
Electrical systems are modeled using resistors, capacitors, and inductors.
Basic Model Example: RLC Circuit.
Example: Electrical Systems
Solution:
The End!

Any Questions

You might also like