9 #ifndef SRC_INCLUDE_DENSITY_H_ 10 #define SRC_INCLUDE_DENSITY_H_ 76 const double tmp = two_sigma_sqr * M_PI;
77 return tmp * std::sqrt(tmp);
98 const double x = rcut_in_sigma / std::sqrt(2.0);
99 return -2.0 / std::sqrt(M_PI) * x * std::exp(-x * x) + std::erf(x);
117 : sig_(par.gaussian_sigma),
118 r_cut_(par.gauss_cutoff_in_sigma * par.gaussian_sigma),
119 ntest_(par.testparticles) {
120 r_cut_sqr_ = r_cut_ * r_cut_;
121 const double two_sig_sqr = 2 * sig_ * sig_;
122 two_sig_sqr_inv_ = 1. / two_sig_sqr;
124 const double corr_factor =
126 norm_factor_sf_ = 1. / (norm * ntest_ * corr_factor);
129 int ntest()
const {
return ntest_; }
131 double r_cut()
const {
return r_cut_; }
225 std::tuple<double, FourVector, ThreeVector, ThreeVector, ThreeVector>
228 bool compute_gradient,
bool smearing);
230 std::tuple<double, FourVector, ThreeVector, ThreeVector, ThreeVector>
233 bool compute_gradient,
bool smearing);
278 if (FactorTimesSf > 0.0) {
279 jmu_pos_ += PartFourVelocity * FactorTimesSf;
281 jmu_neg_ += PartFourVelocity * FactorTimesSf;
300 for (
int k = 1; k <= 3; k++) {
301 djmu_dx_[k] += factor * PartFourVelocity * sf_grad[k - 1];
303 factor * PartFourVelocity * sf_grad[k - 1] * part.
velocity()[k - 1];
324 double density(
const double norm_factor = 1.0) {
325 return (jmu_pos_.abs() - jmu_neg_.abs()) * norm_factor;
336 j_rot.
set_x1(djmu_dx_[2].x3() - djmu_dx_[3].x2());
337 j_rot.
set_x2(djmu_dx_[3].x1() - djmu_dx_[1].x3());
338 j_rot.
set_x3(djmu_dx_[1].x2() - djmu_dx_[2].x1());
339 j_rot *= norm_factor;
351 for (
int i = 1; i < 4; i++) {
352 rho_grad[i - 1] = djmu_dx_[i].x0() * norm_factor;
364 return djmu_dx_[0].threevec() * norm_factor;
399 template <
typename T>
403 const bool compute_gradient =
false) {
405 if (lat ==
nullptr || lat->
when_update() != update) {
410 for (
const auto &part : particles) {
411 const double dens_factor =
density_factor(part.type(), dens_type);
416 const double m = p.
abs();
418 const auto &log = logger<LogArea::Density>();
419 log.warn(
"Gaussian smearing is undefined for momentum ", p);
422 const double m_inv = 1.0 / m;
424 const ThreeVector pos = part.position().threevec();
426 pos, par.
r_cut(), [&](T &node,
int ix,
int iy,
int iz) {
431 node.add_particle(part, sf.first * norm_factor * dens_factor);
433 if (compute_gradient) {
434 node.add_particle_for_derivatives(part, dens_factor,
435 sf.second * norm_factor);
443 #endif // SRC_INCLUDE_DENSITY_H_ A class to pre-calculate and store parameters relevant for density calculation.
std::array< FourVector, 4 > djmu_dx_
A class for time-efficient (time-memory trade-off) calculation of density on the lattice.
The ThreeVector class represents a physical three-vector with the components .
DensityParameters(const ExperimentParameters &par)
Constructor of DensityParameters.
constexpr double really_small
Numerical error tolerance.
FourVector jmu_neg_
Four-current density of the negatively charged particle.
const int ntest_
Testparticle number.
void add_particle(const ParticleData &part, double FactorTimesSf)
Adds particle to 4-current: .
const double sig_
Gaussian smearing width [fm].
void update_lattice(RectangularLattice< T > *lat, const LatticeUpdate update, const DensityType dens_type, const DensityParameters &par, const Particles &particles, const bool compute_gradient=false)
Updates the contents on the lattice.
double abs() const
calculate the lorentz invariant absolute value
LatticeUpdate
Enumerator option for lattice updates.
ThreeVector velocity() const
Get the velocity 3-vector.
FourVector jmu_net() const
void iterate_in_radius(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 giv...
void set_x1(double x)
set first component
double two_sig_sqr_inv_
[fm ]
A container class to hold all the arrays on the lattice and access them.
LatticeUpdate when_update() const
void reset()
Sets all values on lattice to zeros.
ThreeVector cell_center(int ix, int iy, int iz) const
Find the coordinates of a given cell.
DensityOnLattice()
Default constructor.
double gauss_cutoff_in_sigma
Distance at which gaussian is cut, i.e. set to zero, IN SIGMA (not fm)
Particle type contains the static properties of a particle species.
ThreeVector rot_j(const double norm_factor=1.0)
Compute curl of the current on the local lattice.
double norm_factor_sf_
Normalization for smearing factor.
double smearing_factor_rcut_correction(const double rcut_in_sigma)
Gaussians used for smearing are cut at radius for calculation speed-up.
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...
ThreeVector dj_dt(const double norm_factor=1.0)
Compute time derivative of the current density on the local lattice.
std::tuple< double, FourVector, ThreeVector, ThreeVector, ThreeVector > 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 set_x3(double z)
set third component
double smearing_factor_norm(const double two_sigma_sqr)
Norm of the Gaussian smearing function.
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.
const double r_cut_
Cut-off radius [fm].
double two_sig_sqr_inv() const
#define unlikely(x)
Tell the branch predictor that this expression is likely false.
FourVector jmu_pos_
Four-current density of the positively charged particle.
double norm_factor_sf() const
The Particles class abstracts the storage and manipulation of particles.
DensityType
Allows to choose which kind of density to calculate.
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Convenience: dereferences the ActionPtr to Action.
ThreeVector grad_rho(const double norm_factor=1.0)
Compute gradient of the density on the local lattice.
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
double density(const double norm_factor=1.0)
Compute the net Eckart density on the local lattice.
RectangularLattice< DensityOnLattice > DensityLattice
Conveniency typedef for lattice of density.
Helper structure for Experiment.
ParticleData contains the dynamic information of a certain particle.
void set_x2(double y)
set second component
double r_cut_sqr_
Squared cut-off radius [fm ].
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.