У меня есть координаты x и y, которые показывают путь частицы. Как мне оживить этот путь? - PullRequest
0 голосов
/ 22 мая 2019

У меня есть координаты x и y, пример:

a = [(2.9552e-13, 5.00000000000000e-15),(2.8592e-13, 5.0003e-15),(2.7634e-13, 5.0008e-15),(2.6677e-13, 5.0017e-15),(2.5722e-13, 5.0030e-15),(2.4770e-13, 5.0046e-15),(2.3819e-13, 5.0067e-15),(2.2871e-13, 5.0093e-15),(2.1926e-13, 5.0125e-15)]

Как показать анимацию в 2-й плоскости точки, когда она изменяется через эти точки?

1 Ответ

0 голосов
/ 23 мая 2019

Я наконец сделал это, и вот как я это сделал, я знаю, что случай 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()

Это результирующий граф пути

...