' h5clib.bas - jackord@kw.igs.net - 16 Dec 02 - Liberty Basic v3.01 ' the two lowest energy states of a double well (an infinite square well ' with a central barrier) ' Initialize Window nomainwin button#1, "State1", [b1], UL, 25, 200, 60, 20 button#1, "State2", [b2], UL, 105, 200, 60, 20 WindowWidth=410 ' pixel scale 0-400 WindowHeight=329 ' pixel scale 0-300 UpperLeftX=10: UpperLeftY=100 open "The Double Well" for graphics_nsb as #1 ' no slide bars #1 "trapclose [quit]" dx=1: k=4*atn(1)/400: k=k*k gosub [grid] [waitHere] wait [b1] kk=1: goto [eigen] [b2] kk=2: goto [eigen] [eigen] gosub [grid] n=200: de=.00001: b=3.8: c=4.2 ' Bisection Algorithm e=b: gosub [fey]: yb=y e=c: gosub [fey]: yc=y if yb*yc<0 then while c-b>de e=(b+c)/2: gosub [fey] if y*yb>0 then b=e else c=e wend #1 "color red": e=(b+c)/2: n=400: gosub [fey] #1 "place 50 240" #1 "\E"; kk; " = "; left$(str$(e), 7) end if goto [waitHere] [fey] a=0-e*k: y=0: v=2: #1 "place 0 150" for i=1 to n y=y+v*dx: #1 "goto "; i; " "; 150-int(y) if i=192 then a=(200-e)*k if i=209 then a=0-e*k v=v+a*y*dx next i if kk=1 then y=v-a*y*dx/2 return [grid] #1 "cls ; down" #1 "color green ; backcolor green ; place 192 0 ; boxfilled 208 300" #1 "color black ; backcolor white ; line 0 150 400 150 ; color blue" return [quit] close #1 end