Ejemplo n.º 1
0
    Bn = np.array([0.0, 0.05818182, 0.11345455, 0.16181818])

    # ===============================================================================
    # Perform Trajectory calculation for Trajectory Sweep
    # ===============================================================================

    AngleComponents = []
    Coordinates = []
    Parameters = []
    TrajectoryList = []
    OutputPath = './tmp/'
    Color = ['b', 'g', 'r', 'c']

    B = BfieldTF(B0=0.0)
    Bv = BfieldVF(B0=0.0)
    T = Trajectory(Vessel, B, Bv, v0=Vinjection[0], Method=None)
    for i, B0 in enumerate(Bn):
        for j, alph in enumerate(alpha):
            B = BfieldTF(B0=B0)
            Bv = BfieldVF(B0=0.00000)
            V0 = Vinjection[j]
            T.init_condition(Vessel, B, Bv, v0=V0, Method='LeapFrog')
            T.LineColor = Color[j]
            T.PlotParticle()
            T.PlotBV()
            TrajectoryList.append(T)

            np.savetxt("./tmp/Traject_{:d}_{:d}.dat".format(j, i),
                       np.array(T.r))
            AngleComponents.append([T.target.VAngle, T.target.HAngle])
            Coordinates.append([T.target.R, T.target.Z, T.target.Phi])
Ejemplo n.º 2
0
# Vessel.Plot2D(0)

if False:
    B = Bfieldc(B0=0.1)
    Bv = Bfieldc(B0=0.0001)
    d0 = 10.0
    dS = np.logspace(-5, -2, 15)
    dr = []
    T = []
    for i in range(len(dS)):
        #		T.append(Trajectory(Vessel,B,r0=[20.0,0.0,0.0],v0=[0.0,0.0,1.0],dS=dS[i],Nmax=round(d0/dS[i])) )
        T.append(
            Trajectory(Vessel,
                       B,
                       Bv,
                       r0=[20.0, 0.0, 0.0],
                       v0=[0.0, 0.0, 1.0],
                       dS=dS[i],
                       Nmax=round(d0 / dS[i])))
        RL = (T[-1].m0 * T[-1].v0) / (T[-1].q0 * B.B0)
        R = T[-1].r[-1] - np.array([20.0 - RL, 0, 0.0])
        # -RL)/d0 ) #/T.s[-1]*d0 - RL)
        dr.append(
            np.sqrt(R[0]**2 + R[1]**2 + R[2]**2) * (d0 / T[-1].s[-1]) - RL)
        # T.Plot2D()
    plt.figure(1)
    plt.loglog(dS, dr, '.')
    plt.xlabel(r'Step Size $\Delta$S [m]')
    plt.ylabel(r'$\Delta R/S$')
    plt.title(r'Error / Arc length')
Ejemplo n.º 3
0
In = np.array([0.0, 1600.0, 3120, 4450.0])
Bn = np.array([0.0, 0.05818182, 0.11345455, 0.16181818])

# ===============================================================================
# Perform Trajectory and sigma dynamics calculation for B-Field Sweep
# ===============================================================================

AngleComponents = []
Coordinates = []
Parameters = []
TrajectoryList = []
OutputPath = './output/'
for i in [0, 1, 2, 3]:  # range(len(Bn)):
    B = BfieldTF(B0=Bn[i])
    Bv = BfieldVF(B0=0.00000)
    T = Trajectory(Vessel, B, Bv)
    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 trajectory results
Color = ['b', 'g', 'r', 'c']
Ejemplo n.º 4
0
Bn = np.array([0.0, 0.05818182, 0.11345455, 0.16181818])

# ===============================================================================
# Perform Trajectory and sigma dynamics calculation for B-Field Sweep
# ===============================================================================

