Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Федеральное агентство по образованию.docx
Скачиваний:
4
Добавлен:
18.12.2018
Размер:
185.5 Кб
Скачать

Оглавление.

Введение.

Оглавление.

Раздел 1. Имитационное моделирование.

  • Формулировку задания.

  • Математическое описание поставленной задачи.

  • Описание методов решения задания.

  • Описание программной реализации модели.

  • Описание созданного приложения.

  • Результаты работы приложения.

  • Исходный код приложения.

Раздел 2. Моделирование сложных систем.

  • Формулировку задания.

  • Математическое описание поставленной задачи.

  • Описание методов решения задания.

  • Описание программной реализации модели.

  • Описание созданного приложения.

  • Результаты работы приложения.

  • Исходный код приложения.

Список литературы.

Раздел 1. Имитационное моделирование.

Формулировка задания:

Дан стакан с жидкостью выделяющей газ, составить модель показывающую движение пузырьков газа в стакане. Известны следующие условия:

Скорость всплывания пузырей в воде определяется уравнением:

,

где 0,074 г/см – поверхностное натяжение воды;

γ – удельный вес воды;

g – ускорение силы тяжести;

d – диаметр пузыря.

Модель составить для d = 0,1 - 1 см.

Каждую секунду в стакане появляется от 2 до 10 пузырей, появляются на разной глубине и исчезают достигнув верха стакана. Стакан заполнен водой полностью.

Количество пузырей и глубина их появления выбирается случайным образом.

Математическое описание поставленной задачи:

Описание методов решения задания: для создания программы использовалось компоненты: shapeContainer, ovalShape, rectangleShape, timer, button; классы и математические уравнения.

Описание программной реализации модели: программа создана в среде С++ без использования дополнительных программ.

Описание созданного приложения: в результате реализации модели была создана программа, которая имитирует поведение пузырьков газированной воды: появление, всплывание и исчезновение пузырьков.

Результаты работы приложения:

Рисунок1.Окно программы Puziri.

Исходный код приложения.

#pragma once

#include "Header1.h"

#include <stdlib.h>

#include <math.h>

namespace Puziri{

using namespace System;

using namespace System::ComponentModel;

using namespace System::Collections;

using namespace System::Windows::Forms;

using namespace System::Data;

using namespace System::Drawing;

int x, y, d;\\объявление переменных

bool start = true;

int puz (int dmtr)\\ функция расчета скорости

{

double v = sqrt(((10*dmtr)/2)+((2*10*0.074)/dmtr));

int r = (int)v;

return r;

}

/// <summary>

/// Summary for Form1

/// </summary>

public ref class Form1 : public System::Windows::Forms::Form

{

public:

Form1(void)

{

InitializeComponent();

//

//TODO: Add the constructor code here

//

}

protected:

/// <summary>

/// Clean up any resources being used.

/// </summary>

~Form1()

{

if (components)

{

delete components;

}

}

private: Microsoft::VisualBasic::PowerPacks::ShapeContainer^ shapeContainer1;

protected:

private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape1;

private: Microsoft::VisualBasic::PowerPacks::RectangleShape^ rectangleShape1;

private: System::Windows::Forms::Timer^ timer1;

private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape10;

private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape9;

private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape8;

private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape7;

private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape6;

private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape5;

private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape4;

private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape3;

private: Microsoft::VisualBasic::PowerPacks::OvalShape^ ovalShape2;

private: System::Windows::Forms::Timer^ timer2;

private: System::Windows::Forms::Button^ button1;

private: System::ComponentModel::IContainer^ components;

private:

/// <summary>

/// Required designer variable.

/// </summary>

#pragma region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

void InitializeComponent(void)

{

this->components = (gcnew System::ComponentModel::Container());

this->shapeContainer1 = (gcnew Microsoft::VisualBasic::PowerPacks::ShapeContainer());

this->ovalShape10 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape());

this->ovalShape9 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape());

this->ovalShape8 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape());

this->ovalShape7 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape());

this->ovalShape6 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape());

this->ovalShape5 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape());

this->ovalShape4 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape());

this->ovalShape3 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape());

this->ovalShape2 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape());

this->ovalShape1 = (gcnew Microsoft::VisualBasic::PowerPacks::OvalShape());

this->rectangleShape1 = (gcnew Microsoft::VisualBasic::PowerPacks::RectangleShape());

