[yt-svn] commit/yt: chummels: Merged in RicardaBeckmann/yt (pull request #1694)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Aug 20 09:09:09 PDT 2015


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/e0b16d0403a7/
Changeset:   e0b16d0403a7
Branch:      yt
User:        chummels
Date:        2015-08-20 16:08:57+00:00
Summary:     Merged in RicardaBeckmann/yt (pull request #1694)

Fixing units for ramses when boxlen>1.
Affected #:  1 file

diff -r cfc98fddd9d791464330adf166d4229749dab22c -r e0b16d0403a7812a8a302f87327ab0fe5ff07728 yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -491,26 +491,18 @@
         """
         Generates the conversion to various physical _units based on the parameter file
         """
-        #Please note that for all units given in the info file, the boxlen
-        #still needs to be folded in, as shown below!
+        # loading the units from the info file
+        boxlen=self.parameters['boxlen']
+        length_unit = self.parameters['unit_l']
+        density_unit = self.parameters['unit_d']
+        time_unit = self.parameters['unit_t']
 
-        boxlen=self.parameters['boxlen']
-        length_unit = self.parameters['unit_l'] * boxlen
-        density_unit = self.parameters['unit_d']/ boxlen**3
-
-        # In the mass unit, the factors of boxlen cancel back out, so this 
-        #is equivalent to unit_d*unit_l**3
-
-        mass_unit = density_unit * length_unit**3
-
-        # Cosmological runs are done in lookback conformal time. 
-        # To convert to proper time, the time unit is calculated from 
-        # the expansion factor. This is not yet  done here!
-
-        time_unit = self.parameters['unit_t']
+        # calculating derived units (except velocity and temperature, done below)
+        mass_unit = density_unit * length_unit**3     
         magnetic_unit = np.sqrt(4*np.pi * mass_unit /
                                 (time_unit**2 * length_unit))
         pressure_unit = density_unit * (length_unit / time_unit)**2
+
         # TODO:
         # Generalize the temperature field to account for ionization
         # For now assume an atomic ideal gas with cosmic abundances (x_H = 0.76)
@@ -518,13 +510,15 @@
 
         self.density_unit = self.quan(density_unit, 'g/cm**3')
         self.magnetic_unit = self.quan(magnetic_unit, "gauss")
+        self.pressure_unit = self.quan(pressure_unit, 'dyne/cm**2')
+        self.time_unit = self.quan(time_unit, "s")
+        self.mass_unit = self.quan(mass_unit, "g")
+        self.velocity_unit = self.quan(length_unit, 'cm') / self.time_unit
+        self.temperature_unit = (self.velocity_unit**2*mp* 
+                                 mean_molecular_weight_factor/kb).in_units('K')
+
+        # Only the length unit get scales by a factor of boxlen
         self.length_unit = self.quan(length_unit * boxlen, "cm")
-        self.mass_unit = self.quan(mass_unit, "g")
-        self.time_unit = self.quan(time_unit, "s")
-        self.velocity_unit = self.quan(length_unit, 'cm') / self.time_unit
-        self.temperature_unit = (self.velocity_unit**2 * mp *
-                                 mean_molecular_weight_factor / kb)
-        self.pressure_unit = self.quan(pressure_unit, 'dyne/cm**2')
 
     def _parse_parameter_file(self):
         # hardcoded for now

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