From 2c1bd1b3388a8a01781853d5d3c4f036648a079c Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Jacob <137695414+jbjacob94@users.noreply.github.com> Date: Mon, 11 Dec 2023 14:57:06 +0100 Subject: [PATCH 01/12] corrected mistakes in eps_sig_solve_NEW.py + updated invariant properties function - corrected a few mistakes and typos in function description - corrected a mistake in convert_tensors_to_vect - changed invariant_prop function to return von Mises stress / strain instead of octahedral shear stress / strain --- ImageD11/eps_sig_solver_NEW.py | 45 ++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/ImageD11/eps_sig_solver_NEW.py b/ImageD11/eps_sig_solver_NEW.py index 2837d9fc..f4ad377c 100644 --- a/ImageD11/eps_sig_solver_NEW.py +++ b/ImageD11/eps_sig_solver_NEW.py @@ -42,7 +42,7 @@ def __init__(self, Cij_symmetry (str) : symmetry considered for the Stiffness and Compliance matrices. Should be one of the following: 'cubic', 'trigonal_high', 'trigonal_low', 'tetragonal', 'hexagonal','orthorombic', 'monoclinic', 'triclinic' - dzero_unitcell (array_like) : Unstrained unit cell parameters [a, b, c, alpha,beta, gamma] + unitcell (array_like) : Unstrained unit cell parameters [a, b, c, alpha,beta, gamma] UBI_list (list of 3x3 arrays) : List of real-space unit cell vectors (ubi in ImageD11). """ @@ -208,8 +208,8 @@ def strain2stress_Lab(self, m=1, debug=0): """ Compute elastic strain and stress in Lab coordinates for all ubis, using the stiffness matrix in self.Cij. Computation is done first in the grain coordinate system, and then stress in lab coordinates is obtained by rotating the 3x3 stress tensor from the grain to the lab - coordinate system using the following transormation : σ' = UT.Cij.U where U is the rotation matrix yielded by the polar decomposition - of the finite deormation gradient tensor F. + coordinate system using the following transormation : σ' = RT.σ.R where R is the rotation matrix yielded by the polar decomposition + of the finite deformation gradient tensor F. Returns strain and stress as two lists of 3x3 symmetric tensors 'eps_Lab' and 'sigma_Lab'. @@ -274,7 +274,7 @@ def convert_tensors_to_vecs(self, output_format = 'voigt', debug=0): # select all strain and stress tensors list dnames = [attr for attr in dir(self) if any([attr.startswith(s) for s in ['eps','sigma']]) ] # filter out all data that begins with 'eps' or 'sigma' but are not strain or stress tensors - dnames = [d for d in dnames if any([d.endswith(s) for s in ['Lab','Ref','d']]) ] + dnames = [d for d in dnames if any([d.endswith(s) for s in ['Lab','Ref','_d']]) ] # stop if no strain / stress tensor list fond if len(dnames) == 0: @@ -329,36 +329,43 @@ def deviatoric_tensors(self, debug=0): def invariant_props(self, dname): + # NOTE : not sure about the expression of von Mises strain. In any case it is related to √J2 by a multiplication factor k, but it seems to be different from + # the definition of von Mises stress √(3.J2). see https://www.continuummechanics.org/vonmisesstress.html """ - compute invariant properties for selected data column + compute invariant properties for selected data column: volumetric strain / pressure (-I1/3) and von mises strain /stress (√3.J2) dname (str) : name of the input data column. Must be a non-deviatoric 3x3 tensors Returns ---------- New instances added to EpsSigSolver, containing list of floats + if strain tensor in input + dname+'_vol' : volumetric strain + dname+'_vM' : von Mises strain (√2.J2) + + if stress tensor in input: dname+'_P_hyd' : hydrostatic Pressure (if stress tensor in input) - dname+'_vol' : volumetric strain (if strain tensor in input) - dname+'_tau_oct' : octahedral shear strain /stress + dname+'_vM' : von Mises stress (√3.J2) """ assert dname in dir(self), 'dname not recognized' + assert '_d_' not in dname, 'tensor is deviatoric. Please use the non-deviatoric tensor' tensor_list = self.__getattribute__(dname) assert np.all([T.shape == (3,3) for T in tensor_list]) + + tensor_list_dev = [deviatoric(T) for T in tensors_list] + Invts = [invariants(T) for T in tensor_list] + Invts_dev = [invariants(T) for T in tensor_list_dev] - Invts = [invariants_quantities(T) for T in tensor_list] - Inv1 = [i[0] for i in Invts] - Inv2 = [i[1] for i in Invts] - - # tensor is already deviatoric : - assert '_d_' not in dname, 'tensor is deviatoric. Please use the non-deviatoric tensor' - + Inv1 = [-i[0]/3 for i in Invts] + Inv2 = [np.sqrt(3*i[1]) for i in Invts_dev] + if 'eps' in dname: setattr(self, dname+'_vol', Inv1) else: setattr(self, dname+'_P_hyd', Inv1) - setattr(self, dname+'_tau_oct', Inv2) + setattr(self, dname+'_vM', Inv2) @@ -476,7 +483,7 @@ def vector_to_full_3x3(vec, input_format='default', is_strain=True): def rotate_3x3_tensor(S, R, tol = 1e-6): - """Express 3x3 matrix in rotated coordinate system + """Return 3x3 matrix in rotated coordinate system Parameters ----------- @@ -498,7 +505,7 @@ def rotate_3x3_tensor(S, R, tol = 1e-6): def build_6x6_rot_mat(R, tol): """ - Return 6x6 transormation matrix corresponding to rotation R for a 6x6 stiffness / compliance tensor + Return 6x6 transormation matrix corresponding to rotation R for a Voigt 6x6 stiffness tensor Parameters ----------- @@ -590,14 +597,14 @@ def invariants_quantities(T): Returns -------- P (float) : -I1/3 : hydrostatic pressure / volumetric strain - τ_oct (float) : √(2*J2/3) : octahedral shear stress / strain + vM (float) : √(3*J2) : von Mises shear stress / strain """ T_dev = deviatoric(T) I1, I2, I3 = invariants(T) J1, J2, J3 = invariants(T_dev) - return -I1/3, np.sqrt(2*J2/3) + return -I1/3, np.sqrt(3*J2) From 279ebad6554c07015e60cd6e330f1a2dc7171ee6 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Jacob <137695414+jbjacob94@users.noreply.github.com> Date: Mon, 11 Dec 2023 15:18:33 +0100 Subject: [PATCH 02/12] Update eps_sig_solver_NEW.py --- ImageD11/eps_sig_solver_NEW.py | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/ImageD11/eps_sig_solver_NEW.py b/ImageD11/eps_sig_solver_NEW.py index f4ad377c..d6b9ed36 100644 --- a/ImageD11/eps_sig_solver_NEW.py +++ b/ImageD11/eps_sig_solver_NEW.py @@ -341,7 +341,7 @@ def invariant_props(self, dname): New instances added to EpsSigSolver, containing list of floats if strain tensor in input dname+'_vol' : volumetric strain - dname+'_vM' : von Mises strain (√2.J2) + dname+'_vM' : von Mises strain if stress tensor in input: dname+'_P_hyd' : hydrostatic Pressure (if stress tensor in input) @@ -590,25 +590,6 @@ def invariants(T): return I1, I2, I3 -def invariants_quantities(T): - """ - compute relevant invariant parameters of strain / stress tensor T - - Returns - -------- - P (float) : -I1/3 : hydrostatic pressure / volumetric strain - vM (float) : √(3*J2) : von Mises shear stress / strain - """ - - T_dev = deviatoric(T) - I1, I2, I3 = invariants(T) - J1, J2, J3 = invariants(T_dev) - - return -I1/3, np.sqrt(3*J2) - - - - # Cij_symmetry for stiffness tensor (copied from matscipy.elasticity : https://github.com/libAtoms/matscipy/blob/master/matscipy/elasticity.py) ######################## From a9d29f75fb51d345e37f852251469a2baaba3cd9 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Jacob <137695414+jbjacob94@users.noreply.github.com> Date: Mon, 11 Dec 2023 15:35:53 +0100 Subject: [PATCH 03/12] corrected typo in form_stiffness_tensor --- ImageD11/eps_sig_solver_NEW.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ImageD11/eps_sig_solver_NEW.py b/ImageD11/eps_sig_solver_NEW.py index d6b9ed36..f6345f56 100644 --- a/ImageD11/eps_sig_solver_NEW.py +++ b/ImageD11/eps_sig_solver_NEW.py @@ -47,7 +47,7 @@ def __init__(self, """ assert symmetry in ['cubic', 'trigonal_high','trigonal_low', 'tetragonal', - 'hexagonal','orthorombic', 'monoclinic', 'triclinic'], 'symmetry not recognized!' + 'hexagonal','orthorhombic', 'monoclinic', 'triclinic'], 'symmetry not recognized!' self.phase_name = name self.unitcell = unitcell From f5443f2e1a35a8290463306ed3f83ffc351368a6 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Jacob <137695414+jbjacob94@users.noreply.github.com> Date: Tue, 12 Dec 2023 09:26:24 +0100 Subject: [PATCH 04/12] updated Cij_symmetry --- ImageD11/eps_sig_solver_NEW.py | 83 ++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 33 deletions(-) diff --git a/ImageD11/eps_sig_solver_NEW.py b/ImageD11/eps_sig_solver_NEW.py index f6345f56..47041e7e 100644 --- a/ImageD11/eps_sig_solver_NEW.py +++ b/ImageD11/eps_sig_solver_NEW.py @@ -42,12 +42,11 @@ def __init__(self, Cij_symmetry (str) : symmetry considered for the Stiffness and Compliance matrices. Should be one of the following: 'cubic', 'trigonal_high', 'trigonal_low', 'tetragonal', 'hexagonal','orthorombic', 'monoclinic', 'triclinic' - unitcell (array_like) : Unstrained unit cell parameters [a, b, c, alpha,beta, gamma] + dzero_unitcell (array_like) : Unstrained unit cell parameters [a, b, c, alpha,beta, gamma] UBI_list (list of 3x3 arrays) : List of real-space unit cell vectors (ubi in ImageD11). """ - assert symmetry in ['cubic', 'trigonal_high','trigonal_low', 'tetragonal', - 'hexagonal','orthorhombic', 'monoclinic', 'triclinic'], 'symmetry not recognized!' + assert symmetry in Cij_symmetry.keys(), 'symmetry not recognized!' self.phase_name = name self.unitcell = unitcell @@ -80,7 +79,9 @@ def __init__(self, self.stress_unit = 'GPa' self.Cij_symmetry = Cij_symmetry[self.symmetry] self.Cij = self.form_stiffness_tensor() - self.Sij = np.linalg.inv(self.Cij) + + if np.trace(self.Cij) != 0: + self.Sij = np.linalg.inv(self.Cij) self.UBIs = UBI_list self.F_list = None @@ -146,6 +147,9 @@ def form_stiffness_tensor(self): v = self.parameterobj.parameters[parname] if v is None: continue + if self.symmetry in ['hexagonal','trigonal_high','trigonal_low'] and parname == 'c66': + v = 0.5 * (self.parameterobj.parameters['c11'] - self.parameterobj.parameters['c12']) + c_ij = np.where( np.abs(pattern) == i+1, np.sign(pattern) * v, 0 ) Cij += c_ij return Cij @@ -208,8 +212,8 @@ def strain2stress_Lab(self, m=1, debug=0): """ Compute elastic strain and stress in Lab coordinates for all ubis, using the stiffness matrix in self.Cij. Computation is done first in the grain coordinate system, and then stress in lab coordinates is obtained by rotating the 3x3 stress tensor from the grain to the lab - coordinate system using the following transormation : σ' = RT.σ.R where R is the rotation matrix yielded by the polar decomposition - of the finite deformation gradient tensor F. + coordinate system using the following transormation : σ' = UT.Cij.U where U is the rotation matrix yielded by the polar decomposition + of the finite deormation gradient tensor F. Returns strain and stress as two lists of 3x3 symmetric tensors 'eps_Lab' and 'sigma_Lab'. @@ -329,43 +333,36 @@ def deviatoric_tensors(self, debug=0): def invariant_props(self, dname): - # NOTE : not sure about the expression of von Mises strain. In any case it is related to √J2 by a multiplication factor k, but it seems to be different from - # the definition of von Mises stress √(3.J2). see https://www.continuummechanics.org/vonmisesstress.html """ - compute invariant properties for selected data column: volumetric strain / pressure (-I1/3) and von mises strain /stress (√3.J2) + compute invariant properties for selected data column dname (str) : name of the input data column. Must be a non-deviatoric 3x3 tensors Returns ---------- New instances added to EpsSigSolver, containing list of floats - if strain tensor in input - dname+'_vol' : volumetric strain - dname+'_vM' : von Mises strain - - if stress tensor in input: dname+'_P_hyd' : hydrostatic Pressure (if stress tensor in input) - dname+'_vM' : von Mises stress (√3.J2) + dname+'_vol' : volumetric strain (if strain tensor in input) + dname+'_tau_oct' : octahedral shear strain /stress """ assert dname in dir(self), 'dname not recognized' - assert '_d_' not in dname, 'tensor is deviatoric. Please use the non-deviatoric tensor' tensor_list = self.__getattribute__(dname) assert np.all([T.shape == (3,3) for T in tensor_list]) - - tensor_list_dev = [deviatoric(T) for T in tensors_list] - Invts = [invariants(T) for T in tensor_list] - Invts_dev = [invariants(T) for T in tensor_list_dev] - Inv1 = [-i[0]/3 for i in Invts] - Inv2 = [np.sqrt(3*i[1]) for i in Invts_dev] - + Invts = [invariants_quantities(T) for T in tensor_list] + Inv1 = [i[0] for i in Invts] + Inv2 = [i[1] for i in Invts] + + # tensor is already deviatoric : + assert '_d_' not in dname, 'tensor is deviatoric. Please use the non-deviatoric tensor' + if 'eps' in dname: setattr(self, dname+'_vol', Inv1) else: setattr(self, dname+'_P_hyd', Inv1) - setattr(self, dname+'_vM', Inv2) + setattr(self, dname+'_tau_oct', Inv2) @@ -483,7 +480,7 @@ def vector_to_full_3x3(vec, input_format='default', is_strain=True): def rotate_3x3_tensor(S, R, tol = 1e-6): - """Return 3x3 matrix in rotated coordinate system + """Express 3x3 matrix in rotated coordinate system Parameters ----------- @@ -505,7 +502,7 @@ def rotate_3x3_tensor(S, R, tol = 1e-6): def build_6x6_rot_mat(R, tol): """ - Return 6x6 transormation matrix corresponding to rotation R for a Voigt 6x6 stiffness tensor + Return 6x6 transormation matrix corresponding to rotation R for a 6x6 stiffness / compliance tensor Parameters ----------- @@ -590,8 +587,27 @@ def invariants(T): return I1, I2, I3 +def invariants_quantities(T): + """ + compute relevant invariant parameters of strain / stress tensor T + + Returns + -------- + P (float) : -I1/3 : hydrostatic pressure / volumetric strain + τ_oct (float) : √(2*J2/3) : octahedral shear stress / strain + """ + + T_dev = deviatoric(T) + I1, I2, I3 = invariants(T) + J1, J2, J3 = invariants(T_dev) + + return -I1/3, np.sqrt(2*J2/3) + + + + -# Cij_symmetry for stiffness tensor (copied from matscipy.elasticity : https://github.com/libAtoms/matscipy/blob/master/matscipy/elasticity.py) +# Cij_symmetry for stiffness tensor (from Mouhat & Coudert 2014) ######################## Cij_symmetry = { @@ -602,12 +618,12 @@ def invariants(T): [0, 0, 0, 0, 4, 0], [0, 0, 0, 0, 0, 4]]), - 'trigonal_high': np.array([[1, 7, 8, 9, 10, 0], - [7, 1, 8, 0,-9, 0], - [8, 8, 3, 0, 0, 0], + 'trigonal_high': np.array([[1, 7, 8, 9, 0, 0], + [7, 1, 8, -9, 0, 0], + [8, 8, 3, 0, 0, 0], [9, -9, 0, 4, 0, 0], - [10, 0, 0, 0, 4, 0], - [0, 0, 0, 0, 0, 6]]), + [0, 0, 0, 0, 4, 9], + [0, 0, 0, 0, 9, 6]]), 'trigonal_low': np.array([[1, 7, 8, 9, 10, 0 ], [7, 1, 8, -9, -10, 0 ], @@ -653,5 +669,6 @@ def invariants(T): } -Cij_symmetry['hexagonal'] = Cij_symmetry['trigonal_high'] +Cij_symmetry['hexagonal'] = Cij_symmetry['tetragonal_high'] +Cij_symmetry['tetragonal'] = Cij_symmetry['tetragonal_high'] Cij_symmetry[None] = Cij_symmetry['triclinic'] From d7273438e44ec0852beaef8b6e885af3f0568d68 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Jacob <137695414+jbjacob94@users.noreply.github.com> Date: Tue, 12 Dec 2023 09:55:40 +0100 Subject: [PATCH 05/12] Update eps_sig_solver_NEW.py --- ImageD11/eps_sig_solver_NEW.py | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/ImageD11/eps_sig_solver_NEW.py b/ImageD11/eps_sig_solver_NEW.py index 47041e7e..7ae64bde 100644 --- a/ImageD11/eps_sig_solver_NEW.py +++ b/ImageD11/eps_sig_solver_NEW.py @@ -40,9 +40,9 @@ def __init__(self, ----------- cij (float) : elastic constants of the crystal Cij_symmetry (str) : symmetry considered for the Stiffness and Compliance matrices. Should be one of the following: - 'cubic', 'trigonal_high', 'trigonal_low', 'tetragonal', 'hexagonal','orthorombic', 'monoclinic', 'triclinic' + 'cubic', 'trigonal_high', 'trigonal_low', 'tetragonal_high', 'tetragonal_low', 'hexagonal', 'orthorhombic', 'monoclinic', 'triclinic' - dzero_unitcell (array_like) : Unstrained unit cell parameters [a, b, c, alpha,beta, gamma] + unitcell (array_like) : Unstrained unit cell parameters [a, b, c, alpha,beta, gamma] UBI_list (list of 3x3 arrays) : List of real-space unit cell vectors (ubi in ImageD11). """ @@ -79,8 +79,7 @@ def __init__(self, self.stress_unit = 'GPa' self.Cij_symmetry = Cij_symmetry[self.symmetry] self.Cij = self.form_stiffness_tensor() - - if np.trace(self.Cij) != 0: + if not np.alltrue(self.Cij == 0): self.Sij = np.linalg.inv(self.Cij) self.UBIs = UBI_list @@ -139,7 +138,8 @@ def form_stiffness_tensor(self): Cij : 6x6 matrix containing the elastic components """ Cij = np.zeros((6,6)) - pattern = self.Cij_symmetry # pattern for the stiffness matrix + pattern = self.Cij_symmetry # pattern for the stiffness matrix. From Mouhat & Coudert (2014). Necessary and sufficient elastic stability conditions in various crystal systems. Physical Review + parlist = 'c11,c22,c33,c44,c55,c66,c12,c13,c14,c15,c16,c23,c24,c25,c26,c34,c35,c36,c45,c46,c56'.split(',') @@ -585,28 +585,7 @@ def invariants(T): I3 = np.linalg.det(T) return I1, I2, I3 - - -def invariants_quantities(T): - """ - compute relevant invariant parameters of strain / stress tensor T - - Returns - -------- - P (float) : -I1/3 : hydrostatic pressure / volumetric strain - τ_oct (float) : √(2*J2/3) : octahedral shear stress / strain - """ - - T_dev = deviatoric(T) - I1, I2, I3 = invariants(T) - J1, J2, J3 = invariants(T_dev) - return -I1/3, np.sqrt(2*J2/3) - - - - - # Cij_symmetry for stiffness tensor (from Mouhat & Coudert 2014) ######################## From f5c4dd81e04f484b2e723ae025f25015b383383d Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Jacob <137695414+jbjacob94@users.noreply.github.com> Date: Tue, 12 Dec 2023 10:43:45 +0100 Subject: [PATCH 06/12] Rename eps_sig_solver_NEW.py to stress.py --- ImageD11/{eps_sig_solver_NEW.py => stress.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ImageD11/{eps_sig_solver_NEW.py => stress.py} (100%) diff --git a/ImageD11/eps_sig_solver_NEW.py b/ImageD11/stress.py similarity index 100% rename from ImageD11/eps_sig_solver_NEW.py rename to ImageD11/stress.py From 89641ea415c7a2cd92ed1fa4c70ea778e4a7ce2b Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Jacob <137695414+jbjacob94@users.noreply.github.com> Date: Tue, 12 Dec 2023 10:45:33 +0100 Subject: [PATCH 07/12] Rename ImageD11/eps_sig_solver.py to ImageD11/depreciated/eps_sig_solver.py --- ImageD11/{ => depreciated}/eps_sig_solver.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ImageD11/{ => depreciated}/eps_sig_solver.py (100%) diff --git a/ImageD11/eps_sig_solver.py b/ImageD11/depreciated/eps_sig_solver.py similarity index 100% rename from ImageD11/eps_sig_solver.py rename to ImageD11/depreciated/eps_sig_solver.py From 74ebe0edf235b2a90cfa6d91deb2752f06303019 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Jacob <137695414+jbjacob94@users.noreply.github.com> Date: Tue, 12 Dec 2023 11:10:43 +0100 Subject: [PATCH 08/12] Update stress.py --- ImageD11/stress.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ImageD11/stress.py b/ImageD11/stress.py index 7ae64bde..8145a6c5 100644 --- a/ImageD11/stress.py +++ b/ImageD11/stress.py @@ -87,9 +87,9 @@ def __init__(self, - def __str__(self): - return f"EpsSigSolver:\n phase name: {self.phase_name}\n reference unitcell: {self.unitcell}\n symmetry:" +\ - f"{self.symmetry}\n unit:{self.stress_unit}\n Stiffness:\n {self.Cij}\n n ubis: {len(self.UBIs)}" + #def __str__(self): + # return f"EpsSigSolver:\n phase name: {self.phase_name}\n reference unitcell: {self.unitcell}\n symmetry:" +\ + # f"{self.symmetry}\n unit:{self.stress_unit}\n Stiffness:\n {self.Cij}\n n ubis: {len(self.UBIs)}" # Load / save / update functions for parameters (from former eps_sig_solver.py) ######################################## From 6e70510b3cd6ef955b9f3681c5da6409a961a46a Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Jacob <137695414+jbjacob94@users.noreply.github.com> Date: Tue, 12 Dec 2023 11:22:08 +0100 Subject: [PATCH 09/12] Update stress.py --- ImageD11/stress.py | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/ImageD11/stress.py b/ImageD11/stress.py index 8145a6c5..91b2e3f0 100644 --- a/ImageD11/stress.py +++ b/ImageD11/stress.py @@ -212,8 +212,8 @@ def strain2stress_Lab(self, m=1, debug=0): """ Compute elastic strain and stress in Lab coordinates for all ubis, using the stiffness matrix in self.Cij. Computation is done first in the grain coordinate system, and then stress in lab coordinates is obtained by rotating the 3x3 stress tensor from the grain to the lab - coordinate system using the following transormation : σ' = UT.Cij.U where U is the rotation matrix yielded by the polar decomposition - of the finite deormation gradient tensor F. + coordinate system using the following transormation : σ' = RT.σ.R where R is the rotation matrix yielded by the polar decomposition + of the finite deformation gradient tensor F. Returns strain and stress as two lists of 3x3 symmetric tensors 'eps_Lab' and 'sigma_Lab'. @@ -332,37 +332,43 @@ def deviatoric_tensors(self, debug=0): - def invariant_props(self, dname): + def invariant_props(self, dname): + # NOTE : not sure about the expression of von Mises strain. In any case it is related to √J2 by a multiplication factor k, but it seems to be different from + # the definition of von Mises stress √(3.J2). see https://www.continuummechanics.org/vonmisesstress.html """ compute invariant properties for selected data column + compute invariant properties for selected data column: volumetric strain / pressure (-I1/3) and von mises strain /stress (√3.J2) dname (str) : name of the input data column. Must be a non-deviatoric 3x3 tensors Returns ---------- New instances added to EpsSigSolver, containing list of floats + if strain tensor in input + dname+'_vol' : volumetric strain + dname+'_vM' : von Mises strain (√2.J2) + if stress tensor in input: dname+'_P_hyd' : hydrostatic Pressure (if stress tensor in input) - dname+'_vol' : volumetric strain (if strain tensor in input) - dname+'_tau_oct' : octahedral shear strain /stress + dname+'_vM' : von Mises stress (√3.J2) """ assert dname in dir(self), 'dname not recognized' - + assert '_d_' not in dname, 'tensor is deviatoric. Please use the non-deviatoric tensor' + tensor_list = self.__getattribute__(dname) assert np.all([T.shape == (3,3) for T in tensor_list]) - - Invts = [invariants_quantities(T) for T in tensor_list] - Inv1 = [i[0] for i in Invts] - Inv2 = [i[1] for i in Invts] - - # tensor is already deviatoric : - assert '_d_' not in dname, 'tensor is deviatoric. Please use the non-deviatoric tensor' - + + tensor_list_dev = [deviatoric(T) for T in tensors_list] + Invts = [invariants(T) for T in tensor_list] + Invts_dev = [invariants(T) for T in tensor_list_dev] + + Inv1 = [-i[0]/3 for i in Invts] + Inv2 = [np.sqrt(3*i[1]) for i in Invts_dev] + if 'eps' in dname: setattr(self, dname+'_vol', Inv1) else: setattr(self, dname+'_P_hyd', Inv1) - - setattr(self, dname+'_tau_oct', Inv2) + setattr(self, dname+'_vM', Inv2) @@ -480,7 +486,7 @@ def vector_to_full_3x3(vec, input_format='default', is_strain=True): def rotate_3x3_tensor(S, R, tol = 1e-6): - """Express 3x3 matrix in rotated coordinate system + """Return 3x3 matrix in rotated coordinate system Parameters ----------- @@ -502,7 +508,7 @@ def rotate_3x3_tensor(S, R, tol = 1e-6): def build_6x6_rot_mat(R, tol): """ - Return 6x6 transormation matrix corresponding to rotation R for a 6x6 stiffness / compliance tensor + Return 6x6 transormation matrix corresponding to rotation R for a Voigt 6x6 stiffness tensor Parameters ----------- @@ -585,6 +591,8 @@ def invariants(T): I3 = np.linalg.det(T) return I1, I2, I3 + + # Cij_symmetry for stiffness tensor (from Mouhat & Coudert 2014) ######################## From 167ec31afee9667648baccab10c1fd0137ee0aa8 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Jacob <137695414+jbjacob94@users.noreply.github.com> Date: Tue, 12 Dec 2023 11:26:59 +0100 Subject: [PATCH 10/12] Update stress.py --- ImageD11/stress.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ImageD11/stress.py b/ImageD11/stress.py index 91b2e3f0..1d351220 100644 --- a/ImageD11/stress.py +++ b/ImageD11/stress.py @@ -210,10 +210,11 @@ def strain2stress_Ref(self, m=1): def strain2stress_Lab(self, m=1, debug=0): """ - Compute elastic strain and stress in Lab coordinates for all ubis, using the stiffness matrix in self.Cij. Computation is done first in - the grain coordinate system, and then stress in lab coordinates is obtained by rotating the 3x3 stress tensor from the grain to the lab - coordinate system using the following transormation : σ' = RT.σ.R where R is the rotation matrix yielded by the polar decomposition - of the finite deformation gradient tensor F. + Compute elastic strain and stress in Lab coordinates for all ubis, using the stiffness matrix in self.Cij. + Computation is done first in the grain coordinate system, and then stress in lab coordinates is obtained by + rotating the 3x3 stress tensor from the grain to the lab coordinate system using the following transormation + σ' = RT.σ.R where R is the rotation matrix yielded by the polar decomposition of the finite deformation + gradient tensor F. Returns strain and stress as two lists of 3x3 symmetric tensors 'eps_Lab' and 'sigma_Lab'. @@ -332,9 +333,10 @@ def deviatoric_tensors(self, debug=0): - def invariant_props(self, dname): - # NOTE : not sure about the expression of von Mises strain. In any case it is related to √J2 by a multiplication factor k, but it seems to be different from - # the definition of von Mises stress √(3.J2). see https://www.continuummechanics.org/vonmisesstress.html + def invariant_props(self, dname): + # NOTE : not sure about the expression of von Mises strain. In any case it is related to √J2 by a multiplication factor k, + # but it seems to be different from the definition of von Mises stress √(3.J2). + # see https://www.continuummechanics.org/vonmisesstress.html """ compute invariant properties for selected data column compute invariant properties for selected data column: volumetric strain / pressure (-I1/3) and von mises strain /stress (√3.J2) From 40a6c82d428de03d96502adc85ffd0d01ebfaf53 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Jacob <137695414+jbjacob94@users.noreply.github.com> Date: Tue, 12 Dec 2023 11:32:29 +0100 Subject: [PATCH 11/12] Update stress.py --- ImageD11/stress.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ImageD11/stress.py b/ImageD11/stress.py index 1d351220..308ddd27 100644 --- a/ImageD11/stress.py +++ b/ImageD11/stress.py @@ -359,7 +359,7 @@ def invariant_props(self, dname): tensor_list = self.__getattribute__(dname) assert np.all([T.shape == (3,3) for T in tensor_list]) - tensor_list_dev = [deviatoric(T) for T in tensors_list] + tensor_list_dev = [deviatoric(T) for T in tensor_list] Invts = [invariants(T) for T in tensor_list] Invts_dev = [invariants(T) for T in tensor_list_dev] From 43097540f52cf48fced0e68b870346c50389432c Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Jacob <137695414+jbjacob94@users.noreply.github.com> Date: Tue, 12 Dec 2023 11:35:51 +0100 Subject: [PATCH 12/12] Update stress.py --- ImageD11/stress.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ImageD11/stress.py b/ImageD11/stress.py index 308ddd27..2f6d333f 100644 --- a/ImageD11/stress.py +++ b/ImageD11/stress.py @@ -87,9 +87,9 @@ def __init__(self, - #def __str__(self): - # return f"EpsSigSolver:\n phase name: {self.phase_name}\n reference unitcell: {self.unitcell}\n symmetry:" +\ - # f"{self.symmetry}\n unit:{self.stress_unit}\n Stiffness:\n {self.Cij}\n n ubis: {len(self.UBIs)}" + def __str__(self): + return f"EpsSigSolver:\n phase name: {self.phase_name}\n reference unitcell: {self.unitcell}\n symmetry:" +\ + f"{self.symmetry}\n unit:{self.stress_unit}\n Stiffness:\n {self.Cij}\n n ubis: {len(self.UBIs)}" # Load / save / update functions for parameters (from former eps_sig_solver.py) ########################################