this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));

this->timer2 = (gcnew System::Windows::Forms::Timer(this->components));

this->button1 = (gcnew System::Windows::Forms::Button());

this->SuspendLayout();

//

// shapeContainer1

//

this->shapeContainer1->Location = System::Drawing::Point(0, 0);

this->shapeContainer1->Margin = System::Windows::Forms::Padding(0);

this->shapeContainer1->Name = L"shapeContainer1";

this->shapeContainer1->Shapes->AddRange(gcnew cli::array< Microsoft::VisualBasic::PowerPacks::Shape^ >(11) {this->ovalShape10,

this->ovalShape9, this->ovalShape8, this->ovalShape7, this->ovalShape6, this->ovalShape5, this->ovalShape4, this->ovalShape3,

this->ovalShape2, this->ovalShape1, this->rectangleShape1});

this->shapeContainer1->Size = System::Drawing::Size(176, 261);

this->shapeContainer1->TabIndex = 0;

this->shapeContainer1->TabStop = false;

//

// ovalShape10

//

this->ovalShape10->BorderColor = System::Drawing::SystemColors::Desktop;

this->ovalShape10->Location = System::Drawing::Point(91, 211);

this->ovalShape10->Name = L"ovalShape10";

this->ovalShape10->SelectionColor = System::Drawing::SystemColors::Desktop;

this->ovalShape10->Size = System::Drawing::Size(4, 4);

//

// ovalShape9

//

this->ovalShape9->BorderColor = System::Drawing::SystemColors::Desktop;

this->ovalShape9->Location = System::Drawing::Point(110, 210);

this->ovalShape9->Name = L"ovalShape9";

this->ovalShape9->SelectionColor = System::Drawing::SystemColors::Desktop;

this->ovalShape9->Size = System::Drawing::Size(6, 6);

//

// ovalShape8

//

this->ovalShape8->BorderColor = System::Drawing::SystemColors::Desktop;

this->ovalShape8->Location = System::Drawing::Point(58, 210);

this->ovalShape8->Name = L"ovalShape8";

this->ovalShape8->SelectionColor = System::Drawing::SystemColors::Desktop;

this->ovalShape8->Size = System::Drawing::Size(8, 8);

//

// ovalShape7

//

this->ovalShape7->BorderColor = System::Drawing::SystemColors::Desktop;

this->ovalShape7->Location = System::Drawing::Point(26, 212);

this->ovalShape7->Name = L"ovalShape7";

this->ovalShape7->SelectionColor = System::Drawing::SystemColors::Desktop;

this->ovalShape7->Size = System::Drawing::Size(10, 10);

//

// ovalShape6

//

this->ovalShape6->BorderColor = System::Drawing::SystemColors::Desktop;

this->ovalShape6->Location = System::Drawing::Point(114, 211);

this->ovalShape6->Name = L"ovalShape6";

this->ovalShape6->SelectionColor = System::Drawing::SystemColors::Desktop;

this->ovalShape6->Size = System::Drawing::Size(12, 12);

//

// ovalShape5

//

this->ovalShape5->BorderColor = System::Drawing::SystemColors::Desktop;

this->ovalShape5->Location = System::Drawing::Point(41, 212);

this->ovalShape5->Name = L"ovalShape5";

this->ovalShape5->SelectionColor = System::Drawing::SystemColors::Desktop;

this->ovalShape5->Size = System::Drawing::Size(14, 14);

//

// ovalShape4

//

this->ovalShape4->BorderColor = System::Drawing::SystemColors::Desktop;

this->ovalShape4->FillColor = System::Drawing::SystemColors::Desktop;

this->ovalShape4->Location = System::Drawing::Point(94, 209);

this->ovalShape4->Name = L"ovalShape4";

this->ovalShape4->SelectionColor = System::Drawing::SystemColors::Desktop;

this->ovalShape4->Size = System::Drawing::Size(16, 16);

//

// ovalShape3

//

this->ovalShape3->BorderColor = System::Drawing::SystemColors::Desktop;

this->ovalShape3->Location = System::Drawing::Point(67, 206);

this->ovalShape3->Name = L"ovalShape3";

this->ovalShape3->SelectionColor = System::Drawing::SystemColors::Desktop;

this->ovalShape3->Size = System::Drawing::Size(18, 18);

//

// ovalShape2

//

this->ovalShape2->BorderColor = System::Drawing::SystemColors::Desktop;

