Giter Club home page Giter Club logo

impy's Introduction

impy - (hadronic) interaction models in python

This package implements are generic user interface to popular event generators used in cosmic ray and high-energy particle physics. The purpose of the package is to simplify working with simulations of particle interactions without the need to use Fortran style interfaces to event generators, 'ASCII input cards' and files or C++ dependencies.

Simulate interactions with one of the supported event generators

from impy.definitions import *
from impy.constants import *
from impy.kinematics import EventKinematics
from impy import impy_config

# Define the parameters of the collisions
event_kinematics = EventKinematics(
    ecm=13 * TeV, p1pdg=2212, p2pdg=2212)

# Create an instance of an event generator by passing
# the model name as a string
generator = make_generator_instance(
    interaction_model_by_tag['SIBYLL2.3D'])

# Initialize it
generator.init_generator(event_kinematics)

# Number of events to generate
nevents = 100

for event in generator.event_generator(event_kinematics, nevents):
    event.filter_final_state_charged()
    # do something with event.p_ids, event.eta, event.en, event.pt, etc.
    # these variables are numpy arrays, that can be histogrammed or counted like
    average_pt += 1/float(nevents)*np.mean(event.pt[np.abs(event.p_ids) == 211])

print('Average pT for charged pions {0:4.3f}'.format(average_pt))

Installation

The package is (will be) available including pre-compiled binaries. The installation in that case simplifies to (this does not work yet use installation from source):

pip install impy

To build from source (the recursive flag is important to checkout the sub-modules):

git clone --recursive https://github.com/afedynitch/impy
cd impy
make -j<insert number of CPU cores>

The package shall be installed in editable mode with pip install -e . and will behave as an ordinary pip package but using this source build.

Because of the architectural transition and there are many issues on mac, building from source may be a bit complicated. Using brew gcc and python it is possible to build the code by:

CC=gcc-10 CXX=gcc-10 FC=gfortran-10 PYTHON_EXE=/usr/local/opt/[email protected]/bin/python3 make -jXXX

Replace gcc-10 by your version in brew. The official Mac Python is currently broken due to th transition to Apple Silicon, but it is possible to build with a bit of hacking. But currently I don't use a Mac and cannot debug it.

Requirements

  • Python 2.7 - 3.9
  • Linux, Mac OS X, or Windows
  • pip
  • particletools
  • numpy
  • scipy
  • pyyaml
  • pyhepmc-ng

User interface

There are two ways to interact with the code.

  1. As in the example above, via plain python in scripts or jupyter notebooks. Look at this example.

  2. Via a HEPMC output that can be piped in Rivet or other tools supporting the format.

Supported models

  • DPMJET-III 3.0.6
  • DPMJET-III 19.1
  • EPOS-LHC
  • PHOJET 1.12-35
  • PHOJET 19.1
  • PYTHIA 6
  • PYTHIA 8 (not yet bundled)
  • QGSJet-01
  • QGSJet-II-03
  • QGSJet-II-04
  • SIBYLL-2.1
  • SIBYLL-2.3
  • SIBYLL-2.3c
  • SIBYLL-2.3d
  • SOPHIA (needs update)
  • DPMJET-II (also needs update but model deprecated)
  • UrQMD 3.4

Authors:

  • Anatoli Fedynitch
  • Hans Dembinski
  • Sonia El Hadri
  • Keito Watanabe

LICENSE

The source code of impy is licensed under the BSD 3-clause license (see LICENSE for detail). The source codes of the event generators are individually licensed under different conditions (see the COPYING files located in the subdirectories).

impy's People

Contributors

afedynitch avatar hdembinski avatar kwat8973 avatar soso128 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.