Advertisement
Guest User

Untitled

a guest
May 30th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. """
  2. Created on Sat May 30 16:36:44 2015
  3.  
  4. @author: ameyah
  5. """
  6.  
  7. from __future__ import division
  8. import numpy as np
  9. from numpy import linalg as lin
  10. #from matplotlib import pyplot as plt
  11. #from scipy.special import hermite as herm # hermite-polynoms
  12.  
  13. # all parameters and stuff
  14. heff = 0.05
  15. xmin = -1.5
  16. xmax = 1.5
  17. N = 100
  18. dx = (xmax-xmin)/(N-1)
  19. x = np.linspace(xmin, xmax, N-1)
  20. z = heff**2/(2*dx**2)
  21.  
  22. #wtf is V? lets say V=0.5*x**2 here harmonic oscillator as example
  23. V=0.5*x**2
  24. A=0.04
  25.  
  26. def H(V,z,A,N,dx):
  27.     return (np.diag(V(xmin + np.arange(1, N)*dx, A) + 2*z) +
  28.     np.diag(-np.ones(N-2)*z, -1) + np.diag(-np.ones(N-2)*z, 1))
  29.     # brackets because to separate 2 lines of code for the return
  30.    
  31. ew, ev = lin.eigh(H) # 0-dim array given, linalgerror :/ any ideas?!
  32.  
  33.  
  34. #plt.plot(x,V)
  35.  
  36.  
  37.  
  38. #def eigen(H):
  39. #    [ev, ew] = la.eigh(H)
  40. #    return [ev, ew]
  41.    
  42.  
  43.    
  44. #print potential(0.05, np.linspace(x_min, x_max, delta))
  45. #print
  46.    
  47. #[ew, ev] = matrix.Eigen
  48. #print ew
  49.    
  50. # test if Eigenvalues are normed to 1, hmm this works
  51. #print np.sum(np.abs(ev[:, i])**2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement