Genesis4 Basic Example¶
This will show the basic usage of LUME-Genesis.
import matplotlib.pyplot as plt
import numpy as np
import genesis
from genesis.version4 import Genesis4, Track, Write
%config InlineBackend.figure_format = 'retina'
Setup¶
Instantiate the object on a value init file. This will configure a working directory that stages all input and output files.
G = Genesis4("data/basic4/cu_hxr.in", "data/basic4/hxr.lat", verbose=True)
Here is what the main input ("cu_hxr.in") looks like in Python:
G.input.main
MainInput( namelists=[ Setup( rootname='LCLS2_HXR_9keV', lattice='hxr.lat', beamline='HXR', gamma0=19174.0776, lambda0=1.3789244869952112e-10, delz=0.026, seed=84672, npart=1024, ), Time(slen=1.5e-05, sample=200), Field(dgrid=0.0001, ngrid=101, accumulate=True), ProfileFile( label='beamcurrent', xdata='beam_current.h5/s', ydata='beam_current.h5/current', ), ProfileFile(label='beamgamma', xdata='beam_gamma.h5/s', ydata='beam_gamma.h5/gamma'), Beam( gamma='@beamgamma', delgam=3.97848, current='@beamcurrent', ex=4e-07, ey=4e-07, betax=7.910909406464387, betay=16.881178621346898, alphax=-0.7393217413918415, alphay=1.3870723536888105, ), Track(zstop=10.0), ], filename=pathlib.Path('/home/runner/work/lume-genesis/lume-genesis/docs/examples/genesis4/data/basic4/cu_hxr.in'), )
Inspect the main input by filtering the namelists by their type:
G.input.main.tracks
[Track(zstop=10.0)]
There is also a dictionary mapping you can use to see all types by using their type class directly:
G.input.main.by_namelist[Track]
[Track(zstop=10.0)]
We can use this to modify the z-stop for all track instances:
for track in G.input.main.tracks:
track.zstop = 12
If there is only one instance of a namelist ite, it can be accessed more simply:
G.input.main.track.zstop = 12
You can view the data as a convenient table, too, when looking at a single namelist:
G.input.main.tracks[0].to_table()
Attribute | Value | Type | Description |
---|---|---|---|
type | track | str | |
zstop | 12.0 | float | If `zstop` is shorter than the lattice length the tracking stops at the specified position. |
output_step | 1 | int | Defines the number of integration steps before the particle and field distribution is analyzed for output. |
field_dump_step | 0 | int | Defines the number of integration steps before a field dump is written. Be careful because for time-dependent simulation it can generate many large output files. |
beam_dump_step | 0 | int | Defines the number of integration steps before a particle dump is written. Be careful because for time-dependent simulation it can generate many large output files. |
sort_step | 0 | int | Defines the number of steps of integration before the particle distribution is sorted. Works only for one-4-one simulations. |
s0 | 0.0 | float | Option to override the default time window start from the TIME module. |
slen | 0.0 | float | Option to override the default time window length from the TIME module. |
field_dump_at_undexit | False | bool | Field dumps at the exit of the undulator (one dump for each undulator in the expanded lattice). |
bunchharm | 1 | int | Bunching harmonic output setting. Must be >= 1. |
# Add writing a field file
G.input.main.namelists.append(Write(field="end"))
# Add writing a beam (particle) file
G.input.main.namelists.append(Write(beam="end"))
Let's look at the lattice input format that Genesis will see:
print(G.input.lattice.to_genesis())
QHXH17: quadrupole = {l=0.101, k1=1.78}; QHXH18: quadrupole = {l=0.101, k1=-1.78}; QHXH19: quadrupole = {l=0.101, k1=1.78}; QHXH20: quadrupole = {l=0.101, k1=-1.78}; QHXH21: quadrupole = {l=0.101, k1=1.78}; QHXH22: quadrupole = {l=0.101, k1=-1.78}; QHXH23: quadrupole = {l=0.101, k1=1.78}; QHXH24: quadrupole = {l=0.101, k1=-1.78}; QHXH25: quadrupole = {l=0.101, k1=1.78}; QHXH26: quadrupole = {l=0.101, k1=-1.78}; QHXH27: quadrupole = {l=0.101, k1=1.78}; QHXH28: quadrupole = {l=0.101, k1=-1.78}; QHXH29: quadrupole = {l=0.101, k1=1.78}; QHXH30: quadrupole = {l=0.101, k1=-1.78}; QHXH31: quadrupole = {l=0.101, k1=1.78}; QHXH32: quadrupole = {l=0.101, k1=-1.78}; QHXH33: quadrupole = {l=0.101, k1=1.78}; QHXH34: quadrupole = {l=0.101, k1=-1.78}; QHXH35: quadrupole = {l=0.101, k1=1.78}; QHXH36: quadrupole = {l=0.101, k1=-1.78}; QHXH37: quadrupole = {l=0.101, k1=1.78}; QHXH38: quadrupole = {l=0.101, k1=-1.78}; QHXH39: quadrupole = {l=0.101, k1=1.78}; QHXH40: quadrupole = {l=0.101, k1=-1.78}; QHXH41: quadrupole = {l=0.101, k1=1.78}; QHXH42: quadrupole = {l=0.101, k1=-1.78}; QHXH43: quadrupole = {l=0.101, k1=1.78}; QHXH44: quadrupole = {l=0.101, k1=-1.78}; QHXH45: quadrupole = {l=0.101, k1=1.78}; QHXH46: quadrupole = {l=0.101, k1=-1.78}; QHXH47: quadrupole = {l=0.101, k1=1.78}; QHXH48: quadrupole = {l=0.101, k1=-1.78}; QHXH49: quadrupole = {l=0.101, k1=1.78}; QHXH50: quadrupole = {l=0.101, k1=-1.78}; UMAHXH17: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH18: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH19: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH20: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH21: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH22: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH23: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH25: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH26: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH27: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH28: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH29: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH30: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH31: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH33: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH34: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH35: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH36: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH37: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH38: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH39: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH40: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH41: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH42: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH43: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH44: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH45: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH46: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH47: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH48: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH49: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; UMAHXH50: undulator = {aw=1.7017, lambdau=0.026, nwig=130}; CORR00: corrector = {l=0.001}; CORR01: corrector = {l=0.001}; CORR02: corrector = {l=0.001}; CORR03: corrector = {l=0.001}; CORR04: corrector = {l=0.001}; CORR05: corrector = {l=0.001}; CORR06: corrector = {l=0.001}; CORR07: corrector = {l=0.001}; CORR08: corrector = {l=0.001}; CORR09: corrector = {l=0.001}; CORR10: corrector = {l=0.001}; CORR11: corrector = {l=0.001}; CORR12: corrector = {l=0.001}; CORR13: corrector = {l=0.001}; CORR14: corrector = {l=0.001}; CORR15: corrector = {l=0.001}; CORR16: corrector = {l=0.001}; CORR17: corrector = {l=0.001}; CORR18: corrector = {l=0.001}; CORR19: corrector = {l=0.001}; CORR20: corrector = {l=0.001}; CORR21: corrector = {l=0.001}; CORR22: corrector = {l=0.001}; CORR23: corrector = {l=0.001}; CORR24: corrector = {l=0.001}; CORR25: corrector = {l=0.001}; CORR26: corrector = {l=0.001}; CORR27: corrector = {l=0.001}; CORR28: corrector = {l=0.001}; CORR29: corrector = {l=0.001}; CORR30: corrector = {l=0.001}; CORR31: corrector = {l=0.001}; CORR32: corrector = {l=0.001}; CORR33: corrector = {l=0.001}; D1: drift = {l=0.1335}; D2: drift = {l=0.4615}; D3: drift = {l=0.328}; D4: drift = {l=3.4}; HXRSS: chicane = {l=4.55, lb=0.1}; HXR: LINE = {D1, UMAHXH17, D2, QHXH17, CORR00, D3, D1, UMAHXH18, D2, QHXH18, CORR01, D3, D1, UMAHXH19, D2, QHXH19, CORR02, D3, D1, UMAHXH20, D2, QHXH20, CORR03, D3, D1, UMAHXH21, D2, QHXH21, CORR04, D3, D1, UMAHXH22, D2, QHXH22, CORR05, D3, D1, UMAHXH23, D2, QHXH23, CORR06, D3, D1, HXRSS, D2, QHXH24, CORR07, D3, D1, UMAHXH25, D2, QHXH25, CORR08, D3, D1, UMAHXH26, D2, QHXH26, CORR09, D3, D1, UMAHXH27, D2, QHXH27, CORR10, D3, D1, UMAHXH28, D2, QHXH28, CORR11, D3, D1, UMAHXH29, D2, QHXH29, CORR12, D3, D1, UMAHXH30, D2, QHXH30, CORR13, D3, D1, UMAHXH31, D2, QHXH31, CORR14, D3, D1, D4, D2, QHXH32, CORR15, D3, D1, UMAHXH33, D2, QHXH33, CORR16, D3, D1, UMAHXH34, D2, QHXH34, CORR17, D3, D1, UMAHXH35, D2, QHXH35, CORR18, D3, D1, UMAHXH36, D2, QHXH36, CORR19, D3, D1, UMAHXH37, D2, QHXH37, CORR20, D3, D1, UMAHXH38, D2, QHXH38, CORR21, D3, D1, UMAHXH39, D2, QHXH39, CORR22, D3, D1, UMAHXH40, D2, QHXH40, CORR23, D3, D1, UMAHXH41, D2, QHXH41, CORR24, D3, D1, UMAHXH42, D2, QHXH42, CORR25, D3, D1, UMAHXH43, D2, QHXH43, CORR26, D3, D1, UMAHXH44, D2, QHXH44, CORR27, D3, D1, UMAHXH45, D2, QHXH45, CORR28, D3, D1, UMAHXH46, D2, QHXH46, CORR29, D3, D1, UMAHXH47, D2, QHXH47, CORR30, D3, D1, UMAHXH48, D2, QHXH48, CORR31, D3, D1, UMAHXH49, D2, QHXH49, CORR32, D3, D1, UMAHXH50, D2, QHXH50, CORR33, D3}; LCLS2_HXR_U1: LINE = {D1, UMAHXH17, D2, QHXH17, CORR00, D3, D1, UMAHXH18, D2, QHXH18, CORR01, D3, D1, UMAHXH19, D2, QHXH19, CORR02, D3, D1, UMAHXH20, D2, QHXH20, CORR03, D3, D1, UMAHXH21, D2, QHXH21, CORR04, D3, D1, UMAHXH22, D2, QHXH22, CORR05, D3, D1, UMAHXH23, D2, QHXH23, CORR06, D3}; LCLS2_HXR_U2: LINE = {D1, UMAHXH25, D2, QHXH25, CORR08, D3, D1, UMAHXH26, D2, QHXH26, CORR09, D3, D1, UMAHXH27, D2, QHXH27, CORR10, D3, D1, UMAHXH28, D2, QHXH28, CORR11, D3, D1, UMAHXH29, D2, QHXH29, CORR12, D3, D1, UMAHXH30, D2, QHXH30, CORR13, D3, D1, UMAHXH31, D2, QHXH31, CORR14, D3, D1, D4, D2, QHXH32, CORR15, D3, D1, UMAHXH33, D2, QHXH33, CORR16, D3, D1, UMAHXH34, D2, QHXH34, CORR17, D3, D1, UMAHXH35, D2, QHXH35, CORR18, D3, D1, UMAHXH36, D2, QHXH36, CORR19, D3, D1, UMAHXH37, D2, QHXH37, CORR20, D3, D1, UMAHXH38, D2, QHXH38, CORR21, D3, D1, UMAHXH39, D2, QHXH39, CORR22, D3, D1, UMAHXH40, D2, QHXH40, CORR23, D3, D1, UMAHXH41, D2, QHXH41, CORR24, D3, D1, UMAHXH42, D2, QHXH42, CORR25, D3, D1, UMAHXH43, D2, QHXH43, CORR26, D3, D1, UMAHXH44, D2, QHXH44, CORR27, D3, D1, UMAHXH45, D2, QHXH45, CORR28, D3, D1, UMAHXH46, D2, QHXH46, CORR29, D3, D1, UMAHXH47, D2, QHXH47, CORR30, D3, D1, UMAHXH48, D2, QHXH48, CORR31, D3, D1, UMAHXH49, D2, QHXH49, CORR32, D3, D1, UMAHXH50, D2, QHXH50, CORR33, D3};
Here's what the Python representation would look like:
G.input.lattice
Lattice( elements={ 'QHXH17': Quadrupole(label='QHXH17', L=0.101, k1=1.78), 'QHXH18': Quadrupole(label='QHXH18', L=0.101, k1=-1.78), 'QHXH19': Quadrupole(label='QHXH19', L=0.101, k1=1.78), 'QHXH20': Quadrupole(label='QHXH20', L=0.101, k1=-1.78), 'QHXH21': Quadrupole(label='QHXH21', L=0.101, k1=1.78), 'QHXH22': Quadrupole(label='QHXH22', L=0.101, k1=-1.78), 'QHXH23': Quadrupole(label='QHXH23', L=0.101, k1=1.78), 'QHXH24': Quadrupole(label='QHXH24', L=0.101, k1=-1.78), 'QHXH25': Quadrupole(label='QHXH25', L=0.101, k1=1.78), 'QHXH26': Quadrupole(label='QHXH26', L=0.101, k1=-1.78), 'QHXH27': Quadrupole(label='QHXH27', L=0.101, k1=1.78), 'QHXH28': Quadrupole(label='QHXH28', L=0.101, k1=-1.78), 'QHXH29': Quadrupole(label='QHXH29', L=0.101, k1=1.78), 'QHXH30': Quadrupole(label='QHXH30', L=0.101, k1=-1.78), 'QHXH31': Quadrupole(label='QHXH31', L=0.101, k1=1.78), 'QHXH32': Quadrupole(label='QHXH32', L=0.101, k1=-1.78), 'QHXH33': Quadrupole(label='QHXH33', L=0.101, k1=1.78), 'QHXH34': Quadrupole(label='QHXH34', L=0.101, k1=-1.78), 'QHXH35': Quadrupole(label='QHXH35', L=0.101, k1=1.78), 'QHXH36': Quadrupole(label='QHXH36', L=0.101, k1=-1.78), 'QHXH37': Quadrupole(label='QHXH37', L=0.101, k1=1.78), 'QHXH38': Quadrupole(label='QHXH38', L=0.101, k1=-1.78), 'QHXH39': Quadrupole(label='QHXH39', L=0.101, k1=1.78), 'QHXH40': Quadrupole(label='QHXH40', L=0.101, k1=-1.78), 'QHXH41': Quadrupole(label='QHXH41', L=0.101, k1=1.78), 'QHXH42': Quadrupole(label='QHXH42', L=0.101, k1=-1.78), 'QHXH43': Quadrupole(label='QHXH43', L=0.101, k1=1.78), 'QHXH44': Quadrupole(label='QHXH44', L=0.101, k1=-1.78), 'QHXH45': Quadrupole(label='QHXH45', L=0.101, k1=1.78), 'QHXH46': Quadrupole(label='QHXH46', L=0.101, k1=-1.78), 'QHXH47': Quadrupole(label='QHXH47', L=0.101, k1=1.78), 'QHXH48': Quadrupole(label='QHXH48', L=0.101, k1=-1.78), 'QHXH49': Quadrupole(label='QHXH49', L=0.101, k1=1.78), 'QHXH50': Quadrupole(label='QHXH50', L=0.101, k1=-1.78), 'UMAHXH17': Undulator(label='UMAHXH17', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH18': Undulator(label='UMAHXH18', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH19': Undulator(label='UMAHXH19', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH20': Undulator(label='UMAHXH20', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH21': Undulator(label='UMAHXH21', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH22': Undulator(label='UMAHXH22', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH23': Undulator(label='UMAHXH23', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH25': Undulator(label='UMAHXH25', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH26': Undulator(label='UMAHXH26', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH27': Undulator(label='UMAHXH27', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH28': Undulator(label='UMAHXH28', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH29': Undulator(label='UMAHXH29', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH30': Undulator(label='UMAHXH30', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH31': Undulator(label='UMAHXH31', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH33': Undulator(label='UMAHXH33', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH34': Undulator(label='UMAHXH34', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH35': Undulator(label='UMAHXH35', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH36': Undulator(label='UMAHXH36', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH37': Undulator(label='UMAHXH37', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH38': Undulator(label='UMAHXH38', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH39': Undulator(label='UMAHXH39', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH40': Undulator(label='UMAHXH40', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH41': Undulator(label='UMAHXH41', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH42': Undulator(label='UMAHXH42', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH43': Undulator(label='UMAHXH43', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH44': Undulator(label='UMAHXH44', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH45': Undulator(label='UMAHXH45', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH46': Undulator(label='UMAHXH46', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH47': Undulator(label='UMAHXH47', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH48': Undulator(label='UMAHXH48', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH49': Undulator(label='UMAHXH49', aw=1.7017, lambdau=0.026, nwig=130), 'UMAHXH50': Undulator(label='UMAHXH50', aw=1.7017, lambdau=0.026, nwig=130), 'CORR00': Corrector(label='CORR00', L=0.001), 'CORR01': Corrector(label='CORR01', L=0.001), 'CORR02': Corrector(label='CORR02', L=0.001), 'CORR03': Corrector(label='CORR03', L=0.001), 'CORR04': Corrector(label='CORR04', L=0.001), 'CORR05': Corrector(label='CORR05', L=0.001), 'CORR06': Corrector(label='CORR06', L=0.001), 'CORR07': Corrector(label='CORR07', L=0.001), 'CORR08': Corrector(label='CORR08', L=0.001), 'CORR09': Corrector(label='CORR09', L=0.001), 'CORR10': Corrector(label='CORR10', L=0.001), 'CORR11': Corrector(label='CORR11', L=0.001), 'CORR12': Corrector(label='CORR12', L=0.001), 'CORR13': Corrector(label='CORR13', L=0.001), 'CORR14': Corrector(label='CORR14', L=0.001), 'CORR15': Corrector(label='CORR15', L=0.001), 'CORR16': Corrector(label='CORR16', L=0.001), 'CORR17': Corrector(label='CORR17', L=0.001), 'CORR18': Corrector(label='CORR18', L=0.001), 'CORR19': Corrector(label='CORR19', L=0.001), 'CORR20': Corrector(label='CORR20', L=0.001), 'CORR21': Corrector(label='CORR21', L=0.001), 'CORR22': Corrector(label='CORR22', L=0.001), 'CORR23': Corrector(label='CORR23', L=0.001), 'CORR24': Corrector(label='CORR24', L=0.001), 'CORR25': Corrector(label='CORR25', L=0.001), 'CORR26': Corrector(label='CORR26', L=0.001), 'CORR27': Corrector(label='CORR27', L=0.001), 'CORR28': Corrector(label='CORR28', L=0.001), 'CORR29': Corrector(label='CORR29', L=0.001), 'CORR30': Corrector(label='CORR30', L=0.001), 'CORR31': Corrector(label='CORR31', L=0.001), 'CORR32': Corrector(label='CORR32', L=0.001), 'CORR33': Corrector(label='CORR33', L=0.001), 'D1': Drift(label='D1', L=0.1335), 'D2': Drift(label='D2', L=0.4615), 'D3': Drift(label='D3', L=0.328), 'D4': Drift(label='D4', L=3.4), 'HXRSS': Chicane(label='HXRSS', L=4.55, lb=0.1), 'HXR': Line( label='HXR', elements=[ 'D1', 'UMAHXH17', 'D2', 'QHXH17', 'CORR00', 'D3', 'D1', 'UMAHXH18', 'D2', 'QHXH18', 'CORR01', 'D3', 'D1', 'UMAHXH19', 'D2', 'QHXH19', 'CORR02', 'D3', 'D1', 'UMAHXH20', 'D2', 'QHXH20', 'CORR03', 'D3', 'D1', 'UMAHXH21', 'D2', 'QHXH21', 'CORR04', 'D3', 'D1', 'UMAHXH22', 'D2', 'QHXH22', 'CORR05', 'D3', 'D1', 'UMAHXH23', 'D2', 'QHXH23', 'CORR06', 'D3', 'D1', 'HXRSS', 'D2', 'QHXH24', 'CORR07', 'D3', 'D1', 'UMAHXH25', 'D2', 'QHXH25', 'CORR08', 'D3', 'D1', 'UMAHXH26', 'D2', 'QHXH26', 'CORR09', 'D3', 'D1', 'UMAHXH27', 'D2', 'QHXH27', 'CORR10', 'D3', 'D1', 'UMAHXH28', 'D2', 'QHXH28', 'CORR11', 'D3', 'D1', 'UMAHXH29', 'D2', 'QHXH29', 'CORR12', 'D3', 'D1', 'UMAHXH30', 'D2', 'QHXH30', 'CORR13', 'D3', 'D1', 'UMAHXH31', 'D2', 'QHXH31', 'CORR14', 'D3', 'D1', 'D4', 'D2', 'QHXH32', 'CORR15', 'D3', 'D1', 'UMAHXH33', 'D2', 'QHXH33', 'CORR16', 'D3', 'D1', 'UMAHXH34', 'D2', 'QHXH34', 'CORR17', 'D3', 'D1', 'UMAHXH35', 'D2', 'QHXH35', 'CORR18', 'D3', 'D1', 'UMAHXH36', 'D2', 'QHXH36', 'CORR19', 'D3', 'D1', 'UMAHXH37', 'D2', 'QHXH37', 'CORR20', 'D3', 'D1', 'UMAHXH38', 'D2', 'QHXH38', 'CORR21', 'D3', 'D1', 'UMAHXH39', 'D2', 'QHXH39', 'CORR22', 'D3', 'D1', 'UMAHXH40', 'D2', 'QHXH40', 'CORR23', 'D3', 'D1', 'UMAHXH41', 'D2', 'QHXH41', 'CORR24', 'D3', 'D1', 'UMAHXH42', 'D2', 'QHXH42', 'CORR25', 'D3', 'D1', 'UMAHXH43', 'D2', 'QHXH43', 'CORR26', 'D3', 'D1', 'UMAHXH44', 'D2', 'QHXH44', 'CORR27', 'D3', 'D1', 'UMAHXH45', 'D2', 'QHXH45', 'CORR28', 'D3', 'D1', 'UMAHXH46', 'D2', 'QHXH46', 'CORR29', 'D3', 'D1', 'UMAHXH47', 'D2', 'QHXH47', 'CORR30', 'D3', 'D1', 'UMAHXH48', 'D2', 'QHXH48', 'CORR31', 'D3', 'D1', 'UMAHXH49', 'D2', 'QHXH49', 'CORR32', 'D3', 'D1', 'UMAHXH50', 'D2', 'QHXH50', 'CORR33', 'D3', ], ), 'LCLS2_HXR_U1': Line( label='LCLS2_HXR_U1', elements=[ 'D1', 'UMAHXH17', 'D2', 'QHXH17', 'CORR00', 'D3', 'D1', 'UMAHXH18', 'D2', 'QHXH18', 'CORR01', 'D3', 'D1', 'UMAHXH19', 'D2', 'QHXH19', 'CORR02', 'D3', 'D1', 'UMAHXH20', 'D2', 'QHXH20', 'CORR03', 'D3', 'D1', 'UMAHXH21', 'D2', 'QHXH21', 'CORR04', 'D3', 'D1', 'UMAHXH22', 'D2', 'QHXH22', 'CORR05', 'D3', 'D1', 'UMAHXH23', 'D2', 'QHXH23', 'CORR06', 'D3', ], ), 'LCLS2_HXR_U2': Line( label='LCLS2_HXR_U2', elements=[ 'D1', 'UMAHXH25', 'D2', 'QHXH25', 'CORR08', 'D3', 'D1', 'UMAHXH26', 'D2', 'QHXH26', 'CORR09', 'D3', 'D1', 'UMAHXH27', 'D2', 'QHXH27', 'CORR10', 'D3', 'D1', 'UMAHXH28', 'D2', 'QHXH28', 'CORR11', 'D3', 'D1', 'UMAHXH29', 'D2', 'QHXH29', 'CORR12', 'D3', 'D1', 'UMAHXH30', 'D2', 'QHXH30', 'CORR13', 'D3', 'D1', 'UMAHXH31', 'D2', 'QHXH31', 'CORR14', 'D3', 'D1', 'D4', 'D2', 'QHXH32', 'CORR15', 'D3', 'D1', 'UMAHXH33', 'D2', 'QHXH33', 'CORR16', 'D3', 'D1', 'UMAHXH34', 'D2', 'QHXH34', 'CORR17', 'D3', 'D1', 'UMAHXH35', 'D2', 'QHXH35', 'CORR18', 'D3', 'D1', 'UMAHXH36', 'D2', 'QHXH36', 'CORR19', 'D3', 'D1', 'UMAHXH37', 'D2', 'QHXH37', 'CORR20', 'D3', 'D1', 'UMAHXH38', 'D2', 'QHXH38', 'CORR21', 'D3', 'D1', 'UMAHXH39', 'D2', 'QHXH39', 'CORR22', 'D3', 'D1', 'UMAHXH40', 'D2', 'QHXH40', 'CORR23', 'D3', 'D1', 'UMAHXH41', 'D2', 'QHXH41', 'CORR24', 'D3', 'D1', 'UMAHXH42', 'D2', 'QHXH42', 'CORR25', 'D3', 'D1', 'UMAHXH43', 'D2', 'QHXH43', 'CORR26', 'D3', 'D1', 'UMAHXH44', 'D2', 'QHXH44', 'CORR27', 'D3', 'D1', 'UMAHXH45', 'D2', 'QHXH45', 'CORR28', 'D3', 'D1', 'UMAHXH46', 'D2', 'QHXH46', 'CORR29', 'D3', 'D1', 'UMAHXH47', 'D2', 'QHXH47', 'CORR30', 'D3', 'D1', 'UMAHXH48', 'D2', 'QHXH48', 'CORR31', 'D3', 'D1', 'UMAHXH49', 'D2', 'QHXH49', 'CORR32', 'D3', 'D1', 'UMAHXH50', 'D2', 'QHXH50', 'CORR33', 'D3', ], ), }, filename=pathlib.Path('/home/runner/work/lume-genesis/lume-genesis/docs/examples/genesis4/data/basic4/hxr.lat'), )
Here's what a fully-detailed table representation looks like:
G.input.lattice.to_table()
Attribute | Value | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
QHXH17 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH18 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH19 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH20 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH21 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH22 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH23 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH24 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH25 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH26 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH27 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH28 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH29 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH30 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH31 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH32 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH33 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH34 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH35 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH36 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH37 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH38 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH39 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH40 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH41 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH42 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH43 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH44 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH45 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH46 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH47 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH48 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH49 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
QHXH50 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH17 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH18 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH19 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH20 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH21 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH22 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH23 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH25 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH26 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH27 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH28 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH29 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH30 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH31 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH33 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH34 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH35 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH36 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH37 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH38 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH39 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH40 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH41 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH42 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH43 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH44 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH45 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH46 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH47 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH48 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH49 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
UMAHXH50 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR00 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR01 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR02 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR03 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR04 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR05 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR06 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR07 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR08 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR09 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR10 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR11 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR12 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR13 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR14 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR15 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR16 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR17 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR18 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR19 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR20 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR21 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR22 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR23 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR24 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR25 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR26 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR27 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR28 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR29 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR30 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR31 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR32 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
CORR33 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
D1 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
D2 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
D3 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
D4 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
HXRSS |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
HXR |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
LCLS2_HXR_U1 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
LCLS2_HXR_U2 |
|
You can turn off/on descriptions in tables and configure other aspects of LUME-Genesis rendering of objects for Jupyter:
genesis.global_display_options.include_description = False
G.input.main.writes[0].to_table()
Attribute | Value | Type |
---|---|---|
type | write | str |
field | end | str |
beam | str | |
stride | 1 | int |
View it as a markdown table for easy pasting into GitHub and other platforms:
print(G.input.main.profile_files[0].to_string("markdown"))
| Attribute | Value | Type | | :--------: | :---------------------: | :--: | | type | profile_file | str | | label | beamcurrent | str | | xdata | beam_current.h5/s | str | | ydata | beam_current.h5/current | str | | isTime | False | bool | | reverse | False | bool | | autoassign | False | bool |
Run¶
Run with MPI. Here, setting G.nproc = 0
will automatically select the maximum number of CPUs.
G.nproc = 0
output = G.run()
Configured to run in: /tmp/tmp5uco9f6g Setting use_mpi = True because nproc = 2 Running Genesis4 in /tmp/tmp5uco9f6g /home/runner/miniconda3/envs/lume-genesis-dev/bin/mpirun -n 2 /home/runner/miniconda3/envs/lume-genesis-dev/bin/genesis4 -l hxr.lat genesis4.in
--------------------------------------------- GENESIS - Version 4.6.7 has started... Compile info: Compiled by conda at 2024-12-09 17:34:26 [UTC] from Git Commit ID: f166211af8ded3543c5b983d3d6d8680af6ab767 Starting Time: Mon Jan 6 22:15:38 2025 MPI-Comm Size: 2 nodes Opened input file genesis4.in Parsing lattice file hxr.lat ... Setting up time window of 15.0027 microns with 544 sample points... Generating input radiation field for HARM = 1 ...
Adding profile with label: beamcurrent Adding profile with label: beamgamma Generating input particle distribution... Running Core Simulation... Time-dependent run with 544 slices for a time window of 15.0027 microns Initial analysis of electron beam and radiation field... Calculation: 0% done
Calculation: 10% done
Calculation: 20% done
Calculation: 30% done
Calculation: 40% done
Calculation: 50% done
Calculation: 60% done
Calculation: 70% done
Calculation: 80% done
Calculation: 90% done
Calculation: 100% done
Calculation: 110% done
Calculation terminated due to requested stop. Writing output file... Core Simulation done. End of Track Writing field distribution to file: end.fld.h5 ...
Writing particle distribution to file: end.par.h5 ... Program is terminating... Ending Time: Mon Jan 6 22:17:20 2025 Total Wall Clock Time: 101.87 seconds -------------------------------------
Success - execution took 103.12s.
if output.run.error:
print(G.output.run.error_reason)
else:
print("No error")
No error
Output¶
The main output is an HDF5. The Genesis4 object loads all array data into convenient Pydantic models:
G.output.beam, G.output.field
(OutputBeam( extra={}, globals=OutputBeamGlobal( extra={}, energy=array([], dtype=float64), energyspread=array([], dtype=float64), xposition=array([], dtype=float64), yposition=array([], dtype=float64), xsize=array([], dtype=float64), ysize=array([], dtype=float64), ), bunching=array(shape=(390, 544), dtype=float64), bunchingphase=array(shape=(390, 544), dtype=float64), energy=array(shape=(390, 544), dtype=float64), energyspread=array(shape=(390, 544), dtype=float64), xsize=array(shape=(390, 544), dtype=float64), ysize=array(shape=(390, 544), dtype=float64), lsc_field=array(shape=(390, 544), dtype=float64), ssc_field=array(shape=(390, 544), dtype=float64), efield=array(shape=(390, 544), dtype=float64), wakefield=array(shape=(390, 544), dtype=float64), emin=array(shape=(390, 544), dtype=float64), emax=array(shape=(390, 544), dtype=float64), pxmin=array(shape=(390, 544), dtype=float64), pxmax=array(shape=(390, 544), dtype=float64), pymin=array(shape=(390, 544), dtype=float64), pymax=array(shape=(390, 544), dtype=float64), pxposition=array(shape=(390, 544), dtype=float64), pyposition=array(shape=(390, 544), dtype=float64), xmin=array(shape=(390, 544), dtype=float64), xmax=array(shape=(390, 544), dtype=float64), ymin=array(shape=(390, 544), dtype=float64), ymax=array(shape=(390, 544), dtype=float64), xposition=array(shape=(390, 544), dtype=float64), yposition=array(shape=(390, 544), dtype=float64), alphax=array(shape=(1, 544), dtype=float64), alphay=array(shape=(1, 544), dtype=float64), betax=array(shape=(1, 544), dtype=float64), betay=array(shape=(1, 544), dtype=float64), current=array(shape=(1, 544), dtype=float64), emitx=array(shape=(1, 544), dtype=float64), emity=array(shape=(1, 544), dtype=float64), ), OutputField( extra={}, globals=OutputFieldGlobal( extra={}, energy=array([], dtype=float64), intensity_farfield=array([], dtype=float64), intensity_nearfield=array([], dtype=float64), xdivergence=array([], dtype=float64), ydivergence=array([], dtype=float64), xpointing=array([], dtype=float64), ypointing=array([], dtype=float64), xposition=array([], dtype=float64), yposition=array([], dtype=float64), xsize=array([], dtype=float64), ysize=array([], dtype=float64), ), dgrid=0.0001, gridspacing=2e-06, intensity_farfield=array(shape=(390, 544), dtype=float64), intensity_nearfield=array(shape=(390, 544), dtype=float64), ngrid=101, phase_farfield=array(shape=(390, 544), dtype=float64), phase_nearfield=array(shape=(390, 544), dtype=float64), power=array(shape=(390, 544), dtype=float64), xdivergence=array(shape=(390, 544), dtype=float64), ydivergence=array(shape=(390, 544), dtype=float64), xpointing=array(shape=(390, 544), dtype=float64), ypointing=array(shape=(390, 544), dtype=float64), xposition=array(shape=(390, 544), dtype=float64), yposition=array(shape=(390, 544), dtype=float64), xsize=array(shape=(390, 544), dtype=float64), ysize=array(shape=(390, 544), dtype=float64), energy=array(shape=(390,), dtype=float64), ))
G.output.beam.stat.alphax.shape
(1,)
plt.plot(G.output.beam.stat.sigma_x)
plt.yscale("log")
Each of these parameters has a string alias that you can use to refer to the data. These string parameters can be used in G.plot()
and similar methods.
Here are the first 10 of those keys:
list(G.output.keys())[:10]
['beam_globals_energy', 'beam_globals_energyspread', 'beam_globals_xposition', 'beam_globals_yposition', 'beam_globals_xsize', 'beam_globals_ysize', 'beam_bunching', 'beam_bunchingphase', 'beam_energy', 'beam_energyspread']
print("Took", G.output.run.run_time, "sec")
Took 103.122445 sec
To inspect these aliases, check this dictionary:
print(G.output.alias["alphax"])
beam.alphax
G.output["alphax"] is G.output.beam.alphax
True
The above indicates that the alias "alphax"
corresponds to the attribute beam.alphax
. So, you could access the data either as G.output["alphax"]
or G.output.beam.alphax
.
Though the former may be shorter, you can take advantage of tab completion when working with the Python classes directly. Try typing G.output.beam.
and then hit tab with the cursor after the final .
. You should see a list of other output beam data.
There are many outputs. .output_info()
gives a convenient table describing what was read in.
genesis.global_display_options.include_description = True
G.output.info()
Key | Units | Shape | Description |
---|---|---|---|
alphax | rad | (1, 544) | Twiss alpha horizontal. Evaluated only at the beginning. (output.beam.alphax) |
alphay | rad | (1, 544) | Twiss alpha vertical. Evaluated only at the beginning. (output.beam.alphay) |
aw | (4332,) | The dimensionless rms undulator parameter. For planar undulator this value is smaller by a factor $1 / \sqrt{2}$ than its K-value, while for helical undulator rms and peak values are identical. (output.lattice.aw) | |
ax | m | (4332,) | Offset of the undulator module in $x$. (output.lattice.ax) |
ay | m | (4332,) | Offset of the undulator module in $y$. (output.lattice.ay) |
beam_alphax | rad | (1, 544) | Twiss alpha horizontal. Evaluated only at the beginning. (output.beam.alphax) |
beam_alphay | rad | (1, 544) | Twiss alpha vertical. Evaluated only at the beginning. (output.beam.alphay) |
beam_betax | m | (1, 544) | Twiss beta horizontal. Evaluated only at the beginning. (output.beam.betax) |
beam_betay | m | (1, 544) | Twiss beta vertical. Evaluated only at the beginning. (output.beam.betay) |
beam_bunching | (390, 544) | Evaluated at each integration step. [unitless] (output.beam.bunching) | |
beam_bunchingphase | rad | (390, 544) | Evaluated at each integration step. (output.beam.bunchingphase) |
beam_current | A | (1, 544) | Beam current. Evaluated only at the beginning. (output.beam.current) |
beam_efield | eV/m | (390, 544) | Efield, internally eloss+longESC (output.beam.efield) |
beam_emax | eV | (390, 544) | Particle energy maximum. Genesis4 mc^2 units are automatically converted to eV in LUME-Genesis. (output.beam.emax) |
beam_emin | eV | (390, 544) | Particle energy minimum. Genesis4 mc^2 units are automatically converted to eV in LUME-Genesis. (output.beam.emin) |
beam_emitx | m | (1, 544) | Beam horizontal emittance. Evaluated only at the beginning. (output.beam.emitx) |
beam_emity | m | (1, 544) | Beam vertical emittance. Evaluated only at the beginning. (output.beam.emity) |
beam_energy | eV | (390, 544) | Evaluated at each integration step. Genesis4 mc^2 units are automatically converted to eV in LUME-Genesis. (output.beam.energy) |
beam_energyspread | eV | (390, 544) | Evaluated at each integration step. Genesis4 mc^2 units are automatically converted to eV in LUME-Genesis. (output.beam.energyspread) |
beam_globals_energy | eV | (0,) | Average beam energy (output.beam.globals.energy) |
beam_globals_energyspread | (0,) | Projected energy spread [1] (output.beam.globals.energyspread) | |
beam_globals_xposition | m | (0,) | Slice average centroid X position (output.beam.globals.xposition) |
beam_globals_xsize | m | (0,) | Projected RMS beam size in X (output.beam.globals.xsize) |
beam_globals_yposition | m | (0,) | Slice average centroid Y position (output.beam.globals.yposition) |
beam_globals_ysize | m | (0,) | Projected RMS beam size in Y (output.beam.globals.ysize) |
beam_lsc_field | eV/m | (390, 544) | Longitudinal space charge (output.beam.lsc_field) |
beam_pxmax | rad | (390, 544) | Particle horizontal maximum momentum (output.beam.pxmax) |
beam_pxmin | rad | (390, 544) | Particle horizontal minimum momentum (output.beam.pxmin) |
beam_pxposition | rad | (390, 544) | Particle horizontal position in momentum space (output.beam.pxposition) |
beam_pymax | rad | (390, 544) | Particle vertical maximum momentum (output.beam.pymax) |
beam_pymin | rad | (390, 544) | Particle vertical minimum momentum (output.beam.pymin) |
beam_pyposition | rad | (390, 544) | Particle vertical position in momentum space (output.beam.pyposition) |
beam_sigma_energy | eV | (390,) | Average beam energy (output.beam.stat.sigma_energy) |
beam_sigma_x | m | (390,) | Projected RMS beam size in X (output.beam.stat.sigma_x) |
beam_sigma_y | m | (390,) | Projected RMS beam size in Y (output.beam.stat.sigma_y) |
beam_ssc_field | eV/m | (390, 544) | Short-range space charge (output.beam.ssc_field) |
beam_stat_alphax | rad | (1,) | Slice-averaged by current twiss alpha horizontal. Evaluated only at the beginning. (output.beam.stat.alphax) |
beam_stat_alphay | rad | (1,) | Slice-averaged by current twiss alpha vertical. Evaluated only at the beginning. (output.beam.stat.alphay) |
beam_stat_betax | m | (1,) | Slice-averaged by current twiss beta horizontal. Evaluated only at the beginning. (output.beam.stat.betax) |
beam_stat_betay | m | (1,) | Slice-averaged by current twiss beta vertical. Evaluated only at the beginning. (output.beam.stat.betay) |
beam_stat_bunching | (390,) | Bunching - see `OutputBeamStat.calculate_bunching` method for details. (output.beam.stat.bunching) | |
beam_stat_bunchingphase | rad | (390,) | Bunching phase evaluated at each integration step. (output.beam.stat.bunchingphase) |
beam_stat_current | A | (1,) | [Deprecated] Beam current. Evaluated only at the beginning. (output.beam.stat.current) |
beam_stat_efield | eV/m | (390,) | Slice-averaged by current Efield, internally eloss+longESC (output.beam.stat.efield) |
beam_stat_emitx | m | (1,) | Slice-averaged by current beam horizontal emittance. Evaluated only at the beginning. (output.beam.stat.emitx) |
beam_stat_emity | m | (1,) | Slice-averaged by current beam vertical emittance. Evaluated only at the beginning. (output.beam.stat.emity) |
beam_stat_energy | eV | (390,) | Slice-averaged by current energy (output.beam.stat.energy) |
beam_stat_energyspread | eV | (390,) | Slice-averaged by current energy spread (output.beam.stat.energyspread) |
beam_stat_lsc_field | eV/m | (390,) | Slice-averaged by current longitudinal space charge (output.beam.stat.lsc_field) |
beam_stat_pxmax | rad | (390,) | Slice-averaged by current particle horizontal maximum momentum (output.beam.stat.pxmax) |
beam_stat_pxmin | rad | (390,) | Slice-averaged by current particle horizontal minimum momentum (output.beam.stat.pxmin) |
beam_stat_pxposition | rad | (390,) | Slice-averaged by current particle horizontal position in momentum space (output.beam.stat.pxposition) |
beam_stat_pymax | rad | (390,) | Slice-averaged by current particle vertical maximum momentum (output.beam.stat.pymax) |
beam_stat_pymin | rad | (390,) | Slice-averaged by current particle vertical minimum momentum (output.beam.stat.pymin) |
beam_stat_pyposition | rad | (390,) | Slice-averaged by current particle vertical position in momentum space (output.beam.stat.pyposition) |
beam_stat_sigma_energy | eV | (390,) | Average beam energy (output.beam.stat.sigma_energy) |
beam_stat_sigma_x | m | (390,) | Projected RMS beam size in X (output.beam.stat.sigma_x) |
beam_stat_sigma_y | m | (390,) | Projected RMS beam size in Y (output.beam.stat.sigma_y) |
beam_stat_ssc_field | eV/m | (390,) | Slice-averaged by energy short-range space charge (output.beam.stat.ssc_field) |
beam_stat_wakefield | eV/m | (390,) | Slice-averaged by energy wakefield, internally the energy loss. (output.beam.stat.wakefield) |
beam_stat_xmax | m | (390,) | Maximum over all slices of particle horizontal minimum position (output.beam.stat.xmax) |
beam_stat_xmin | m | (390,) | Minimum over all slices of particle horizontal minimum position (output.beam.stat.xmin) |
beam_stat_xposition | m | (390,) | Slice-averaged by current particle horizontal position (output.beam.stat.xposition) |
beam_stat_ymax | m | (390,) | Slice-averaged by current particle vertical maximum position (output.beam.stat.ymax) |
beam_stat_ymin | m | (390,) | Slice-averaged by current particle vertical minimum position (output.beam.stat.ymin) |
beam_stat_yposition | m | (390,) | Slice-averaged by current particle vertical position (output.beam.stat.yposition) |
beam_wakefield | eV/m | (390, 544) | Wakefield, internally the energy loss. (output.beam.wakefield) |
beam_xmax | m | (390, 544) | Particle horizontal maximum position (output.beam.xmax) |
beam_xmin | m | (390, 544) | Particle horizontal minimum position (output.beam.xmin) |
beam_xposition | m | (390, 544) | Particle horizontal position (output.beam.xposition) |
beam_xsize | m | (390, 544) | Beam horizontal sigma. (output.beam.xsize) |
beam_ymax | m | (390, 544) | Particle vertical maximum position (output.beam.ymax) |
beam_ymin | m | (390, 544) | Particle vertical minimum position (output.beam.ymin) |
beam_yposition | m | (390, 544) | Particle vertical position (output.beam.yposition) |
beam_ysize | m | (390, 544) | Beam horizontal sigma. (output.beam.ysize) |
betax | m | (1, 544) | Twiss beta horizontal. Evaluated only at the beginning. (output.beam.betax) |
betay | m | (1, 544) | Twiss beta vertical. Evaluated only at the beginning. (output.beam.betay) |
bunching | (390, 544) | Evaluated at each integration step. [unitless] (output.beam.bunching) | |
bunchingphase | rad | (390, 544) | Evaluated at each integration step. (output.beam.bunchingphase) |
chic_angle | degree | (4332,) | Chicane angle (output.lattice.chic_angle) |
chic_lb | m | (4332,) | Length of an individual dipole in meter. (output.lattice.chic_lb) |
chic_ld | m | (4332,) | Drift between the outer and inner dipoles, projected onto the undulator axis. The actual path length is longer by the factor $1/\cos\theta$, where $\theta$ is the bending angle of an individual dipole. (output.lattice.chic_ld) |
chic_lt | m | (4332,) | Chicane length (output.lattice.chic_lt) |
current | A | (1, 544) | Beam current. Evaluated only at the beginning. (output.beam.current) |
cx | rad | (4332,) | Kick angle in $x$ in units of $\gamma \beta_x$. (output.lattice.cx) |
cy | rad | (4332,) | Kick angle in $y$ in units of $\gamma \beta_y$. (output.lattice.cy) |
dz | m | (4332,) | Step length (output.lattice.dz) |
efield | eV/m | (390, 544) | Efield, internally eloss+longESC (output.beam.efield) |
emax | eV | (390, 544) | Particle energy maximum. Genesis4 mc^2 units are automatically converted to eV in LUME-Genesis. (output.beam.emax) |
emin | eV | (390, 544) | Particle energy minimum. Genesis4 mc^2 units are automatically converted to eV in LUME-Genesis. (output.beam.emin) |
emitx | m | (1, 544) | Beam horizontal emittance. Evaluated only at the beginning. (output.beam.emitx) |
emity | m | (1, 544) | Beam vertical emittance. Evaluated only at the beginning. (output.beam.emity) |
field1_energy | J | (390,) | Calculated by LUME-Genesis using slen from /Global. (output.field.energy) |
field1_globals_energy | J | (0,) | Field energy (output.field.globals.energy) |
field1_globals_intensity_farfield | (0,) | Field intensity in the far field [arb units] (output.field.globals.intensity_farfield) | |
field1_globals_intensity_nearfield | (0,) | Field intensity in the near field [arb units] (output.field.globals.intensity_nearfield) | |
field1_globals_xdivergence | rad | (0,) | Horizontal divergence (output.field.globals.xdivergence) |
field1_globals_xpointing | rad | (0,) | Horizontal pointing. (output.field.globals.xpointing) |
field1_globals_xposition | m | (0,) | Horizontal position. (output.field.globals.xposition) |
field1_globals_xsize | m | (0,) | Horizontal sigma. (output.field.globals.xsize) |
field1_globals_ydivergence | rad | (0,) | Vertical divergence (output.field.globals.ydivergence) |
field1_globals_ypointing | rad | (0,) | Vertical pointing. (output.field.globals.ypointing) |
field1_globals_yposition | m | (0,) | Vertical position. (output.field.globals.yposition) |
field1_globals_ysize | m | (0,) | Vertical sigma. (output.field.globals.ysize) |
field1_intensity_farfield | W/rad^2 | (390, 544) | Field intensity in the far field [arb units] (output.field.intensity_farfield) |
field1_intensity_nearfield | W/m^2 | (390, 544) | Field intensity in the near field [arb units] (output.field.intensity_nearfield) |
field1_peak_power | W | (390,) | Peak power . (output.field.peak_power) |
field1_phase_farfield | rad | (390, 544) | Far field phase (output.field.phase_farfield) |
field1_phase_nearfield | rad | (390, 544) | Near field phase (output.field.phase_nearfield) |
field1_power | W | (390, 544) | Power (output.field.power) |
field1_stat_energy | J | (390,) | Power-weighted energy (output.field.stat.energy) |
field1_stat_intensity_farfield | W/rad^2 | (390,) | Power-weighted field intensity in the far field [arb units] (output.field.stat.intensity_farfield) |
field1_stat_intensity_nearfield | W/m^2 | (390,) | Power-weighted field intensity in the near field [arb units] (output.field.stat.intensity_nearfield) |
field1_stat_phase_farfield | rad | (390,) | Power-weighted far field phase (output.field.stat.phase_farfield) |
field1_stat_phase_nearfield | rad | (390,) | Power-weighted near field phase (output.field.stat.phase_nearfield) |
field1_stat_power | W | (390,) | Power (output.field.stat.power) |
field1_stat_xdivergence | rad | (390,) | Power-weighted horizontal divergence (output.field.stat.xdivergence) |
field1_stat_xpointing | rad | (390,) | Power-weighted horizontal pointing. (output.field.stat.xpointing) |
field1_stat_xposition | m | (390,) | Power-weighted horizontal position. (output.field.stat.xposition) |
field1_stat_xsize | m | (390,) | Power-weighted horizontal sigma. (output.field.stat.xsize) |
field1_stat_ydivergence | rad | (390,) | Power-weighted vertical divergence (output.field.stat.ydivergence) |
field1_stat_ypointing | rad | (390,) | Power-weighted vertical pointing. (output.field.stat.ypointing) |
field1_stat_yposition | m | (390,) | Power-weighted vertical position. (output.field.stat.yposition) |
field1_stat_ysize | m | (390,) | Power-weighted vertical sigma. (output.field.stat.ysize) |
field1_xdivergence | rad | (390, 544) | Horizontal divergence (output.field.xdivergence) |
field1_xpointing | rad | (390, 544) | Horizontal pointing. (output.field.xpointing) |
field1_xposition | m | (390, 544) | Horizontal position. (output.field.xposition) |
field1_xsize | m | (390, 544) | Horizontal sigma. (output.field.xsize) |
field1_ydivergence | rad | (390, 544) | Vertical divergence (output.field.ydivergence) |
field1_ypointing | rad | (390, 544) | Vertical pointing. (output.field.ypointing) |
field1_yposition | m | (390, 544) | Vertical position. (output.field.yposition) |
field1_ysize | m | (390, 544) | Vertical sigma. (output.field.ysize) |
field_energy | J | (390,) | Calculated by LUME-Genesis using slen from /Global. (output.field.energy) |
field_globals_energy | J | (0,) | Field energy (output.field.globals.energy) |
field_globals_intensity_farfield | (0,) | Field intensity in the far field [arb units] (output.field.globals.intensity_farfield) | |
field_globals_intensity_nearfield | (0,) | Field intensity in the near field [arb units] (output.field.globals.intensity_nearfield) | |
field_globals_xdivergence | rad | (0,) | Horizontal divergence (output.field.globals.xdivergence) |
field_globals_xpointing | rad | (0,) | Horizontal pointing. (output.field.globals.xpointing) |
field_globals_xposition | m | (0,) | Horizontal position. (output.field.globals.xposition) |
field_globals_xsize | m | (0,) | Horizontal sigma. (output.field.globals.xsize) |
field_globals_ydivergence | rad | (0,) | Vertical divergence (output.field.globals.ydivergence) |
field_globals_ypointing | rad | (0,) | Vertical pointing. (output.field.globals.ypointing) |
field_globals_yposition | m | (0,) | Vertical position. (output.field.globals.yposition) |
field_globals_ysize | m | (0,) | Vertical sigma. (output.field.globals.ysize) |
field_intensity_farfield | W/rad^2 | (390, 544) | Field intensity in the far field [arb units] (output.field.intensity_farfield) |
field_intensity_nearfield | W/m^2 | (390, 544) | Field intensity in the near field [arb units] (output.field.intensity_nearfield) |
field_peak_power | W | (390,) | Peak power . (output.field.peak_power) |
field_phase_farfield | rad | (390, 544) | Far field phase (output.field.phase_farfield) |
field_phase_nearfield | rad | (390, 544) | Near field phase (output.field.phase_nearfield) |
field_power | W | (390, 544) | Power (output.field.power) |
field_stat_energy | J | (390,) | Power-weighted energy (output.field.stat.energy) |
field_stat_intensity_farfield | W/rad^2 | (390,) | Power-weighted field intensity in the far field [arb units] (output.field.stat.intensity_farfield) |
field_stat_intensity_nearfield | W/m^2 | (390,) | Power-weighted field intensity in the near field [arb units] (output.field.stat.intensity_nearfield) |
field_stat_phase_farfield | rad | (390,) | Power-weighted far field phase (output.field.stat.phase_farfield) |
field_stat_phase_nearfield | rad | (390,) | Power-weighted near field phase (output.field.stat.phase_nearfield) |
field_stat_power | W | (390,) | Power (output.field.stat.power) |
field_stat_xdivergence | rad | (390,) | Power-weighted horizontal divergence (output.field.stat.xdivergence) |
field_stat_xpointing | rad | (390,) | Power-weighted horizontal pointing. (output.field.stat.xpointing) |
field_stat_xposition | m | (390,) | Power-weighted horizontal position. (output.field.stat.xposition) |
field_stat_xsize | m | (390,) | Power-weighted horizontal sigma. (output.field.stat.xsize) |
field_stat_ydivergence | rad | (390,) | Power-weighted vertical divergence (output.field.stat.ydivergence) |
field_stat_ypointing | rad | (390,) | Power-weighted vertical pointing. (output.field.stat.ypointing) |
field_stat_yposition | m | (390,) | Power-weighted vertical position. (output.field.stat.yposition) |
field_stat_ysize | m | (390,) | Power-weighted vertical sigma. (output.field.stat.ysize) |
field_xdivergence | rad | (390, 544) | Horizontal divergence (output.field.xdivergence) |
field_xpointing | rad | (390, 544) | Horizontal pointing. (output.field.xpointing) |
field_xposition | m | (390, 544) | Horizontal position. (output.field.xposition) |
field_xsize | m | (390, 544) | Horizontal sigma. (output.field.xsize) |
field_ydivergence | rad | (390, 544) | Vertical divergence (output.field.ydivergence) |
field_ypointing | rad | (390, 544) | Vertical pointing. (output.field.ypointing) |
field_yposition | m | (390, 544) | Vertical position. (output.field.yposition) |
field_ysize | m | (390, 544) | Vertical sigma. (output.field.ysize) |
frequency | (544,) | Frequency [eV] (output.globals.frequency) | |
globals_frequency | (544,) | Frequency [eV] (output.globals.frequency) | |
globals_s | (544,) | Longitudinal position [m] (output.globals.s) | |
gradx | 1/m | (4332,) | Relative transverse gradient of undulator field in $x$ $\equiv (1/a_w) \partial a_w/\partial x$. (output.lattice.gradx) |
grady | 1/m | (4332,) | Relative transverse gradient of undulator field in $y$ $\equiv (1/a_w) \partial a_w/\partial y$. (output.lattice.grady) |
ku | 1/m | (4332,) | Ku (output.lattice.ku) |
kx | (4332,) | Roll-off parameter of the quadratic term of the undulator field in x. It is normalized with respect to $k_u^2$. (output.lattice.kx) | |
ky | (4332,) | Roll-off parameter of the quadratic term of the undulator field in y. (output.lattice.ky) | |
lattice_aw | (4332,) | The dimensionless rms undulator parameter. For planar undulator this value is smaller by a factor $1 / \sqrt{2}$ than its K-value, while for helical undulator rms and peak values are identical. (output.lattice.aw) | |
lattice_ax | m | (4332,) | Offset of the undulator module in $x$. (output.lattice.ax) |
lattice_ay | m | (4332,) | Offset of the undulator module in $y$. (output.lattice.ay) |
lattice_chic_angle | degree | (4332,) | Chicane angle (output.lattice.chic_angle) |
lattice_chic_lb | m | (4332,) | Length of an individual dipole in meter. (output.lattice.chic_lb) |
lattice_chic_ld | m | (4332,) | Drift between the outer and inner dipoles, projected onto the undulator axis. The actual path length is longer by the factor $1/\cos\theta$, where $\theta$ is the bending angle of an individual dipole. (output.lattice.chic_ld) |
lattice_chic_lt | m | (4332,) | Chicane length (output.lattice.chic_lt) |
lattice_cx | rad | (4332,) | Kick angle in $x$ in units of $\gamma \beta_x$. (output.lattice.cx) |
lattice_cy | rad | (4332,) | Kick angle in $y$ in units of $\gamma \beta_y$. (output.lattice.cy) |
lattice_dz | m | (4332,) | Step length (output.lattice.dz) |
lattice_gradx | 1/m | (4332,) | Relative transverse gradient of undulator field in $x$ $\equiv (1/a_w) \partial a_w/\partial x$. (output.lattice.gradx) |
lattice_grady | 1/m | (4332,) | Relative transverse gradient of undulator field in $y$ $\equiv (1/a_w) \partial a_w/\partial y$. (output.lattice.grady) |
lattice_ku | 1/m | (4332,) | Ku (output.lattice.ku) |
lattice_kx | (4332,) | Roll-off parameter of the quadratic term of the undulator field in x. It is normalized with respect to $k_u^2$. (output.lattice.kx) | |
lattice_ky | (4332,) | Roll-off parameter of the quadratic term of the undulator field in y. (output.lattice.ky) | |
lattice_phaseshift | rad | (4332,) | Phase shift in radians. (output.lattice.phaseshift) |
lattice_qf | 1/m^2 | (4332,) | Quadrupole focusing strength in $1/m^2$ (output.lattice.qf) |
lattice_qx | m | (4332,) | Quadrupole offset in $x$ in meters. (output.lattice.qx) |
lattice_qy | m | (4332,) | Quadrupole offset in $y$ in meters. (output.lattice.qy) |
lattice_slippage | (4332,) | Lattice slippage. [1] (output.lattice.slippage) | |
lattice_z | m | (4332,) | Step Z position in m. The same length and describes the lattice quantities from the position ``.z[i]`` to ``.z[i]+.dz[i]`` of the i-th integration step. (output.lattice.z) |
lattice_zplot | m | (390,) | For plotting the beam or field parameters along the undulator. (output.lattice.zplot) |
lsc_field | eV/m | (390, 544) | Longitudinal space charge (output.beam.lsc_field) |
meta_beamdumps_intstep | (0,) | Integration step (output.meta.beamdumps.intstep) | |
meta_fielddumps_intstep | (0,) | Integration step (output.meta.fielddumps.intstep) | |
peak_power | W | (390,) | Peak power . (output.field.peak_power) |
phase_farfield | rad | (390, 544) | Far field phase (output.field.phase_farfield) |
phase_nearfield | rad | (390, 544) | Near field phase (output.field.phase_nearfield) |
phaseshift | rad | (4332,) | Phase shift in radians. (output.lattice.phaseshift) |
power | W | (390, 544) | Power (output.field.power) |
pxmax | rad | (390, 544) | Particle horizontal maximum momentum (output.beam.pxmax) |
pxmin | rad | (390, 544) | Particle horizontal minimum momentum (output.beam.pxmin) |
pxposition | rad | (390, 544) | Particle horizontal position in momentum space (output.beam.pxposition) |
pymax | rad | (390, 544) | Particle vertical maximum momentum (output.beam.pymax) |
pymin | rad | (390, 544) | Particle vertical minimum momentum (output.beam.pymin) |
pyposition | rad | (390, 544) | Particle vertical position in momentum space (output.beam.pyposition) |
qf | 1/m^2 | (4332,) | Quadrupole focusing strength in $1/m^2$ (output.lattice.qf) |
qx | m | (4332,) | Quadrupole offset in $x$ in meters. (output.lattice.qx) |
qy | m | (4332,) | Quadrupole offset in $y$ in meters. (output.lattice.qy) |
s | (544,) | Longitudinal position [m] (output.globals.s) | |
slippage | (4332,) | Lattice slippage. [1] (output.lattice.slippage) | |
ssc_field | eV/m | (390, 544) | Short-range space charge (output.beam.ssc_field) |
wakefield | eV/m | (390, 544) | Wakefield, internally the energy loss. (output.beam.wakefield) |
xmax | m | (390, 544) | Particle horizontal maximum position (output.beam.xmax) |
xmin | m | (390, 544) | Particle horizontal minimum position (output.beam.xmin) |
ymax | m | (390, 544) | Particle vertical maximum position (output.beam.ymax) |
ymin | m | (390, 544) | Particle vertical minimum position (output.beam.ymin) |
z | m | (4332,) | Step Z position in m. The same length and describes the lattice quantities from the position ``.z[i]`` to ``.z[i]+.dz[i]`` of the i-th integration step. (output.lattice.z) |
zplot | m | (390,) | For plotting the beam or field parameters along the undulator. (output.lattice.zplot) |
Fields¶
Field files can be very large and are made readily available for lazy loading.
Loaded fields are present in .field
attribute of the output:
list(G.output.field3d)
[]
For convenience, fields and particles may be automatically loaded after a run by using run(load_fields=True, load_particles=True)
instead.
Otherwise, these can be manually loaded individually or all at once:
G.output.load_fields()
['end']
list(G.output.field3d)
['end']
This field data has two parts: basic parameters param
, and the raw 3D complex array dfl
:
G.output.field3d["end"].param
FieldFileParams( gridpoints=101, gridsize=2e-06, wavelength=1.3789244869952112e-10, slicecount=544, slicespacing=2.7578489739904225e-08, )
G.output.field3d["end"].dfl.shape
(101, 101, 544)
.field
is a convenience property that points to this
G.output.field3d["end"].param
FieldFileParams( gridpoints=101, gridsize=2e-06, wavelength=1.3789244869952112e-10, slicecount=544, slicespacing=2.7578489739904225e-08, )
Visualize Field¶
# Sum over y and compute the absolute square
dfl = G.output.field3d["end"].dfl
param = G.output.field3d["end"].param
dat2 = np.abs(np.sum(dfl, axis=1)) ** 2
plt.imshow(dat2)
<matplotlib.image.AxesImage at 0x7f488ba49160>
def plot_slice(i=0):
dat = np.angle(dfl[:, :, i])
dx = param.gridsize * 1e6
plt.xlabel("x (µm)")
plt.xlabel("y (µm)")
plt.title(f"Phase for slize {i}")
plt.imshow(dat.T, origin="lower", extent=[-dx, dx, -dx, dx])
plot_slice(i=100)
Particles¶
Particle files can be read in as openPMD-beamphysics ParticleGroup
objects.
These are loaded only on-demand by default (run(load_particles=False)
). They may also be loaded all at once, with load_particles()
.
list(G.output.particle_files)
['end']
G.output.load_particles()
['end']
After loading particles, use the .particles
attribute to access their data:
G.output.particles
{'end': <ParticleGroup with 557056 particles at 0x7f488ba4b230>}
P = G.output.particles["end"]
P.plot("z", "energy")
Change to z coordinates to see the current. Note that the head of the bunch is now on the left.
P.drift_to_z()
P.plot("t", "energy")
Check some statistics
P["norm_emit_x"], P["norm_emit_y"], P["mean_gamma"]
(np.float64(4.000048858981104e-07), np.float64(4.0000677465464084e-07), np.float64(19174.078131770453))
Bunching¶
wavelength = G.input.main.setup.lambda0
bunching_key = f"bunching_{wavelength}"
P.drift_to_t()
P.slice_plot(bunching_key, n_slice=1000)
# Genesis4 data
final_bunching = G.output.beam.bunching[-1, :]
current = G.output.beam.current[-1, :]
s = G.output.globals.s
# ParticleGroup data
ss = P.slice_statistics(bunching_key, n_slice=len(s))
ss.keys()
x = ss["mean_z"]
y = ss[bunching_key]
Compare
fig, ax = plt.subplots()
ax.plot(x * 1e6, y, label="ParticleGroup")
ax.plot(s * 1e6, final_bunching, "--", label="Genesis4 output")
ax.set_xlabel("s (µm)")
ax.set_ylabel("bunching")
plt.legend()
<matplotlib.legend.Legend at 0x7f488bbde660>
This is the average bunching from the ParticleGroup:
P.bunching(wavelength)
np.complex128(-5.164069315109893e-05+5.012701108232233e-05j)
That agrees with the appropriate averaging of Genesis4's bunching calc:
G.stat("bunching")[-1]
np.float64(7.196859337842971e-05)
G.plot("bunching")
Check the total charge in pC:
P["charge"] / 1e-12 # pC
np.float64(50.1584225612439)
Units¶
Each item in the output class should have corresponding units.
G.output.units("beam_betax")
pmd_unit('m', 1, (1, 0, 0, 0, 0, 0, 0))
Plotting¶
Convenient plotting of the data in .output
is provided by .plot
. The default is to plot the power. Depending on the key these statistics are averaged or integrated over the slices. Some keys like power
are converted to peak_power
, while field_energy
is the integral over field_power
.
print(G.output.alias["power"])
field.power
G.plot()
Left and right axes can be set this way:
G.plot("field_energy", yscale="log", y2=["beam_xsize", "beam_ysize"], ylim2=(0, 100e-6))
By default, these plots average over slices. In the case of beam sizes, simply averaging these does not take into account the effect of misaligned slices. To plot this, LUME-Genesis provides additional beam_sigma_x
, beam_sima_y
, beam_sigma_energy
keys that properly project these quantities. The difference is noticable in the energy spread calculation:
G.plot(["beam_sigma_energy", "beam_energyspread"], ylim=(0, 100))
The field slice statistics are power-weighted averages:
G.plot(["field_xsize", "field_ysize"])
plt.imshow(G.output.field.power, aspect="auto");
Archiving¶
G.archive("archived.h5")
Grestored = Genesis4.from_archive("archived.h5")
Grestored.output.plot()
Check that the restored object is the same¶
The Genesis4 object as well as the input, output, and all namelists support equality checks:
Grestored == G
True
Grestored.input == G.input
True
Grestored.output == G.output
True
Manual loading of Genesis4 data¶
Sometimes it is necessary to run Genesis4 manually, and load the output into LUME-Genesis for further analysis.
First, let's create some input to run in a local directory temp/
:
import os
os.makedirs("temp/", exist_ok=True)
G.write_input("temp/")
Now run on the command line:
!cd temp; ./run | tee log.txt
--------------------------------------------- GENESIS - Version 4.6.7 has started... Compile info: Compiled by conda at 2024-12-09 17:34:26 [UTC] from Git Commit ID: f166211af8ded3543c5b983d3d6d8680af6ab767 Starting Time: Mon Jan 6 22:17:29 2025 MPI-Comm Size: 2 nodes Opened input file genesis4.in Parsing lattice file hxr.lat ... Setting up time window of 15.0027 microns with 544 sample points... Generating input radiation field for HARM = 1 ...
Adding profile with label: beamcurrent Adding profile with label: beamgamma Generating input particle distribution...
Running Core Simulation... Time-dependent run with 544 slices for a time window of 15.0027 microns Initial analysis of electron beam and radiation field...
Calculation: 0% done
Calculation: 10% done
Calculation: 20% done
Calculation: 30% done
Calculation: 40% done
Calculation: 50% done
Calculation: 60% done
Calculation: 70% done
Calculation: 80% done
Calculation: 90% done
Calculation: 100% done
Calculation: 110% done
Calculation terminated due to requested stop. Writing output file...
Core Simulation done. End of Track Writing field distribution to file: end.fld.h5 ...
Writing particle distribution to file: end.par.h5 ...
Program is terminating... Ending Time: Mon Jan 6 22:19:11 2025 Total Wall Clock Time: 101.906 seconds -------------------------------------
Using the use_temp_dir=False
and workdir
options, the input and output data can be loaded into a new Genesis4 object:
G2 = Genesis4("genesis4.in", use_temp_dir=False, workdir="temp/", verbose=True)
G2.configure()
output = G2.load_output()
Configured to run in: temp/
output.plot()
Cleanup¶
import shutil
shutil.rmtree("temp")
os.remove("archived.h5")