[Yt-svn] yt-commit r770 - in branches/yt-generalization/yt: . lagos
joishi at wrangler.dreamhost.com
joishi at wrangler.dreamhost.com
Thu Sep 11 07:45:35 PDT 2008
Author: joishi
Date: Thu Sep 11 07:45:34 2008
New Revision: 770
URL: http://yt.spacepope.org/changeset/770
Log:
many improvements to generalization
* BaseDataTypes -- fixed a few left_edge = 0
* cleaned up Orion stuff from Universal & Enzo fields
* added a whole lot of Orion fields, mostly related to thermodynamics
* minor fixes to fparameter parsing in OutputTypes
* added OrionStaticOutput to the imports list in mods.py
Modified:
branches/yt-generalization/yt/lagos/BaseDataTypes.py
branches/yt-generalization/yt/lagos/EnzoFields.py
branches/yt-generalization/yt/lagos/HierarchyType.py
branches/yt-generalization/yt/lagos/OrionFields.py
branches/yt-generalization/yt/lagos/OutputTypes.py
branches/yt-generalization/yt/lagos/UniversalFields.py
branches/yt-generalization/yt/mods.py
Modified: branches/yt-generalization/yt/lagos/BaseDataTypes.py
==============================================================================
--- branches/yt-generalization/yt/lagos/BaseDataTypes.py (original)
+++ branches/yt-generalization/yt/lagos/BaseDataTypes.py Thu Sep 11 07:45:34 2008
@@ -1567,16 +1567,22 @@
#raise ValueError
kwargs['num_ghost_zones'] = 0
AMRCoveringGrid.__init__(self, *args, **kwargs)
- if na.any(self.left_edge == 0):
+ if na.any(self.left_edge == self.pf["DomainLeftEdge"]):
self.left_edge += self.dx
self.ActiveDimensions -= 1
- if na.any(self.right_edge == 0):
+ if na.any(self.right_edge == self.pf["DomainRightEdge"]):
self.right_edge -= self.dx
self.ActiveDimensions -= 1
def _get_list_of_grids(self):
- grids, ind = self.pf.hierarchy.get_box_grids(self.left_edge-self.dx,
- self.right_edge+self.dx)
+ if na.any(self.left_edge - self.dx < self.pf["DomainLeftEdge"]) or \
+ na.any(self.right_edge + self.dx > self.pf["DomainRightEdge"]):
+ grids,ind = self.pf.hierarchy.get_periodic_box_grids(
+ self.left_edge - self.dx, self.right_edge + self.dx)
+ ind = slice(None)
+ else:
+ grids,ind = self.pf.hierarchy.get_box_grids(
+ self.left_edge - self.dx, self.right_edge + self.dx)
level_ind = na.where(self.pf.hierarchy.gridLevels.ravel()[ind] <= self.level)
sort_ind = na.argsort(self.pf.h.gridLevels.ravel()[ind][level_ind])
self._grids = self.pf.hierarchy.grids[ind][level_ind][(sort_ind,)]
Modified: branches/yt-generalization/yt/lagos/EnzoFields.py
==============================================================================
--- branches/yt-generalization/yt/lagos/EnzoFields.py (original)
+++ branches/yt-generalization/yt/lagos/EnzoFields.py Thu Sep 11 07:45:34 2008
@@ -49,11 +49,6 @@
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 Thu Sep 11 07:45:34 2008
@@ -867,8 +867,6 @@
def readGlobalHeader(self,filename,paranoid_read):
"""
read the global header file for an Orion plotfile output.
-
-
"""
counter = 0
header_file = open(filename,'r')
Modified: branches/yt-generalization/yt/lagos/OrionFields.py
==============================================================================
--- branches/yt-generalization/yt/lagos/OrionFields.py (original)
+++ branches/yt-generalization/yt/lagos/OrionFields.py Thu Sep 11 07:45:34 2008
@@ -1,3 +1,27 @@
+"""
+Orion-specific fields
+
+Author: J. S. Oishi <jsoishi at gmail.com>
+Affiliation: UC Berkeley
+Homepage: http://yt.enzotools.org/
+License:
+ Copyright (C) 2008 J. S. Oishi, Matthew Turk. All Rights Reserved.
+
+ This file is part of yt.
+
+ yt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
from UniversalFields import *
@@ -8,11 +32,15 @@
validators = [ValidateDataField("density")],
units=r"\rm{g}/\rm{cm}^3")
+add_field("eden", function=lambda a,b: None, take_log=True,
+ validators = [ValidateDataField("eden")],
+ units=r"\rm{erg}/\rm{cm}^3")
+
translation_dict = {"x-velocity": "xvel",
"y-velocity": "yvel",
"z-velocity": "zvel",
"Density": "density",
- "Gas_Energy": "eden",
+ "Total_Energy": "eden",
"Temperature": "temperature",
"x-momentum": "xmom",
"y-momentum": "ymom",
@@ -28,3 +56,56 @@
validators = [ValidateDataField(v)])
#print "Setting up translator from %s to %s" % (v, f)
_generate_translation(v, f)
+
+def _xVelocity(field, data):
+ """generate x-velocity from x-momentum and density
+
+ """
+ return data["xmom"]/data["density"]
+add_field("x-velocity",function=_xVelocity, take_log=False,
+ units=r'\rm{cm}/\rm{s}')
+
+def _yVelocity(field,data):
+ """generate y-velocity from y-momentum and density
+
+ """
+ #try:
+ # return data["xvel"]
+ #except KeyError:
+ return data["ymom"]/data["density"]
+add_field("y-velocity",function=_yVelocity, take_log=False,
+ units=r'\rm{cm}/\rm{s}')
+
+def _zVelocity(field,data):
+ """generate z-velocity from z-momentum and density
+
+ """
+ return data["zmom"]/data["density"]
+add_field("z-velocity",function=_zVelocity, take_log=False,
+ units=r'\rm{cm}/\rm{s}')
+
+def _ThermalEnergy(field, data):
+ """generate thermal (gas energy). Dual Energy Formalism was
+ implemented by Stella, but this isn't how it's called, so I'll
+ leave that commented out for now.
+ """
+ #if data.pf["DualEnergyFormalism"]:
+ # return data["Gas_Energy"]
+ #else:
+ return data["Total_Energy"] - 0.5 * data["density"] * (
+ data["x-velocity"]**2.0
+ + data["y-velocity"]**2.0
+ + data["z-velocity"]**2.0 )
+add_field("ThermalEnergy", function=_ThermalEnergy,
+ units=r"\rm{ergs}/\rm{cm^3}")
+
+def _Pressure(field,data):
+ """M{(Gamma-1.0)*e, where e is thermal energy density
+ NB: this will need to be modified for radiation
+ """
+ return (data.pf["Gamma"] - 1.0)*data["ThermalEnergy"]
+add_field("Pressure", function=_Pressure, units=r"\rm{dyne}/\rm{cm}^{2}")
+
+def _Temperature(field,data):
+ return (data.pf["Gamma"]-1.0)*data.pf["mu"]*mh*data["ThermalEnergy"]/(kboltz*data["Density"])
+add_field("Temperature",function=_Temperature,units=r"\rm{Kelvin}",take_log=False)
Modified: branches/yt-generalization/yt/lagos/OutputTypes.py
==============================================================================
--- branches/yt-generalization/yt/lagos/OutputTypes.py (original)
+++ branches/yt-generalization/yt/lagos/OutputTypes.py Thu Sep 11 07:45:34 2008
@@ -1,20 +1,13 @@
"""
-Generalized Enzo output objects, both static and time-series.
+AMR output objects, both static and time-series.
Presumably at some point EnzoRun will be absorbed into here.
-<<<<<<< .working
+
Author: Matthew Turk <matthewturk at gmail.com>
Affiliation: KIPAC/SLAC/Stanford
Homepage: http://yt.enzotools.org/
License:
Copyright (C) 2007-2008 Matthew Turk, J. S. Oishi. All Rights Reserved.
-=======
-Author: Matthew Turk <matthewturk at gmail.com>
-Affiliation: KIPAC/SLAC/Stanford
-Homepage: http://yt.enzotools.org/
-License:
- Copyright (C) 2007-2008 Matthew Turk. All Rights Reserved.
->>>>>>> .merge-right.r687
This file is part of yt.
@@ -382,8 +375,10 @@
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 vals.count("'") == 0:
+ t = map(float,[a.replace('D','e').replace('d','e') for a in vals.split()]) # all are floating point.
+ else:
+ t = vals.split()
if len(t) == 1:
self.fparameters[param] = t[0]
else:
Modified: branches/yt-generalization/yt/lagos/UniversalFields.py
==============================================================================
--- branches/yt-generalization/yt/lagos/UniversalFields.py (original)
+++ branches/yt-generalization/yt/lagos/UniversalFields.py Thu Sep 11 07:45:34 2008
@@ -225,14 +225,9 @@
def _Pressure(field, data):
"""M{(Gamma-1.0)*rho*E}"""
- if data.pf["HydroMethod"] == 'orion':
- return (data.pf["Gamma"] - 1.0) * data["ThermalEnergy"]
- else:
- return (data.pf["Gamma"] - 1.0) * \
- data["Density"] * data["ThermalEnergy"]
+ return (data.pf["Gamma"] - 1.0) * \
+ data["Density"] * data["ThermalEnergy"]
add_field("Pressure", function=_Pressure, units=r"\rm{dyne}/\rm{cm}^{2}")
-# for Orion, units are different...how to do this?
-# add_field("ThermalEnergy", units=r"\rm{ergs}/\rm{g}")
def _Entropy(field, data):
return data["Density"]**(-2./3.) * \
Modified: branches/yt-generalization/yt/mods.py
==============================================================================
--- branches/yt-generalization/yt/mods.py (original)
+++ branches/yt-generalization/yt/mods.py Thu Sep 11 07:45:34 2008
@@ -32,7 +32,7 @@
import numpy as na
import sys
-from yt.lagos import EnzoStaticOutput, \
+from yt.lagos import EnzoStaticOutput, OrionStaticOutput, \
BinnedProfile1D, BinnedProfile2D, BinnedProfile3D, \
add_field, Clump, write_clump_hierarchy, find_clumps, \
write_clumps
More information about the yt-svn
mailing list