示例#1
0
 def test_transverse_output(self):
     print('\nTesting transverse  plot, scale log, symlog')
     read_cfg = pytlwall.CfgIo('input/one_layer.cfg')
     mywall = read_cfg.read_pytlwall()
     mywall.calc_ZTrans()
     savedir = 'output/one_layer/img/'
     savename = 'ZTransReal.png'
     imped_type = "T"
     f = mywall.f
     list_Z = [
         mywall.ZDipX.real, mywall.ZDipY.real, mywall.ZQuadX.real,
         mywall.ZQuadY.real
     ]
     title = 'Transverse impedance Real'
     list_label = [
         'Dipolar X', 'Dipolar Y', 'Quadrupolar X', 'Quadrupolar Y'
     ]
     plot.plot_list_Z_vs_f(f, list_Z, list_label, 'T', title, savedir,
                           savename, 'log', 'symlog')
     savename = 'ZTransImag.png'
     list_Z = [
         mywall.ZDipX.imag, mywall.ZDipY.imag, mywall.ZQuadX.imag,
         mywall.ZQuadY.imag
     ]
     list_label = [
         'Dipolar X', 'Dipolar Y', 'Quadrupolar X', 'Quadrupolar Y'
     ]
     title = 'Transverse impedance Imaginary Part'
     plot.plot_list_Z_vs_f(f, list_Z, list_label, 'T', title, savedir,
                           savename, 'log', 'symlog')
示例#2
0
 def test_onelayer(self):
     print('\nTesting one layer cfg')
     read_cfg = pytlwall.CfgIo()
     chamber = read_cfg.read_chamber('input/one_layer.cfg')
     self.assertEqual('prova', chamber.component_name)
     self.assertEqual(2e-2, chamber.pipe_hor_m)
     self.assertEqual('CW', chamber.layers[0].layer_type)
     self.assertEqual('PEC', chamber.layers[1].layer_type)
示例#3
0
 def test_longitudinal_output(self):
     print('\nTesting longitudinal output, text')
     read_cfg = pytlwall.CfgIo('input/one_layer.cfg')
     mywall = read_cfg.read_pytlwall()
     mywall.calc_ZLong()
     filedir = 'output/'
     filename = 'one_layerZLong.txt'
     label = "longitudinal impedance"
     txt.save_ZLong(filedir, filename, mywall.f, mywall.ZLong, label)
示例#4
0
 def test_transverse_output(self):
     print('\nTesting transverse output, text')
     read_cfg = pytlwall.CfgIo('input/one_layer.cfg')
     mywall = read_cfg.read_pytlwall()
     mywall.calc_ZTrans()
     filedir = 'output/'
     filename = 'one_layerZTrans.txt'
     label = "transverse impedance"
     txt.save_ZTrans(filedir, filename, mywall.f, mywall.ZTrans, label)
示例#5
0
 def test_all_transverse_output(self):
     print('\nTesting all the transverse output, text')
     read_cfg = pytlwall.CfgIo('input/test001.cfg')
     mywall = read_cfg.read_pytlwall()
     mywall.calc_ZTrans()
     filedir = 'output/'
     filename = 'test001ZAllTrans.txt'
     label = "transverse impedance"
     txt.save_ZAllTrans(filedir, filename, mywall.f, mywall.ZDipX,
                        mywall.ZDipY, mywall.ZQuadX, mywall.ZQuadY, label)
