-
Notifications
You must be signed in to change notification settings - Fork 0
/
Unit1.txt
143 lines (118 loc) · 3.89 KB
/
Unit1.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
const im = 20;
int Gd, Gm, k,i,m,j;
float dt,dTr,c,Tpl,at,xt,g,L,time1,dR,v;
float T[100];
float B[100];
float R[100];
float RR[100];
float tt[100]; int kmax;
AnsiString ss;
bool execute=true;
void __fastcall TForm1::Button1Click(TObject *Sender)
{ //void
if (execute==true)
{
//exicute=false;
time1=0;
R[1]=0.001; //radius of liquid
RR[1]=R[1];
R[im]=0.002; //radius of surrounded solid
g=2600; //kg/m**3 //closeness of matter
L=430000*2600; //heat of fusion, J/m**3
xt=207; //Bt/m/K; Parameters of Al
c=1179; //heat capacity J/kg/grad
at=xt/(g*c); //m^^2/s
dR=(R[im]-R[1])/(im-1);
dt=0.02*dR*dR/at;
Tpl=660; //temperature of fusion
T[2]=659.8; T[3]=620; T[4]=540; T[5]=440;
T[1]=Tpl;
for (m=6; m<=im; m++) T[m]=20;
for (i=2; i<=im-1; i++) R[i]=R[i-1]+dR;
B[1]=Tpl;
v=xt*(T[2]-T[1])/(dR*L);
Form1->Canvas->Brush->Color = clGray;
Form1->Canvas->FillRect(Rect(0,200,450,450));
kmax=1;
for (k=1; k<=20; k++)
{ for(j=1; j<=1000; j++)
{
for (i=2; i<=im-1; i++)
{
dR=(R[im]-R[1])/(im-1);
R[i]= R[im]-dR*(im-i);
dTr=(T[i+1]-T[i-1])/(2*dR); //first derivation
B[i]=T[i]+dt*at*(((T[i+1]+T[i-1]-2*T[i])/(dR*dR))+dTr*2/R[i]);
B[i]=B[i]+v*dt*(im-i)/(im-1)*dTr;
}
for (i=2; i<=im; i++) T[i]=B[i];
v=xt*(T[2]-T[1])/(dR*L);
R[1]=R[1]+v*dt; time1=time1+dt;
/*Form1->Canvas->Brush->Style = bsSolid;
Form1->Canvas->Brush->Color = clBlue;
Form1->Canvas->FillRect(Rect(0,200,420,420));
Form1->Canvas->Pen->Color = clRed;*/
//drawing of fill circle
/*Form1->Canvas->Ellipse(200,200, abs(R[1]*100000),abs (R[1]*100000));
Form1->Canvas->Pen->Color = clBlack; */
// for (i=1; i<=8; i++)
if (j==1) // || (j==500))
{
int RKK= R[1]*100000;
Form1->Canvas->Brush->Color = clGray;
Form1->Canvas->FillRect(Rect(0,200,450,450));
/*Form1->Canvas->Brush->Color = clRed;
Form1->Canvas->Ellipse(200-RKK, 200-RKK,
200+RKK, 200+RKK); */
Form1->Canvas->Brush->Color = clLtGray;
Form1->Canvas->FillRect(Rect(0,0,450,200));
Form1->Canvas->Brush->Color = clGray;
for (i=8; i>=1; i--)
{ int RK= R[i]*100000;
Form1->Canvas->RoundRect(200-RK, 200-RK,
200+RK, 200+RK,2*RK,2*RK);
if(i%2==0)
{ int TTT=T[i];
ss=IntToStr(abs(TTT));
Form1->Canvas->TextOutA(190,RK+196,ss);
}
}
Form1->Canvas->Brush->Color = clRed;
Form1->Canvas->Ellipse(200-RKK, 200-RKK,
200+RKK, 200+RKK);
Form1->Canvas->Brush->Color = clLtGray;
Form1->Canvas->FillRect(Rect(0,0,450,200));
Sleep(400);
if (R[1]<=0.00001) break;
} //end if j=1
//if (R[1]<=0.00001)
for (i=1; i<=5; i++)
Memo1->Lines->Add(FloatToStrF(T[i], ffGeneral, 10, 6));
} // end in j=500
RR[k]=R[1]; tt[k]=time1; kmax +=1; //in cycle in k
if (R[1]<=0.00001) break;
} //end in k
for (k=1; k < kmax; k++)
Memo1->Lines->Add(FloatToStrF(RR[k], ffGeneral, 10, 4));
} execute=false; //end if true
} // end of void
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
execute=true;
}
//---------------------------------------------------------------------------