Esempio n. 1
0
if mode == "VIS" or visWithStats:
    plt.figure(num=1, figsize=(15, 7))

    Drawing.Draw3Dtrajs(trajs, subplot=121)

    Drawing.DrawLine(c1, c2, is3d=True)
    Drawing.DrawLine(c2, c3, is3d=True)
    Drawing.DrawLine(c3, c4, is3d=True)
    Drawing.DrawLine(c4, c1, is3d=True)

    for i in range(len(intersects)):
        Drawing.DrawLine(intersects[i],
                         intersects[i],
                         is3d=True,
                         linestyle='None',
                         marker='o',
                         color='r')

    Drawing.DrawXYslice(trajs, subplot=122)

    plt.figure(num=2)
    Drawing.DrawXZslice(trajs)

    plt.figure(3)
    rvals = np.linalg.norm(trajs[0][:3, :], axis=0)
    pvals = np.linalg.norm(trajs[0][3:, :], axis=0)
    plt.plot(rvals, pvals)

    plt.show()
Esempio n. 2
0
# compute trajectories. Each trajectory is a 2D numpy array,
# where the first dimension contains (x,y,z,px,py,pz),
# and the second dimension is the "timestep"
# e.g. trajs[0][2,5] is the z coordinate at the 6th step of the 1st trajectory
trajs = [None for i in init_p]
for i in range(len(init_p)):
    x0 = np.array([0, 0, 0] + init_p[i])
    trajs[i] = Integrator.rk4(x0, dt, nsteps)

fig = plt.figure(1, figsize=(14.5, 5.5))

## Do the drawing. the Drawing module contains methods to do this automatically

## XZ slice
plt.subplot2grid((1, 5), (0, 0), colspan=3)
Drawing.DrawXZslice(trajs, colors=colors, ax=plt.gca(), drawBField=True)

plt.axis([-15, 15, -9, 9])
plt.xlabel("z (m)")
plt.ylabel("x (m)")

## xy slice
plt.subplot2grid((1, 5), (0, 3), colspan=2)
Drawing.DrawXYslice(trajs, ax=plt.gca())

plt.axis([-9, 9, -9, 9])
plt.xlabel("x (m)")
plt.ylabel("y (m)")

## 3d view
fig = plt.figure(num=2, figsize=(8, 8))