[yt-svn] commit/yt: MatthewTurk: Merged in ngoldbaum/yt (pull request #1173)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Tue Sep 2 15:49:36 PDT 2014
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/4966afceaddf/
Changeset: 4966afceaddf
Branch: yt
User: MatthewTurk
Date: 2014-09-03 00:49:27
Summary: Merged in ngoldbaum/yt (pull request #1173)
Enabling deposited particle velocity fields.
Affected #: 1 file
diff -r d5abcd31e49c5aeaad7dca2a155bba1394341bad -r 4966afceaddf8602f20a7a95aa02afd17bfaca39 yt/fields/particle_fields.py
--- a/yt/fields/particle_fields.py
+++ b/yt/fields/particle_fields.py
@@ -125,6 +125,33 @@
display_name = "\\mathrm{%s CIC Density}" % ptype_dn,
units = "g/cm**3")
+ def _get_density_weighted_deposit_field(fname, units, method):
+ def _deposit_field(field, data):
+ """
+ Create a grid field for particle quantities weighted by particle
+ mass, using cloud-in-cell deposit.
+ """
+ pos = data[ptype, "particle_position"]
+ # Get back into density
+ pden = data[ptype, 'particle_mass']
+ top = data.deposit(pos, [data[(ptype, fname)]*pden], method=method)
+ bottom = data.deposit(pos, [pden], method=method)
+ top[bottom == 0] = 0.0
+ bnz = bottom.nonzero()
+ top[bnz] /= bottom[bnz]
+ d = data.ds.arr(top, input_units=units)
+ return d
+ return _deposit_field
+
+ for ax in 'xyz':
+ for method, name in zip(("cic", "sum"), ("cic", "nn")):
+ function = _get_density_weighted_deposit_field(
+ "particle_velocity_%s" % ax, "cm/s", method)
+ registry.add_field(
+ ("deposit", ("%s_"+name+"_velocity_%s") % (ptype, ax)),
+ function=function, units="cm/s", take_log=False,
+ validators=[ValidateSpatial(0)])
+
# Now some translation functions.
def particle_ones(field, data):
@@ -490,31 +517,6 @@
validators=[ValidateParameter("normal"),
ValidateParameter("center")])
- def _get_cic_field(fname, units):
- def _cic_particle_field(field, data):
- """
- Create a grid field for particle quantities weighted by particle
- mass, using cloud-in-cell deposit.
- """
- pos = data[ptype, "particle_position"]
- # Get back into density
- pden = data[ptype, 'particle_mass'] / data["index", "cell_volume"]
- top = data.deposit(pos, [data[('all', particle_field)]*pden],
- method = 'cic')
- bottom = data.deposit(pos, [pden], method = 'cic')
- top[bottom == 0] = 0.0
- bnz = bottom.nonzero()
- top[bnz] /= bottom[bnz]
- d = data.ds.arr(top, input_units = units)
- return top
-
- for ax in 'xyz':
- registry.add_field(
- ("deposit", "%s_cic_velocity_%s" % (ptype, ax)),
- function=_get_cic_field(svel % ax, "cm/s"),
- units = "cm/s", take_log=False,
- validators=[ValidateSpatial(0)])
-
def add_particle_average(registry, ptype, field_name,
weight = "particle_mass",
density = True):
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