class TeapotFoilNode(DriftTEAPOT):
	""" 
	The foil node class for TEAPOT lattice
	"""
	def __init__(self, xmin, xmax, ymin, ymax, thick, name = "foil no name"):
		"""
		Constructor. Creates the Foil TEAPOT element.
		"""
		DriftTEAPOT.__init__(self,name)
		self.foil = Foil(xmin, xmax, ymin, ymax, thick)
		self.setType("foil teapot")
		self.setLength(0.0)
		# The user choice of scattering routine. Defualt (0) is full scatter
		self.scatterChoice = 0

	def track(self, paramsDict):
		"""
		The foil-teapot class implementation of the AccNodeBunchTracker class track(probe) method.
		"""
		length = self.getLength(self.getActivePartIndex())
		bunch = paramsDict["bunch"]
		lostbunch = paramsDict["lostbunch"]
		if(self.scatterChoice == 0):
			self.foil.traverseFoilFullScatter(bunch, lostbunch)
		else:
			self.foil.traverseFoilSimpleScatter(bunch)
	
	
	def setScatterChoice(self, choice):
		self.scatterChoice = choice
Example #2
0
class TeapotFoilNode(DriftTEAPOT):
    """ 
	The foil node class for TEAPOT lattice
	"""
    def __init__(self, xmin, xmax, ymin, ymax, thick, name="foil no name"):
        """
		Constructor. Creates the Foil TEAPOT element.
		"""
        DriftTEAPOT.__init__(self, name)
        self.foil = Foil(xmin, xmax, ymin, ymax, thick)
        self.setType("foil teapot")
        self.setLength(0.0)
        # The user choice of scattering routine. Defualt (0) is full scatter
        self.scatterChoice = 0

    def track(self, paramsDict):
        """
		The foil-teapot class implementation of the AccNodeBunchTracker class track(probe) method.
		"""
        length = self.getLength(self.getActivePartIndex())
        bunch = paramsDict["bunch"]
        lostbunch = paramsDict["lostbunch"]
        if (self.scatterChoice == 0):
            self.foil.traverseFoilFullScatter(bunch, lostbunch)
        else:
            self.foil.traverseFoilSimpleScatter(bunch)

    def setScatterChoice(self, choice):
        self.scatterChoice = choice
Example #3
0
	def __init__(self, x, y, anchor_point, polarity, body_length, wing_chord, wing_span, stabilizer_chord, stabilizer_span, fluid, box2dWorld, density=10.0):
		self.polarity = polarity
		self.body_length = body_length
		self.anchor_point = anchor_point
		
		# Make a body to Box2D for this foil
		bodyDef = b2BodyDef()
		bodyDef.position.Set(x, y)
		#bodyDef.linearDamping = 10.0
		#bodyDef.angularDamping = 1.0
		body = box2dWorld.CreateBody(bodyDef)
		shapeDef = b2PolygonDef()
		body_center = b2Vec2(-0.5 * body_length, 0.0)
		shapeDef.SetAsBox(body_length * 0.5, 0.05, body_center, 0)
		shapeDef.density = 0.0 # kg/m^3, from wikipedia for styrofoam density
		shapeDef.friction = 0.0
		body.CreateShape(shapeDef)
		
		print "Made body"

		self.wing = Foil(wing_chord, wing_span, fluid, 
							  body, b2Vec2(0.0, 0.15 * polarity), angle=radians(5) * polarity, density=density)
		print "Made wing"
		self.stabilizer = Foil(stabilizer_chord, stabilizer_span, fluid, 
								    body, b2Vec2(-body_length + stabilizer_chord, 0.15 * polarity), angle=0.0, density=density)
		print "Made stabilizer"
		body.SetMassFromShapes()
		
		self.body = body
