print "=============================================" #---- define the sequences in the linac accelerator lattice names = [ "MEBT", "DTL1", "DTL2", "DTL3", "DTL4", "DTL5", "DTL6", "CCL1", "CCL2", "CCL3", "CCL4", "SCLMed", "SCLHigh", "HEBT1", "HEBT2" ] #---- the XML file name with the structure xml_file_name = "../sns_linac_xml/sns_linac.xml" acc_da = XmlDataAdaptor.adaptorForFile(xml_file_name) #---- make lattice from XML file - another way to construct a lattice #acc_lattice_linac = sns_linac_factory.getLinacAccLattice(names,xml_file_name) acc_lattice_linac = sns_linac_factory.getLinacAccLatticeFromDA(names, acc_da) seqs = acc_lattice_linac.getSequences() L_acc = 0. for seq in seqs: L_acc += seq.getLength() print "seq=", seq.getName(), " pos=", seq.getPosition( ), " L=", seq.getLength(), " total=", L_acc, " nCav=", len( seq.getRF_Cavities()) print "=============================================" cavs = acc_lattice_linac.getRF_Cavities() print "total number of RF cavities =", len(cavs) rf_gaps = acc_lattice_linac.getRF_Gaps() print "total number of RF gaps =", len(rf_gaps)
#---- make vacuum window node and add it to the end of the DTL window_length = 0.005 pos = dtl_da.doubleValue("length") - window_length - 0.00001 vacwin_node = make_vacwin_da("DTL:VACWIN", window_length, pos) dtl_da.addChildAdaptor(vacwin_node) #---- print a structure of the new data adaptor DTL3 #print dtl_da.makeXmlText() #---- create the factory instance sns_linac_factory = SNS_LinacLatticeFactory() sns_linac_factory.setMaxDriftLength(0.1) #---- make lattice from XML file names = ["MEBT", "DTL1", "DTL2", "DTL3"] sns_lattice = sns_linac_factory.getLinacAccLatticeFromDA(names, sns_lattice_da) bunch = Bunch() bunch.readBunch("bunch_at_mebt_start.dat") lostbunch = Bunch() paramsDict = { "lostbunch": lostbunch, } sns_lattice.trackDesignBunch(bunch) sns_lattice.trackBunch(bunch, paramsDict) print "========= Bunch Sizes after Vacuum Window ==========" print "transported bunch size = ", bunch.getSize() print " lost bunch size = ", lostbunch.getSize()
print "Lattice max drift length =",sns_linac_factory.getMaxDriftLength() print "=============================================" #---- define the sequences in the linac accelerator lattice names = ["MEBT","DTL1","DTL2","DTL3","DTL4","DTL5","DTL6","CCL1","CCL2","CCL3","CCL4","SCLMed","SCLHigh","HEBT1","HEBT2"] #names = ["MEBT","DTL1","DTL2","DTL3","DTL4","DTL5","DTL6","CCL1","CCL2","CCL3","CCL4"] #---- the XML file name with the structure xml_file_name = "../sns_linac_xml/sns_linac.xml" acc_da = XmlDataAdaptor.adaptorForFile(xml_file_name) #---- make lattice from XML file #acc_lattice_linac = sns_linac_factory.getLinacAccLattice(names,xml_file_name) acc_lattice_linac = sns_linac_factory.getLinacAccLatticeFromDA(names,acc_da) seqs = acc_lattice_linac.getSequences() L_acc = 0. for seq in seqs: L_acc += seq.getLength() print "seq=",seq.getName()," pos=",seq.getPosition()," L=",seq.getLength()," total=",L_acc," nCav=",len(seq.getRF_Cavities()) print "=============================================" cavs = acc_lattice_linac.getRF_Cavities() print "total number of RF cavities =",len(cavs) rf_gaps = acc_lattice_linac.getRF_Gaps() print "total number of RF gaps =",len(rf_gaps) quads = acc_lattice_linac.getQuads()