[yt-svn] commit/yt-3.0: 4 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Fri May 24 08:16:14 PDT 2013


4 new commits in yt-3.0:

https://bitbucket.org/yt_analysis/yt-3.0/commits/092f2338cb85/
Changeset:   092f2338cb85
Branch:      yt-3.0
User:        MatthewTurk
Date:        2013-05-23 16:09:37
Summary:     A few units tweaks for RAMSES.  Also implemented Temperature derived field.

Note that this temperature field may require a mu that is not yet specified.
Affected #:  2 files

diff -r 4dcdcbad4ae304727cd63a5eca39a0bab7dab952 -r 092f2338cb8541e88eb0e2ac048130cf3db079ab yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -429,8 +429,10 @@
         self.time_units['1'] = 1
         self.units['1'] = 1.0
         self.units['unitary'] = 1.0 / (self.domain_right_edge - self.domain_left_edge).max()
-        self.conversion_factors["Density"] = self.parameters['unit_d']
+        rho_u = self.parameters['unit_d']
+        self.conversion_factors["Density"] = rho_u
         vel_u = self.parameters['unit_l'] / self.parameters['unit_t']
+        self.conversion_factors["Pressure"] = rho_u*vel_u**2
         self.conversion_factors["x-velocity"] = vel_u
         self.conversion_factors["y-velocity"] = vel_u
         self.conversion_factors["z-velocity"] = vel_u
@@ -499,6 +501,5 @@
     def _is_valid(self, *args, **kwargs):
         if not os.path.basename(args[0]).startswith("info_"): return False
         fn = args[0].replace("info_", "amr_").replace(".txt", ".out00001")
-        print fn
         return os.path.exists(fn)
 

diff -r 4dcdcbad4ae304727cd63a5eca39a0bab7dab952 -r 092f2338cb8541e88eb0e2ac048130cf3db079ab yt/frontends/ramses/fields.py
--- a/yt/frontends/ramses/fields.py
+++ b/yt/frontends/ramses/fields.py
@@ -34,6 +34,9 @@
     ValidateSpatial, \
     ValidateGridType
 import yt.data_objects.universal_fields
+from yt.utilities.physical_constants import \
+    boltzmann_constant_cgs, \
+    mass_hydrogen_cgs
 
 RAMSESFieldInfo = FieldInfoContainer.create_with_fallback(FieldInfo, "RFI")
 add_field = RAMSESFieldInfo.add_field
@@ -73,6 +76,11 @@
 KnownRAMSESFields["Density"]._projected_units = r"\rm{g}/\rm{cm}^2"
 KnownRAMSESFields["Density"]._convert_function=_convertDensity
 
+def _convertPressure(data):
+    return data.convert("Pressure")
+KnownRAMSESFields["Pressure"]._units=r"\rm{dyne}/\rm{cm}^{2}/\mu"
+KnownRAMSESFields["Pressure"]._convert_function=_convertPressure
+
 def _convertVelocity(data):
     return data.convert("x-velocity")
 for ax in ['x','y','z']:
@@ -134,3 +142,9 @@
                 just_one(data["CellVolumeCode"].ravel())
     # Note that we mandate grid-type here, so this is okay
     return particles
+
+def _Temperature(field, data):
+    rv = data["Pressure"]/data["Density"]
+    rv *= mass_hydrogen_cgs/boltzmann_constant_cgs
+    return rv
+add_field("Temperature", function=_Temperature, units=r"\rm{K}")


https://bitbucket.org/yt_analysis/yt-3.0/commits/1e258e92949d/
Changeset:   1e258e92949d
Branch:      yt-3.0
User:        MatthewTurk
Date:        2013-05-23 16:19:29
Summary:     Hubble Constant for us is normalized to 100.
Affected #:  1 file

diff -r 092f2338cb8541e88eb0e2ac048130cf3db079ab -r 1e258e92949d5f699268a1d784101aa19bd6ae90 yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -488,13 +488,13 @@
         self.domain_right_edge = np.ones(3, dtype='float64')
         # This is likely not true, but I am not sure how to otherwise
         # distinguish them.
-        mylog.warning("No current mechanism of distinguishing cosmological simulations in RAMSES!")
+        mylog.warning("RAMSES frontend assumes all simulations are cosmological!")
         self.cosmological_simulation = 1
         self.periodicity = (True, True, True)
         self.current_redshift = (1.0 / rheader["aexp"]) - 1.0
         self.omega_lambda = rheader["omega_l"]
         self.omega_matter = rheader["omega_m"]
-        self.hubble_constant = rheader["H0"]
+        self.hubble_constant = rheader["H0"] / 100.0 # This is H100
         self.max_level = rheader['levelmax'] - rheader['levelmin']
 
     @classmethod


https://bitbucket.org/yt_analysis/yt-3.0/commits/69d81d1f44f2/
Changeset:   69d81d1f44f2
Branch:      yt-3.0
User:        MatthewTurk
Date:        2013-05-23 18:55:19
Summary:     Fixing RAMSES length units and adding particle mass conversions.
Affected #:  2 files