AngleComponents = []
Coordinates = []
Parameters = []
AIMSBeam = []
OutputPath = '../output/'
for i in [0, 1, 2, 3]:  # range(len(Bn)):
    B = BfieldTF(B0=Bn[i])
    Bv = BfieldVF(B0=0.00000)
    # ---------------------------- Calculate Trajectory (initialize Trajectory Class)
    T = Trajectory(Vessel, B, Bv)
    # --------------------- Initialize Beam Class from trajectory and sigma matrix S1
    beam = Beam(T, S1)
    # ----------------------------------- Calculate (Trace) evolution of sigma matrix
    beam.Trace()  # Trace
    AIMSBeam.append(beam)

    # ------------------------------------------------------------------------------
    # Save Sigma Matrix
    np.savetxt(
        OutputPath + 'sigma/' + 'SigmaFinal_I_' + str(int(In[i])) + '.dat',
        AIMSBeam[-1].target.Sigma)

    # ------------------------------------------------------------------------------
    # Save field and geometric parameters along trajectory
    #	T.SaveFieldParameters(TFCurrent=In[i],Path=OutputPath+'geometry/')
Ejemplo n.º 5
0
        0.0872727273, 0.1090909091, 0.1134545455, 0.1261818182, 0.1454545455,
        0.1618181818, 0.1745454545
    ])

# ===============================================================================
# Calculate Trajectories in vessel and final sigma matrix
# ===============================================================================

if True:
    Angle = []
    Coordinates = []
    Path = '../output/'
    for i in range(len(Bn)):
        B = BfieldTF(B0=Bn[i])
        Bv = BfieldVF(B0=0.00000)
        T = Trajectory(Vessel, B, Bv)
        # ------------------------------------------------------------------------------
        # Plot B-field and Velocity Components
        T.PlotB(2)
        T.PlotV(3)

        # ------------------------------------------------------------------------------
        # Trace beam (Calculate sigma evolution)
        AIMSBeam = Beam(T, S1)
        AIMSBeam.Trace()

        # ------------------------------------------------------------------------------
        # Save Geometric Paremters
        if True:
            np.savetxt(Path + 'Curvature_I_' + str(int(In[i])) + '.txt', T.k)
            np.savetxt(Path + 'SCoord_I_' + str(int(In[i])) + '.txt', T.s)
# Perform Trajectory calculation for B-Field Sweep
# ===============================================================================
AngleComponents = []
Coordinates = []
Parameters = []
trajectory = []
beam = []
targetellipse = []
OutputPath = '../output/'
# Color=['k','g','r','c','b','m','g','r','c','b','m','g']

for i in range(len(Bn)):
    B = BfieldTF(B0=Bn[i])
    Bv = BfieldVF(B0=0.00000)
    # Calcuate Trajectory
    T = Trajectory(Vessel, B, Bv, v0=Vinjection, T0=Energy)
    T.LineColor = CMAP(1.0 * i / len(Bn))
    T.target.LineColor = CMAP(1.0 * i / len(Bn))
    T.LineWidth = 2.0
    T.target.LineWidth = 2.0
    trajectory.append(T)
    # Calcuate Sigma and Beamspot
    IonBeam = Beam(T, SInput)
    IonBeam.Trace()
    beam.append(IonBeam)
    targetellipse.append(Ellipse(IonBeam.sigma[-1]))
    plt.figure(10)
    IonBeam.target.PlotProjection()
    plt.figure(11)
    #	IonBeam.target.PlotProjection(Type='ThetaPhi')
    Vessel.PlotCorners2D(Xlim=[-2.0, 2.0], scale=100.0)
#Bn = np.array([ 0.0, 0.05818182, 0.11345455, 0.16181818 ])
#Bn = np.array([0.10,0.20, 0.30, 0.40])
Bn = np.array([0.0, 0.05, 0.10, 0.15, 0.20, 0.25, 0.30, 0.35, 0.40, 0.45])

AngleComponents = []
Coordinates = []
Parameters = []
TrajectoryList = []
OutputPath = '../output/'
Color = ['k', 'g', 'r', 'c', 'b', 'm', 'g', 'r', 'c', 'b', 'm', 'g']
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/')
Ejemplo n.º 8
0
Vessel.Plot2D(0)

# R = np.sqrt(2 M E)*(c/B)
R0 = 1.0
Angle = np.pi / 2.0
BR = np.sqrt(2.0 * (2.0 * 1.67262158e-27) *
             (0.9e6 * 1.602e-19)) / (1.60217646e-19 * R0)
Bv = BfieldVF(B0=0.00000)

