388 using namespace smash;
390 constexpr option longopts[] = {
391 {
"config", required_argument, 0,
'c'},
392 {
"decaymodes", required_argument, 0,
'd'},
393 {
"endtime", required_argument, 0,
'e'},
394 {
"force", no_argument, 0,
'f'},
395 {
"help", no_argument, 0,
'h'},
396 {
"inputfile", required_argument, 0,
'i'},
397 {
"modus", required_argument, 0,
'm'},
398 {
"particles", required_argument, 0,
'p'},
399 {
"output", required_argument, 0,
'o'},
400 {
"list-2-to-n", no_argument, 0,
'l'},
401 {
"resonance", required_argument, 0,
'r'},
402 {
"cross-sections", required_argument, 0,
's'},
403 {
"cross-sections-fs", required_argument, 0,
'S'},
404 {
"dump-iSS", no_argument, 0,
'x'},
405 {
"version", no_argument, 0,
'v'},
406 {
"no-cache", no_argument, 0,
'n'},
407 {
"quiet", no_argument, 0,
'q'},
411 const std::string progname = bf::path(argv[0]).filename().native();
414 bool force_overwrite =
false;
416 std::string input_path(
"./config.yaml"), particles, decaymodes;
417 std::vector<std::string> extra_config;
418 char *modus =
nullptr, *end_time =
nullptr, *pdg_string =
nullptr,
419 *cs_string =
nullptr;
420 bool list2n_activated =
false;
421 bool resonance_dump_activated =
false;
422 bool cross_section_dump_activated =
false;
423 bool final_state_cross_sections =
false;
424 bool particles_dump_iSS_format =
false;
425 bool cache_integrals =
true;
426 bool suppress_disclaimer =
false;
430 while ((opt = getopt_long(argc, argv,
"c:d:e:fhi:m:p:o:lr:s:S:xvnq",
431 longopts,
nullptr)) != -1) {
434 extra_config.emplace_back(optarg);
440 force_overwrite =
true;
446 usage(EXIT_SUCCESS, progname);
458 output_path = optarg;
461 list2n_activated =
true;
462 suppress_disclaimer =
true;
465 resonance_dump_activated =
true;
467 suppress_disclaimer =
true;
470 final_state_cross_sections =
true;
473 cross_section_dump_activated =
true;
475 suppress_disclaimer =
true;
478 particles_dump_iSS_format =
true;
479 suppress_disclaimer =
true;
487 "System : %s\nCompiler : %s %s\n"
488 "Build : %s\nDate : %s\n",
493 CMAKE_SYSTEM, CMAKE_CXX_COMPILER_ID, CMAKE_CXX_COMPILER_VERSION,
494 CMAKE_BUILD_TYPE, BUILD_DATE);
495 std::exit(EXIT_SUCCESS);
497 cache_integrals =
false;
500 suppress_disclaimer =
true;
503 usage(EXIT_FAILURE, progname);
509 std::cout << argv[0] <<
": invalid argument -- '" << argv[optind]
511 usage(EXIT_FAILURE, progname);
514 if (!suppress_disclaimer) {
519 decaymodes, extra_config);
526 std::string tabulations_path;
527 if (cache_integrals) {
528 tabulations_path = output_path.has_parent_path()
529 ? output_path.parent_path().string()
531 tabulations_path +=
"/tabulations";
533 tabulations_path =
"";
535 const std::string version(SMASH_VERSION);
537 if (list2n_activated) {
548 scat_finder.dump_reactions();
549 std::exit(EXIT_SUCCESS);
551 if (particles_dump_iSS_format) {
554 ParticleTypePtrList list;
556 for (
const auto &ptype : ParticleType::list_all()) {
557 list.push_back(&ptype);
559 std::sort(list.begin(), list.end(),
561 return a->mass() < b->mass();
564 if (ptype->pdgcode().is_lepton() || ptype->baryon_number() < 0) {
567 const auto &decay_modes = ptype->decay_modes();
568 const auto &modelist = decay_modes.decay_mode_list();
569 int ndecays = ptype->is_stable() ? 1 : modelist.size();
570 std::printf(
"%13i %s %10.5f %10.5f %5i %5i %5i %5i %5i %5i %5i %5i\n",
571 ptype->pdgcode().get_decimal(),
573 ptype->mass(), ptype->width_at_pole(),
574 ptype->pdgcode().spin_degeneracy(), ptype->baryon_number(),
575 ptype->strangeness(), ptype->pdgcode().charmness(),
576 ptype->pdgcode().bottomness(), ptype->isospin() + 1,
577 ptype->charge(), ndecays);
578 if (!ptype->is_stable()) {
579 for (
const auto &decay : modelist) {
580 auto ptypes = decay->particle_types();
581 std::printf(
"%13i %13i %20.5f %13i %13i %13i %13i %13i\n",
582 ptype->pdgcode().get_decimal(), 2, decay->weight(),
583 ptypes[0]->pdgcode().get_decimal(),
584 ptypes[1]->pdgcode().get_decimal(), 0, 0, 0);
587 std::printf(
"%13i %13i %20.5f %13i %13i %13i %13i %13i\n",
588 ptype->pdgcode().get_decimal(), 1, 1.0,
589 ptype->pdgcode().get_decimal(), 0, 0, 0, 0);
592 std::exit(EXIT_SUCCESS);
594 if (resonance_dump_activated) {
598 const auto _dummy = ExperimentBase::create(
configuration, output_path);
605 std::exit(EXIT_SUCCESS);
607 if (cross_section_dump_activated) {
610 std::string arg_string(cs_string);
611 std::vector<std::string> args =
split(arg_string,
',');
612 const unsigned int n_arg = args.size();
613 if (n_arg != 2 && n_arg != 4 && n_arg < 5) {
614 throw std::invalid_argument(
"-s usage: pdg1,pdg2[,m1,m2[,sqrts1,...]]");
616 PdgCode pdg_a(args[0]), pdg_b(args[1]);
620 for (
unsigned int i = 0; i < 4 - n_arg; i++) {
624 double ma = (args[2] ==
"") ? a.
mass() : std::stod(args[2]);
625 double mb = (args[3] ==
"") ? b.
mass() : std::stod(args[3]);
626 if (a.
is_stable() && args[2] !=
"" && std::stod(args[2]) != a.
mass()) {
628 std::cerr <<
"Warning: pole mass is used for stable particle "
629 << a.
name() <<
" instead of " << args[2] << std::endl;
631 if (b.
is_stable() && args[3] !=
"" && std::stod(args[3]) != b.
mass()) {
633 std::cerr <<
"Warning: pole mass is used for stable particle "
634 << b.
name() <<
" instead of " << args[3] << std::endl;
636 const size_t plab_size = n_arg <= 4 ? 0 : n_arg - 4;
637 std::vector<double> plab;
638 plab.reserve(plab_size);
639 for (
size_t i = 4; i < n_arg; i++) {
640 plab.push_back(std::stod(args.at(i)));
647 scat_finder.dump_cross_sections(a, b, ma, mb, final_state_cross_sections,
649 std::exit(EXIT_SUCCESS);
655 configuration[
"General"][
"End_Time"] = std::abs(std::atof(end_time));
664 const bf::path lock_path = output_path /
"smash.lock";
666 if (!lock.acquire()) {
667 throw std::runtime_error(
668 "Another instance of SMASH is already writing to the specified "
669 "output directory. If you are sure this is not the case, remove \"" +
670 lock_path.native() +
"\".");
672 logg[
LMain].debug(
"output path: ", output_path);
673 if (!force_overwrite && bf::exists(output_path /
"config.yaml")) {
674 throw std::runtime_error(
675 "Output directory would get overwritten. Select a different output "
676 "directory, clean up, or tell SMASH to ignore existing files.");
681 bf::ofstream(output_path /
"config.yaml")
682 <<
"# " << SMASH_VERSION <<
'\n'
684 <<
"# Branch : " << GIT_BRANCH <<
'\n'
686 <<
"# System : " << CMAKE_SYSTEM <<
'\n'
687 <<
"# Compiler : " << CMAKE_CXX_COMPILER_ID <<
' '
688 << CMAKE_CXX_COMPILER_VERSION <<
'\n'
689 <<
"# Build : " << CMAKE_BUILD_TYPE <<
'\n'
690 <<
"# Date : " << BUILD_DATE <<
'\n'
708 }
catch (std::exception &e) {
709 logg[
LMain].fatal() <<
"SMASH failed with the following error:\n"
void merge_yaml(const std::string &yaml)
Merge the configuration in yaml into the existing tree.
std::string to_string() const
Returns a YAML string of the current tree.
Value take(std::initializer_list< const char * > keys)
The default interface for SMASH to read configuration values.
Value read(std::initializer_list< const char * > keys) const
Additional interface for SMASH to read configuration values without removing them.
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.
const std::string & name() const
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.
Configuration configuration(std::string overrides={})
Return a configuration object filled with data from src/config.yaml.
std::unique_ptr< ExperimentBase > experiment(const Configuration &c=configuration())
Create an experiment.
void ignore_simulation_config_values(Configuration &configuration)
Remove all config values that are only needed for simulations.
bf::path default_output_path()
ScatterActionsFinder actions_finder_for_dump(Configuration configuration)
Prepares ActionsFinder for cross-section and reaction dumps.
void check_for_unused_config_values(const Configuration &configuration)
Checks if there are unused config values.
void ensure_path_is_valid(const bf::path &path)
Ensures the output path is valid.
void print_disclaimer()
Print the disclaimer.
void check_config_version_is_compatible(Configuration configuration)
Checks if the SMASH version is compatible with the version of the configuration file.
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