From 280076e7ef1894c682c361f4b5214eb67f3b4e8b Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Wed, 11 May 2016 10:04:01 -0400 Subject: [PATCH 1/7] removed (probably obsolete) warning about missing h5py module. --- lib/damask/result.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/damask/result.py b/lib/damask/result.py index 36e4ba81b..bb68c3ac5 100644 --- a/lib/damask/result.py +++ b/lib/damask/result.py @@ -8,7 +8,7 @@ import sys try: import h5py except (ImportError) as e: - sys.stderr.write('\nREMARK: h5py module not available \n\n') + pass # sys.stderr.write('\nREMARK: h5py module not available \n\n') class Result(): """ From ba6889a54f7ef52b38244e96b05bd550f0863e7d Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Wed, 11 May 2016 10:04:55 -0400 Subject: [PATCH 2/7] removed debug statement --- processing/post/averageTable.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/processing/post/averageTable.py b/processing/post/averageTable.py index 4a2f1eca6..aaa4ea88d 100755 --- a/processing/post/averageTable.py +++ b/processing/post/averageTable.py @@ -37,8 +37,6 @@ if options.label is None: if filenames == []: filenames = [None] for name in filenames: - damask.util.croak(name) - try: table = damask.ASCIItable(name = name, outname = os.path.join( os.path.split(name)[0], From 0c1657693f85fe50da2cb4baaa12759d13f29eca Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 17 May 2016 10:52:21 -0400 Subject: [PATCH 3/7] dirty (but working) fix to adopt table.labels now being table.tags: table.labels --> table.labels(raw = True) --- lib/damask/test/test.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/damask/test/test.py b/lib/damask/test/test.py index e617568f8..c05a6474d 100644 --- a/lib/damask/test/test.py +++ b/lib/damask/test/test.py @@ -336,16 +336,16 @@ class Test(): key0 = ('1_' if length[i]>1 else '') + headings0[i]['label'] key1 = ('1_' if length[i]>1 else '') + headings1[i]['label'] normKey = ('1_' if normLength[i]>1 else '') + normHeadings[i]['label'] - if key0 not in table0.labels: + if key0 not in table0.labels(raw = True): raise Exception('column {} not found in 1. table...\n'.format(key0)) - elif key1 not in table1.labels: + elif key1 not in table1.labels(raw = True): raise Exception('column {} not found in 2. table...\n'.format(key1)) - elif normKey not in table0.labels: + elif normKey not in table0.labels(raw = True): raise Exception('column {} not found in 1. table...\n'.format(normKey)) else: - column[0][i] = table0.labels.index(key0) - column[1][i] = table1.labels.index(key1) - normColumn[i] = table0.labels.index(normKey) + column[0][i] = table0.label_index(key0) + column[1][i] = table1.label_index(key1) + normColumn[i] = table0.label_index(normKey) line0 = 0 while table0.data_read(): # read next data line of ASCII table @@ -421,7 +421,7 @@ class Test(): columns = columns[:len(files)] # truncate to same length as files for i,column in enumerate(columns): - if column is None: columns[i] = tables[i].labels # if no column is given, read all + if column is None: columns[i] = tables[i].labels(raw = True) # if no column is given, read all logging.info('comparing ASCIItables statistically') for i in xrange(len(columns)): @@ -477,7 +477,7 @@ class Test(): columns = columns[:len(files)] # truncate to same length as files for i,column in enumerate(columns): - if column is None: columns[i] = tables[i].labels # if no column is given, read all + if column is None: columns[i] = tables[i].labels(raw = True) # if no column is given, read all logging.info('comparing ASCIItables') for i in xrange(len(columns)): From a8765a963d45287e4df0cf7f3f2ad7d61f32f40f Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 17 May 2016 11:12:26 -0400 Subject: [PATCH 4/7] more fixing of old .labels use --- processing/misc/yieldSurface.py | 11 +++++------ processing/post/addTable.py | 21 +++++++++------------ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/processing/misc/yieldSurface.py b/processing/misc/yieldSurface.py index e7e6b473b..406a0d2cd 100755 --- a/processing/misc/yieldSurface.py +++ b/processing/misc/yieldSurface.py @@ -138,7 +138,7 @@ def principalStrs_Der(p, (s1, s2, s3, s4, s5, s6), dim, Karafillis=False): return np.array([np.dot(dSdI[:,:,i],dIdc[:,:,i]).T for i in xrange(num)]).T def invariant(sigmas): - I=np.zeros(3) + I = np.zeros(3) s11,s22,s33,s12,s23,s31 = sigmas I[0] = s11 + s22 + s33 I[1] = s11*s22 + s22*s33 + s33*s11 - s12**2 - s23**2 - s31**2 @@ -1271,13 +1271,12 @@ def doSim(thread): table = damask.ASCIItable(refFile,readonly=True) table.head_read() - if options.fitting =='equivalentStrain': - thresholdKey = 'Mises(ln(V))' - elif options.fitting =='totalshear': - thresholdKey = 'totalshear' + thresholdKey = {'equivalentStrain':'Mises(ln(V))', + 'totalshear': 'totalshear', + }[options.fitting] for l in [thresholdKey,'1_Cauchy']: - if l not in table.labels: damask.util.croak('%s not found'%l) + if l not in table.labels(raw = True): damask.util.croak('%s not found'%l) s.release() table.data_readArray(['%i_Cauchy'%(i+1) for i in xrange(9)]+[thresholdKey]+['%i_ln(V)'%(i+1) for i in xrange(9)]) diff --git a/processing/post/addTable.py b/processing/post/addTable.py index df47b6c55..53774b5d7 100755 --- a/processing/post/addTable.py +++ b/processing/post/addTable.py @@ -29,33 +29,30 @@ parser.add_option('-a', '--add','--table', if filenames == []: filenames = [None] for name in filenames: - try: - table = damask.ASCIItable(name = name, - buffered = False) + try: table = damask.ASCIItable(name = name, + buffered = False) except: continue damask.util.report(scriptName,name) + tables = [] for addTable in options.table: - try: - tables.append(damask.ASCIItable(name = addTable, - buffered = False, - readonly = True) - ) + try: tables.append(damask.ASCIItable(name = addTable, + buffered = False, + readonly = True) + ) except: continue # ------------------------------------------ read headers ------------------------------------------ table.head_read() - for addTable in tables: - addTable.head_read() + for addTable in tables: addTable.head_read() # ------------------------------------------ assemble header -------------------------------------- table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:])) - for addTable in tables: - table.labels_append(addTable.labels) # extend ASCII header with new labels + for addTable in tables: table.labels_append(addTable.labels(raw = True)) # extend ASCII header with new labels table.head_write() From d669cfb0245bbf754cede26bc11ba648e53daacb Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 17 May 2016 11:15:04 -0400 Subject: [PATCH 5/7] removed obsolete importing of sys --- lib/damask/result.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/damask/result.py b/lib/damask/result.py index acd207d84..350495a33 100644 --- a/lib/damask/result.py +++ b/lib/damask/result.py @@ -2,7 +2,7 @@ import numpy as np -import sys +#import sys try: import h5py From 12affbd2400403043c1beed8c499ed5dffd7c6f4 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 17 May 2016 11:23:57 -0400 Subject: [PATCH 6/7] simplified and corrected --- processing/misc/yieldSurface.py | 53 +++++++++++++++------------------ 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/processing/misc/yieldSurface.py b/processing/misc/yieldSurface.py index 406a0d2cd..d636c37f3 100755 --- a/processing/misc/yieldSurface.py +++ b/processing/misc/yieldSurface.py @@ -1379,51 +1379,46 @@ parser.add_option('-e', '--exponent', dest='exponent', type='float', parser.add_option('-u', '--uniaxial', dest='eqStress', type='float', help='Equivalent stress', metavar='float') -parser.set_defaults(min = 12) -parser.set_defaults(max = 30) -parser.set_defaults(threads = 4) -parser.set_defaults(yieldValue = (0.002,0.004,2)) -parser.set_defaults(load = (0.010,100,100.0)) -parser.set_defaults(criterion = 'vonmises') -parser.set_defaults(fitting = 'totalshear') -parser.set_defaults(geometry = '20grains16x16x16') -parser.set_defaults(bounds = None) -parser.set_defaults(dimension = '3') -parser.set_defaults(exponent = -1.0) +parser.set_defaults(min = 12, + max = 30, + threads = 4, + yieldValue = (0.002,0.004,2), + load = (0.010,100,100.0), + criterion = 'vonmises', + fitting = 'totalshear', + geometry = '20grains16x16x16', + bounds = None, + dimension = '3', + exponent = -1.0, + ) options = parser.parse_args()[0] -if not os.path.isfile(options.geometry+'.geom'): - parser.error('geometry file %s.geom not found'%options.geometry) -if not os.path.isfile('material.config'): - parser.error('material.config file not found') -if options.threads<1: - parser.error('invalid number of threads %i'%options.threads) -if options.min<0: - parser.error('invalid minimum number of simulations %i'%options.min) -if options.maxoptions.yieldValue[1]: +if options.yieldValue[0] > options.yieldValue[1]: parser.error('invalid yield start (below yield end)') if options.yieldValue[2] != int(options.yieldValue[2]): parser.error('count must be an integer') -if not os.path.isfile('numerics.config'): - damask.util.croak('numerics.config file not found') -if not os.path.isfile('material.config'): - damask.util.croak('material.config file not found') +for check in [options.geometry+'.geom','numerics.config','material.config']: + if not os.path.isfile(check): + damask.util.croak('"{}" file not found'.format(check)) options.dimension = int(options.dimension) -if options.criterion == 'hill1948': stressUnit = 1.0e9 -else : stressUnit = 1.0e6 +stressUnit = 1.0e9 if options.criterion == 'hill1948' else 1.0e6 if options.dimension not in fitCriteria[options.criterion]['dimen']: parser.error('invalid dimension for selected criterion') -if options.criterion not in ['vonmises','tresca','drucker','hill1984'] and options.eqStress is None: - parser.error('please specifie an equivalent stress (e.g. fitting to von Mises)') +if options.criterion not in ['vonmises','tresca','drucker','hill1948'] and options.eqStress is None: + parser.error('please specify an equivalent stress (e.g. fitting to von Mises)') run = runFit(options.exponent, options.eqStress, options.dimension, options.criterion) From a7c15b4c0041ec0b8db3b199f5c05e0d9652a771 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 17 May 2016 11:29:31 -0400 Subject: [PATCH 7/7] avoided quoting of "N of x" and "a to b". --- processing/pre/geom_pack.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/processing/pre/geom_pack.py b/processing/pre/geom_pack.py index 324141aaa..168cfe1d6 100755 --- a/processing/pre/geom_pack.py +++ b/processing/pre/geom_pack.py @@ -91,11 +91,11 @@ for name in filenames: if type == '': table.data = [] elif type == '.': - table.data = [str(former)] + table.data = [former] elif type == 'to': - table.data = ['{0} to {1}'.format(former-reps+1,former)] + table.data = [former-reps+1,'to',former] elif type == 'of': - table.data = ['{0} of {1}'.format(reps,former)] + table.data = [reps,'of',former] outputAlive = table.data_write(delimiter = ' ') # output processed line @@ -106,9 +106,9 @@ for name in filenames: former = current table.data = { - '.' : [str(former)], - 'to': ['%i to %i'%(former-reps+1,former)], - 'of': ['%i of %i'%(reps,former)], + '.' : [former], + 'to': [former-reps+1,'to',former], + 'of': [reps,'of',former], }[type] outputAlive = table.data_write(delimiter = ' ') # output processed line