Untitled

 avatar
unknown
plain_text
a year ago
745 B
9
Indexable
import numpy as np

#input
v0=float(input())
V=float(input())

# your code
N = 10**6
L = 5
m = 4*(10**-26)
dt = 10**-2
# Initial positions and velocities
x0 = np.random.uniform(0, L, N)
v = np.random.normal(0, v0, N)
# Positions after time dt
x = x0 + v * dt
# Determine balls that cross the board
crossed_left_to_right = (x0 < 0.5 * L) & (x > 0.5 * L)
crossed_right_to_left = (x0 > 0.5 * L) & (x < 0.5 * L)
# Calculate momentum change for crossed balls
p_change_left_to_right = m*V - m*v[crossed_left_to_right]
p_change_right_to_left = m*V - m*v[crossed_right_to_left]
# Total change in momentum
dp = np.sum(p_change_left_to_right) + np.sum(p_change_right_to_left)

F = dp / dt * 2

#output
print(np.round(F*1e17,1))
Editor is loading...
Leave a Comment