Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ bench/timing.pkl
config
Untitled*.ipynb
.venv*
fort.*
.timer.out
296 changes: 60 additions & 236 deletions examples/compare_models.ipynb

Large diffs are not rendered by default.

103 changes: 103 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,109 @@ foreach ver, cfg : dpm_cfg
endforeach
endforeach

# ── FLUKA block --------------------------------------------------------
if 'fluka' in enabled_models
# assign environment variable from $FLUPRO, check that the directory it is pointing to exists
fluprod = run_command('sh', '-c', 'echo ${FLUPRO:-}', check: true).stdout().strip()
if fluprod == ''
error('FLUKA: Environment variable FLUPRO not set.')
endif
# Check if directory exists using shell command
dir_check = run_command('sh', '-c', 'test -d "' + fluprod + '" && echo "exists" || echo "missing"', check: true).stdout().strip()
if dir_check != 'exists'
error('Directory set by FLUPRO does not exist: ' + fluprod)
endif
fluprod_inc = fluprod + '/flukapro'
fluprod_aamod = fluprod + '/aamodmvax'

# Read DPMVERS from the file
dpm_version = run_command('sh', '-c', 'grep "DPMVERS=" ' +
meson.project_source_root() +
'/../FLUKA/interface/dpmvers | cut -d= -f2', check: true).stdout().strip()
message('FLUKA DPM Version: ' + dpm_version)

flka_src = [
f/'fluka/chromo_fluka.f',
logging_src
]
common_inc += [fluprod_inc, fluprod_aamod]

# Find FLUKA library directories
fluka_lib_dir = fluprod

# Extract all object files from all FLUKA archives and create a combined static library
# Only rebuild when input libraries change

# Inputs
tmp_dir = meson.current_build_dir() / 'fluka_temp_objects'
lib_dpm = fluka_lib_dir / 'interface' / ('libdpmjet' + dpm_version + '.a')
lib_rqmd = fluka_lib_dir / 'latestRQMD' / 'librqmd.a'
lib_hp = fluka_lib_dir / 'libflukahp.a'
lib_dpmx = fluka_lib_dir / 'libdpmmvax.a'
lib_rqmx = fluka_lib_dir / 'librqmdmvax.a'

cmd_script = '''
tmp="@0@"
rm -rf "$tmp"; mkdir -p "$tmp"
cd "$tmp"
ar x "@1@"
ar x "@2@"
ar x "@3@"
ar x "@4@"
ar x "@5@"
ar crs "@OUTPUT@" $(find . -name '*.o' -print)
'''.format(tmp_dir, lib_dpm, lib_rqmd, lib_hp, lib_dpmx, lib_rqmx)

fluka_all = custom_target('fluka_all',
input : [lib_dpm, lib_rqmd, lib_hp, lib_dpmx, lib_rqmx],
output : ['fluka_all.a'],
command: ['sh', '-ceu', cmd_script],
depend_files: [lib_dpm, lib_rqmd, lib_hp, lib_dpmx, lib_rqmx],
build_by_default: false
)
fluka_all_dep = declare_dependency(link_args: [tmp_dir / 'fluka_all.a'])

# Prepare include flags for F2PY wrapper generation
inc_flags = []
foreach d : common_inc
if not d.startswith(meson.project_source_root())
d = meson.project_source_root() / d
endif
inc_flags += '-I' + d
endforeach
inc_str = ' '.join(inc_flags)

# Symbols
fluka_syms = [
'chromo_evtxyz', 'chromo_stpxyz', 'chromo_sgmxyz', 'chromo_fllhep',
'fluka_key', 'random_direction',
'icode_from_pdg', 'pdg_from_icode',
'init_rng_state', 'load_rng_state', 'save_rng_state',
'fluka_rand', 'icode_from_pdg_arr', 'charge_from_pdg_arr',
'fluka_particle_scheme'
]

wrap = custom_target('_fluka'+'_wrap',
output : ['_fluka'+'module.c', '_fluka'+'-f2pywrappers.f', '_fluka'+'.pyf'],
input : flka_src,
command: [py,scripts_dir + 'generate_f2py.py', '_fluka', ','.join(fluka_syms+common_syms),
meson.global_build_root()/'meson-logs', inc_str, ' '.join(common_fargs),
'@OUTDIR@','@INPUT@'],
build_by_default:true)

py.extension_module('_fluka',
sources : [wrap, f2py_obj, files(flka_src + rangen_src + [normal_src])],
include_directories: include_directories(common_inc),
dependencies : [py_dep, numpy_dep, fluka_all_dep],
c_args : common_cargs,
fortran_args : common_fargs + ['-DCHROMO', '-DDPMVER=' + dpm_version],
subdir : 'chromo/models',
install : true,
install_rpath : rpath_tok,
build_rpath : rpath_tok,
)
endif

# ── PYTHIA 8 block (unchanged) ----------------------------------------
cpp_dir = 'src/cpp'
if 'pythia8' in enabled_models
Expand Down
15 changes: 8 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ examples = [
[tool.chromo]
# Enabled models
enabled-models = [
"sib21",
"sib23c01",
"sib23d",
"sib23d_star",
"sib23e",
"sib23e_star",
"sib23c01",
"eposlhc",
"eposlhcr",
"dpmjet_phojet191",
Expand All @@ -81,18 +88,12 @@ enabled-models = [
"qgs2_03",
"qgs2_04",
"qgs3",
"sib21",
"sib23c01",
"sib23d",
"sib23d_star",
"sib23e",
"sib23e_star",
"sib23c01",
"sophia",
"pythia6",
"urqmd34",
]
disabled-models = [
"fluka",
]

[tool.mypy]
Expand Down
12 changes: 10 additions & 2 deletions src/chromo/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,14 @@ def fw(self):
"""Quantity needed for invariant cross section histograms."""
return self.en / self.kin.pcm

@property
def name(self):
"""Name of the particle according scikit-hep/pythia naming.

Note that this is a slow convenience function for developing/debugging.
"""
return [Particle.from_pdgid(pid) for pid in self.pid]

def _prepare_for_hepmc(self):
"""
Override this method in classes that need to modify event
Expand Down Expand Up @@ -768,8 +776,8 @@ def _check_kinematics(self, kin):
raise ValueError(msg)
if kin.ecm < self._ecm_min:
msg = (
f"center-of-mass energy {kin.ecm/GeV} GeV < "
f"minimum energy {self._ecm_min/GeV} GeV"
f"center-of-mass energy {kin.ecm / GeV} GeV < "
f"minimum energy {self._ecm_min / GeV} GeV"
)
raise ValueError(msg)

Expand Down
2 changes: 2 additions & 0 deletions src/chromo/models/_extra_models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from chromo.models.dpmjetIII import DpmjetIII193_DEV
from chromo.models.fluka import Fluka
from chromo.models.sibyll import (
Sibyll23c00,
Sibyll23c01,
Expand All @@ -17,6 +18,7 @@
__all__ = (
"DpmjetIII193_DEV",
"DpmjetIII193_DEV",
"Fluka",
"Sibyll23c00",
"Sibyll23c01",
"Sibyll23c02",
Expand Down
Loading
Loading