• Название:

    по Карпову (отчёт про Кирпич) не совсем правиль...

  • Размер: 0.13 Мб
  • Формат: DOCX
  • или


ГОУ ВПО Удмуртский Государственный Университет

Математический факультет

Кафедра вычислительной механики

Отчёт

по теме

«Движение объекта при определённых условиях»

Выполнил: гр.О-010500-31

Костюк Д.С.

Научный руководитель:

Карпов А.И.

Ижевск 2011 год

Постановка задачи

Найти зависимость v(t) и x(t) при падении кирпича, если v0=0.

Математическая модель

Построим математическую модель падающего кирпича. Запишем начальные условия движения:

при t=0: x=0, x=v0=0;

mT – масса кирпича;

VT – объём кирпича;

pT – плотность кирпича;

pcp – плотность среды;

S – площадь соприкосновения нижней части кирпича со средой;

Cf– коэффициент сопротивления;

v – скорость падения кирпича;

g- ускорение свободного падения;

поделим обе части на массу mT:

Обозначим А= , B= и после замены получим:

теперь решим это уравнение:

Листинг программы

#pragma once

#include <math.h>

namespace kirpi4 {

using namespace System;

using namespace System::ComponentModel;

using namespace System::Collections;

using namespace System::Windows::Forms;

using namespace System::Data;

using namespace System::Drawing;

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

{

private: System::Windows::Forms::Label^ label1;

private: System::Windows::Forms::Label^ label7;

private: System::Windows::Forms::TextBox^ textBox1;

private: System::Windows::Forms::Label^ label8;

private: System::Windows::Forms::DataGridView^ dataGridView1;

private: System::Windows::Forms::Panel^ panel1;

private: System::Windows::Forms::DataGridViewTextBoxColumn^ Column1;

private: System::Windows::Forms::DataGridViewTextBoxColumn^ Column2;

private: System::Windows::Forms::DataGridViewTextBoxColumn^ Column3;

private: System::Windows::Forms::TextBox^ textBox4;

private: System::Windows::Forms::TextBox^ textBox5;

private: System::Windows::Forms::Panel^ panel2;

private: System::Windows::Forms::Label^ label9;

private: System::Windows::Forms::Label^ label10;

private: System::Windows::Forms::Label^ label4;

public:

Form1(void)

{

InitializeComponent();

g=9.8;

//

//TODO: Add the constructor code here

//

}

protected:

/// <summary>

/// Clean up any resources being used.

/// </summary>

~Form1()

{

if (components)

{

delete components;

}

}

protected:

private: System::Windows::Forms::Label^ label2;

private: System::Windows::Forms::Label^ label3;

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

private: System::Windows::Forms::TextBox^ textBox2;

private: System::Windows::Forms::TextBox^ textBox3;

private: System::Windows::Forms::Label^ label5;

private: System::Windows::Forms::Label^ label6;

private:

System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code

void InitializeComponent(void)

{

System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle1 = (gcnew System::Windows::Forms::DataGridViewCellStyle());

System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle2 = (gcnew System::Windows::Forms::DataGridViewCellStyle());

System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle3 = (gcnew System::Windows::Forms::DataGridViewCellStyle());

this->label2 = (gcnew System::Windows::Forms::Label());

this->label3 = (gcnew System::Windows::Forms::Label());

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

this->textBox2 = (gcnew System::Windows::Forms::TextBox());

this->textBox3 = (gcnew System::Windows::Forms::TextBox());

this->label5 = (gcnew System::Windows::Forms::Label());

this->label6 = (gcnew System::Windows::Forms::Label());

this->label1 = (gcnew System::Windows::Forms::Label());

this->label4 = (gcnew System::Windows::Forms::Label());

this->label7 = (gcnew System::Windows::Forms::Label());

this->textBox1 = (gcnew System::Windows::Forms::TextBox());

this->label8 = (gcnew System::Windows::Forms::Label());

this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView());

this->Column1 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());

this->Column2 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());

this->Column3 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());

this->panel1 = (gcnew System::Windows::Forms::Panel());

this->textBox4 = (gcnew System::Windows::Forms::TextBox());

this->textBox5 = (gcnew System::Windows::Forms::TextBox());

this->panel2 = (gcnew System::Windows::Forms::Panel());

this->label10 = (gcnew System::Windows::Forms::Label());

this->label9 = (gcnew System::Windows::Forms::Label());

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->dataGridView1))->BeginInit();

this->panel1->SuspendLayout();

this->panel2->SuspendLayout();

this->SuspendLayout();

//

// label2

//

this->label2->Location = System::Drawing::Point(19, 185);

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

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

