Chemical Recommp; amp; Materials Engineering
Jak modelować i symulować systemy inżynieryjne za pomocą Numpy Scipy
Table of Contents
Modeling and simulating interior systems are essential tasks in collering analyses. Using Python libraries like NumPy and SciPy simplifies these processes by provising powerful tools for numerical computation and system analyses. Thie article wprowadzi basic methods to model and simulate corresering systems with these libraries.
Setting Up the Environment
Tu begin, trzeba mieć bibliotekę, jeśli nie ma już wolnych miejsc.
Xi1; Xi1; FLT: 0 Xi3; Xi3; pip install numpy clipy Xi1; Xi1; FLT: 1 Xi3; Xi3; Xi3;
Systemy inżynierów modeling
Inżynieria systemów can often be consignited using matematical models such as differentiations or transfer functions. NumPy provides tools for creating matrices andd vectors, while SciPy offers functions for solving equations andd simulating system responses.
For example, a simple mass- spring- damper system can be modeled with the differental equation:
m * x kwotowanie; + c * x kwotowanie; + k * x = 0
Simulating Systems
SciPy 's integrate module allows solving differentiations numerycally. The equipment; solve _ ivp presentation; functionon is common used for this intence. Here' s an example of simulating thee mas- spring- damper system:
Definiować ten system a functionon:
Xi1; Xi1; FLT: 0 Xi3; Xi3; import numpy as np Xi1; Xi1; FLT: 1 Xi3; Xi3;
Xiv1; Xiv1; FLT: 0 Xiv3; Xiv3; frem scipy.integrate import solve _ ivp Xiv1; Xiv1; FLT: 1 Xiv3; Xiv3;
(t, y, c, k): (1) (0) (0) (0) (0) (3) (0) (3) (3) (3) (3) (3) (3) (3) (3) (3) (3) (3) (3) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4) (4)
return previo1; y previo1; 1 previo3; - (c / m) * y previo1; 1 previous; - (k / m) * y previous 1; 0 previous 3; previous;
Ustawić warunki initional i parametry:
Xiv1; Xiv1; FLT: 0 Xiv3; Xiv3; initial _ conditions = Xiv1; x0, v0 Xiv3; Xiv1; Xiv1; FLT: 1 Xiv3; Xiv3;
Xi1; Xi1; FLT: 0 Xi3; Xi3; t _ span = Xi1; 0, 10 Xi3; Xi1; Xi1; FLT: 1 Xi3; Xi3; Xi3;
Call thee solver:
(mass _ spring _ damper, t _ span, initial _ conditions, args = (c, k)))
Results Analyzing
After simulation, analyze the results by placting thee system 's responses over time. Usie libraries like Matplalib to visualizate the data:
Xiv1; Xiv1; FLT: 0 Xiv3; Xiv3; import matplalib.pyplot as plt Xiv1; Xiv1; FLT: 1 Xiv3; Xiv3; Xiv3;
Xion1; Xion1; FLT: 0 Xion3; Xion3; plt.plot (soltion.t, Xion1; 0 Xion3;) Xion1; Xion1; FLT: 1 Xion3; Xion3; Xion3;
Xi1; Xi1; FLT: 0 Xi3; Xi3; plt.xlabel (Xion1; Time (s) Xion1; Xion1; FLT: 1 Xion3; Xion3; Xion3;
Xiv1; Xiv1; FLT: 0 Xiv3; Xiv3; plt.ylabel (Xiv.; Displacement Xiv.) Xiv1; Xiv. 1; FLT: 1 Xiv3; Xiv3; Xiv.;
Xi1; Xi1; FLT: 0 Xi3; Xi3; plt.show () Xi1; Xi1; FLT: 1 Xi3; Xi3;