def actionPerformed(self, actionEvent):
     linac_wizard_document = self.transverse_twiss_fitting_controller.linac_wizard_document
     if (linac_wizard_document.getAccSeq() == null):
         return
     accSeq = linac_wizard_document.getAccSeq()
     quads = linac_wizard_document.ws_lw_controller.quads
     cavs = linac_wizard_document.ws_lw_controller.cavs
     env_tracker = AlgorithmFactory.createEnvTrackerAdapt(accSeq)
     design_probe = ProbeFactory.getEnvelopeProbe(accSeq, env_tracker)
     twiss_arr = design_probe.getCovariance().computeTwiss()
     initial_twiss_params_holder = self.transverse_twiss_fitting_controller.initial_twiss_params_holder
     ph = initial_twiss_params_holder
     #------------X--------------------
     ph.setAlphaX(twiss_arr[0].getAlpha())
     ph.setBetaX(twiss_arr[0].getBeta())
     ph.setEmittX(twiss_arr[0].getEmittance() * 1.0e+6)
     ph.setAlphaX_Err(0.)
     ph.setBetaX_Err(0.)
     ph.setEmittX_Err(0.)
     ph.setAlphaX_Step(0.1)
     ph.setBetaX_Step(0.1)
     ph.setEmittX_Step(ph.getEmittX() * 0.05)
     #------------Y--------------------
     ph.setAlphaY(twiss_arr[1].getAlpha())
     ph.setBetaY(twiss_arr[1].getBeta())
     ph.setEmittY(twiss_arr[1].getEmittance() * 1.0e+6)
     ph.setAlphaY_Err(0.)
     ph.setBetaY_Err(0.)
     ph.setEmittY_Err(0.)
     ph.setAlphaY_Step(0.1)
     ph.setBetaY_Step(0.1)
     ph.setEmittY_Step(ph.getEmittY() * 0.05)
     #------------Z--------------------
     ph.setAlphaZ(twiss_arr[2].getAlpha())
     ph.setBetaZ(twiss_arr[2].getBeta())
     ph.setEmittZ(twiss_arr[2].getEmittance() * 1.0e+6)
     ph.setAlphaZ_Err(0.)
     ph.setBetaZ_Err(0.)
     ph.setEmittZ_Err(0.)
     ph.setAlphaZ_Step(0.)
     ph.setBetaZ_Step(0.)
     ph.setEmittZ_Step(0.)
     #initial_twiss_params_holder.printParams()
     self.transverse_twiss_fitting_controller.initTwiss_table.getModel(
     ).fireTableDataChanged()
     init_and_fit_params_controller = self.transverse_twiss_fitting_controller.init_and_fit_params_controller
     init_and_fit_params_controller.eKin_text.setValue(
         design_probe.getKineticEnergy() / 1.0e+6)
     init_and_fit_params_controller.current_text.setValue(
         design_probe.getBeamCurrent() * 1000)
Пример #2
0
	def __init__(self,main_loop_controller):
		self.main_loop_controller = main_loop_controller
		cav_wrappers = self.main_loop_controller.cav_wrappers	
		self.accSeq = self.main_loop_controller.accSeq
		self.part_tracker = AlgorithmFactory.createParticleTracker(self.accSeq)
		self.part_tracker.setRfGapPhaseCalculation(true)
		self.part_probe_init = ProbeFactory.createParticleProbe(self.accSeq,self.part_tracker)
		self.scenario = Scenario.newScenarioFor(self.accSeq)
		self.scenario.setSynchronizationMode(Scenario.SYNC_MODE_DESIGN)
		self.scenario.resync()
		part_probe = ParticleProbe(self.part_probe_init)
		part_probe.setKineticEnergy(self.part_probe_init.getKineticEnergy())
		self.scenario.setProbe(part_probe)	
		self.scenario.run()	
		#-------------------------------------------------
		# The cavToGapsDict is needed for reference to the irfGap to set phase and do not use  scenario.resync()
		rfGaps = self.accSeq.getAllNodesWithQualifier(AndTypeQualifier().and((OrTypeQualifier()).or(RfGap.s_strType)))	
		self.cavToGapsDict = {}
		self.cavEnergyInOutDict = {}		
		for cav_wrapper in cav_wrappers:
			self.cavToGapsDict[cav_wrapper] = []
			for rfGap in rfGaps:
				if(rfGap.getParent().getId() == cav_wrapper.cav.getId()):
					irfGaps = self.scenario.elementsMappedTo(rfGap)
					self.cavToGapsDict[cav_wrapper].append(irfGaps[0])
		for cav_wrapper_ind in range(len(cav_wrappers)):
			cav_wrapper = cav_wrappers[cav_wrapper_ind]
			irfGaps = self.cavToGapsDict[cav_wrapper]
			nGaps = len(irfGaps)
			state_in = self.scenario.getTrajectory().statesForElement(irfGaps[0].getId()).get(0)
			if(cav_wrapper_ind > 0):
				irfGaps_0 = self.cavToGapsDict[cav_wrappers[cav_wrapper_ind-1]]
				irfGap_0 = irfGaps_0[len(irfGaps_0)-1]
				state_in = self.scenario.getTrajectory().statesForElement(irfGap_0.getId()).get(0)
			state_out = self.scenario.getTrajectory().statesForElement(irfGaps[nGaps-1].getId()).get(0)
			#print "debug cav=",cav_wrapper.alias," eKin_in=",state_in.getKineticEnergy()/1.0e+6," eKin_out=",state_out.getKineticEnergy()/1.0e+6
			self.cavEnergyInOutDict[cav_wrapper] = (state_in.getKineticEnergy()/1.0e+6,state_out.getKineticEnergy()/1.0e+6)
		# cav_wrappers_param_dict[cav_wrapper] = (cavAmp,phase)
		self.cav_wrappers_param_dict = {}
		self.cav_amp_phase_dict = {}
		for cav_wrapper in cav_wrappers:
			amp = cav_wrapper.cav.getDfltCavAmp()
			phase = cav_wrapper.cav.getDfltCavPhase()
			self.cav_amp_phase_dict[cav_wrapper] = (amp,phase)
		#----------------------------------------------------------------
		self.active_cav_wrapper = null
		self.gap_first = null
		self.gap_last = null	
		self.gap_list = null
Пример #3
0
	def __init__(self,mebt_main_orbit_diff_cntrl):
		self.mebt_main_orbit_diff_cntrl = mebt_main_orbit_diff_cntrl	
		self.accSeq = self.mebt_main_orbit_diff_cntrl.accSeq
		self.scenario = Scenario.newScenarioFor(self.accSeq)
		self.scenario.setSynchronizationMode(Scenario.SYNC_MODE_DESIGN)
		self.scenario.unsetStartNode()
		self.scenario.unsetStopNode()			
		self.part_tracker = AlgorithmFactory.createParticleTracker(self.accSeq)
		self.part_tracker.setRfGapPhaseCalculation(true)
		self.part_probe_init = ProbeFactory.createParticleProbe(self.accSeq,self.part_tracker)
		self.scenario.resync()
		part_probe = ParticleProbe(self.part_probe_init)
		self.scenario.setProbe(part_probe)
		self.scenario.run()
		self.traj = self.scenario.getTrajectory()	
	def actionPerformed(self,actionEvent):
		linac_wizard_document = self.transverse_twiss_fitting_controller.linac_wizard_document		
		if(linac_wizard_document.getAccSeq() == null):
			return
		accSeq = linac_wizard_document.getAccSeq()
		quads = linac_wizard_document.ws_lw_controller.quads
		cavs = linac_wizard_document.ws_lw_controller.cavs
		env_tracker = AlgorithmFactory.createEnvTrackerAdapt(accSeq)
		design_probe = ProbeFactory.getEnvelopeProbe(accSeq,env_tracker)
		twiss_arr = design_probe.getCovariance().computeTwiss()
		initial_twiss_params_holder = self.transverse_twiss_fitting_controller.initial_twiss_params_holder
		ph = initial_twiss_params_holder
		#------------X--------------------
		ph.setAlphaX(twiss_arr[0].getAlpha())
		ph.setBetaX(twiss_arr[0].getBeta())
		ph.setEmittX(twiss_arr[0].getEmittance()*1.0e+6)
		ph.setAlphaX_Err(0.)
		ph.setBetaX_Err(0.)
		ph.setEmittX_Err(0.)
		ph.setAlphaX_Step(0.1)
		ph.setBetaX_Step(0.1)
		ph.setEmittX_Step(ph.getEmittX()*0.05)		
		#------------Y--------------------
		ph.setAlphaY(twiss_arr[1].getAlpha())
		ph.setBetaY(twiss_arr[1].getBeta())
		ph.setEmittY(twiss_arr[1].getEmittance()*1.0e+6)
		ph.setAlphaY_Err(0.)
		ph.setBetaY_Err(0.)
		ph.setEmittY_Err(0.)
		ph.setAlphaY_Step(0.1)
		ph.setBetaY_Step(0.1)
		ph.setEmittY_Step(ph.getEmittY()*0.05)
		#------------Z--------------------
		ph.setAlphaZ(twiss_arr[2].getAlpha())
		ph.setBetaZ(twiss_arr[2].getBeta())
		ph.setEmittZ(twiss_arr[2].getEmittance()*1.0e+6)
		ph.setAlphaZ_Err(0.)
		ph.setBetaZ_Err(0.)
		ph.setEmittZ_Err(0.)
		ph.setAlphaZ_Step(0.)
		ph.setBetaZ_Step(0.)
		ph.setEmittZ_Step(0.)			
		#initial_twiss_params_holder.printParams()
		self.transverse_twiss_fitting_controller.initTwiss_table.getModel().fireTableDataChanged()
		init_and_fit_params_controller = self.transverse_twiss_fitting_controller.init_and_fit_params_controller
		init_and_fit_params_controller.eKin_text.setValue(design_probe.getKineticEnergy()/1.0e+6)
		init_and_fit_params_controller.current_text.setValue(design_probe.getBeamCurrent()*1000)