Example #4
0
    def __init__(self, xmin, xmax, ymin, ymax, thick, name="foil no name"):
        """
		Constructor. Creates the Foil TEAPOT element.
		"""
        DriftTEAPOT.__init__(self, name)
        self.foil = Foil(xmin, xmax, ymin, ymax, thick)
        self.setType("foil teapot")
        self.setLength(0.0)
        # The user choice of scattering routine. Defualt (0) is full scatter
        self.scatterChoice = 0
Example #5
0
 def __init__(self, chord, thickness):
     Foil.__init__(self,chord, thickness)
     self.linterp, self.uinterp, x0, x1 = ARADFoil.load_interpolator()
     self.xl = np.linspace(x0, x1, 60)
     self.xu = np.linspace(x0, x1, 60)
     t_pts = np.ones(60)*thickness
     #print t_pts
     self.yl = self.linterp(np.transpose([t_pts, self.xl]))
     self.yu = self.uinterp(np.transpose([t_pts, self.xu]))
     #print self.xl, self.yl
     #print self.xu, self.yu
     #print x0, x1
     self.init_te = (self.yu[-1] - self.yl[-1])
def initialize_dictionary():
    foils = {}
    # import list of foil keys and store in dictionary
    with open('foil_ids.txt', 'r') as F:
        foil_keys = F.read().splitlines()
    for key in foil_keys:
        foils[key] = Foil(key)
    return foils, foil_keys
	def __init__(self, xmin, xmax, ymin, ymax, thick, name = "foil no name"):
		"""
		Constructor. Creates the Foil TEAPOT element.
		"""
		DriftTEAPOT.__init__(self,name)
		self.foil = Foil(xmin, xmax, ymin, ymax, thick)
		self.setType("foil teapot")
		self.setLength(0.0)
		# The user choice of scattering routine. Defualt (0) is full scatter
		self.scatterChoice = 0
Example #8
0
 def __init__(self, chord, thickness):
     Foil.__init__(self,chord, thickness)
     if (self.thickness <= 0.06):
         self.xl, self.yl, self.xu, self.yu = self.load_selig('foils/ara_d_6.dat')
         self.yu *= self.thickness / 0.06
         self.yl *= self.thickness / 0.06
     elif (self.thickness <= 0.10):
         self.xl, self.yl, self.xu, self.yu = self.load_selig('foils/ara_d_10.dat')
         self.yu *= self.thickness / 0.1
         self.yl *= self.thickness / 0.1
     elif (self.thickness <= 0.13):
         self.xl, self.yl, self.xu, self.yu = self.load_selig('foils/ara_d_13.dat')
         self.yu *= self.thickness / 0.13
         self.yl *= self.thickness / 0.13
     else:
         self.xl, self.yl, self.xu, self.yu= self.load_selig('foils/ara_d_20.dat')
         self.yu *= self.thickness / 0.2
         self.yl *= self.thickness / 0.2
     self.init_te = (self.yu[-1] - self.yl[-1])
# storing the data from the wisconsin mpfd irradiation
from foil import Foil

data = {}
data['al1'] = Foil(60036, 317, 2.20E-02, 6.61E-03, -1)
data['al2'] = Foil(15467, 155, 3.47E-02, 5.48E-03, -1)
data['al3'] = Foil(17094, 171, 3.86E-02, 6.10E-03, -1)
data['al4'] = Foil(18031, 180, 3.08E-02, 4.87E-03, -1)
data['mo_cd1'] = Foil(15271, 150, 0.439, 4.58E-02, -1)
data['mo_cd2'] = Foil(28709, 213, 0.541, 9.57E-02, -1)
data['mo_cd3'] = Foil(14523, 148, 0.758, 7.90E-02, -1)
data['mo_cd4'] = Foil(32746, 230, 0.559, 9.88E-02, -1)

data['dum'] = Foil(0, 0, 0, 0, -1)

