[Yt-svn] yt: 2 new changesets

hg at spacepope.org hg at spacepope.org
Wed Nov 10 13:11:48 PST 2010


hg Repository: yt
details:   yt/rev/a855c1b74fff
changeset: 3522:a855c1b74fff
user:      Christopher Erick Moody <cemoody at ucsc.edu>
date:
Wed Nov 10 12:53:10 2010 -0800
description:
Made Sunrise exporter generic again (not just for ART.) Clarified & further cleaned up the ART fields, changed the current_time to code units so that pf.current_time*pf['years'] works

hg Repository: yt
details:   yt/rev/4f84accffde2
changeset: 3523:4f84accffde2
user:      Christopher Erick Moody <cemoody at ucsc.edu>
date:
Wed Nov 10 13:11:41 2010 -0800
description:
Sunrise exporter fixed for all codes, not just ART. ART fields cleaned. ART current time in code units such that pf.current_time*pf['years'] works

diffstat:

 yt/analysis_modules/sunrise_export/sunrise_exporter.py |  18 +++++++----
 yt/frontends/art/data_structures.py                    |  13 ++++---
 yt/frontends/art/fields.py                             |  28 +++++++++---------
 3 files changed, 32 insertions(+), 27 deletions(-)

diffs (159 lines):

diff -r a198f8022927 -r 4f84accffde2 yt/analysis_modules/sunrise_export/sunrise_exporter.py
--- a/yt/analysis_modules/sunrise_export/sunrise_exporter.py	Tue Nov 09 21:54:19 2010 -0800
+++ b/yt/analysis_modules/sunrise_export/sunrise_exporter.py	Wed Nov 10 13:11:41 2010 -0800
@@ -94,6 +94,7 @@
     col_list = []
     if subregion_bounds == None:    
         DLE, DRE = pf.domain_left_edge, pf.domain_right_edge
+        DX = pf.domain_dimensions
     else:
         DLE, DX = zip(*subregion_bounds)
         DLE, DX = na.array(DLE), na.array(DX)
@@ -122,9 +123,10 @@
         col_list.append(pyfits.Column("mass", format="D", array=current_mass, unit="Msun"))
         col_list.append(pyfits.Column("age_m", format="D", array=age))
         col_list.append(pyfits.Column("age_l", format="D", array=age))
+        #For particles, Sunrise takes 
+        #the dimensionless metallicity, not the mass of the metals
         col_list.append(pyfits.Column("metallicity", format="D",
-            array=0.02*current_mass*reg["metallicity_fraction"][pi],
-            unit="Msun")) # wrong?
+            array=reg["metallicity_fraction"][pi],unit="Msun")) # wrong?
         col_list.append(pyfits.Column("L_bol", format="D",
             array=na.zeros(particle_mass.size)))
 
@@ -137,9 +139,11 @@
         write_particles = True
 
     def _MetalMass(field, data):
-        return data["Metallicity"] * data["CellMassMsun"]
+        return data["Metal_Density"] * data["CellVolume"]
+        
     def _convMetalMass(data):
-        return 1.0
+        return 1.0/1.989e33
+        
     add_field("MetalMass", function=_MetalMass,
               convert_function=_convMetalMass)
 
@@ -172,8 +176,8 @@
 
     st_table.header.update("hierarch lengthunit", "kpc", comment="Length unit for grid")
     for i,a in enumerate('xyz'):
-        st_table.header.update("min%s" % a, DLE[i] * pf['kpc'])
-        st_table.header.update("max%s" % a, DRE[i] * pf['kpc'])
+        st_table.header.update("min%s" % a, DLE[i] * pf['kpc']/pf.domain_dimensions)
+        st_table.header.update("max%s" % a, DRE[i] * pf['kpc']/pf.domain_dimensions)
         st_table.header.update("n%s" % a, DX[i])
         st_table.header.update("subdiv%s" % a, 2)
     st_table.header.update("subdivtp", "UNIFORM", "Type of grid subdivision")
@@ -222,7 +226,7 @@
     col_list = [pyfits.Column("dummy", format="F", array=na.zeros(1, dtype='float32'))]
     cols = pyfits.ColDefs(col_list)
     md_table = pyfits.new_table(cols)
-    md_table.header.update("snaptime", pf.current_time*pf["years"])
+    md_table.header.update("snaptime", pf.current_time*pf['years'])
     md_table.name = "YT"
 
     hls = [pyfits.PrimaryHDU(), st_table, mg_table,md_table]
diff -r a198f8022927 -r 4f84accffde2 yt/frontends/art/data_structures.py
--- a/yt/frontends/art/data_structures.py	Tue Nov 09 21:54:19 2010 -0800
+++ b/yt/frontends/art/data_structures.py	Wed Nov 10 13:11:41 2010 -0800
@@ -438,10 +438,8 @@
             self.rho0*self.v0**2*(aexpn**-5.0)
         tr  = self.tr
         self.conversion_factors["Temperature"] = tr