diff -r 1e258e92949d5f699268a1d784101aa19bd6ae90 -r 69d81d1f44f25bd0eb1ed9eee9b23ae04032ef4d yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -436,10 +436,13 @@
         self.conversion_factors["x-velocity"] = vel_u
         self.conversion_factors["y-velocity"] = vel_u
         self.conversion_factors["z-velocity"] = vel_u
+        # Necessary to get the length units in, which are needed for Mass
+        self.conversion_factors['mass'] = rho_u * self.parameters['unit_l']**3
 
     def _setup_nounits_units(self):
+        unit_l_prop = self.parameters['unit_l'] / (1.0 + self.current_redshift)
         for unit in mpc_conversion.keys():
-            self.units[unit] = self.parameters['unit_l'] * mpc_conversion[unit] / mpc_conversion["cm"]
+            self.units[unit] = unit_l_prop * mpc_conversion[unit] / mpc_conversion["cm"]
         for unit in sec_conversion.keys():
             self.time_units[unit] = self.parameters['unit_t'] / sec_conversion[unit]
 

diff -r 1e258e92949d5f699268a1d784101aa19bd6ae90 -r 69d81d1f44f25bd0eb1ed9eee9b23ae04032ef4d yt/frontends/ramses/fields.py
--- a/yt/frontends/ramses/fields.py
+++ b/yt/frontends/ramses/fields.py
@@ -109,39 +109,24 @@
                   validators = [ValidateDataField(f)],
                   particle_type = True)
 
-def _ParticleMass(field, data):
-    particles = data["particle_mass"].astype('float64') * \
-                just_one(data["CellVolumeCode"].ravel())
-    # Note that we mandate grid-type here, so this is okay
-    return particles
+for ax in 'xyz':
+    KnownRAMSESFields["particle_velocity_%s" % ax]._convert_function = \
+        _convertVelocity
 
 def _convertParticleMass(data):
-    return data.convert("Density")*(data.convert("cm")**3.0)
-def _IOLevelParticleMass(grid):
-    dd = dict(particle_mass = np.ones(1), CellVolumeCode=grid["CellVolumeCode"])
-    cf = (_ParticleMass(None, dd) * _convertParticleMass(grid))[0]
-    return cf
+    return data.convert("mass")
+
+KnownRAMSESFields["particle_mass"]._convert_function = \
+        _convertParticleMass
+KnownRAMSESFields["particle_mass"]._units = r"\mathrm{g}"
+
 def _convertParticleMassMsun(data):
-    return data.convert("Density")*((data.convert("cm")**3.0)/1.989e33)
-def _IOLevelParticleMassMsun(grid):
-    dd = dict(particle_mass = np.ones(1), CellVolumeCode=grid["CellVolumeCode"])
-    cf = (_ParticleMass(None, dd) * _convertParticleMassMsun(grid))[0]
-    return cf
-add_field("ParticleMass",
-          function=_ParticleMass, validators=[ValidateSpatial(0)],
-          particle_type=True, convert_function=_convertParticleMass,
-          particle_convert_function=_IOLevelParticleMass)
+    return 1.0/1.989e33
+add_field("ParticleMass", function=TranslationFunc("particle_mass"), 
+          particle_type=True)
 add_field("ParticleMassMsun",
-          function=_ParticleMass, validators=[ValidateSpatial(0)],
-          particle_type=True, convert_function=_convertParticleMassMsun,
-          particle_convert_function=_IOLevelParticleMassMsun)
-
-
-def _ParticleMass(field, data):
-    particles = data["particle_mass"].astype('float64') * \
-                just_one(data["CellVolumeCode"].ravel())
-    # Note that we mandate grid-type here, so this is okay
-    return particles
+          function=TranslationFunc("particle_mass"), 
+          particle_type=True, convert_function=_convertParticleMassMsun)
 
 def _Temperature(field, data):
     rv = data["Pressure"]/data["Density"]


https://bitbucket.org/yt_analysis/yt-3.0/commits/b20f76ccd3c3/
Changeset:   b20f76ccd3c3
Branch:      yt-3.0
User:        MatthewTurk
Date:        2013-05-24 15:02:39
Summary:     Removing factor of 1+z from length calculation in RAMSES.
Affected #:  1 file

diff -r 69d81d1f44f25bd0eb1ed9eee9b23ae04032ef4d -r b20f76ccd3c34bac9c187272593f9f49b58e7795 yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -440,9 +440,10 @@
         self.conversion_factors['mass'] = rho_u * self.parameters['unit_l']**3
 
     def _setup_nounits_units(self):
-        unit_l_prop = self.parameters['unit_l'] / (1.0 + self.current_redshift)
+        # Note that unit_l *already* converts to proper!
+        unit_l = self.parameters['unit_l']
         for unit in mpc_conversion.keys():
-            self.units[unit] = unit_l_prop * mpc_conversion[unit] / mpc_conversion["cm"]
+            self.units[unit] = unit_l * mpc_conversion[unit] / mpc_conversion["cm"]
         for unit in sec_conversion.keys():
             self.time_units[unit] = self.parameters['unit_t'] / sec_conversion[unit]

Repository URL: https://bitbucket.org/yt_analysis/yt-3.0/

--

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