python同步加速器波动器计算
pySRU的Python项目详细描述
警告:项目正在开发中!!
python中的同步辐射波动器发射
主要开发网站:https://github.com/SophieTh/und_Sophie_2016
计算储存环中波动器辐射的工具箱。
这个软件库实现了计算储存环中波动器辐射发射的公式,等等 一般来说,相对论性电子在任意磁场中的发射。
该软件是用纯python编写的,使用标准包numpy和scipy。它对绘图使用matplotlib,但计算时不需要它。
许可证
此代码在麻省理工学院的许可证下转发,详见许可证文件。
安装
要构建供python使用的库,只需使用python setup.py install方法。
示例
文件simulations.py包含许多仿真。例如,下面的代码创建了波动器的发射,如x射线数据手册(http://xdb.lbl.gov/Section2/Sec_2-1.html)中的图2.5所示
这段python代码展示了如何通过其python绑定使用库。
frompySRU.ElectronBeamimportElectronBeamfrompySRU.MagneticStructureUndulatorPlaneimportMagneticStructureUndulatorPlaneasUndulatorfrompySRU.Simulationimportcreate_simulationfrompySRU.TrajectoryFactoryimportTRAJECTORY_METHOD_ANALYTIC,TRAJECTORY_METHOD_ODEfrompySRU.RadiationFactoryimportRADIATION_METHOD_NEAR_FIELD,RADIATION_METHOD_APPROX_FARFIELDprint("======================================================================")print("====== Undulator from X-ray data booklet =======")print("====== fig 2.5 in http://xdb.lbl.gov/Section2/Sec_2-1.html =======")print("======================================================================")# note that the flux in the reference fig 2.6 is a factor 10 smaller than the calculated here.# This factor comes from the units:# here: phot / s / A / 0.1%bw / (mrad)^2# ref : phot / s / A / 1%bw / (0.1 mrad)^2undulator_test=Undulator(K=1.87,period_length=0.035,length=0.035*14)electron_beam_test=ElectronBeam(Electron_energy=1.3,I_current=1.0)simulation_test=create_simulation(magnetic_structure=undulator_test,electron_beam=electron_beam_test,magnetic_field=None,photon_energy=None,traj_method=TRAJECTORY_METHOD_ANALYTIC,Nb_pts_trajectory=None,rad_method=RADIATION_METHOD_APPROX_FARFIELD,Nb_pts_radiation=101,initial_condition=None,distance=None,XY_are_list=False,X=None,Y=None)simulation_test.print_parameters()simulation_test.trajectory.plot_3D(title="Electron Trajectory")simulation_test.radiation.plot(title="Flux in far field vs angle")
结果链接:https://github.com/SophieTh/und_Sophie_2016/blob/master/doc/radiation_xraybooklet.jpeg