[Yt-svn] yt-commit r638 - branches/yt-generalization/yt/lagos

joishi at wrangler.dreamhost.com joishi at wrangler.dreamhost.com
Mon Jun 30 16:44:22 PDT 2008


Author: joishi
Date: Mon Jun 30 16:44:20 2008
New Revision: 638
URL: http://yt.spacepope.org/changeset/638

Log:
Lots of changes to ytOrion.

* changed hydro method to 'orion', and this makes pressure and gas energy
  calculations assume the TotalEnergy is an energy density instead of a
  specific energy a la Enzo.

* read in the fortran input file to get mu, the mean mass per particle (in
  m_H). this will eventually be used for Temperature calculation. it's
  currently set to be a parameter of the OrionStaticOutput, which isn't really
  the right place for it, but we can move it later. this makes it fairly
  visible.

* some code cleanup.


Modified:
   branches/yt-generalization/yt/lagos/DerivedFields.py
   branches/yt-generalization/yt/lagos/HierarchyType.py
   branches/yt-generalization/yt/lagos/OrionDefs.py
   branches/yt-generalization/yt/lagos/OutputTypes.py

Modified: branches/yt-generalization/yt/lagos/DerivedFields.py
==============================================================================
--- branches/yt-generalization/yt/lagos/DerivedFields.py	(original)
+++ branches/yt-generalization/yt/lagos/DerivedFields.py	Mon Jun 30 16:44:20 2008
@@ -440,13 +440,21 @@
 
 def _Pressure(field, data):
     """M{(Gamma-1.0)*rho*E}"""
-    return (data.pf["Gamma"] - 1.0) * \
-           data["Density"] * data["ThermalEnergy"]
+    if data.pf["HydroMethod"] == 'orion':
+        return (data.pf["Gamma"] - 1.0) * data["ThermalEnergy"]
+    else:
+        return (data.pf["Gamma"] - 1.0) * \
+               data["Density"] * data["ThermalEnergy"]
 add_field("Pressure", units=r"\rm{dyne}/\rm{cm}^{2}")
 
 def _ThermalEnergy(field, data):
     if data.pf["HydroMethod"] == 2:
         return data["Total_Energy"]
+    elif data.pf["HydroMethod"] == 'orion':
+        return data["Total_Energy"] - 0.5 * data["Density"] * (
+                   data["x-velocity"]**2.0
+                 + data["y-velocity"]**2.0
+                 + data["z-velocity"]**2.0 )
     else:
         if data.pf["DualEnergyFormalism"]:
             return data["Gas_Energy"]

Modified: branches/yt-generalization/yt/lagos/HierarchyType.py
==============================================================================
--- branches/yt-generalization/yt/lagos/HierarchyType.py	(original)
+++ branches/yt-generalization/yt/lagos/HierarchyType.py	Mon Jun 30 16:44:20 2008
@@ -805,6 +805,7 @@
         self.field_indexes = {}
         self.parameter_file = weakref.proxy(pf)
         header_filename = os.path.join(pf.fullplotdir,'Header')
+        self.directory = pf.fullpath
         self.data_style = data_style
         self._setup_classes()
         self.readGlobalHeader(header_filename)

Modified: branches/yt-generalization/yt/lagos/OrionDefs.py
==============================================================================
--- branches/yt-generalization/yt/lagos/OrionDefs.py	(original)
+++ branches/yt-generalization/yt/lagos/OrionDefs.py	Mon Jun 30 16:44:20 2008
@@ -31,6 +31,7 @@
 # converts the Orion inputs file name to the Enzo/yt name expected
 # throughout the code. key is Orion name, value is Enzo/yt equivalent
 orion2enzoDict = {"amr.n_cell": "TopGridRank",
+                  "materials.gamma": "Gamma"
                   }
 
 

Modified: branches/yt-generalization/yt/lagos/OutputTypes.py
==============================================================================
--- branches/yt-generalization/yt/lagos/OutputTypes.py	(original)
+++ branches/yt-generalization/yt/lagos/OutputTypes.py	Mon Jun 30 16:44:20 2008
@@ -286,10 +286,11 @@
     """
     _hierarchy_class = OrionHierarchy
 
-    def __init__(self, plotname, paramFilename='inputs',data_style=7):
+    def __init__(self, plotname, paramFilename='inputs',fparamFilename='probin',data_style=7):
         """need to override for Orion file structure.
 
         the paramfile is usually called "inputs"
+        and there may be a fortran inputs file usually called "probin"
         plotname here will be a directory name
         as per BoxLib, data_style will be one of
           Native
@@ -298,10 +299,14 @@
 
         """
         self.data_style = data_style
+        plotname = plotname.rstrip('/')
         self.basename = os.path.basename(plotname)
         # this will be the directory ENCLOSING the pltNNNN directory
         self.directory = os.path.dirname(plotname)
         self.parameter_filename = os.path.join(self.directory,paramFilename)
+        # fortran parameters
+        self.fparameters = {}
+        self.fparameter_filename = os.path.join(self.directory,fparamFilename)
         self.fullpath = os.path.abspath(self.directory)
         self.fullplotdir = os.path.abspath(plotname)
         if len(self.directory) == 0:
@@ -309,11 +314,16 @@
         self.conversion_factors = {}
         self.parameters = {}
         self._parse_parameter_file()
+        if os.path.isfile(self.fparameter_filename):
+            self._parse_fparameter_file()
         self._set_units()
         
         # These should maybe not be hardcoded?
-        self.parameters["HydroMethod"] = 0 # always PPM DE
+        self.parameters["HydroMethod"] = 'orion' # always PPM DE
         self.parameters["InitialTime"] = 0. # FIX ME!!!
+
+        if self.fparameters.has_key("mu"):
+            self.parameters["mu"] = self.fparameters["mu"]
         
     def _parse_parameter_file(self):
         """
@@ -344,25 +354,30 @@
                 if paramName.endswith("Units") and not paramName.startswith("Temperature"):
                     dataType = paramName[:-5]
                     self.conversion_factors[dataType] = self.parameters[paramName]
-            # elif param.startswith("#DataCGS"):
-#                 # Assume of the form: #DataCGSConversionFactor[7] = 2.38599e-26 g/cm^3
-#                 if lines[lineI-1].find("Label") >= 0:
-#                     kk = lineI-1
-#                 elif lines[lineI-2].find("Label") >= 0:
-#                     kk = lineI-2
-#                 dataType = lines[kk].split("=")[-1].rstrip().strip()
-#                 convFactor = float(line.split("=")[-1].split()[0])
-#                 self.conversion_factors[dataType] = convFactor
-#             elif param.startswith("#CGSConversionFactor"):
-#                 dataType = param[20:].rstrip()
-#                 convFactor = float(line.split("=")[-1])
-#                 self.conversion_factors[dataType] = convFactor
             elif param.startswith("geometry.prob_hi"):
                 self.parameters["DomainRightEdge"] = \
                     na.array([float(i) for i in vals.split()])
             elif param.startswith("geometry.prob_lo"):
                 self.parameters["DomainLeftEdge"] = \
                     na.array([float(i) for i in vals.split()])
+
+    def _parse_fparameter_file(self):
+        """
+        Parses the fortran parameter file for Orion. Most of this will
+        be useless, but this is where it keeps mu = mass per
+        particle/m_hydrogen.
+        """
+        lines = open(self.fparameter_filename).readlines()
+        for line in lines:
+            if line.count("=") == 1:
+                param, vals = map(strip,map(rstrip,line.split("=")))
+                t = map(float,[a.replace('D','e').replace('d','e') for a in vals.split()]) # all are floating point.
+                
+                if len(t) == 1:
+                    self.fparameters[param] = t[0]
+                else:
+                    self.fparameters[param] = t
+                
                 
     def _set_units(self):
         """



More information about the yt-svn mailing list