Author: Jun Zhu, zhujun981661@gmail.com
LISO (LInac Simulation and Optimization) is a library which provides a unified interface for numerical simulations, experiments and data management in the era of big data and artificial intelligence. LISO was initially created only for simulation and optimization back in 2017. After a more than two years interruption, it is live again but aims at:
- providing a high-level API to run a large numbers of beam dynamics simulations using a combination of different codes;
- providing a unified IO for the simulated and experimental data;
- providing an interface for deep learning and deep reinforcement learning studies on accelerator physics.
The full documentation can be found at
$ pip install liso
from liso import EuXFELInterface, MachineScan
from liso import doocs_channels as dc
m = EuXFELInterface()
m.add_control_channel('XFEL.RF/LLRF.CONTROLLER/VS.GUN.I1/PHASE.SAMPLE', dc.FLOAT,
write_address='XFEL.RF/LLRF.CONTROLLER/CTRL.GUN.I1/SP.PHASE')
m.add_control_channel('XFEL.RF/LLRF.CONTROLLER/VS.A1.I1/PHASE.SAMPLE', dc.FLOAT,
write_address='XFEL.RF/LLRF.CONTROLLER/CTRL.A1.I1/SP.PHASE')
m.add_diagnostic_channel('XFEL.DIAG/CAMERA/OTRC.64.I1D/IMAGE_EXT_ZMQ', dc.ARRAY,
shape=(1750, 2330), dtype='uint16')
sc = MachineScan(m)
sc.add_param('XFEL.RF/LLRF.CONTROLLER/VS.GUN.I1/PHASE.SAMPLE', lb=-3, ub=3)
sc.add_param('XFEL.RF/LLRF.CONTROLLER/VS.A1.I1/PHASE.SAMPLE', lb=-3, ub=3)
sc.scan(4000, n_tasks=8)
from liso import open_run
run = open_run('r0001')
# Get an overview of the run
run.info()
# Loop over a run
for pid, data in run:
pass
# Access a single macropulse
# - by id
pid, data = run.from_id(123456789)
# - by index
pid, data = run.from_index(0)
# Access a channel data
ch_data = run.channel('XFEL.RF/LLRF.CONTROLLER/VS.GUN.I1/PHASE.SAMPLE')
# and convert it to a numpy array
ch_data_array = ch_data.numpy()
from liso import Linac
linac = Linac(2000)
linac.add_beamline('astra',
name='injector',
swd='../astra_files',
fin='injector.in',
template='injector.in.000',
pout='injector.0450.001')
from liso import LinacScan
sc = LinacScan(linac)
sc.add_param('gun_gradient', start=120, stop=140, num=10, sigma=-0.001)
sc.add_param('gun_phase', start=-10, stop=10, num=20, sigma=0.1)
sc.scan()
from liso import open_sim
sim = open_sim('./')
# Get an overview of the simulation
sim.info()
# Loop over the simulated data
for sid, data in sim:
pass
# Access a single simulation
# - by id
sid, data = sim.from_id(1)
# - by index
sid, data = sim.from_index(0)
# Access a phasespace data
ch_data = sim.channel('injector/out', ['x', 'px'])
# and convert it to a numpy array
ch_data_array = ch_data.numpy()
A BibTeX entry that you can use to cite it in a publication:
@misc{liso,
Author = {J. Zhu},
Title = {LISO},
Year = {2020},
publisher = {GitHub},
journal = {/~https://github.com/zhujun98/liso},
version = {...}
}