preinitialize a ConfigMaterial object with 'constituents','homogenization','phase' keys
This commit is contained in:
parent
b030123980
commit
e11be7e600
|
@ -9,6 +9,13 @@ from . import Orientation
|
||||||
class ConfigMaterial(Config):
|
class ConfigMaterial(Config):
|
||||||
"""Material configuration."""
|
"""Material configuration."""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
"""Initialize object with all required dictionary keys."""
|
||||||
|
super().__init__()
|
||||||
|
self['material'] = []
|
||||||
|
self['homogenization'] = {}
|
||||||
|
self['phase'] = {}
|
||||||
|
|
||||||
def save(self,fname='material.yaml',**kwargs):
|
def save(self,fname='material.yaml',**kwargs):
|
||||||
"""
|
"""
|
||||||
Save to yaml file.
|
Save to yaml file.
|
||||||
|
@ -274,6 +281,7 @@ class ConfigMaterial(Config):
|
||||||
|
|
||||||
c = [{} for _ in range(length)] if constituents is None else \
|
c = [{} for _ in range(length)] if constituents is None else \
|
||||||
[{'constituents':u} for u in ConfigMaterial._constituents(**constituents)]
|
[{'constituents':u} for u in ConfigMaterial._constituents(**constituents)]
|
||||||
|
|
||||||
if len(c) == 1: c = [copy.deepcopy(c[0]) for _ in range(length)]
|
if len(c) == 1: c = [copy.deepcopy(c[0]) for _ in range(length)]
|
||||||
|
|
||||||
if length != 1 and length != len(c):
|
if length != 1 and length != len(c):
|
||||||
|
|
Loading…
Reference in New Issue