data['mo1'] = Foil(117208, 444, 0.365, 6.45E-02, -1)
data['mo2'] = Foil(15617, 156, 0.692, 7.21E-02, -1)
data['mo3'] = Foil(14896, 142, 0.805, 8.38E-02, -1)
data['mo4'] = Foil(30133, 224, 0.629, 0.111, -1)
Example #10
0
class Boat:
    sail_name = []

    def __init__(self, json_boat_file, **kwargs):
        # Choix des options
        self.current_location = np.zeros(2)  # 0 :Longitude, 1: Latitude
        self.destination_location = np.zeros(2)  # 0 :Longitude, 1: Latitude
        self.twa_array = []
        self.tws_array = []
        self.hull = 1
        self.boat_name = "none"
        self.Jib_option = True
        self.Spi_option = True
        self.sail_speed = []
        self.Staysail_option = False
        self.LightJib_option = False
        self.Code0_option = False
        self.HeavyGnk_option = False
        self.LightGnk_option = False
        self.Foil_option = False
        self.Polish_option = False
        self.WinchPro_option = False
        self.utc = get_utctime()
        print("heure actuelle UTC", self.utc)

        if kwargs.__len__() != 0:
            if 'LightSail' in kwargs:
                if kwargs['LightSail']:
                    self.LightJib_option = True
                    self.LightGnk_option = True

            if 'HeavySail' in kwargs:
                if kwargs['HeavySail']:
                    self.Staysail_option = True
                    self.HeavyGnk_option = True

            if 'Code0' in kwargs:
                if kwargs['Code0']:
                    self.Code0_option = True

            if 'Foil' in kwargs:
                if kwargs['Foil']:
                    self.Foil_option = True

            if 'Polish' in kwargs:
                if kwargs['Polish']:
                    self.Polish_option = True

            if 'WinchPro' in kwargs:
                if kwargs['WinchPro']:
                    self.WinchPro_option = True

            if 'FullPack' in kwargs:
                if kwargs['FullPack']:
                    self.Staysail_option = True
                    self.LightJib_option = True
                    self.Code0_option = True
                    self.HeavyGnk_option = True
                    self.LightGnk_option = True
                    self.Foil_option = True
                    self.Hull_option = True
                    self.WinchPro_option = True
        if self.Foil_option:
            self.foil = Foil()
        self.read(json_boat_file)

    def read(self, json_polar_file):
        file = open(json_polar_file, 'r')
        polar_data = json.load(file)
        self.twa_array = np.asarray(polar_data['twa'])
        self.tws_array = np.asarray(polar_data['tws'])
        self.boat_name = (polar_data['label'])
        nb_possible_sail = len(polar_data['sail'])
        nb_selected_sail = self.get_nb_selected_sail()
        # print('nb de voile sélectionné:', nb_selected_sail)
        self.sail_speed = np.zeros((len(self.twa_array), len(self.tws_array), nb_selected_sail))
        index = 0
        if self.Jib_option:
            self.sail_name.append(polar_data['sail'][0]['name'])
            self.sail_speed[:, :, index] = polar_data['sail'][0]['speed']
            index = index + 1
        if self.Spi_option:
            self.sail_name.append(polar_data['sail'][1]['name'])
            self.sail_speed[:, :, index] = polar_data['sail'][1]['speed']
            index = index + 1
        if self.Staysail_option:
            self.sail_name.append(polar_data['sail'][2]['name'])
            self.sail_speed[:, :, index] = polar_data['sail'][2]['speed']
            index = index + 1
        if self.LightJib_option:
            self.sail_name.append(polar_data['sail'][3]['name'])
            self.sail_speed[:, :, index] = polar_data['sail'][3]['speed']
            index = index + 1
        if self.Code0_option:
            self.sail_name.append(polar_data['sail'][4]['name'])
            self.sail_speed[:, :, index] = polar_data['sail'][4]['speed']
            index = index + 1
        if self.HeavyGnk_option:
            self.sail_name.append(polar_data['sail'][5]['name'])
            self.sail_speed[:, :, index] = polar_data['sail'][5]['speed']
            index = index + 1
        if self.LightGnk_option:
            self.sail_name.append(polar_data['sail'][6]['name'])
            self.sail_speed[:, :, index] = polar_data['sail'][6]['speed']
            index = index + 1
        self.get_best_polar_sail()
        # print(self.sail_name)
        # print(self.sail_speed)

        # caracteristiques des  foils
        if self.Foil_option:
            self.foil.speedRatio = polar_data['foil']['speedRatio']
            self.foil.twaMin = polar_data['foil']['twaMin']
            self.foil.twaMax = polar_data['foil']['twaMax']
            self.foil.twaMerge = polar_data['foil']['twaMerge']
            self.foil.twsMin = polar_data['foil']['twsMin']
            self.foil.twsMax = polar_data['foil']['twsMax']
            self.foil.twsMerge = polar_data['foil']['twsMerge']

        # polish
        self.hull = polar_data['hull']['speedRatio']

    def get_speed_sail(self, tws, twa, sail_polar):
        return interp2d_linear(twa, tws, self.twa_array, self.tws_array, sail_polar)

    def print_options(self):
        print("Jib:", self.Jib_option)
        print("Spi:", self.Spi_option)
        print("LightJib:", self.LightJib_option)
        print("LightGnk", self.LightGnk_option)
        print("Staysail:", self.Staysail_option)
        print("HeavyGnk:", self.HeavyGnk_option)
        print("Code0:", self.Code0_option)
        print("Foil:", self.Foil_option)
        print("Polish:", self.Polish_option)
        print("WinchPro:", self.WinchPro_option)

    def get_nb_selected_sail(self):
        nb = 0
        if self.Jib_option:
            nb = nb + 1
        if self.Spi_option:
            nb = nb + 1
        if self.Staysail_option:
            nb = nb + 1
        if self.LightJib_option:
            nb = nb + 1
        if self.Code0_option:
            nb = nb + 1
        if self.HeavyGnk_option:
            nb = nb + 1
        if self.LightGnk_option:
            nb = nb + 1
        return nb

    def plotpolar(self, sail_index):
        fig = plt.figure()
        ax = fig.add_subplot(111, projection='3d')
        ax.set_title(self.sail_name[sail_index])
        twa_plot = np.arange(0, 180, 1)
        tws_plot = np.arange(0, 40, 1)
        print("twaplot:", twa_plot)
        boatspeed = np.zeros((40, 180))
        print("toto1", boatspeed.shape)
        print("toto2", len(boatspeed[1][:]))
        print("toto3", len(boatspeed[:][0]))
        print("toto4", len(boatspeed[:][1]))
        # print("zero", boatspeed)

        for j in range(0, 40):
            for i in range(0, 180):
                boatspeed[j][i] = self.get_speed_sail(j, i, self.sail_speed[:, :, sail_index])

        # boatspeed[i] = self.get_speed_sail(10,i,self.sail_speed[:,:,0])
        twa_plot, tws_plot = np.meshgrid(twa_plot, tws_plot)
        ax.plot_surface(twa_plot, tws_plot, boatspeed, cmap=plt.cm.coolwarm)
        plt.show()

    def get_sail_interpolated(self, sail, speed):
        sail_speed_interpolated = np.zeros(181)
        #print('speed_interpol', speed)
        for i in range(0, 181):
            sail_speed_interpolated[i] = self.get_speed_sail(speed, i, sail)

        return sail_speed_interpolated

    def get_best_polar_sail(self):
        nb = np.shape(self.sail_speed)
        self.best_polar_sail = np.zeros((31, 18))
        self.best_polar_sail[:, :] = self.sail_speed[:, :, 0]
        self.best_polar_sail = np.maximum(self.best_polar_sail, self.sail_speed[:, :, 1])
        if nb[2] > 2:
            for i in range(2, nb[2]):
                self.best_polar_sail = np.maximum(self.best_polar_sail, self.sail_speed[:, :, i])
        return self.best_polar_sail

    def navigate(self, dswind):
        self.dswind = dswind
        utc = get_utctime()
        windspeed, windangle = get_wind_speed(self.current_location[1], self.current_location[0], utc, self.dswind)
        print('windspeed', utc, windspeed, windangle)

        self.get_best_polar_sail()
        speed = np.zeros(360)
        print('windspeed', windspeed)
        for i in range(0, 181):
            speed[i] = self.get_speed_sail(windspeed, i, self.best_polar_sail)*self.foil.foiling_factor(windspeed, i)*self.hull
            speed[(360-i) % 360] = speed[i]
