forked from brstu/TMAU-2024
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
2,558 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
|
||
<p align="center"> Министерство образования Республики Беларусь</p> | ||
<p align="center">Учреждение образования</p> | ||
<p align="center">“Брестский Государственный Технический университет”</p> | ||
<p align="center">Кафедра ИИТ</p> | ||
<br><br><br><br><br><br><br> | ||
<p align="center">Лабораторная работа №1</p> | ||
<p align="center">По дисциплине “Теория и методы автоматического управления”</p> | ||
<p align="center">Тема: “Моделирования температуры объекта”</p> | ||
<br><br><br><br><br> | ||
<p align="right">Выполнил:</p> | ||
<p align="right">Студент 3 курса</p> | ||
<p align="right">Группы АС-63</p> | ||
<p align="right">Ващук А. В.</p> | ||
<p align="right">Проверила:</p> | ||
<p align="right">Ситковец Я. С.</p> | ||
<br><br><br><br><br> | ||
<p align="center">Брест 2024</p> | ||
|
||
--- | ||
|
||
**Задание**: | ||
|
||
The rate of change of temperature with respect to time depends on the input heat, the room temperature, and certain constants that characterize the system's behavior. After some transformations, we obtain both linear and nonlinear models: | ||
|
||
The linear model expresses the next temperature value as a function of the current temperature and input heat, along with system constants. | ||
The nonlinear model adds complexity by including terms that account for more intricate dependencies on the previous temperature and input heat, incorporating non-linearities like squared terms and trigonometric functions. | ||
The goal is to use these models to control the temperature over discrete time intervals. | ||
|
||
Пример вывода программы: | ||
|
||
``` bash | ||
Enter the constant a for the model: 0.08 | ||
Enter the constant b for the linear model: 0.02 | ||
Enter the constant c for the nonlinear model: 0.01 | ||
Enter the constant d for the nonlinear model: 0.05 | ||
Enter the initial temperature (y0): 20 | ||
Enter the number of discrete time moments: 10 | ||
Enter the heat values (u) for each time moment: | ||
u[1]: 10 | ||
u[2]: 15 | ||
u[3]: 20 | ||
u[4]: 25 | ||
u[5]: 30 | ||
u[6]: 35 | ||
u[7]: 40 | ||
u[8]: 45 | ||
u[9]: 50 | ||
u[10]: 55 | ||
|
||
Linear Model Simulation: | ||
Time 1: Temperature = 20 | ||
Time 2: Temperature = 1.8 | ||
Time 3: Temperature = 0.444 | ||
Time 4: Temperature = 0.43552 | ||
Time 5: Temperature = 0.534842 | ||
Time 6: Temperature = 0.642787 | ||
Time 7: Temperature = 0.751423 | ||
Time 8: Temperature = 0.860114 | ||
Time 9: Temperature = 0.968809 | ||
Time 10: Temperature = 1.0775 | ||
|
||
Non-linear Model Simulation: | ||
Time 1: Temperature = 20 | ||
Time 2: Temperature = -6.3272 | ||
Time 3: Temperature = -1.12433 | ||
Time 4: Temperature = 0.130418 | ||
Time 5: Temperature = 0.253476 | ||
Time 6: Temperature = 0.269591 | ||
Time 7: Temperature = 0.348705 | ||
Time 8: Temperature = 0.46272 | ||
Time 9: Temperature = 0.525281 | ||
Time 10: Temperature = 0.523385 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Игнорировать все в папке .vscode | ||
.vscode/ | ||
|
||
# Игнорировать папку build | ||
build/ | ||
|
||
# Игнорировать папку out | ||
out/ | ||
|
||
# Игнорировать json файл | ||
CMakePresets.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
cmake_minimum_required(VERSION 3.5.0) | ||
project(TempControlSystem VERSION 0.1.0 LANGUAGES C CXX) | ||
|
||
add_executable(TempControlSystem TempControlSystem.cpp) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#include <iostream> | ||
#include <cmath> | ||
#include <vector> | ||
|
||
using namespace std; | ||
|
||
// Function to simulate the linear model | ||
vector<double> simulateLinearModel(double a, double b, double y0, const vector<double>& u, int n) { | ||
vector<double> y(n); | ||
y[0] = y0; // Initial temperature | ||
|
||
// Loop through each time step to calculate the temperature | ||
for (int t = 1; t < n; ++t) { | ||
y[t] = a * y[t - 1] + b * u[t - 1]; // Update temperature based on the linear model | ||
} | ||
|
||
return y; // Return the vector of temperatures | ||
} | ||
|
||
// Function to simulate the nonlinear model | ||
vector<double> simulateNonLinearModel(double a, double b, double c, double d, double y0, const vector<double>& u, int n) { | ||
vector<double> y(n); | ||
y[0] = y0; // Initial temperature | ||
|
||
// Loop through each time step to calculate the temperature | ||
for (int t = 1; t < n; ++t) { | ||
double prev_y = y[t - 1]; | ||
double prev_u = u[t - 1]; | ||
y[t] = a * prev_y - b * pow(prev_y, 2) + c * prev_u + d * sin(prev_u); // Nonlinear model update | ||
} | ||
|
||
return y; // Return the vector of temperatures | ||
} | ||
|
||
int main() { | ||
// Input constants from user | ||
double a, b, c, d, y0; | ||
cout << "Enter the constant a for the model: "; | ||
cin >> a; | ||
cout << "Enter the constant b for the linear model: "; | ||
cin >> b; | ||
cout << "Enter the constant c for the nonlinear model: "; | ||
cin >> c; | ||
cout << "Enter the constant d for the nonlinear model: "; | ||
cin >> d; | ||
cout << "Enter the initial temperature (y0): "; | ||
cin >> y0; | ||
|
||
// Input the number of time moments | ||
int n; | ||
cout << "Enter the number of discrete time moments: "; | ||
cin >> n; | ||
|
||
// Input the heat values | ||
vector<double> u(n); | ||
cout << "Enter the heat values (u) for each time moment:" << endl; | ||
for (int i = 0; i < n; ++i) { | ||
cout << "u[" << i + 1 << "]: "; | ||
cin >> u[i]; // Read input for each heat value | ||
} | ||
|
||
// Simulate the linear model | ||
vector<double> y_linear = simulateLinearModel(a, b, y0, u, n); | ||
|
||
// Simulate the nonlinear model | ||
vector<double> y_nonlinear = simulateNonLinearModel(a, b, c, d, y0, u, n); | ||
|
||
// Output results | ||
cout << "\nLinear Model Simulation:" << endl; | ||
for (int t = 0; t < n; ++t) { | ||
cout << "Time " << t + 1 << ": Temperature = " << y_linear[t] << endl; | ||
} | ||
|
||
cout << "\nNon-linear Model Simulation:" << endl; | ||
for (int t = 0; t < n; ++t) { | ||
cout << "Time " << t + 1 << ": Temperature = " << y_nonlinear[t] << endl; | ||
} | ||
|
||
return 0; // Indicate successful completion | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<p align="center"> Министерство образования Республики Беларусь</p> | ||
<p align="center">Учреждение образования</p> | ||
<p align="center">“Брестский Государственный технический университет”</p> | ||
<p align="center">Кафедра ИИТ</p> | ||
<br><br><br><br><br><br><br> | ||
<p align="center">Лабораторная работа №1</p> | ||
<p align="center">По дисциплине “Теория и методы автоматического управления”</p> | ||
<p align="center">Тема: “Моделирования температуры объекта”</p> | ||
<br><br><br><br><br> | ||
<p align="right">Выполнил:</p> | ||
<p align="right">Студент 3 курса</p> | ||
<p align="right">Группы АС-63</p> | ||
<p align="right">Карпеш Н.П.</p> | ||
<p align="right">Проверила:</p> | ||
<p align="right">Ситковец Я. С.</p> | ||
<br><br><br><br><br> | ||
<p align="center">Брест 2024</p> | ||
|
||
--- | ||
|
||
**Задание**: | ||
|
||
Let's get some object to be controlled. We want to control its temperature, which can be described by this differential equation: | ||
|
||
$$\Large\frac{dy(\tau)}{d\tau}=\frac{u(\tau)}{C}+\frac{Y_0-y(\tau)}{RC} $$ (1) | ||
|
||
where $\tau$ – time; $y(\tau)$ – input temperature; $u(\tau)$ – input warm; $Y_0$ – room temperature; $C,RC$ – some constants. | ||
|
||
After transformation we get these linear (2) and nonlinear (3) models: | ||
|
||
$$\Large y_{\tau+1}=ay_{\tau}+bu_{\tau}$$ (2) | ||
|
||
$$\Large y_{\tau+1}=ay_{\tau}-by_{\tau-1}^2+cu_{\tau}+d\sin(u_{\tau-1})$$ (3) | ||
|
||
where $\tau$ – time discrete moments ($1,2,3{\dots}n$); $a,b,c,d$ – some constants. | ||
|
||
Task is to write program (**С++**), which simulates this object temperature. | ||
|
||
Пример вывода программы: | ||
|
||
``` bash | ||
Введите константу a: 1 | ||
Введите константу b: 2 | ||
Введите константу c: 3 | ||
Введите константу d: 4 | ||
Введите подаваемое тепло: 10 | ||
Введите температуру: 5 | ||
Введите количество тактов работы модели: 5 | ||
---Линейна температурная модель--- | ||
y1 = 25 | ||
y2 = 45 | ||
y3 = 65 | ||
y4 = 85 | ||
y5 = 105 | ||
---Нелинейная температурная модель--- | ||
y1 = 35 | ||
y2 = 12.8239 | ||
y3 = -2409.35 | ||
y4 = -2710.43 | ||
y5 = -1.16126e+07 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
cmake_minimum_required(VERSION 3.0.0) | ||
project(Lab01) | ||
|
||
add_executable(Lab01 main.cpp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <iostream> | ||
#include <cmath> | ||
using namespace std; | ||
|
||
//линейная модель | ||
void linear(double a, double b, double uT, double yT, int t) { | ||
cout << "\t---Линейна температурная модель---" << endl; | ||
for (int i = 1; i <= t; i++) { | ||
double yT1 = a * yT + b * uT; | ||
cout << "y" << i << " = " << yT1 << endl; | ||
yT = yT1; | ||
} | ||
} | ||
|
||
//НЕлинейная модель | ||
void nonLinear(double a, double b, double c, double d, double uT, double yT, int t) { | ||
double uT_1 = 0; | ||
double yT_1 = 0; | ||
|
||
cout << "\t---Нелинейная температурная модель---" << endl; | ||
for (int i = 1; i <= t; i++) { | ||
double yT1 = a * yT - b * pow(yT_1, 2) + c * uT + d * sin(uT_1); | ||
cout << "y" << i << " = " << yT1 << endl; | ||
uT_1 = uT; | ||
yT_1 = yT; | ||
yT = yT1; | ||
} | ||
} | ||
|
||
int main() { | ||
|
||
system("chcp 1251"); | ||
system("cls"); | ||
|
||
double a, b, c, d; //константы | ||
double uT; //теплота | ||
double yT; //температура | ||
int t; // такты | ||
|
||
cout << "Введите константу a: "; cin >> a; | ||
cout << "Введите константу b: "; cin >> b; | ||
cout << "Введите константу c: "; cin >> c; | ||
cout << "Введите константу d: "; cin >> d; | ||
cout << "Введите подаваемое тепло: "; cin >> uT; | ||
cout << "Введите температуру: "; cin >> yT; | ||
cout << "Введите количество тактов работы модели: "; cin >> t; | ||
|
||
linear(a, b, uT, yT, t); | ||
nonLinear(a, b, c, d, uT, yT, t); | ||
|
||
return 0; | ||
} |
Oops, something went wrong.