From cdaddf8e6fc821646fe35a96009305a26645d0f6 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 7 Jan 2023 13:48:23 +0100 Subject: [PATCH] kwargs flexibility not needed the number of supported entries is rather limited, so guide the user using explicit arguments --- python/damask/_configmaterial.py | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/python/damask/_configmaterial.py b/python/damask/_configmaterial.py index 2c6ac4daa..5ee8ea73d 100644 --- a/python/damask/_configmaterial.py +++ b/python/damask/_configmaterial.py @@ -415,23 +415,39 @@ class ConfigMaterial(Config): return dup - def material_add(self, - **kwargs: Any) -> 'ConfigMaterial': + def material_add(self,*, + homogenization: Any = None, + phase: Any = None, + v: Any = None, + O: Any = None, + V_e: Any = None) -> 'ConfigMaterial': """ Add material entries. Parameters ---------- - **kwargs - Key-value pairs. - First index of array-like values runs over materials, - whereas second index runs over constituents. + homogenization: (array-like) of str, optional + Homogenization label. + phase: (array-like) of str, optional + Phase label (per constituent). + v: (array-like) of float, optional + Constituent volume fraction (per constituent). + O: (array-like) of damask.Rotation or np.array/list of shape(4), optional + Orientation as unit quaternion (per constituent). + V_e: (array-like) of np.array/list of shape(3,3), optional + Left elastic stretch (per constituent). Returns ------- updated : damask.ConfigMaterial Updated material configuration. + Notes + ----- + First index of array-like values that are defined per + consituent runs over materials, whereas second index runs + over constituents. + Examples -------- Create two grains of ferrite and one grain of martensite, each with random orientation: @@ -509,6 +525,10 @@ class ConfigMaterial(Config): phase: {Austenite: null, Ferrite: null} """ + kwargs = {} + for keyword,value in zip(['homogenization','phase','v','O','V_e'],[homogenization,phase,v,O,V_e]): + if value is not None: kwargs[keyword] = value + _constituent_properties = ['phase','O','v','V_e'] _dim = {'O':(4,),'V_e':(3,3,)} _ex = dict((k, -len(v)) for k, v in _dim.items())