368 using namespace smash;
370 constexpr option longopts[] = {
371 {
"config", required_argument, 0,
'c'},
372 {
"decaymodes", required_argument, 0,
'd'},
373 {
"endtime", required_argument, 0,
'e'},
374 {
"force", no_argument, 0,
'f'},
375 {
"help", no_argument, 0,
'h'},
376 {
"inputfile", required_argument, 0,
'i'},
377 {
"modus", required_argument, 0,
'm'},
378 {
"particles", required_argument, 0,
'p'},
379 {
"output", required_argument, 0,
'o'},
380 {
"list-2-to-n", no_argument, 0,
'l'},
381 {
"resonance", required_argument, 0,
'r'},
382 {
"cross-sections", required_argument, 0,
's'},
383 {
"cross-sections-fs", required_argument, 0,
'S'},
384 {
"dump-iSS", no_argument, 0,
'x'},
385 {
"version", no_argument, 0,
'v'},
386 {
"no-cache", no_argument, 0,
'n'},
387 {
"quiet", no_argument, 0,
'q'},
391 const std::string progname =
392 std::filesystem::path(argv[0]).filename().native();
395 bool force_overwrite =
false;
397 std::string input_path(
"./config.yaml"), particles, decaymodes;
398 std::vector<std::string> extra_config;
399 char *modus =
nullptr, *end_time =
nullptr, *pdg_string =
nullptr,
400 *cs_string =
nullptr;
401 bool list2n_activated =
false;
402 bool resonance_dump_activated =
false;
403 bool cross_section_dump_activated =
false;
404 bool final_state_cross_sections =
false;
405 bool particles_dump_iSS_format =
false;
406 bool cache_integrals =
true;
407 bool suppress_disclaimer =
false;
411 while ((opt = getopt_long(argc, argv,
"c:d:e:fhi:m:p:o:lr:s:S:xvnq",
412 longopts,
nullptr)) != -1) {
415 extra_config.emplace_back(optarg);
421 force_overwrite =
true;
427 usage(EXIT_SUCCESS, progname);
439 output_path = optarg;
442 list2n_activated =
true;
443 suppress_disclaimer =
true;
446 resonance_dump_activated =
true;
448 suppress_disclaimer =
true;
451 final_state_cross_sections =
true;
454 cross_section_dump_activated =
true;
456 suppress_disclaimer =
true;
459 particles_dump_iSS_format =
true;
460 suppress_disclaimer =
true;
468 "System : %s\nCompiler : %s %s\n"
469 "Build : %s\nDate : %s\n",
474 CMAKE_SYSTEM, CMAKE_CXX_COMPILER_ID, CMAKE_CXX_COMPILER_VERSION,
475 CMAKE_BUILD_TYPE, BUILD_DATE);
476 std::exit(EXIT_SUCCESS);
478 cache_integrals =
false;
481 suppress_disclaimer =
true;
484 usage(EXIT_FAILURE, progname);
490 std::cout << argv[0] <<
": invalid argument -- '" << argv[optind]
492 usage(EXIT_FAILURE, progname);
495 if (!suppress_disclaimer) {
500 decaymodes, extra_config);
506 std::string tabulations_path;
507 if (cache_integrals) {
508 tabulations_path = output_path.has_parent_path()
509 ? output_path.parent_path().string()
511 tabulations_path +=
"/tabulations";
513 tabulations_path =
"";
515 const std::string version(SMASH_VERSION);
517 if (list2n_activated) {
520 configuration.merge_yaml(
"{Collision_Term: {Two_to_One: False}}");
528 scat_finder.dump_reactions();
529 std::exit(EXIT_SUCCESS);
531 if (particles_dump_iSS_format) {
534 ParticleTypePtrList list;
537 list.push_back(&ptype);
539 std::sort(list.begin(), list.end(),
541 return a->mass() < b->mass();
544 if (ptype->pdgcode().is_lepton() || ptype->baryon_number() < 0) {
547 const auto &decay_modes = ptype->decay_modes();
548 const auto &modelist = decay_modes.decay_mode_list();
549 int ndecays = ptype->is_stable() ? 1 : modelist.size();
550 std::printf(
"%13i %s %10.5f %10.5f %5i %5i %5i %5i %5i %5i %5i %5i\n",
551 ptype->pdgcode().get_decimal(),
553 ptype->mass(), ptype->width_at_pole(),
554 ptype->pdgcode().spin_degeneracy(), ptype->baryon_number(),
555 ptype->strangeness(), ptype->pdgcode().charmness(),
556 ptype->pdgcode().bottomness(), ptype->isospin() + 1,
557 ptype->charge(), ndecays);
558 if (!ptype->is_stable()) {
559 for (
const auto &decay : modelist) {
560 auto ptypes = decay->particle_types();
561 std::printf(
"%13i %13i %20.5f %13i %13i %13i %13i %13i\n",
562 ptype->pdgcode().get_decimal(), 2, decay->weight(),
563 ptypes[0]->pdgcode().get_decimal(),
564 ptypes[1]->pdgcode().get_decimal(), 0, 0, 0);
567 std::printf(
"%13i %13i %20.5f %13i %13i %13i %13i %13i\n",
568 ptype->pdgcode().get_decimal(), 1, 1.0,
569 ptype->pdgcode().get_decimal(), 0, 0, 0, 0);
572 std::exit(EXIT_SUCCESS);
574 if (resonance_dump_activated) {
585 std::exit(EXIT_SUCCESS);
587 if (cross_section_dump_activated) {
590 std::string arg_string(cs_string);
591 std::vector<std::string> args =
split(arg_string,
',');
592 const unsigned int n_arg = args.size();
593 if (n_arg != 2 && n_arg != 4 && n_arg < 5) {
594 throw std::invalid_argument(
"-s usage: pdg1,pdg2[,m1,m2[,sqrts1,...]]");
596 PdgCode pdg_a(args[0]), pdg_b(args[1]);
600 for (
unsigned int i = 0; i < 4 - n_arg; i++) {
604 double ma = (args[2] ==
"") ? a.
mass() : std::stod(args[2]);
605 double mb = (args[3] ==
"") ? b.
mass() : std::stod(args[3]);
606 if (a.
is_stable() && args[2] !=
"" && std::stod(args[2]) != a.
mass()) {
608 std::cerr <<
"Warning: pole mass is used for stable particle "
609 << a.
name() <<
" instead of " << args[2] << std::endl;
611 if (b.
is_stable() && args[3] !=
"" && std::stod(args[3]) != b.
mass()) {
613 std::cerr <<
"Warning: pole mass is used for stable particle "
614 << b.
name() <<
" instead of " << args[3] << std::endl;
616 const size_t plab_size = n_arg <= 4 ? 0 : n_arg - 4;
617 std::vector<double> plab;
618 plab.reserve(plab_size);
619 for (
size_t i = 4; i < n_arg; i++) {
620 plab.push_back(std::stod(args.at(i)));
627 scat_finder.dump_cross_sections(a, b, ma, mb, final_state_cross_sections,
629 std::exit(EXIT_SUCCESS);
632 configuration.set_value({
"General",
"Modus"}, std::string(modus));
635 configuration.set_value({
"General",
"End_Time"},
636 std::abs(std::atof(end_time)));
639 int64_t seed = configuration.read({
"General",
"Randomseed"});
641 configuration.set_value({
"General",
"Randomseed"},
646 const std::filesystem::path lock_path = output_path /
"smash.lock";
648 if (!lock.acquire()) {
649 throw std::runtime_error(
650 "Another instance of SMASH is already writing to the specified "
651 "output directory. If you are sure this is not the case, remove \"" +
652 lock_path.native() +
"\".");
654 logg[
LMain].debug(
"output path: ", output_path);
655 if (!force_overwrite &&
656 std::filesystem::exists(output_path /
"config.yaml")) {
657 throw std::runtime_error(
658 "Output directory would get overwritten. Select a different output "
659 "directory, clean up, or tell SMASH to ignore existing files.");
664 std::ofstream(output_path /
"config.yaml")
665 <<
"# " << SMASH_VERSION <<
'\n'
667 <<
"# Branch : " << GIT_BRANCH <<
'\n'
669 <<
"# System : " << CMAKE_SYSTEM <<
'\n'
670 <<
"# Compiler : " << CMAKE_CXX_COMPILER_ID <<
' '
671 << CMAKE_CXX_COMPILER_VERSION <<
'\n'
672 <<
"# Build : " << CMAKE_BUILD_TYPE <<
'\n'
673 <<
"# Date : " << BUILD_DATE <<
'\n'
674 << configuration.to_string() <<
'\n';
684 if (configuration.has_value({
"Version"})) {
685 configuration.take({
"Version"});
692 }
catch (std::exception &e) {
693 logg[
LMain].fatal() <<
"SMASH failed with the following error:\n"
static std::unique_ptr< ExperimentBase > create(Configuration &config, const std::filesystem::path &output_path)
Factory method that creates and initializes a new Experiment<Modus>.
Guard to create a file lock.
A pointer-like interface to global references to ParticleType objects.
Particle type contains the static properties of a particle species.
void dump_width_and_spectral_function() const
Prints out width and spectral function versus mass to the standard output.
static const ParticleType & find(PdgCode pdgcode)
Returns the ParticleType object for the given pdgcode.
const std::string & name() const
static const ParticleTypeList & list_all()
PdgCode stores a Particle Data Group Particle Numbering Scheme particle type number.
#define SMASH_SOURCE_LOCATION
Hackery that is required to output the location in the source code where the log statement occurs.
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
std::unique_ptr< ExperimentBase > experiment(Configuration c)
Create an experiment given an input configuration.
void ignore_simulation_config_values(Configuration &configuration)
Remove all config values that are only needed for simulations.
ScatterActionsFinder actions_finder_for_dump(Configuration &configuration)
Prepares ActionsFinder for cross-section and reaction dumps.
void usage(const int rc, const std::string &progname)
Prints usage information and exits the program.
void ensure_path_is_valid(const std::filesystem::path &path)
Ensures the output path is valid.
void check_for_unused_config_values(const Configuration &configuration)
Checks if there are unused config values.
void print_disclaimer()
Print the disclaimer.
std::filesystem::path default_output_path()
int64_t generate_63bit_seed()
Generates a seed with a truly random 63-bit value, if possible.
std::string fill_left(const std::string &s, size_t width, char fill=' ')
Fill string with characters to the left until the given width is reached.
std::vector< std::string > split(const std::string &s, char delim)
Split string by delimiter.
void initialize_particles_decays_and_tabulations(Configuration &configuration, const std::string &version, const std::string &tabulations_dir={})
Initialize the particles and decays from the given configuration, plus tabulate the resonance integra...
Configuration setup_config_and_logging(const std::string &config_file, const std::string &particles_file={}, const std::string &decaymodes_file={}, const std::vector< std::string > &extra_config={})
Set up configuration and logging from input files and extra config.
void setup_default_float_traps()
Setup the floating-point traps used throughout SMASH.
static constexpr int LMain