Пример #5
0
	def __init__(self,linac_wizard_document):
		#--- linac_wizard_document the parent document for all controllers
		self.linac_wizard_document = linac_wizard_document	
		#----scl_accSeq is a specific for this controller
		accl = self.linac_wizard_document.accl
		lst = ArrayList()
		for seqName in ["SCLMed","SCLHigh","HEBT1","HEBT2"]:	
			lst.add(accl.getSequence(seqName))
		self.scl_accSeq = AcceleratorSeqCombo("SCL_SEQUENCE", lst)	
		part_tracker = AlgorithmFactory.createParticleTracker(self.scl_accSeq)
		part_probe = ProbeFactory.createParticleProbe(self.scl_accSeq,part_tracker)
		self.mass = part_probe.getSpeciesRestEnergy()
		self.bpm_freq = 402.5e+6
		self.c_light = 2.99792458e+8
		#-------- Ring length 
		self.ring_length = accl.findSequence("Ring").getLength()
		#-------- BPMs and Cavities arrays
		self.bpm_wrappers = []
		self.cav_wrappers = []
		#-------- self.cav0_wrapper is used for all cavities (includind Cav01a) Blanked statistics
		self.cav0_wrapper = null
		self.fillOut_Arrays()	
		#--- the main tabbed pane		
		self.tabbedPane = JTabbedPane()
		#-------- child controllers 
		self.scl_long_tuneup_init_controller = SCL_Long_TuneUp_Init_Controller(self)
		self.scl_long_tuneup_phase_scan_controller = SCL_Long_TuneUp_PhaseScan_Controller(self)
		self.scl_long_tuneup_bpm_offsets_controller = SCL_Long_TuneUp_BPM_Offsets_Controller(self)
		self.scl_long_tuneup_phase_analysis_controller = SCL_Long_TuneUp_PhaseAnalysis_Controller(self)
		self.scl_long_tuneup_rescale_controller = SCL_Long_TuneUp_Rescale_Controller(self)
		self.scl_long_tuneup_energy_meter_controller = SCL_Energy_Meter_Controller(self)	
		self.scl_long_twiss_analysis_controller = SCL_Long_Twiss_Analysis_Controller(self)
		self.scl_long_laser_stripping_controller = SCL_Laser_Stripping_Controller(self)
		#the beamTrigger will be initialized after the user hit "Init" button in SCL_Long_Init_Controller 
		self.beamTrigger = null
		#sets of BPMs for BPM_Batch_Reader will be setup in "Init" button in SCL_Long_Init_Controller 
		self.bpmBatchReader = BPM_Batch_Reader(self)
		#----add all subpanels to the SCL main tab panel
		self.tabbedPane.add("Init",self.scl_long_tuneup_init_controller.getMainPanel())
		self.tabbedPane.add("Phase Scan",self.scl_long_tuneup_phase_scan_controller.getMainPanel())		
		self.tabbedPane.add("BPM Offsets",self.scl_long_tuneup_bpm_offsets_controller.getMainPanel())	
		self.tabbedPane.add("Phase Analysis",self.scl_long_tuneup_phase_analysis_controller.getMainPanel())
		self.tabbedPane.add("Rescale SCL",self.scl_long_tuneup_rescale_controller.getMainPanel())
		self.tabbedPane.add("Energy Meter",self.scl_long_tuneup_energy_meter_controller.getMainPanel())
		self.tabbedPane.add("Long. Twiss",self.scl_long_twiss_analysis_controller.getMainPanel())
		self.tabbedPane.add("Laser Stripping",self.scl_long_laser_stripping_controller.getMainPanel())
	def __init__(self,scl_long_tuneup_controller):
		self.scl_long_tuneup_controller = scl_long_tuneup_controller
		self.scl_accSeq = self.scl_long_tuneup_controller.scl_accSeq
		self.part_tracker = AlgorithmFactory.createParticleTracker(self.scl_accSeq)
		self.part_tracker.setRfGapPhaseCalculation(true)
		self.part_probe_init = ProbeFactory.createParticleProbe(self.scl_accSeq,self.part_tracker)
		scl_long_tuneup_phase_analysis_controller = self.scl_long_tuneup_controller.scl_long_tuneup_phase_analysis_controller
		self.scenario = scl_long_tuneup_phase_analysis_controller.scl_one_cavity_tracker_model.scenario
		if(self.scenario == null):
			self.scenario = Scenario.newScenarioFor(self.scl_accSeq)
			self.scenario.setSynchronizationMode(Scenario.SYNC_MODE_DESIGN)
			self.scenario.resync()
		else:
			self.scenario.unsetStartNode()
			self.scenario.unsetStopNode()			
		# in the dictionary we will have 
		# cav_wrappers_param_dict[cav_wrapper] = [cavAmp,phase]
		self.cav_wrappers_param_dict = {}
		cav_wrappers = self.scl_long_tuneup_controller.cav_wrappers
		self.cav_amp_phase_dict = {}
		for cav_wrapper in cav_wrappers:
			amp = cav_wrapper.cav.getDfltCavAmp()
			phase = cav_wrapper.cav.getDfltCavPhase()
			self.cav_amp_phase_dict[cav_wrapper] = [amp,phase]
		#------ Make rf gap arrays for each cavity. 
		#------ The elements are IdealRfGap instances not AcceleratorNode. 
		#------ self.cavToGapsDict has {cav_name:[irfGaps]}
		rfGaps = self.scl_accSeq.getAllNodesWithQualifier(AndTypeQualifier().and((OrTypeQualifier()).or(RfGap.s_strType)))	
		self.cavToGapsDict = {}		
		for cav_wrapper in cav_wrappers:
			self.cavToGapsDict[cav_wrapper] = []
			for rfGap in rfGaps:
				if(rfGap.getId().find(cav_wrapper.cav.getId()) >= 0):
					irfGaps = self.scenario.elementsMappedTo(rfGap)
					self.cavToGapsDict[cav_wrapper].append(irfGaps[0])				
		#self.scenario.setModelInput(self.gap_first,RfGapPropertyAccessor.PROPERTY_PHASE,phase)
		#self.scenario.setModelInput(self.gap_first,RfGapPropertyAccessor.PROPERTY_ETL,val)
		#self.scenario.setModelInput(self.gap_first,RfGapPropertyAccessor.PROPERTY_E0,val)
		#self.scenario.setModelInput(quad,ElectromagnetPropertyAccessor,PROPERTY_FIELD,val)		
		#----------------------------------------------------------------
		self.modelArrivalTimesIsReady = false
		self.new_cav_amp_phase_dict = {}
		for cav_wrapper in cav_wrappers:
			self.new_cav_amp_phase_dict[cav_wrapper] = self.cav_amp_phase_dict[cav_wrapper][:]
	def __init__(self,scl_long_tuneup_controller):
		self.scl_long_tuneup_controller = scl_long_tuneup_controller
		self.scl_accSeq = self.scl_long_tuneup_controller.scl_accSeq
		self.part_tracker = AlgorithmFactory.createParticleTracker(self.scl_accSeq)
		self.part_tracker.setRfGapPhaseCalculation(true)
		self.part_probe_init = ProbeFactory.createParticleProbe(self.scl_accSeq,self.part_tracker)
		scl_long_tuneup_phase_analysis_controller = self.scl_long_tuneup_controller.scl_long_tuneup_phase_analysis_controller
		self.scenario = scl_long_tuneup_phase_analysis_controller.scl_one_cavity_tracker_model.scenario
		if(self.scenario == null):
			self.scenario = Scenario.newScenarioFor(self.scl_accSeq)
			self.scenario.setSynchronizationMode(Scenario.SYNC_MODE_DESIGN)
			self.scenario.resync()
		else:
			self.scenario.unsetStartNode()
			self.scenario.unsetStopNode()			
		# in the dictionary we will have 
		# cav_wrappers_param_dict[cav_wrapper] = [cavAmp,phase]
		self.cav_wrappers_param_dict = {}
		cav_wrappers = self.scl_long_tuneup_controller.cav_wrappers
		self.cav_amp_phase_dict = {}
		for cav_wrapper in cav_wrappers:
			amp = cav_wrapper.cav.getDfltCavAmp()
			phase = cav_wrapper.cav.getDfltCavPhase()
			self.cav_amp_phase_dict[cav_wrapper] = [amp,phase]
		#------ Make rf gap arrays for each cavity. 
		#------ The elements are IdealRfGap instances not AcceleratorNode. 
		#------ self.cavToGapsDict has {cav_name:[irfGaps]}
		rfGaps = self.scl_accSeq.getAllNodesWithQualifier(AndTypeQualifier().and((OrTypeQualifier()).or(RfGap.s_strType)))	
		self.cavToGapsDict = {}		
		for cav_wrapper in cav_wrappers:
			self.cavToGapsDict[cav_wrapper] = []
			for rfGap in rfGaps:
				if(rfGap.getId().find(cav_wrapper.cav.getId()) >= 0):
					irfGaps = self.scenario.elementsMappedTo(rfGap)
					self.cavToGapsDict[cav_wrapper].append(irfGaps[0])				
		#self.scenario.setModelInput(self.gap_first,RfGapPropertyAccessor.PROPERTY_PHASE,phase)
		#self.scenario.setModelInput(self.gap_first,RfGapPropertyAccessor.PROPERTY_ETL,val)
		#self.scenario.setModelInput(self.gap_first,RfGapPropertyAccessor.PROPERTY_E0,val)
		#self.scenario.setModelInput(quad,ElectromagnetPropertyAccessor,PROPERTY_FIELD,val)		
		#----------------------------------------------------------------
		self.modelArrivalTimesIsReady = false
		self.new_cav_amp_phase_dict = {}
		for cav_wrapper in cav_wrappers:
			self.new_cav_amp_phase_dict[cav_wrapper] = self.cav_amp_phase_dict[cav_wrapper][:]
	def __init__(self,scl_long_tuneup_controller):
		self.scl_long_tuneup_controller = scl_long_tuneup_controller
		self.scl_accSeq = self.scl_long_tuneup_controller.scl_accSeq
		self.part_tracker = AlgorithmFactory.createParticleTracker(self.scl_accSeq)
		self.part_tracker.setRfGapPhaseCalculation(true)
		self.part_probe_init = ProbeFactory.createParticleProbe(self.scl_accSeq,self.part_tracker)
		self.scenario = Scenario.newScenarioFor(self.scl_accSeq)
		self.scenario.setSynchronizationMode(Scenario.SYNC_MODE_DESIGN)
		self.scenario.resync()
		# in the dictionary we will have 
		# cav_wrappers_param_dict[cav_wrapper] = [cavAmp,phase,[[gapLattElem,E0,ETL],...]]
		# E0 and ETL are parameters for all RF gaps
		self.cav_wrappers_param_dict = {}
		cav_wrappers = self.scl_long_tuneup_controller.cav_wrappers
		self.cav_amp_phase_dict = {}
		for cav_wrapper in cav_wrappers:
			amp = cav_wrapper.cav.getDfltCavAmp()
			phase = cav_wrapper.cav.getDfltCavPhase()
			self.cav_amp_phase_dict[cav_wrapper] = (amp,phase)
		#------ Make rf gap arrays for each cavity. 
		#------ The elements are IdealRfGap instances not AcceleratorNode. 
		#------ self.cavToGapsDict has {cav_name:[irfGaps]}
		rfGaps = self.scl_accSeq.getAllNodesWithQualifier(AndTypeQualifier().and((OrTypeQualifier()).or(RfGap.s_strType)))	
		self.cavToGapsDict = {}		
		for cav_wrapper in cav_wrappers:
			self.cavToGapsDict[cav_wrapper] = []
			for rfGap in rfGaps:
				if(rfGap.getId().find(cav_wrapper.cav.getId()) >= 0):
					irfGaps = self.scenario.elementsMappedTo(rfGap)
					self.cavToGapsDict[cav_wrapper].append(irfGaps[0])				
		#self.scenario.setModelInput(self.gap_first,RfGapPropertyAccessor.PROPERTY_PHASE,phase)
		#self.scenario.setModelInput(self.gap_first,RfGapPropertyAccessor.PROPERTY_ETL,val)
		#self.scenario.setModelInput(self.gap_first,RfGapPropertyAccessor.PROPERTY_E0,val)
		#self.scenario.setModelInput(quad,ElectromagnetPropertyAccessor,PROPERTY_FIELD,val)		
		#----------------------------------------------------------------
		self.scan_gd = BasicGraphData()
		self.harmonicsAnalyzer = HarmonicsAnalyzer(2)
		self.eKin_in = 185.6
		self.cav_amp = 14.0
		self.cav_phase_shift = 0.
		#------------------------
		self.active_cav_wrapper = null
		self.solver = null
