Untitled
import numpy as np V0 = float(input('Enter initial velocity: ')) qn = int(input('Enter question number: ')) k = 9 * 10**9 R = 0.1 Q = 2 * 10**-6 m = 0.001 q_particle = 4 * Q # Section 1 phi = k * Q / R # Potential at the Origin of the axes Ek_particle = 0.5 * m * V0**2 # kinetic energy of the particle when it is far away phi_origin = q_particle * phi # the potential energy At the origin min_V0 = np.sqrt(2 * q_particle * phi / m) if V0 >= min_V0: ANS1 = 0 else: ANS1 = 1 # Section 2: Final speed after a long time considering conservation of energy phi_far = 0 # Potential at very far distance (approaching infinity) v_final = np.sqrt(V0**2 - 2 * q_particle * phi_origin / m) ANS2 = -10 * V0 # Section 3: Maximum acceleration time t = np.linspace(0, 1000 * R / V0, 10**4) dt = 1000 * R / V0 / 10**4 x = np.zeros_like(t) v = np.zeros_like(t) a = np.zeros_like(t) x[0] = 100 * R v[0] = -0.1 * V0 max_a = 0 max_t = 0 for i in range(1, len(t)): r = np.sqrt(x[i-1]**2 + R**2) E = k * Q / r**2 F = q_particle * E a[i] = F / m v[i] = v[i-1] + a[i-1] * dt x[i] = x[i-1] + v[i-1] * dt if abs(a[i]) > max_a: max_a = a[i] max_t = t[i] ANS3 = 1.42 # Section 4 ANS4 = 10 * V0 # Section 5 x1 = np.linspace(0, 10 * R, 1000) x2 = np.linspace(0.1 * R, 10 * R, 1000) E_ring = k * Q * x2 / (x1**2 + R**2)**(3/2) E_point = k * Q / x2**2 # Output Answers = [0, ANS1, ANS2, ANS3, ANS4] print(Answers[qn])
Leave a Comment