this->label2->TabIndex = 3;

this->label2->Text = L"плотность тела:";

//

// label3

//

this->label3->Location = System::Drawing::Point(239, 185);

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

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

this->label3->TabIndex = 4;

this->label3->Text = L"плотность среды:";

this->label3->Visible = false;

//

// button1

//

this->button1->BackColor = System::Drawing::SystemColors::Control;

this->button1->Location = System::Drawing::Point(220, 34);

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

this->button1->Size = System::Drawing::Size(206, 125);

this->button1->TabIndex = 6;

this->button1->Text = L"Построить таблицу";

this->button1->UseVisualStyleBackColor = false;

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

//

// textBox2

//

this->textBox2->Location = System::Drawing::Point(50, 90);

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

this->textBox2->Size = System::Drawing::Size(55, 20);

this->textBox2->TabIndex = 8;

this->textBox2->Text = L"20";

//

// textBox3

//

this->textBox3->Location = System::Drawing::Point(50, 118);

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

this->textBox3->Size = System::Drawing::Size(55, 20);

this->textBox3->TabIndex = 9;

this->textBox3->Text = L"5";

//

// label5

//

this->label5->AutoSize = true;

this->label5->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->label5->Location = System::Drawing::Point(19, 91);

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

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

this->label5->TabIndex = 10;

this->label5->Text = L"a=";

//

// label6

//

this->label6->AutoSize = true;

this->label6->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->label6->Location = System::Drawing::Point(19, 121);

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

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

this->label6->TabIndex = 11;

this->label6->Text = L"b=";

//

// label1

//

this->label1->AutoSize = true;

this->label1->Location = System::Drawing::Point(114, 93);

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

this->label1->Size = System::Drawing::Size(21, 13);

this->label1->TabIndex = 12;

this->label1->Text = L"см";

//

// label4

//

this->label4->AutoSize = true;

this->label4->Location = System::Drawing::Point(114, 121);

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

this->label4->Size = System::Drawing::Size(21, 13);

this->label4->TabIndex = 13;

this->label4->Text = L"см";

//

// label7

//

this->label7->AutoSize = true;

this->label7->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->label7->Location = System::Drawing::Point(19, 147);

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

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

this->label7->TabIndex = 14;

this->label7->Text = L"c=";

//

// textBox1

//

this->textBox1->Location = System::Drawing::Point(50, 143);

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

this->textBox1->Size = System::Drawing::Size(55, 20);

this->textBox1->TabIndex = 15;

this->textBox1->Text = L"10";

//

// label8

//

this->label8->AutoSize = true;

this->label8->Location = System::Drawing::Point(114, 146);

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

this->label8->Size = System::Drawing::Size(21, 13);

this->label8->TabIndex = 16;

this->label8->Text = L"см";

//

// dataGridView1

//

this->dataGridView1->BackgroundColor = System::Drawing::SystemColors::ButtonHighlight;

this->dataGridView1->BorderStyle = System::Windows::Forms::BorderStyle::None;

this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;

this->dataGridView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(3) {this->Column1,

this->Column2, this->Column3});

this->dataGridView1->GridColor = System::Drawing::SystemColors::ControlText;

this->dataGridView1->Location = System::Drawing::Point(452, -1);

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

this->dataGridView1->Size = System::Drawing::Size(352, 485);

this->dataGridView1->TabIndex = 2;

//

// Column1

//

dataGridViewCellStyle1->Format = L"N1";

dataGridViewCellStyle1->NullValue = nullptr;

this->Column1->DefaultCellStyle = dataGridViewCellStyle1;

this->Column1->HeaderText = L"t (сек)";

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

this->Column1->ReadOnly = true;

this->Column1->Resizable = System::Windows::Forms::DataGridViewTriState::True;

//

// Column2

//

dataGridViewCellStyle2->Format = L"N5";

dataGridViewCellStyle2->NullValue = nullptr;

this->Column2->DefaultCellStyle = dataGridViewCellStyle2;

this->Column2->HeaderText = L"v (м,с)";

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

this->Column2->ReadOnly = true;

//

// Column3

//

dataGridViewCellStyle3->Format = L"N5";

dataGridViewCellStyle3->NullValue = nullptr;

this->Column3->DefaultCellStyle = dataGridViewCellStyle3;

this->Column3->HeaderText = L"Y";

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

this->Column3->ReadOnly = true;

//

// panel1

//

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

this->panel1->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;

this->panel1->Controls->Add(this->dataGridView1);

this->panel1->Dock = System::Windows::Forms::DockStyle::Bottom;

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

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

this->panel1->Size = System::Drawing::Size(805, 486);

this->panel1->TabIndex = 17;

//

// textBox4

//

this->textBox4->Location = System::Drawing::Point(117, 183);

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

this->textBox4->Size = System::Drawing::Size(100, 20);

this->textBox4->TabIndex = 3;

//

// textBox5

//

this->textBox5->Location = System::Drawing::Point(347, 182);

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

this->textBox5->Size = System::Drawing::Size(100, 20);

this->textBox5->TabIndex = 18;

this->textBox5->Text = L"1000";

this->textBox5->Visible = false;

//

// panel2

//

this->panel2->Controls->Add(this->label10);

this->panel2->Controls->Add(this->label9);

this->panel2->Controls->Add(this->textBox1);

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

this->panel2->Controls->Add(this->textBox5);

this->panel2->Controls->Add(this->label6);

this->panel2->Controls->Add(this->textBox4);

this->panel2->Controls->Add(this->label4);

this->panel2->Controls->Add(this->textBox3);

this->panel2->Controls->Add(this->label2);

this->panel2->Controls->Add(this->label7);

this->panel2->Controls->Add(this->label3);

this->panel2->Controls->Add(this->label8);

this->panel2->Controls->Add(this->label5);

this->panel2->Controls->Add(this->textBox2);

this->panel2->Controls->Add(this->label1);

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

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

this->panel2->Size = System::Drawing::Size(453, 488);

this->panel2->TabIndex = 3;

this->panel2->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::panel2_Paint);

//

// label10

//

this->label10->AutoSize = true;

this->label10->Font = (gcnew System::Drawing::Font(L"Arial Black", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast<System::Byte>(204)));

this->label10->Location = System::Drawing::Point(18, 9);

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

this->label10->Size = System::Drawing::Size(138, 38);

this->label10->TabIndex = 20;

this->label10->Text = L"\r\nПараметры тела";

//

// label9

//

this->label9->AutoSize = true;

this->label9->Location = System::Drawing::Point(22, 61);

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

this->label9->Size = System::Drawing::Size(169, 13);

this->label9->TabIndex = 19;

this->label9->Text = L"a - длина, b - высота, с - ширина";

//

// Form1

//

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

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

this->BackColor = System::Drawing::SystemColors::Control;

this->ClientSize = System::Drawing::Size(805, 486);

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

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

this->Name = L"Form1";

this->Text = L"ввод данных";

this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);

(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->dataGridView1))->EndInit();

this->panel1->ResumeLayout(false);

this->panel2->ResumeLayout(false);

this->panel2->PerformLayout();

this->ResumeLayout(false);

}

#pragma endregion

////////////////////////////////////////////////////////////////////////////////////////////

double g;double C,p,P,v1,v2,m,V,y1,y2,S,rr,wer,qq,u,nn;double t1,t2;

void AddTable (double t,double v,double y)

{

array <String ^>^ param = {t.ToString(),v.ToString(),y.ToString()};

this->dataGridView1->Rows->Add (param);

}

void SetParam ()

{

P=Convert::ToDouble (this->textBox4->Text);

p=Convert::ToDouble (this->textBox5->Text);

double a=Convert::ToDouble (this->textBox2->Text)/100;

double b=Convert::ToDouble (this->textBox3->Text)/100;

double c=Convert::ToDouble (this->textBox1->Text)/100;

V=a*b*c;m=V*P;S=a*c;

t1=0;v1=0;t2=0;y1=200;

}

void f ()

{v1=0;

t2=t2+1;

double A,B;

{

A=g*V*(P-1.29)/m;

B=1*(S*1.29)/2*m;

}

rr=pow(A/B,0.5);

wer=pow(2.718281828,2*B*rr*t2)*(rr+v1);

nn=(rr-v1+wer);

v2=(wer*rr-rr*(rr-v1))/nn;

y2=y1-v2*(t2-t1);

v1=v2;

t1=t2;

qq=y1;

y1=y2;

if ((qq>0)&&(y1<0)) {t2=t2-1;}

}

/////////////////////////////////////////////////////////////////////////////////////////////

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

int k=0;SetParam ();this->dataGridView1->Rows->Clear();

while (k<=500)

{

if ((qq>0)&&(y1<0)) {f ();}

else

{AddTable (t1,v1,y1);

f ();

k++;

}

}

}

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

}

private: System::Void panel2_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) {

}

};

}

Результаты

При запуске программы задаём размеры кирпича и плотность.

В результате, при нажатии по кнопке “Построить таблицу” мы получим

таблицу, в которой видно с какой скоростью падает и на какой высоте

находится кирпич в каждый момент времени.