Example #11
0
    def __init__(self, json_boat_file, **kwargs):
        # Choix des options
        self.current_location = np.zeros(2)  # 0 :Longitude, 1: Latitude
        self.destination_location = np.zeros(2)  # 0 :Longitude, 1: Latitude
        self.twa_array = []
        self.tws_array = []
        self.hull = 1
        self.boat_name = "none"
        self.Jib_option = True
        self.Spi_option = True
        self.sail_speed = []
        self.Staysail_option = False
        self.LightJib_option = False
        self.Code0_option = False
        self.HeavyGnk_option = False
        self.LightGnk_option = False
        self.Foil_option = False
        self.Polish_option = False
        self.WinchPro_option = False
        self.utc = get_utctime()
        print("heure actuelle UTC", self.utc)

        if kwargs.__len__() != 0:
            if 'LightSail' in kwargs:
                if kwargs['LightSail']:
                    self.LightJib_option = True
                    self.LightGnk_option = True

            if 'HeavySail' in kwargs:
                if kwargs['HeavySail']:
                    self.Staysail_option = True
                    self.HeavyGnk_option = True

            if 'Code0' in kwargs:
                if kwargs['Code0']:
                    self.Code0_option = True

            if 'Foil' in kwargs:
                if kwargs['Foil']:
                    self.Foil_option = True

            if 'Polish' in kwargs:
                if kwargs['Polish']:
                    self.Polish_option = True

            if 'WinchPro' in kwargs:
                if kwargs['WinchPro']:
                    self.WinchPro_option = True

            if 'FullPack' in kwargs:
                if kwargs['FullPack']:
                    self.Staysail_option = True
                    self.LightJib_option = True
                    self.Code0_option = True
                    self.HeavyGnk_option = True
                    self.LightGnk_option = True
                    self.Foil_option = True
                    self.Hull_option = True
                    self.WinchPro_option = True
        if self.Foil_option:
            self.foil = Foil()
        self.read(json_boat_file)