Пример #9
0
	def __init__(self,main_loop_controller):
		self.main_loop_controller = main_loop_controller
		cav_wrappers = self.main_loop_controller.cav_wrappers	
		self.accSeq = self.main_loop_controller.accSeq
		self.env_tracker = AlgorithmFactory.createEnvTrackerAdapt(self.accSeq)
		self.env_tracker.setRfGapPhaseCalculation(true)
		self.env_probe = ProbeFactory.getEnvelopeProbe(self.accSeq,self.env_tracker)
		self.scenario = Scenario.newScenarioFor(self.accSeq)
		self.scenario.setSynchronizationMode(Scenario.SYNC_MODE_DESIGN)
		self.scenario.resync()
		self.scenario.setProbe(self.env_probe)	
		self.scenario.run()	
		#-------------------------------------------------	
		for cav_wrapper_ind in range(len(cav_wrappers)):
			cav_wrapper = cav_wrappers[cav_wrapper_ind]
			gap_list = cav_wrapper.cav.getGapsAsList()
			gap_first = gap_list.get(0)
			gap_last = gap_list.get(gap_list.size()-1)
			ind0 = self.scenario.getTrajectory().indicesForElement(gap_first.getId())[0] - 1
			ind1 = self.scenario.getTrajectory().indicesForElement(gap_last.getId())[0]
			state_in = self.scenario.getTrajectory().stateWithIndex(ind0)
			state_out = self.scenario.getTrajectory().stateWithIndex(ind1)
			Ekin_in = state_in.getKineticEnergy()/1.0e+6
			Ekin_out = state_out.getKineticEnergy()/1.0e+6
			twiss_in = state_in.twissParameters()[2]
			twiss_out = state_out.twissParameters()[2]
			z_prim_in = math.sqrt(twiss_in.getGamma()*twiss_in.getEmittance())
			z_prim_out = math.sqrt(twiss_out.getGamma()*twiss_out.getEmittance())
			beta_gamma_in = state_in.getBeta()*state_in.getGamma()
			beta_gamma_out = state_out.getBeta()*state_out.getGamma()
			mass = state_in.getSpeciesRestEnergy()/1.0e+6
			delta_Ekin_in = (mass+Ekin_in)*beta_gamma_in**2*z_prim_in
			delta_Ekin_out = (mass+Ekin_out)*beta_gamma_out**2*z_prim_out
			cav_wrapper.Ekin_in = Ekin_in            
			cav_wrapper.Ekin_out = Ekin_out
			cav_wrapper.Ekin_in_design = Ekin_in
			cav_wrapper.Ekin_in_delta_design = delta_Ekin_in
			cav_wrapper.Ekin_out_design = Ekin_out
			cav_wrapper.Ekin_out_delta_design = delta_Ekin_out 
		for cav_wrapper_ind in range(len(cav_wrappers)-1):
			cav_wrappers[cav_wrapper_ind].Ekin_out_delta_design = cav_wrappers[cav_wrapper_ind+1].Ekin_in_delta_design