-        self.conversion_factors["Metallicity"] = 1
-        self.conversion_factors["MetallicitySNII"] = 1
-        self.conversion_factors["MetallicitySNIa"] = 1
-                
+        self.conversion_factors["Metal_Density"] = 1
+        
         # Now our conversion factors
         for ax in 'xyz':
             # Add on the 1e5 to get to cm/s
@@ -450,6 +448,10 @@
         self.time_units['years'] = seconds / (365*3600*24.0)
         self.time_units['days']  = seconds / (3600*24.0)
 
+        #we were already in seconds, go back in to code units
+        self.current_time /= self.t0 
+        
+        
     def _parse_parameter_file(self):
         # We set our domain to run from 0 .. 1 since we are otherwise
         # unconstrained.
@@ -526,7 +528,6 @@
         self.max_level = header_vals['max_level']
         self.nhydro_vars = 10 #this gets updated later, but we'll default to this
         #nchem is nhydrovars-8, so we typically have 2 extra chem species 
-        
         self.hubble_time  = 1.0/(self.hubble_constant*100/3.08568025e19)
         #self.hubble_time /= 3.168876e7 #Gyr in s 
         def integrand(x,oml=self.omega_lambda,omb=self.omega_matter):
@@ -535,7 +536,7 @@
         integrand_arr = integrand(spacings)
         self.current_time = na.trapz(integrand_arr,dx=na.diff(spacings))
         self.current_time *= self.hubble_time
-        
+                
         for to_skip in ['tl','dtl','tlold','dtlold','iSO']:
             _skip_record(f)
 
diff -r a198f8022927 -r 4f84accffde2 yt/frontends/art/fields.py
--- a/yt/frontends/art/fields.py	Tue Nov 09 21:54:19 2010 -0800
+++ b/yt/frontends/art/fields.py	Wed Nov 10 13:11:41 2010 -0800
@@ -94,38 +94,38 @@
 ARTFieldInfo["Temperature"]._convert_function=_convertTemperature
 
 def _MetallicitySNII(field, data):
-    #get the dimensionaless mass fraction
+    #get the dimensionless mass fraction
     tr  = data["Metal_DensitySNII"] / data["Density"]
     tr *= data.pf.conversion_factors["Density"]    
     return tr
-def _convert_MetallicitySNII(data):
-    return data.convert("MetallicitySNII")
     
 add_field("MetallicitySNII", function=_MetallicitySNII, units = r"\mathrm{K}")
 ARTFieldInfo["MetallicitySNII"]._units = r"\mathrm{K}"
-ARTFieldInfo["MetallicitySNII"]._convert_function=_convert_MetallicitySNII
 
 def _MetallicitySNIa(field, data):
-    #get the dimensionaless mass fraction
+    #get the dimensionless mass fraction
     tr  = data["Metal_DensitySNIa"] / data["Density"]
     tr *= data.pf.conversion_factors["Density"]    
     return tr
-def _convert_MetallicitySNIa(data):
-    return data.convert("MetallicitySNIa")
     
 add_field("MetallicitySNIa", function=_MetallicitySNIa, units = r"\mathrm{K}")
 ARTFieldInfo["MetallicitySNIa"]._units = r"\mathrm{K}"
-ARTFieldInfo["MetallicitySNIa"]._convert_function=_convert_MetallicitySNIa
 
 def _Metallicity(field, data):
-    #get the dimensionaless mass fraction of the total metals
-    tr  = data["Metal_Density2"] / data["Density"]
-    tr += data["Metal_Density1"] / data["Density"]
+    #get the dimensionless mass fraction of the total metals
+    tr  = data["Metal_DensitySNIa"] / data["Density"]
+    tr += data["Metal_DensitySNII"] / data["Density"]
     tr *= data.pf.conversion_factors["Density"]    
     return tr
-def _convert_Metallicity(data):
-    return data.convert("Metallicity")
     
 add_field("Metallicity", function=_Metallicity, units = r"\mathrm{K}")
 ARTFieldInfo["Metallicity"]._units = r"\mathrm{K}"
-ARTFieldInfo["Metallicity"]._convert_function=_convert_Metallicity
\ No newline at end of file
+
+def _Metal_Density(field,data):
+    return data["Metal_DensitySNII"]+data["Metal_DensitySNIa"]
+def _convert_Metal_Density(data):
+    return data.convert("Metal_Density")
+
+add_field("Metal_Density", function=_Metal_Density, units = r"\mathrm{K}")
+ARTFieldInfo["Metal_Density"]._units = r"\mathrm{K}"
+ARTFieldInfo["Metal_Density"]._convert_function=_convert_Metal_Density



More information about the yt-svn mailing list