more...
This commit is contained in:
parent
e89923d6d3
commit
3ed3073eff
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import os,sys,math,string
|
import os,sys,math
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
@ -124,16 +124,22 @@ for name in filenames:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
eulerangles=np.around(eulerangles,int(options.precision)) # round to desired precision
|
eulerangles=np.around(eulerangles,int(options.precision)) # round to desired precision
|
||||||
|
# ensure, that rounded euler angles are not out of bounds (modulo by limits)
|
||||||
for i,angle in enumerate(['phi1','PHI','phi2']):
|
for i,angle in enumerate(['phi1','PHI','phi2']):
|
||||||
eulerangles[:,i]%=limits[i] # ensure, that rounded euler angles are not out of bounds (modulo by limits)
|
eulerangles[:,i]%=limits[i]
|
||||||
|
|
||||||
|
# scale angles by desired precision and convert to int. create unique integer key from three euler angles by
|
||||||
|
# concatenating the string representation with leading zeros and store as integer and search unique euler angle keys.
|
||||||
|
# Texture IDs are the indices of the first occurrence, the inverse is used to construct the microstructure
|
||||||
|
# create a microstructure (texture/phase pair) for each point using unique texture IDs.
|
||||||
|
# Use longInt (64bit, i8) because the keys might be long
|
||||||
if options.compress:
|
if options.compress:
|
||||||
formatString='{0:0>'+str(int(options.precision)+3)+'}'
|
formatString='{0:0>'+str(int(options.precision)+3)+'}'
|
||||||
euleranglesRadInt = (eulerangles*10**int(options.precision)).astype('int') # scale by desired precision and convert to int
|
euleranglesRadInt = (eulerangles*10**int(options.precision)).astype('int')
|
||||||
eulerKeys = np.array([int(''.join(map(formatString.format,euleranglesRadInt[i,:]))) \
|
eulerKeys = np.array([int(''.join(map(formatString.format,euleranglesRadInt[i,:]))) \
|
||||||
for i in xrange(info['grid'].prod())]) # create unique integer key from three euler angles by concatenating the string representation with leading zeros and store as integer
|
for i in xrange(info['grid'].prod())])
|
||||||
devNull, texture, eulerKeys_idx = np.unique(eulerKeys, return_index = True, return_inverse=True)# search unique euler angle keys. Texture IDs are the indices of the first occurrence, the inverse is used to construct the microstructure
|
devNull, texture, eulerKeys_idx = np.unique(eulerKeys, return_index = True, return_inverse=True)
|
||||||
msFull = np.array([[eulerKeys_idx[i],phase[i]] for i in xrange(info['grid'].prod())],'i8') # create a microstructure (texture/phase pair) for each point using unique texture IDs. Use longInt (64bit, i8) because the keys might be long
|
msFull = np.array([[eulerKeys_idx[i],phase[i]] for i in xrange(info['grid'].prod())],'i8')
|
||||||
devNull,msUnique,matPoints = np.unique(msFull.view('c16'),True,True)
|
devNull,msUnique,matPoints = np.unique(msFull.view('c16'),True,True)
|
||||||
matPoints+=1
|
matPoints+=1
|
||||||
microstructure = np.array([msFull[i] for i in msUnique]) # pick only unique microstructures
|
microstructure = np.array([msFull[i] for i in msUnique]) # pick only unique microstructures
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import os,sys,math,string
|
import os,sys,math
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
@ -101,16 +101,22 @@ for name in filenames:
|
||||||
%(angle,n,eulerangles[n,0],eulerangles[n,1],eulerangles[n,2]))
|
%(angle,n,eulerangles[n,0],eulerangles[n,1],eulerangles[n,2]))
|
||||||
continue
|
continue
|
||||||
eulerangles=np.around(eulerangles,int(options.precision)) # round to desired precision
|
eulerangles=np.around(eulerangles,int(options.precision)) # round to desired precision
|
||||||
|
# ensure, that rounded euler angles are not out of bounds (modulo by limits)
|
||||||
for i,angle in enumerate(['phi1','PHI','phi2']):
|
for i,angle in enumerate(['phi1','PHI','phi2']):
|
||||||
eulerangles[:,i]%=limits[i] # ensure, that rounded euler angles are not out of bounds (modulo by limits)
|
eulerangles[:,i]%=limits[i]
|
||||||
|
|
||||||
|
# scale angles by desired precision and convert to int. create unique integer key from three euler angles by
|
||||||
|
# concatenating the string representation with leading zeros and store as integer and search unique euler angle keys.
|
||||||
|
# Texture IDs are the indices of the first occurrence, the inverse is used to construct the microstructure
|
||||||
|
# create a microstructure (texture/phase pair) for each point using unique texture IDs.
|
||||||
|
# Use longInt (64bit, i8) because the keys might be long
|
||||||
if options.compress:
|
if options.compress:
|
||||||
formatString='{0:0>'+str(int(options.precision)+3)+'}'
|
formatString='{0:0>'+str(int(options.precision)+3)+'}'
|
||||||
euleranglesRadInt = (eulerangles*10**int(options.precision)).astype('int') # scale by desired precision and convert to int
|
euleranglesRadInt = (eulerangles*10**int(options.precision)).astype('int')
|
||||||
eulerKeys = np.array([int(''.join(map(formatString.format,euleranglesRadInt[i,:]))) \
|
eulerKeys = np.array([int(''.join(map(formatString.format,euleranglesRadInt[i,:]))) \
|
||||||
for i in xrange(info['grid'].prod())]) # create unique integer key from three euler angles by concatenating the string representation with leading zeros and store as integer
|
for i in xrange(info['grid'].prod())])
|
||||||
devNull, texture, eulerKeys_idx = np.unique(eulerKeys, return_index = True, return_inverse=True)# search unique euler angle keys. Texture IDs are the indices of the first occurence, the inverse is used to construct the microstructure
|
devNull, texture, eulerKeys_idx = np.unique(eulerKeys, return_index = True, return_inverse=True)
|
||||||
msFull = np.array([[eulerKeys_idx[i],phase[i]] for i in xrange(info['grid'].prod())],'i8') # create a microstructure (texture/phase pair) for each point using unique texture IDs. Use longInt (64bit, i8) because the keys might be long
|
msFull = np.array([[eulerKeys_idx[i],phase[i]] for i in xrange(info['grid'].prod())],'i8')
|
||||||
devNull,msUnique,matPoints = np.unique(msFull.view('c16'),True,True)
|
devNull,msUnique,matPoints = np.unique(msFull.view('c16'),True,True)
|
||||||
matPoints+=1
|
matPoints+=1
|
||||||
microstructure = np.array([msFull[i] for i in msUnique]) # pick only unique microstructures
|
microstructure = np.array([msFull[i] for i in msUnique]) # pick only unique microstructures
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import os,sys,math,string
|
import os,sys,math
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
@ -13,9 +13,7 @@ scriptID = ' '.join([scriptName,damask.version])
|
||||||
|
|
||||||
|
|
||||||
def meshgrid2(*arrs):
|
def meshgrid2(*arrs):
|
||||||
'''
|
"""code inspired by http://stackoverflow.com/questions/1827489/numpy-meshgrid-in-3d"""
|
||||||
code inspired by http://stackoverflow.com/questions/1827489/numpy-meshgrid-in-3d
|
|
||||||
'''
|
|
||||||
arrs = tuple(reversed(arrs))
|
arrs = tuple(reversed(arrs))
|
||||||
arrs = tuple(arrs)
|
arrs = tuple(arrs)
|
||||||
lens = np.array(map(len, arrs))
|
lens = np.array(map(len, arrs))
|
||||||
|
@ -99,7 +97,8 @@ def laguerreTessellation(undeformed, coords, weights, grains, nonperiodic = Fals
|
||||||
for i,arg in enumerate(arguments):
|
for i,arg in enumerate(arguments):
|
||||||
closestSeeds[i] = findClosestSeed(arg)
|
closestSeeds[i] = findClosestSeed(arg)
|
||||||
|
|
||||||
return grains[closestSeeds%coords.shape[0]] # closestSeed is modulo number of original seed points (i.e. excluding periodic copies)
|
# closestSeed is modulo number of original seed points (i.e. excluding periodic copies)
|
||||||
|
return grains[closestSeeds%coords.shape[0]]
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
|
@ -210,9 +209,9 @@ for name in filenames:
|
||||||
table.head_read()
|
table.head_read()
|
||||||
info,extra_header = table.head_getGeom()
|
info,extra_header = table.head_getGeom()
|
||||||
|
|
||||||
if options.grid != None: info['grid'] = options.grid
|
if options.grid is not None: info['grid'] = options.grid
|
||||||
if options.size != None: info['size'] = options.size
|
if options.size is not None: info['size'] = options.size
|
||||||
if options.origin != None: info['origin'] = options.origin
|
if options.origin is not None: info['origin'] = options.origin
|
||||||
|
|
||||||
# ------------------------------------------ sanity checks ---------------------------------------
|
# ------------------------------------------ sanity checks ---------------------------------------
|
||||||
|
|
||||||
|
@ -298,7 +297,7 @@ for name in filenames:
|
||||||
phase = options.phase * np.ones(info['microstructures'],'i')
|
phase = options.phase * np.ones(info['microstructures'],'i')
|
||||||
if int(options.secondphase*info['microstructures']) > 0:
|
if int(options.secondphase*info['microstructures']) > 0:
|
||||||
phase[0:int(options.secondphase*info['microstructures'])] += 1
|
phase[0:int(options.secondphase*info['microstructures'])] += 1
|
||||||
randomSeed = int(os.urandom(4).encode('hex'), 16) if options.randomSeed == None \
|
randomSeed = int(os.urandom(4).encode('hex'), 16) if options.randomSeed is None \
|
||||||
else options.randomSeed # random seed for second phase
|
else options.randomSeed # random seed for second phase
|
||||||
np.random.seed(randomSeed)
|
np.random.seed(randomSeed)
|
||||||
np.random.shuffle(phase)
|
np.random.shuffle(phase)
|
||||||
|
@ -317,7 +316,7 @@ for name in filenames:
|
||||||
config_header += ['[Grain%s]'%(str(ID).zfill(formatwidth)),
|
config_header += ['[Grain%s]'%(str(ID).zfill(formatwidth)),
|
||||||
'(gauss)\tphi1 %g\tPhi %g\tphi2 %g\tscatter 0.0\tfraction 1.0'%tuple(eulers[eulerID])
|
'(gauss)\tphi1 %g\tPhi %g\tphi2 %g\tscatter 0.0\tfraction 1.0'%tuple(eulers[eulerID])
|
||||||
]
|
]
|
||||||
if options.axes != None: config_header.append('axes\t%s %s %s'%tuple(options.axes))
|
if options.axes is not None: config_header.append('axes\t%s %s %s'%tuple(options.axes))
|
||||||
|
|
||||||
table.labels_clear()
|
table.labels_clear()
|
||||||
table.info_clear()
|
table.info_clear()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import os,sys,string,math
|
import os,sys,math
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
@ -82,8 +82,12 @@ for name in filenames:
|
||||||
'microstructures': 0,
|
'microstructures': 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
newInfo['grid'] = np.array([{True:round(o*float(n.translate(None,'xX'))), False: round(float(n.translate(None,'xX')))}[n[-1].lower() == 'x'] for o,n in zip(info['grid'],options.grid)],'i')
|
newInfo['grid'] = np.array([{True:round(o*float(n.translate(None,'xX'))),
|
||||||
newInfo['size'] = np.array([{True: o*float(n.translate(None,'xX')) , False: float(n.translate(None,'xX')) }[n[-1].lower() == 'x'] for o,n in zip(info['size'],options.size)],'d')
|
False: round(float(n.translate(None,'xX')))}[n[-1].lower() == 'x']
|
||||||
|
for o,n in zip(info['grid'],options.grid)],'i')
|
||||||
|
newInfo['size'] = np.array([{True: o*float(n.translate(None,'xX')) ,
|
||||||
|
False: float(n.translate(None,'xX')) }[n[-1].lower() == 'x']
|
||||||
|
for o,n in zip(info['size'],options.size)],'d')
|
||||||
newInfo['grid'] = np.where(newInfo['grid'] <= 0 , info['grid'],newInfo['grid'])
|
newInfo['grid'] = np.where(newInfo['grid'] <= 0 , info['grid'],newInfo['grid'])
|
||||||
newInfo['size'] = np.where(newInfo['size'] <= 0.0, info['size'],newInfo['size'])
|
newInfo['size'] = np.where(newInfo['size'] <= 0.0, info['size'],newInfo['size'])
|
||||||
|
|
||||||
|
@ -97,11 +101,8 @@ for name in filenames:
|
||||||
last = this
|
last = this
|
||||||
|
|
||||||
microstructure = microstructure.reshape(info['grid'],order='F')
|
microstructure = microstructure.reshape(info['grid'],order='F')
|
||||||
microstructure = np.repeat(
|
microstructure = np.repeat(np.repeat(np.repeat(microstructure,
|
||||||
np.repeat(
|
multiplicity[0], axis=0),multiplicity[1], axis=1),multiplicity[2], axis=2)
|
||||||
np.repeat(microstructure,multiplicity[0], axis=0),
|
|
||||||
multiplicity[1], axis=1),
|
|
||||||
multiplicity[2], axis=2)
|
|
||||||
# --- renumber to sequence 1...Ngrains if requested ------------------------------------------------
|
# --- renumber to sequence 1...Ngrains if requested ------------------------------------------------
|
||||||
# http://stackoverflow.com/questions/10741346/np-frequency-counts-for-unique-values-in-an-array
|
# http://stackoverflow.com/questions/10741346/np-frequency-counts-for-unique-values-in-an-array
|
||||||
|
|
||||||
|
@ -119,9 +120,12 @@ for name in filenames:
|
||||||
remarks = []
|
remarks = []
|
||||||
errors = []
|
errors = []
|
||||||
|
|
||||||
if (any(newInfo['grid'] != info['grid'])): remarks.append('--> grid a b c: %s'%(' x '.join(map(str,newInfo['grid']))))
|
if (any(newInfo['grid'] != info['grid'])):
|
||||||
if (any(newInfo['size'] != info['size'])): remarks.append('--> size x y z: %s'%(' x '.join(map(str,newInfo['size']))))
|
remarks.append('--> grid a b c: %s'%(' x '.join(map(str,newInfo['grid']))))
|
||||||
if ( newInfo['microstructures'] != info['microstructures']): remarks.append('--> microstructures: %i'%newInfo['microstructures'])
|
if (any(newInfo['size'] != info['size'])):
|
||||||
|
remarks.append('--> size x y z: %s'%(' x '.join(map(str,newInfo['size']))))
|
||||||
|
if ( newInfo['microstructures'] != info['microstructures']):
|
||||||
|
remarks.append('--> microstructures: %i'%newInfo['microstructures'])
|
||||||
|
|
||||||
if np.any(newInfo['grid'] < 1): errors.append('invalid new grid a b c.')
|
if np.any(newInfo['grid'] < 1): errors.append('invalid new grid a b c.')
|
||||||
if np.any(newInfo['size'] <= 0.0): errors.append('invalid new size x y z.')
|
if np.any(newInfo['size'] <= 0.0): errors.append('invalid new size x y z.')
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import os,sys,string,vtk
|
import os,sys
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
|
Loading…
Reference in New Issue