def Hessian(self,StrainTensors, ElectricFieldx=0, elem=0, gcounter=0): mu = self.mu lamb = self.lamb c1 = self.c1 c2 = self.c2 I = StrainTensors['I'] J = StrainTensors['J'][gcounter] b = StrainTensors['b'][gcounter] E = ElectricFieldx # print(E.shape, b.shape, np.dot(b,ElectricFieldx).shape) be = np.dot(b,ElectricFieldx).reshape(self.ndim) # Elasticity C = lamb*(2.*J-1.)*einsum("ij,kl",I,I) +(mu/J - lamb*(J-1))*( einsum("ik,jl",I,I)+einsum("il,jk",I,I) ) C_Voigt = Voigt(C,1) # Coupled Tensor (e - 3rd order) e_voigt = 2*c2/J*( einsum('ij,k',b,be) + einsum('i,jk',be,b) ) e_voigt = Voigt(e_voigt,1) # Dielectric Tensor (Permittivity - 2nd order) # Permittivity = -2./J*np.dot((c1*I+c2*b),b) Permittivity = 2./J*np.dot((c1*I+c2*b),b) factor = -1. H1 = np.concatenate((C_Voigt,factor*e_voigt),axis=1) H2 = np.concatenate((factor*e_voigt.T,Permittivity),axis=1) H_Voigt = np.concatenate((H1,H2),axis=0) self.H_VoigtSize = H_Voigt.shape[0] return H_Voigt
def Hessian(self, StrainTensors, ElectricFieldx=None, elem=0, gcounter=0): """Hessian split into isochoroic and volumetric parts""" I = StrainTensors['I'] b = StrainTensors['b'][gcounter] J = StrainTensors['J'][gcounter] mu = self.mu kappa = self.kappa # ISOCHORIC H_Voigt = 2*mu*J**(-5./3.)*(1./9.*trace(b)*einsum('ij,kl',I,I) - \ 1./3.*(einsum('ij,kl',b,I) + einsum('ij,kl',I,b)) +\ 1./6.*trace(b)*(einsum('ik,jl',I,I) + einsum('il,jk',I,I)) ) # VOLUMETRIC CHANGES if self.is_nearly_incompressible: H_Voigt += self.pressure * ( einsum('ij,kl', I, I) - (einsum('ik,jl', I, I) + einsum('il,jk', I, I))) else: H_Voigt += kappa * ( (2. * J - 1.) * einsum('ij,kl', I, I) - (J - 1.) * (einsum('ik,jl', I, I) + einsum('il,jk', I, I))) H_Voigt = Voigt(H_Voigt, 1) self.H_VoigtSize = H_Voigt.shape[0] return H_Voigt
def CauchyStress(self,StrainTensors,ElectricFieldx,elem=0,gcounter=0): strain = StrainTensors['strain'][gcounter] strain_Voigt = Voigt(strain) E = self.E E_A = self.E_A G_A = self.G_A v = self.nu H_Voigt = np.array([ [ -(E*(- E*v**2 + E_A))/((v + 1)*(2*E*v**2 + E_A*v - E_A)), -(E*v*(E_A + E*v))/((v + 1)*(2*E*v**2 + E_A*v - E_A)), -(E_A*E*v)/(2*E*v**2 + E_A*v - E_A), 0, 0, 0], [ -(E*v*(E_A + E*v))/((v + 1)*(2*E*v**2 + E_A*v - E_A)), -(E*(- E*v**2 + E_A))/((v + 1)*(2*E*v**2 + E_A*v - E_A)), -(E_A*E*v)/(2*E*v**2 + E_A*v - E_A), 0, 0, 0], [ -(E_A*E*v)/(2*E*v**2 + E_A*v - E_A), -(E_A*E*v)/(2*E*v**2 + E_A*v - E_A), (E_A**2*(v - 1))/(2*E*v**2 + E_A*v - E_A), 0, 0, 0], [ 0, 0, 0, E/(2*(v + 1)), 0, 0], [ 0, 0, 0, 0, G_A, 0], [ 0, 0, 0, 0, 0, G_A] ]) if self.ndim == 2: # CAREFUL WITH THIS SLICING AS SOME MATERIAL CONSTANTS WOULD BE REMOVED. # ESSENTIALLY IN PLANE STRAIN ANISOTROPY THE BEHAVIOUR OF MATERIAL # PERPENDICULAR TO THE PLANE IS LOST H_Voigt = H_Voigt[np.array([2,1,-1])[:,None],[2,1,-1]] stress = UnVoigt(np.dot(H_Voigt,strain_Voigt)) return stress
def Hessian(self, StrainTensors, ElectricFieldx=None, elem=0, gcounter=0): I = StrainTensors['I'] J = StrainTensors['J'][gcounter] b = StrainTensors['b'][gcounter] F = StrainTensors['F'][gcounter] C = np.dot(F.T, F) if np.isclose(J, 0) or J < 0: delta = np.sqrt(0.04 * J * J + 1e-8) J = 0.5 * (J + np.sqrt(J**2 + 4 * delta**2)) mu = self.mu lamb = self.lamb E = 0.5 * (C - I) C_Voigt = lamb * np.einsum("ij,kl", I, I) + mu * ( np.einsum("ik,jl", I, I) + np.einsum("il,jk", I, I)) C_Voigt = 1. / J * np.einsum("iI,jJ,kK,lL,IJKL", F, F, F, F, C_Voigt) # same here # C_Voigt = lamb/J * np.einsum("ij,kl",b,b) + mu/J * (np.einsum("ik,jl",b,b) + np.einsum("il,jk",b,b)) C_Voigt = Voigt(C_Voigt, 1) self.H_VoigtSize = C_Voigt.shape[0] return C_Voigt
def Hessian(self, StrainTensors, ElectricFieldx=0, elem=0, gcounter=0): mu1 = self.mu1 mu2 = self.mu2 mu3 = self.mu3 lamb = self.lamb I = StrainTensors['I'] J = StrainTensors['J'][gcounter] b = StrainTensors['b'][gcounter] F = StrainTensors['F'][gcounter] H = J * np.linalg.inv(F).T N = self.anisotropic_orientations[elem][:, None] HN = np.dot(H, N)[:, 0] innerHN = einsum('i,i', HN, HN) outerHN = einsum('i,j', HN, HN) H_Voigt = 2.*mu2/J* ( 2.0*einsum('ij,kl',b,b) - einsum('ik,jl',b,b) - einsum('il,jk',b,b) ) + \ 2.*(mu1+2.*mu2+mu3)/J * ( einsum('ik,jl',I,I) + einsum('il,jk',I,I) ) + \ lamb*(2.*J-1.)*einsum('ij,kl',I,I) - lamb*(J-1.) * ( einsum('ik,jl',I,I) + einsum('il,jk',I,I) ) - \ 4.*mu3/J * ( einsum('ij,kl',I,outerHN) + einsum('ij,kl',outerHN,I) ) + \ 2.*mu3/J*innerHN*(2.0*einsum('ij,kl',I,I) - einsum('ik,jl',I,I) - einsum('il,jk',I,I) ) + \ 2.*mu3/J * ( einsum('ik,jl',I,outerHN) + einsum('il,jk',I,outerHN) + \ einsum('ik,jl',outerHN,I) + einsum('il,jk',outerHN,I) ) # 2.*mu3/J * ( einsum('il,j,k',I,HN,HN) + einsum('jl,i,k',I,HN,HN) + \ # einsum('ik,j,l',I,HN,HN) + einsum('jk,i,l',I,HN,HN) ) H_Voigt = Voigt(H_Voigt, 1) return H_Voigt
def Hessian(self, StrainTensors, ElectricDisplacementx, elem=0, gcounter=0): d = self.ndim I = StrainTensors['I'] F = StrainTensors['F'][gcounter] J = StrainTensors['J'][gcounter] b = StrainTensors['b'][gcounter] if np.isclose(J, 0) or J < 0: delta = np.sqrt(0.04 * J * J + 1e-8) # J = 0.5 * (J + np.sqrt(J**2 + 4 *delta**2)) # J = 1. trb = trace(b) + 0 C_Voigt = 4./d * J**(-1) * einsum("ij,kl", (-1./d * trb * I + b), (-1./d) * J**(-2./d) * I ) +\ 4./d**2 * J**(-1) * J**(-2./d) * (-einsum("ij,kl", I, b) + 0.5 * trb * (einsum("ik,jl",I,I)+einsum("il,jk",I,I)) ) # factor = np.exp(1./d * J**(-2./d) * trb - 1.) # sigma = 2./d * J**(-2./d - 1.) * (-1./d * trb * I + b) # C_Voigt = factor * (np.einsum("ij,kl", sigma, sigma) + C_Voigt) C_Voigt = Voigt(C_Voigt, 1) # s = np.linalg.svd(C_Voigt)[1] # if np.any(s < 0): # print(s) return C_Voigt
def Hessian(self, StrainTensors, ElectricFieldx=0, elem=0, gcounter=0): lamb = self.lamb I = StrainTensors['I'] J = StrainTensors['J'][gcounter] b = StrainTensors['b'][gcounter] # Actual version # d = np.einsum # H_Voigt = Voigt( 4.0*beta/J*d('ij,kl',b,b) - 2.0*beta/J*( d('ik,jl',b,b) + d('il,jk',b,b) ) +\ # (lamb+4.0*beta+4.0*alpha/J)*d('ij,kl',I,I) + 2.0*(lamb*(J-1.0) -4.0*beta -2.0*alpha/J)*d('ij,kl',I,I) -\ # 1.0*(lamb*(J-1.0) -4.0*beta -2.0*alpha/J)*(d('ik,jl',I,I)+d('il,jk',I,I)) ,1) # # Simplified version # H_Voigt = 2.0*beta/J*( 2.0*einsum('ij,kl',b,b) - einsum('ik,jl',b,b) - einsum('il,jk',b,b) ) + \ # (lamb*(2.0*J-1.0) -4.0*beta)*einsum('ij,kl',I,I) - \ # (lamb*(J-1.0) -4.0*beta -2.0*alpha/J)*( einsum('ik,jl',I,I) + einsum('il,jk',I,I) ) # Further simplified version H_Voigt = 2.0*self.beta/J*( 2.0*einsum('ij,kl',b,b) - einsum('ik,jl',b,b) - einsum('il,jk',b,b) ) + \ (lamb*(2.0*J-1.0) -4.0*self.beta)*self.Iijkl - \ (lamb*(J-1.0) -4.0*self.beta -2.0*self.alpha/J)*self.Iikjl H_Voigt = Voigt(H_Voigt, 1) self.H_VoigtSize = H_Voigt.shape[0] return H_Voigt
def Hessian(self, StrainTensors, ElectricFieldx=None, elem=0, gcounter=0): I = StrainTensors['I'] J = StrainTensors['J'][gcounter] F = StrainTensors['F'][gcounter] b = StrainTensors['b'][gcounter] if np.isclose(J, 0) or J < 0: delta = np.sqrt(0.04 * J * J + 1e-8) else: delta = 1e-4 J = 0.5 * (J + np.sqrt(J**2 + 4 * delta**2)) # cr = J**2 mu = self.mu lamb = self.lamb C_Voigt = 2 * (lamb * (1. - 1./J) - mu / J) * self.d2CrdCdC(StrainTensors, gcounter) +\ (mu+lamb)/J**3 * J * np.einsum("ij,kl", self.dCrdC(StrainTensors, gcounter), self.dCrdC(StrainTensors, gcounter)) C_Voigt = Voigt(C_Voigt, 1) # print(C_Voigt) # exit() self.H_VoigtSize = C_Voigt.shape[0] return C_Voigt
def Hessian(self, StrainTensors, ElectricFieldx=0, elem=0, gcounter=0): """Hessian split into isochoroic and volumetric parts""" I = StrainTensors['I'] b = StrainTensors['b'][gcounter] J = StrainTensors['J'][gcounter] if np.isclose(J, 0) or J < 0: delta = np.sqrt(0.04 * J * J + 1e-8) # J = 0.5 * (J + np.sqrt(J**2 + 4 *delta**2)) mu = self.mu trb = trace(b) if self.ndim == 2: trb += 1. # ISOCHORIC H_Voigt = 2*mu*J**(-5./3.)*(1./9.*trb*einsum('ij,kl',I,I) - \ 1./3.*(einsum('ij,kl',b,I) + einsum('ij,kl',I,b)) +\ 1./6.*trb*(einsum('ik,jl',I,I) + einsum('il,jk',I,I)) ) # VOLUMETRIC # H_Voigt += self.pressure[elem]*(einsum('ij,kl',I,I) - (einsum('ik,jl',I,I) + einsum('il,jk',I,I))) H_Voigt += self.lamb * (2 * J - 1) * einsum( 'ij,kl', I, I) - self.lamb * (J - 1) * (einsum('ik,jl', I, I) + einsum('il,jk', I, I)) H_Voigt = Voigt(H_Voigt, 1) self.H_VoigtSize = H_Voigt.shape[0] return H_Voigt
def Hessian(self, StrainTensors, ElectricFieldx=0, elem=0, gcounter=0): # Get material constants (5 in this case) E = self.E E_A = self.E_A v = self.nu I = StrainTensors['I'] J = StrainTensors['J'][gcounter] b = StrainTensors['b'][gcounter] F = StrainTensors['F'][gcounter] H = J * np.linalg.inv(F).T N = self.anisotropic_orientations[elem][:, None] FN = np.dot(F, N)[:, 0] HN = np.dot(H, N)[:, 0] innerFN = einsum('i,i', FN, FN) innerHN = einsum('i,i', HN, HN) outerHN = einsum('i,j', HN, HN) gamma = self.gamma lamb = -(E_A * E * v) / (2. * E * v**2 + E_A * v - E_A) ut = (E**2 * v**2 + E_A * E * v**2 + E_A * E * v - E_A * E) / (2 * (v + 1) * (2 * E * v**2 + E_A * v - E_A)) beta = 0. eta_1 = (E_A**2 * v**2 - E_A**2 - 2 * E_A * E * v**2 + E_A * E + E**2 * v**2) / (4 * (gamma - 1) * (v + 1) * (2 * E * v**2 + E_A * v - E_A)) eta_2 = -(E_A**2 * v - E_A**2 + E_A * E - E_A * E * v) / ( 4 * (gamma - 1) * (2 * E * v**2 + E_A * v - E_A)) alpha = ut - 4 * gamma * beta - 2 * (1 - gamma) * eta_1 - 2 * ( 1 - gamma) * eta_2 alpha = alpha / 2. / gamma eta = [eta_1, eta_2] H_Voigt = 2.*gamma*beta/J* ( 2.0*einsum('ij,kl',b,b) - einsum('ik,jl',b,b) - einsum('il,jk',b,b) ) - \ (- lamb*(2.*J-1.) ) *einsum('ij,kl',I,I) + \ (ut - lamb*(J-1.) ) * ( einsum('ik,jl',I,I) + einsum('il,jk',I,I) ) for m in range(2, 4): H_Voigt += self.TransverseHessianNCN(StrainTensors, m, eta[m - 2], gamma, FN, innerFN, elem, gcounter) H_Voigt += self.TransverseHessianNGN(StrainTensors, 1., eta_1, gamma, HN, innerHN, elem, gcounter) H_Voigt += self.TransverseHessianNGN(StrainTensors, 1., eta_2, gamma, HN, innerHN, elem, gcounter) H_Voigt = Voigt(H_Voigt, 1) self.H_VoigtSize = H_Voigt.shape[0] return H_Voigt
def Hessian(self,StrainTensors,ElectricFieldx=0,elem=0,gcounter=0): mu1 = self.mu1 mu2 = self.mu2 lamb = self.lamb eps_1 = self.eps_1 I = StrainTensors['I'] J = StrainTensors['J'][gcounter] b = StrainTensors['b'][gcounter] E = ElectricFieldx.reshape(self.ndim,1) Ex = E.reshape(E.shape[0]) EE = np.dot(E,E.T) be = np.dot(b,ElectricFieldx).reshape(self.ndim,1) C_mech = 2.*mu2/J*(2*einsum('ij,kl',b,b) - einsum('ik,jl',b,b) - einsum('il,jk',b,b)) +\ 2.*(mu1+2.*mu2)/J*( einsum("ik,jl",I,I)+einsum("il,jk",I,I) ) + \ lamb*(2.*J-1.)*einsum("ij,kl",I,I) - lamb*(J-1)*( einsum("ik,jl",I,I)+einsum("il,jk",I,I) ) C_elect = -eps_1/J* (einsum("ik,j,l",I,Ex,Ex) + einsum("il,j,k",I,Ex,Ex) + einsum("i,k,jl",Ex,Ex,I) + einsum("i,l,jk",Ex,Ex,I)) C_Voigt = Voigt(C_mech + C_elect, 1) P_Voigt = eps_1/J*(einsum('ik,j',I,Ex)+einsum('i,jk',Ex,I)) P_Voigt = Voigt(P_Voigt,1) E_Voigt = -eps_1/J*I # Build the Hessian factor = -1. H1 = np.concatenate((C_Voigt,factor*P_Voigt),axis=1) H2 = np.concatenate((factor*P_Voigt.T,E_Voigt),axis=1) H_Voigt = np.concatenate((H1,H2),axis=0) self.H_VoigtSize = H_Voigt.shape[0] return H_Voigt
def Hessian(self, StrainTensors, ElectricFieldx=0, elem=0, gcounter=0): mu = self.mu lamb = self.lamb c1 = self.c1 c2 = self.c2 eps_1 = self.eps_1 I = StrainTensors['I'] J = StrainTensors['J'][gcounter] b = StrainTensors['b'][gcounter] E = 1.0 * ElectricFieldx.reshape(self.ndim, 1) Ex = E.reshape(E.shape[0]) EE = np.dot(E, E.T) be = np.dot(b, ElectricFieldx).reshape(self.ndim) C_Voigt = lamb/J*einsum('ij,kl',I,I) - (lamb*np.log(J) - mu)/J*( einsum('ik,jl',I,I) + einsum('il,jk',I,I) ) + \ eps_1*( einsum('ij,kl',I,EE) + einsum('ij,kl',EE,I) - einsum('ik,jl',EE,I) - einsum('il,jk',EE,I) - \ einsum('ik,jl',I,EE) - einsum('il,jk',I,EE) ) + \ eps_1*(np.dot(E.T,E)[0,0])*0.5*( einsum('ik,jl',I,I) + einsum('il,jk',I,I) - einsum('ij,kl',I,I) ) C_Voigt = Voigt(C_Voigt, 1) P_Voigt = eps_1*( einsum('ik,j',I,Ex) + einsum('jk,i',I,Ex) - einsum('ij,k',I,Ex)) +\ 2.0*c2/J*( einsum('ik,j',b,be) + einsum('i,jk',be,b) ) P_Voigt = Voigt(P_Voigt, 1) E_Voigt = -eps_1 * I + 2.0 * c1 / J * b + 2.0 * c2 / J * np.dot(b, b) # Build the Hessian factor = -1. H1 = np.concatenate((C_Voigt, factor * P_Voigt), axis=1) H2 = np.concatenate((factor * P_Voigt.T, E_Voigt), axis=1) H_Voigt = np.concatenate((H1, H2), axis=0) return H_Voigt
def Hessian(self, StrainTensors, ElectricFieldx=0, elem=0, gcounter=0): # CHECK IF FIBRE ORIENTATION IS SET if self.anisotropic_orientations is None: raise ValueError( "Fibre orientation for non-isotropic material is not available" ) # Get material constants (5 in this case) E = self.E E_A = self.E_A G_A = self.G_A v = self.nu mu = self.mu I = StrainTensors['I'] J = StrainTensors['J'][gcounter] b = StrainTensors['b'][gcounter] F = StrainTensors['F'][gcounter] H = J * np.linalg.inv(F).T N = self.anisotropic_orientations[elem, :, None] FN = np.dot(F, N)[:, 0] alpha = E / 8.0 / (1. + v) beta = E / 8.0 / (1. + v) eta_1 = 4. * alpha - G_A lamb = -(3 * E) / (2 * (v + 1)) - (E * (-E * v**2 + E_A)) / ( (v + 1) * (2 * E * v**2 + E_A * v - E_A)) eta_2 = E/(4*(v + 1)) - (E_A*E*v)/(4*(2*E*v**2 + E_A*v - E_A)) + \ (E*(- E*v**2 + E_A))/(4*(v + 1)*(2*E*v**2 + E_A*v - E_A)) gamma = (E_A**2*(v - 1))/(8*(2*E*v**2 + E_A*v - E_A)) - G_A/2 + \ (E_A*E*v)/(4*(2*E*v**2 + E_A*v - E_A)) - \ (E*(- E*v**2 + E_A))/(8*(v + 1)*(2*E*v**2 + E_A*v - E_A)) ut = 2 * alpha + 4 * beta H_Voigt = 2.*beta/J* ( 2.0*einsum('ij,kl',b,b) - einsum('ik,jl',b,b) - einsum('il,jk',b,b) ) + \ lamb*(2.*J-1.) *einsum('ij,kl',I,I) + \ (ut/J - lamb*(J-1.) ) * ( einsum('ik,jl',I,I) + einsum('il,jk',I,I) ) + \ 4.*eta_2/J*( einsum('ij,k,l',b,FN,FN) + einsum('i,j,kl',FN,FN,b) ) + \ 8.*gamma/J*( einsum('i,j,k,l',FN,FN,FN,FN) ) - \ eta_1/J*( einsum('jk,i,l',b,FN,FN) + einsum('ik,j,l',b,FN,FN) + einsum('jl,i,k',b,FN,FN) + einsum('il,j,k',b,FN,FN) ) H_Voigt = Voigt(H_Voigt, 1) self.H_VoigtSize = H_Voigt.shape[0] return H_Voigt
def Hessian(self, StrainTensors, ElectricFieldx=0, elem=0, gcounter=0): alpha = self.alpha beta = self.beta kappa = self.kappa I = StrainTensors['I'] J = StrainTensors['J'][gcounter] b = StrainTensors['b'][gcounter] F = StrainTensors['F'][gcounter] # b=np.dot(F,F.T) H = J * np.linalg.inv(F).T g = np.dot(H, H.T) if self.ndim == 2: trb = trace(b) + 1 trg = trace(g) + J**2 elif self.ndim == 3: trb = trace(b) trg = trace(g) H_Voigt = -4/3.*alpha*J**(-5/3.)*( einsum('ij,kl',b,I) + einsum('ij,kl',I,b) ) + \ 4.*alpha/9.*J**(-5/3.)*trb*einsum('ij,kl',I,I) + \ 2/3.*alpha*J**(-5/3.)*trb*( einsum('il,jk',I,I) + einsum('ik,jl',I,I) ) + \ beta*J**(-3)*trg**(3./2.)* ( einsum('ij,kl',I,I) - einsum('ik,jl',I,I) - einsum('il,jk',I,I) ) - \ 3.*beta*J**(-3)*trg**(1./2.)*( einsum('ij,kl',I,g) + einsum('ij,kl',g,I) ) + \ 6.*beta*J**(-3)*trg**(1./2.)*( einsum('ik,jl',I,g) + einsum('il,jk',g,I) ) + \ 3.*beta*J**(-3)*trg**(-1./2.)*( einsum('ij,kl',g,g) ) + \ kappa*(2.0*J-1)*einsum('ij,kl',I,I) - kappa*(J-1)*(einsum('ik,jl',I,I)+einsum('il,jk',I,I)) # # # # WITH PRE-COMPUTED IDENTITY TENSORS # H_Voigt = -4/3.*alpha*J**(-5/3.)*( einsum('ij,kl',b,I) + einsum('ij,kl',I,b) ) + \ # 4.*alpha/9.*J**(-5/3.)*trb*self.Iijkl + \ # 2/3.*alpha*J**(-5/3.)*trb*self.Iikjl + \ # beta*J**(-3)*trg**(3./2.)*( self.Iijkl - self.Iikjl ) - \ # 3.*beta*J**(-3)*trg**(1./2.)*( einsum('ij,kl',I,g) + einsum('ij,kl',g,I) ) + \ # 6.*beta*J**(-3)*trg**(1./2.)*( einsum('ik,jl',I,g) + einsum('il,jk',g,I) ) + \ # 3.*beta*J**(-3)*trg**(-1./2.)*( einsum('ij,kl',g,g) ) + \ # kappa*(2.0*J-1)*self.Iijkl - kappa*(J-1)*self.Iikjl H_Voigt = Voigt(H_Voigt, 1) self.H_VoigtSize = H_Voigt.shape[0] return H_Voigt
def Hessian(self,StrainTensors,ElectricFieldx,elem=0,gcounter=0): mu = self.mu lamb = self.lamb eta = self.eta I = StrainTensors['I'] self.elasticity_tensor = Voigt(lamb*einsum('ij,kl',I,I)+mu*(einsum('ik,jl',I,I)+einsum('il,jk',I,I)),1) self.gradient_elasticity_tensor = 2.*eta*I self.coupling_tensor0 = np.zeros((self.elasticity_tensor.shape[0],self.gradient_elasticity_tensor.shape[0])) # # BUILD HESSIAN # factor = 1. # H1 = np.concatenate((self.elasticity_tensor,factor*self.coupling_tensor0),axis=1) # H2 = np.concatenate((factor*self.coupling_tensor0.T,self.gradient_elasticity_tensor),axis=1) # H_Voigt = np.concatenate((H1,H2),axis=0) # return H_Voigt return None
def CauchyStress(self,StrainTensors,ElectricFieldx,elem=0,gcounter=0): strain = StrainTensors['strain'][gcounter] strain_Voigt = Voigt(strain) E = self.E E_A = self.E_A G_A = self.G_A v = self.nu H_Voigt = np.array([ [ -(E*(- E*v**2 + E_A))/((v + 1)*(2*E*v**2 + E_A*v - E_A)), -(E*v*(E_A + E*v))/((v + 1)*(2*E*v**2 + E_A*v - E_A)), -(E_A*E*v)/(2*E*v**2 + E_A*v - E_A), 0, 0, 0], [ -(E*v*(E_A + E*v))/((v + 1)*(2*E*v**2 + E_A*v - E_A)), -(E*(- E*v**2 + E_A))/((v + 1)*(2*E*v**2 + E_A*v - E_A)), -(E_A*E*v)/(2*E*v**2 + E_A*v - E_A), 0, 0, 0], [ -(E_A*E*v)/(2*E*v**2 + E_A*v - E_A), -(E_A*E*v)/(2*E*v**2 + E_A*v - E_A), (E_A**2*(v - 1))/(2*E*v**2 + E_A*v - E_A), 0, 0, 0], [ 0, 0, 0, E/(2*(v + 1)), 0, 0], [ 0, 0, 0, 0, G_A, 0], [ 0, 0, 0, 0, 0, G_A] ]) if self.ndim == 2:
def Hessian(self, StrainTensors, ElectricFieldx=0, elem=0, gcounter=0): """Hessian split into isochoroic and volumetric parts""" I = StrainTensors['I'] b = StrainTensors['b'][gcounter] J = StrainTensors['J'][gcounter] mu = self.mu # ISOCHORIC H_Voigt = 2*mu*J**(-5./3.)*(1./9.*trace(b)*einsum('ij,kl',I,I) - \ 1./3.*(einsum('ij,kl',b,I) + einsum('ij,kl',I,b)) +\ 1./6.*trace(b)*(einsum('ik,jl',I,I) + einsum('il,jk',I,I)) ) # VOLUMETRIC H_Voigt += self.pressure[elem]*(einsum('ij,kl',I,I) - (einsum('ik,jl',I,I) + einsum('il,jk',I,I))) H_Voigt = Voigt(H_Voigt,1) self.H_VoigtSize = H_Voigt.shape[0] return H_Voigt
def Hessian(self, StrainTensors, ElectricFieldx=0, elem=0, gcounter=0): mu = self.mu lamb = self.lamb I = StrainTensors['I'] J = StrainTensors['J'][gcounter] b = StrainTensors['b'][gcounter] F = StrainTensors['F'][gcounter] H = J * np.linalg.inv(F).T N = self.anisotropic_orientations[elem][:, None] FN = np.dot(F, N)[:, 0] HN = np.dot(H, N)[:, 0] innerHN = einsum('i,i', HN, HN) outerHN = einsum('i,j', HN, HN) # FIX GAMMA gamma = 0.5 # gamma = 1.0 alpha = mu / 2. / gamma beta = mu / 2. / gamma eta = mu / 3. ut = 2. * gamma * (alpha + 2.0 * beta) + 2. * (1. - gamma) * eta lamb = lamb + 2. * gamma * alpha - 2 * (1. - gamma) * eta H_Voigt = 2.*gamma*beta/J* ( 2.0*einsum('ij,kl',b,b) - einsum('ik,jl',b,b) - einsum('il,jk',b,b) ) + \ 4.*(1-gamma)*eta/J * einsum('i,j,k,l',FN,FN,FN,FN) + \ 4.*(1-gamma)*eta/J * ( innerHN * einsum('ij,kl',I,I) - \ 0.5*innerHN * ( einsum('ik,jl',I,I) + einsum('il,jk',I,I) ) - \ einsum('ij,k,l',I,HN,HN) - einsum('i,j,kl',HN,HN,I) ) + \ 2.*(1-gamma)*eta/J * ( einsum('il,j,k',I,HN,HN) + einsum('jl,i,k',I,HN,HN) + \ einsum('ik,j,l',I,HN,HN) + einsum('jk,i,l',I,HN,HN) ) - \ ut*einsum('ij,kl',I,I) + ut * ( einsum('ik,jl',I,I) + einsum('il,jk',I,I) ) + \ lamb*(2.*J-1.)*einsum('ij,kl',I,I) - lamb*(J-1.) * ( einsum('ik,jl',I,I) + einsum('il,jk',I,I) ) H_Voigt = Voigt(H_Voigt, 1) self.H_VoigtSize = H_Voigt.shape[0] return H_Voigt
def Hessian(self, StrainTensors, ElectricDisplacementx, elem=0, gcounter=0): mu1 = self.mu1 mu2 = self.mu2 lamb = self.lamb I = StrainTensors['I'] J = StrainTensors['J'][gcounter] b = StrainTensors['b'][gcounter] C_Voigt = 2.*mu2/J*(2*einsum('ij,kl',b,b) - einsum('ik,jl',b,b) - einsum('il,jk',b,b)) +\ 2.*(mu1+2.*mu2)/J*( einsum("ik,jl",I,I)+einsum("il,jk",I,I) ) + \ lamb*(2.*J-1.)*einsum("ij,kl",I,I) - lamb*(J-1)*( einsum("ik,jl",I,I)+einsum("il,jk",I,I) ) C_Voigt = Voigt(C_Voigt, 1) return C_Voigt
def Hessian(self,StrainTensors,ElectricFieldx=None,elem=0,gcounter=0): kappa = self.kappa mu = self.mu k1 = self.k1 k2 = self.k2 I = StrainTensors['I'] J = StrainTensors['J'][gcounter] b = StrainTensors['b'][gcounter] F = StrainTensors['F'][gcounter] if self.ndim == 3: trb = trace(b) elif self.ndim == 2: trb = trace(b) + 1 H_Voigt = 2.*mu*J**(-5./3.) * (1./9.*trb*einsum('ij,kl',I,I) - \ 1./3.*einsum('ij,kl',I,b) - 1./3.*einsum('ij,kl',b,I) + \ 1./6.*trb*(einsum('il,jk',I,I) + einsum('ik,jl',I,I)) ) if self.is_nearly_incompressible: H_Voigt += self.pressure*(einsum('ij,kl',I,I) - (einsum('ik,jl',I,I) + einsum('il,jk',I,I))) else: H_Voigt += kappa*((2.*J-1.)*einsum('ij,kl',I,I) - (J-1.)*(einsum('ik,jl',I,I) + einsum('il,jk',I,I))) # Anisotropic contibution nfibres = self.anisotropic_orientations.shape[1] for i_fibre in range(nfibres): N = self.anisotropic_orientations[elem,i_fibre,:,None] FN = np.dot(F,N)[:,0] innerFN = einsum('i,i',FN,FN) outerFN = einsum('i,j',FN,FN) expo = np.exp(k2*(innerFN-1.)**2) H_Voigt += 4.*k1/J*(1.+2.*k2*(innerFN-1.)**2)*expo*einsum('ij,kl',outerFN,outerFN) H_Voigt = Voigt(H_Voigt ,1) return H_Voigt
def Hessian(self, StrainTensors, ElectricFieldx=None, elem=0, gcounter=0): I = StrainTensors['I'] J = StrainTensors['J'][gcounter] # Jb = 1.27168554933 Jb = self.Jbar[elem] mu2 = self.mu / J - self.lamb * (J - Jb) lamb2 = self.lamb * (2 * J - Jb) H_Voigt_n = lamb2 * self.vIijIkl + mu2 * self.vIikIjl # return H_Voigt H_Voigt_l = Voigt( self.lamb * einsum('ij,kl', I, I) + self.mu * (einsum('ik,jl', I, I) + einsum('il,jk', I, I)), 1) alp = 0.1 # H_Voigt = (1-alp)*H_Voigt_l + alp*H_Voigt_n H_Voigt = H_Voigt_n # return H_Voigt_l + H_Voigt_n return H_Voigt
def Hessian(self,StrainTensors,ElectricFieldx,elem=0,gcounter=0): mu = self.mu lamb = self.lamb eta = self.eta eps = self.eps I = StrainTensors['I'] self.elasticity_tensor = Voigt(lamb*einsum('ij,kl',I,I)+mu*(einsum('ik,jl',I,I)+einsum('il,jk',I,I)),1) self.gradient_elasticity_tensor = 2.*eta*I self.coupling_tensor0 = np.zeros((self.elasticity_tensor.shape[0],self.gradient_elasticity_tensor.shape[0])) # Piezoelectric tensor must be 6x3 [3D] or 3x2 [2D] self.piezoelectric_tensor = self.P # Dielectric tensor self.dielectric_tensor = -self.eps*I # # BUILD HESSIAN factor = -1. H1 = np.concatenate((self.elasticity_tensor,factor*self.piezoelectric_tensor),axis=1) H2 = np.concatenate((factor*self.piezoelectric_tensor.T,self.dielectric_tensor),axis=1) H_Voigt = np.concatenate((H1,H2),axis=0) return H_Voigt
def Hessian(self, StrainTensors, ElectricFieldx=None, elem=0, gcounter=0): I = StrainTensors['I'] J = StrainTensors['J'][gcounter] F = StrainTensors['F'][gcounter] b = StrainTensors['b'][gcounter] if np.isclose(J, 0) or J < 0: delta = np.sqrt(0.04 * J * J + 1e-8) # J = 0.5 * (J + np.sqrt(J**2 + 4 *delta**2)) mu = self.mu lamb = self.lamb alpha = self.alpha C_Voigt = (lamb * (2 * J - alpha) - mu) * np.einsum( "ij,kl", I, I) + (mu - lamb * (J - alpha)) * (np.einsum("ik,jl", I, I) + np.einsum("il,jk", I, I)) C_Voigt = Voigt(C_Voigt, 1) self.H_VoigtSize = C_Voigt.shape[0] return C_Voigt
def Hessian(self, StrainTensors, ElectricDisplacementx, elem=0, gcounter=0): mu = self.mu mu1 = self.mu1 mu2 = self.mu2 lamb = self.lamb d = self.ndim I = StrainTensors['I'] F = StrainTensors['F'][gcounter] J = StrainTensors['J'][gcounter] b = StrainTensors['b'][gcounter] trb = trace(b) + 0 C_Voigt0 = 4./d * J**(-1) * einsum("ij,kl", (-1./d * trb * I + b), (-1./d) * J**(-2./d) * I ) +\ 4./d**2 * J**(-1) * J**(-2./d) * (-einsum("ij,kl", I, b) + 0.5 * trb * (einsum("ik,jl",I,I)+einsum("il,jk",I,I)) ) C_Voigt0 *= (1. / d * J**(-2 / d) * trb - 1) sigma = 2. / d * J**(-2. / d - 1.) * (-1. / d * trb * I + b) C_Voigt1 = einsum("ij,kl", sigma, sigma) C_Voigt = C_Voigt0 + C_Voigt1 # C_Voigt = C_Voigt0 C_Voigt = mu * C_Voigt C_Voigt += 2.*mu2/J*(2*einsum('ij,kl',b,b) - einsum('ik,jl',b,b) - einsum('il,jk',b,b)) +\ 2.*(mu1+2.*mu2)/J*( einsum("ik,jl",I,I)+einsum("il,jk",I,I) ) + \ lamb*(2.*J-1.)*einsum("ij,kl",I,I) - lamb*(J-1)*( einsum("ik,jl",I,I)+einsum("il,jk",I,I) ) C_Voigt = Voigt(C_Voigt, 1) return C_Voigt
eta = mu/3. ut = 2.*gamma*(alpha+2.0*beta) + 2.*(1. - gamma)*eta lamb = lamb + 2.*gamma*alpha - 2*(1.- gamma)*eta H_Voigt = 2.*gamma*beta/J* ( 2.0*einsum('ij,kl',b,b) - einsum('ik,jl',b,b) - einsum('il,jk',b,b) ) + \ 4.*(1-gamma)*eta/J * einsum('i,j,k,l',FN,FN,FN,FN) + \ 4.*(1-gamma)*eta/J * ( innerHN * einsum('ij,kl',I,I) - \ 0.5*innerHN * ( einsum('ik,jl',I,I) + einsum('il,jk',I,I) ) - \ einsum('ij,k,l',I,HN,HN) - einsum('i,j,kl',HN,HN,I) ) + \ 2.*(1-gamma)*eta/J * ( einsum('il,j,k',I,HN,HN) + einsum('jl,i,k',I,HN,HN) + \ einsum('ik,j,l',I,HN,HN) + einsum('jk,i,l',I,HN,HN) ) - \ ut*einsum('ij,kl',I,I) + ut * ( einsum('ik,jl',I,I) + einsum('il,jk',I,I) ) + \ lamb*(2.*J-1.)*einsum('ij,kl',I,I) - lamb*(J-1.) * ( einsum('ik,jl',I,I) + einsum('il,jk',I,I) ) H_Voigt = Voigt(H_Voigt ,1) <<<<<<< HEAD ======= >>>>>>> upstream/master self.H_VoigtSize = H_Voigt.shape[0] return H_Voigt def CauchyStress(self,StrainTensors,ElectricFieldx,elem=0,gcounter=0): I = StrainTensors['I'] J = StrainTensors['J'][gcounter]
J = StrainTensors['J'][gcounter] # Jb = 1.27168554933 Jb = self.Jbar[elem] mu2 = self.mu/J- self.lamb*(J-Jb) <<<<<<< HEAD lamb2 = self.lamb*(2*J-Jb) ======= lamb2 = self.lamb*(2*J-Jb) >>>>>>> upstream/master H_Voigt_n = lamb2*self.vIijIkl+mu2*self.vIikIjl # return H_Voigt H_Voigt_l = Voigt(self.lamb*einsum('ij,kl',I,I)+self.mu*(einsum('ik,jl',I,I)+einsum('il,jk',I,I)) ,1) <<<<<<< HEAD ======= >>>>>>> upstream/master alp = 0.1 # H_Voigt = (1-alp)*H_Voigt_l + alp*H_Voigt_n H_Voigt = H_Voigt_n # return H_Voigt_l + H_Voigt_n return H_Voigt def CauchyStress(self,StrainTensors,ElectricFieldx=None,elem=0,gcounter=0): I = StrainTensors['I'] J = StrainTensors['J'][gcounter]
def __checkdata__(self, material, boundary_condition, formulation, mesh, function_spaces, solver, contact_formulation=None): ## IMPORTANT self.requires_geometry_update = False self.analysis_nature = "linear" function_spaces, solver = super(CoupleStressSolver,self).__checkdata__(material, boundary_condition, formulation, mesh, function_spaces, solver, contact_formulation=contact_formulation) # BUILD THE TANGENT OPERATORS BEFORE HAND if material.mtype == "CoupleStressModel": I = np.eye(material.ndim,material.ndim) material.elasticity_tensor = Voigt(material.lamb*np.einsum('ij,kl',I,I)+material.mu*(np.einsum('ik,jl',I,I)+np.einsum('il,jk',I,I)),1) material.gradient_elasticity_tensor = 2.*material.eta*I material.coupling_tensor0 = np.zeros((material.elasticity_tensor.shape[0], material.gradient_elasticity_tensor.shape[0])) # print material.elasticity_tensor ngauss = function_spaces[0].AllGauss.shape[0] d0 = material.elasticity_tensor.shape[0] d1 = material.elasticity_tensor.shape[1] d2 = material.gradient_elasticity_tensor.shape[0] d3 = material.gradient_elasticity_tensor.shape[1] material.elasticity_tensors = np.tile(material.elasticity_tensor.ravel(),ngauss).reshape(ngauss,d0,d1) material.gradient_elasticity_tensors = np.tile(material.gradient_elasticity_tensor.ravel(),ngauss).reshape(ngauss,d2,d3) elif material.mtype == "IsotropicLinearFlexoelectricModel": I = np.eye(material.ndim,material.ndim) material.elasticity_tensor = Voigt(material.lamb*np.einsum('ij,kl',I,I)+material.mu*(np.einsum('ik,jl',I,I)+np.einsum('il,jk',I,I)),1) material.gradient_elasticity_tensor = 2.*material.eta*I material.coupling_tensor0 = np.zeros((material.elasticity_tensor.shape[0], material.gradient_elasticity_tensor.shape[0])) material.piezoelectric_tensor = material.P material.flexoelectric_tensor = material.f material.dielectric_tensor = -material.eps*np.eye(material.ndim,material.ndim) # print material.elasticity_tensor ngauss = function_spaces[0].AllGauss.shape[0] d0 = material.elasticity_tensor.shape[0] d1 = material.elasticity_tensor.shape[1] d2 = material.gradient_elasticity_tensor.shape[0] d3 = material.gradient_elasticity_tensor.shape[1] material.elasticity_tensors = np.tile(material.elasticity_tensor.ravel(),ngauss).reshape(ngauss,d0,d1) material.gradient_elasticity_tensors = np.tile(material.gradient_elasticity_tensor.ravel(),ngauss).reshape(ngauss,d2,d3) material.piezoelectric_tensors = np.tile(material.P.ravel(),ngauss).reshape(ngauss,material.P.shape[0],material.P.shape[1]) material.flexoelectric_tensors = np.tile(material.f.ravel(),ngauss).reshape(ngauss,material.f.shape[0],material.f.shape[1]) material.dielectric_tensors = np.tile(material.dielectric_tensor.ravel(),ngauss).reshape(ngauss,material.ndim,material.ndim) factor = -1. material.H_Voigt = np.zeros((ngauss,material.H_VoigtSize,material.H_VoigtSize)) for i in range(ngauss): H1 = np.concatenate((material.elasticity_tensor,factor*material.piezoelectric_tensor),axis=1) H2 = np.concatenate((factor*material.piezoelectric_tensor.T,material.dielectric_tensor),axis=1) H_Voigt = np.concatenate((H1,H2),axis=0) material.H_Voigt[i,:,:] = H_Voigt return function_spaces, solver
def Hessian(self, StrainTensors, ElectricFieldx=0, elem=0, gcounter=0): mu = self.mu lamb = self.lamb varepsilon_1 = self.eps_1 detF = StrainTensors['J'][gcounter] mu2 = mu - lamb * (detF - 1.0) lamb2 = lamb * (2.0 * detF - 1.0) - mu delta = StrainTensors['I'] E = 1.0 * ElectricFieldx Ex = E.reshape(E.shape[0]) EE = np.outer(E, E) innerEE = np.dot(E, E.T) I = delta # C = lamb2*AijBkl(I,I) +mu2*(AikBjl(I,I)+AilBjk(I,I)) + varepsilon_1*(AijBkl(I,EE) + AijBkl(EE,I) - \ # 2.*AikBjl(EE,I)-2.0*AilBjk(I,EE) ) + varepsilon_1*(np.dot(E.T,E)[0,0])*(AikBjl(I,I)-0.5*AijBkl(I,I)) # ORIGINAL # C = lamb2*AijBkl(I,I) +mu2*(AikBjl(I,I)+AilBjk(I,I)) +\ # varepsilon_1*(AijBkl(I,EE) + AijBkl(EE,I) -AikBjl(EE,I)-AilBjk(EE,I)-AilBjk(I,EE)-AikBjl(I,EE) ) +\ # varepsilon_1*(np.dot(E.T,E)[0,0])*(0.5*(AikBjl(I,I) + AilBjk(I,I))-0.5*AijBkl(I,I)) # C=0.5*(C+C.T) # C_Voigt = C C = lamb2*einsum("ij,kl",I,I) +mu2*(einsum("ik,jl",I,I)+einsum("il,jk",I,I)) +\ varepsilon_1*(einsum("ij,kl",I,EE) + einsum("ij,kl",EE,I) - einsum("ik,jl",EE,I)- einsum("il,jk",I,EE) -\ einsum("il,jl",I,EE)- einsum("ik,jl",I,EE) ) +\ varepsilon_1*(innerEE)*(0.5*( einsum("ik,jl",I,I)+einsum("il,jk",I,I) )-0.5* einsum("ij,kl",I,I) ) C_Voigt = Voigt(C, 1) # Computing the hessian # Elasticity tensor (C - 4th order tensor) # C[i,j,k,l] += lamb2*delta[i,j]*delta[k,l]+2.0*mu2*(delta[i,k]*delta[j,l]) # b = StrainTensors['b'][gcounter] be = np.dot(b, ElectricFieldx).reshape(self.ndim, 1) # Coupled Tensor (e - 3rd order) # e[k,i,j] += (-2.0*varepsilon_1/detF)*(be[j]*b[i,k] + be[i]*b[j,k]) # # e[i,j,k] += 1.0*varepsilon_1*( E[i]*delta[j,k] + E[j]*delta[i,k] - delta[i,j]*E[k]) ## # e[k,i,j] += 1.0*varepsilon_1*(E[i]*delta[j,k] + E[j]*delta[i,k] - delta[i,j]*E[k]) ## # Note that the actual piezoelectric tensor is symmetric wrt to the last two indices # Actual tensor is: e[k,i,j] += 1.0*varepsilon_1*(E[i]*delta[j,k] + E[j]*delta[i,k] - delta[i,j]*E[k]) # We need to make its Voigt_form symmetric with respect to (j,k) instead of (i,j) # ORIGINAL # e_voigt = 1.0*varepsilon_1*(AijUk(I,Ex)+AikUj(I,Ex)-UiAjk(Ex,I)).T e_voigt = 1.0 * varepsilon_1 * (einsum('ij,k', I, Ex) + einsum( 'ik,j', I, Ex) - einsum('i,jk', Ex, I)).T e_voigt = Voigt(np.ascontiguousarray(e_voigt), 1) # Dielectric Tensor (Permittivity - 2nd order) Permittivity = -varepsilon_1 * delta ## # bb = np.dot(StrainTensors.b,StrainTensors.b) # # Permittivity = -(2.0*varepsilon_1/detF)*bb # factor = -1. H1 = np.concatenate((C_Voigt, factor * e_voigt), axis=1) H2 = np.concatenate((factor * e_voigt.T, Permittivity), axis=1) H_Voigt = np.concatenate((H1, H2), axis=0) self.H_VoigtSize = H_Voigt.shape[0] # return H_Voigt, C, e, Permittivity return H_Voigt
# C = lamb2*AijBkl(I,I) +mu2*(AikBjl(I,I)+AilBjk(I,I)) + varepsilon_1*(AijBkl(I,EE) + AijBkl(EE,I) - \ # 2.*AikBjl(EE,I)-2.0*AilBjk(I,EE) ) + varepsilon_1*(np.dot(E.T,E)[0,0])*(AikBjl(I,I)-0.5*AijBkl(I,I)) # ORIGINAL # C = lamb2*AijBkl(I,I) +mu2*(AikBjl(I,I)+AilBjk(I,I)) +\ # varepsilon_1*(AijBkl(I,EE) + AijBkl(EE,I) -AikBjl(EE,I)-AilBjk(EE,I)-AilBjk(I,EE)-AikBjl(I,EE) ) +\ # varepsilon_1*(np.dot(E.T,E)[0,0])*(0.5*(AikBjl(I,I) + AilBjk(I,I))-0.5*AijBkl(I,I)) # C=0.5*(C+C.T) # C_Voigt = C C = lamb2*einsum("ij,kl",I,I) +mu2*(einsum("ik,jl",I,I)+einsum("il,jk",I,I)) +\ varepsilon_1*(einsum("ij,kl",I,EE) + einsum("ij,kl",EE,I) - einsum("ik,jl",EE,I)- einsum("il,jk",I,EE) -\ einsum("il,jl",I,EE)- einsum("ik,jl",I,EE) ) +\ <<<<<<< HEAD varepsilon_1*(np.dot(E.T,E)[0,0])*(0.5*( einsum("ik,jl",I,I)+einsum("il,jk",I,I) )-0.5* einsum("ij,kl",I,I) ) C_Voigt = Voigt(C,1) # Computing the hessian # Elasticity tensor (C - 4th order tensor) ======= varepsilon_1*(innerEE)*(0.5*( einsum("ik,jl",I,I)+einsum("il,jk",I,I) )-0.5* einsum("ij,kl",I,I) ) C_Voigt = Voigt(C,1) # Computing the hessian # Elasticity tensor (C - 4th order tensor) >>>>>>> upstream/master # C[i,j,k,l] += lamb2*delta[i,j]*delta[k,l]+2.0*mu2*(delta[i,k]*delta[j,l]) # b = StrainTensors['b'][gcounter]
def Hessian(self, StrainTensors, ElectricDisplacementx, elem=0, gcounter=0): mu = self.mu lamb = self.lamb d = self.ndim I = StrainTensors['I'] F = StrainTensors['F'][gcounter] J = StrainTensors['J'][gcounter] b = StrainTensors['b'][gcounter] det = np.linalg.det u, s, vh = svd(F, full_matrices=True) vh = vh.T # print(det(u),det(vh)) # exit() if self.ndim == 2: s1 = s[0] s2 = s[1] T = np.array([[0., -1], [1, 0.]]) s1s2 = s1 + s2 if (s1s2 < 2.0): s1s2 = 2.0 lamb = 2. / (s1s2) T = 1. / np.sqrt(2) * np.dot(u, np.dot(T, vh.T)) # C_Voigt = 1.0 * ( einsum("ik,jl",I,I)+einsum("il,jk",I,I) ) - 2. * lamb * np.einsum("ij,kl", T, T) # C_Voigt = 1./ J * np.einsum("kI,lJ,iIjJ->iklj", F, F, C_Voigt) C_Voigt = 2.0 * (einsum("ik,jl", I, I)) - 2. * lamb * np.einsum( "ij,kl", T, T) # C_Voigt = 2.0 * ( einsum("ij,kl",I,I)) - 2. * lamb * np.einsum("ij,kl", T, T) C_Voigt = 1. / J * np.einsum("jJ,iJkL,lL->ijkl", F, C_Voigt, F) # Exclude the stress term from this R = u.dot(vh.T) sigma = 2. * (F - R) sigma = 1. / J * np.dot(sigma, F.T) C_Voigt -= np.einsum("ij,kl", sigma, I) # print(C_Voigt) # print(np.linalg.norm(T.flatten())) # print(Voigt(np.einsum("ij,kl", T, T),1)) # print(np.einsum("ij,kl", T, T)) # exit() C_Voigt = np.ascontiguousarray(C_Voigt) elif self.ndim == 3: s1 = s[0] s2 = s[1] s3 = s[2] T1 = np.array([[0., 0., 0.], [0., 0., -1], [0., 1., 0.]]) T1 = 1. / np.sqrt(2) * np.dot(u, np.dot(T1, vh.T)) T2 = np.array([[0., 0., -1], [0., 0., 0.], [1., 0., 0.]]) T2 = 1. / np.sqrt(2) * np.dot(u, np.dot(T2, vh.T)) T3 = np.array([[0., -1, 0.], [1., 0., 0.], [0., 0., 0.]]) T3 = 1. / np.sqrt(2) * np.dot(u, np.dot(T3, vh.T)) s1s2 = s1 + s2 s1s3 = s1 + s3 s2s3 = s2 + s3 if (s1s2 < 2.0): s1s2 = 2.0 if (s1s3 < 2.0): s1s3 = 2.0 if (s2s3 < 2.0): s2s3 = 2.0 lamb1 = 2. / (s1s2) lamb2 = 2. / (s1s3) lamb3 = 2. / (s2s3) # C_Voigt = 1.0 * ( einsum("ik,jl",I,I)+einsum("il,jk",I,I) ) - 2. * lamb3 * np.einsum("ij,kl", T1, T1) - \ # - 2. * lamb2 * np.einsum("ij,kl", T2, T2) - 2. * lamb1 * np.einsum("ij,kl", T3, T3) # C_Voigt = 1./ J * np.einsum("kI,lJ,iIjJ->iklj", F, F, C_Voigt) # C_Voigt = np.ascontiguousarray(C_Voigt) C_Voigt = 2.0 * ( einsum("ik,jl",I,I)) - 2. * lamb3 * np.einsum("ij,kl", T1, T1) - \ - 2. * lamb2 * np.einsum("ij,kl", T2, T2) - 2. * lamb1 * np.einsum("ij,kl", T3, T3) C_Voigt = 1. / J * np.einsum("jJ,iJkL,lL->ijkl", F, C_Voigt, F) C_Voigt = np.ascontiguousarray(C_Voigt) R = u.dot(vh.T) sigma = 2. * (F - R) sigma = 1. / J * np.dot(sigma, F.T) C_Voigt -= np.einsum("ij,kl", sigma, I) # s1 = s[0] # s2 = s[1] # s3 = s[2] # T1 = np.array([[0.,-1.,0.],[1.,0.,0],[0.,0.,0.]]) # T1 = 1./np.sqrt(2) * np.dot(u, np.dot(T1, vh.T)) # T2 = np.array([[0.,0.,0.],[0.,0., 1],[0.,-1,0.]]) # T2 = 1./np.sqrt(2) * np.dot(u, np.dot(T2, vh.T)) # T3 = np.array([[0.,0.,1.],[0.,0.,0.],[-1,0.,0.]]) # T3 = 1./np.sqrt(2) * np.dot(u, np.dot(T3, vh.T)) # s1s2 = s1 + s2 # s1s3 = s1 + s3 # s2s3 = s2 + s3 # # if (s1s2 < 2.0): # # s1s2 = 2.0 # # if (s1s3 < 2.0): # # s1s3 = 2.0 # # if (s2s3 < 2.0): # # s2s3 = 2.0 # lamb1 = 2. / (s1s2) # lamb2 = 2. / (s1s3) # lamb3 = 2. / (s2s3) # # C_Voigt = 1.0 * ( einsum("ik,jl",I,I)+einsum("il,jk",I,I) ) - 2. * lamb1 * np.einsum("ij,kl", T1, T1) - \ # # - 2. * lamb3 * np.einsum("ij,kl", T2, T2) - 2. * lamb2 * np.einsum("ij,kl", T3, T3) # # C_Voigt = 1./ J * np.einsum("kI,lJ,iIjJ->iklj", F, F, C_Voigt) # # C_Voigt = np.ascontiguousarray(C_Voigt) # C_Voigt = 2.0 * ( einsum("ik,jl",I,I)) - 2. * lamb1 * np.einsum("ij,kl", T1, T1) - \ # - 2. * lamb3 * np.einsum("ij,kl", T2, T2) - 2. * lamb2 * np.einsum("ij,kl", T3, T3) # C_Voigt = 1./ J * np.einsum("kI,lJ,iIjJ->iklj", F, F, C_Voigt) # C_Voigt = np.ascontiguousarray(C_Voigt) # R = u.dot(vh.T) # sigma = 2. * (F - R) # sigma = 1./J * np.dot(sigma, F.T) # C_Voigt -= np.einsum("ij,kl",sigma,I) C_Voigt = Voigt(C_Voigt, 1) makezero(C_Voigt) # C_Voigt = np.eye(3,3)*2 # C_Voigt += 0.05*self.vIikIjl # print(C_Voigt) # s = svd(C_Voigt)[1] # print(s) return C_Voigt