Coder Social home page Coder Social logo

zhujun98 / liso Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 3.0 2.25 MB

Python API for beam dynamics simulation, data acquisition, data IO, data processing and optimization for particle accelerators.

Home Page: http://liso.readthedocs.io/en/latest/

License: GNU General Public License v3.0

Python 98.88% Shell 0.66% Jupyter Notebook 0.46%
accelerator-physics particle-accelerator optimization data-acquisition

liso's Introduction

LISO

Lates Release License: GPL v3 Build Status Python package codecov.io Documentation

Author: Jun Zhu, [email protected]

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:

  1. providing a high-level API to run a large numbers of beam dynamics simulations using a combination of different codes;
  2. providing a unified IO for the simulated and experimental data;
  3. providing an interface for deep learning and deep reinforcement learning studies on accelerator physics.

Documentation

The full documentation can be found at

https://liso.readthedocs.io/

Getting started

Installation

$ pip install liso

Use LISO in your experiments

Parameter scan

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)

Reading experimental data from files

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()

Use LISO to run simulations

Building a linac

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')

Running a parameter scan or a jitter study

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()

Reading simulated data from files

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()

Cite LISO

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 = {...}
}

liso's People

Contributors

zhujun98 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.