예제 #1
0
    # Inputs for B-field settings
    In = np.array([0.0, 1600.0, 3120, 4450.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))
예제 #2
0
# Inputs for four B-field settings
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 = []
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)
# Define current ripple as a function of current


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
예제 #4
0
from lib.BeamDynamicsTools.Bfield import Bfield, BfieldTF, BfieldVF
from lib.BeamDynamicsTools.Trajectory import Trajectory
from lib.BeamDynamicsTools.Beam import Beam
from lib.BeamDynamicsTools.Ellipse import Ellipse
import numpy as np
import pylab as pl
import scipy.special as sp
from numpy.linalg import norm
import matplotlib as mpl

R = np.array([1, 0, 0])
RInj = [1.798, -0.052, 0.243]

# ------------------------------------------------------------------------------
# Define Toroidal Field
TF = BfieldTF()

# ------------------------------------------------------------------------------
# Define Vertical Field
VF = BfieldVF(B0=1.0)

# ===============================================================================
# B Field Plotting Functions
# ===============================================================================

# ------------------------------------------------------------------------------
# Plot Elliptic Integrals of the 1st and 2nd kind, used for vertical field


def PlotEllipticInt():
    Ni = 1000
CMAP = mpl.colors.LinearSegmentedColormap.from_list(
    'mycolors', ['green', 'blue', 'black', 'red', 'orange'])

# ===============================================================================
# Perform Trajectory calculation for B-Field Sweep
# ===============================================================================

AngleComponents = []
Coordinates = []
Parameters = []
TrajectoryList = []
OutputPath = '../output/'
# Color=['k','g','r','c','b','m','g','r','c','b','m','g']

for i in range(len(Bn)):
    B = BfieldTF(B0=0.0)
    Bv = BfieldVF(B0=Bn[i])
    T = Trajectory(Vessel, B, Bv, v0=Vinjection, T0=Energy)
    T.LineColor = CMAP(1.0 * i / len(Bn))
    T.LineWidth = 2.0
    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())