this->ovalShape2->Location = System::Drawing::Point(134, 211);

this->ovalShape2->Name = L"ovalShape2";

this->ovalShape2->SelectionColor = System::Drawing::SystemColors::Desktop;

this->ovalShape2->Size = System::Drawing::Size(3, 3);

//

// ovalShape1

//

this->ovalShape1->BorderColor = System::Drawing::SystemColors::Desktop;

this->ovalShape1->Location = System::Drawing::Point(124, 211);

this->ovalShape1->Name = L"ovalShape1";

this->ovalShape1->SelectionColor = System::Drawing::SystemColors::Desktop;

this->ovalShape1->Size = System::Drawing::Size(5, 5);

//

// rectangleShape1

//

this->rectangleShape1->BackColor = System::Drawing::SystemColors::ButtonHighlight;

this->rectangleShape1->BorderColor = System::Drawing::SystemColors::Desktop;

this->rectangleShape1->FillColor = System::Drawing::SystemColors::Desktop;

this->rectangleShape1->Location = System::Drawing::Point(10, 13);

this->rectangleShape1->Name = L"rectangleShape1";

this->rectangleShape1->SelectionColor = System::Drawing::SystemColors::Desktop;

this->rectangleShape1->Size = System::Drawing::Size(150, 214);

//

// timer1

//

this->timer1->Enabled = true;

this->timer1->Interval = 1000;

this->timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);

//

// timer2

//

this->timer2->Enabled = true;

this->timer2->Interval = 50;

this->timer2->Tick += gcnew System::EventHandler(this, &Form1::timer2_Tick);

//

// button1

//

this->button1->Location = System::Drawing::Point(38, 236);

this->button1->Name = L"button1";

this->button1->Size = System::Drawing::Size(94, 23);

this->button1->TabIndex = 1;

this->button1->Text = L"pause";

this->button1->UseVisualStyleBackColor = true;

this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);

//

// Form1

//

this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);

this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;

this->ClientSize = System::Drawing::Size(176, 261);

this->Controls->Add(this->button1);

this->Controls->Add(this->shapeContainer1);

this->Name = L"Form1";

this->Text = L"Form1";

this->ResumeLayout(false);

}

#pragma endregion

private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e)

{

\\условия появления

if (ovalShape1->Location.X < 1)

{

bubble b1;

ovalShape1->Location = System::Drawing::Point(b1.X, b1.Y);

ovalShape1->Size = System::Drawing::Size(b1.diam, b1.diam);

}

if (ovalShape2->Location.X < 1)

{

bubble b2;

ovalShape2->Location = System::Drawing::Point(b2.X, b2.Y);

ovalShape2->Size = System::Drawing::Size(b2.diam, b2.diam);

}

if (ovalShape3->Location.X < 1)

{

bubble b3;

ovalShape3->Location = System::Drawing::Point(b3.X, b3.Y);

ovalShape3->Size = System::Drawing::Size(b3.diam, b3.diam);

}

if (ovalShape4->Location.X < 1)

{

bubble b4;

ovalShape4->Location = System::Drawing::Point(b4.X, b4.Y);

ovalShape4->Size = System::Drawing::Size(b4.diam, b4.diam);

}

if (ovalShape5->Location.X < 1)

{

bubble b5;

ovalShape5->Location = System::Drawing::Point(b5.X, b5.Y);

ovalShape5->Size = System::Drawing::Size(b5.diam, b5.diam);

}

if (ovalShape6->Location.X < 1)

{

bubble b6;

ovalShape6->Location = System::Drawing::Point(b6.X, b6.Y);

ovalShape6->Size = System::Drawing::Size(b6.diam, b6.diam);

}

if (ovalShape7->Location.X < 1)

{

bubble b7;

ovalShape7->Location = System::Drawing::Point(b7.X, b7.Y);

ovalShape7->Size = System::Drawing::Size(b7.diam, b7.diam);

}

if (ovalShape8->Location.X < 1)

{

bubble b8;

ovalShape8->Location = System::Drawing::Point(b8.X, b8.Y);

ovalShape8->Size = System::Drawing::Size(b8.diam, b8.diam);

}

if (ovalShape9->Location.X < 1)

{

bubble b9;

ovalShape9->Location = System::Drawing::Point(b9.X, b9.Y);

ovalShape9->Size = System::Drawing::Size(b9.diam, b9.diam);

}

if (ovalShape10->Location.X < 1)

{

bubble b10;

ovalShape10->Location = System::Drawing::Point(b10.X, b10.Y);

ovalShape10->Size = System::Drawing::Size(b10.diam, b10.diam);

}

}

