Escolar Documentos
Profissional Documentos
Cultura Documentos
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Buttons, Vcl.Grids, Vcl.ComCtrls,
Vcl.Imaging.pngimage, Vcl.ExtCtrls, VclTee.TeeGDIPlus, VCLTee.TeEngine,
VCLTee.TeeProcs, VCLTee.Chart, VCLTee.Series, Vcl.StdCtrls;
type
TFrmPrincipal = class(TForm)
SpeedButton1: TSpeedButton;
SGResultados: TStringGrid;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
Image1: TImage;
NCelulas: TLabeledEdit;
QscT: TLabeledEdit;
BrefT: TLabeledEdit;
PinicT: TLabeledEdit;
PorusT: TLabeledEdit;
Visct: TLabeledEdit;
compt: TLabeledEdit;
permt: TLabeledEdit;
Lxt: TLabeledEdit;
lyt: TLabeledEdit;
lzt: TLabeledEdit;
ttst: TLabeledEdit;
itermaxt: TLabeledEdit;
tolt: TLabeledEdit;
Chart1: TChart;
Series1: TFastLineSeries;
Series2: TFastLineSeries;
Series3: TFastLineSeries;
procedure SpeedButton1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FrmPrincipal: TFrmPrincipal;
implementation
{$R *.dfm}
TTSt.Text := '860000';
itermaxt.Text := '1000';
tolt.Text := '1';
end;
Qsc, DeltaX, Bref, Pinic, Porus, Visc, Comp, Perm, tol, Vbulk, Gamma, Paux,
t, erro, pmeio,pinicio,pfim : Double;
begin
series1.Clear;
series2.Clear;
series3.Clear;
linha := 1;
SGResultados.Cells[1,0] := 'Tempo (em segundos)';
SGResultados.Cells[0,0] := 'N da Iterao';
SGResultados.Cells[2,0] := 'Primeira Clula';
SGResultados.Cells[3,0] := 'Clula Central';
SGResultados.Cells[4,0] := 'ltima Clula';
Qsc := StrToFloat(Qsct.Text);
Bref := StrToFloat(Breft.Text);
Pinic := Power10(StrToFloat(Pinict.Text),-6);
Porus := StrToFloat(Porust.Text);
Visc := Power10(StrToFloat(Visct.Text),-3);
Comp := Power10(StrToFloat(Compt.Text),-10);
Perm := Power10(StrToFloat(permt.Text),-15) ;
Lx := StrToInt(lxt.Text) ;
Ly := StrToInt(lyt.Text) ;
Lz := StrToInt(lzt.Text) ;
NC := StrToInt(NCelulas.Text) ;
NT := 10 ;
TTS := StrToInt(ttst.Text) ;
DeltaT := Trunc(TTS/NT) ;
Ax := Ly*Lz ;
DeltaX := Lx/NC ;
Vbulk := Ax*DeltaX ;
Gamma := (Vbulk*Porus*Comp)/(Bref);
iter_max := StrToInt(itermaxt.Text);
tol := Power10(StrToFloat(tolt.Text),-3);
SetLength(Q,NC+1);
SetLength(B,NC+1);
SetLength(P,NC+1);
SetLength(Pold,NC+1);
SetLength(Tx1,NC+1);
SetLength(Tx2,NC+1);
SetLength(COEF,NC+1);
SetLength(Bmed,NC+1);
Rewrite(pressoescentrais);
Rewrite(pressoesfinais);
i := 0;
while (i<NC) do
begin
Q[i] := 0;
i := i + 1;
end;
Q[Trunc((NC-1)/2)] := Qsc;
i := 0;
while (i<NC) do
begin
P[i] := Pinic;
Pold[i] := Pinic;
i := i + 1;
end;
i := 0;
while (i<NC) do
begin
B[i] := Bref / (1+Comp*(Pold[i]-Pinic));
i := i + 1;
end;
i := 0;
while (i<NC) do
begin
Bmed[i] := 0.5*(B[i]+B[i+1]);
i := i + 1;
end;
iteracoes := 0;
i := 0;
while (i<NC) do
begin
B[i] := Bref / (1+Comp*(Pold[i]-Pinic));
Bmed[i] := 0.5*(B[i]+B[i+1]);
Tx1[i] := Ax*Perm / (Visc*Bmed[i]);
i := i + 1;
end;
Paux := ((Tx1[0]*P[1])+((Gamma*Pold[0])/DeltaT)+Q[0])/(Tx1[0]+
(Gamma/DeltaT));
Pold[0] := Paux;
P[0] := Paux;
SGResultados.Cells[2,linha] :=
FormatFloat('###,###,###,###,###,##0.000.000.000.000',Paux);
Writeln(pressoesiniciais, (floattostr(t) + ' *** ' +
FormatFloat('###,###,###,###,###,##0.000.000.000.000',Paux)));
Series1.add(Paux,floattostr(t));
i := 1;
while (i<NC-1) do
begin
Paux :=((Tx1[i]*P[i+1])+(Tx1[i-1]*P[i-1])+((Gamma*Pold[i])/DeltaT)
+Q[i])/(Tx1[i]+Tx1[i-1]+(Gamma/DeltaT));
Pold[i] := Paux;
P[i] := Paux;
if ( i = ((NC-1)/2) ) then
begin
SGResultados.Cells[3,linha] :=
FormatFloat('###,###,###,###,###,##0.000.000.000.000',Paux);
Writeln(pressoescentrais, (floattostr(t) + ' *** ' +
FormatFloat('###,###,###,###,###,##0.000.000.000.000',Paux)));
Series2.add(Paux,floattostr(t));
end
else if ( i = (NC-2)) then
begin
SGResultados.Cells[4,linha] :=
FormatFloat('###,###,###,###,###,##0.000.000.000.000',Paux);
Writeln(pressoesfinais, (floattostr(t) + ' *** ' +
FormatFloat('###,###,###,###,###,##0.000.000.000.000',Paux)));
Series3.add(Paux,floattostr(t));
end;
i := i + 1;
end;
Paux := ((Tx1[NC-1]*P[NC-1])+((Gamma*Pold[NC])/DeltaT)+Q[NC])/
(Tx1[NC-1]+(Gamma/DeltaT));
Pold[NC] := Paux;
P[NC] := Paux;
erro := -1;
i := 1;
while(i<=NC) do
begin
erro := erro + Abs(Paux-P[i]);
i := i + 1;
end;
SGResultados.Cells[1,linha] := FloatToStr(t);
SGResultados.Cells[0,linha] := FloatToStr(iteracoes);
linha := linha + 1;
t := t + DeltaT;
end;
iteracoes := iteracoes + 1;
end;
SGResultados.RowCount := linha;
CloseFile(pressoesfinais);
CloseFile(pressoesiniciais);
CloseFile(pressoescentrais);
end;
end.