[yt-svn] commit/yt: 3 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Jul 23 09:27:06 PDT 2015


3 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/8720621b3491/
Changeset:   8720621b3491
Branch:      yt
User:        BW Keller
Date:        2015-07-15 00:12:23+00:00
Summary:     Tipsy datasets were not being generated with smoothing lengths, and this led to some strange behaviour
(biases in calculations of cell-averaged quantities and plots).
Affected #:  1 file

diff -r 0d6ac4368c991d9fd829d41fd4499c52971045e9 -r 8720621b3491489baf0dfe6a235a928433590052 yt/frontends/tipsy/fields.py
--- a/yt/frontends/tipsy/fields.py
+++ b/yt/frontends/tipsy/fields.py
@@ -16,6 +16,8 @@
 #-----------------------------------------------------------------------------
 
 from yt.frontends.sph.fields import SPHFieldInfo
+from yt.fields.particle_fields import add_volume_weighted_smoothed_field, add_nearest_neighbor_field
+from yt.utilities.physical_constants import mp, kb
 
 class TipsyFieldInfo(SPHFieldInfo):
     aux_particle_fields = {
@@ -44,3 +46,29 @@
                 self.aux_particle_fields[field[1]] not in self.known_particle_fields:
                 self.known_particle_fields += (self.aux_particle_fields[field[1]],)
         super(TipsyFieldInfo,self).__init__(ds, field_list, slice_info)
+
+    def setup_particle_fields(self, ptype, *args, **kwargs):
+
+        # setup some special fields that only make sense for SPH particles
+
+        if ptype in ("PartType0", "Gas"):
+            self.setup_gas_particle_fields(ptype)
+
+        super(TipsyFieldInfo, self).setup_particle_fields(
+            ptype, *args, **kwargs)
+
+
+    def setup_gas_particle_fields(self, ptype):
+
+        def _smoothing_length(field, data):
+            # For now, we hardcode num_neighbors.  We should make this configurable
+            # in the future.
+            num_neighbors = 64
+            fn, = add_nearest_neighbor_field(ptype, "particle_position", self, num_neighbors)
+            return data[ptype, 'nearest_neighbor_distance_%d' % num_neighbors]
+
+        self.add_field(
+            (ptype, "smoothing_length"),
+            function=_smoothing_length,
+            particle_type=True,
+            units="code_length")


https://bitbucket.org/yt_analysis/yt/commits/97561feef687/
Changeset:   97561feef687
Branch:      yt
User:        BW Keller
Date:        2015-07-18 16:19:54+00:00
Summary:     Tipsy datasets were not being generated with smoothing lengths, and this led to some strange behaviour
Affected #:  2 files

diff -r 04499d34ddbd8f91389560984b3da1bc75ac3e51 -r 97561feef6874182ca5f96f31e70e744f4b957d0 yt/frontends/tipsy/data_structures.py
--- a/yt/frontends/tipsy/data_structures.py
+++ b/yt/frontends/tipsy/data_structures.py
@@ -180,7 +180,7 @@
                 self.domain_left_edge = None
                 self.domain_right_edge = None
         else: 
-            bbox = self.arr(self.bounding_box, 'code_length', dtype="float64")
+            bbox = np.array(self.bounding_box, dtype="float64")
             if bbox.shape == (2, 3):
                 bbox = bbox.transpose()
             self.domain_left_edge = bbox[:,0]

diff -r 04499d34ddbd8f91389560984b3da1bc75ac3e51 -r 97561feef6874182ca5f96f31e70e744f4b957d0 yt/frontends/tipsy/fields.py
--- a/yt/frontends/tipsy/fields.py
+++ b/yt/frontends/tipsy/fields.py
@@ -16,6 +16,8 @@
 #-----------------------------------------------------------------------------
 
 from yt.frontends.sph.fields import SPHFieldInfo
+from yt.fields.particle_fields import add_volume_weighted_smoothed_field, add_nearest_neighbor_field
+from yt.utilities.physical_constants import mp, kb
 
 class TipsyFieldInfo(SPHFieldInfo):
     aux_particle_fields = {
@@ -44,3 +46,29 @@
                 self.aux_particle_fields[field[1]] not in self.known_particle_fields:
                 self.known_particle_fields += (self.aux_particle_fields[field[1]],)
         super(TipsyFieldInfo,self).__init__(ds, field_list, slice_info)
+
+    def setup_particle_fields(self, ptype, *args, **kwargs):
+
+        # setup some special fields that only make sense for SPH particles
+
+        if ptype in ("PartType0", "Gas"):
+            self.setup_gas_particle_fields(ptype)
+
+        super(TipsyFieldInfo, self).setup_particle_fields(
+            ptype, *args, **kwargs)
+
+
+    def setup_gas_particle_fields(self, ptype):
+
+        def _smoothing_length(field, data):
+            # For now, we hardcode num_neighbors.  We should make this configurable
+            # in the future.
+            num_neighbors = 64
+            fn, = add_nearest_neighbor_field(ptype, "particle_position", self, num_neighbors)
+            return data[ptype, 'nearest_neighbor_distance_%d' % num_neighbors]
+
+        self.add_field(
+            (ptype, "smoothing_length"),
+            function=_smoothing_length,
+            particle_type=True,
+            units="code_length")


https://bitbucket.org/yt_analysis/yt/commits/f5d20191a6e2/
Changeset:   f5d20191a6e2
Branch:      yt
User:        brittonsmith
Date:        2015-07-23 16:26:56+00:00
Summary:     Merged in bwkeller/yt (pull request #1648)

[BUGFIX] Smoothing Lengths for Tipsy Datasets
Affected #:  1 file

diff -r fcc7f7abfff1f2d6c0598bc54b421121ab4d029b -r f5d20191a6e277fa4b3028052806d82023bd6c65 yt/frontends/tipsy/fields.py
--- a/yt/frontends/tipsy/fields.py
+++ b/yt/frontends/tipsy/fields.py
@@ -16,6 +16,8 @@
 #-----------------------------------------------------------------------------
 
 from yt.frontends.sph.fields import SPHFieldInfo
+from yt.fields.particle_fields import add_volume_weighted_smoothed_field, add_nearest_neighbor_field
+from yt.utilities.physical_constants import mp, kb
 
 class TipsyFieldInfo(SPHFieldInfo):
     aux_particle_fields = {
@@ -44,3 +46,29 @@
                 self.aux_particle_fields[field[1]] not in self.known_particle_fields:
                 self.known_particle_fields += (self.aux_particle_fields[field[1]],)
         super(TipsyFieldInfo,self).__init__(ds, field_list, slice_info)
+
+    def setup_particle_fields(self, ptype, *args, **kwargs):
+
+        # setup some special fields that only make sense for SPH particles
+
+        if ptype in ("PartType0", "Gas"):
+            self.setup_gas_particle_fields(ptype)
+
+        super(TipsyFieldInfo, self).setup_particle_fields(
+            ptype, *args, **kwargs)
+
+
+    def setup_gas_particle_fields(self, ptype):
+
+        def _smoothing_length(field, data):
+            # For now, we hardcode num_neighbors.  We should make this configurable
+            # in the future.
+            num_neighbors = 64
+            fn, = add_nearest_neighbor_field(ptype, "particle_position", self, num_neighbors)
+            return data[ptype, 'nearest_neighbor_distance_%d' % num_neighbors]
+
+        self.add_field(
+            (ptype, "smoothing_length"),
+            function=_smoothing_length,
+            particle_type=True,
+            units="code_length")

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