REM nm7bbc.bas - jackord@kw.igs.net - 21 Nov 07 - BBC Basic v5.50b REM wave pulse incident on a variable thickness segment where the mass density REM increases by a factor of 1.44 followed by a region where the mass density REM increases again by a factor of 1.44 REM the motion is generated directly from Newton's Law REM or a superposition of (non-orthogonal) normal mode displacements *FLOAT64 INSTALL @lib$+"WINLIB5" REM Initialize Window b1% = FN_button("Pulse B", 10, 5, 60, 20, FN_setproc(PROCp1), 0) b2% = FN_button("Motion", 80, 5, 60, 20, FN_setproc(PROCp2), 0) c1% = FN_combobox("", 150, 5, 90, 120, 0, 3) c2% = FN_combobox("", 250, 5, 70, 40, 0, 3) WindowWidth=480 WindowHeight=220 VDU 23,22,WindowWidth;WindowHeight;8,15,16,128 SYS "SetWindowText", @hwnd%, "Pulse Striking Interface" SYS "SendMessage", c1%, &143, 0, "D(film)=0" SYS "SendMessage", c1%, &143, 1, "D(film)=5" SYS "SendMessage", c1%, &143, 1, "D(film)=10" SYS "SendMessage", c1%, &14E, 0, 0 SYS "SendMessage", c2%, &143, 0, "F=ma" SYS "SendMessage", c2%, &143, 1, "FFSS" SYS "SendMessage", c2%, &14E, 0, 0 DIM y(480): DIM v(480) n=480: nf=320: nk=4: kk=0: dt=0.9: no=48: nw=96 OFF: VDU 5 REPEAT WAIT 1 UNTIL FALSE QUIT DEF PROCp1: kk=1: jt=0: plt=0 : REM Pulse B DEF PROCp2: IF kk>0 THEN plt=1 : REM Motion IF jt=0 THEN SYS "SendMessage", c1%, &147, 0, 0 TO ch1% SYS "SendMessage", c2%, &147, 0, 0 TO ch2% dl=5*ch1%: e1=0: e2=0 FOR i=0 TO n : REM Initialize y(i)=0: v(i)=0 NEXT i FOR i=no TO no+nw q=(i-no)*2*PI/nw y(i)=80*(1-COS(q)) v(i)=-80*2*PI/nw*SIN(q) v(i)=v(i)*COS(nk*q)+y(i)*nk*2*PI/nw*SIN(nk*q) y(i)=y(i)*COS(nk*q) e1=e1+v(i)*v(i) NEXT i FOR i=no TO no+nw : REM Feynman half-step v(i)=v(i)+(y(i-1)+y(i+1)-2*y(i))*dt/2 NEXT i ENDIF IF plt=1 THEN * REFRESH OFF tt=TIME WHILE jt=0 OR plt=1 CLS: GCOL 0: MOVE 700, 420: PRINT "Frame "; jt; "/320" GCOL 12: MOVE 0, 190 FOR i=1 TO n IF i=n/2 THEN GCOL 10 IF i=n/2+dl THEN GCOL 9 DRAW 2*i, 190+INT(y(i)+1) NEXT i IF plt=1 THEN * REFRESH jt=jt+1 FOR i=1 TO n-1 : REM F=ma y(i)=y(i)+v(i)*dt NEXT i m=1 FOR i=1 TO n-1 IF i=n/2 THEN m=1.44*m IF i=n/2+dl THEN m=m*1.44 v(i)=v(i)+(y(i-1)+y(i+1)-2*y(i))/m*dt NEXT i IF jt=nf+1 THEN plt=0: kk=0 FOR i=1 TO n/2-1: e2=e2+v(i)*v(i): NEXT i GCOL 0: MOVE 20, 370 PRINT "Reflects "; INT(10000*e2/e1)/100; " % of incident energy" * REFRESH ON ENDIF ENDWHILE ENDPROC