[yt-svn] commit/yt: jzuhone: We have to use the "mass" corresponding to the density field, otherwise the particle distribution isn't quite right, thanks to AMR.
Bitbucket
commits-noreply at bitbucket.org
Sun Dec 9 21:35:31 PST 2012
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/changeset/6c8b29681fef/
changeset: 6c8b29681fef
branch: yt
user: jzuhone
date: 2012-12-10 06:34:45
summary: We have to use the "mass" corresponding to the density field, otherwise the particle distribution isn't quite right, thanks to AMR.
affected #: 1 file
diff -r 7fe902d74ea4da03d4c1cf13b791f612490bc767 -r 6c8b29681fef1e54d9486a65567b05ed1d938745 yt/utilities/particle_generator.py
--- a/yt/utilities/particle_generator.py
+++ b/yt/utilities/particle_generator.py
@@ -330,7 +330,8 @@
ParticleGenerator.__init__(self, pf, num_particles, field_list)
num_cells = len(data_source["x"].flat)
- max_density = data_source[density_field].max()
+ max_mass = (data_source[density_field]*
+ data_source["CellVolume"]).max()
num_particles_left = num_particles
all_x = []
all_y = []
@@ -341,12 +342,13 @@
while num_particles_left > 0:
- rho = np.random.uniform(high=1.01*max_density,
- size=num_particles_left)
+ m = np.random.uniform(high=1.01*max_mass,
+ size=num_particles_left)
idxs = np.random.random_integers(low=0, high=num_cells-1,
size=num_particles_left)
- rho_true = data_source[density_field].flat[idxs]
- accept = rho <= rho_true
+ m_true = (data_source[density_field]*
+ data_source["CellVolume"]).flat[idxs]
+ accept = m <= m_true
num_accepted = accept.sum()
accepted_idxs = idxs[accept]
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list