[cig-commits] r16131 - in short/3D/PyLith/trunk/playpen: . powerlaw

willic3 at geodynamics.org willic3 at geodynamics.org
Thu Jan 14 16:25:37 PST 2010


Author: willic3
Date: 2010-01-14 16:25:37 -0800 (Thu, 14 Jan 2010)
New Revision: 16131

Added:
   short/3D/PyLith/trunk/playpen/powerlaw/
   short/3D/PyLith/trunk/playpen/powerlaw/mat_elastic.spatialdb
   short/3D/PyLith/trunk/playpen/powerlaw/mat_powerlaw_in.spatialdb
   short/3D/PyLith/trunk/playpen/powerlaw/pl3dcomputeparams.cfg
   short/3D/PyLith/trunk/playpen/powerlaw/pl3dcomputeparams.py
   short/3D/PyLith/trunk/playpen/powerlaw/temperature.spatialdb
Log:
Initial work on a utility to convert from lab results to PyLith properties
for a power-law material.



Added: short/3D/PyLith/trunk/playpen/powerlaw/mat_elastic.spatialdb
===================================================================
--- short/3D/PyLith/trunk/playpen/powerlaw/mat_elastic.spatialdb	                        (rev 0)
+++ short/3D/PyLith/trunk/playpen/powerlaw/mat_elastic.spatialdb	2010-01-15 00:25:37 UTC (rev 16131)
@@ -0,0 +1,26 @@
+// -*- C++ -*- (tell Emacs to use C++ mode for syntax highlighting)
+//
+// This spatial database specifies the distribution of material
+// properties. In this case, the material properties are uniform.
+//
+#SPATIAL.ascii 1
+SimpleDB {
+  num-values = 3 // number of material property values
+  value-names =  density vs vp // names of the material property values
+  value-units =  kg/m**3  m/s  m/s // units
+  num-locs = 1 // number of locations
+  data-dim = 0
+  space-dim = 3
+  cs-data = cartesian {
+    to-meters = 1.0
+    space-dim = 3
+  }
+}
+// Columns are
+// (1) x coordinate (m)
+// (2) y coordinate (m)
+// (3) z coordinate (m)
+// (4) density (kg/m^3)
+// (5) vs (m/s)
+// (6) vp (m/s)
+0.0  0.0  0.0   2500.0  3000.0  5291.502622129181

Added: short/3D/PyLith/trunk/playpen/powerlaw/mat_powerlaw_in.spatialdb
===================================================================
--- short/3D/PyLith/trunk/playpen/powerlaw/mat_powerlaw_in.spatialdb	                        (rev 0)
+++ short/3D/PyLith/trunk/playpen/powerlaw/mat_powerlaw_in.spatialdb	2010-01-15 00:25:37 UTC (rev 16131)
@@ -0,0 +1,37 @@
+// -*- C++ -*- (tell Emacs to use C++ mode for syntax highlighting)
+//
+// This spatial database defines the power-law parameters for two materials:
+// Wet granite and dry olivine. The properties are from Strehlau and
+// Meissner (1987).
+// Note that the flow constant is expressed as log10(flow-constant), where
+// the units are GPa^(-n)/s. The activation energy (Q) is expressed in
+// kJ/mol.  To accommodate the strange units of the flow constant, the
+// given units of are 'None', and we specify a new parameter
+// (flow-constant-multiplier), with a value of 9, to indicate that the
+// underlying units are GPa.  A value of 6 would indicate MPa, etc.
+//
+#SPATIAL.ascii 1
+SimpleDB {
+  num-values = 4 // number of material property values
+  value-names =  flow-constant activation-energy power-law-exponent flow-constant-multiplier // names of the material property values
+  value-units =  None kJ/mol None None // units
+  num-locs = 4 // number of locations
+  data-dim = 1
+  space-dim = 3
+  cs-data = cartesian {
+    to-meters = 1000.0
+    space-dim = 3
+  }
+}
+// Columns are
+// (1) x coordinate (m)
+// (2) y coordinate (m)
+// (3) z coordinate (m)
+// (4) flow-constant (None)
+// (5) activation-energy (kJ/mol)
+// (6) power-law-exponent (None)
+// (7) activation-energy-multiplier (None)
+0.0   0.0   0.0    2.0 137.0 1.5 9.0
+0.0   0.0 -24.9    2.0 137.0 1.5 9.0
+0.0   0.0 -25.1   15.5 535.0 3.5 9.0
+0.0   0.0 -400.   15.5 535.0 3.5 9.0

Added: short/3D/PyLith/trunk/playpen/powerlaw/pl3dcomputeparams.cfg
===================================================================
--- short/3D/PyLith/trunk/playpen/powerlaw/pl3dcomputeparams.cfg	                        (rev 0)
+++ short/3D/PyLith/trunk/playpen/powerlaw/pl3dcomputeparams.cfg	2010-01-15 00:25:37 UTC (rev 16131)
@@ -0,0 +1,13 @@
+# -*- Python -*-
+[pl3dcomputeparams]
+
+# Top-level parameters
+use_reference_stress = False
+reference_stress = 1.0*MPa
+reference_strain_rate = 1.0e-6/s
+output_db_name = mat_powerlaw.spatialdb
+db_template = db_input_power_law_properties
+
+# Top-level facilities
+# Need to specify all of these along with their facilities and properties.
+db_input_elastic_properties = 

Added: short/3D/PyLith/trunk/playpen/powerlaw/pl3dcomputeparams.py
===================================================================
--- short/3D/PyLith/trunk/playpen/powerlaw/pl3dcomputeparams.py	                        (rev 0)
+++ short/3D/PyLith/trunk/playpen/powerlaw/pl3dcomputeparams.py	2010-01-15 00:25:37 UTC (rev 16131)
@@ -0,0 +1,188 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file powerlaw/pl3dcomputeparams
+
+## @brief Python application to compute power-law parameters used by PyLith,
+## given a spatial database describing the temperature and another spatial
+## database describing the laboratory-derived properties for the various
+## materials. The output is another spatial database containing the power-law
+## parameters for PyLith, as well as user-specified elastic properties. The
+## generated spatial database will have the same dimensions and coordinate
+## specifications as the input properties database.
+
+import numpy
+
+from pyre.applications.Script import Script as Application
+
+class Pl3dComputeParams(Application):
+  """
+  Python application to compute power-law parameters used by PyLith,
+  given input spatial databases describing the elastic properties, the
+  temperature, and the laboratory-derived properties for the various
+  materials. The output is another spatial database containing the power-law
+  parameters for PyLith, as well as user-specified elastic properties. The
+  generated spatial database will have the same dimensions and coordinate
+  specifications as the input properties database.
+  """
+  
+  class Inventory(Application.Inventory):
+    """
+    Python object for managing Pl3dComputeParams facilities and properties.
+    """
+
+    ## @class Inventory
+    ## Python object for managing Pl3dComputeParams facilities and properties.
+    ##
+    ## \b Properties
+    ## @li \b use_reference_stress Use reference stress to compute reference strain rate.
+    ## @li \b reference_stress Value of reference stress.
+    ## @li \b reference_strain_rate Value of reference strain rate.
+    ## @li \b db_template Which database to use as template for output.
+    ## @li \b output_db_name File name for output spatial database.
+    ##
+    ## \b Facilities
+    ## @li \b db_input_elastic_properties Database of input elastic properties.
+    ## @li \b db_input_power_law_properties Database of input power law properties.
+    ## @li \b db_input_temperature Database of input temperature values.
+    ## @li \b db_output_properties Database of output material properties.
+
+    import pyre.inventory
+    from pyre.units.pressure import Pa
+    from pyre.units.time import s
+
+    useReferenceStress = pyre.inventory.bool("use_reference_stress",
+                                             default=False)
+    useReferenceStress.meta['tip'] = "Use reference stress to compute reference strain rate."
+
+    referenceStress = pyre.inventory.dimensional("reference_stress",
+                                                 default=1.0*MPa)
+    referenceStress.meta['tip'] = "Reference stress value."
+
+    referenceStrainRate = pyre.inventory.dimensional("reference_strain_rate",
+                                                     default=1.0e-6/s)
+    referenceStrainRate.meta['tip'] = "Reference strain rate value."
+
+    outputDbName = pyre.inventory.str("output_db_name",
+                                      default="mat_powerlaw.spatialdb")
+    outputDbName.meta['tip'] = "File name of output spatial database."
+    
+    dbTemplate = pyre.inventory.str(
+      "db_template",
+      default="db_input_power_law_properties",
+      validator=pyre.inventory.choice(["db_input_power_law_properties",
+                                       "db_input_elastic_properties",
+                                       "db_input_temperature"]))
+    dbTemplate.meta['tip'] = "Which input DB to use as a template for output."
+
+    from spatialdata.spatialdb.SimpleDB import SimpleDB
+    dbInputElasticProperties = pyre.inventory.facility(
+      "db_input_elastic_properties",
+      family="spatial_database",
+      factory=SimpleDB)
+    dbInputElasticProperties.meta['tip'] = "DB for input elastic properties."
+
+    dbInputPowerLawProperties = pyre.inventory.facility(
+      "db_input_power_law_properties",
+      family="spatial_database",
+      factory=SimpleDB)
+    dbInputPowerLawProperties.meta['tip'] = "DB for input power law properties."
+
+    dbInputTemperature = pyre.inventory.facility(
+      "db_input_temperature",
+      family="spatial_database",
+      factory=SimpleDB)
+    dbInputTemperature.meta['tip'] = "DB for input temperature values."
+    
+    dbOutputProperties = pyre.inventory.facility(
+      "db_output_properties",
+      family="spatial_database",
+      factory=SimpleDB)
+    dbOutputProperties.meta['tip'] = "DB for output material properties."
+
+
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+
+  def __init__(self, name="pl3dcomputeparams"):
+    Application.__init__(self, name)
+
+    return
+
+
+  def main(self):
+    # import pdb
+    # pdb.set_trace()
+    self._getParameters()
+    return
+
+
+  # PRIVATE METHODS ////////////////////////////////////////////////////
+
+  def _configure(self):
+    """
+    Setup members using inventory.
+    """
+    Application._configure(self)
+
+    # Parameters
+    self.useReferenceStress = self.inventory.useReferenceStress
+    self.referenceStress = self.inventory.referenceStress.value
+    self.referenceStrainRate = self.inventory.referenceStrainRate.value
+    self.dbTemplate = self.inventory.dbTemplate
+    self.outputDbName = self.inventory.outputDbName
+
+    # Facilities
+    self.dbInputElasticProperties = self.inventory.dbInputElasticProperties
+    self.dbInputPowerLawProperties = self.inventory.dbInputPowerLawProperties
+    self.dbInputTemperature = self.inventory.dbInputTemperature
+    self.dbOutputProperties = self.inventory.dbOutputProperties
+
+    return
+
+
+  def _getParameters(self):
+    """
+    Get parameters from different databases and output power-law properties.
+    """
+
+    # Need to open all the input databases and then get the number of locations
+    # from the template database.
+    # We then loop over these locations and compute the power-law parameters
+    # for each point.
+    self.dbInputElasticProperties.open()
+    self.dbInputPowerLawProperties.open()
+    self.dbInputTemperature.open()
+    temp_queryVals = ["temperature"]
+    elastic_queryVals = ["density", "Vs", "Vp"]
+    pl_queryVals = ["flow-constant", "activation-energy",
+                    "power-law-exponent", "flow-constant-multiplier"]
+
+    # Actually, I can't find a way of determining the number of locations
+    # a priori.  We may need a different type of loop that continues until
+    # the data in the template database is exhausted.
+    # Alternatively, we can define a set of points for the output database
+    # and just loop over those. One method might be:
+    # specify min and max values for each coordinate direction along with
+    # either an interval or number of increments. If the min and max values are
+    # equal for a direction, that direction is just held constant.
+
+    for loc in range(nlocs):
+      
+    return
+
+
+# ----------------------------------------------------------------------
+if __name__ == '__main__':
+  app = Pl3dComputeParams()
+  app.run()
+
+# End of file


Property changes on: short/3D/PyLith/trunk/playpen/powerlaw/pl3dcomputeparams.py
___________________________________________________________________
Name: svn:executable
   + *

Added: short/3D/PyLith/trunk/playpen/powerlaw/temperature.spatialdb
===================================================================
--- short/3D/PyLith/trunk/playpen/powerlaw/temperature.spatialdb	                        (rev 0)
+++ short/3D/PyLith/trunk/playpen/powerlaw/temperature.spatialdb	2010-01-15 00:25:37 UTC (rev 16131)
@@ -0,0 +1,36 @@
+// -*- C++ -*- (tell Emacs to use C++ mode for syntax highlighting)
+//
+// This spatial database defines a simple 1D temperature, assuming a
+// temperature of 200 degrees C (473 degrees K) between 0 and 25 km depth,
+// and 500 degrees C (773 degrees K) below that.
+// Wet granite and dry olivine. The properties are from Strehlau and
+// Meissner (1987).
+// Note that the flow constant is expressed as log10(flow-constant), where
+// the units are GPa^(-n)/s. The activation energy (Q) is expressed in
+// kJ/mol.  To accommodate the strange units of the flow constant, the
+// given units of are 'None', and we specify a new parameter
+// (flow-constant-multiplier), with a value of 9, to indicate that the
+// underlying units are GPa.  A value of 6 would indicate MPa, etc.
+//
+#SPATIAL.ascii 1
+SimpleDB {
+  num-values = 1 // number of material property values
+  value-names =  temperature // names of the material property values
+  value-units =  K // units
+  num-locs = 4 // number of locations
+  data-dim = 1
+  space-dim = 3
+  cs-data = cartesian {
+    to-meters = 1000.0
+    space-dim = 3
+  }
+}
+// Columns are
+// (1) x coordinate (m)
+// (2) y coordinate (m)
+// (3) z coordinate (m)
+// (4) temperature (K)
+0.0   0.0   0.0   473.0
+0.0   0.0 -24.9   473.0
+0.0   0.0 -25.1   773.0
+0.0   0.0 -400.   773.0



More information about the CIG-COMMITS mailing list