30 static constexpr
int LCollider = LogArea::Collider::id;
323 if (modus_cfg.
has_value({
"Calculation_Frame"})) {
324 frame_ = modus_cfg.
take({
"Calculation_Frame"});
331 bool same_file =
false;
336 }
else if (proj_cfg.
has_value({
"Custom"})) {
339 make_unique<CustomNucleus>(proj_cfg, params.
testparticles, same_file);
344 throw ColliderEmpty(
"Input Error: Projectile nucleus is empty.");
351 }
else if (targ_cfg.
has_value({
"Custom"})) {
353 make_unique<CustomNucleus>(targ_cfg, params.
testparticles, same_file);
358 throw ColliderEmpty(
"Input Error: Target nucleus is empty.");
363 if (modus_cfg.
has_value({
"Fermi_Motion"})) {
372 int energy_input = 0;
374 const double mass_target =
target_->mass();
376 const double mass_a =
378 const double mass_b =
target_->mass() /
target_->number_of_particles();
385 "Input Error: sqrt(s_NN) is not larger than masses:\n" +
386 std::to_string(
sqrt_s_NN_) +
" GeV <= " + std::to_string(mass_a) +
387 " GeV + " + std::to_string(mass_b) +
" GeV.");
391 mass_projec * mass_target / (mass_a * mass_b) +
392 mass_projec * mass_projec + mass_target * mass_target;
398 const double e_tot = modus_cfg.
take({
"E_Tot"});
402 "E_Tot must be nonnegative.");
406 mass_projec, mass_target);
413 const double e_kin = modus_cfg.
take({
"E_Kin"});
417 "E_Kin must be nonnegative.");
421 mass_projec, mass_target);
427 const double p_lab = modus_cfg.
take({
"P_Lab"});
431 "P_Lab must be nonnegative.");
435 mass_projec, mass_target);
441 const double e_tot_p = proj_cfg.
take({
"E_Tot"});
442 const double e_tot_t = targ_cfg.
take({
"E_tot"});
443 if (e_tot_p < 0 || e_tot_t < 0) {
446 "E_Tot must be nonnegative.");
449 e_tot_t *
target_->number_of_particles(),
450 mass_projec, mass_target);
456 const double e_kin_p = proj_cfg.
take({
"E_Kin"});
457 const double e_kin_t = targ_cfg.
take({
"E_Kin"});
458 if (e_kin_p < 0 || e_kin_t < 0) {
461 "E_Kin must be nonnegative.");
464 e_kin_t *
target_->number_of_particles(),
465 mass_projec, mass_target);
471 const double p_lab_p = proj_cfg.
take({
"P_Lab"});
472 const double p_lab_t = targ_cfg.
take({
"P_Lab"});
473 if (p_lab_p < 0 || p_lab_t < 0) {
476 "P_Lab must be nonnegative.");
479 p_lab_t *
target_->number_of_particles(),
480 mass_projec, mass_target);
484 if (energy_input == 0) {
485 throw std::domain_error(
486 "Input Error: Non-existent collision energy. "
487 "Please provide one of Sqrtsnn/E_Kin/P_Lab.");
489 if (energy_input > 1) {
490 throw std::domain_error(
491 "Input Error: Redundant collision energy. "
492 "Please provide only one of Sqrtsnn/E_Kin/P_Lab.");
497 if (modus_cfg.
has_value({
"Impact",
"Value"})) {
503 if (modus_cfg.
has_value({
"Impact",
"Sample"})) {
506 if (!(modus_cfg.
has_value({
"Impact",
"Values"}) ||
507 modus_cfg.
has_value({
"Impact",
"Yields"}))) {
508 throw std::domain_error(
509 "Input Error: Need impact parameter spectrum for custom "
511 "Please provide Values and Yields.");
513 const std::vector<double> impacts =
514 modus_cfg.
take({
"Impact",
"Values"});
515 const std::vector<double> yields = modus_cfg.
take({
"Impact",
"Yields"});
516 if (impacts.size() != yields.size()) {
517 throw std::domain_error(
518 "Input Error: Need as many impact parameter values as yields. "
519 "Please make sure that Values and Yields have the same length.");
524 const auto imp_minmax =
525 std::minmax_element(impacts.begin(), impacts.end());
528 yield_max_ = *std::max_element(yields.begin(), yields.end());
531 if (modus_cfg.
has_value({
"Impact",
"Range"})) {
532 const std::array<double, 2> range = modus_cfg.
take({
"Impact",
"Range"});
536 if (modus_cfg.
has_value({
"Impact",
"Max"})) {
544 modus_cfg.
take({
"Impact",
"Random_Reaction_Plane"},
false);
546 if (modus_cfg.
has_value({
"Initial_Distance"})) {
563 return out <<
"-- Collider Modus:\n"
564 <<
"sqrt(S) (nucleus-nucleus) = "
573 Configuration &nucleus_cfg,
int ntest,
const std::string &nucleus_type) {
574 bool auto_deform = nucleus_cfg.
take({
"Deformed",
"Automatic"});
575 bool is_beta2 = nucleus_cfg.
has_value({
"Deformed",
"Beta_2"}) ?
true :
false;
576 bool is_beta4 = nucleus_cfg.
has_value({
"Deformed",
"Beta_4"}) ?
true :
false;
577 std::unique_ptr<DeformedNucleus> nucleus;
579 if ((auto_deform && (!is_beta2 && !is_beta4)) ||
580 (!auto_deform && (is_beta2 && is_beta4))) {
581 nucleus = make_unique<DeformedNucleus>(nucleus_cfg, ntest, auto_deform);
584 throw std::domain_error(
"Deformation of " + nucleus_type +
585 " nucleus not configured "
586 "properly, please check whether all necessary "
587 "parameters are set.");
605 if (v_a >= 1.0 || v_b >= 1.0) {
606 throw std::domain_error(
607 "Found velocity equal to or larger than 1 in "
608 "ColliderModus::initial_conditions.\nConsider using "
609 "the center of velocity reference frame.");
625 target_->generate_fermi_momenta();
628 throw std::domain_error(
"Invalid Fermi_Motion input.");
638 const double d_a = std::max(0.,
projectile_->get_diffusiveness());
639 const double d_b = std::max(0.,
target_->get_diffusiveness());
640 const double r_a =
projectile_->get_nuclear_radius();
641 const double r_b =
target_->get_nuclear_radius();
644 const double simulation_time = -dz / std::abs(v_a);
645 const double proj_z = -dz - std::sqrt(1.0 - v_a * v_a) * (r_a + d_a);
646 const double targ_z =
647 +dz * std::abs(v_b / v_a) + std::sqrt(1.0 - v_b * v_b) * (r_b + d_b);
657 target_->copy_particles(particles);
659 return simulation_time;
668 p.set_3position(pos);
669 p.set_3momentum(mom);
686 double probability_random = 1;
687 double probability = 0;
689 while (probability_random > probability) {
691 probability = (*impact_interpolation_)(b) /
yield_max_;
692 assert(probability < 1.);
717 v_a =
pCM / std::sqrt(m_a * m_a +
pCM *
pCM);
718 v_b = -
pCM / std::sqrt(m_b * m_b +
pCM *
pCM);
724 throw std::domain_error(
725 "Invalid reference frame in "
726 "ColliderModus::get_velocities.");
728 return std::make_pair(v_a, v_b);
732 const std::string &file_name) {
734 if (file_directory.back() ==
'/') {
735 return file_directory + file_name;
737 return file_directory +
'/' + file_name;
746 if (!targ_config.
has_value({
"Custom"})) {
749 std::string projectile_file_directory =
750 proj_config.
read({
"Custom",
"File_Directory"});
751 std::string target_file_directory =
752 targ_config.
read({
"Custom",
"File_Directory"});
753 std::string projectile_file_name = proj_config.
read({
"Custom",
"File_Name"});
754 std::string target_file_name = targ_config.
read({
"Custom",
"File_Name"});
756 std::string proj_path =
758 std::string targ_path =
760 if (proj_path == targ_path) {
ColliderModus: Provides a modus for colliding nuclei.
CalculationFrame frame_
Reference frame for the system, as specified from config.
double imp_min_
Minimum value of impact parameter.
double initial_z_displacement_
Initial z-displacement of nuclei.
double yield_max_
Maximum value of yield. Needed for custom impact parameter sampling.
bool random_reaction_plane_
Whether the reaction plane should be randomized.
void rotate_reaction_plane(double phi, Particles *particles)
Rotate the reaction plane about the angle phi.
std::pair< double, double > get_velocities(double mandelstam_s, double m_a, double m_b)
Get the frame dependent velocity for each nucleus, using the current reference frame.
void sample_impact()
Sample impact parameter.
std::unique_ptr< Nucleus > projectile_
Projectile.
std::unique_ptr< InterpolateDataLinear< double > > impact_interpolation_
Pointer to the impact parameter interpolation.
FermiMotion fermi_motion_
An option to include Fermi motion ("off", "on", "frozen")
double velocity_projectile_
Beam velocity of the projectile.
Sampling sampling_
Method used for sampling of impact parameter.
std::string custom_file_path(const std::string &file_directory, const std::string &file_name)
Creates full path string consisting of file_directory and file_name Needed to initialize a customnucl...
double total_s_
Center-of-mass energy squared of the nucleus-nucleus collision.
std::unique_ptr< Nucleus > target_
Target.
ColliderModus(Configuration modus_config, const ExperimentParameters ¶meters)
Constructor.
double impact_
Impact parameter.
double sqrt_s_NN_
Center-of-mass energy of a nucleon-nucleon collision.
double initial_conditions(Particles *particles, const ExperimentParameters ¶meters)
Generates initial state of the particles in the system.
bool same_inputfile(Configuration &proj_config, Configuration &targ_config)
Checks if target and projectile are read from the same external file if they are both initialized as ...
static std::unique_ptr< DeformedNucleus > create_deformed_nucleus(Configuration &nucleus_cfg, const int ntest, const std::string &nucleus_type)
Configure Deformed Nucleus.
double velocity_target_
Beam velocity of the target.
double imp_max_
Maximum value of impact parameter.
Interface to the SMASH configuration files.
bool has_value(std::initializer_list< const char * > keys) const
Returns whether there is a non-empty value behind the requested keys.
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.
Represent a piecewise linear interpolation.
ParticleData contains the dynamic information of a certain particle.
The Particles class abstracts the storage and manipulation of particles.
The ThreeVector class represents a physical three-vector with the components .
void rotate_around_z(double theta)
Rotate the vector around the z axis by the given angle theta.
@ On
Use fermi motion in combination with potentials.
@ Frozen
Use fermi motion without potentials.
@ Off
Don't use fermi motion.
@ Quadratic
Sample from areal / quadratic distribution.
@ Custom
Sample from custom, user-defined distribution.
@ Uniform
Sample from uniform distribution.
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Convenience: dereferences the ActionPtr to Action.
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
FormattingHelper< T > format(const T &value, const char *unit, int width=-1, int precision=-1)
Acts as a stream modifier for std::ostream to output an object with an optional suffix string and wit...
T pCM(const T sqrts, const T mass_a, const T mass_b) noexcept
double fixed_target_projectile_v(double s, double ma, double mb)
double s_from_Ekin(double e_kin, double m_P, double m_T)
Convert E_kin to Mandelstam-s for a fixed-target setup, with a projectile of mass m_P and a kinetic e...
double center_of_velocity_v(double s, double ma, double mb)
T pCM_from_s(const T s, const T mass_a, const T mass_b) noexcept
static constexpr int LCollider
double s_from_Etot(double e_tot, double m_P, double m_T)
Convert E_tot to Mandelstam-s for a fixed-target setup, with a projectile of mass m_P and a total ene...
double s_from_plab(double plab, double m_P, double m_T)
Convert p_lab to Mandelstam-s for a fixed-target setup, with a projectile of mass m_P and momentum pl...
Thrown when either projectile_ or target_ nuclei are empty.
Helper structure for Experiment.
int testparticles
Number of test-particles.
Thrown when the requested energy is smaller than the masses of two particles.