fixed language and syntax
This commit is contained in:
parent
3dc5bc4379
commit
94fcc9ad24
|
@ -24,7 +24,7 @@ except(NameError):
|
||||||
|
|
||||||
|
|
||||||
def lables_to_path(label, dsXMLPath=None):
|
def lables_to_path(label, dsXMLPath=None):
|
||||||
"""Read the xml definition file and return the path."""
|
"""Read the XML definition file and return the path."""
|
||||||
if dsXMLPath is None:
|
if dsXMLPath is None:
|
||||||
# use the default storage layout in DS_HDF5.xml
|
# use the default storage layout in DS_HDF5.xml
|
||||||
if "h5table.pyc" in __file__:
|
if "h5table.pyc" in __file__:
|
||||||
|
@ -49,31 +49,31 @@ def lables_to_path(label, dsXMLPath=None):
|
||||||
|
|
||||||
class H5Table(object):
|
class H5Table(object):
|
||||||
"""
|
"""
|
||||||
Light weight interface class for h5py
|
Lightweight interface class for h5py
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
-----------
|
-----------
|
||||||
Interface/wrapper class for manipulating data in HDF5 with DAMASK
|
Interface/wrapper class for manipulating data in HDF5 with DAMASK
|
||||||
specialized data structure.
|
specialized data structure.
|
||||||
-->try to maintain a minimal API design.
|
--> try to maintain a minimal API design.
|
||||||
PARAMETERS
|
PARAMETERS
|
||||||
----------
|
----------
|
||||||
h5f_path: str
|
h5f_path: str
|
||||||
Absolute path the HDF5 file
|
Absolute path of the HDF5 file
|
||||||
METHOD
|
METHOD
|
||||||
------
|
------
|
||||||
del_entry() -- Force delete attributes/group/datasets (Dangerous)
|
del_entry() -- Force delete attributes/group/datasets (dangerous)
|
||||||
get_attr() -- Return attributes if possible
|
get_attr() -- Return attributes if possible
|
||||||
add_attr() -- Add NEW attributes to dataset/group (no force overwrite)
|
add_attr() -- Add NEW attributes to dataset/group (no force overwrite)
|
||||||
get_data() -- Retrieve data in numpy.ndarray
|
get_data() -- Retrieve data in numpy.ndarray
|
||||||
add_data() -- Add dataset to H5 file
|
add_data() -- Add dataset to H5 file
|
||||||
get_cmdlog() -- Return the command used to generate the data if possible.
|
get_cmdlog() -- Return the command used to generate the data if possible
|
||||||
NOTE
|
NOTE
|
||||||
----
|
----
|
||||||
1. As an interface class, it uses the lazy evaluation design
|
1. As an interface class, it uses the lazy evaluation design
|
||||||
that read the data only when its absolutely necessary.
|
that reads the data only when it is absolutely necessary.
|
||||||
2. The command line used to generate new feature is stored with
|
2. The command line used to generate each new feature is stored with
|
||||||
each dataset as dataset attribute.
|
each dataset as dataset attribute.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
@ -28,14 +28,14 @@ class Rodrigues:
|
||||||
# ******************************************************************************************
|
# ******************************************************************************************
|
||||||
class Quaternion:
|
class Quaternion:
|
||||||
"""
|
"""
|
||||||
Orientation represented as unit quaternion
|
Orientation represented as unit quaternion.
|
||||||
|
|
||||||
All methods and naming conventions based on http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions
|
All methods and naming conventions based on http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions.
|
||||||
|
|
||||||
w is the real part, (x, y, z) are the imaginary parts
|
w is the real part, (x, y, z) are the imaginary parts.
|
||||||
Representation of rotation is in ACTIVE form!
|
Representation of rotation is in ACTIVE form!
|
||||||
(derived directly or through angleAxis, Euler angles, or active matrix)
|
(Derived directly or through angleAxis, Euler angles, or active matrix)
|
||||||
vector "a" (defined in coordinate system "A") is actively rotated to new coordinates "b"
|
Vector "a" (defined in coordinate system "A") is actively rotated to new coordinates "b".
|
||||||
b = Q * a
|
b = Q * a
|
||||||
b = np.dot(Q.asMatrix(),a)
|
b = np.dot(Q.asMatrix(),a)
|
||||||
"""
|
"""
|
||||||
|
@ -77,7 +77,7 @@ class Quaternion:
|
||||||
return Q
|
return Q
|
||||||
|
|
||||||
def __ipow__(self, exponent):
|
def __ipow__(self, exponent):
|
||||||
"""In place power"""
|
"""In-place power"""
|
||||||
omega = math.acos(self.w)
|
omega = math.acos(self.w)
|
||||||
vRescale = math.sin(exponent*omega)/math.sin(omega)
|
vRescale = math.sin(exponent*omega)/math.sin(omega)
|
||||||
self.w = np.cos(exponent*omega)
|
self.w = np.cos(exponent*omega)
|
||||||
|
@ -135,7 +135,7 @@ class Quaternion:
|
||||||
return self.copy()
|
return self.copy()
|
||||||
|
|
||||||
def __imul__(self, other):
|
def __imul__(self, other):
|
||||||
"""In place multiplication"""
|
"""In-place multiplication"""
|
||||||
try: # Quaternion
|
try: # Quaternion
|
||||||
Ax = self.x
|
Ax = self.x
|
||||||
Ay = self.y
|
Ay = self.y
|
||||||
|
@ -164,7 +164,7 @@ class Quaternion:
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
|
|
||||||
def __idiv__(self, other):
|
def __idiv__(self, other):
|
||||||
"""In place division"""
|
"""In-place division"""
|
||||||
if isinstance(other, (int,float)):
|
if isinstance(other, (int,float)):
|
||||||
self.w /= other
|
self.w /= other
|
||||||
self.x /= other
|
self.x /= other
|
||||||
|
@ -184,7 +184,7 @@ class Quaternion:
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
|
|
||||||
def __iadd__(self, other):
|
def __iadd__(self, other):
|
||||||
"""In place division"""
|
"""In-place addition"""
|
||||||
if isinstance(other, Quaternion):
|
if isinstance(other, Quaternion):
|
||||||
self.w += other.w
|
self.w += other.w
|
||||||
self.x += other.x
|
self.x += other.x
|
||||||
|
@ -205,7 +205,7 @@ class Quaternion:
|
||||||
return self.copy()
|
return self.copy()
|
||||||
|
|
||||||
def __isub__(self, other):
|
def __isub__(self, other):
|
||||||
"""In place subtraction"""
|
"""In-place subtraction"""
|
||||||
if isinstance(other, Quaternion):
|
if isinstance(other, Quaternion):
|
||||||
self.w -= other.w
|
self.w -= other.w
|
||||||
self.x -= other.x
|
self.x -= other.x
|
||||||
|
@ -339,12 +339,12 @@ class Quaternion:
|
||||||
degrees = False,
|
degrees = False,
|
||||||
standardRange = False):
|
standardRange = False):
|
||||||
"""
|
"""
|
||||||
Orientation as Bunge-Euler angles
|
Orientation as Bunge-Euler angles.
|
||||||
|
|
||||||
conversion of ACTIVE rotation to Euler angles taken from:
|
Conversion of ACTIVE rotation to Euler angles taken from:
|
||||||
Melcher, A.; Unser, A.; Reichhardt, M.; Nestler, B.; Poetschke, M.; Selzer, M.
|
Melcher, A.; Unser, A.; Reichhardt, M.; Nestler, B.; Poetschke, M.; Selzer, M.
|
||||||
Conversion of EBSD data by a quaternion based algorithm to be used for grain structure simulations
|
Conversion of EBSD data by a quaternion based algorithm to be used for grain structure simulations
|
||||||
Technische Mechanik 30 (2010) pp 401--413
|
Technische Mechanik 30 (2010) pp 401--413.
|
||||||
"""
|
"""
|
||||||
angles = [0.0,0.0,0.0]
|
angles = [0.0,0.0,0.0]
|
||||||
|
|
||||||
|
@ -510,8 +510,8 @@ class Quaternion:
|
||||||
"""
|
"""
|
||||||
Interpolation
|
Interpolation
|
||||||
|
|
||||||
see http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20070017872_2007014421.pdf
|
See http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20070017872_2007014421.pdf
|
||||||
for (another?) way to interpolate quaternions
|
for (another?) way to interpolate quaternions.
|
||||||
"""
|
"""
|
||||||
assert isinstance(q1, Quaternion) and isinstance(q2, Quaternion)
|
assert isinstance(q1, Quaternion) and isinstance(q2, Quaternion)
|
||||||
Q = cls()
|
Q = cls()
|
||||||
|
@ -744,39 +744,39 @@ class Symmetry:
|
||||||
|
|
||||||
if self.lattice == 'cubic':
|
if self.lattice == 'cubic':
|
||||||
basis = {'improper':np.array([ [-1. , 0. , 1. ],
|
basis = {'improper':np.array([ [-1. , 0. , 1. ],
|
||||||
[ np.sqrt(2.) , -np.sqrt(2.) , 0. ],
|
[ np.sqrt(2.) , -np.sqrt(2.) , 0. ],
|
||||||
[ 0. , np.sqrt(3.) , 0. ] ]),
|
[ 0. , np.sqrt(3.) , 0. ] ]),
|
||||||
'proper':np.array([ [ 0. , -1. , 1. ],
|
'proper':np.array([ [ 0. , -1. , 1. ],
|
||||||
[-np.sqrt(2.) , np.sqrt(2.) , 0. ],
|
[-np.sqrt(2.) , np.sqrt(2.) , 0. ],
|
||||||
[ np.sqrt(3.) , 0. , 0. ] ]),
|
[ np.sqrt(3. ) , 0. , 0. ] ]),
|
||||||
}
|
}
|
||||||
elif self.lattice == 'hexagonal':
|
elif self.lattice == 'hexagonal':
|
||||||
basis = {'improper':np.array([ [ 0. , 0. , 1. ],
|
basis = {'improper':np.array([ [ 0. , 0. , 1. ],
|
||||||
[ 1. , -np.sqrt(3.), 0. ],
|
[ 1. , -np.sqrt(3.) , 0. ],
|
||||||
[ 0. , 2. , 0. ] ]),
|
[ 0. , 2. , 0. ] ]),
|
||||||
'proper':np.array([ [ 0. , 0. , 1. ],
|
'proper':np.array([ [ 0. , 0. , 1. ],
|
||||||
[-1. , np.sqrt(3.) , 0. ],
|
[-1. , np.sqrt(3.) , 0. ],
|
||||||
[ np.sqrt(3) , -1. , 0. ] ]),
|
[ np.sqrt(3) , -1. , 0. ] ]),
|
||||||
}
|
}
|
||||||
elif self.lattice == 'tetragonal':
|
elif self.lattice == 'tetragonal':
|
||||||
basis = {'improper':np.array([ [ 0. , 0. , 1. ],
|
basis = {'improper':np.array([ [ 0. , 0. , 1. ],
|
||||||
[ 1. , -1. , 0. ],
|
[ 1. , -1. , 0. ],
|
||||||
[ 0. , np.sqrt(2.), 0. ] ]),
|
[ 0. , np.sqrt(2.) , 0. ] ]),
|
||||||
'proper':np.array([ [ 0. , 0. , 1. ],
|
'proper':np.array([ [ 0. , 0. , 1. ],
|
||||||
[-1. , 1. , 0. ],
|
[-1. , 1. , 0. ],
|
||||||
[ np.sqrt(2.) , 0. , 0. ] ]),
|
[ np.sqrt(2.) , 0. , 0. ] ]),
|
||||||
}
|
}
|
||||||
elif self.lattice == 'orthorhombic':
|
elif self.lattice == 'orthorhombic':
|
||||||
basis = {'improper':np.array([ [ 0., 0., 1.],
|
basis = {'improper':np.array([ [ 0., 0., 1.],
|
||||||
[ 1., 0., 0.],
|
[ 1., 0., 0.],
|
||||||
[ 0., 1., 0.] ]),
|
[ 0., 1., 0.] ]),
|
||||||
'proper':np.array([ [ 0., 0., 1.],
|
'proper':np.array([ [ 0., 0., 1.],
|
||||||
[-1., 0., 0.],
|
[-1., 0., 0.],
|
||||||
[ 0., 1., 0.] ]),
|
[ 0., 1., 0.] ]),
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
basis = {'improper':np.zeros((3,3),dtype=float),
|
basis = {'improper': np.zeros((3,3),dtype=float),
|
||||||
'proper':np.zeros((3,3),dtype=float),
|
'proper': np.zeros((3,3),dtype=float),
|
||||||
}
|
}
|
||||||
|
|
||||||
if np.all(basis == 0.0):
|
if np.all(basis == 0.0):
|
||||||
|
|
|
@ -69,7 +69,7 @@ for name in filenames:
|
||||||
# ------------------------------------------ assemble header --------------------------------------
|
# ------------------------------------------ assemble header --------------------------------------
|
||||||
|
|
||||||
table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:]))
|
table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:]))
|
||||||
table.labels_append(['%i_S'%(i+1) for i in range(9)]) # extend ASCII header with new labels
|
table.labels_append(['{}_S'.format(i+1) for i in range(9)]) # extend ASCII header with new labels
|
||||||
table.head_write()
|
table.head_write()
|
||||||
|
|
||||||
# ------------------------------------------ process data ------------------------------------------
|
# ------------------------------------------ process data ------------------------------------------
|
||||||
|
|
|
@ -51,7 +51,7 @@ def ParseOutputFormat(filename,what,me):
|
||||||
|
|
||||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog [option(s)] Abaqus.Inputfile(s)', description = """
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog [option(s)] Abaqus.Inputfile(s)', description = """
|
||||||
Transfer the output variables requested in the material.config to
|
Transfer the output variables requested in the material.config to
|
||||||
properly labelled user defined variables within the Abaqus input file (*.inp).
|
properly labelled user-defined variables within the Abaqus input file (*.inp).
|
||||||
|
|
||||||
Requires the files
|
Requires the files
|
||||||
<modelname_jobname>.output<Homogenization/Crystallite/Constitutive>
|
<modelname_jobname>.output<Homogenization/Crystallite/Constitutive>
|
||||||
|
@ -84,7 +84,7 @@ parser.set_defaults(number = 0,
|
||||||
(options, files) = parser.parse_args()
|
(options, files) = parser.parse_args()
|
||||||
|
|
||||||
if not files:
|
if not files:
|
||||||
parser.error('no file(s) specified...')
|
parser.error('no file(s) specified.')
|
||||||
|
|
||||||
me = { 'Homogenization': options.homog,
|
me = { 'Homogenization': options.homog,
|
||||||
'Crystallite': options.cryst,
|
'Crystallite': options.cryst,
|
||||||
|
@ -93,7 +93,7 @@ me = { 'Homogenization': options.homog,
|
||||||
|
|
||||||
|
|
||||||
for myFile in files:
|
for myFile in files:
|
||||||
print('\033[1m'+scriptName+'\033[0m: '+myFile+'\n')
|
damask.util.report(scriptName,myFile)
|
||||||
if options.useFile:
|
if options.useFile:
|
||||||
formatFile = os.path.splitext(options.useFile)[0]
|
formatFile = os.path.splitext(options.useFile)[0]
|
||||||
else:
|
else:
|
||||||
|
@ -103,7 +103,7 @@ for myFile in files:
|
||||||
print('{} not found'.format(myFile))
|
print('{} not found'.format(myFile))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print('Scanning format files of: %s'%formatFile)
|
print('Scanning format files of: {}'.format(formatFile))
|
||||||
|
|
||||||
if options.number < 1:
|
if options.number < 1:
|
||||||
outputFormat = {}
|
outputFormat = {}
|
||||||
|
@ -140,7 +140,7 @@ for myFile in files:
|
||||||
UserVars += ['%i_%s'%(grain+1,var[0]) for i in range(var[1])]
|
UserVars += ['%i_%s'%(grain+1,var[0]) for i in range(var[1])]
|
||||||
|
|
||||||
# Now change *.inp file(s)
|
# Now change *.inp file(s)
|
||||||
print('Adding labels to: %s'%myFile)
|
print('Adding labels to: {}'.format(myFile))
|
||||||
inFile = open(myFile)
|
inFile = open(myFile)
|
||||||
input = inFile.readlines()
|
input = inFile.readlines()
|
||||||
inFile.close()
|
inFile.close()
|
||||||
|
@ -154,11 +154,11 @@ for myFile in files:
|
||||||
if m:
|
if m:
|
||||||
lastSection = thisSection
|
lastSection = thisSection
|
||||||
thisSection = m.group(1)
|
thisSection = m.group(1)
|
||||||
if (lastSection.upper() == '*DEPVAR' and thisSection.upper() == '*USER'): #Abaqus keyword can be upper or lower case
|
if (lastSection.upper() == '*DEPVAR' and thisSection.upper() == '*USER'): # Abaqus keyword can be upper or lower case
|
||||||
if options.number > 0:
|
if options.number > 0:
|
||||||
output.write('%i\n'%options.number) #Abaqus needs total number of SDVs in the line after *Depvar keyword
|
output.write('{}\n'.format(options.number)) # Abaqus needs total number of SDVs in the line after *Depvar keyword
|
||||||
else:
|
else:
|
||||||
output.write('%i\n'%len(UserVars))
|
output.write('{}\n'.format(len(UserVars)))
|
||||||
|
|
||||||
for i in range(len(UserVars)):
|
for i in range(len(UserVars)):
|
||||||
output.write('%i,"%i%s","%i%s"\n'%(i+1,0,UserVars[i],0,UserVars[i])) #index,output variable key,output variable description
|
output.write('%i,"%i%s","%i%s"\n'%(i+1,0,UserVars[i],0,UserVars[i])) #index,output variable key,output variable description
|
||||||
|
|
Loading…
Reference in New Issue