Example #12
0
# storing the data from the 6_25_18 mpfd irradiation
from foil import Foil

data = {}
data['al1'] = Foil(115.3, 14.62, 3.2033E-002, 12.68, 3600)
data['al2'] = Foil(150.9, 16.86, 4.1906E-002, 11.17, 3600)
data['al3'] = Foil(-1, -1, -1, -1, -1)
data['al4'] = Foil(-1, -1, -1, -1, -1)
data['au1'] = Foil(137326.1, 382.43, 1.318e+000, 7.382e-003, 60)
data['au2'] = Foil(175561.4, 433.84, 1.685E+000, 9.186E-003, 60)
data['au3'] = Foil(185317.2, 447.60, 1.518E+001, 5.480E-001, 60)
data['au4'] = Foil(113048.9, 505.68, 2.938E-001, 3.235E-002, 60)
data['au_cd1'] = Foil(847634.3, 955.40, 1.388E+001, 5.004E-001, 300)
data['au_cd2'] = Foil(1202112.1, 1101.06, 2.308E+000, 1.142E-002, 300)
data['au_cd3'] = Foil(905406.3, 952.34, 1.739E+000, 8.645E-003, 300)
data['au_cd4'] = Foil(836461.0, 4653.72, 2.1532E+002, 6.48, 300)
data['in1'] = Foil(16385.8, 137.96, 9.897E-001, 2.669e-002, 60)
data['in2'] = Foil(18046.7, 144.63, 1.090E+000, 2.926E-002, 60)
data['in3'] = Foil(14003.7, 126.65, 8.458E-001, 2.298E-002, 60)
data['in4'] = Foil(13549.7, 125.62, 8.184E-001, 2.230E-002, 60)
data['in_cd1'] = Foil(40613.9, 219.35, -1, -1, 300)
data['in_cd2'] = Foil(-1, -1, -1, -1, -1)
data['in_cd3'] = Foil(3993.0, 67.70, 4.823E-002, 1.482E-003, 300)
data['in_cd4'] = Foil(-1, -1, -1, -1, -1)
Example #13
0
class Glider(object):
	
	def __init__(self, x, y, anchor_point, polarity, body_length, wing_chord, wing_span, stabilizer_chord, stabilizer_span, fluid, box2dWorld, density=10.0):
		self.polarity = polarity
		self.body_length = body_length
		self.anchor_point = anchor_point
		
		# Make a body to Box2D for this foil
		bodyDef = b2BodyDef()
		bodyDef.position.Set(x, y)
		#bodyDef.linearDamping = 10.0
		#bodyDef.angularDamping = 1.0
		body = box2dWorld.CreateBody(bodyDef)
		shapeDef = b2PolygonDef()
		body_center = b2Vec2(-0.5 * body_length, 0.0)
		shapeDef.SetAsBox(body_length * 0.5, 0.05, body_center, 0)
		shapeDef.density = 0.0 # kg/m^3, from wikipedia for styrofoam density
		shapeDef.friction = 0.0
		body.CreateShape(shapeDef)
		
		print "Made body"

		self.wing = Foil(wing_chord, wing_span, fluid, 
							  body, b2Vec2(0.0, 0.15 * polarity), angle=radians(5) * polarity, density=density)
		print "Made wing"
		self.stabilizer = Foil(stabilizer_chord, stabilizer_span, fluid, 
								    body, b2Vec2(-body_length + stabilizer_chord, 0.15 * polarity), angle=0.0, density=density)
		print "Made stabilizer"
		body.SetMassFromShapes()
		
		self.body = body

	def get_force_vectors(self):
		forces = []
		forces += self.wing.appliedForces
		forces += self.stabilizer.appliedForces
		return forces
		
	def clear_force_vectors(self):
		self.wing.appliedForces = []
		self.stabilizer.appliedForces = []

	def rotate_wing(self, delta_angle):
		self.wing.set_angle(self.wing.get_angle() + (delta_angle * self.polarity))

	def set_wing_angle(self, new_angle):
		self.wing.set_angle(new_angle * self.polarity)
	
	def move_anchor(self, amount):
		self.anchor_point += amount
		return self.get_anchor_point()
		
	def get_anchor_point(self):
		return self.body.GetWorldPoint(b2Vec2(-self.body_length * self.anchor_point, 0.0))#-0.02 * self.body_length * self.polarity))
	
	def step(self, damper=0.0):
		if debug: print "Wing:"
		self.wing.step(damper)
		if debug: print "Stabilizer:"
		self.stabilizer.step(damper)
		pos = self.body.GetPosition()
		angle = self.body.GetAngle()
		if debug: print "X: %3.2f\tY: %3.2f\tA: %3.2f\tV(W): %4.2f\tL(W): %4.2f\tD(W): %4.2f\tV(S): %4.2f\tL(S): %4.2f\tD(S): %4.2f" % (pos.x, pos.y, degrees(angle), self.wing.velocity().Length(), self.wing.lift.Length(), self.wing.drag.Length(), self.stabilizer.velocity().Length(), self.stabilizer.lift.Length(), self.stabilizer.drag.Length())
		
	def draw(self, ctx):
		self.wing.draw(ctx)
		self.stabilizer.draw(ctx)
		
	def rotate(self, angle):
		rotation = self.body.GetAngle()
		position = self.body.GetPosition()
		self.body.SetXForm(position, rotation + angle)
		
	def velocity(self):
		return (self.wing.body.GetLinearVelocity() + self.stabilizer.body.GetLinearVelocity()) / 2.0
