Running Genesis4¶
In [1]:
Copied!
import genesis.version4 as g4
%config InlineBackend.figure_format = 'retina' # Nicer plots
import genesis.version4 as g4
%config InlineBackend.figure_format = 'retina' # Nicer plots
Create the main input and lattice¶
In [2]:
Copied!
main = g4.MainInput(
[
g4.Setup(
rootname="Example1",
beamline="FEL",
gamma0=11357.82,
delz=0.045,
nbins=8,
shotnoise=False,
),
g4.LatticeNamelist(zmatch=9.5),
g4.Field(power=5000.0, waist_size=3e-05, dgrid=0.0002, ngrid=255),
g4.Beam(delgam=1.0, current=3000.0, ex=4e-07, ey=4e-07),
g4.Track(),
],
)
lattice = g4.Lattice(
{
"D1": g4.Drift(L=0.44),
"D2": g4.Drift(L=0.24),
"FEL": g4.Line(elements=["FODO"] * 6),
"FODO": g4.Line(
elements=["UND", "D1", "QF", "D2", "UND", "D1", "QD", "D2"],
),
"QD": g4.Quadrupole(L=0.08, k1=-2.0),
"QF": g4.Quadrupole(L=0.08, k1=2.0),
"UND": g4.Undulator(aw=0.84853, lambdau=0.015, nwig=266, helical=True),
}
)
main = g4.MainInput(
[
g4.Setup(
rootname="Example1",
beamline="FEL",
gamma0=11357.82,
delz=0.045,
nbins=8,
shotnoise=False,
),
g4.LatticeNamelist(zmatch=9.5),
g4.Field(power=5000.0, waist_size=3e-05, dgrid=0.0002, ngrid=255),
g4.Beam(delgam=1.0, current=3000.0, ex=4e-07, ey=4e-07),
g4.Track(),
],
)
lattice = g4.Lattice(
{
"D1": g4.Drift(L=0.44),
"D2": g4.Drift(L=0.24),
"FEL": g4.Line(elements=["FODO"] * 6),
"FODO": g4.Line(
elements=["UND", "D1", "QF", "D2", "UND", "D1", "QD", "D2"],
),
"QD": g4.Quadrupole(L=0.08, k1=-2.0),
"QF": g4.Quadrupole(L=0.08, k1=2.0),
"UND": g4.Undulator(aw=0.84853, lambdau=0.015, nwig=266, helical=True),
}
)
Run without verbose output¶
In [3]:
Copied!
G = g4.Genesis4(main, lattice, verbose=False)
G = g4.Genesis4(main, lattice, verbose=False)
In [4]:
Copied!
output = G.run()
output = G.run()
In [5]:
Copied!
G.plot(["beam_xsize", "beam_ysize", "field_xsize", "field_ysize"])
G.plot(["beam_xsize", "beam_ysize", "field_xsize", "field_ysize"])
In [6]:
Copied!
output.info()
output.info()
Out[6]:
| Key | Units | Shape | Description |
|---|---|---|---|
| alphax | rad | (1, 1) | Twiss alpha horizontal. Evaluated only at the beginning. (output.beam.alphax) |
| alphay | rad | (1, 1) | Twiss alpha vertical. Evaluated only at the beginning. (output.beam.alphay) |
| aw | (1104,) | 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 | (1104,) | Offset of the undulator module in $x$. (output.lattice.ax) |
| ay | m | (1104,) | Offset of the undulator module in $y$. (output.lattice.ay) |
| beam_alphax | rad | (1, 1) | Twiss alpha horizontal. Evaluated only at the beginning. (output.beam.alphax) |
| beam_alphay | rad | (1, 1) | Twiss alpha vertical. Evaluated only at the beginning. (output.beam.alphay) |
| beam_betax | m | (1, 1) | Twiss beta horizontal. Evaluated only at the beginning. (output.beam.betax) |
| beam_betay | m | (1, 1) | Twiss beta vertical. Evaluated only at the beginning. (output.beam.betay) |
| beam_bunching | (1105, 1) | Evaluated at each integration step. [unitless] (output.beam.bunching) | |
| beam_bunchingphase | rad | (1105, 1) | Evaluated at each integration step. (output.beam.bunchingphase) |
| beam_current | A | (1, 1) | Beam current. Evaluated only at the beginning. (output.beam.current) |
| beam_efield | eV/m | (1105, 1) | Efield, internally eloss+longESC (output.beam.efield) |
| beam_emax | eV | (1105, 1) | Particle energy maximum. Genesis4 mc^2 units are automatically converted to eV in LUME-Genesis. (output.beam.emax) |
| beam_emin | eV | (1105, 1) | Particle energy minimum. Genesis4 mc^2 units are automatically converted to eV in LUME-Genesis. (output.beam.emin) |
| beam_emitx | m | (1, 1) | Beam horizontal emittance. Evaluated only at the beginning. (output.beam.emitx) |
| beam_emity | m | (1, 1) | Beam vertical emittance. Evaluated only at the beginning. (output.beam.emity) |
| beam_energy | eV | (1105, 1) | Evaluated at each integration step. Genesis4 mc^2 units are automatically converted to eV in LUME-Genesis. (output.beam.energy) |
| beam_energyspread | eV | (1105, 1) | 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 | (1105, 1) | Longitudinal space charge (output.beam.lsc_field) |
| beam_pxmax | rad | (1105, 1) | Particle horizontal maximum momentum (output.beam.pxmax) |
| beam_pxmin | rad | (1105, 1) | Particle horizontal minimum momentum (output.beam.pxmin) |
| beam_pxposition | rad | (1105, 1) | Particle horizontal position in momentum space (output.beam.pxposition) |
| beam_pymax | rad | (1105, 1) | Particle vertical maximum momentum (output.beam.pymax) |
| beam_pymin | rad | (1105, 1) | Particle vertical minimum momentum (output.beam.pymin) |
| beam_pyposition | rad | (1105, 1) | Particle vertical position in momentum space (output.beam.pyposition) |
| beam_sigma_energy | eV | (1105,) | Average beam energy (output.beam.stat.sigma_energy) |
| beam_sigma_x | m | (1105,) | Projected RMS beam size in X (output.beam.stat.sigma_x) |
| beam_sigma_y | m | (1105,) | Projected RMS beam size in Y (output.beam.stat.sigma_y) |
| beam_ssc_field | eV/m | (1105, 1) | 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 | (1105,) | Bunching - see `OutputBeamStat.calculate_bunching` method for details. (output.beam.stat.bunching) | |
| beam_stat_bunchingphase | rad | (1105,) | 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 | (1105,) | 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 | (1105,) | Slice-averaged by current energy (output.beam.stat.energy) |
| beam_stat_energyspread | eV | (1105,) | Slice-averaged by current energy spread (output.beam.stat.energyspread) |
| beam_stat_lsc_field | eV/m | (1105,) | Slice-averaged by current longitudinal space charge (output.beam.stat.lsc_field) |
| beam_stat_pxmax | rad | (1105,) | Slice-averaged by current particle horizontal maximum momentum (output.beam.stat.pxmax) |
| beam_stat_pxmin | rad | (1105,) | Slice-averaged by current particle horizontal minimum momentum (output.beam.stat.pxmin) |
| beam_stat_pxposition | rad | (1105,) | Slice-averaged by current particle horizontal position in momentum space (output.beam.stat.pxposition) |
| beam_stat_pymax | rad | (1105,) | Slice-averaged by current particle vertical maximum momentum (output.beam.stat.pymax) |
| beam_stat_pymin | rad | (1105,) | Slice-averaged by current particle vertical minimum momentum (output.beam.stat.pymin) |
| beam_stat_pyposition | rad | (1105,) | Slice-averaged by current particle vertical position in momentum space (output.beam.stat.pyposition) |
| beam_stat_sigma_energy | eV | (1105,) | Average beam energy (output.beam.stat.sigma_energy) |
| beam_stat_sigma_x | m | (1105,) | Projected RMS beam size in X (output.beam.stat.sigma_x) |
| beam_stat_sigma_y | m | (1105,) | Projected RMS beam size in Y (output.beam.stat.sigma_y) |
| beam_stat_ssc_field | eV/m | (1105,) | Slice-averaged by energy short-range space charge (output.beam.stat.ssc_field) |
| beam_stat_wakefield | eV/m | (1105,) | Slice-averaged by energy wakefield, internally the energy loss. (output.beam.stat.wakefield) |
| beam_stat_xmax | m | (1105,) | Maximum over all slices of particle horizontal minimum position (output.beam.stat.xmax) |
| beam_stat_xmin | m | (1105,) | Minimum over all slices of particle horizontal minimum position (output.beam.stat.xmin) |
| beam_stat_xposition | m | (1105,) | Slice-averaged by current particle horizontal position (output.beam.stat.xposition) |
| beam_stat_ymax | m | (1105,) | Slice-averaged by current particle vertical maximum position (output.beam.stat.ymax) |
| beam_stat_ymin | m | (1105,) | Slice-averaged by current particle vertical minimum position (output.beam.stat.ymin) |
| beam_stat_yposition | m | (1105,) | Slice-averaged by current particle vertical position (output.beam.stat.yposition) |
| beam_wakefield | eV/m | (1105, 1) | Wakefield, internally the energy loss. (output.beam.wakefield) |
| beam_xmax | m | (1105, 1) | Particle horizontal maximum position (output.beam.xmax) |
| beam_xmin | m | (1105, 1) | Particle horizontal minimum position (output.beam.xmin) |
| beam_xposition | m | (1105, 1) | Particle horizontal position (output.beam.xposition) |
| beam_xsize | m | (1105, 1) | Beam horizontal sigma. (output.beam.xsize) |
| beam_ymax | m | (1105, 1) | Particle vertical maximum position (output.beam.ymax) |
| beam_ymin | m | (1105, 1) | Particle vertical minimum position (output.beam.ymin) |
| beam_yposition | m | (1105, 1) | Particle vertical position (output.beam.yposition) |
| beam_ysize | m | (1105, 1) | Beam horizontal sigma. (output.beam.ysize) |
| betax | m | (1, 1) | Twiss beta horizontal. Evaluated only at the beginning. (output.beam.betax) |
| betay | m | (1, 1) | Twiss beta vertical. Evaluated only at the beginning. (output.beam.betay) |
| bunching | (1105, 1) | Evaluated at each integration step. [unitless] (output.beam.bunching) | |
| bunchingphase | rad | (1105, 1) | Evaluated at each integration step. (output.beam.bunchingphase) |
| chic_angle | degree | (1104,) | Chicane angle (output.lattice.chic_angle) |
| chic_lb | m | (1104,) | Length of an individual dipole in meter. (output.lattice.chic_lb) |
| chic_ld | m | (1104,) | 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 | (1104,) | Chicane length (output.lattice.chic_lt) |
| current | A | (1, 1) | Beam current. Evaluated only at the beginning. (output.beam.current) |
| cx | rad | (1104,) | Kick angle in $x$ in units of $\gamma \beta_x$. (output.lattice.cx) |
| cy | rad | (1104,) | Kick angle in $y$ in units of $\gamma \beta_y$. (output.lattice.cy) |
| dz | m | (1104,) | Step length (output.lattice.dz) |
| efield | eV/m | (1105, 1) | Efield, internally eloss+longESC (output.beam.efield) |
| emax | eV | (1105, 1) | Particle energy maximum. Genesis4 mc^2 units are automatically converted to eV in LUME-Genesis. (output.beam.emax) |
| emin | eV | (1105, 1) | Particle energy minimum. Genesis4 mc^2 units are automatically converted to eV in LUME-Genesis. (output.beam.emin) |
| emitx | m | (1, 1) | Beam horizontal emittance. Evaluated only at the beginning. (output.beam.emitx) |
| emity | m | (1, 1) | Beam vertical emittance. Evaluated only at the beginning. (output.beam.emity) |
| field1_energy | J | (1105,) | 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 | (1105, 1) | Field intensity in the far field [arb units] (output.field.intensity_farfield) |
| field1_intensity_nearfield | W/m^2 | (1105, 1) | Field intensity in the near field [arb units] (output.field.intensity_nearfield) |
| field1_peak_power | W | (1105,) | Peak power . (output.field.peak_power) |
| field1_phase_farfield | rad | (1105, 1) | Far field phase (output.field.phase_farfield) |
| field1_phase_nearfield | rad | (1105, 1) | Near field phase (output.field.phase_nearfield) |
| field1_power | W | (1105, 1) | Power (output.field.power) |
| field1_stat_energy | J | (1105,) | Power-weighted energy (output.field.stat.energy) |
| field1_stat_intensity_farfield | W/rad^2 | (1105,) | Power-weighted field intensity in the far field [arb units] (output.field.stat.intensity_farfield) |
| field1_stat_intensity_nearfield | W/m^2 | (1105,) | Power-weighted field intensity in the near field [arb units] (output.field.stat.intensity_nearfield) |
| field1_stat_phase_farfield | rad | (1105,) | Power-weighted far field phase (output.field.stat.phase_farfield) |
| field1_stat_phase_nearfield | rad | (1105,) | Power-weighted near field phase (output.field.stat.phase_nearfield) |
| field1_stat_power | W | (1105,) | Power (output.field.stat.power) |
| field1_stat_xdivergence | rad | (1105,) | Power-weighted horizontal divergence (output.field.stat.xdivergence) |
| field1_stat_xpointing | rad | (1105,) | Power-weighted horizontal pointing. (output.field.stat.xpointing) |
| field1_stat_xposition | m | (1105,) | Power-weighted horizontal position. (output.field.stat.xposition) |
| field1_stat_xsize | m | (1105,) | Power-weighted horizontal sigma. (output.field.stat.xsize) |
| field1_stat_ydivergence | rad | (1105,) | Power-weighted vertical divergence (output.field.stat.ydivergence) |
| field1_stat_ypointing | rad | (1105,) | Power-weighted vertical pointing. (output.field.stat.ypointing) |
| field1_stat_yposition | m | (1105,) | Power-weighted vertical position. (output.field.stat.yposition) |
| field1_stat_ysize | m | (1105,) | Power-weighted vertical sigma. (output.field.stat.ysize) |
| field1_xdivergence | rad | (1105, 1) | Horizontal divergence (output.field.xdivergence) |
| field1_xpointing | rad | (1105, 1) | Horizontal pointing. (output.field.xpointing) |
| field1_xposition | m | (1105, 1) | Horizontal position. (output.field.xposition) |
| field1_xsize | m | (1105, 1) | Horizontal sigma. (output.field.xsize) |
| field1_ydivergence | rad | (1105, 1) | Vertical divergence (output.field.ydivergence) |
| field1_ypointing | rad | (1105, 1) | Vertical pointing. (output.field.ypointing) |
| field1_yposition | m | (1105, 1) | Vertical position. (output.field.yposition) |
| field1_ysize | m | (1105, 1) | Vertical sigma. (output.field.ysize) |
| field_energy | J | (1105,) | 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 | (1105, 1) | Field intensity in the far field [arb units] (output.field.intensity_farfield) |
| field_intensity_nearfield | W/m^2 | (1105, 1) | Field intensity in the near field [arb units] (output.field.intensity_nearfield) |
| field_peak_power | W | (1105,) | Peak power . (output.field.peak_power) |
| field_phase_farfield | rad | (1105, 1) | Far field phase (output.field.phase_farfield) |
| field_phase_nearfield | rad | (1105, 1) | Near field phase (output.field.phase_nearfield) |
| field_power | W | (1105, 1) | Power (output.field.power) |
| field_stat_energy | J | (1105,) | Power-weighted energy (output.field.stat.energy) |
| field_stat_intensity_farfield | W/rad^2 | (1105,) | Power-weighted field intensity in the far field [arb units] (output.field.stat.intensity_farfield) |
| field_stat_intensity_nearfield | W/m^2 | (1105,) | Power-weighted field intensity in the near field [arb units] (output.field.stat.intensity_nearfield) |
| field_stat_phase_farfield | rad | (1105,) | Power-weighted far field phase (output.field.stat.phase_farfield) |
| field_stat_phase_nearfield | rad | (1105,) | Power-weighted near field phase (output.field.stat.phase_nearfield) |
| field_stat_power | W | (1105,) | Power (output.field.stat.power) |
| field_stat_xdivergence | rad | (1105,) | Power-weighted horizontal divergence (output.field.stat.xdivergence) |
| field_stat_xpointing | rad | (1105,) | Power-weighted horizontal pointing. (output.field.stat.xpointing) |
| field_stat_xposition | m | (1105,) | Power-weighted horizontal position. (output.field.stat.xposition) |
| field_stat_xsize | m | (1105,) | Power-weighted horizontal sigma. (output.field.stat.xsize) |
| field_stat_ydivergence | rad | (1105,) | Power-weighted vertical divergence (output.field.stat.ydivergence) |
| field_stat_ypointing | rad | (1105,) | Power-weighted vertical pointing. (output.field.stat.ypointing) |
| field_stat_yposition | m | (1105,) | Power-weighted vertical position. (output.field.stat.yposition) |
| field_stat_ysize | m | (1105,) | Power-weighted vertical sigma. (output.field.stat.ysize) |
| field_xdivergence | rad | (1105, 1) | Horizontal divergence (output.field.xdivergence) |
| field_xpointing | rad | (1105, 1) | Horizontal pointing. (output.field.xpointing) |
| field_xposition | m | (1105, 1) | Horizontal position. (output.field.xposition) |
| field_xsize | m | (1105, 1) | Horizontal sigma. (output.field.xsize) |
| field_ydivergence | rad | (1105, 1) | Vertical divergence (output.field.ydivergence) |
| field_ypointing | rad | (1105, 1) | Vertical pointing. (output.field.ypointing) |
| field_yposition | m | (1105, 1) | Vertical position. (output.field.yposition) |
| field_ysize | m | (1105, 1) | Vertical sigma. (output.field.ysize) |
| frequency | eV | (1,) | Frequency (output.globals.frequency) |
| globals_frequency | eV | (1,) | Frequency (output.globals.frequency) |
| globals_s | m | (1,) | Longitudinal position (output.globals.s) |
| gradx | 1/m | (1104,) | Relative transverse gradient of undulator field in $x$ $\equiv (1/a_w) \partial a_w/\partial x$. (output.lattice.gradx) |
| grady | 1/m | (1104,) | Relative transverse gradient of undulator field in $y$ $\equiv (1/a_w) \partial a_w/\partial y$. (output.lattice.grady) |
| ku | 1/m | (1104,) | Ku (output.lattice.ku) |
| kx | (1104,) | 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 | (1104,) | Roll-off parameter of the quadratic term of the undulator field in y. (output.lattice.ky) | |
| lattice_aw | (1104,) | 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 | (1104,) | Offset of the undulator module in $x$. (output.lattice.ax) |
| lattice_ay | m | (1104,) | Offset of the undulator module in $y$. (output.lattice.ay) |
| lattice_chic_angle | degree | (1104,) | Chicane angle (output.lattice.chic_angle) |
| lattice_chic_lb | m | (1104,) | Length of an individual dipole in meter. (output.lattice.chic_lb) |
| lattice_chic_ld | m | (1104,) | 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 | (1104,) | Chicane length (output.lattice.chic_lt) |
| lattice_cx | rad | (1104,) | Kick angle in $x$ in units of $\gamma \beta_x$. (output.lattice.cx) |
| lattice_cy | rad | (1104,) | Kick angle in $y$ in units of $\gamma \beta_y$. (output.lattice.cy) |
| lattice_dz | m | (1104,) | Step length (output.lattice.dz) |
| lattice_gradx | 1/m | (1104,) | Relative transverse gradient of undulator field in $x$ $\equiv (1/a_w) \partial a_w/\partial x$. (output.lattice.gradx) |
| lattice_grady | 1/m | (1104,) | Relative transverse gradient of undulator field in $y$ $\equiv (1/a_w) \partial a_w/\partial y$. (output.lattice.grady) |
| lattice_ku | 1/m | (1104,) | Ku (output.lattice.ku) |
| lattice_kx | (1104,) | 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 | (1104,) | Roll-off parameter of the quadratic term of the undulator field in y. (output.lattice.ky) | |
| lattice_phaseshift | rad | (1104,) | Phase shift in radians. (output.lattice.phaseshift) |
| lattice_qf | 1/m^2 | (1104,) | Quadrupole focusing strength in $1/m^2$ (output.lattice.qf) |
| lattice_qx | m | (1104,) | Quadrupole offset in $x$ in meters. (output.lattice.qx) |
| lattice_qy | m | (1104,) | Quadrupole offset in $y$ in meters. (output.lattice.qy) |
| lattice_slippage | (1104,) | Lattice slippage. [1] (output.lattice.slippage) | |
| lattice_z | m | (1104,) | 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 | (1105,) | For plotting the beam or field parameters along the undulator. (output.lattice.zplot) |
| lsc_field | eV/m | (1105, 1) | 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 | (1105,) | Peak power . (output.field.peak_power) |
| phase_farfield | rad | (1105, 1) | Far field phase (output.field.phase_farfield) |
| phase_nearfield | rad | (1105, 1) | Near field phase (output.field.phase_nearfield) |
| phaseshift | rad | (1104,) | Phase shift in radians. (output.lattice.phaseshift) |
| power | W | (1105, 1) | Power (output.field.power) |
| pxmax | rad | (1105, 1) | Particle horizontal maximum momentum (output.beam.pxmax) |
| pxmin | rad | (1105, 1) | Particle horizontal minimum momentum (output.beam.pxmin) |
| pxposition | rad | (1105, 1) | Particle horizontal position in momentum space (output.beam.pxposition) |
| pymax | rad | (1105, 1) | Particle vertical maximum momentum (output.beam.pymax) |
| pymin | rad | (1105, 1) | Particle vertical minimum momentum (output.beam.pymin) |
| pyposition | rad | (1105, 1) | Particle vertical position in momentum space (output.beam.pyposition) |
| qf | 1/m^2 | (1104,) | Quadrupole focusing strength in $1/m^2$ (output.lattice.qf) |
| qx | m | (1104,) | Quadrupole offset in $x$ in meters. (output.lattice.qx) |
| qy | m | (1104,) | Quadrupole offset in $y$ in meters. (output.lattice.qy) |
| s | m | (1,) | Longitudinal position (output.globals.s) |
| slippage | (1104,) | Lattice slippage. [1] (output.lattice.slippage) | |
| ssc_field | eV/m | (1105, 1) | Short-range space charge (output.beam.ssc_field) |
| wakefield | eV/m | (1105, 1) | Wakefield, internally the energy loss. (output.beam.wakefield) |
| xmax | m | (1105, 1) | Particle horizontal maximum position (output.beam.xmax) |
| xmin | m | (1105, 1) | Particle horizontal minimum position (output.beam.xmin) |
| ymax | m | (1105, 1) | Particle vertical maximum position (output.beam.ymax) |
| ymin | m | (1105, 1) | Particle vertical minimum position (output.beam.ymin) |
| z | m | (1104,) | 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 | (1105,) | For plotting the beam or field parameters along the undulator. (output.lattice.zplot) |
In [7]:
Copied!
output["beam_energy"]
output["beam_energy"]
Out[7]:
array([[5.80383410e+09],
[5.80383410e+09],
[5.80383410e+09],
...,
[5.80353021e+09],
[5.80353021e+09],
[5.80353021e+09]], shape=(1105, 1))
We can still access the output in output.run.output_log:
In [8]:
Copied!
print(output.run.output_log[:200], "...")
print(output.run.output_log[:200], "...")
--------------------------------------------- GENESIS - Version 4.6.10 has started... Compile info: Compiled by conda at 2025-09-29 14:31:23 [UTC] from Git Commit ID: ab50470cb72f55c8aa5849ebff9d6fe42 ...
Run with verbose output¶
This allows you to monitor Genesis4 as it runs.
In [9]:
Copied!
G.verbose = True
output = G.run()
G.verbose = True
output = G.run()
Running Genesis4 in /tmp/tmplliqgn51 /home/runner/miniconda3/envs/lume-genesis-dev/bin/genesis4 -l genesis.lat genesis4.in
--------------------------------------------- GENESIS - Version 4.6.10 has started... Compile info: Compiled by conda at 2025-09-29 14:31:23 [UTC] from Git Commit ID: ab50470cb72f55c8aa5849ebff9d6fe424284c27 Starting Time: Wed Nov 19 18:59:59 2025 MPI-Comm Size: 1 node Opened input file genesis4.in Parsing lattice file genesis.lat ... Matching for periodic solution between z = 0 and z = 9.5 : betax (m) : 8.53711 alphax : -0.703306 phix (deg): 45.818 betay (m) : 17.3899 alphay : 1.40348 phiy (deg): 45.818 Generating input radiation field for HARM = 1 ... Generating input particle distribution... Running Core Simulation... Steady-state run 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 Writing output file... Core Simulation done. End of Track Program is terminating... Ending Time: Wed Nov 19 19:00:06 2025 Total Wall Clock Time: 6.95328 seconds ------------------------------------- Success - execution took 8.14s.
Configure MPI for running on your machine¶
By default, Genesis4 objects are configured to use 1 processor (G.nproc = 1).
To run Genesis4 with MPI, we first need to tell it how many processors to use. To run on 8 cores, we could simply set:
G.nproc = 8
A special value of 0 or None will tell LUME-Genesis to use all available processor cores on your machine:
G.nproc = 0
We'll use that convenient value below.
In [10]:
Copied!
G.nproc = 0
output = G.run()
G.nproc = 0
output = G.run()
Setting use_mpi = True because nproc = 2 Running Genesis4 in /tmp/tmplliqgn51 /home/runner/miniconda3/envs/lume-genesis-dev/bin/mpirun -n 2 /home/runner/miniconda3/envs/lume-genesis-dev/bin/genesis4 -l genesis.lat genesis4.in
--------------------------------------------- GENESIS - Version 4.6.10 has started... Compile info: Compiled by conda at 2025-09-29 14:31:23 [UTC] from Git Commit ID: ab50470cb72f55c8aa5849ebff9d6fe424284c27 Starting Time: Wed Nov 19 19:00:07 2025 MPI-Comm Size: 2 nodes Opened input file genesis4.in Parsing lattice file genesis.lat ... Matching for periodic solution between z = 0 and z = 9.5 : betax (m) : 8.53711 alphax : -0.703306 phix (deg): 45.818 betay (m) : 17.3899 alphay : 1.40348 phiy (deg): 45.818 Generating input radiation field for HARM = 1 ... Generating input particle distribution... Running Core Simulation... Steady-state run 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 Writing output file... Core Simulation done. End of Track Program is terminating... Ending Time: Wed Nov 19 19:00:14 2025 Total Wall Clock Time: 7.1717 seconds -------------------------------------
Success - execution took 8.42s.
We should see the "MPI-Comm size" as the number of processor cores used by Genesis4 in the output:
In [11]:
Copied!
for line in G.output.run.output_log.splitlines():
if "MPI" in line:
print(line)
for line in G.output.run.output_log.splitlines():
if "MPI" in line:
print(line)
MPI-Comm Size: 2 nodes
In [12]:
Copied!
output.run.to_table()
output.run.to_table()
Out[12]:
| Attribute | Value | Type | Description |
|---|---|---|---|
| error | False | bool | `True` if an error occurred during the Genesis run |
| error_reason | str | None | Error explanation, if `error` is set. | |
| run_script | /home/runner/miniconda3/envs/lume-genesis-dev/bin/mpirun -n 2 /home/runner/miniconda3/envs/lume-gene... | str | The command-line arguments used to run Genesis |
| run_time | 8.423039753000012 | float | Wall clock run time of the process |