#DeltaS = R0*Angle
if True:
    #	B = BfieldTF(B0=0.2)
    B = Bfieldc(B0=BR)
    T = Trajectory(Vessel,
                   B,
                   Bv,
                   r0=[10.0, 0.0, 1.0],
                   v0=[-1.0, 0.0, 0.0],
                   Nmax=100)
    plt.plot(Rb, Zb)
    T.Plot2D()
    #	T.PlotB()
    plt.xlabel(r'X')
    plt.ylabel(r'Y')
    plt.title(r'?')
    plt.xlim(-L0, L1 * 1.1)
    plt.ylim(-L1 * 1.1, L1 * 1.1)
    Y = []
    for i in range(len(T.B)):
        #		Y.append(norm( cross(T.v[i],T.B[i]) ) )
        Yi = np.cross(T.v[i], T.B[i])
        Y.append(Yi[2])
def RippleFunction(I0):
    RipMax = 3.0
    RipFS = 1.0
    FS = 12.5e3
    dI = (RipMax - RipFS) / FS**2 * (-(I0 - FS) * (I0 + FS)) + RipFS
    return dI


if False:
    dRdB = []  # change in Target position with respect to B
    fB = 0.01
    for i in range(len(Bn)):
        B = BfieldTF(B0=Bn[i])
        Bv = BfieldVF(B0=0.00000)
        T = Trajectory(Vessel, B, Bv, v0=Vinjection, E0=Energy)
        T.LineColor = CMAP(1.0 * i / len(Bn))
        T.LineWidth = 2.0
        TrajectoryList.append(T)

        B1 = BfieldTF(B0=Bn[i] * (1 + fB))  # Bfield + fractional change
        T1 = Trajectory(Vessel, B1, Bv, v0=Vinjection, T0=Energy)
        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 = []
    Bn = np.array([
        0.0000000000, 0.0225454545, 0.0403636364, 0.0581818182, 0.0647272727,
        0.0872727273, 0.1090909091, 0.1134545455, 0.1261818182, 0.1454545455,
        0.1618181818, 0.1745454545
    ])

if True:
    Angle = []
    Coordinates = []
    Path = '../output/'
    # ------------------------------------------------------------------------------
    # Calculate Trajectories
    for i in range(len(Bn)):
        B = BfieldTF(B0=Bn[i])
        Bv = BfieldVF(B0=0.00000)
        T = Trajectory(Vessel, B, Bv, M0=0.511e6, Method='LeapFrog')
        AIMSBeam = Beam(T, S1)
        AIMSBeam.Trace()
        # ------------------------------------------------------------------------------
        # Save beam and target parameters
        if False:
            np.savetxt(Path + 'Curvature_I_' + str(int(In[i])) + '.txt', T.k)
            np.savetxt(Path + 'SCoord_I_' + str(int(In[i])) + '.txt', T.s)
            np.savetxt(Path + 'GradB_I_' + str(int(In[i])) + '.txt', T.gradB)
            np.savetxt(Path + 'GradBk_I_' + str(int(In[i])) + '.txt', T.gradBn)
            np.savetxt(Path + 'GradBn_I_' + str(int(In[i])) + '.txt', T.gradBk)
            np.savetxt(Path + 'TargetBasis_I_' + str(int(In[i])) + '.txt',
                       T.target.TargetBasis)
            np.savetxt(Path + 'SigmaBasis_I_' + str(int(In[i])) + '.txt',
                       T.target.SigmaBasis)
            np.savetxt(Path + 'SigmaFinal_I_' + str(int(In[i])) + '.txt',
# ===============================================================================
# Perform Trajectory calculation for Trajectory Sweep
# ===============================================================================

AngleComponents = []
Coordinates = []
Parameters = []
TrajectoryList = []
OutputPath = '../output/'
Color = ['b', 'g', 'r', 'c']
for j in range(len(alpha)):
    for i in [0, 3]:  # range(len(Bn)):
        B = BfieldTF(B0=Bn[i])
        Bv = BfieldVF(B0=0.00000)
        T = Trajectory(Vessel, B, Bv, v0=Vinjection[j])
        T.LineColor = Color[j]
        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