Example #14
0
 def __init__(self, chord):
     Foil.__init__(self,chord, chord*0.06)
Example #15
0
    def load_interpolator():
        global g_linterp, g_uinterp, g_x0, g_x1
        if g_linterp is not None:
            return g_linterp, g_uinterp, g_x0, g_x1
        
        files = ['foils/ara_d_6.dat', 'foils/ara_d_10.dat', 'foils/ara_d_13.dat', 'foils/ara_d_20.dat']
        thickness = np.array([0.06, 0.10, 0.13, 0.2])
        lpts = []
        lval = []
        upts = []
        uval = []
        # Lower Bound, linear interpolate here from the 6% foil
        xl, yl, xu, yu = Foil.load_selig('foils/ara_d_6.dat')
        l_interp = ARADFoil.polyfit(xl, yl)
        u_interp = ARADFoil.polyfit(xu, yu)
        
        beta = np.linspace(0, np.pi, 90)    # Use cosine spacing of points.
        x = (1.0 - np.cos(beta))/2


        for t in np.linspace(0.0, 0.04, 7):
            l = l_interp(x)
            u = u_interp(x)
            for xx, ll, uu in zip(x, l, u):
                lpts.append([t, xx])
                upts.append([t, xx])
                lval.append(ll*t/0.06)
                uval.append(uu*t/0.06)

        for t, fname in zip(thickness, files):
            xl, yl, xu, yu = Foil.load_selig(fname)
            l_interp = ARADFoil.polyfit(xl, yl)
            u_interp = ARADFoil.polyfit(xu, yu)
            l = l_interp(x)
            u = u_interp(x)
            for xx, ll, uu in zip(x, l, u):
                lpts.append([t, xx])
                upts.append([t, xx])
                lval.append(ll)
                uval.append(uu)
        
        # Upper Bound is a circle
        xl, yl, xu, yu = Foil.load_selig('foils/ara_d_20.dat')
        l_interp = ARADFoil.polyfit(xl, yl)
        u_interp = ARADFoil.polyfit(xu, yu)
        for t in np.linspace(0.25, 1.0, 9):
            l = l_interp(x)
            u = u_interp(x)
            for xx, ll, uu in zip(x, l, u):
                lpts.append([t, xx])
                upts.append([t, xx])
                lval.append(ll*t/0.2)
                uval.append(uu*t/0.2)

        lpts = np.array(lpts)
        upts = np.array(upts)
        lval = np.array(lval)
        uval = np.array(uval)
        g_linterp = CloughTocher2DInterpolator(lpts, lval)
        g_uinterp = CloughTocher2DInterpolator(upts, uval)
        g_x0 = xl[0]
        g_x1 = xl[-1]
        
        return g_linterp, g_uinterp, g_x0, g_x1
Example #16
0
import math
import sys
from bunch import Bunch
from foil import Foil
from injection import InjectParts

print "Start."

xmin = -0.050
xmax = 0.050
ymin = -0.050
ymax = 0.050
# Below is 1000 times the width of normal foil but will do only one turn.
thick = 400

foil = Foil(xmin, xmax, ymin, ymax, thick)

#------------------------------
#Main Bunch init
#------------------------------
b = Bunch()
print "Read Bunch."
runName = "Benchmark_Collimator"

b.mass(0.93827231)
b.macroSize(1.0e+1)
energy = 1.0 #Gev
b.readBunch("parts.dat")
b.getSyncParticle().kinEnergy(energy)

#=====track bunch through Foil============