private: System::Void timer2_Tick(System::Object^ sender, System::EventArgs^ e)

{

int k = 0;

int ro;

\\задания размеров и координат

x = ovalShape1->Location.X;

y = ovalShape1->Location.Y;

d = ovalShape1->Size.Width;

ro = puz(d);

\\ условия исчезновения

if (ovalShape1->Location.Y > 20)

ovalShape1->Location = System::Drawing::Point(x, y-ro);

else

ovalShape1->Location = System::Drawing::Point(x-200, y);

x = ovalShape2->Location.X;

y = ovalShape2->Location.Y;

d = ovalShape2->Size.Width;

ro = puz(d);

if (ovalShape2->Location.Y > 20)

ovalShape2->Location = System::Drawing::Point(x, y-ro);

else

ovalShape2->Location = System::Drawing::Point(x-200, y);

x = ovalShape3->Location.X;

y = ovalShape3->Location.Y;

d = ovalShape3->Size.Width;

ro = puz(d);

if (ovalShape3->Location.Y > 20)

ovalShape3->Location = System::Drawing::Point(x, y-ro);

else

ovalShape3->Location = System::Drawing::Point(x-200, y);

x = ovalShape4->Location.X;

y = ovalShape4->Location.Y;

d = ovalShape4->Size.Width;

ro = puz(d);

if (ovalShape4->Location.Y > 20)

ovalShape4->Location = System::Drawing::Point(x, y-ro);

else

ovalShape4->Location = System::Drawing::Point(x-200, y);

x = ovalShape5->Location.X;

y = ovalShape5->Location.Y;

d = ovalShape5->Size.Width;

ro = puz(d);

if (ovalShape5->Location.Y > 20)

ovalShape5->Location = System::Drawing::Point(x, y-ro);

else

ovalShape5->Location = System::Drawing::Point(x-200, y);

x = ovalShape6->Location.X;

y = ovalShape6->Location.Y;

d = ovalShape6->Size.Width;

ro = puz(d);

if (ovalShape6->Location.Y > 20)

ovalShape6->Location = System::Drawing::Point(x, y-ro);

else

ovalShape6->Location = System::Drawing::Point(x-200, y);

x = ovalShape7->Location.X;

y = ovalShape7->Location.Y;

d = ovalShape7->Size.Width;

ro = puz(d);

if (ovalShape7->Location.Y > 20)

ovalShape7->Location = System::Drawing::Point(x, y-ro);

else

ovalShape7->Location = System::Drawing::Point(x-200, y);

x = ovalShape8->Location.X;

y = ovalShape8->Location.Y;

d = ovalShape8->Size.Width;

ro = puz(d);

if (ovalShape8->Location.Y > 20)

ovalShape8->Location = System::Drawing::Point(x, y-ro);

else

ovalShape8->Location = System::Drawing::Point(x-200, y);

x = ovalShape9->Location.X;

y = ovalShape9->Location.Y;

d = ovalShape9->Size.Width;

ro = puz(d);

if (ovalShape9->Location.Y > 20)

ovalShape9->Location = System::Drawing::Point(x, y-ro);

else

ovalShape9->Location = System::Drawing::Point(x-200, y);

x = ovalShape10->Location.X;

y = ovalShape10->Location.Y;

d = ovalShape10->Size.Width;

ro = puz(d);

if (ovalShape10->Location.Y > 20)

ovalShape10->Location = System::Drawing::Point(x, y-ro);

else

ovalShape10->Location = System::Drawing::Point(x-200, y);

}

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)

{

if (start == true)\\условие нажатия кнопки

{

timer1->Enabled = false;

timer2->Enabled = false;

button1->Text = "start";

start = false;

}

else

{

timer1->Enabled = true;

timer2->Enabled = true;

button1->Text = "pause";

start = true;

}

}

};

}

Header1 файл:\\создание класса

#include <stdlib.h>

class bubble

{

public:

int diam;\\объявление переменных

int X;

int Y;

bubble()

{

diam = rand()%15+4;\\задание переменных

X = rand()%130+15;

Y = rand()%200+15;

};

~bubble()

{};

};