layers.append(layer0) boundary = pytlwall.Layer(layer_type='V', boundary=True) layers.append(boundary) # Define Chamber characteristics pipe_len_m = 1. pipe_rad_m = 0.0184 chamber_shape = 'CIRCULAR' betax = 1. betay = 1. component_name = 'newCW' chamber = pytlwall.Chamber(pipe_len_m=pipe_len_m, pipe_rad_m=pipe_rad_m, chamber_shape=chamber_shape, betax=betax, betay=betay, layers=layers, component_name=component_name) # Run TlWall mywall = pytlwall.TlWall(chamber, beam, freq) ZLong = mywall.ZLong ZTrans = mywall.ZTrans ZLongSurf = mywall.ZLongSurf ZTransSurf = mywall.ZTransSurf # save the data in a dataframe savedir = 'ex_CW/output/' data = { 'f': mywall.f,
def test_default(self): print('\nTesting default values') chamber = pytlwall.Chamber() self.assertEqual(1, chamber.pipe_len_m) self.assertEqual('CIRCULAR', chamber.chamber_shape)
def test_horizontal_vertical(self): print('\nTesting pipe horizontal and vertical dimension') chamber = pytlwall.Chamber(pipe_hor_m=0.02, pipe_ver_m=0.01) self.assertEqual(0.02, chamber.pipe_hor_m) self.assertEqual(0.01, chamber.pipe_ver_m) self.assertEqual(0.01, chamber.pipe_rad_m)
def test_pipe_radius(self): print('\nTesting pipe radius') chamber = pytlwall.Chamber(pipe_rad_m=0.02) self.assertEqual(0.02, chamber.pipe_rad_m) self.assertEqual(0.02, chamber.pipe_hor_m) self.assertEqual(0.02, chamber.pipe_ver_m)
def chamber_interface(): choice = '' chamber = pytlwall.Chamber() while choice.lower() != 'back' and choice.lower() != 'x': submenu_chamber() choice = input('Your choice: ') if choice.lower() == 'name': choice = input('insert component name ') chamber.component_name = choice print(f'Component name {chamber.component_name}') elif choice.lower() == 'shape': choice = input('what is chamber shape (allowed values= CIRCULAR' ' (default), ELLIPTICAL, RECTANGULAR ') if (choice.upper() == 'ELLIPTICAL' or choice.upper() == 'RECTANGULAR'): chamber.chamber_shape = choice.upper() print(f'Used chamber shape {chamber.chamber_shape}') elif choice.lower() == 'len': choice = input('what is chamber len in meters ') try: chamber.pipe_len_m = float(choice) except ValueError: pass print(f'Used chamber len {chamber.pipe_len_m}') elif choice.lower() == 'radius': choice = input('what is chamber radius in meters ') try: chamber.pipe_rad_m = float(choice) except ValueError: pass print(f'Used chamber radius {chamber.pipe_rad_m}') elif choice.lower() == 'hor': choice = input('what is chamber horizontal dimension in meters ') try: chamber.pipe_hor_m = float(choice) except ValueError: pass print(f'Used chamber horizontal dimension {chamber.pipe_hor_m}') elif choice.lower() == 'ver': choice = input('what is chamber vertical dimension in meters ') try: chamber.pipe_ver_m = float(choice) except ValueError: pass print(f'Used chamber vertical dimension {chamber.pipe_ver_m}') elif choice.lower() == 'betax': choice = input('what is horizontal beta ') try: chamber.betax = float(choice) except ValueError: pass print(f'Used horizontal beta {chamber.betax}') elif choice.lower() == 'betay': choice = input('what is vertical beta ') try: chamber.betax = float(choice) except ValueError: pass print(f'Used vertical beta {chamber.betay}') elif choice.lower() == 'layer': choice = input('How many layers does the chamber have ' '(not counting the boundary) ') try: nbr_layer = int(choice) except ValueError: nbr_layer = 1 for i in range(nbr_layer): layer = layer_interface(boundary=False, layer_nbr=i) chamber.layers.append(layer) i = i + 1 layer = layer_interface(boundary=True, layer_nbr=i) chamber.layers.append(layer) return chamber
def read_chamber(self, cfg_file=None): if cfg_file is not None: self.read_cfg(cfg_file) if self.config.has_section('base_info') is False: return None pipe_len_m = self.config.getfloat('base_info', 'pipe_len_m') # pipe radius is equal to vertical dimension so in the cfg file or # it is defined the radius or the vertical dimension if self.config.has_option('base_info', 'pipe_radius_m'): pipe_rad_m = self.config.getfloat('base_info', 'pipe_radius_m') pipe_hor_m = pipe_rad_m pipe_ver_m = pipe_rad_m else: pipe_ver_m = self.config.getfloat('base_info', 'pipe_ver_m') pipe_rad_m = pipe_ver_m if self.config.has_option('base_info', 'pipe_hor_m'): pipe_hor_m = self.config.getfloat('base_info', 'pipe_hor_m') chamber_shape = self.config.get('base_info', 'chamber_shape') if self.config.has_option('base_info', 'component_name'): component_name = self.config.get('base_info', 'component_name') else: component_name = 'chamber' betax = self.config.getfloat('base_info', 'betax') betay = self.config.getfloat('base_info', 'betay') nbr_layers = self.config.getint('layers_info', 'nbr_layers') layers = [] for i in range(nbr_layers): layer_type = self.config.get('layer' + str(i), 'type') thick_m = self.config.getfloat('layer' + str(i), 'thick_m') if layer_type == 'CW': muinf_Hz = self.config.getfloat('layer' + str(i), 'muinf_Hz') epsr = self.config.getfloat('layer' + str(i), 'epsr') sigmaDC = self.config.getfloat('layer' + str(i), 'sigmaDC') k_Hz = self.config.getfloat('layer' + str(i), 'k_Hz') tau = self.config.getfloat('layer' + str(i), 'tau') RQ = self.config.getfloat('layer' + str(i), 'RQ') layers.append( pytlwall.Layer(layer_type=layer_type, thick_m=thick_m, muinf_Hz=muinf_Hz, epsr=epsr, sigmaDC=sigmaDC, k_Hz=k_Hz, tau=tau, RQ=RQ, boundary=False)) else: layers.append( pytlwall.Layer(layer_type=layer_type, thick_m=thick_m, boundary=False)) layer_type = self.config.get('boundary', 'type') if layer_type == 'CW': muinf_Hz = self.config.getfloat('boundary', 'muinf_Hz') epsr = self.config.getfloat('boundary', 'epsr') sigmaDC = self.config.getfloat('boundary', 'sigmaDC') k_Hz = self.config.getfloat('boundary', 'k_Hz') tau = self.config.getfloat('boundary', 'tau') RQ = self.config.getfloat('boundary', 'RQ') layers.append( pytlwall.Layer(layer_type=layer_type, muinf_Hz=muinf_Hz, epsr=epsr, sigmaDC=sigmaDC, k_Hz=k_Hz, tau=tau, RQ=RQ, boundary=True)) else: layers.append(pytlwall.Layer(layer_type=layer_type, boundary=True)) chamber = pytlwall.Chamber(pipe_len_m=pipe_len_m, pipe_rad_m=pipe_rad_m, pipe_hor_m=pipe_hor_m, pipe_ver_m=pipe_ver_m, chamber_shape=chamber_shape, betax=betax, betay=betay, layers=layers, component_name=component_name) return chamber