From a98ae267a04f0ab3abf84edc76c8f0d6752ed8d6 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 24 Jul 2021 18:47:45 +0200 Subject: [PATCH 1/8] option to initialize F_i start simulation with eigenstrain. Works only for moderate eigentstrains, reaching the plastic limit is most likely an issue. --- src/material.f90 | 5 +++++ src/phase_mechanical.f90 | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/material.f90 b/src/material.f90 index 652cc30fb..4bf994987 100644 --- a/src/material.f90 +++ b/src/material.f90 @@ -26,6 +26,7 @@ module material type(tRotationContainer), dimension(:), allocatable :: material_O_0 + type(tTensorContainer), dimension(:), allocatable :: material_F_i_0 integer, dimension(:), allocatable, public, protected :: & homogenization_Nconstituents !< number of grains in each homogenization @@ -48,6 +49,7 @@ module material public :: & tTensorContainer, & tRotationContainer, & + material_F_i_0, & material_O_0, & material_init @@ -159,14 +161,17 @@ subroutine parse() enddo allocate(material_O_0(materials%length)) + allocate(material_F_i_0(materials%length)) do ma = 1, materials%length material => materials%get(ma) constituents => material%get('constituents') allocate(material_O_0(ma)%data(constituents%length)) + allocate(material_F_i_0(ma)%data(1:3,1:3,constituents%length)) do co = 1, constituents%length constituent => constituents%get(co) call material_O_0(ma)%data(co)%fromQuaternion(constituent%get_as1dFloat('O',requiredSize=4)) + material_F_i_0(ma)%data(1:3,1:3,co) = constituent%get_as2dFloat('F_i',defaultVal=math_I3) ! requiredShape=(3,3) enddo enddo diff --git a/src/phase_mechanical.f90 b/src/phase_mechanical.f90 index 006133258..c05d6210e 100644 --- a/src/phase_mechanical.f90 +++ b/src/phase_mechanical.f90 @@ -206,6 +206,9 @@ module subroutine mechanical_init(materials,phases) phases integer :: & + ce, & + co, & + ma, & ph, & en, & Nmembers @@ -262,15 +265,21 @@ module subroutine mechanical_init(materials,phases) #endif enddo + do ce = 1, size(material_phaseID,2) + ma = discretization_materialAt((ce-1)/discretization_nIPs+1) + do co = 1,homogenization_Nconstituents(material_homogenizationID(ce)) + ph = material_phaseID(co,ce) + phase_mechanical_Fi0(ph)%data(1:3,1:3,material_phaseEntry(co,ce)) = material_F_i_0(ma)%data(1:3,1:3,co) + enddo + enddo + do ph = 1, phases%length do en = 1, count(material_phaseID == ph) phase_mechanical_Fp0(ph)%data(1:3,1:3,en) = phase_O_0(ph)%data(en)%asMatrix() ! Fp reflects initial orientation (see 10.1016/j.actamat.2006.01.005) phase_mechanical_Fp0(ph)%data(1:3,1:3,en) = phase_mechanical_Fp0(ph)%data(1:3,1:3,en) & / math_det33(phase_mechanical_Fp0(ph)%data(1:3,1:3,en))**(1.0_pReal/3.0_pReal) - phase_mechanical_Fi0(ph)%data(1:3,1:3,en) = math_I3 - phase_mechanical_F0(ph)%data(1:3,1:3,en) = math_I3 - + phase_mechanical_F0(ph)%data(1:3,1:3,en) = math_I3 phase_mechanical_Fe(ph)%data(1:3,1:3,en) = math_inv33(matmul(phase_mechanical_Fi0(ph)%data(1:3,1:3,en), & phase_mechanical_Fp0(ph)%data(1:3,1:3,en))) ! assuming that euler angles are given in internal strain free configuration enddo From aa215ff81e9d4631e8e7e1515f553706a55114b5 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 24 Jul 2021 18:56:25 +0200 Subject: [PATCH 2/8] generalization, now used for F_i --- python/damask/_configmaterial.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python/damask/_configmaterial.py b/python/damask/_configmaterial.py index 375d3e2ce..be5d4c3eb 100644 --- a/python/damask/_configmaterial.py +++ b/python/damask/_configmaterial.py @@ -440,9 +440,10 @@ class ConfigMaterial(Config): """ N,n,shaped = 1,1,{} + dim_map = {'O':-1,'F_i':-2} for k,v in kwargs.items(): shaped[k] = np.array(v) - s = shaped[k].shape[:-1] if k=='O' else shaped[k].shape + s = shaped[k].shape[:dim_map.get(k,None)] N = max(N,s[0]) if len(s)>0 else N n = max(n,s[1]) if len(s)>1 else n @@ -451,8 +452,9 @@ class ConfigMaterial(Config): if 'v' not in kwargs: shaped['v'] = np.broadcast_to(1/n,(N,n)) + shape_map = {'O':(N,n,4),'F_i':(N,n,3,3)} for k,v in shaped.items(): - target = (N,n,4) if k=='O' else (N,n) + target = shape_map.get(k,(N,n)) obj = np.broadcast_to(v.reshape(util.shapeshifter(v.shape,target,mode='right')),target) for i in range(N): if k in ['phase','O','v']: From 5503592790669043efad07d32d644d2f10f75b88 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 5 Aug 2021 16:24:59 +0200 Subject: [PATCH 3/8] needs to be in constituents --- python/damask/_configmaterial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/damask/_configmaterial.py b/python/damask/_configmaterial.py index be5d4c3eb..1097df2d0 100644 --- a/python/damask/_configmaterial.py +++ b/python/damask/_configmaterial.py @@ -457,7 +457,7 @@ class ConfigMaterial(Config): target = shape_map.get(k,(N,n)) obj = np.broadcast_to(v.reshape(util.shapeshifter(v.shape,target,mode='right')),target) for i in range(N): - if k in ['phase','O','v']: + if k in ['phase','O','v','F_i']: for j in range(n): mat[i]['constituents'][j][k] = obj[i,j].item() if isinstance(obj[i,j],np.generic) else obj[i,j] else: From 5b4b1c1933812bcf750fad8a6db73008ba43fc61 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 5 Aug 2021 20:32:58 +0200 Subject: [PATCH 4/8] enforce correct shape --- src/material.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/material.f90 b/src/material.f90 index 4bf994987..2af1e47fb 100644 --- a/src/material.f90 +++ b/src/material.f90 @@ -171,7 +171,7 @@ subroutine parse() do co = 1, constituents%length constituent => constituents%get(co) call material_O_0(ma)%data(co)%fromQuaternion(constituent%get_as1dFloat('O',requiredSize=4)) - material_F_i_0(ma)%data(1:3,1:3,co) = constituent%get_as2dFloat('F_i',defaultVal=math_I3) ! requiredShape=(3,3) + material_F_i_0(ma)%data(1:3,1:3,co) = constituent%get_as2dFloat('F_i',defaultVal=math_I3,requiredShape=[3,3]) enddo enddo From 1038abd1a3f092ea84509ce868fde5110130de59 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 8 Nov 2021 18:50:00 +0100 Subject: [PATCH 5/8] testing initial eigenstrain --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index 5a769ec75..62be3aa39 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 5a769ec759d9dacc1866c35c6663cd0001e198c5 +Subproject commit 62be3aa392eb17cd553041996c6315e47ea3b83c From d751350bda57cf5ee57a735771e311bc051c12ab Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 14 Nov 2021 06:51:47 +0100 Subject: [PATCH 6/8] systematic naming --- python/damask/_configmaterial.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/damask/_configmaterial.py b/python/damask/_configmaterial.py index 1097df2d0..d1091aa76 100644 --- a/python/damask/_configmaterial.py +++ b/python/damask/_configmaterial.py @@ -440,10 +440,10 @@ class ConfigMaterial(Config): """ N,n,shaped = 1,1,{} - dim_map = {'O':-1,'F_i':-2} + map_dim = {'O':-1,'F_i':-2} for k,v in kwargs.items(): shaped[k] = np.array(v) - s = shaped[k].shape[:dim_map.get(k,None)] + s = shaped[k].shape[:map_dim.get(k,None)] N = max(N,s[0]) if len(s)>0 else N n = max(n,s[1]) if len(s)>1 else n @@ -452,9 +452,9 @@ class ConfigMaterial(Config): if 'v' not in kwargs: shaped['v'] = np.broadcast_to(1/n,(N,n)) - shape_map = {'O':(N,n,4),'F_i':(N,n,3,3)} + map_shape = {'O':(N,n,4),'F_i':(N,n,3,3)} for k,v in shaped.items(): - target = shape_map.get(k,(N,n)) + target = map_shape.get(k,(N,n)) obj = np.broadcast_to(v.reshape(util.shapeshifter(v.shape,target,mode='right')),target) for i in range(N): if k in ['phase','O','v','F_i']: From ec24af24038fca98cb9a0c32796568e447a67d4a Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 14 Nov 2021 11:45:13 +0100 Subject: [PATCH 7/8] testing new functionality --- python/tests/test_ConfigMaterial.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/tests/test_ConfigMaterial.py b/python/tests/test_ConfigMaterial.py index c968f429a..a713b636f 100644 --- a/python/tests/test_ConfigMaterial.py +++ b/python/tests/test_ConfigMaterial.py @@ -99,12 +99,15 @@ class TestConfigMaterial: @pytest.mark.parametrize('N,n,kw',[ (1,1,{'phase':'Gold', 'O':[1,0,0,0], + 'F_i':np.eye(3), 'homogenization':'SX'}), (3,1,{'phase':'Gold', 'O':Rotation.from_random(3), + 'F_i':np.broadcast_to(np.eye(3),(3,3,3)), 'homogenization':'SX'}), (2,3,{'phase':np.broadcast_to(['a','b','c'],(2,3)), 'O':Rotation.from_random((2,3)), + 'F_i':np.broadcast_to(np.eye(3),(2,3,3,3)), 'homogenization':['SX','PX']}), ]) def test_material_add(self,kw,N,n): From 2320b8166a5f85abae40a2407ac172f93406310a Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Mon, 15 Nov 2021 17:37:51 -0500 Subject: [PATCH 8/8] use polished init-eigenstrain test --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index 320c80237..ee4b1a03b 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 320c80237c3e0875e491eead9ae8a541ca82f458 +Subproject commit ee4b1a03b443a2c497a13c45c9498313442d731e