diff --git a/corsika/modules/sophia/Random.hpp b/corsika/modules/sophia/Random.hpp new file mode 100644 index 0000000000000000000000000000000000000000..3c8c190efe42c73208adf9632b510a55dde81d5a --- /dev/null +++ b/corsika/modules/sophia/Random.hpp @@ -0,0 +1,31 @@ +/* + * (c) Copyright 2022 CORSIKA Project, corsika-project@lists.kit.edu + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#pragma once + +#include <corsika/framework/random/RNGManager.hpp> +#include <random> + +/** + * \file sophia/Random.hpp + * + * This file is an integral part of the sophia interface. It must be + * linked to the executable linked to sophia exactly once + * + */ + +namespace sophia { + + double rndm_interface() { + static corsika::default_prng_type& rng = + corsika::RNGManager<>::getInstance().getRandomStream("sophia"); + std::uniform_real_distribution<double> dist; + return dist(rng); + } + +} // namespace sophia diff --git a/modules/sophia/sophia.cpp b/modules/sophia/sophia.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e52d7d1705badc9cbf9fb79c1e05e889b0042b9a --- /dev/null +++ b/modules/sophia/sophia.cpp @@ -0,0 +1,15 @@ +/* + * (c) Copyright 2022 CORSIKA Project, corsika-project@lists.kit.edu + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#include <sophia.hpp> + +#include <cmath> + +double get_sophia_mass2(int& id) { return so_mass1_.am2[std::abs(id) - 1]; } + +double rndm_(int&) { return ::sophia::rndm_interface(); } diff --git a/modules/sophia/sophia.hpp b/modules/sophia/sophia.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b2564f195cbffca8714bb6f99faf35d363bab952 --- /dev/null +++ b/modules/sophia/sophia.hpp @@ -0,0 +1,91 @@ +/* + * (c) Copyright 2022 CORSIKA Project, corsika-project@lists.kit.edu + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#pragma once + +/** + * \file sophia.hpp + * + * Interface definition to link to sophia library. + * + */ + +namespace sophia { + + /** + * \function sophia::rndm_interface + * + * this is the random number hook to external packages. + * + * CORSIKA8, for example, has to provide an implementation of this. + **/ + double rndm_interface(); + +} // namespace sophia + +//---------------------------------------------- +// C++ interface for the SOPHIA event generator +//---------------------------------------------- +// wrapper + +extern "C" { + +/** + \struct so_plist_ + + SOPHIA particle stack (FORTRAN COMMON) + variables are: np : numer of particles on stack + p : 4momentum + mass of particles on stack + llist : id of particles on stack + **/ +extern struct { + double p[5][2000]; + int llist[2000]; + int np; +} so_plist_; + +extern struct { + double cbr[102]; + int idb[49]; + int kdec[612]; + int lbarp[49]; +} so_csydec_; + +// additional particle stack for the mother particles of unstable particles +// stable particles have entry zero +extern struct { int llist1[2000]; } so_plist1_; + +// tables with particle properties +// charge, strangeness and baryon number +extern struct { + double s_life_[49]; + int ichp[49]; + int istr[49]; + int ibar[49]; +} so_chp_; + +// tables with particle properties +// mass and mass squared +extern struct { + double am[49]; + double am2[49]; +} so_mass1_; + +// sophia main subroutine +void eventgen_(const int&, const double&, const double&, const double&, const int&); + +// print event +void print_event_(int&); + +// decay routine (LA,P0,ND,LL,P) +// void decpar_(const int&, const double*, int&, int*, double*); + +double rndm_(int&); + +double get_sophia_mass2(int&); +}