Advertisement
phystota

AE435HW4

Mar 10th, 2025
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.31 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4. # Constants and parameters
  5. mu0 = 4 * np.pi * 1e-7      # permeability of free space [H/m]
  6. amp_turn = 100              # amp-turn rating of calibration coil
  7. R = 0.1                    # radius of calibration coil [m]
  8. Np = 50                     # number of turns of the B-dot probe
  9. Dp = 0.005                  # diameter of probe [m]
  10. A = np.pi * (Dp/2)**2       # cross-sectional area of the probe [m^2]
  11.  
  12. # Define magnetic field along the z-axis for a circular loop
  13. def B(z):
  14.     return (mu0 * amp_turn * R**2) / (2 * (R**2 + z**2)**(3/2))
  15.  
  16. # Compute dB/dz analytically
  17. def dBdz(z):
  18.     # d/dz [ (R^2+z^2)^(-3/2) ] = -3z/(R^2+z^2)^(5/2)
  19.     return - (mu0 * amp_turn * R**2) * (3 * z) / (2 * (R**2 + z**2)**(5/2))
  20.  
  21. # Time array [s]
  22. t = np.linspace(0, 0.25, 1000)  # from 0 to 250 ms
  23.  
  24. # Define probe motion: initial position z0 = 0.2 m, moves to 0 m then back to 0.2 m.
  25. z = np.zeros_like(t)
  26. dz_dt = np.zeros_like(t)
  27. for i, ti in enumerate(t):
  28.     if ti < 0.1:  # 0 to 100 ms, moving in negative z at -2 m/s
  29.         dz_dt[i] = -2
  30.         z[i] = 0.2 - 2 * ti
  31.     elif ti < 0.15:  # 100 to 150 ms, stationary at z = 0
  32.         dz_dt[i] = 0
  33.         z[i] = 0.0
  34.     else:  # 150 to 250 ms, moving in positive z at +2 m/s
  35.         dz_dt[i] = 2
  36.         z[i] = 2 * (ti - 0.15)
  37.  
  38. # Calculate induced voltage using V(t) = - Np * A * (dB/dz) * (dz/dt)
  39. V = -Np * A * dBdz(z) * dz_dt
  40.  
  41. # Plot the voltage trace
  42. plt.figure(figsize=(8,4))
  43. plt.plot(t*1e3, V*1e6)  # converting time to ms and voltage to microvolts
  44. plt.xlabel('time, ms')
  45. plt.ylabel('induced voltage, ยตV')
  46. plt.title('Voltage trace')
  47. plt.grid(True)
  48. plt.show()
  49.  
  50.  
  51. import numpy as np
  52. import matplotlib.pyplot as plt
  53.  
  54. m_e = 9.1093837E-31 # electron mass
  55. M_Xe = 2.1801714E-25 # Xenon mass
  56. k = 1.38E-23 # Boltzmann constant
  57. T_tr = 11600
  58.  
  59.  
  60. T_e = [5, 50]   # electron temp
  61. T_i = [0.5, 5]  # ion temp
  62.  
  63. def VDF(m,V,T):
  64.     return (m/(2*np.pi*T*k*T_tr))**0.5 * np.exp(-m*V**2/(2*T*T_tr*k))
  65.  
  66. def SDF(m,C,T):
  67.     return 4*np.pi*C**2*(m/(2*np.pi*T*k*T_tr))**1.5 * np.exp(-m*C**2/(2*T*T_tr*k))
  68.  
  69. V = np.linspace(-10000, 10000, 200000)
  70.  
  71. plt.figure(figsize=(8, 5))
  72.  
  73. for T, label in zip(T_i, ['5 eV', '50 eV']):
  74.     y = VDF(M_Xe, V, T)
  75.     plt.plot(V, y, label=f'Temperature = {label}')
  76.  
  77. # Customize your plot
  78. plt.title(r'Speed distribution function for Xe')
  79. plt.xlabel(r'C, m/s')
  80. plt.ylabel(r'normalized distribution function')
  81. plt.grid(True)
  82. plt.legend()
  83.  
  84. # Display the plot
  85. plt.show()
  86.  
  87. import numpy as np
  88. import matplotlib.pyplot as plt
  89.  
  90.  
  91.  
  92. def func(x):
  93.     return (5.8e-17*x**4 - 3.71e-12*x**3 - 8e-8*x**2 + 6.37e-4*x + 6.97)/(-1.08e-21*x**5 +
  94.                                                                           1.86e-16*x**4 - 6.49e-12*x**3 + 8.97e-8*x**2 - 5.42e-4*x + 2.02)
  95.  
  96.  
  97. x = np.linspace(0, 15000, 100000)
  98. y = func(x)
  99.  
  100. plt.figure(figsize=(8, 5))  # Optional: set figure size
  101. plt.plot(x, y)
  102.  
  103. # Customize your plot
  104. plt.title('ratio of the partition functions of $Xe^+$ and Xe  ')
  105. plt.xlabel(r'$\theta$')
  106. plt.ylabel('$f_+/f_a$')
  107. plt.grid(True)
  108. plt.legend()
  109.  
  110. # Display the plot
  111. plt.show()
  112.  
  113. import numpy as np
  114. import matplotlib.pyplot as plt
  115.  
  116. m = 9.1E-31
  117. k = 1.38E-23
  118. h = 6.62607015E-34
  119. I = 12.13*1.6E-19
  120.  
  121.  
  122. pressures_Torr = [1E-3, 1E-1, 1E1]  # Torr
  123. pressures_Pa = [p * 133.322 for p in pressures_Torr]  # conversion from mTorr to Pa
  124.  
  125. def C(T,p):
  126.     return 2*(2*np.pi*m)**1.5 *(k*T)**2.5 /(p*h**3)
  127.  
  128. def func(T):
  129.     return (5.8e-17*T**4 - 3.71e-12*T**3 - 8e-8*T**2 + 6.37e-4*T + 6.97)/(-1.08e-21*T**5 +
  130.                                                                           1.86e-16*T**4 - 6.49e-12*T**3 + 8.97e-8*T**2 - 5.42e-4*T + 2.02)
  131.  
  132. def RHS(T,p):
  133.     return (C(T,p)*func(T)*np.exp(-I/(k*T))/(1+C(T,p)*func(T)*np.exp(-I/(k*T))))**0.5
  134.  
  135. def A(T,p):
  136.     return (-RHS(T, p) + (RHS(T, p)**2 + 4*RHS(T, p))**0.5)/2
  137.  
  138. T = np.linspace(0.1, 10000, 10000)
  139.  
  140. plt.figure(figsize=(8, 5))  # Optional: set figure size
  141.  
  142. for p, label in zip(pressures_Pa, ['1E-3 Torr', '1E-1 Torr', '10 Torr']):
  143.     y = A(T,p)
  144.     plt.plot(T, y, label=f'Pressure = {label}')
  145.  
  146. # Customize your plot
  147. plt.title(r'ionization fraction $\alpha$ as a function of temperature for different pressures')
  148. plt.xlabel(r'T,K')
  149. plt.ylabel(r'$\alpha$')
  150. plt.grid(True)
  151. plt.legend()
  152.  
  153. # Display the plot
  154. plt.show()
  155.  
  156.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement