[yt-svn] commit/yt: 4 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Tue Apr 4 14:49:16 PDT 2017
4 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/8eeb58e29b49/
Changeset: 8eeb58e29b49
Branch: yt
User: polaris42
Date: 2017-04-03 21:26:59+00:00
Summary: Added functionality for dynamical dark energy for Gadget simulations. Uses Linder 2002 parameterization of w(z).
Affected #: 7 files
diff -r 1088ca4ac8d84017d1809a6f114c852297286350 -r 8eeb58e29b4933c312827bbf6d15dcf7cbecf1f1 doc/source/reference/api/api.rst
--- a/doc/source/reference/api/api.rst
+++ b/doc/source/reference/api/api.rst
@@ -874,6 +874,7 @@
~yt.utilities.cosmology.Cosmology.expansion_factor
~yt.utilities.cosmology.Cosmology.z_from_t
~yt.utilities.cosmology.Cosmology.t_from_z
+ ~yt.utilities.cosmology.Cosmology.get_dark_factor
Testing Infrastructure
----------------------
diff -r 1088ca4ac8d84017d1809a6f114c852297286350 -r 8eeb58e29b4933c312827bbf6d15dcf7cbecf1f1 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -262,7 +262,8 @@
return obj
def __init__(self, filename, dataset_type=None, file_style=None,
- units_override=None, unit_system="cgs"):
+ units_override=None, unit_system="cgs", use_dark_factor = False,
+ w_0 = None, w_a = None):
"""
Base class for generating new output types. Principally consists of
a *filename* and a *dataset_type* which will be passed on to children.
@@ -294,6 +295,11 @@
if len(self.directory) == 0:
self.directory = "."
+ # Dynamical Dark Energy parameters
+ self.use_dark_factor = use_dark_factor
+ self.w_0 = w_0
+ self.w_a = w_a
+
# to get the timing right, do this before the heavy lifting
self._instantiated = time.time()
@@ -966,7 +972,9 @@
self.cosmology = \
Cosmology(hubble_constant=self.hubble_constant,
omega_matter=self.omega_matter,
- omega_lambda=self.omega_lambda)
+ omega_lambda=self.omega_lambda, \
+ use_dark_factor = self.use_dark_factor,
+ w_0 = self.w_0, w_a = self.w_a)
self.critical_density = \
self.cosmology.critical_density(self.current_redshift)
self.scale_factor = 1.0 / (1.0 + self.current_redshift)
@@ -1443,9 +1451,11 @@
def __init__(self, filename, dataset_type=None, file_style=None,
units_override=None, unit_system="cgs",
- n_ref=64, over_refine_factor=1):
+ n_ref=64, over_refine_factor=1, use_dark_factor = False,
+ w_0 = None, w_a = None):
self.n_ref = n_ref
self.over_refine_factor = over_refine_factor
super(ParticleDataset, self).__init__(
filename, dataset_type=dataset_type, file_style=file_style,
- units_override=units_override, unit_system=unit_system)
+ units_override=units_override, unit_system=unit_system,
+ use_dark_factor = use_dark_factor, w_0 = w_0, w_a = w_a)
diff -r 1088ca4ac8d84017d1809a6f114c852297286350 -r 8eeb58e29b4933c312827bbf6d15dcf7cbecf1f1 yt/frontends/gadget/data_structures.py
--- a/yt/frontends/gadget/data_structures.py
+++ b/yt/frontends/gadget/data_structures.py
@@ -96,7 +96,10 @@
field_spec = "default",
ptype_spec = "default",
units_override=None,
- unit_system="cgs"):
+ unit_system="cgs",
+ use_dark_factor = False,
+ w_0 = None,
+ w_a = None):
if self._instantiated: return
self._header_spec = self._setup_binary_spec(
header_spec, gadget_header_specs)
@@ -125,7 +128,8 @@
super(GadgetDataset, self).__init__(
filename, dataset_type=dataset_type, unit_system=unit_system,
n_ref=n_ref, over_refine_factor=over_refine_factor,
- kernel_name=kernel_name)
+ kernel_name=kernel_name, use_dark_factor = use_dark_factor,
+ w_0 = w_0, w_a = w_a)
if self.cosmological_simulation:
self.time_unit.convert_to_units('s/h')
self.length_unit.convert_to_units('kpccm/h')
diff -r 1088ca4ac8d84017d1809a6f114c852297286350 -r 8eeb58e29b4933c312827bbf6d15dcf7cbecf1f1 yt/frontends/gadget/definitions.py
--- a/yt/frontends/gadget/definitions.py
+++ b/yt/frontends/gadget/definitions.py
@@ -83,6 +83,14 @@
("NStarsSpawned", ("Gas", "Stars")),
("StellarAge", "Stars")
),
+ nd_dm = ( "Coordinates",
+ "Velocities",
+ "ParticleIDs",
+ "Mass",
+ ("Temperature", "Halo"),
+ ("Density", "Halo"),
+ ("SmoothingLength", "Halo"),
+ ),
)
gadget_hdf5_ptypes = (
diff -r 1088ca4ac8d84017d1809a6f114c852297286350 -r 8eeb58e29b4933c312827bbf6d15dcf7cbecf1f1 yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -25,7 +25,8 @@
def __init__(self, filename, dataset_type=None, file_style=None,
units_override=None, unit_system="cgs",
n_ref=64, over_refine_factor=1,
- kernel_name=None):
+ kernel_name=None, use_dark_factor = False, w_0 = None,
+ w_a = None):
if kernel_name is None:
self.kernel_name = self.default_kernel_name
else:
@@ -33,7 +34,8 @@
super(SPHDataset, self).__init__(
filename, dataset_type=dataset_type, file_style=file_style,
units_override=units_override, unit_system=unit_system,
- n_ref=n_ref, over_refine_factor=over_refine_factor)
+ n_ref=n_ref, over_refine_factor=over_refine_factor,
+ use_dark_factor = use_dark_factor, w_0 = w_0, w_a = w_a)
def add_smoothed_particle_field(self, smooth_field,
method="volume_weighted", nneighbors=64,
diff -r 1088ca4ac8d84017d1809a6f114c852297286350 -r 8eeb58e29b4933c312827bbf6d15dcf7cbecf1f1 yt/utilities/cosmology.py
--- a/yt/utilities/cosmology.py
+++ b/yt/utilities/cosmology.py
@@ -58,6 +58,18 @@
unit_system : :class:`yt.units.unit_systems.UnitSystem`, optional
The units system to use when making calculations. If not specified,
cgs units are assumed.
+ use_dark_factor: Bool, optional
+ The flag to either use the cosmological constant (False, default)
+ or to use the parameterization of w(a) as given in Linder 2002. This,
+ along with w_0 and w_a, only matters in the function expansion_factor.
+ Right now, this is only implemented for Gadget.
+ w_0 : float, optional
+ The Linder 2002 parameterization of w(a) is: w(a) = w_0 + w_a(1 - a).
+ w_0 is w(a = 1). Only matters if use_dark_factor = True. Default is None.
+ Cosmological constant case corresponds to w_0 = -1.
+ w_a : float, optional
+ See w_0. w_a is the derivative of w(a) evaluated at a = 1. Cosmological
+ constant case corresponds to w_a = 0. Default is None.
Examples
--------
@@ -72,7 +84,10 @@
omega_lambda = 0.73,
omega_curvature = 0.0,
unit_registry = None,
- unit_system = "cgs"):
+ unit_system = "cgs",
+ use_dark_factor = False,
+ w_0 = None,
+ w_a = None):
self.omega_matter = float(omega_matter)
self.omega_lambda = float(omega_lambda)
self.omega_curvature = float(omega_curvature)
@@ -87,6 +102,21 @@
self.unit_registry = unit_registry
self.hubble_constant = self.quan(hubble_constant, "100*km/s/Mpc")
self.unit_system = unit_system
+
+ # For non-standard dark energy. If false, use default cosmological constant
+ # This only affects the expansion_factor function.
+ self.use_dark_factor = use_dark_factor
+ self.dark_factor = 1.0
+ self.w_0 = w_0
+ self.w_a = w_a
+
+ # Do a quick error check on the dark energy parameters. If use_dark_factor
+ # is set to true, we have to make sure that w_0 and w_a are set, as well.
+ # That is, w_0 and w_a must not be None.
+ if self.use_dark_factor != False:
+ if (self.w_0 == None) or (self.w_a == None):
+ mylog.error("Dynamical dark energy turned on but w_0 and/or w_a is not set!")
+ raise YTDynamicalDarkEnergyError(self.use_dark_factor, self.w_0, self.w_a)
def hubble_distance(self):
r"""
@@ -382,9 +412,18 @@
cosmological distances.
"""
+
+ # Use non-standard dark energy
+ if self.use_dark_factor:
+ self.dark_factor = self.get_dark_factor(z)
+
+ # Use default cosmological constant
+ else:
+ self.dark_factor = 1.0
+
return np.sqrt(self.omega_matter * ((1 + z)**3.0) +
self.omega_curvature * ((1 + z)**2.0) +
- self.omega_lambda)
+ (self.omega_lambda * self.dark_factor))
def inverse_expansion_factor(self, z):
return 1 / self.expansion_factor(z)
@@ -548,6 +587,32 @@
return my_time.in_base(self.unit_system)
+ def get_dark_factor(self, z):
+ """
+ This function computes the additional term that enters the expansion factor
+ when using non-standard dark energy. See Dolag et al 2004 eq. 7 for ref (but
+ note that there's a typo in his eq. There should be no negative sign).
+
+ At the moment, this only works using the parameterization given in Linder 2002
+ eq. 7: w(a) = w0 + wa(1 - a) = w0 + wa * z / (1+z). This gives rise to an analytic
+ expression. It is also only functional for Gadget simulations, at the moment.
+
+ Parameters
+ ----------
+ z: Redshift in question
+ w0: The value of w(z = 0). This is a class member.
+ wa: The value of dw/dz |_z = 0. This is a class member.
+ """
+
+ # Get value of scale factor a corresponding to redshift z
+ scale_factor = 1.0 / (1.0 + z)
+
+ # Evaluate exponential using Linder02 parameterization
+ dark_factor = np.power(scale_factor, -3.0 * (1.0 + self.w_0 + self.w_a)) * \
+ np.exp(-3.0 * self.w_a * (1.0 - scale_factor))
+
+ return dark_factor
+
_arr = None
@property
def arr(self):
diff -r 1088ca4ac8d84017d1809a6f114c852297286350 -r 8eeb58e29b4933c312827bbf6d15dcf7cbecf1f1 yt/utilities/exceptions.py
--- a/yt/utilities/exceptions.py
+++ b/yt/utilities/exceptions.py
@@ -649,3 +649,13 @@
def __str__(self):
return "Boolean data objects must share a common dataset object."
+
+class YTDynamicalDarkEnergyError(YTException):
+ def __init__(self, use_dark_factor, w_0, w_a):
+ self.use_dark_factor = use_dark_factor
+ self.w_0 = w_0
+ self.w_a = w_a
+
+ def __str__(self):
+ return "Dark factor on: %s, but w_0 = %s and w_a = %s are not set." % \
+ (self.use_dark_factor, self.w_0, self.w_a)
https://bitbucket.org/yt_analysis/yt/commits/9621f4ffbc32/
Changeset: 9621f4ffbc32
Branch: yt
User: Jared
Date: 2017-04-04 15:14:01+00:00
Summary: Addressed the comments in the pull request. Removed my default gadget field_spec, made w_0, w_a, and use_dark_factor only parameters of the gadget subclass.
Affected #: 6 files
diff -r 8eeb58e29b4933c312827bbf6d15dcf7cbecf1f1 -r 9621f4ffbc329a458511ef1074233381e147d6d8 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -262,8 +262,7 @@
return obj
def __init__(self, filename, dataset_type=None, file_style=None,
- units_override=None, unit_system="cgs", use_dark_factor = False,
- w_0 = None, w_a = None):
+ units_override=None, unit_system="cgs"):
"""
Base class for generating new output types. Principally consists of
a *filename* and a *dataset_type* which will be passed on to children.
@@ -295,11 +294,6 @@
if len(self.directory) == 0:
self.directory = "."
- # Dynamical Dark Energy parameters
- self.use_dark_factor = use_dark_factor
- self.w_0 = w_0
- self.w_a = w_a
-
# to get the timing right, do this before the heavy lifting
self._instantiated = time.time()
@@ -1451,11 +1445,9 @@
def __init__(self, filename, dataset_type=None, file_style=None,
units_override=None, unit_system="cgs",
- n_ref=64, over_refine_factor=1, use_dark_factor = False,
- w_0 = None, w_a = None):
+ n_ref=64, over_refine_factor=1):
self.n_ref = n_ref
self.over_refine_factor = over_refine_factor
super(ParticleDataset, self).__init__(
filename, dataset_type=dataset_type, file_style=file_style,
- units_override=units_override, unit_system=unit_system,
- use_dark_factor = use_dark_factor, w_0 = w_0, w_a = w_a)
+ units_override=units_override, unit_system=unit_system)
diff -r 8eeb58e29b4933c312827bbf6d15dcf7cbecf1f1 -r 9621f4ffbc329a458511ef1074233381e147d6d8 yt/frontends/gadget/data_structures.py
--- a/yt/frontends/gadget/data_structures.py
+++ b/yt/frontends/gadget/data_structures.py
@@ -98,8 +98,8 @@
units_override=None,
unit_system="cgs",
use_dark_factor = False,
- w_0 = None,
- w_a = None):
+ w_0 = -1.0,
+ w_a = 0.0):
if self._instantiated: return
self._header_spec = self._setup_binary_spec(
header_spec, gadget_header_specs)
@@ -128,8 +128,7 @@
super(GadgetDataset, self).__init__(
filename, dataset_type=dataset_type, unit_system=unit_system,
n_ref=n_ref, over_refine_factor=over_refine_factor,
- kernel_name=kernel_name, use_dark_factor = use_dark_factor,
- w_0 = w_0, w_a = w_a)
+ kernel_name=kernel_name)
if self.cosmological_simulation:
self.time_unit.convert_to_units('s/h')
self.length_unit.convert_to_units('kpccm/h')
diff -r 8eeb58e29b4933c312827bbf6d15dcf7cbecf1f1 -r 9621f4ffbc329a458511ef1074233381e147d6d8 yt/frontends/gadget/definitions.py
--- a/yt/frontends/gadget/definitions.py
+++ b/yt/frontends/gadget/definitions.py
@@ -83,14 +83,6 @@
("NStarsSpawned", ("Gas", "Stars")),
("StellarAge", "Stars")
),
- nd_dm = ( "Coordinates",
- "Velocities",
- "ParticleIDs",
- "Mass",
- ("Temperature", "Halo"),
- ("Density", "Halo"),
- ("SmoothingLength", "Halo"),
- ),
)
gadget_hdf5_ptypes = (
diff -r 8eeb58e29b4933c312827bbf6d15dcf7cbecf1f1 -r 9621f4ffbc329a458511ef1074233381e147d6d8 yt/frontends/sph/data_structures.py
--- a/yt/frontends/sph/data_structures.py
+++ b/yt/frontends/sph/data_structures.py
@@ -25,8 +25,7 @@
def __init__(self, filename, dataset_type=None, file_style=None,
units_override=None, unit_system="cgs",
n_ref=64, over_refine_factor=1,
- kernel_name=None, use_dark_factor = False, w_0 = None,
- w_a = None):
+ kernel_name=None):
if kernel_name is None:
self.kernel_name = self.default_kernel_name
else:
@@ -34,8 +33,7 @@
super(SPHDataset, self).__init__(
filename, dataset_type=dataset_type, file_style=file_style,
units_override=units_override, unit_system=unit_system,
- n_ref=n_ref, over_refine_factor=over_refine_factor,
- use_dark_factor = use_dark_factor, w_0 = w_0, w_a = w_a)
+ n_ref=n_ref, over_refine_factor=over_refine_factor)
def add_smoothed_particle_field(self, smooth_field,
method="volume_weighted", nneighbors=64,
diff -r 8eeb58e29b4933c312827bbf6d15dcf7cbecf1f1 -r 9621f4ffbc329a458511ef1074233381e147d6d8 yt/utilities/cosmology.py
--- a/yt/utilities/cosmology.py
+++ b/yt/utilities/cosmology.py
@@ -62,7 +62,6 @@
The flag to either use the cosmological constant (False, default)
or to use the parameterization of w(a) as given in Linder 2002. This,
along with w_0 and w_a, only matters in the function expansion_factor.
- Right now, this is only implemented for Gadget.
w_0 : float, optional
The Linder 2002 parameterization of w(a) is: w(a) = w_0 + w_a(1 - a).
w_0 is w(a = 1). Only matters if use_dark_factor = True. Default is None.
@@ -86,8 +85,8 @@
unit_registry = None,
unit_system = "cgs",
use_dark_factor = False,
- w_0 = None,
- w_a = None):
+ w_0 = -1.0,
+ w_a = 0.0):
self.omega_matter = float(omega_matter)
self.omega_lambda = float(omega_lambda)
self.omega_curvature = float(omega_curvature)
@@ -106,18 +105,9 @@
# For non-standard dark energy. If false, use default cosmological constant
# This only affects the expansion_factor function.
self.use_dark_factor = use_dark_factor
- self.dark_factor = 1.0
self.w_0 = w_0
self.w_a = w_a
- # Do a quick error check on the dark energy parameters. If use_dark_factor
- # is set to true, we have to make sure that w_0 and w_a are set, as well.
- # That is, w_0 and w_a must not be None.
- if self.use_dark_factor != False:
- if (self.w_0 == None) or (self.w_a == None):
- mylog.error("Dynamical dark energy turned on but w_0 and/or w_a is not set!")
- raise YTDynamicalDarkEnergyError(self.use_dark_factor, self.w_0, self.w_a)
-
def hubble_distance(self):
r"""
The distance corresponding to c / h, where c is the speed of light
@@ -415,15 +405,15 @@
# Use non-standard dark energy
if self.use_dark_factor:
- self.dark_factor = self.get_dark_factor(z)
+ dark_factor = self.get_dark_factor(z)
# Use default cosmological constant
else:
- self.dark_factor = 1.0
+ dark_factor = 1.0
return np.sqrt(self.omega_matter * ((1 + z)**3.0) +
self.omega_curvature * ((1 + z)**2.0) +
- (self.omega_lambda * self.dark_factor))
+ (self.omega_lambda * dark_factor))
def inverse_expansion_factor(self, z):
return 1 / self.expansion_factor(z)
@@ -599,9 +589,8 @@
Parameters
----------
- z: Redshift in question
- w0: The value of w(z = 0). This is a class member.
- wa: The value of dw/dz |_z = 0. This is a class member.
+ z: float
+ Redshift
"""
# Get value of scale factor a corresponding to redshift z
diff -r 8eeb58e29b4933c312827bbf6d15dcf7cbecf1f1 -r 9621f4ffbc329a458511ef1074233381e147d6d8 yt/utilities/exceptions.py
--- a/yt/utilities/exceptions.py
+++ b/yt/utilities/exceptions.py
@@ -649,13 +649,3 @@
def __str__(self):
return "Boolean data objects must share a common dataset object."
-
-class YTDynamicalDarkEnergyError(YTException):
- def __init__(self, use_dark_factor, w_0, w_a):
- self.use_dark_factor = use_dark_factor
- self.w_0 = w_0
- self.w_a = w_a
-
- def __str__(self):
- return "Dark factor on: %s, but w_0 = %s and w_a = %s are not set." % \
- (self.use_dark_factor, self.w_0, self.w_a)
https://bitbucket.org/yt_analysis/yt/commits/6261622d0d72/
Changeset: 6261622d0d72
Branch: yt
User: Jared
Date: 2017-04-04 20:55:09+00:00
Summary: Updated static_output.py so that use_dark_factor, w_0, and w_a are set based on the attributes of the frontend being used. If the frontend does not support these attributes then the default values corresponding to a cosmological constant are set.
Affected #: 1 file
diff -r 9621f4ffbc329a458511ef1074233381e147d6d8 -r 6261622d0d72a3f7211d185cc8593a2fd05470ef yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -963,12 +963,18 @@
if getattr(self, "cosmological_simulation", False):
# this dataset is cosmological, add a cosmology object
+
+ # Set dynamical dark energy parameters
+ use_dark_factor = getattr(self, 'use_dark_factor', False)
+ w_0 = getattr(self, 'w_0', -1.0)
+ w_a = getattr(self, 'w_a', 0.0)
+
self.cosmology = \
Cosmology(hubble_constant=self.hubble_constant,
omega_matter=self.omega_matter,
- omega_lambda=self.omega_lambda, \
- use_dark_factor = self.use_dark_factor,
- w_0 = self.w_0, w_a = self.w_a)
+ omega_lambda=self.omega_lambda,
+ use_dark_factor = use_dark_factor,
+ w_0 = w_0, w_a = w_a)
self.critical_density = \
self.cosmology.critical_density(self.current_redshift)
self.scale_factor = 1.0 / (1.0 + self.current_redshift)
https://bitbucket.org/yt_analysis/yt/commits/11a616b013dd/
Changeset: 11a616b013dd
Branch: yt
User: ngoldbaum
Date: 2017-04-04 21:49:12+00:00
Summary: Merged in polaris42/yt (pull request #2572)
Dynamical Dark Energy for Gadget
Approved-by: Britton Smith <brittonsmith at gmail.com>
Approved-by: Nathan Goldbaum <ngoldbau at illinois.edu>
Affected #: 7 files
diff -r 51ca56bb7126b9be23edd0fe6f2bf281be7ee2d3 -r 11a616b013dda6081d04e4ccd2ad8c71b31fe8dc doc/source/reference/api/api.rst
--- a/doc/source/reference/api/api.rst
+++ b/doc/source/reference/api/api.rst
@@ -874,6 +874,7 @@
~yt.utilities.cosmology.Cosmology.expansion_factor
~yt.utilities.cosmology.Cosmology.z_from_t
~yt.utilities.cosmology.Cosmology.t_from_z
+ ~yt.utilities.cosmology.Cosmology.get_dark_factor
Testing Infrastructure
----------------------
diff -r 51ca56bb7126b9be23edd0fe6f2bf281be7ee2d3 -r 11a616b013dda6081d04e4ccd2ad8c71b31fe8dc yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -964,10 +964,18 @@
if getattr(self, "cosmological_simulation", False):
# this dataset is cosmological, add a cosmology object
+
+ # Set dynamical dark energy parameters
+ use_dark_factor = getattr(self, 'use_dark_factor', False)
+ w_0 = getattr(self, 'w_0', -1.0)
+ w_a = getattr(self, 'w_a', 0.0)
+
self.cosmology = \
Cosmology(hubble_constant=self.hubble_constant,
omega_matter=self.omega_matter,
- omega_lambda=self.omega_lambda)
+ omega_lambda=self.omega_lambda,
+ use_dark_factor = use_dark_factor,
+ w_0 = w_0, w_a = w_a)
self.critical_density = \
self.cosmology.critical_density(self.current_redshift)
self.scale_factor = 1.0 / (1.0 + self.current_redshift)
diff -r 51ca56bb7126b9be23edd0fe6f2bf281be7ee2d3 -r 11a616b013dda6081d04e4ccd2ad8c71b31fe8dc yt/frontends/gadget/data_structures.py
--- a/yt/frontends/gadget/data_structures.py
+++ b/yt/frontends/gadget/data_structures.py
@@ -96,7 +96,10 @@
field_spec = "default",
ptype_spec = "default",
units_override=None,
- unit_system="cgs"):
+ unit_system="cgs",
+ use_dark_factor = False,
+ w_0 = -1.0,
+ w_a = 0.0):
if self._instantiated: return
self._header_spec = self._setup_binary_spec(
header_spec, gadget_header_specs)
diff -r 51ca56bb7126b9be23edd0fe6f2bf281be7ee2d3 -r 11a616b013dda6081d04e4ccd2ad8c71b31fe8dc yt/utilities/cosmology.py
--- a/yt/utilities/cosmology.py
+++ b/yt/utilities/cosmology.py
@@ -58,6 +58,17 @@
unit_system : :class:`yt.units.unit_systems.UnitSystem`, optional
The units system to use when making calculations. If not specified,
cgs units are assumed.
+ use_dark_factor: Bool, optional
+ The flag to either use the cosmological constant (False, default)
+ or to use the parameterization of w(a) as given in Linder 2002. This,
+ along with w_0 and w_a, only matters in the function expansion_factor.
+ w_0 : float, optional
+ The Linder 2002 parameterization of w(a) is: w(a) = w_0 + w_a(1 - a).
+ w_0 is w(a = 1). Only matters if use_dark_factor = True. Default is None.
+ Cosmological constant case corresponds to w_0 = -1.
+ w_a : float, optional
+ See w_0. w_a is the derivative of w(a) evaluated at a = 1. Cosmological
+ constant case corresponds to w_a = 0. Default is None.
Examples
--------
@@ -72,7 +83,10 @@
omega_lambda = 0.73,
omega_curvature = 0.0,
unit_registry = None,
- unit_system = "cgs"):
+ unit_system = "cgs",
+ use_dark_factor = False,
+ w_0 = -1.0,
+ w_a = 0.0):
self.omega_matter = float(omega_matter)
self.omega_lambda = float(omega_lambda)
self.omega_curvature = float(omega_curvature)
@@ -87,6 +101,12 @@
self.unit_registry = unit_registry
self.hubble_constant = self.quan(hubble_constant, "100*km/s/Mpc")
self.unit_system = unit_system
+
+ # For non-standard dark energy. If false, use default cosmological constant
+ # This only affects the expansion_factor function.
+ self.use_dark_factor = use_dark_factor
+ self.w_0 = w_0
+ self.w_a = w_a
def hubble_distance(self):
r"""
@@ -382,9 +402,18 @@
cosmological distances.
"""
+
+ # Use non-standard dark energy
+ if self.use_dark_factor:
+ dark_factor = self.get_dark_factor(z)
+
+ # Use default cosmological constant
+ else:
+ dark_factor = 1.0
+
return np.sqrt(self.omega_matter * ((1 + z)**3.0) +
self.omega_curvature * ((1 + z)**2.0) +
- self.omega_lambda)
+ (self.omega_lambda * dark_factor))
def inverse_expansion_factor(self, z):
return 1 / self.expansion_factor(z)
@@ -548,6 +577,31 @@
return my_time.in_base(self.unit_system)
+ def get_dark_factor(self, z):
+ """
+ This function computes the additional term that enters the expansion factor
+ when using non-standard dark energy. See Dolag et al 2004 eq. 7 for ref (but
+ note that there's a typo in his eq. There should be no negative sign).
+
+ At the moment, this only works using the parameterization given in Linder 2002
+ eq. 7: w(a) = w0 + wa(1 - a) = w0 + wa * z / (1+z). This gives rise to an analytic
+ expression. It is also only functional for Gadget simulations, at the moment.
+
+ Parameters
+ ----------
+ z: float
+ Redshift
+ """
+
+ # Get value of scale factor a corresponding to redshift z
+ scale_factor = 1.0 / (1.0 + z)
+
+ # Evaluate exponential using Linder02 parameterization
+ dark_factor = np.power(scale_factor, -3.0 * (1.0 + self.w_0 + self.w_a)) * \
+ np.exp(-3.0 * self.w_a * (1.0 - scale_factor))
+
+ return dark_factor
+
_arr = None
@property
def arr(self):
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