Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. Created on Thu Sep 19 01:25:30 2019
  5.  
  6. @author: jzonkey
  7. """
  8.  
  9. from mpl_toolkits import mplot3d
  10. import numpy as np
  11. import matplotlib.pyplot as plt
  12.  
  13. #enables 3D axes
  14. fig = plt.figure()
  15. ax = plt.axes(projection='3d')
  16.  
  17. #constants
  18. A = np.pi
  19. epsnot =  8.854187817e-12
  20. q = 1.6e-19
  21.  
  22. #variables
  23. Z = np.linspace(1,.1,11)
  24. R = np.linspace(1,1,11)
  25.  
  26. #expresses E as a function of Z and R
  27. def e_func(R,Z):
  28.     return (q/2*A*epsnot)*(1-(Z/R))
  29. E = e_func(R, Z)
  30.  
  31. #plot
  32. ax.plot3D(R, Z, E, 'gray')
  33. plt.show()
  34.  
  35. ax.set_xlabel('R')
  36. ax.set_ylabel('Z')
  37. ax.set_zlabel('E')
  38. ax.set_title('Electric Field of Ring When Z<<R')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement