[yt-svn] commit/yt: chummels: Merged in ngoldbaum/yt (pull request #1710)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Thu Aug 27 09:31:07 PDT 2015
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/14a4cacf4dfa/
Changeset: 14a4cacf4dfa
Branch: yt
User: chummels
Date: 2015-08-27 16:30:51+00:00
Summary: Merged in ngoldbaum/yt (pull request #1710)
Gadget cosmology simulation unit fixes
Affected #: 2 files
diff -r 5e5edba3739c1b8c9f8ee2d32e87304bc64557bf -r 14a4cacf4dfaa1b0af3830e7d2efa1ab69db1b35 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -683,6 +683,7 @@
self.unit_registry.add("code_velocity", 1.0, dimensions.velocity)
self.unit_registry.add("code_metallicity", 1.0,
dimensions.dimensionless)
+ self.unit_registry.add("a", 1.0, dimensions.dimensionless)
def set_units(self):
"""
@@ -700,6 +701,7 @@
self.unit_registry.add(new_unit, self.unit_registry.lut[my_unit][0] /
(1 + self.current_redshift),
length, "\\rm{%s}/(1+z)" % my_unit)
+ self.unit_registry.modify('a', 1/(1+self.current_redshift))
self.set_code_units()
diff -r 5e5edba3739c1b8c9f8ee2d32e87304bc64557bf -r 14a4cacf4dfaa1b0af3830e7d2efa1ab69db1b35 yt/frontends/gadget/data_structures.py
--- a/yt/frontends/gadget/data_structures.py
+++ b/yt/frontends/gadget/data_structures.py
@@ -108,6 +108,14 @@
raise RuntimeError("units_override is not supported for GadgetDataset. "+
"Use unit_base instead.")
super(GadgetDataset, self).__init__(filename, dataset_type)
+ if self.cosmological_simulation:
+ self.time_unit.convert_to_units('s/h')
+ self.length_unit.convert_to_units('kpccm/h')
+ self.mass_unit.convert_to_units('g/h')
+ else:
+ self.time_unit.convert_to_units('s')
+ self.length_unit.convert_to_units('kpc')
+ self.mass_unit.convert_to_units('Msun')
def _setup_binary_spec(self, spec, spec_dict):
if isinstance(spec, str):
@@ -218,12 +226,21 @@
self.length_unit = self.quan(length_unit[0], length_unit[1])
unit_base = self._unit_base or {}
+
+ if self.cosmological_simulation:
+ # see http://www.mpa-garching.mpg.de/gadget/gadget-list/0113.html
+ # for why we need to include a factor of square root of the
+ # scale factor
+ vel_units = "cm/s * sqrt(a)"
+ else:
+ vel_units = "cm/s"
+
if "velocity" in unit_base:
velocity_unit = unit_base["velocity"]
elif "UnitVelocity_in_cm_per_s" in unit_base:
- velocity_unit = (unit_base["UnitVelocity_in_cm_per_s"], "cm/s")
+ velocity_unit = (unit_base["UnitVelocity_in_cm_per_s"], vel_units)
else:
- velocity_unit = (1e5, "cm/s")
+ velocity_unit = (1e5, vel_units)
velocity_unit = _fix_unit_ordering(velocity_unit)
self.velocity_unit = self.quan(velocity_unit[0], velocity_unit[1])
@@ -238,10 +255,26 @@
mass_unit = (unit_base["UnitMass_in_g"], "g/h")
else:
# Sane default
- mass_unit = (1.0, "1e10*Msun/h")
+ mass_unit = (1e10, "Msun/h")
mass_unit = _fix_unit_ordering(mass_unit)
self.mass_unit = self.quan(mass_unit[0], mass_unit[1])
- self.time_unit = self.length_unit / self.velocity_unit
+ if self.cosmological_simulation:
+ # self.velocity_unit is the unit to rescale on-disk velocities, The
+ # actual internal velocity unit is really in comoving units
+ # since the time unit is derived from the internal velocity unit, we
+ # infer the internal velocity unit here and name it vel_unit
+ #
+ # see http://www.mpa-garching.mpg.de/gadget/gadget-list/0113.html
+ if 'velocity' in unit_base:
+ vel_unit = unit_base['velocity']
+ elif "UnitVelocity_in_cm_per_s" in unit_base:
+ vel_unit = (unit_base['UnitVelocity_in_cm_per_s'], 'cmcm/s')
+ else:
+ vel_unit = (1, 'kmcm/s')
+ vel_unit = self.quan(*vel_unit)
+ else:
+ vel_unit = self.velocity_unit
+ self.time_unit = self.length_unit / vel_unit
@staticmethod
def _validate_header(filename):
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