Guest User

Untitled

a guest
May 30th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4. halfpi, pi, twopi = [f*np.pi for f in (0.5, 1, 2)]
  5. to_degs, to_rads = 180/pi, pi/180
  6. root2, r3o2 = np.sqrt(2.), np.sqrt(3)/2.
  7.  
  8. nmax = 16
  9.  
  10. i = np.arange(-nmax, nmax+1)
  11. I, J = np.meshgrid(i, i)
  12. keep = (np.abs(I + J) <= nmax) * ~((I==0) * (J==0)) # [1:] avoids (0, 0)
  13. I, J = [thing[keep].flatten() for thing in (I, J)]
  14. u_dots = np.vstack((I + 0.5*J, r3o2 * J))
  15.  
  16. k, l = 3, 1
  17.  
  18. nmax = 4
  19. i = np.arange(-nmax, nmax+1)
  20. I, J = np.meshgrid(i, i)
  21. keep = (np.abs(I + J) <= nmax) * ~((I==0) * (J==0)) # [1:] avoids (0, 0)
  22. I, J = [thing[keep].flatten() for thing in (I, J)]
  23.    
  24. i_super = I * k + J * (-l)
  25. j_super = I * l + J * (k+l)
  26.    
  27. u_dots_super = np.vstack((i_super + 0.5*j_super, r3o2 * j_super))
  28.  
  29. plt.figure()
  30. x, y = u_dots
  31. plt.scatter(x, y, s=12)
  32. plt.gca().set_aspect('equal')
  33. xlims = plt.xlim()
  34. ylims = plt.ylim()
  35. x, y = u_dots_super
  36. plt.scatter(x, y, s=32, c='red')
  37. plt.gca().set_aspect('equal')
  38. plt.show()
Add Comment
Please, Sign In to add comment