from __future__ import division from visual import * from visual.graph import * #x is in nm and E is in eV E_rest=0.511e6 hc=1240 E=0.29765 #values of x N=1000 #starting value of x x_left=-1 #ending value of x x_right=1 #x increment dx=(x_right-x_left)/N #Define V list and Vmax V=[] Vmax=10 #Create the graph windows and define the curves that wil be plotted VGraphWindow = gdisplay(x=0,y=0,width=400, ymax=Vmax, ymin=-Vmax, xmin=x_left, xmax=x_right) Vgraph=gcurve() PsiGraphWindow = gdisplay(x=0,y=400,width=400, xmin=x_left, xmax=x_right) Psigraph=gcurve(color=color.cyan) #Plot V for x in arange(x_left,x_right,dx): leftWall=-0.5 rightWall=0.5 if(xrightWall): V.append(Vmax) Vgraph.plot(pos=(x,Vmax)) else: V.append(0) Vgraph.plot(pos=(x,0)) #Define first two values of Psi Psi_0=0 Psi_1=1e-6 #Psi list Psi=[] #i is a counter i=0 #Calculate and plot Psi for x in arange(x_left,x_right,dx): if(i==0): Psi.append(Psi_0) Psigraph.plot(pos=(x,Psi_0)) elif(i==1): Psi.append(Psi_1) Psigraph.plot(pos=(x,Psi_1)) else: #fill in the calculation for Psi, append it to the list, and plot it i=i+1