
import os
os.sys.path.append("../pyspire")
from SpiresCoaxiales import *
import numpy
from matplotlib.pyplot import *
            

max=5.0
bobines = SystemeSpires(-max,max,-max,max)
bobines.ajouter(Spire(1.0,0.5,1.0))
bobines.ajouter(Spire(1.0,-0.5,1.0))
            

figure(figsize=(7,7))
bobines.plot_lignes([[0.0,0.0],[0.15,0.0],[0.3,0.0],[0.45,0.0],[0.6,0.0],[0.75,0.0],[0.9,0.0]],'b')
axis([-max,max,-max,max])
xlabel('z')
ylabel('r')
grid()
            

z = numpy.arange(-5.0,5.0,0.01)
bz = bobines.Bz_z(0.0,z)
figure()
plot(z,bz)
xlabel("z")
ylabel("Bz")
title("r=0")
grid()
            

x = numpy.arange(-3.0,3.0,0.01)
bz = bobines.Bz_x(x,0.0)
figure()
plot(x,bz)
xlabel("r")
ylabel("Bz")
title("z=0")
axis([-3,3,-5,5])
grid()
            

figure()
r0 = 0.001
z0=-4.0
tmax=100.0
te=0.01
[r1,theta1,z1] = bobines.trajectoire(1.0,r0,z0,0.05,1.0,tmax,te)
plot(z1,r1,'r')
[r2,theta2,z2] = bobines.trajectoire(1.0,r0,z0,0.02,1.0,tmax,te)
plot(z2,r2,'g')
[r3,theta3,z3] = bobines.trajectoire(1.0,r0,z0,0.1,1.0,tmax,te)
plot(z3,r3,'b')
axis([-5.0,5.0,-1.0,1.0])
xlabel('z')
ylabel('r')
grid()
            

figure()
plot(z1,theta1,'r')
plot(z2,theta2,'g')
plot(z3,theta3,'b')
xlabel('z')
ylabel('theta')
grid()
            
