def _readSteps(self): """ Read time step sizes from file. """ fin = open(self.filename, "r") lines = fin.readlines() fin.close() from pyre.units.unitparser import parser unitparser = parser() self.steps = [] for line in lines: fields = line.split() if line[0:2] != "//" and len(fields) > 0: if line[0:5] != "units": try: value = float(fields[0]) except ValueError: raise IOError("Unable to time step specification '%s'.\n" "Expected floating point value." % line.rstrip()) self.steps.append(value*units) else: if len(fields) != 3: raise IOError("Unable to parse units specification.\n" "Expected 'units = VALUE', got '%s'." % line.rstrip()) try: units = unitparser.parse(fields[2]) except NameError: raise IOError("Unable to parse units specification.\n" "Expected 'units = VALUE', got '%s'." % line.rstrip()) if len(self.steps) == 0: raise IOError("No time step size values found in time step file '%s'." % \ self.filename) return
def _readSteps(self): """ Read time step sizes from file. """ fin = open(self.filename, "r") lines = fin.readlines() fin.close() from pyre.units.unitparser import parser unitparser = parser() self.steps = [] for line in lines: fields = line.split() if line[0:2] != "//" and len(fields) > 0: if line[0:5] != "units": try: value = float(fields[0]) except ValueError: raise IOError( "Unable to time step specification '%s'.\n" "Expected floating point value." % line.rstrip()) self.steps.append(value * units) else: if len(fields) != 3: raise IOError("Unable to parse units specification.\n" "Expected 'units = VALUE', got '%s'." % line.rstrip()) try: units = unitparser.parse(fields[2]) except NameError: raise IOError("Unable to parse units specification.\n" "Expected 'units = VALUE', got '%s'." % line.rstrip()) if len(self.steps) == 0: raise IOError("No time step size values found in time step file '%s'." % \ self.filename) return
#!/usr/bin/env python import numpy import h5py import matplotlib.pyplot as pyplot from pyre.units.time import year from pyre.units.unitparser import parser stepSizes = ["dt01", "dt02", "dt05", "dt10"] # Time and stress/strain normalization information. uparser = parser() timeUnits = uparser.parse('1.0*year').value strainUnits = 1.0e-6 stressUnits = uparser.parse('1.0*MPa').value # Line styles. stylePlastic = ['k-', 'ro', 'bs', 'gD'] styleElastic = ['k--', 'r--', 'b--', 'g--'] #----------------------------------------------------------------------------- def computeStressInvar(fileName): """ Function to compute second deviatoric stress invariant. """ h5 = h5py.File(fileName, "r", driver="sec2") times = h5['time'][:,0,0] timeYears = times/timeUnits numSteps = times.shape[0] stressInvarMean = numpy.zeros(numSteps, dtype=numpy.float64)
#!/usr/bin/env python import numpy import h5py import matplotlib.pyplot as pyplot from pyre.units.time import year from pyre.units.unitparser import parser # Input files. stepSizes = ["dt01", "dt02", "dt05", "dt10"] # Time and stress/strain normalization information. uparser = parser() timeUnits = uparser.parse('1.0*year').value strainUnits = 1.0e-6 stressUnits = uparser.parse("1.0*MPa").value # Line styles. stylePlastic = ['k-', 'ro', 'bs', 'gD'] styleElastic = ['k--', 'r--', 'b--', 'g--'] #----------------------------------------------------------------------------- def computeStressInvar(fileName): """ Function to compute second deviatoric stress invariant. Exclude this for now because we need stress_zz to do it correctly. """ h5 = h5py.File(fileName, "r", driver="sec2")