Пример #10
0
	def __init__(self,quad_cav_dict,linac_wizard_document):
		self.quad_cav_dict = quad_cav_dict
		self.linac_wizard_document = linac_wizard_document
		self.isOn = true
		self.size_hor_record_arr = []
		self.size_ver_record_arr = []
		self.isSelected_ = false
		#----------- graph data 
		self.gd_exp_hor =  BasicGraphData()
		self.gd_exp_ver =  BasicGraphData()
		self.gd_exp_hor.setDrawLinesOn(false)
		self.gd_exp_ver.setDrawLinesOn(false)
		self.gd_exp_hor.setGraphPointSize(11)
		self.gd_exp_ver.setGraphPointSize(11)
		self.gd_exp_hor.setGraphColor(Color.BLUE)
		self.gd_exp_ver.setGraphColor(Color.BLUE)
		self.gd_model_hor =  BasicGraphData()
		self.gd_model_ver =  BasicGraphData()
		self.gd_model_lon =  BasicGraphData()
		self.gd_model_hor.setGraphColor(Color.RED)
		self.gd_model_ver.setGraphColor(Color.RED)
		self.gd_model_lon.setGraphColor(Color.RED)
		self.gd_model_hor.setLineThick(3)
		self.gd_model_ver.setLineThick(3)
		self.gd_model_lon.setLineThick(4)
		self.gd_model_hor.setDrawPointsOn(false)
		self.gd_model_ver.setDrawPointsOn(false)
		self.gd_exp_hor.setGraphProperty(GRAPH_LEGEND_KEY,"LW/WS sizes")
		self.gd_exp_ver.setGraphProperty(GRAPH_LEGEND_KEY,"LW/WS sizes")
		self.gd_model_hor.setGraphProperty(GRAPH_LEGEND_KEY,"Model Hor. Size")
		self.gd_model_ver.setGraphProperty(GRAPH_LEGEND_KEY,"Model Ver. Size")
		self.gd_model_lon.setGraphProperty(GRAPH_LEGEND_KEY,"Model Longitudinal Size")
		#------ accelerator model set up
		accSeq = self.linac_wizard_document.getAccSeq()
		quads = self.linac_wizard_document.ws_lw_controller.quads
		cavs = self.linac_wizard_document.ws_lw_controller.cavs
		#--memorize the initial values
		self.quad_field_arr = []
		for quad in quads:
			self.quad_field_arr.append([quad,quad.getDfltField()])
		self.cav_amp_phase_arr = []
		for cav in cavs:
			self.cav_amp_phase_arr.append([cav,cav.getDfltCavAmp(),cav.getDfltCavPhase()])
		#-- set up values from dictionaries
		[quad_dict,cav_amp_phase_dict] = self.quad_cav_dict
		for quad in quads:
			if(quad_dict.has_key(quad)):
				quad.setDfltField(quad_dict[quad])
		for cav in cavs:
			if(cav_amp_phase_dict.has_key(cav)):
				cav.updateDesignAmp(cav_amp_phase_dict[cav][0])
				cav.updateDesignPhase(cav_amp_phase_dict[cav][1])
		self.env_tracker = AlgorithmFactory.createEnvTrackerAdapt(accSeq)
		self.env_tracker.setRfGapPhaseCalculation(true)
		self.env_tracker.setUseSpacecharge(true)
		self.design_probe = ProbeFactory.getEnvelopeProbe(accSeq,self.env_tracker)
		probe = EnvelopeProbe(self.design_probe)
		self.scenario = Scenario.newScenarioFor(accSeq)
		self.scenario.setProbe(probe)
		self.scenario.setSynchronizationMode(Scenario.SYNC_MODE_DESIGN)
		self.scenario.resync()
		self.scenario.run()
		self.traj = self.scenario.getTrajectory()
		#---restore the quads and cav parameters
		for [quad,field] in self.quad_field_arr:
			quad.setDfltField(field)
		for [cav,amp,phase] in self.cav_amp_phase_arr:
			cav.updateDesignAmp(amp)
			cav.updateDesignPhase(phase)