示例#6
0
 def test_onelayer_circ(self):
     print('\nTesting one layer circular relativ')
     read_cfg = pytlwall.CfgIo('input/test001.cfg')
     # plot all save all
     mywall = read_cfg.read_pytlwall()
     mywall.calc_ZLong()
     mywall.calc_ZTrans()
     savedir = 'output/test001/'
     savename = 'ZLong.txt'
     label = 'Longitudinal'
     txt.save_ZLong(savedir, savename, mywall.f, mywall.ZLong, label)
     savename = 'ZTrans.txt'
     label = 'Transversal'
     txt.save_ZTrans(savedir, savename, mywall.f, mywall.ZTrans, label)
     savedir = 'output/test001/img/'
     savename = 'ZLong.png'
     imped_type = "L"
     title = 'Longitudinal impedance'
     plot.plot_Z_vs_f_simple(mywall.f,
                             mywall.ZLong,
                             imped_type,
                             title,
                             savedir,
                             savename,
                             xscale='log',
                             yscale='log')
     savename = 'ZTransReal.png'
     imped_type = "T"
     list_Z = [
         mywall.ZDipX.real, mywall.ZDipY.real, mywall.ZQuadX.real,
         mywall.ZQuadY.real
     ]
     title = 'Transverse impedance Real'
     list_label = [
         'Dipolar X', 'Dipolar Y', 'Quadrupolar X', 'Quadrupolar Y'
     ]
     plot.plot_list_Z_vs_f(mywall.f, list_Z, list_label, 'T', title,
                           savedir, savename, 'log', 'symlog')
     savename = 'ZTransImag.png'
     list_Z = [
         mywall.ZDipX.imag, mywall.ZDipY.imag, mywall.ZQuadX.imag,
         mywall.ZQuadY.imag
     ]
     list_label = [
         'Dipolar X', 'Dipolar Y', 'Quadrupolar X', 'Quadrupolar Y'
     ]
     title = 'Transverse impedance Imaginary Part'
     plot.plot_list_Z_vs_f(mywall.f, list_Z, list_label, 'T', title,
                           savedir, savename, 'log', 'symlog')
示例#7
0
 def test_longitudinal_output(self):
     print('\nTesting longitudinal simple plot, scale log')
     read_cfg = pytlwall.CfgIo('input/one_layer.cfg')
     mywall = read_cfg.read_pytlwall()
     mywall.calc_ZLong()
     savedir = 'output/one_layer/img/'
     savename = 'ZLong.png'
     imped_type = "L"
     title = 'Longitudinal impedance'
     plot.plot_Z_vs_f_simple(mywall.f,
                             mywall.ZLong,
                             imped_type,
                             title,
                             savedir,
                             savename,
                             xscale='log',
                             yscale='log')
示例#8
0
 def test_onelayer_circSurf(self):
     print('\nTesting one layer circular relativ surface impedance')
     read_cfg = pytlwall.CfgIo('input/test001.cfg')
     # plot all save all
     mywall = read_cfg.read_pytlwall()
     ZLongSurf = mywall.ZLongSurf
     ZTransSurf = mywall.ZTransSurf
     savedir = 'output/test001/'
     savename = 'ZLongSurf.txt'
     label = 'Longitudinal'
     txt.save_ZLong(savedir, savename, mywall.f, ZLongSurf, label)
     savename = 'ZTransSurf.txt'
     label = 'Transversal'
     txt.save_ZTrans(savedir, savename, mywall.f, ZTransSurf, label)
     savedir = 'output/test001/img/'
     savename = 'ZLongSurf.png'
     imped_type = "L"
     title = 'Longitudinal impedance'
     plot.plot_Z_vs_f_simple(mywall.f,
                             ZLongSurf,
                             imped_type,
                             title,
                             savedir,
                             savename,
                             xscale='log',
                             yscale='log')
     savename = 'ZTransSurf.png'
     imped_type = "T"
     plot.plot_Z_vs_f_simple(mywall.f,
                             ZTransSurf,
                             imped_type,
                             title,
                             savedir,
                             savename,
                             xscale='log',
                             yscale='log')
示例#9
0
import pandas as pd
import pytlwall
import pytlwall.plot_util as plot

read_cfg = pytlwall.CfgIo('ex_lowbeta/ex_lowbeta.cfg')
mywall = read_cfg.read_pytlwall()
mywall.calc_ZLong()
mywall.calc_ZTrans()

# save all the data in a dataframe
savedir = 'ex_lowbeta/output/'
data = {
    'f': mywall.f,
    'ZLong real': mywall.ZLong.real,
    'ZLong imag': mywall.ZLong.imag,
    'ZTrans real': mywall.ZTrans.real,
    'ZTrans imag': mywall.ZTrans.imag
}
df = pd.DataFrame(data)
df.to_excel(savedir + 'output.xlsx')

