diff --git a/readme.md b/readme.md index 277fd756..5abd614e 100644 --- a/readme.md +++ b/readme.md @@ -30,7 +30,7 @@ |8|Козлович Антон||||||||||| |9|Козловская Анна||||||||||| |10|Колодич Максим||||||||||| -|11|Крагель Алина||||||||||| +|11|Крагель Алина|[as0006311](./trunk/as0006311/)|:white_check_mark:|:white_check_mark:|||||||| |12|Куликович Иван||||||||||| |13|Кульбеда Кирилл||||||||||| |14|Кухарчук Илья|[as0006314](trunk/as0006314)|||||||||| diff --git a/trunk/as0006311/task_01/doc/readme.md b/trunk/as0006311/task_01/doc/readme.md new file mode 100644 index 00000000..b76618b7 --- /dev/null +++ b/trunk/as0006311/task_01/doc/readme.md @@ -0,0 +1,58 @@ +

Министерство образования Республики Беларусь

+

Учреждение образования

+

“Брестский Государственный технический университет”

+

Кафедра ИИТ

+






+

Лабораторная работа №1

+

По дисциплине “Теория и методы автоматического управления”

+

Тема: “Моделирования температуры объекта”

+




+

Выполнил:

+

Студент 3 курса

+

Группы АС-63

+

Крагель А. М.

+

Проверила:

+

Ситковец Я. С.

+




+

Брест 2024

+ +--- + +**Задание**: + +Let's consider the wrong object, the control of which consists of controlling its temperature, described by the following differential equations: + +After transformations we have the following linear (2) and nonlinear (3) models: + +The goal is to write a program in C++ that will simulate the temperature of a given object. + +Пример вывода программы: + +``` bash +Enter the constant alpha for the model: 0.08 +Enter the constant beta for the linear model: 0.06 +Enter the constant gamma for the nonlinear model: 0.02 +Enter the constant delta for the nonlinear model: 0.01 +Enter the initial temperature (initialTemp): 20 +Enter the number of discrete time moments: 5 +Enter the heat values (heatInput) for each time moment: +heatInput[1]: 10 +heatInput[2]: 15 +heatInput[3]: 20 +heatInput[4]: 25 +heatInput[5]: 30 + +Linear Model Simulation: +Time 1: Temperature = 20 +Time 2: Temperature = 2.2 +Time 3: Temperature = 1.076 +Time 4: Temperature = 1.28608 +Time 5: Temperature = 1.60289 + +Non-linear Model Simulation: +Time 1: Temperature = 20 +Time 2: Temperature = -22.2054 +Time 3: Temperature = -31.0548 +Time 4: Temperature = -59.9394 +Time 5: Temperature = -219.86 +``` diff --git a/trunk/as0006311/task_01/src/CMakeLists.txt b/trunk/as0006311/task_01/src/CMakeLists.txt new file mode 100644 index 00000000..8d932959 --- /dev/null +++ b/trunk/as0006311/task_01/src/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.5.0) +project(main VERSION 0.1.0 LANGUAGES C CXX) + +add_executable(main main.cpp) diff --git a/trunk/as0006311/task_01/src/main.cpp b/trunk/as0006311/task_01/src/main.cpp new file mode 100644 index 00000000..b8f5a2af --- /dev/null +++ b/trunk/as0006311/task_01/src/main.cpp @@ -0,0 +1,80 @@ +#include +#include +#include + +using namespace std; + +// Function to simulate the linear model +vector calculateLinearTemp(double alpha, double beta, double initialTemp, const vector& heatInput, int steps) { + vector temperature(steps); + temperature[0] = initialTemp; // Initial temperature + + // Loop through each time step to calculate the temperature + for (int time = 1; time < steps; ++time) { + temperature[time] = alpha * temperature[time - 1] + beta * heatInput[time - 1]; // Update temperature based on the linear model + } + + return temperature; // Return the vector of temperatures +} + +// Function to simulate the nonlinear model +vector calculateNonLinearTemp(double alpha, double beta, double gamma, double delta, double initialTemp, const vector& heatInput, int steps) { + vector temperature(steps); + temperature[0] = initialTemp; // Initial temperature + + // Loop through each time step to calculate the temperature + for (int time = 1; time < steps; ++time) { + double prev_temp = temperature[time - 1]; + double prev_input = heatInput[time - 1]; + temperature[time] = alpha * prev_temp - beta * pow(prev_temp, 2) + gamma * prev_input + delta * sin(prev_input); // Nonlinear model update + } + + return temperature; // Return the vector of temperatures +} + +int main() { + // Input constants from user + double alpha, beta, gamma, delta, initialTemp; + cout << "Enter the constant alpha for the model: "; + cin >> alpha; + cout << "Enter the constant beta for the linear model: "; + cin >> beta; + cout << "Enter the constant gamma for the nonlinear model: "; + cin >> gamma; + cout << "Enter the constant delta for the nonlinear model: "; + cin >> delta; + cout << "Enter the initial temperature (initialTemp): "; + cin >> initialTemp; + + // Input the number of time moments + int steps; + cout << "Enter the number of discrete time moments: "; + cin >> steps; + + // Input the heat values + vector heatInput(steps); + cout << "Enter the heat values (heatInput) for each time moment:" << endl; + for (int i = 0; i < steps; ++i) { + cout << "heatInput[" << i + 1 << "]: "; + cin >> heatInput[i]; // Read input for each heat value + } + + // Simulate the linear model + vector linearTemp = calculateLinearTemp(alpha, beta, initialTemp, heatInput, steps); + + // Simulate the nonlinear model + vector nonLinearTemp = calculateNonLinearTemp(alpha, beta, gamma, delta, initialTemp, heatInput, steps); + + // Output results + cout << "\nLinear Model Simulation:" << endl; + for (int time = 0; time < steps; ++time) { + cout << "Time " << time + 1 << ": Temperature = " << linearTemp[time] << endl; + } + + cout << "\nNon-linear Model Simulation:" << endl; + for (int time = 0; time < steps; ++time) { + cout << "Time " << time + 1 << ": Temperature = " << nonLinearTemp[time] << endl; + } + + return 0; // Indicate successful completion +}