264 if (modus_cfg.
has_value({
"Calculation_Frame"})) {
265 frame_ = modus_cfg.
take({
"Calculation_Frame"});
269 if (modus_cfg.
has_value({
"Collisions_Within_Nucleus"})) {
278 }
else if (proj_cfg.
has_value({
"Custom"})) {
284 throw ColliderEmpty(
"Input Error: Projectile nucleus is empty.");
291 }
else if (targ_cfg.
has_value({
"Custom"})) {
297 throw ColliderEmpty(
"Input Error: Target nucleus is empty.");
301 if (modus_cfg.
has_value({
"Fermi_Motion"})) {
310 int energy_input = 0;
312 const double mass_target =
target_->mass();
314 const double mass_a =
316 const double mass_b =
target_->mass() /
target_->number_of_particles();
323 "Input Error: sqrt(s_NN) is not larger than masses:\n" +
324 std::to_string(
sqrt_s_NN_) +
" GeV <= " + std::to_string(mass_a) +
325 " GeV + " + std::to_string(mass_b) +
" GeV.");
329 mass_projec * mass_target / (mass_a * mass_b) +
330 mass_projec * mass_projec + mass_target * mass_target;
336 const double e_kin = modus_cfg.
take({
"E_Kin"});
340 "E_Kin must be nonnegative.");
344 mass_projec, mass_target);
350 const double p_lab = modus_cfg.
take({
"P_Lab"});
354 "P_Lab must be nonnegative.");
358 mass_projec, mass_target);
362 if (energy_input == 0) {
363 throw std::domain_error(
364 "Input Error: Non-existent collision energy. " 365 "Please provide one of Sqrtsnn/E_Kin/P_Lab.");
367 if (energy_input > 1) {
368 throw std::domain_error(
369 "Input Error: Redundant collision energy. " 370 "Please provide only one of Sqrtsnn/E_Kin/P_Lab.");
375 if (modus_cfg.
has_value({
"Impact",
"Value"})) {
381 if (modus_cfg.
has_value({
"Impact",
"Sample"})) {
384 if (!(modus_cfg.
has_value({
"Impact",
"Values"}) ||
385 modus_cfg.
has_value({
"Impact",
"Yields"}))) {
386 throw std::domain_error(
387 "Input Error: Need impact parameter spectrum for custom " 389 "Please provide Values and Yields.");
391 const std::vector<double> impacts =
392 modus_cfg.
take({
"Impact",
"Values"});
393 const std::vector<double> yields = modus_cfg.
take({
"Impact",
"Yields"});
394 if (impacts.size() != yields.size()) {
395 throw std::domain_error(
396 "Input Error: Need as many impact parameter values as yields. " 397 "Please make sure that Values and Yields have the same length.");
402 const auto imp_minmax =
403 std::minmax_element(impacts.begin(), impacts.end());
406 yield_max_ = *std::max_element(yields.begin(), yields.end());
409 if (modus_cfg.
has_value({
"Impact",
"Range"})) {
410 const std::array<double, 2> range = modus_cfg.
take({
"Impact",
"Range"});
414 if (modus_cfg.
has_value({
"Impact",
"Max"})) {
422 if (modus_cfg.
has_value({
"Initial_Distance"})) {
431 return out <<
"-- Collider Modus:\n" 432 <<
"sqrt(S) (nucleus-nucleus) = " 441 Configuration &nucleus_cfg,
int ntest,
const std::string &nucleus_type) {
442 bool auto_deform = nucleus_cfg.
take({
"Deformed",
"Automatic"});
443 bool is_beta2 = nucleus_cfg.
has_value({
"Deformed",
"Beta_2"}) ?
true :
false;
444 bool is_beta4 = nucleus_cfg.
has_value({
"Deformed",
"Beta_4"}) ?
true :
false;
445 std::unique_ptr<DeformedNucleus> nucleus;
447 if ((auto_deform && (!is_beta2 && !is_beta4)) ||
448 (!auto_deform && (is_beta2 && is_beta4))) {
449 nucleus = make_unique<DeformedNucleus>(nucleus_cfg, ntest);
452 throw std::domain_error(
"Deformation of " + nucleus_type +
453 " nucleus not configured " 454 "properly, please check whether all necessary " 455 "parameters are set.");
461 const auto &log = logger<LogArea::Collider>();
464 log.info() <<
"Impact parameter = " <<
format(
impact_,
"fm");
477 if (v_a >= 1.0 || v_b >= 1.0) {
478 throw std::domain_error(
479 "Found velocity equal to or larger than 1 in " 480 "ColliderModus::initial_conditions.\nConsider using " 481 "the center of velocity reference frame.");
497 target_->generate_fermi_momenta();
499 log.info() <<
"Fermi motion is ON.";
501 log.info() <<
"FROZEN Fermi motion is on.";
505 log.info() <<
"Fermi motion is OFF.";
507 throw std::domain_error(
"Invalid Fermi_Motion input.");
517 const double d_a = std::max(0.,
projectile_->get_diffusiveness());
518 const double d_b = std::max(0.,
target_->get_diffusiveness());
519 const double r_a =
projectile_->get_nuclear_radius();
520 const double r_b =
target_->get_nuclear_radius();
523 const double simulation_time = -dz / std::abs(v_a);
524 const double proj_z = -dz - std::sqrt(1.0 - v_a * v_a) * (r_a + d_a);
525 const double targ_z =
526 +dz * std::abs(v_b / v_a) + std::sqrt(1.0 - v_b * v_b) * (r_b + d_b);
532 target_->copy_particles(particles);
533 return simulation_time;
549 double probability_random = 1;
550 double probability = 0;
552 while (probability_random > probability) {
554 probability = (*impact_interpolation_)(b) /
yield_max_;
555 assert(probability < 1.);
580 v_a = pCM / std::sqrt(m_a * m_a + pCM * pCM);
581 v_b = -pCM / std::sqrt(m_b * m_b + pCM * pCM);
587 throw std::domain_error(
588 "Invalid reference frame in " 589 "ColliderModus::get_velocities.");
591 return std::make_pair(v_a, v_b);
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...
double yield_max_
Maximum value of yield. Needed for custom impact parameter sampling.
Thrown when the requested energy is smaller than the masses of two particles.
double fixed_target_projectile_v(double s, double ma, double mb)
double velocity_target_
Beam velocity of the target.
static std::unique_ptr< DeformedNucleus > create_deformed_nucleus(Configuration &nucleus_cfg, const int ntest, const std::string &nucleus_type)
Configure Deformed Nucleus.
double center_of_velocity_v(double s, double ma, double mb)
double impact_
Impact parameter.
T pCM_from_s(const T s, const T mass_a, const T mass_b) noexcept
Value read(std::initializer_list< const char * > keys) const
Additional interface for SMASH to read configuration values without removing them.
Interface to the SMASH configuration files.
std::unique_ptr< InterpolateDataLinear< double > > impact_interpolation_
Pointer to the impact parameter interpolation.
double imp_min_
Minimum value of impact parameter.
bool has_value(std::initializer_list< const char * > keys) const
Returns whether there is a non-empty value behind the requested keys.
Generic numerical functions.
ColliderModus(Configuration modus_config, const ExperimentParameters ¶meters)
Constructor.
std::unique_ptr< Nucleus > projectile_
Projectile.
Sample from uniform distribution.
Sampling sampling_
Method used for sampling of impact parameter.
Thrown when either projectile_ or target_ nuclei are empty.
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...
Sample from custom, user-defined distribution.
Value take(std::initializer_list< const char * > keys)
The default interface for SMASH to read configuration values.
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.
FermiMotion fermi_motion_
An option to include Fermi motion ("off", "on", "frozen")
double initial_z_displacement_
Initial z-displacement of nuclei.
Sample from areal / quadratic distribution.
Don't use fermi motion.
ColliderModus: Provides a modus for colliding nuclei.
double sqrt_s_NN_
Center-of-mass energy of a nucleon-nucleon collision.
Use fermi motion without potentials.
bool cll_in_nucleus_
An option to accept first collisions within the same nucleus.
double initial_conditions(Particles *particles, const ExperimentParameters ¶meters)
Generates initial state of the particles in the system.
std::unique_ptr< Nucleus > target_
Target.
double velocity_projectile_
Beam velocity of the projectile.
void sample_impact()
Sample impact parameter.
int testparticles
Number of test particle.
friend std::ostream & operator<<(std::ostream &, const ColliderModus &)
Writes the initial state for the ColliderModus to the output stream.
The Particles class abstracts the storage and manipulation of particles.
T pCM(const T sqrts, const T mass_a, const T mass_b) noexcept
double imp_max_
Maximum value of impact parameter.
Helper structure for Experiment.
Use fermi motion in combination with potentials.
CalculationFrame frame_
Reference frame for the system, as specified from config.
double total_s_
Center-of-mass energy squared of the nucleus-nucleus collision.
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...