print(len(Energy) * len(Bn) * 10.0 / 60.0)
for j in range(len(Energy)):
    for i in range(len(Bn)):
        B = BfieldTF(B0=Bn[i])
        Bv = BfieldVF(B0=0.00000)
        T = Trajectory(Vessel, B, Bv, v0=Vinjection, T0=Energy[j])
        T.LineColor = Color[i]
        T.LineWidth = 1.0
        if j == 0:
            T.LineWidth = 2
        if j == 9:
            T.LineWidth = 4
        if j == 4:
            T.LineWidth = 2
            T.LineColor = 'k'
            T.LineStyle = '--'
        TrajectoryList.append(T)

    # Save Target parameters
#	T.Target.SaveTargetParameters(TFCurrent=In[i],Path=OutputPath+'geometry/')

    # append lists of Target Quantities
#	AngleComponents.append([T.Target.VAngle,T.Target.HAngle])
#	Coordinates.append([T.Target.R,T.Target.Z,T.Target.Phi])
#	Parameters.append(T.Target.GetDetectionParameters())

# ------------------------------------------------------------------------------
# Plot 3D results

for i in range(len(TrajectoryList)):
    TrajectoryList[i].Plot3D(ax)
        dRdB.append(T1.Target.Distance(T) / (fB * 100.0))
    print(dRdB)

# ------------------------------------------------------------------------------
# Calculate Target Error trajectories given % Magnet Ripple
if True:
    #	fB = 0.02
    # Centroid Trajectory
    I0 = []
    for i in range(len(Bn)):
        B = BfieldTF(B0=Bn[i])
        Bv = BfieldVF(B0=0.00000)
        T = Trajectory(Vessel, B, Bv, v0=Vinjection, T0=Energy)
        T.LineColor = CMAP(1.0 * i / len(Bn))
        T.LineWidth = 1.0
        T.LineStyle = ':'
        I0.append(CalculateI0(Bn[i]))
        TrajectoryList.append(T)

# Error Trajectories
    RError = [np.zeros(3), np.zeros(3)]
    DeltaR = []
    for i in range(len(Bn)):
        I1 = CalculateI0(Bn[i])
        dI = RippleFunction(I1) / 2.0
        #		fB = CalculateB0(dI)
        fB = CalculateB0(dI + 0.0005 * 12.5e3)
        fB1 = [-fB, fB]
        print(dI, fB)
        for j in range(len(fB1)):
            fB1 = [-fB, fB]