# plot the impedances
savedir = 'ex_lowbeta/img/'
savename = 'ZLong.png'
title = 'Longitudinal impedance'
ZLong = mywall.ZLong + mywall.ZLongISC
plot.plot_Z_vs_f_simple(mywall.f,
                        ZLong,
                        'L',
                        title,
                        savedir,
示例#10
0
 def test_pytlwall(self):
     print('\nTesting pytlwall')
     read_cfg = pytlwall.CfgIo('input/one_layer.cfg')
     mywall = read_cfg.read_pytlwall()
     self.assertEqual(0.01, mywall.beam.test_beam_shift)
     self.assertEqual(1.e5, round(mywall.beam.gammarel, 3))
示例#11
0
 def test_beam(self):
     print('\nTesting beam')
     read_cfg = pytlwall.CfgIo()
     beam = read_cfg.read_beam('input/one_layer.cfg')
     self.assertEqual(0.01, beam.test_beam_shift)
     self.assertEqual(1e5, round(beam.gammarel, 3))
示例#12
0
 def test_frequency(self):
     print('\nTesting frequency')
     read_cfg = pytlwall.CfgIo()
     freq = read_cfg.read_freq('input/one_layer.cfg')
     self.assertEqual(2, freq.fstep)
示例#13
0
import pandas as pd
import pytlwall
import pytlwall.plot_util as plot

read_cfg = pytlwall.CfgIo('ex_PEC/ex_PEC.cfg')
mywall = read_cfg.read_pytlwall()
mywall.calc_ZLong()
mywall.calc_ZTrans()

# save all the data in a dataframe
savedir = 'ex_PEC/output/'
data = {
    'f': mywall.f,
    'ZLong real': mywall.ZLong.real,
    'ZLong imag': mywall.ZLong.imag,
    'ZTrans real': mywall.ZTrans.real,
    'ZTrans imag': mywall.ZTrans.imag
}
df = pd.DataFrame(data)
df.to_excel(savedir + 'output.xlsx')

# plot the impedances
savedir = 'ex_PEC/img/'
savename = 'ZLong.png'
title = 'Longitudinal impedance'
plot.plot_Z_vs_f_simple(mywall.f,
                        mywall.ZLong,
                        'L',
                        title,
                        savedir,
                        savename,
示例#14
0
import pandas as pd
import pytlwall
import pytlwall.plot_util as plot

read_cfg = pytlwall.CfgIo('ex_Vac/ex_Vac.cfg')
mywall = read_cfg.read_pytlwall()
mywall.calc_ZLong()
mywall.calc_ZTrans()

# save all the data in a dataframe
savedir = 'ex_Vac/output/'
data = {
    'f': mywall.f,
    'ZLong real': mywall.ZLong.real,
    'ZLong imag': mywall.ZLong.imag,
    'ZTrans real': mywall.ZTrans.real,
    'ZTrans imag': mywall.ZTrans.imag
}
df = pd.DataFrame(data)
df.to_excel(savedir + 'output.xlsx')

# plot the impedances
savedir = 'ex_Vac/img/'
savename = 'ZLong.png'
title = 'Longitudinal impedance'
plot.plot_Z_vs_f_simple(mywall.f,
                        mywall.ZLong,
                        'L',
                        title,
                        savedir,
                        savename,
示例#15
0
configurator file or interactively taking the information from the user
'''

import sys
import pytlwall
import pytlwall.shell_interface as shell


if len(sys.argv) == 1:
    shell.welcome_message()
    shell.help_pytlwall()
else:
    param = sys.argv[1]
    if param == '-a':
        filename = sys.argv[2]
        read_cfg = pytlwall.CfgIo(filename)
        read_cfg.read_output()
        read_cfg.calc_wall()
        read_cfg.print_wall()
        read_cfg.plot_wall()
    elif param == '-i':
        choice = ''
        shell.welcome_message()
        myconfig = pytlwall.CfgIo()
        while choice.upper() != 'X' and choice.lower() != 'exit':
            if ('chamber' in locals() and 'beam' in locals()
               and 'freq' in locals() and 'wall' not in locals()):
                if len(chamber.layers) > 0:
                    defined_wall = True
                    wall = pytlwall.TlWall(chamber, beam, freq)
            shell.menu0_pytlwall()
示例#16
0
import pandas as pd
import pytlwall
import pytlwall.plot_util as plot

read_cfg = pytlwall.CfgIo('ex_surface_impedance/ex_surface_impedance.cfg')
mywall = read_cfg.read_pytlwall()
mywall.calc_ZLong()
mywall.calc_ZTrans()

# save all the data in a dataframe
savedir = 'ex_surface_impedance/output/'
data = {
    'f': mywall.f,
    'ZLong real': mywall.ZLong.real,
    'ZLong imag': mywall.ZLong.imag,
    'ZTrans real': mywall.ZTrans.real,
    'ZTrans imag': mywall.ZTrans.imag,
    'ZLong Equivalent Surface real': mywall.ZLongSurf.real,
    'ZLong Equivalent Surface imag': mywall.ZLongSurf.imag,
    'ZTrans Equivalent Surface real': mywall.ZTransSurf.real,
    'ZTrans Equivalent Surface imag': mywall.ZTransSurf.imag
}
df = pd.DataFrame(data)
df.to_excel(savedir + 'output.xlsx')

# plot the impedances
savedir = 'ex_surface_impedance/img/'
savename = 'ZLongSurf.png'
title = 'Eq. Long. Surface imp.'
plot.plot_Z_vs_f_simple(mywall.f,
                        mywall.ZLongSurf,
示例#17
0
import pandas as pd
import pytlwall
import pytlwall.plot_util as plot
import pytlwall.txt_util as txt

read_cfg = pytlwall.CfgIo(
    'ex_surface_impedance_input/ex_surface_impedance_input.cfg')
mywall = read_cfg.read_pytlwall()
filename = 'ex_surface_impedance_input/surface_impedance_input.txt'
new_f, new_KZ = txt.read_surface_impedance_txt(filename, skipped_rows=1)
mywall.chamber.layers[0].set_surf_imped(new_f, new_KZ)

mywall.calc_ZLong()
mywall.calc_ZTrans()

# save all the data in a dataframe
savedir = 'ex_surface_impedance_input/output/'
data = {
    'f': mywall.f,
    'ZLong real': mywall.ZLong.real,
    'ZLong imag': mywall.ZLong.imag,
    'ZTrans real': mywall.ZTrans.real,
    'ZTrans imag': mywall.ZTrans.imag,
}
df = pd.DataFrame(data)
df.to_excel(savedir + 'output.xlsx')

# plot the impedances
savedir = 'ex_surface_impedance_input/img/'
savename = 'ZLong.png'
title = 'Long. impedance'
示例#18
0
import pandas as pd
import pytlwall
import pytlwall.plot_util as plot

read_cfg = pytlwall.CfgIo('ex_CW/ex_CW.cfg')
mywall = read_cfg.read_pytlwall()
mywall.calc_ZLong()
mywall.calc_ZTrans()

# save all the data in a dataframe
savedir = 'ex_CW/output/'
data = {'f': mywall.f,
        'ZLong real': mywall.ZLong.real, 'ZLong imag': mywall.ZLong.imag,
        'ZTrans real': mywall.ZTrans.real, 'ZTrans imag': mywall.ZTrans.imag}
df = pd.DataFrame(data)
df.to_excel(savedir + 'output.xlsx')

# plot the impedances
savedir = 'ex_CW/img/'
savename = 'ZLong.png'
title = 'Longitudinal impedance'
plot.plot_Z_vs_f_simple(mywall.f, mywall.ZLong, 'L', title,
                        savedir, savename,
                        xscale='log', yscale='log')

savename = 'ZTrans.png'
title = 'Transversal impedance'
plot.plot_Z_vs_f_simple(mywall.f, mywall.ZTrans, 'T', title,
                        savedir, savename,
                        xscale='log', yscale='log')