Пример #11
0
bpms = accSeq.getAllNodesOfType("BPM")
bpm_names_dict = {}
for bpm in bpms:
    bpm_names_dict[bpm.getId()] = bpm
    #print "debug bpm=",bpm.getId()," pos[m]=",accSeq.getPosition(bpm)," freq.=",bpm.getBPMBucket().getFrequency()

#---- array of all 1st RF gaps
rf_gaps = []
for cav in cavs:
    rf_gaps.append(cav.getGaps()[0])

#----- New Online Model for the acc. sequence
scenario = Scenario.newScenarioFor(accSeq)
scenario.setSynchronizationMode(Scenario.SYNC_MODE_DESIGN)

particle_tracker = AlgorithmFactory.createParticleTracker(accSeq)
particle_tracker.setRfGapPhaseCalculation(True)
probe = ProbeFactory.createParticleProbe(accSeq, particle_tracker)

scenario.resync()
scenario.setProbe(probe)
scenario.run()

traj = scenario.getProbe().getTrajectory()

#----- bpm_phases_init_arr = [[bpm,position,phase],...]
bpm_phases_init_arr = []
for state_ind in range(traj.numStates()):
    state = traj.stateWithIndex(state_ind)
    if (state.getElementId().find("BPM") >= 0):
        bpm = bpm_names_dict[state.getElementId()]
Пример #12
0
wss = accSeq.getAllNodesOfType(ProfileMonitor.s_strType)
for ws in wss:
    print "ws=", ws.getId(), " pos=", accSeq.getPosition(ws)

print "==========================="

quads = accSeq.getAllNodesOfType(Quadrupole.s_strType)
for quad in quads:
    print "quad=", quad.getId(), " B=", quad.getDfltField()

print "==========================="

scenario = Scenario.newScenarioFor(accSeq)
scenario.setSynchronizationMode(Scenario.SYNC_MODE_DESIGN)

tracker = AlgorithmFactory.createEnvTrackerAdapt(accSeq)
tracker.setProbeUpdatePolicy(tracker.UPDATE_ALWAYS)

probe = ProbeFactory.getEnvelopeProbe(accSeq, tracker)
#---- peak current in [A]
peak_current = 0.000
probe.setBeamCurrent(peak_current)

#---- initial kinetic energy in [MeV]
eKin_init = probe.getKineticEnergy() / 1.0e+6

scenario.setProbe(probe)
scenario.resync()
scenario.run()

traj = scenario.getProbe().getTrajectory()