9 #ifndef SRC_INCLUDE_SMASH_DENSITY_H_ 
   10 #define SRC_INCLUDE_SMASH_DENSITY_H_ 
   29 static constexpr 
int LDensity = LogArea::Density::id;
 
   78   const double tmp = two_sigma_sqr * M_PI;
 
   79   return tmp * std::sqrt(tmp);
 
  100   const double x = rcut_in_sigma / std::sqrt(2.0);
 
  101   return -2.0 / std::sqrt(M_PI) * x * std::exp(-x * x) + std::erf(x);
 
  122       : 
sig_(par.gaussian_sigma),
 
  123         r_cut_(par.gauss_cutoff_in_sigma * par.gaussian_sigma),
 
  124         ntest_(par.testparticles),
 
  133     const double two_sig_sqr = 2 * 
sig_ * 
sig_;
 
  136     const double corr_factor =
 
  274                bool compute_gradient, 
bool smearing);
 
  280                bool compute_gradient, 
bool smearing);
 
  332     if (FactorTimesSf > 0.0) {
 
  333       jmu_pos_ += part_four_velocity * FactorTimesSf;
 
  335       jmu_neg_ += part_four_velocity * FactorTimesSf;
 
  354     for (
int k = 1; k <= 3; k++) {
 
  355       djmu_dxnu_[k] += factor * PartFourVelocity * sf_grad[k - 1];
 
  357           factor * PartFourVelocity * sf_grad[k - 1] * part.
velocity()[k - 1];
 
  378   double rho(
const double norm_factor = 1.0) {
 
  393     curl_vec_j *= norm_factor;
 
  406     for (
int i = 1; i < 4; i++) {
 
  407       j0_grad[i - 1] = 
djmu_dxnu_[i].x0() * norm_factor;
 
  419     return djmu_dxnu_[0].threevec() * norm_factor;
 
  470     return Drho_cross_vecj;
 
  534 template <
typename T>
 
  537                     const std::vector<Particles> &ensembles,
 
  538                     const bool compute_gradient) {
 
  540   if (lat == 
nullptr || lat->
when_update() != update) {
 
  548   const double V_cell =
 
  552   const double small = (1.0 - big) / 6.0;
 
  554   const std::array<double, 3> triangular_radius = {
 
  558   const double prefactor_triangular =
 
  561        triangular_radius[0] * triangular_radius[1] * triangular_radius[1] *
 
  562        triangular_radius[2] * triangular_radius[2]);
 
  564   for (
const Particles &particles : ensembles) {
 
  568         if (part.get_history().collisions_per_particle == 0) {
 
  572       const double dens_factor = 
density_factor(part.type(), dens_type);
 
  577       const ThreeVector pos = part.position().threevec();
 
  581         const double m = p_mu.
abs();
 
  583           logg[
LDensity].warn(
"Gaussian smearing is undefined for momentum ",
 
  587         const double m_inv = 1.0 / m;
 
  590         const double common_weight = dens_factor * norm_factor_gaus;
 
  592             pos, par.
r_cut(), [&](T &node, 
int ix, 
int iy, 
int iz) {
 
  594               const ThreeVector r = lat->cell_center(ix, iy, iz);
 
  595               const auto sf = unnormalized_smearing_factor(
 
  596                   pos - r, p_mu, m_inv, par, compute_gradient);
 
  597               node.add_particle(part, sf.first * common_weight);
 
  598               if (par.derivatives() == DerivativesMode::CovariantGaussian) {
 
  599                 node.add_particle_for_derivatives(part, dens_factor,
 
  600                                                   sf.second * norm_factor_gaus);
 
  605         const double common_weight =
 
  608             pos, [&](T &node, 
int iterated_index, 
int center_index) {
 
  610                   part, common_weight *
 
  613                             (iterated_index == center_index ? big : small));
 
  617         const double common_weight = dens_factor * prefactor_triangular;
 
  619             pos, triangular_radius, [&](T &node, 
int ix, 
int iy, 
int iz) {
 
  623               const double weight_x =
 
  624                   triangular_radius[0] - std::abs(cell_center[0] - pos[0]);
 
  625               const double weight_y =
 
  626                   triangular_radius[1] - std::abs(cell_center[1] - pos[1]);
 
  627               const double weight_z =
 
  628                   triangular_radius[2] - std::abs(cell_center[2] - pos[2]);
 
  630               node.add_particle(part,
 
  631                                 common_weight * weight_x * weight_y * weight_z);
 
  658     RectangularLattice<DensityOnLattice> *lat,
 
  659     RectangularLattice<FourVector> *old_jmu,
 
  660     RectangularLattice<FourVector> *new_jmu,
 
  661     RectangularLattice<std::array<FourVector, 4>> *four_grad_lattice,
 
  663     const DensityParameters &par, 
const std::vector<Particles> &ensembles,
 
  664     const double time_step, 
const bool compute_gradient);
 
A class for time-efficient (time-memory trade-off) calculation of density on the lattice.
 
std::array< FourVector, 4 > djmu_dxnu() const
Return the FourGradient of the net baryon current .
 
std::array< FourVector, 4 > djmu_dxnu_
Four-gradient of the four-current density, .
 
double rho(const double norm_factor=1.0)
Compute the net Eckart density on the local lattice.
 
ThreeVector grad_j0(const double norm_factor=1.0)
Compute gradient of the the zeroth component of the four-current j^mu (that is of the computational f...
 
void overwrite_djmu_dxnu(FourVector djmu_dt, FourVector djmu_dx, FourVector djmu_dy, FourVector djmu_dz)
Overwrite all density current derivatives to provided values.
 
ThreeVector grad_rho_cross_vecj() const
Compute the cross product of  and .
 
void add_particle(const ParticleData &part, double FactorTimesSf)
Adds particle to 4-current: .
 
ThreeVector dvecj_dt(const double norm_factor=1.0)
Compute time derivative of the current density on the local lattice.
 
void add_to_jmu_pos(FourVector additional_jmu_B)
Add to the positive density current.
 
FourVector drho_dxnu_
Four-gradient of the rest frame density, .
 
void add_to_jmu_neg(FourVector additional_jmu_B)
Add to the negative density current.
 
void overwrite_drho_dxnu(FourVector computed_drho_dxnu)
Overwrite the rest frame density derivatives to provided values.
 
void overwrite_djmu_dt_to_zero()
Overwrite the time derivative of the current to zero.
 
FourVector jmu_pos_
Four-current density of the positively charged particle.
 
void overwrite_drho_dt_to_zero()
Overwrite the time derivative of the rest frame density to zero.
 
DensityOnLattice()
Default constructor.
 
ThreeVector curl_vecj(const double norm_factor=1.0)
Compute curl of the current on the local lattice.
 
FourVector jmu_net() const
 
void add_particle_for_derivatives(const ParticleData &part, double factor, ThreeVector sf_grad)
Adds particle to the time and spatial derivatives of the 4-current.
 
FourVector drho_dxnu() const
Return the FourGradient of the rest frame density .
 
FourVector jmu_neg_
Four-current density of the negatively charged particle.
 
A class to pre-calculate and store parameters relevant for density calculation.
 
double r_cut_sqr_
Squared cut-off radius [fm ].
 
const double central_weight_
Weight of the central cell in the discrete smearing.
 
const double triangular_range_
Range of the triangular smearing.
 
const SmearingMode smearing_
Mode of smearing.
 
const int nensembles_
Number of ensembles.
 
double triangular_range() const
 
RestFrameDensityDerivativesMode rho_derivatives() const
 
SmearingMode smearing() const
 
const DerivativesMode derivatives_
Mode of calculating the gradients.
 
bool only_participants_
Flag to take into account only participants.
 
bool only_participants() const
 
const double sig_
Gaussian smearing width [fm].
 
DerivativesMode derivatives() const
 
double two_sig_sqr_inv() const
 
double central_weight() const
 
const RestFrameDensityDerivativesMode rho_derivatives_
Whether to calculate the rest frame density derivatives.
 
const int ntest_
Testparticle number.
 
double norm_factor_sf() const
 
const double r_cut_
Cut-off radius [fm].
 
double norm_factor_sf_
Normalization for Gaussian smearing factor.
 
DensityParameters(const ExperimentParameters &par)
Constructor of DensityParameters.
 
double two_sig_sqr_inv_
[fm ]
 
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
 
double abs() const
calculate the lorentz invariant absolute value
 
ThreeVector threevec() const
 
ParticleData contains the dynamic information of a certain particle.
 
ThreeVector velocity() const
Get the velocity 3-vector.
 
The Particles class abstracts the storage and manipulation of particles.
 
A container class to hold all the arrays on the lattice and access them.
 
void reset()
Sets all values on lattice to zeros.
 
LatticeUpdate when_update() const
 
ThreeVector cell_center(int ix, int iy, int iz) const
Find the coordinates of a given cell.
 
void iterate_in_cube(const ThreeVector &point, const double r_cut, F &&func)
Iterates only nodes whose cell centers lie not further than r_cut in x, y, z directions from the give...
 
void iterate_nearest_neighbors(const ThreeVector &point, F &&func)
Iterates only over nodes corresponding to the center cell (the cell containing the given point) and i...
 
void iterate_in_rectangle(const ThreeVector &point, const std::array< double, 3 > &rectangle, F &&func)
Iterates only nodes whose cell centers lie not further than d_x in x-, d_y in y-, and d_z in z-direct...
 
const std::array< double, 3 > & cell_sizes() const
 
The ThreeVector class represents a physical three-vector  with the components .
 
void set_x1(double x)
set first component
 
void set_x3(double z)
set third component
 
void set_x2(double y)
set second component
 
ThreeVector cross_product(const ThreeVector &b) const
 
SmearingMode
Modes of smearing.
 
RestFrameDensityDerivativesMode
Modes of calculating the gradients: whether to calculate the rest frame density derivatives.
 
DerivativesMode
Modes of calculating the gradients.
 
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.
 
#define unlikely(x)
Tell the branch predictor that this expression is likely false.
 
double smearing_factor_norm(const double two_sigma_sqr)
Norm of the Gaussian smearing function.
 
void update_lattice(RectangularLattice< T > *lat, const LatticeUpdate update, const DensityType dens_type, const DensityParameters &par, const std::vector< Particles > &ensembles, const bool compute_gradient)
Updates the contents on the lattice.
 
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...
 
void update_lattice(RectangularLattice< DensityOnLattice > *lat, RectangularLattice< FourVector > *old_jmu, RectangularLattice< FourVector > *new_jmu, RectangularLattice< std::array< FourVector, 4 >> *four_grad_lattice, const LatticeUpdate update, const DensityType dens_type, const DensityParameters &par, const std::vector< Particles > &ensembles, const double time_step, const bool compute_gradient)
Updates the contents on the lattice of DensityOnLattice type.
 
LatticeUpdate
Enumerator option for lattice updates.
 
double smearing_factor_rcut_correction(const double rcut_in_sigma)
Gaussians used for smearing are cut at radius  for calculation speed-up.
 
std::pair< double, ThreeVector > unnormalized_smearing_factor(const ThreeVector &r, const FourVector &p, const double m_inv, const DensityParameters &dens_par, const bool compute_gradient=false)
Implements gaussian smearing for any quantity.
 
RectangularLattice< DensityOnLattice > DensityLattice
Conveniency typedef for lattice of density.
 
constexpr double really_small
Numerical error tolerance.
 
DensityType
Allows to choose which kind of density to calculate.
 
double density_factor(const ParticleType &type, DensityType dens_type)
Get the factor that determines how much a particle contributes to the density type that is computed.
 
static constexpr int LDensity
 
Helper structure for Experiment.
 
double gauss_cutoff_in_sigma
Distance at which gaussian is cut, i.e. set to zero, IN SIGMA (not fm)