Last active
November 13, 2020 20:44
-
-
Save animesh-77/409376b89ea6ee1eec9f71399946240c to your computer and use it in GitHub Desktop.
alkesh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| z=1j | |
| x=np.linspace(-30,30,1000) # 1000 equidistant points in [-30,30] | |
| x0=19 #position of the barrier | |
| psi0=np.sin(x0) | |
| psii=np.zeros(np.size(x)) #for incident | |
| psir=np.zeros(np.size(x)) # for refelcted | |
| for pos in range(np.size(x)): | |
| x_val=x[pos] | |
| if (x_val<=x0): # before barrier | |
| psii[pos]=np.sin(x_val) | |
| psir[pos]=psi0*np.cos(x_val-x0) | |
| else: # after barrier | |
| psit=psi0*np.exp(-(x_val-x0)*z).real #taking the real part | |
| psii[pos]=psit | |
| psir[pos]=psit | |
| plt.figure(figsize=[12,8]) | |
| plt.axvline(x=x0,color="black",linestyle="--") | |
| plt.grid() | |
| plt.ylim((-1.5,1.5)) | |
| plt.xlabel("x (nm)") | |
| plt.ylabel("psi ") | |
| plt.text(x0,1,"boundary",size=15) | |
| plt.plot(x,psii,label="incident") | |
| plt.plot(x,psir,label="reflected") | |
| plt.legend() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment