[yt-svn] commit/yt: 2 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Tue Nov 11 18:08:55 PST 2014
2 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/91b14343dfee/
Changeset: 91b14343dfee
Branch: yt
User: krumholz
Date: 2014-11-11 20:13:00+00:00
Summary: Added thermal energy, magnetic energy, kinetic energy, and temperature to ORION2 frontend.
Affected #: 2 files
diff -r feba284df7fea6ac46d0329b9ed2a0bfde6487a2 -r 91b14343dfeebdc3a19280e1af6e433a7091fca3 yt/frontends/chombo/data_structures.py
--- a/yt/frontends/chombo/data_structures.py
+++ b/yt/frontends/chombo/data_structures.py
@@ -630,12 +630,31 @@
# read the file line by line, storing important parameters
for lineI, line in enumerate(lines):
try:
- param, sep, vals = [v.rstrip() for v in line.partition(' ')]
- #param, sep, vals = map(rstrip,line.partition(' '))
+ param, sep, vals = line.partition('=')
+ if sep == '':
+ # No = sign present, so split by space instead
+ param, sep, vals = line.partition(' ')
+ for i, p in enumerate(param):
+ param = param.strip()
+ vals = vals.strip()
+ if len(param) == 0: # skip blank lines
+ continue
+ if param[0] == '#': # skip comment lines
+ continue
+ if param[0] == '[': # skip stanza headers
+ continue
+ vals = vals.partition("#")[0] # strip trailing comments
+ try:
+ self.parameters[param] = np.int64(vals)
+ except ValueError:
+ try:
+ self.parameters[param] = np.float64(vals)
+ except ValueError:
+ self.parameters[param] = vals
except ValueError:
mylog.error("ValueError: '%s'", line)
if param == "GAMMA":
- self.gamma = vals
+ self.gamma = np.float64(vals)
@classmethod
def _is_valid(self, *args, **kwargs):
diff -r feba284df7fea6ac46d0329b9ed2a0bfde6487a2 -r 91b14343dfeebdc3a19280e1af6e433a7091fca3 yt/frontends/chombo/fields.py
--- a/yt/frontends/chombo/fields.py
+++ b/yt/frontends/chombo/fields.py
@@ -24,10 +24,9 @@
from yt.frontends.boxlib.fields import \
rho_units, \
mom_units, \
- eden_units, \
- _thermal_energy_density, \
- _thermal_energy, \
- _temperature
+ eden_units
+
+from yt.utilities.exceptions import YTFieldNotFound
rho_units = "code_mass / code_length**3"
mom_units = "code_mass / (code_time * code_length**2)"
@@ -82,20 +81,70 @@
)
def setup_fluid_fields(self):
+ def _thermal_energy_density(field, data):
+ try:
+ return data['energy-density'] - data['kinetic_energy_density'] - \
+ data["magnetic_energy_density"]
+ except YTFieldNotFound:
+ return data['energy-density'] - data['kinetic_energy_density']
+
+ def _thermal_energy(field, data):
+ return data['thermal_energy_density']/data['density']
+
+ def _magnetic_energy_density(field, data):
+ ret = data["X-magnfield"]**2
+ if data.ds.dimensionality > 1:
+ ret = ret + data["Y-magnfield"]**2
+ if data.ds.dimensionality > 2:
+ ret = ret + data["Z-magnfield"]**2
+ return ret/2.0
+
+ def _magnetic_energy(field, data):
+ return data['magnetic_energy_density']/data['density']
+
+ def _kinetic_energy_density(field, data):
+ p2 = data['X-momentum']**2
+ if data.ds.dimensionality > 1:
+ p2 = p2 + data["Y-momentum"]**2
+ if data.ds.dimensionality > 2:
+ p2 = p2 + data["Z-momentum"]**2
+ return 0.5 * p2/data['density']
+
+ def _kinetic_energy(field, data):
+ return data['kinetic_energy_density']/data['density']
+
+ def _temperature(field, data):
+ c_v = data.ds.quan(data.ds.parameters['radiation.const_cv'],
+ 'erg/g/K')
+ return (data["thermal_energy"]/c_v)
+
def _get_vel(axis):
def velocity(field, data):
return data["momentum_%s" % ax]/data["density"]
return velocity
+
for ax in 'xyz':
- self.add_field("velocity_%s" % ax, function = _get_vel(ax),
+ self.add_field(("gas", "velocity_%s" % ax), function = _get_vel(ax),
units = "cm/s")
- self.add_field("thermal_energy",
+ self.add_field(("gas", "thermal_energy"),
function = _thermal_energy,
units = "erg/g")
- self.add_field("thermal_energy_density",
+ self.add_field(("gas", "thermal_energy_density"),
function = _thermal_energy_density,
units = "erg/cm**3")
- self.add_field("temperature", function=_temperature,
+ self.add_field(("gas", "kinetic_energy"),
+ function = _kinetic_energy,
+ units = "erg/g")
+ self.add_field(("gas", "kinetic_energy_density"),
+ function = _kinetic_energy_density,
+ units = "erg/cm**3")
+ self.add_field(("gas", "magnetic_energy"),
+ function = _magnetic_energy,
+ units = "erg/g")
+ self.add_field(("gas", "magnetic_energy_density"),
+ function = _magnetic_energy_density,
+ units = "erg/cm**3")
+ self.add_field(("gas", "temperature"), function=_temperature,
units="K")
https://bitbucket.org/yt_analysis/yt/commits/f7c75759e039/
Changeset: f7c75759e039
Branch: yt
User: krumholz
Date: 2014-11-12 00:17:05+00:00
Summary: Changed syntax of some checking for empty / zero-length lists, removed an unnecessary loop. Should have no effect on actual behavior, just makes the code cleaner.
Affected #: 1 file
diff -r 91b14343dfeebdc3a19280e1af6e433a7091fca3 -r f7c75759e0395861b52d16921d8ce3ad6e36f89f yt/frontends/chombo/data_structures.py
--- a/yt/frontends/chombo/data_structures.py
+++ b/yt/frontends/chombo/data_structures.py
@@ -631,13 +631,12 @@
for lineI, line in enumerate(lines):
try:
param, sep, vals = line.partition('=')
- if sep == '':
+ if not sep:
# No = sign present, so split by space instead
param, sep, vals = line.partition(' ')
- for i, p in enumerate(param):
- param = param.strip()
- vals = vals.strip()
- if len(param) == 0: # skip blank lines
+ param = param.strip()
+ vals = vals.strip()
+ if not param: # skip blank lines
continue
if param[0] == '#': # skip comment lines
continue
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