new names part 2
This commit is contained in:
parent
1b18cae46b
commit
3d49678e93
|
@ -27,34 +27,34 @@ class ConfigMaterial(Config):
|
||||||
def is_complete(self):
|
def is_complete(self):
|
||||||
"""Check for completeness."""
|
"""Check for completeness."""
|
||||||
ok = True
|
ok = True
|
||||||
for top_level in ['homogenization','phase','microstructure']:
|
for top_level in ['homogenization','phase','material']:
|
||||||
# ToDo: With python 3.8 as prerequisite we can shorten with :=
|
# ToDo: With python 3.8 as prerequisite we can shorten with :=
|
||||||
ok &= top_level in self
|
ok &= top_level in self
|
||||||
if top_level not in self: print(f'{top_level} entry missing')
|
if top_level not in self: print(f'{top_level} entry missing')
|
||||||
|
|
||||||
if ok:
|
if ok:
|
||||||
ok &= len(self['microstructure']) > 0
|
ok &= len(self['material']) > 0
|
||||||
if len(self['microstructure']) < 1: print('Incomplete microstructure definition')
|
if len(self['material']) < 1: print('Incomplete material definition')
|
||||||
|
|
||||||
if ok:
|
if ok:
|
||||||
homogenization = set()
|
homogenization = set()
|
||||||
phase = set()
|
phase = set()
|
||||||
for i,v in enumerate(self['microstructure']):
|
for i,v in enumerate(self['material']):
|
||||||
if 'homogenization' in v:
|
if 'homogenization' in v:
|
||||||
homogenization.add(v['homogenization'])
|
homogenization.add(v['homogenization'])
|
||||||
else:
|
else:
|
||||||
print(f'No homogenization specified in microstructure {i}')
|
print(f'No homogenization specified in material {i}')
|
||||||
ok = False
|
ok = False
|
||||||
|
|
||||||
if 'constituents' in v:
|
if 'constituents' in v:
|
||||||
for ii,vv in enumerate(v['constituents']):
|
for ii,vv in enumerate(v['constituents']):
|
||||||
if 'orientation' not in vv:
|
if 'O' not in vv:
|
||||||
print('No orientation specified in constituent {ii} of microstructure {i}')
|
print('No orientation specified in constituent {ii} of material {i}')
|
||||||
ok = False
|
ok = False
|
||||||
if 'phase' in vv:
|
if 'phase' in vv:
|
||||||
phase.add(vv['phase'])
|
phase.add(vv['phase'])
|
||||||
else:
|
else:
|
||||||
print(f'No phase specified in constituent {ii} of microstructure {i}')
|
print(f'No phase specified in constituent {ii} of material {i}')
|
||||||
ok = False
|
ok = False
|
||||||
|
|
||||||
for k,v in self['phase'].items():
|
for k,v in self['phase'].items():
|
||||||
|
@ -92,42 +92,42 @@ class ConfigMaterial(Config):
|
||||||
print(f"Invalid lattice: '{s}' in phase '{k}'")
|
print(f"Invalid lattice: '{s}' in phase '{k}'")
|
||||||
ok = False
|
ok = False
|
||||||
|
|
||||||
if 'microstructure' in self:
|
if 'material' in self:
|
||||||
for i,v in enumerate(self['microstructure']):
|
for i,v in enumerate(self['material']):
|
||||||
if 'constituents' in v:
|
if 'constituents' in v:
|
||||||
f = 0.0
|
f = 0.0
|
||||||
for c in v['constituents']:
|
for c in v['constituents']:
|
||||||
f+= float(c['fraction'])
|
f+= float(c['fraction'])
|
||||||
if 'orientation' in c:
|
if 'O' in c:
|
||||||
try:
|
try:
|
||||||
Rotation.from_quaternion(c['orientation'])
|
Rotation.from_quaternion(c['O'])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
o = c['orientation']
|
o = c['O']
|
||||||
print(f"Invalid orientation: '{o}' in microstructure '{i}'")
|
print(f"Invalid orientation: '{o}' in material '{i}'")
|
||||||
ok = False
|
ok = False
|
||||||
if not np.isclose(f,1.0):
|
if not np.isclose(f,1.0):
|
||||||
print(f"Invalid total fraction '{f}' in microstructure '{i}'")
|
print(f"Invalid total fraction '{f}' in material '{i}'")
|
||||||
ok = False
|
ok = False
|
||||||
|
|
||||||
return ok
|
return ok
|
||||||
|
|
||||||
|
|
||||||
def microstructure_rename_phase(self,mapping,ID=None,constituent=None):
|
def material_rename_phase(self,mapping,ID=None,constituent=None):
|
||||||
"""
|
"""
|
||||||
Change phase name in microstructure.
|
Change phase name in material.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
mapping: dictionary
|
mapping: dictionary
|
||||||
Mapping from old name to new name
|
Mapping from old name to new name
|
||||||
ID: list of ints, optional
|
ID: list of ints, optional
|
||||||
Limit renaming to selected microstructure IDs.
|
Limit renaming to selected material IDs.
|
||||||
constituent: list of ints, optional
|
constituent: list of ints, optional
|
||||||
Limit renaming to selected constituents.
|
Limit renaming to selected constituents.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
dup = copy.deepcopy(self)
|
dup = copy.deepcopy(self)
|
||||||
for i,m in enumerate(dup['microstructure']):
|
for i,m in enumerate(dup['material']):
|
||||||
if ID and i not in ID: continue
|
if ID and i not in ID: continue
|
||||||
for c in m['constituents']:
|
for c in m['constituents']:
|
||||||
if constituent is not None and c not in constituent: continue
|
if constituent is not None and c not in constituent: continue
|
||||||
|
@ -138,9 +138,9 @@ class ConfigMaterial(Config):
|
||||||
return dup
|
return dup
|
||||||
|
|
||||||
|
|
||||||
def microstructure_rename_homogenization(self,mapping,ID=None):
|
def material_rename_homogenization(self,mapping,ID=None):
|
||||||
"""
|
"""
|
||||||
Change homogenization name in microstructure.
|
Change homogenization name in material.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
|
@ -151,7 +151,7 @@ class ConfigMaterial(Config):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
dup = copy.deepcopy(self)
|
dup = copy.deepcopy(self)
|
||||||
for i,m in enumerate(dup['microstructure']):
|
for i,m in enumerate(dup['material']):
|
||||||
if ID and i not in ID: continue
|
if ID and i not in ID: continue
|
||||||
try:
|
try:
|
||||||
m['homogenization'] = mapping[m['homogenization']]
|
m['homogenization'] = mapping[m['homogenization']]
|
||||||
|
|
Loading…
Reference in New Issue