Fix: Tresca, von Mises, Drucker, Hill 1948 criteria.

This commit is contained in:
Haiming Zhang 2015-02-04 16:47:35 +00:00
parent 2d568b49f2
commit 2b704b3905
1 changed files with 15 additions and 8 deletions

View File

@ -51,9 +51,15 @@ def stressInvariants(lambdas):
Is = Is.reshape(3,np.shape(lambdas)[1]) Is = Is.reshape(3,np.shape(lambdas)[1])
return Is return Is
def formatOutput(n, type='%14.6f'): def formatOutput(n, type='%-14.6f'):
return ''.join([type for i in xrange(n)]) return ''.join([type for i in xrange(n)])
def array2tuple(array):
'''transform numpy.array into tuple'''
try:
return tuple(array2tuple(i) for i in array)
except TypeError:
return array
def get_weight(ndim): def get_weight(ndim):
#more to do #more to do
return np.ones(ndim) return np.ones(ndim)
@ -198,7 +204,7 @@ fittingCriteria = {
'vonMises' :{'fit' :np.ones(1,'d'),'err':np.inf, 'vonMises' :{'fit' :np.ones(1,'d'),'err':np.inf,
'name' :'Huber-Mises-Hencky(von Mises)', 'name' :'Huber-Mises-Hencky(von Mises)',
'paras':'Initial yield stress:'}, 'paras':'Initial yield stress:'},
'Hill48' :{'fit' :np.ones(6,'d'),'err':np.inf, 'Hill1948' :{'fit' :np.ones(6,'d'),'err':np.inf,
'name' :'Hill1948', 'name' :'Hill1948',
'paras':'Normalized [F, G, H, L, M, N]'}, 'paras':'Normalized [F, G, H, L, M, N]'},
'Drucker' :{'fit' :np.ones(2,'d'),'err':np.inf, 'Drucker' :{'fit' :np.ones(2,'d'),'err':np.inf,
@ -283,9 +289,9 @@ class Criterion(object):
funResidum = Drucker funResidum = Drucker
text = '\nCoefficient of Drucker criterion:\nsigma0, C_D: '+formatOutput(2) text = '\nCoefficient of Drucker criterion:\nsigma0, C_D: '+formatOutput(2)
error='The standard deviation errors are: '+formatOutput(2,'%-14.8f')+'\n' error='The standard deviation errors are: '+formatOutput(2,'%-14.8f')+'\n'
elif self.name.lower() == 'hill48': elif self.name.lower() == 'hill1948':
funResidum = Hill1948 funResidum = Hill1948
text = '\nCoefficient of Hill1948 criterion:\n[F, G, H, L, M, N]:\n'+formatOutput(6) text = '\nCoefficient of Hill1948 criterion:\n[F, G, H, L, M, N]:'+' '*16+formatOutput(6)
error='The standard deviation errors are: '+formatOutput(6,'%-14.8f')+'\n' error='The standard deviation errors are: '+formatOutput(6,'%-14.8f')+'\n'
elif self.name.lower() == 'barlat91iso': elif self.name.lower() == 'barlat91iso':
funResidum = Barlat1991iso funResidum = Barlat1991iso
@ -307,8 +313,8 @@ class Criterion(object):
initialguess, weight) initialguess, weight)
perr = np.sqrt(np.diag(pcov)) perr = np.sqrt(np.diag(pcov))
fitResults.append(popt.tolist()) fitResults.append(popt.tolist())
print (text%popt) print (text%array2tuple(popt))
print (error%perr) print (error%array2tuple(perr))
except Exception as detail: except Exception as detail:
print detail print detail
pass pass
@ -410,8 +416,9 @@ def doSim(delay,thread):
for i in xrange(int(options.yieldValue[2])): for i in xrange(int(options.yieldValue[2])):
stressAll[i]=np.append(yieldStress[i]/unitGPa,stressAll[i]) stressAll[i]=np.append(yieldStress[i]/unitGPa,stressAll[i])
myFit.fit(stressAll[i].reshape(len(stressAll[i])//9,9).transpose()) myFit.fit(stressAll[i].reshape(len(stressAll[i])//9,9).transpose())
except Exception: except Exception as detail:
print('could not fit for sim %i from %s'%(me,thread)) print('could not fit for sim %i from %s'%(me,thread))
print detail
s.release() s.release()
return return
s.release() s.release()