30 static constexpr
int LCollider = LogArea::Collider::id;
326 if (modus_cfg.
has_value({
"Calculation_Frame"})) {
327 frame_ = modus_cfg.
take({
"Calculation_Frame"});
334 bool same_file =
false;
339 }
else if (proj_cfg.
has_value({
"Custom"})) {
342 make_unique<CustomNucleus>(proj_cfg, params.
testparticles, same_file);
347 throw ColliderEmpty(
"Input Error: Projectile nucleus is empty.");
354 }
else if (targ_cfg.
has_value({
"Custom"})) {
356 make_unique<CustomNucleus>(targ_cfg, params.
testparticles, same_file);
361 throw ColliderEmpty(
"Input Error: Target nucleus is empty.");
366 if (modus_cfg.
has_value({
"Fermi_Motion"})) {
375 int energy_input = 0;
377 const double mass_target =
target_->mass();
379 const double mass_a =
381 const double mass_b =
target_->mass() /
target_->number_of_particles();
388 "Input Error: sqrt(s_NN) is not larger than masses:\n" +
389 std::to_string(
sqrt_s_NN_) +
" GeV <= " + std::to_string(mass_a) +
390 " GeV + " + std::to_string(mass_b) +
" GeV.");
394 mass_projec * mass_target / (mass_a * mass_b) +
395 mass_projec * mass_projec + mass_target * mass_target;
401 const double e_tot = modus_cfg.
take({
"E_Tot"});
405 "E_Tot must be nonnegative.");
409 mass_projec, mass_target);
416 const double e_kin = modus_cfg.
take({
"E_Kin"});
420 "E_Kin must be nonnegative.");
424 mass_projec, mass_target);
430 const double p_lab = modus_cfg.
take({
"P_Lab"});
434 "P_Lab must be nonnegative.");
438 mass_projec, mass_target);
444 const double e_tot_p = proj_cfg.
take({
"E_Tot"});
445 const double e_tot_t = targ_cfg.
take({
"E_tot"});
446 if (e_tot_p < 0 || e_tot_t < 0) {
449 "E_Tot must be nonnegative.");
452 e_tot_t *
target_->number_of_particles(),
453 mass_projec, mass_target);
459 const double e_kin_p = proj_cfg.
take({
"E_Kin"});
460 const double e_kin_t = targ_cfg.
take({
"E_Kin"});
461 if (e_kin_p < 0 || e_kin_t < 0) {
464 "E_Kin must be nonnegative.");
467 e_kin_t *
target_->number_of_particles(),
468 mass_projec, mass_target);
474 const double p_lab_p = proj_cfg.
take({
"P_Lab"});
475 const double p_lab_t = targ_cfg.
take({
"P_Lab"});
476 if (p_lab_p < 0 || p_lab_t < 0) {
479 "P_Lab must be nonnegative.");
482 p_lab_t *
target_->number_of_particles(),
483 mass_projec, mass_target);
487 if (energy_input == 0) {
488 throw std::domain_error(
489 "Input Error: Non-existent collision energy. "
490 "Please provide one of Sqrtsnn/E_Kin/P_Lab.");
492 if (energy_input > 1) {
493 throw std::domain_error(
494 "Input Error: Redundant collision energy. "
495 "Please provide only one of Sqrtsnn/E_Kin/P_Lab.");
500 if (modus_cfg.
has_value({
"Impact",
"Value"})) {
506 if (modus_cfg.
has_value({
"Impact",
"Sample"})) {
509 if (!(modus_cfg.
has_value({
"Impact",
"Values"}) ||
510 modus_cfg.
has_value({
"Impact",
"Yields"}))) {
511 throw std::domain_error(
512 "Input Error: Need impact parameter spectrum for custom "
514 "Please provide Values and Yields.");
516 const std::vector<double> impacts =
517 modus_cfg.
take({
"Impact",
"Values"});
518 const std::vector<double> yields = modus_cfg.
take({
"Impact",
"Yields"});
519 if (impacts.size() != yields.size()) {
520 throw std::domain_error(
521 "Input Error: Need as many impact parameter values as yields. "
522 "Please make sure that Values and Yields have the same length.");
527 const auto imp_minmax =
528 std::minmax_element(impacts.begin(), impacts.end());
531 yield_max_ = *std::max_element(yields.begin(), yields.end());
534 if (modus_cfg.
has_value({
"Impact",
"Range"})) {
535 const std::array<double, 2> range = modus_cfg.
take({
"Impact",
"Range"});
539 if (modus_cfg.
has_value({
"Impact",
"Max"})) {
547 modus_cfg.
take({
"Impact",
"Random_Reaction_Plane"},
false);
549 if (modus_cfg.
has_value({
"Initial_Distance"})) {
566 return out <<
"-- Collider Modus:\n"
567 <<
"sqrt(S) (nucleus-nucleus) = "
576 Configuration &nucleus_cfg,
int ntest,
const std::string &nucleus_type) {
577 bool auto_deform = nucleus_cfg.
take({
"Deformed",
"Automatic"});
578 bool is_beta2 = nucleus_cfg.
has_value({
"Deformed",
"Beta_2"}) ?
true :
false;
579 bool is_beta4 = nucleus_cfg.
has_value({
"Deformed",
"Beta_4"}) ?
true :
false;
580 std::unique_ptr<DeformedNucleus> nucleus;
582 if ((auto_deform && (!is_beta2 && !is_beta4)) ||
583 (!auto_deform && (is_beta2 && is_beta4))) {
584 nucleus = make_unique<DeformedNucleus>(nucleus_cfg, ntest, auto_deform);
587 throw std::domain_error(
"Deformation of " + nucleus_type +
588 " nucleus not configured "
589 "properly, please check whether all necessary "
590 "parameters are set.");
608 if (v_a >= 1.0 || v_b >= 1.0) {
609 throw std::domain_error(
610 "Found velocity equal to or larger than 1 in "
611 "ColliderModus::initial_conditions.\nConsider using "
612 "the center of velocity reference frame.");
628 target_->generate_fermi_momenta();
631 throw std::domain_error(
"Invalid Fermi_Motion input.");
641 const double d_a = std::max(0.,
projectile_->get_diffusiveness());
642 const double d_b = std::max(0.,
target_->get_diffusiveness());
643 const double r_a =
projectile_->get_nuclear_radius();
644 const double r_b =
target_->get_nuclear_radius();
647 const double simulation_time = -dz / std::abs(v_a);
648 const double proj_z = -dz - std::sqrt(1.0 - v_a * v_a) * (r_a + d_a);
649 const double targ_z =
650 +dz * std::abs(v_b / v_a) + std::sqrt(1.0 - v_b * v_b) * (r_b + d_b);
660 target_->copy_particles(particles);
662 return simulation_time;
671 p.set_3position(pos);
672 p.set_3momentum(mom);
689 double probability_random = 1;
690 double probability = 0;
692 while (probability_random > probability) {
694 probability = (*impact_interpolation_)(b) /
yield_max_;
695 assert(probability < 1.);
720 v_a =
pCM / std::sqrt(m_a * m_a +
pCM *
pCM);
721 v_b = -
pCM / std::sqrt(m_b * m_b +
pCM *
pCM);
727 throw std::domain_error(
728 "Invalid reference frame in "
729 "ColliderModus::get_velocities.");
731 return std::make_pair(v_a, v_b);
735 const std::string &file_name) {
737 if (file_directory.back() ==
'/') {
738 return file_directory + file_name;
740 return file_directory +
'/' + file_name;
749 if (!targ_config.
has_value({
"Custom"})) {
752 std::string projectile_file_directory =
753 proj_config.
read({
"Custom",
"File_Directory"});
754 std::string target_file_directory =
755 targ_config.
read({
"Custom",
"File_Directory"});
756 std::string projectile_file_name = proj_config.
read({
"Custom",
"File_Name"});
757 std::string target_file_name = targ_config.
read({
"Custom",
"File_Name"});
759 std::string proj_path =
761 std::string targ_path =
763 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.