Removed the rejection sampling for the
density drawing position distribution
This commit is contained in:
@@ -44,30 +44,31 @@ class PositionDistributionFromDensity {
|
|||||||
// Constructor taking a pointer to a DynamicDensityField object
|
// Constructor taking a pointer to a DynamicDensityField object
|
||||||
PositionDistributionFromDensity(std::shared_ptr<DynamicDensityField> density);
|
PositionDistributionFromDensity(std::shared_ptr<DynamicDensityField> density);
|
||||||
|
|
||||||
// draw a position from the density provided at construction using the rejection method
|
// // draw a position from the density provided at construction using the rejection method
|
||||||
CylinderCoordinate drawPosition(std::mt19937* engine);
|
// CylinderCoordinate drawPosition(std::mt19937* engine);
|
||||||
|
|
||||||
// draw a position uniformly distributed within the bin of the given index
|
// draw a position uniformly distributed within the bin of the given index
|
||||||
// (note that the r-dependence of the particle number in a uniform density distribution
|
// (note that the r-dependence of the particle number in a uniform density distribution
|
||||||
// is not incorporated)
|
// is not incorporated)
|
||||||
CylinderCoordinate drawPosition(std::mt19937* engine, int r_idx, int phi_idx,
|
CylinderCoordinate drawPosition(std::mt19937* engine, int r_idx, int phi_idx,
|
||||||
int z_idx);
|
int z_idx);
|
||||||
// sets the maximum density value needed for the rejection method
|
// // sets the maximum density value needed for the rejection method
|
||||||
// should not be called frequently, since during each call the density field is
|
// // should not be called frequently, since during each call the density field is
|
||||||
// recalculated from scratch by the DynamicDensityField object
|
// // recalculated from scratch by the DynamicDensityField object
|
||||||
void setMaximumDensity();
|
// void setMaximumDensity();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// variable storing the maximum value of the density
|
// variable storing the maximum value of the density
|
||||||
double maximum_density_ = 1.;
|
// double maximum_density_ = 1.;
|
||||||
|
|
||||||
std::shared_ptr<DynamicDensityField> density_;
|
std::shared_ptr<DynamicDensityField> density_;
|
||||||
|
|
||||||
// distributions for the spatial directions and for the density
|
// // distributions for the spatial directions and for the density
|
||||||
std::uniform_real_distribution<double> r_values;
|
// std::uniform_real_distribution<double> r_values;
|
||||||
std::uniform_real_distribution<double> phi_values;
|
// std::uniform_real_distribution<double> phi_values;
|
||||||
std::uniform_real_distribution<double> z_values;
|
// std::uniform_real_distribution<double> z_values;
|
||||||
std::uniform_real_distribution<double> density_values;
|
// std::uniform_real_distribution<double> density_values;
|
||||||
|
std::uniform_real_distribution<double> std_unifrm;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* EVENT_POSITION_DISTRIBUTION_H */
|
#endif /* EVENT_POSITION_DISTRIBUTION_H */
|
||||||
|
|||||||
+1
-1
@@ -57,7 +57,7 @@ void Restart::restart(
|
|||||||
std::string path = pair.second->name() + "/DensityField/SimulationData/" +
|
std::string path = pair.second->name() + "/DensityField/SimulationData/" +
|
||||||
restart_identifier_;
|
restart_identifier_;
|
||||||
restartDrawingDensityField(pair.second->densityForDrawing(), path);
|
restartDrawingDensityField(pair.second->densityForDrawing(), path);
|
||||||
pair.second->positionDistributionFromDensity()->setMaximumDensity();
|
// pair.second->positionDistributionFromDensity()->setMaximumDensity();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
|
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ CylinderCoordinate EventPositionDistribution::rollPosition(
|
|||||||
PositionDistributionFromDensity::PositionDistributionFromDensity(
|
PositionDistributionFromDensity::PositionDistributionFromDensity(
|
||||||
std::shared_ptr<DynamicDensityField> density):
|
std::shared_ptr<DynamicDensityField> density):
|
||||||
density_(density),
|
density_(density),
|
||||||
density_values(std::uniform_real_distribution<double>(0.,1.)) {
|
std_unifrm(std::uniform_real_distribution<double>(0.,1.)) {
|
||||||
|
/************************************************************************************
|
||||||
// get the extent of the domain of the DynamicDensityField object to be used for
|
// get the extent of the domain of the DynamicDensityField object to be used for
|
||||||
// the rejection method
|
// the rejection method
|
||||||
double rmin = density->positionBinning()->radial_binning.binBorders().front();
|
double rmin = density->positionBinning()->radial_binning.binBorders().front();
|
||||||
@@ -60,9 +60,10 @@ PositionDistributionFromDensity::PositionDistributionFromDensity(
|
|||||||
r_values = std::uniform_real_distribution<double>(rmin*rmin, rmax*rmax);
|
r_values = std::uniform_real_distribution<double>(rmin*rmin, rmax*rmax);
|
||||||
phi_values = std::uniform_real_distribution<double>(phimin, phimax);
|
phi_values = std::uniform_real_distribution<double>(phimin, phimax);
|
||||||
z_values = std::uniform_real_distribution<double>(zmin, zmax);
|
z_values = std::uniform_real_distribution<double>(zmin, zmax);
|
||||||
|
**************************************************************************************/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
void PositionDistributionFromDensity::setMaximumDensity() {
|
void PositionDistributionFromDensity::setMaximumDensity() {
|
||||||
maximum_density_ = blitz::max(density_->densityArray());
|
maximum_density_ = blitz::max(density_->densityArray());
|
||||||
}
|
}
|
||||||
@@ -88,6 +89,7 @@ CylinderCoordinate PositionDistributionFromDensity::drawPosition(std::mt19937* e
|
|||||||
return CylinderCoordinate(
|
return CylinderCoordinate(
|
||||||
blitz::TinyVector<double, 3>(random_r, random_phi, random_z));
|
blitz::TinyVector<double, 3>(random_r, random_phi, random_z));
|
||||||
}
|
}
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
CylinderCoordinate PositionDistributionFromDensity::drawPosition(std::mt19937* engine,
|
CylinderCoordinate PositionDistributionFromDensity::drawPosition(std::mt19937* engine,
|
||||||
int r_idx, int phi_idx, int z_idx) {
|
int r_idx, int phi_idx, int z_idx) {
|
||||||
@@ -102,9 +104,9 @@ CylinderCoordinate PositionDistributionFromDensity::drawPosition(std::mt19937* e
|
|||||||
|
|
||||||
double r_rndm, phi_rndm, z_rndm;
|
double r_rndm, phi_rndm, z_rndm;
|
||||||
|
|
||||||
r_rndm = density_values(*engine);
|
r_rndm = std_unifrm(*engine);
|
||||||
phi_rndm = density_values(*engine);
|
phi_rndm = std_unifrm(*engine);
|
||||||
z_rndm = density_values(*engine);
|
z_rndm = std_unifrm(*engine);
|
||||||
|
|
||||||
double radius = std::sqrt(left_bin_border_radial*left_bin_border_radial +
|
double radius = std::sqrt(left_bin_border_radial*left_bin_border_radial +
|
||||||
(2*left_bin_border_radial + stepsize(0))
|
(2*left_bin_border_radial + stepsize(0))
|
||||||
|
|||||||
Reference in New Issue
Block a user