ocelot.adaptors.genesis¶
interface to genesis
Module Contents¶
Classes¶
Genesis input files storage object |
|
Genesis output *.out files storage object |
|
Genesis statistical output storage object |
|
Genesis particle *.dpa files storage object |
|
Genesis electron beam distribution *.dat files storage object |
|
Genesis analytical radiation input files storage object? |
Functions¶
|
|
|
|
|
Main function for executing Genesis code |
|
assembles the fileName.slice* files into fileName |
|
creates the folder structure nested in exp_dir folder. |
|
Create Genesis inp object with default input parameters |
|
Returns MpiLauncher() object for given program |
|
tmp for moga, to be solved in the future |
|
reads Genesis output from *.out file. |
|
reads statistical info of Genesis simulations, |
|
reads statistical info of Genesis simulations, |
|
More compact function than read_dfl_file() to read the file generated with known .out file |
|
Function to read the Genesis output radiation file “dfl”. |
|
Function to write the RadiationField object into filePath file |
|
simplifies running the read_dpa_file() function |
|
reads genesis particle dump file *.dpa |
|
|
|
|
|
Convert dpa to edist objects |
|
|
|
reads particle distribution file (distfile in genesis input) |
|
|
|
cuts GenesisElectronDist() in phase space |
|
adds energy to the electron beam so that new average energy is E_GeV in [GeV] |
|
Introduces dispersion (good for simulating weak chicanes) |
|
dublicates the GenesisElectronDist() by given factor |
|
writes GenesisElectronDist() into filePath folder |
|
reads GenesisElectronDist() |
|
reads beam file from filePath folder |
|
reads BeamArray() |
|
reads BeamArray() |
|
reads BeamArray() |
|
|
|
cuts BeamArray() object longitudinally |
|
obtains values of the beam at s position |
|
obtains values of the beam at s position |
|
find transform from twiss matrix g1 to g2: x -> M x, g -> Mi.T g M |
|
|
|
|
|
reads analyticall radiation seed file from Genesis? |
|
|
|
|
|
|
|
|
|
pulse spectrum in eV |
|
|
|
|
|
|
|
reading astra distribution parameters Parameter x y z px py pz clock macro_charge particle_index status_flag |
|
converts astra particle distribution into GenesisElectronDist() object |
|
|
|
|
|
reads MagneticLattice() |
|
-
ocelot.adaptors.genesis._logger¶
-
ocelot.adaptors.genesis._inputTemplate¶ -
:annotation: = $newrun -
aw0 = __AW0__ -
xkx = __XKX__ -
xky = __XKY__ -
wcoefz = __WCOEFZ__ -
xlamd = __XLAMD__ -
fbess0 = __FBESS0__ -
delaw = __DELAW__ -
iertyp = __IERTYP__ -
iwityp = __IWITYP__ -
awd = __AWD__ -
awx = __AWX__ -
awy = __AWY__ -
iseed = __ISEED__ -
npart = __NPART__ -
gamma0 = __GAMMA0__ -
delgam = __DELGAM__ -
rxbeam = __RXBEAM__ -
rybeam = __RYBEAM__ -
alphax = __ALPHAX__ -
alphay = __ALPHAY__ -
emitx = __EMITX__ -
emity = __EMITY__ -
xbeam = __XBEAM__ -
ybeam = __YBEAM__ -
pxbeam = __PXBEAM__ -
pybeam = __PYBEAM__ -
conditx = __CONDITX__ -
condity = __CONDITY__ -
bunch = __BUNCH__ -
bunchphase = __BUNCHPHASE__ -
emod = __EMOD__ -
emodphase = __EMODPHASE__ -
xlamds = __XLAMDS__ -
prad0 = __PRAD0__ -
zrayl = __ZRAYL__ -
zwaist = __ZWAIST__ -
ncar = __NCAR__ -
lbc = __LBC__ -
rmax0 = __RMAX0__ -
dgrid = __DGRID__ -
nscr = __NSCR__ -
nscz = __NSCZ__ -
nptr = __NPTR__ -
nwig = __NWIG__ -
zsep = __ZSEP__ -
delz = __DELZ__ -
nsec = __NSEC__ -
iorb = __IORB__ -
zstop = __ZSTOP__ -
magin = __MAGIN__ -
magout = __MAGOUT__ -
quadf = __QUADF__ -
quadd = __QUADD__ -
fl = __FL__ -
dl = __DL__ -
drl = __DRL__ -
f1st = __F1ST__ -
qfdx = __QFDX__ -
qfdy = __QFDY__ -
solen = __SOLEN__ -
sl = __SL__ -
ildgam = __ILDGAM__ -
ildpsi = __ILDPSI__ -
ildx = __ILDX__ -
ildy = __ILDY__ -
ildpx = __ILDPX__ -
ildpy = __ILDPY__ -
itgaus = __ITGAUS__ -
nbins = __NBINS__ -
igamgaus = __IGAMGAUS__ -
lout = __LOUT__ -
iphsty = __IPHSTY__ -
ishsty = __ISHSTY__ -
ippart = __IPPART__ -
ispart = __ISPART__ -
ipradi = __IPRADI__ -
isradi = __ISRADI__ -
idump = __IDUMP__ -
iotail = __IOTAIL__ -
nharm = __NHARM__ -
iharmsc = __IHARMSC__ -
iallharm = __IALLHARM__ -
curpeak = __CURPEAK__ -
curlen = __CURLEN__ -
ntail = __NTAIL__ -
nslice = __NSLICE__ -
shotnoise = __SHOTNOISE__ -
isntyp = __ISNTYP__ -
iall = __IALL__ -
ocelot.adaptors.genesis.__ITDP__¶ -
ipseed = __IPSEED__ -
iscan = __ISCAN__ -
nscan = __NSCAN__ -
svar = __SVAR__ -
isravg = __ISRAVG__ -
isrsig = __ISRSIG__ -
cuttail = __CUTTAIL__ -
eloss = __ELOSS__ -
version = __VERSION__ -
ndcut = __NDCUT__ -
idmpfld = __IDMPFLD__ -
idmppar = __IDMPPAR__ -
ilog = __ILOG__ -
ffspec = __FFSPEC__ -
convharm = __CONVHARM__ -
ibfield = __IBFIELD__ -
imagl = __IMAGL__ -
idril = __IDRIL__ -
alignradf = __ALIGNRADF__ -
offsetradf = __OFFSETRADF__ -
multconv = __MULTCONV__ -
trama = __TRAMA__ -
itram11 = __ITRAM11__ -
itram12 = __ITRAM12__ -
itram13 = __ITRAM13__ -
itram14 = __ITRAM14__ -
itram15 = __ITRAM15__ -
itram16 = __ITRAM16__ -
itram21 = __ITRAM21__ -
itram22 = __ITRAM22__ -
itram23 = __ITRAM23__ -
itram24 = __ITRAM24__ -
itram25 = __ITRAM25__ -
itram26 = __ITRAM26__ -
itram31 = __ITRAM31__ -
itram32 = __ITRAM32__ -
itram33 = __ITRAM33__ -
itram34 = __ITRAM34__ -
itram35 = __ITRAM35__ -
itram36 = __ITRAM36__ -
itram41 = __ITRAM41__ -
itram42 = __ITRAM42__ -
itram43 = __ITRAM43__ -
itram44 = __ITRAM44__ -
itram45 = __ITRAM45__ -
itram46 = __ITRAM46__ -
itram51 = __ITRAM51__ -
itram52 = __ITRAM52__ -
itram53 = __ITRAM53__ -
itram54 = __ITRAM54__ -
itram55 = __ITRAM55__ -
itram56 = __ITRAM56__ -
itram61 = __ITRAM61__ -
itram62 = __ITRAM62__ -
itram63 = __ITRAM63__ -
itram64 = __ITRAM64__ -
itram65 = __ITRAM65__ -
itram66 = __ITRAM66__
__OUTPUTFILE__ __BEAMFILE__ __PARTFILE__ __FIELDFILE__ __RADFILE__ __DISTFILE__ __MAGFILE__
filetype =’ORIGINAL’ $end
-
class
ocelot.adaptors.genesis.GenesisInput¶ Genesis input files storage object
-
input(self)¶
-
__getattr__(self, name)¶
-
copy(self, inp, params)¶ copies list of parameters from another GenesisInput() or GenesisOutput() object
-
copymesh(self, inp, expt=())¶
-
-
class
ocelot.adaptors.genesis.GenesisOutput¶ Genesis output *.out files storage object
-
fileName(self)¶
-
__call__(self, name)¶
-
calc_spec(self, mode='mid', npad=0)¶ calculates the on-axis spectrum at every position along the undulator and writes it into “spec” attirube
if mode = “mid” then on-axis power with on-axis phases is used for calculation if mode = “int” then transversely integrated power with on-axis phases is used (strictly speaking inaccurate, but informative) npad (integer) if > 0 pads the power with zeros in order to increase resolution of spectrum.
-
phase_fix(self, wav=None, s=None, **kwargs)¶ the way to display the phase, without constant slope caused by different radiation wavelength from xlamds. phase is set to 0 at maximum power slice
-
calc_radsize(self, weigh_transv=1)¶ weigh_transv = True to average the transverse radiation size over slices with radiation power as a weight
-
wig(self, z=np.inf, *args, **kwargs)¶
-
re_read(self, read_level=2)¶
-
-
class
ocelot.adaptors.genesis.GenStatOutput¶ Genesis statistical output storage object
-
zi(self, z)¶
-
si(self, s)¶
-
fi(self, f)¶
-
-
class
ocelot.adaptors.genesis.GenesisParticlesDump¶ Genesis particle *.dpa files storage object Each particle record in z starts with the energy of all particles followed by the output of the particle phases, positions in x and y and the momenta in x and y. The momenta are normalized to mc
-
fileName(self)¶
-
-
class
ocelot.adaptors.genesis.GenesisElectronDist¶ Genesis electron beam distribution *.dat files storage object GENESIS follows the rule that the longitudinal position is reversed if a time is specified by the T column. In this case smaller numbers correspond to particle in the tail of the distribution.
-
charge(self)¶
-
fileName(self)¶
-
len(self)¶
-
center(self, s='com')¶
-
property
s(self)¶
-
twiss(self)¶
-
-
ocelot.adaptors.genesis.parray2edist(p_array)¶
-
ocelot.adaptors.genesis.edist2parray(edist)¶
-
class
ocelot.adaptors.genesis.GenesisRad¶ Genesis analytical radiation input files storage object?
-
ocelot.adaptors.genesis.run_genesis(inp, launcher, read_level=2, assembly_ver='pyt', dfl_slipage_incl=True, min_phsh=False, debug=1)¶ Main function for executing Genesis code inp - GenesisInput() object with genesis input parameters launcher - MpiLauncher() object obtained via get_genesis_launcher() function read_level - Parameter to read and calculate values from the output:
- -1 - do not read
0 - read input only (header) 1 - read input and current profile 2 - read all values
dfl_slipage_incl - whether to dedicate time in order to keep the dfl slices, slipped out of the simulation window. if zero, reduces assembly time by ~30% assembly_ver - version of the assembly script: ‘sys’ - system based, ‘pyt’ - python based, None - assembly with Genesis assumed
-
ocelot.adaptors.genesis.assemble(fileName, remove=1, overwrite=0, ram=1, debug=1)¶ assembles the fileName.slice* files into fileName remove - delete .slice files overwrite - writes .slice files on top of fileName.slice* starting from the beginning. Applicable for genesis dfl file assembly ram - store the .slice files in ram simultaneously
-
ocelot.adaptors.genesis.create_exp_dir(exp_dir, run_ids)¶ creates the folder structure nested in exp_dir folder. run_ids is a list of run numbers. resulting folder structure would be .. —exp_dir ——run_1 ——run_2 ——run_3 ——…
-
ocelot.adaptors.genesis.generate_input(undulator, beam, E_photon=None, itdp=True, *args, **kwargs)¶ Create Genesis inp object with default input parameters
-
ocelot.adaptors.genesis.get_genesis_launcher(launcher_program=None, launcher_argument='')¶ Returns MpiLauncher() object for given program
-
ocelot.adaptors.genesis.get_genesis_new_launcher(launcher_program=None, mpi_mode=True)¶ tmp for moga, to be solved in the future
-
ocelot.adaptors.genesis.read_out_file(filePath, read_level=2, precision=float, debug=1)¶ reads Genesis output from *.out file. returns GenesisOutput() object thanks gods Genesis3 out will be in hdf5!
- read_level - 0 = only header is processed. Very fast
1 = slice values are not processed. Current information is obtained, ~2x faster 2 = all contents are read 3 = additional attributed are calculated, like spectrum, transversely averaged radiation size, etc.
precision - precision of stored values precision debug - 0 = no messages printed in console
1 = basic info and execution time is printed 2 = most detailed info is printed (real debug)
-
ocelot.adaptors.genesis.read_out_file_stat(proj_dir, stage, run_inp=[], param_inp=[], debug=1)¶ reads statistical info of Genesis simulations, returns GenStatOutput() object
proj_dir - project directory of the following structure: proj_dir/run_<run_number>/run.<run_number>.s<stage_number>.gout* run_inp - list of genesis runs to be looked for [0:1000] by default param_inp - list of genesis output parameters to be processed debug - see read_out_file()
-
ocelot.adaptors.genesis.read_out_file_stat_u(file_tamplate, run_inp=[], param_inp=[], debug=1)¶ reads statistical info of Genesis simulations, universal function for non-standard exp. folder structure returns GenStatOutput() object
file_tamplate = template of the .out file path with # denoting run number run_inp - list of genesis runs to be looked for [0:1000] by default param_inp - list of genesis output parameters to be processed debug - see read_out_file()
-
ocelot.adaptors.genesis.read_dfl_file_out(out, filePath=None, debug=1)¶ More compact function than read_dfl_file() to read the file generated with known .out file Returns RadiationField object No need to pass all parameters (Nxy, Lxy, Lz, zsep, xlamds), they are read from GenesisOutput object out - The relevant GenesisOutput object or path to it filePath- Path to *.dfl file.
if = None, then it is assumed to be *.out.dfl
-
ocelot.adaptors.genesis.read_dfl_file(filePath, Nxy, Lxy=None, zsep=None, xlamds=None, hist_rec=1, vartype=complex, debug=1)¶ Function to read the Genesis output radiation file “dfl”. Returns RadiationField() object filePath - path to .dfl file Nxy - transverse mesh size, e.g. for 151*151 mesh, Nxy=151 Lxy - transverse mesh size (2*dgrid) zsep - separation between slices in terms of wavelengths xlamds - wavelength of the radiation hist_rec - number of dfl records within a single file (.fld case), not finished!
-
ocelot.adaptors.genesis.write_dfl_file(dfl, filePath=None, debug=1)¶ Function to write the RadiationField object into filePath file dfl RadiationField object filePath - path top write the file
if None then filePath = dfl.filePath
-
ocelot.adaptors.genesis.read_dpa_file_out(out, filePath=None, debug=1)¶ simplifies running the read_dpa_file() function reads GenesisOutput() object returns GenesisParticlesDump() object no need to set nbins and npart parameters as well as file_path (may be overrun) all automatically picked up from GenesisOutput() object
-
ocelot.adaptors.genesis.read_dpa_file(filePath, nbins=4, npart=None, debug=1)¶ reads genesis particle dump file *.dpa returns GenesisParticlesDump() object
-
ocelot.adaptors.genesis.write_dpa_file(dpa, filePath=None, debug=1)¶
-
ocelot.adaptors.genesis.max_dpa_dens(out, dpa, slice_pos=None, slice_num=None, repeat=1, bins=50, 50, debug=1)¶
-
ocelot.adaptors.genesis.dpa2edist(out, dpa, num_part=100000.0, smear=1, debug=1)¶ Convert dpa to edist objects reads GenesisParticlesDump() object returns GenesisElectronDist() object num_part - desired approximate number of particles in edist smear - whether to shuffle macroparticles smearing microbunching
-
ocelot.adaptors.genesis.read_edist_file_out(out, debug=1)¶
-
ocelot.adaptors.genesis.read_edist_file(filePath, **kwargs)¶ reads particle distribution file (distfile in genesis input) returns GenesisElectronDist()
-
ocelot.adaptors.genesis.cut_edist_std(edist, all_std=None, x_std=4, y_std=4, xp_std=4, yp_std=4)¶
-
ocelot.adaptors.genesis.cut_edist(edist, t_lim=- np.inf, np.inf, g_lim=- np.inf, np.inf, x_lim=- np.inf, np.inf, xp_lim=- np.inf, np.inf, y_lim=- np.inf, np.inf, yp_lim=- np.inf, np.inf, s_lim=None, debug=1)¶ cuts GenesisElectronDist() in phase space
-
ocelot.adaptors.genesis.set_edist_energy(edist, E_GeV, debug=1)¶ adds energy to the electron beam so that new average energy is E_GeV in [GeV]
-
ocelot.adaptors.genesis.disperse_edist(edist, R56, debug=1)¶ Introduces dispersion (good for simulating weak chicanes) delays or advances time coordinate of the particles depending on ther energy with respect to the averaged energy
-
ocelot.adaptors.genesis.repeat_edist(edist, repeats, smear=0.001, not_smear=[])¶ dublicates the GenesisElectronDist() by given factor repeats - the number of repetitions smear - smear new particles by x of global standard deviation of parameter
-
ocelot.adaptors.genesis.write_edist_file(edist, filePath=None, debug=1)¶ writes GenesisElectronDist() into filePath folder
-
ocelot.adaptors.genesis.edist2beam(edist, step=2e-07)¶ reads GenesisElectronDist() returns BeamArray() step [m] - long. size ob bin to calculate distribution parameters
-
ocelot.adaptors.genesis.read_beam_file(filePath, *args, **kwargs)¶ reads beam file from filePath folder returns BeamArray()
-
ocelot.adaptors.genesis.beam_file_str(beam)¶ reads BeamArray() returns string of electron beam file, suitable for Genesis
-
ocelot.adaptors.genesis.zero_wake_at_ipk(beam)¶ reads BeamArray() shifts the wake pforile so that at maximum current slice wake is zero returns GenesisBeam()
allows to account for wake losses without additional linear undulator tapering
-
ocelot.adaptors.genesis.set_beam_energy(beam, E_GeV_new)¶ reads BeamArray() returns BeamArray() sets the beam energy with peak current to E_GeV_new
-
ocelot.adaptors.genesis.transform_beam_twiss(beam, transform=None, s=None)¶
-
ocelot.adaptors.genesis.cut_beam(beam=None, cut_s=[- np.inf, np.inf])¶ cuts BeamArray() object longitudinally cut_z [m] - limits of the cut
-
ocelot.adaptors.genesis.get_beam_s(beam, s=0)¶ obtains values of the beam at s position
-
ocelot.adaptors.genesis.get_beam_peak(beam)¶ obtains values of the beam at s position
-
ocelot.adaptors.genesis.find_transform(g1, g2)¶ find transform from twiss matrix g1 to g2: x -> M x, g -> Mi.T g M
-
ocelot.adaptors.genesis.write_beam_file(filePath, beam, debug=0)¶
-
ocelot.adaptors.genesis.create_rad_file(p_duration_s=None, p_intensity=None, beam=None, offset=None, out_file='tmp.rad')¶
-
ocelot.adaptors.genesis.read_rad_file(filePath)¶ reads analyticall radiation seed file from Genesis?
-
ocelot.adaptors.genesis.adapt_rad_file(beam=None, rad_file=None, out_file='tmp.rad')¶
-
ocelot.adaptors.genesis.rad_file_str(rad)¶
-
ocelot.adaptors.genesis.generate_lattice(lattice, unit=1.0, energy=None, debug=1, min_phsh=False)¶
-
ocelot.adaptors.genesis.next_run_id(dir='.')¶
-
ocelot.adaptors.genesis.get_spectrum(power, phase, smax=1.0)¶ pulse spectrum in eV
-
ocelot.adaptors.genesis.get_power_exit(g)¶
-
ocelot.adaptors.genesis.get_power_z(g)¶
-
ocelot.adaptors.genesis.transform_beam_file(beam_file=None, out_file='tmp.beam', s=None, transform=[[25.0, 0.1], [21.0, - 0.1]], energy_scale=1, energy_new=None, emit_scale=1, n_interp=None)¶
-
ocelot.adaptors.genesis.test_beam_transform(beta1=10.0, alpha1=- 0.1, beta2=20, alpha2=2.2)¶
-
ocelot.adaptors.genesis.read_astra_dist(fileName)¶ reading astra distribution parameters Parameter x y z px py pz clock macro_charge particle_index status_flag with units m m m eV/c eV/c eV/c ns nC returns numpy array?
-
ocelot.adaptors.genesis.astra2edist(adist, center=1)¶ converts astra particle distribution into GenesisElectronDist() object center - centers the distribution transversely
-
ocelot.adaptors.genesis.astra2edist_ext(fileName_in, fileName_out='', center=1)¶
-
ocelot.adaptors.genesis.rematch_edist(edist, tws, s=None)¶
-
ocelot.adaptors.genesis.cut_lattice(lat, n_cells, elem_in_cell=4)¶ reads MagneticLattice() returns MagneticLattice() without first n_cells*elem_in_cell elements
-
ocelot.adaptors.genesis.getAverageUndulatorParameter(lattice, unit=1.0, energy=17.5)¶