Расчет вероятности выхода из строя деталей автомобиля

Автор: Ivan Petrov, 10 Октября 2010 в 22:00, курсовая работа

Описание работы

Программа разработана в среде программирования Delphi
Плотность вероятности выхода из строя деталей автомобиля в результате старения материала описывается законом Вейбула: n
n n-1 -µ n
P(t)=nµ t e t ,где
P(t) – плотность вероятности выхода из строя за время эксплуатации t;
µ, n - параметры закона;
Вероятность выхода из строя деталей автомобиля в результате постепенного старения через Т лет эксплуатации определяется как:
T
Q(T)=∫ p(t)dt
0
Определить Q(T) при изменении Т от Тmin до Tmax с интервалом ΔТ для деталей 1, 2, 3 с параметрами n и µ:

Работа содержит 1 файл

Курсовой проект по ЯВУ.doc

— 272.50 Кб (Скачать)

end; 

procedure TForm1.N4Click(Sender: TObject);

begin

  close;

end; 

procedure TForm1.Button2Click(Sender: TObject);

var t,h,QQ,tm:real;

    i,j,count,year0,year1:integer;

begin

  If (Length(SpinEdit2.Text)=0) and (Length(SpinEdit2.Text)=0) then

  begin

   Application.MessageBox('Не указано время эксплуатации!!!',Pchar(Application.Title),MB_ICONERROR);

    exit;

  end;

  t:=strtofloat(SpinEdit2.Text);

  count:=SpinEdit1.Value;

  year0:=strtoint(SpinEdit2.Text);

  year1:=strtoint(SpinEdit3.Text);

  If year1>year0 then

  begin

    If count<=(year1-year0) then

    begin

      StringGrid1.RowCount:=trunc((year1-year0)/count+1);

      for j:=0 to length(n)-1 do

      begin

        i:=1;

        tm:=count;

        while tm<=(year1-year0) do

        begin

          QQ:=Q(tm,n[j],m[j]);

          StringGrid1.Cells[0,i]:=floatToStr(year0+tm);

          StringGrid1.Cells[1+j,i]:=format('%6.6f',[QQ]);

          tm:=tm+count;

          inc(i);

        end;

      end

    end

    else Application.MessageBox('Недопустимое значение шага интегрирования!!!',Pchar(Application.Title),MB_ICONERROR);

    end

    else Application.MessageBox('Неверно задан промежуток лет!',Pchar(Application.Title),MB_ICONERROR);

    N2.Enabled:=true;

end; 

procedure TForm1.load(Sender: TObject);

var s:string;

    f:TextFile;

    x,i:integer;

begin

  With TOpenDialog.Create( NIL ) do

  Try

   Filter := 'Text files (*.txt)|*.txt|';

   Options := Options + [ ofFileMustExist ];

   DefaultExt := 'txt';

   initialDir:='.';

   s:=' ';

  If ( NOT Execute ) then Exit;

  s:=FileName;

  Finally

  free;

end;

assignFile(f, s);reset(f);

try

  x:=0;

  while not eof(f) do begin

  readln(f);

  inc(x);

  end;

  setlength(n,x);

  setlength(m,x);

  reset(f);

  for i:=0 to x-1 do

  readln(f,n[i],m[i]);

  Panel2.Visible:=true;

  Panel3.Visible:=true;

  StringGrid1.Visible:=true;

  StringGrid1.ColCount:=x+1;

  StringGrid1.Cells[0,0]:='Время эксплуатации';

  StringGrid1.ColWidths[0]:=120;

  for i:=1 to x do

  begin

    StringGrid1.Cells[i,0]:=inttostr(i)+'-я деталь n='+floattostr(n[i-1])+' m='+floattostr(m[i-1]);

    StringGrid1.ColWidths[i]:=170;

  end;

  finally

  closeFile(f);

  end;

  N7.Enabled:=true;

end; 

//---сохранение-----

procedure TForm1.N2Click(Sender: TObject);

Var F:TextFile;

i, j, n:integer;

s:string;

begin

  n:=Form1.StringGrid1.RowCount-1;

  For j:=1 to n do

  for i:=0 to 4 do if (Form1.StringGrid1.Cells[i,j]=' ') then

  begin

    Application.MessageBox('Заполнены не все ячейки!!!',Pchar(Application.Title),MB_ICONERROR );

    exit;

  end;

  If ( NOT Form1.SaveDialog1.Execute ) then Exit;

  AssignFile(F, Form1.SaveDialog1.FileName);

  rewrite(F);

  Try

    s:=' ';

    for i:=0 to StringGrid1.ColCount-1 do s:=s+format('%30s',[StringGrid1.Cells[i,0]]);

    writeln(f,s);

    s:=''; 

    for i:=1 to StringGrid1.RowCount-1 do begin

     for j:=0 to StringGrid1.ColCount-1 do begin

      s:=s+format('%27s',[StringGrid1.Cells[j,i]])+' ';

      end;

     writeln(f,s);

     s:='';

    end;

  finally

  closeFile(F);

end;

end;

end.

Информация о работе Расчет вероятности выхода из строя деталей автомобиля