1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| # -*- coding: utf-8 -*-
import scipy.integrate
import matplotlib.pyplot as plt
import numpy as np
global prefacteur
e = 1.6*10**(-19)
m = 1.66*10**(-27)
k = 9*10**9 #k=1/(4*pi*eO)
#Commenter la 1ere (resp 2eme) ligne pour le cas repulsif (resp attractif)
#prefacteur = -e*e*k/m
prefacteur = e*e*k/m
Zmax = 10
def deriveeSysteme(coords,t):
global prefacteur
x=coords[0]
y=coords[1]
vx=coords[2]
vy=coords[3]
ax=prefacteur*x*(x**2+y**2)**(-3/2)
ay=prefacteur*y*(x**2+y**2)**(-3/2)
return([vx,vy,ax,ay])
i=1
while i <= Zmax :
b=-0.08*10**(-10)+0.28*10**(-10)*i
tmax = 8*10**(-14)
coords0=[-10**(-9),b,37313.,0.]
t=np.linspace(0,tmax,10000)
res=scipy.integrate.odeint(deriveeSysteme,coords0,t)
x=res[:,0]
y=res[:,1]
vx=res[:,2]
vy=res[:,3]
print(x)
print(y)
plt.plot(x,y)
i+=1
plt.axis("tight")
plt.show() |
Partager