10 #ifndef SRC_INCLUDE_SMASH_POTENTIALS_H_
11 #define SRC_INCLUDE_SMASH_POTENTIALS_H_
17 #include "gsl/gsl_multiroots.h"
18 #include "gsl/gsl_vector.h"
69 ParticleList &plist)
const {
70 const std::array<double, 3> dr = (jB_lattice)
72 : std::array<double, 3>{0.1, 0.1, 0.1};
75 FourVector net_4current_left, net_4current_right;
76 for (
int i = 0; i < 3; i++) {
77 position_left = position;
78 position_left[i] -= dr[i];
79 position_right = position;
80 position_right[i] += dr[i];
82 if (jB_lattice && jB_lattice->
value_at(position_left, jmu_left)) {
83 net_4current_left = jmu_left.
jmu_net();
87 net_4current_left = std::get<1>(current);
92 if (jB_lattice && jB_lattice->
value_at(position_right, jmu_right)) {
93 net_4current_right = jmu_right.
jmu_net();
97 net_4current_right = std::get<1>(current);
120 std::function<double(
double)> root_equation = [momentum, jmu_B, mass,
121 this](
double energy) {
127 constexpr std::size_t max_number_root_solver_iterations = 100000;
128 const double initial_guess = std::sqrt(mass * mass + momentum * momentum);
129 const std::array<double, 4> interval_half_widths = {0.05, 0.5, 5.0, 50.0};
130 for (
const double half_width : interval_half_widths) {
131 const std::pair<double, double> x_range = {initial_guess - half_width,
132 initial_guess + half_width};
133 const auto calc_frame_energy = root_solver.try_find_root(
134 x_range.first, x_range.second, max_number_root_solver_iterations);
135 if (calc_frame_energy) {
136 return *calc_frame_energy;
139 <<
"Did not find a root for potentials in the interval ["
140 << x_range.first <<
" GeV ," << x_range.second <<
" GeV].";
146 constexpr
double half_interval_width = 100;
147 constexpr
double scanning_resolution = 0.1;
148 const double upper_bound = initial_guess + half_interval_width;
149 const double lower_bound = initial_guess - half_interval_width;
150 std::pair<double, double> x_range = {initial_guess - scanning_resolution,
151 initial_guess + scanning_resolution};
153 <<
"Trying to find a root for potentials around " << initial_guess
154 <<
" GeV in the range [" << lower_bound <<
", " << upper_bound
155 <<
"] GeV\nExploring interval with a resolution of "
156 << scanning_resolution <<
" GeV, starting with x_range: ["
157 << x_range.first <<
", " << x_range.second <<
"] GeV";
159 const auto calc_frame_energy = root_solver.try_find_root(
160 x_range.first, x_range.second, max_number_root_solver_iterations);
161 if (calc_frame_energy) {
162 return *calc_frame_energy;
164 const bool is_possible_to_go_right = (x_range.second < upper_bound);
165 const bool is_possible_to_go_left = (x_range.first > lower_bound);
168 if (!is_possible_to_go_left && !is_possible_to_go_right) {
170 }
else if (!is_possible_to_go_left) {
171 x_range.second += scanning_resolution;
172 }
else if (!is_possible_to_go_right) {
173 x_range.first -= scanning_resolution;
177 x_range.second += scanning_resolution;
179 x_range.first -= scanning_resolution;
183 << x_range.second <<
"] GeV";
187 <<
"Did not find any sub-range with a root scanning the interval ["
188 << x_range.first <<
", " << x_range.second <<
"] GeV";
190 "Failed to find root for momentum-dependent potentials.");
191 throw std::runtime_error(
"Unable to continue simulation.");
219 double symmetry_pot(
const double baryon_isospin_density,
220 const double baryon_density)
const;
228 double symmetry_S(
const double baryon_density)
const;
373 std::pow(dr.
abs(), 3);
392 std::pow(dr.
abs(), 3);
432 std::pair<ThreeVector, ThreeVector>
vdf_force(
433 double rhoB,
const double drhoB_dt,
const ThreeVector grad_rhoB,
434 const ThreeVector gradrhoB_cross_vecjB,
const double j0B,
455 std::pair<ThreeVector, ThreeVector>
vdf_force(
474 virtual std::tuple<ThreeVector, ThreeVector, ThreeVector, ThreeVector>
619 double dVsym_drhoI3(
const double rhoB,
const double rhoI3)
const;
639 double dVsym_drhoB(
const double rhoB,
const double rhoI3)
const;
650 static double skyrme_pot(
const double baryon_density,
const double A,
651 const double B,
const double tau);
682 double B,
double tau,
double C,
685 double rho_LRF = jmu.
abs();
694 double energy_LRF = std::sqrt(m * m + p_LRF * p_LRF) +
697 const double result = energy_calc * energy_calc - momentum_calc.
sqr() -
698 (energy_LRF * energy_LRF - p_LRF * p_LRF);
700 <<
"root equation for potentials called with E_calc=" << energy_calc
701 <<
" p_calc=" << momentum_calc <<
" jmu=" << jmu <<
" m=" << m
702 <<
" tau=" << tau <<
" A=" << A <<
" B=" << B <<
" C=" << C
703 <<
" Lambda=" <<
Lambda <<
" and the root equation is " << result;
729 const double fermi_momentum =
730 std::cbrt(6. * M_PI * M_PI * rho / g);
731 momentum = momentum /
hbarc;
735 std::pow(
Lambda, 3) * std::atan(fermi_momentum /
Lambda));
737 const std::array<double, 7> temp = {
738 2 * g * C * M_PI * std::pow(
Lambda, 3) /
741 momentum * momentum) /
743 std::pow(momentum + fermi_momentum, 2) +
Lambda *
Lambda,
744 std::pow(momentum - fermi_momentum, 2) +
Lambda *
Lambda,
745 2 * fermi_momentum /
Lambda,
746 (momentum + fermi_momentum) /
Lambda,
747 (momentum - fermi_momentum) /
Lambda};
748 const double result =
749 temp[0] * (temp[1] * std::log(temp[2] / temp[3]) + temp[4] -
750 2 * (std::atan(temp[5]) - std::atan(temp[6])));
Interface to the SMASH configuration files.
A class for time-efficient (time-memory trade-off) calculation of density on the lattice.
double rho(const double norm_factor=1.0)
Compute the net Eckart density on the local lattice.
FourVector jmu_net() const
A class to pre-calculate and store parameters relevant for density calculation.
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
double abs() const
calculate the lorentz invariant absolute value
FourVector lorentz_boost(const ThreeVector &v) const
Returns the FourVector boosted with velocity v.
ThreeVector threevec() const
Particle type contains the static properties of a particle species.
A class that stores parameters of potentials, calculates potentials and their gradients.
const std::vector< double > & powers() const
static double momentum_dependent_part(double momentum, double rho, double C, double Lambda)
Momentum dependent term of the potential.
bool use_skyrme_
Skyrme potential on/off.
bool use_symmetry_
Symmetry potential on/off.
double skyrme_pot(const double baryon_density) const
Evaluates Skyrme potential given a baryon density.
static double root_eq_potentials(double energy_calc, const ThreeVector &momentum_calc, const FourVector &jmu, double m, double A, double B, double tau, double C, double Lambda)
Root equation used to determine the energy in the calculation frame.
virtual bool use_symmetry() const
double symmetry_pot(const double baryon_isospin_density, const double baryon_density) const
Evaluates symmetry potential given baryon isospin density.
double mom_dependence_C_
Parameter C of the momentum-dependent part of the potentials given in MeV.
ThreeVector single_particle_energy_gradient(DensityLattice *jB_lattice, const ThreeVector &position, const ThreeVector &momentum, double mass, ParticleList &plist) const
Calculates the gradient of the single-particle energy (including potentials) in the calculation frame...
const std::vector< double > & coeffs() const
static ThreeVector B_field_integrand(ThreeVector pos, DensityOnLattice &charge_density, ThreeVector point)
Integrand for calculating the magnetic field using the Biot-Savart formula.
static ThreeVector E_field_integrand(ThreeVector pos, DensityOnLattice &charge_density, ThreeVector point)
Integrand for calculating the electric field.
std::pair< ThreeVector, ThreeVector > symmetry_force(const double rhoI3, const ThreeVector grad_j0I3, const ThreeVector dvecjI3_dt, const ThreeVector curl_vecjI3, const double rhoB, const ThreeVector grad_j0B, const ThreeVector dvecjB_dt, const ThreeVector curl_vecjB) const
Evaluates the electric and magnetic components of the symmetry force.
double calculation_frame_energy(const ThreeVector &momentum, const FourVector &jmu_B, double mass) const
Evaluates the single-particle energy (including the potential) of a particle at a given position and ...
virtual bool use_skyrme() const
double potential(const ThreeVector &r, const ParticleList &plist, const ParticleType &acts_on) const
Evaluates potential (Skyrme with optional Symmetry or VDF) at point r.
FourVector vdf_pot(double rhoB, const FourVector jmuB_net) const
Evaluates the FourVector potential in the VDF model given the rest frame density and the computationa...
bool use_potentials_outside_lattice() const
std::vector< double > powers_
Parameters of the VDF potential: exponents .
bool use_potentials_outside_lattice_
Wether potentials should be included outside of the lattice.
double dVsym_drhoB(const double rhoB, const double rhoI3) const
Calculate the derivative of the symmetry potential with respect to the net baryon density in GeV * fm...
virtual bool use_coulomb() const
double symmetry_S(const double baryon_density) const
Calculate the factor in the symmetry potential.
double symmetry_S_Pot_
Parameter S_Pot in the symmetry potential in MeV.
double skyrme_a_
Parameter of skyrme potentials: the coefficient in front of in GeV.
std::vector< double > coeffs_
Parameters of the VDF potential: coefficients , in GeV.
std::pair< ThreeVector, ThreeVector > vdf_force(double rhoB, const double drhoB_dt, const ThreeVector grad_rhoB, const ThreeVector gradrhoB_cross_vecjB, const double j0B, const ThreeVector grad_j0B, const ThreeVector vecjB, const ThreeVector dvecjB_dt, const ThreeVector curl_vecjB) const
Evaluates the electric and magnetic components of force in the VDF model given the derivatives of the...
double skyrme_tau() const
double mom_dependence_Lambda_
Parameter Lambda of the momentum-dependent part of the potentials given in 1/fm.
bool use_momentum_dependence_
Momentum-dependent part on/off.
double coulomb_r_cut() const
double skyrme_tau_
Parameters of skyrme potentials: the power index.
double symmetry_S_pot() const
Potentials(Configuration conf, const DensityParameters ¶meters)
Potentials constructor.
double dVsym_drhoI3(const double rhoB, const double rhoI3) const
Calculate the derivative of the symmetry potential with respect to the isospin density in GeV * fm^3.
int number_of_terms() const
static std::pair< double, int > force_scale(const ParticleType &data)
Evaluates the scaling factor of the forces acting on the particles.
std::pair< ThreeVector, ThreeVector > skyrme_force(const double rhoB, const ThreeVector grad_j0B, const ThreeVector dvecjB_dt, const ThreeVector curl_vecjB) const
Evaluates the electric and magnetic components of the skyrme force.
virtual std::tuple< ThreeVector, ThreeVector, ThreeVector, ThreeVector > all_forces(const ThreeVector &r, const ParticleList &plist) const
Evaluates the electric and magnetic components of the forces at point r.
bool use_coulomb_
Coulomb potential on/Off.
double symmetry_gamma_
Power in formula for :
bool symmetry_is_rhoB_dependent_
Whether the baryon density dependence of the symmetry potential is included.
double coulomb_r_cut_
Cutoff in integration for coulomb potential.
virtual bool use_vdf() const
const DensityParameters param_
Struct that contains the gaussian smearing width , the distance cutoff and the testparticle number n...
double saturation_density() const
bool use_vdf_
VDF potential on/off.
double saturation_density_
Saturation density of nuclear matter used in the VDF potential; it may vary between different paramet...
virtual bool use_momentum_dependence() const
virtual ~Potentials()
Standard destructor.
double skyrme_b_
Parameters of skyrme potentials: the coefficient in front of in GeV.
A container class to hold all the arrays on the lattice and access them.
bool value_at(const ThreeVector &r, T &value) const
Interpolates lattice quantity to coordinate r.
const std::array< double, 3 > & cell_sizes() const
A class used for calculating the root of a one-dimensional equation.
The ThreeVector class represents a physical three-vector with the components .
ThreeVector cross_product(const ThreeVector &b) const
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
#define unlikely(x)
Tell the branch predictor that this expression is likely false.
T uniform_int(T min, T max)
constexpr double mev_to_gev
MeV to GeV conversion factor.
std::tuple< double, FourVector, ThreeVector, ThreeVector, FourVector, FourVector, FourVector, FourVector > current_eckart(const ThreeVector &r, const ParticleList &plist, const DensityParameters &par, DensityType dens_type, bool compute_gradient, bool smearing)
Calculates Eckart rest frame density and 4-current of a given density type and optionally the gradien...
static constexpr int LPotentials
constexpr double nuclear_density
Ground state density of symmetric nuclear matter [fm^-3].
constexpr double hbarc
GeV <-> fm conversion factor.
constexpr double really_small
Numerical error tolerance.
const double elementary_charge
Elementary electric charge in natural units, approximately 0.3.