|
|||
begin. whilet<=tk do. while(x>t) do. whilet<=tk dobegin Init; OutRes(t, y, clred); Euler; end.
5)гармонические колебания маятника(см7) program koleb; uses GraphABC; const tk=10; dt=0. 0005; w=6; beta=0. 5; m=1; k=1. 5; g=9. 81; var Sx, Sy, t, v, a, x, v0, h, x0, E: real; Hv, Hu: integer; procedure out ( var x, y: real; c: system. Drawing. color); Begin var u, v: integer; u: =round(Hu+Sx*x); v: =round(Hv-Sy*y*2); putPixel(u, v, c); end; procedure Euler; begin whilet< =tk do begin a: =(-k*x)/m-beta*v; v: =v+a*dt; x: =x+v*dt; E: =((m*v*v/2)+m*g*h); out (t, E, ClBlue); out (t, x, Clred); v0: =v; x0: =x; out (x0, v0, Clgreen); t: =t+dt; end; end; begin t: =0; v: =1; a: =3; Hu: =45; Hv: =Window. Center. y; Sx: =WindowWidth/tk; Sy: =WindowHeight; Euler; Line(0, Hv, Window. Width, Hv); Line(Hu, 0, Hu, Window. Height); window. Title: =' график колебаний ' end. 6) ангармоническое колебание физ. маятника program osc; uses graphABC; var a, dt, v, t, rx, ry, Sy, Sx, Hu, Hv, g, k, k1, m, w, x, f: real;
procedure OutRes(x, y: real; c: color); var u, v: word; begin u: =round(x*Sx + Hu); v: =round(-y*Sy + Hv); PutPixel(u, v, c); end;
procedure Init; begin v: =0; t: =0; m: =20; k: =2; k1: =2; w: =k/m; x: =30; g: =k1/m; dt: =0. 001; f: = 130; rx: =10; ry: =100; Hu: =3; Hv: =Window. Height-3; Sx: =Window. Width/rx; Sy: =Window. Height/ry; Line(round(Hu), 0, round(Hu), Window. Height, clblack); Line(round(Hu), round(Hv), Window. Width, round(Hv), clbrown); end;
procedure Euler; begin while(x> t) do begin a: =-w*x - g*v + f*cos(3*t); //ускорение при применении силы для поддержания колебаний и силе сопротивления v: =v+a*dt; x: =x+v*dt; t: =t+dt; outres(t, x, clgreen); end; end;
begin Init; Euler; end. 7) затухающие колебания program koleb; uses GraphABC; const tk=10; dt=0. 0005; w=6; beta=0. 5; var Sx, Sy, t, v, a, x, v0, x0: real; Hv, Hu: integer; procedure out ( var x, y: real; c: system. Drawing. color); Begin var u, v: integer; u: =round(Hu+Sx*x); v: =round(Hv-Sy*y*2); putPixel(u, v, c); end; procedure Euler; begin whilet< =tk do begin a: =-w*w*x-beta*v; v: =v+a*dt; x: =x+v*dt; out (t, x, Clred); v0: =(-v/5); x0: =x*15+3; out (x0, v0, Clgreen); t: =t+dt; end; end;
|
|||
|