Я наконец сделал это, и вот как я это сделал, я знаю, что случай t == 0 в функции points избыточен.
def trajectory(EMeV=7.7, z1=2, z2=79, m1=4.0, xf=5, yf=0.3):
"""
EMeV: energy in MeV
z1,z2: atomic number of projectile and target respectively
xf: the projectile starts at xf*d away, where d is distance of closest approach
yf: the projectile starts at yf*d from the X-axis
m1: mass of projectile in amu
"""
# setup initial values
q = 1.602e-19 # [C], electronic charge
q1 = z1*q # [C], charge on q1
q2 = z2*q # [C], charge on q1
EJ = EMeV*1e6*q # [J], kinetic energy
u = 1.66e-27 # [kg], amu
m = m1*u # [kg], mass of projectile
v = sqrt(2*EJ/m) # speed of projectile
k = 8.99e9 # [m/F], coulomb's constant
d = k*q1*q2/EJ # [m], minimum distance of closest approach
rmax = xf*d # [m], maximum of x-values
# dynamic values
x = rmax # [m]
y = yf*d # [m]
vx = -v # [m/s]
vy = 0 # [m/s]
t = 0 # [s]
h = x/v/100 # [s], estimate a small time step
points = [(x,y)]
while (x<=rmax) and (x>=-rmax) and (y<=rmax) and (y>=-rmax):
r2 = x*x+y*y
E = k*q2/r2
F = q1*E
theta = arctan2(y,x)
# first do x
ax = F*cos(theta)/m
x += h*vx
vx += h*ax
# then y
ay = F*sin(theta)/m
y += h*vy
vy += h*ay
points.append( (x,y))
t += h
return points
Еще один кусок кода
def point(t):
if (t==0):
a = circle((x[0],y[0]),1.3e-15,fill = true, rgbcolor='red')
if (t>0 and t<len(x)):
a = circle((x[3*t],y[3*t]),1.3e-15, fill = true, rgbcolor='red')
return a
a = animate([plot(point(t)) for t in sxrange(0,60,1)],xmin=-0.2e-13,ymin=-0.2e-
13,xmax=1.5e-13,ymax=8e-14)
b = animate([plot(circle((0,0),0.5e-14,fill=true)) for t in sxrange(0,60,1)],xmin=-0.2e-13,ymin=-0.2e-13,xmax=1.5e-13,ymax=8e-14)
c = a+b
c.show()
Это результирующий граф пути