From 23e4b1ffa35d006398e7e8016892a9cbef431280 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 4 Jan 2026 20:14:45 +0000 Subject: [PATCH 1/7] Initial plan From d596d20a132fc91c1adc3ef297f0e90df9a7ed43 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 4 Jan 2026 20:21:44 +0000 Subject: [PATCH 2/7] Fix strain convention to use proper Voigt notation with engineering strains MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified get_strain() to return engineering shear strains (2× tensor components) and updated all symmetry functions (regular, tetragonal, orthorombic, trigonal, hexagonal, monoclinic, triclinic) to accept Voigt notation without multiplying by 2. This resolves the inconsistency where manual elastic constant calculations would produce C44 values twice as large as expected. Co-authored-by: jochym <5993422+jochym@users.noreply.github.com> --- elastic/elastic.py | 114 +++++++++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 51 deletions(-) diff --git a/elastic/elastic.py b/elastic/elastic.py index 50087a2..71c49a1 100644 --- a/elastic/elastic.py +++ b/elastic/elastic.py @@ -28,9 +28,12 @@ Elastic is a module for calculation of :math:`C_{ij}` components of elastic tensor from the strain-stress relation. -The strain components here are ordered in standard way which is different -to ordering in previous versions of the code (up to 4.0). -The ordering is: :math:`u_{xx}, u_{yy}, u_{zz}, u_{yz}, u_{xz}, u_{xy}`. +The strain components here are in standard Voigt notation with engineering +shear strains (also known as the standard Voigt notation for strain). +The ordering is: :math:`\\epsilon_{1}, \\epsilon_{2}, \\epsilon_{3}, \\epsilon_{4}, \\epsilon_{5}, \\epsilon_{6}`, +corresponding to :math:`\\epsilon_{xx}, \\epsilon_{yy}, \\epsilon_{zz}, 2\\epsilon_{yz}, 2\\epsilon_{xz}, 2\\epsilon_{xy}`, +where the shear components (:math:`\\epsilon_{4}, \\epsilon_{5}, \\epsilon_{6}`) are engineering strains +(twice the corresponding tensor shear components). The general ordering of :math:`C_{ij}` components is (except for triclinic symmetry and taking into account customary names of constants - e.g. @@ -48,11 +51,6 @@ down as a quadratic form of the deformations with respect to elastic constant and deformation. -*Note:* -The elements for deformations :math:`u_{xy}, u_{xz}, u_{yz}` -have to be divided by 2 to properly match the usual definition -of elastic constants. - See: [LL]_ L.D. Landau, E.M. Lifszyc, "Theory of elasticity" There is some usefull summary also at: @@ -99,8 +97,9 @@ def regular(u): .. math:: C_{11}, C_{12}, C_{44} - :param u: vector of deformations: - [ :math:`u_{xx}, u_{yy}, u_{zz}, u_{yz}, u_{xz}, u_{xy}` ] + :param u: vector of deformations in Voigt notation: + [ :math:`\\epsilon_{1}, \\epsilon_{2}, \\epsilon_{3}, \\epsilon_{4}, \\epsilon_{5}, \\epsilon_{6}` ] + where shear strains are engineering strains (2× tensor components) :returns: Symmetry defined stress-strain equation matrix ''' @@ -109,9 +108,9 @@ def regular(u): [[uxx, uyy + uzz, 0], [uyy, uxx + uzz, 0], [uzz, uxx + uyy, 0], - [0, 0, 2*uyz], - [0, 0, 2*uxz], - [0, 0, 2*uxy]]) + [0, 0, uyz], + [0, 0, uxz], + [0, 0, uxy]]) def tetragonal(u): @@ -122,8 +121,9 @@ def tetragonal(u): .. math:: C_{11}, C_{33}, C_{12}, C_{13}, C_{44}, C_{66} - :param u: vector of deformations: - [ :math:`u_{xx}, u_{yy}, u_{zz}, u_{yz}, u_{xz}, u_{xy}` ] + :param u: vector of deformations in Voigt notation: + [ :math:`\\epsilon_{1}, \\epsilon_{2}, \\epsilon_{3}, \\epsilon_{4}, \\epsilon_{5}, \\epsilon_{6}` ] + where shear strains are engineering strains (2× tensor components) :returns: Symmetry defined stress-strain equation matrix ''' @@ -133,9 +133,9 @@ def tetragonal(u): [[uxx, 0, uyy, uzz, 0, 0], [uyy, 0, uxx, uzz, 0, 0], [0, uzz, 0, uxx+uyy, 0, 0], - [0, 0, 0, 0, 2*uxz, 0], - [0, 0, 0, 0, 2*uyz, 0], - [0, 0, 0, 0, 0, 2*uxy]]) + [0, 0, 0, 0, uxz, 0], + [0, 0, 0, 0, uyz, 0], + [0, 0, 0, 0, 0, uxy]]) def orthorombic(u): @@ -147,8 +147,9 @@ def orthorombic(u): C_{11}, C_{22}, C_{33}, C_{12}, C_{13}, C_{23}, C_{44}, C_{55}, C_{66} - :param u: vector of deformations: - [ :math:`u_{xx}, u_{yy}, u_{zz}, u_{yz}, u_{xz}, u_{xy}` ] + :param u: vector of deformations in Voigt notation: + [ :math:`\\epsilon_{1}, \\epsilon_{2}, \\epsilon_{3}, \\epsilon_{4}, \\epsilon_{5}, \\epsilon_{6}` ] + where shear strains are engineering strains (2× tensor components) :returns: Symmetry defined stress-strain equation matrix ''' @@ -158,9 +159,9 @@ def orthorombic(u): [[uxx, 0, 0, uyy, uzz, 0, 0, 0, 0], [0, uyy, 0, uxx, 0, uzz, 0, 0, 0], [0, 0, uzz, 0, uxx, uyy, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 2*uyz, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 2*uxz, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 2*uxy]]) + [0, 0, 0, 0, 0, 0, uyz, 0, 0], + [0, 0, 0, 0, 0, 0, 0, uxz, 0], + [0, 0, 0, 0, 0, 0, 0, 0, uxy]]) def trigonal(u): @@ -174,8 +175,9 @@ def trigonal(u): .. math:: C_{11}, C_{33}, C_{12}, C_{13}, C_{44}, C_{14} - :param u: vector of deformations: - [ :math:`u_{xx}, u_{yy}, u_{zz}, u_{yz}, u_{xz}, u_{xy}` ] + :param u: vector of deformations in Voigt notation: + [ :math:`\\epsilon_{1}, \\epsilon_{2}, \\epsilon_{3}, \\epsilon_{4}, \\epsilon_{5}, \\epsilon_{6}` ] + where shear strains are engineering strains (2× tensor components) :returns: Symmetry defined stress-strain equation matrix ''' @@ -184,12 +186,12 @@ def trigonal(u): # TODO: There is still some doubt about the :math:`C_{14}` constant. uxx, uyy, uzz, uyz, uxz, uxy = u[0], u[1], u[2], u[3], u[4], u[5] return array( - [[ uxx, 0, uyy, uzz, 0, 2*uxz ], - [ uyy, 0, uxx, uzz, 0, -2*uxz ], + [[ uxx, 0, uyy, uzz, 0, uxz ], + [ uyy, 0, uxx, uzz, 0, -uxz ], [ 0, uzz, 0, uxx+uyy, 0, 0 ], - [ 0, 0, 0, 0, 2*uyz, -4*uxy ], - [ 0, 0, 0, 0, 2*uxz, 2*(uxx-uyy)], - [ 2*uxy, 0, -2*uxy, 0, 0, -4*uyz ]]) + [ 0, 0, 0, 0, uyz, -2*uxy ], + [ 0, 0, 0, 0, uxz, (uxx-uyy) ], + [ uxy, 0, -uxy, 0, 0, -2*uyz ]]) def hexagonal(u): @@ -203,8 +205,9 @@ def hexagonal(u): .. math:: C_{11}, C_{33}, C_{12}, C_{13}, C_{44} - :param u: vector of deformations: - [ :math:`u_{xx}, u_{yy}, u_{zz}, u_{yz}, u_{xz}, u_{xy}` ] + :param u: vector of deformations in Voigt notation: + [ :math:`\\epsilon_{1}, \\epsilon_{2}, \\epsilon_{3}, \\epsilon_{4}, \\epsilon_{5}, \\epsilon_{6}` ] + where shear strains are engineering strains (2× tensor components) :returns: Symmetry defined stress-strain equation matrix ''' @@ -215,8 +218,8 @@ def hexagonal(u): [[ uxx, 0, uyy, uzz, 0 ], [ uyy, 0, uxx, uzz, 0 ], [ 0, uzz, 0, uxx+uyy, 0 ], - [ 0, 0, 0, 0, 2*uyz ], - [ 0, 0, 0, 0, 2*uxz ], + [ 0, 0, 0, 0, uyz ], + [ 0, 0, 0, 0, uxz ], [ uxy, 0, -uxy, 0, 0 ]]) @@ -229,20 +232,21 @@ def monoclinic(u): C_{11}, C_{22}, C_{33}, C_{12}, C_{13}, C_{23}, C_{44}, C_{55}, C_{66}, C_{16}, C_{26}, C_{36}, C_{45} - :param u: vector of deformations: - [ :math:`u_{xx}, u_{yy}, u_{zz}, u_{yz}, u_{xz}, u_{xy}` ] + :param u: vector of deformations in Voigt notation: + [ :math:`\\epsilon_{1}, \\epsilon_{2}, \\epsilon_{3}, \\epsilon_{4}, \\epsilon_{5}, \\epsilon_{6}` ] + where shear strains are engineering strains (2× tensor components) :returns: Symmetry defined stress-strain equation matrix ''' uxx, uyy, uzz, uyz, uxz, uxy = u[0], u[1], u[2], u[3], u[4], u[5] return array( - [[uxx, 0, 0,uyy,uzz, 0, 0, 0, 0,uxy, 0, 0, 0], - [ 0,uyy, 0,uxx, 0,uzz, 0, 0, 0, 0,uxy, 0, 0], - [ 0, 0,uzz, 0,uxx,uyy, 0, 0, 0, 0, 0,uxy, 0], - [ 0, 0, 0, 0, 0, 0,2*uyz, 0, 0, 0, 0, 0,uxz], - [ 0, 0, 0, 0, 0, 0, 0,2*uxz, 0, 0, 0, 0,uyz], - [ 0, 0, 0, 0, 0, 0, 0, 0,2*uxy,uxx,uyy,uzz, 0]]) + [[uxx, 0, 0,uyy,uzz, 0, 0, 0, 0,uxy, 0, 0, 0 ], + [ 0,uyy, 0,uxx, 0,uzz, 0, 0, 0, 0,uxy, 0, 0 ], + [ 0, 0,uzz, 0,uxx,uyy, 0, 0, 0, 0, 0,uxy, 0 ], + [ 0, 0, 0, 0, 0, 0, uyz, 0, 0, 0, 0, 0, uxz/2.0], + [ 0, 0, 0, 0, 0, 0, 0, uxz, 0, 0, 0, 0, uyz/2.0], + [ 0, 0, 0, 0, 0, 0, 0, 0, uxy,uxx,uyy,uzz, 0 ]]) def triclinic(u): @@ -259,8 +263,9 @@ def triclinic(u): C_{16}, C_{26}, C_{36}, C_{46}, C_{56}, C_{14}, C_{15}, C_{25}, C_{45} - :param u: vector of deformations: - [ :math:`u_{xx}, u_{yy}, u_{zz}, u_{yz}, u_{xz}, u_{xy}` ] + :param u: vector of deformations in Voigt notation: + [ :math:`\\epsilon_{1}, \\epsilon_{2}, \\epsilon_{3}, \\epsilon_{4}, \\epsilon_{5}, \\epsilon_{6}` ] + where shear strains are engineering strains (2× tensor components) :returns: Symmetry defined stress-strain equation matrix ''' @@ -269,12 +274,12 @@ def triclinic(u): # If you have test cases for this symmetry send them to the author. uxx, uyy, uzz, uyz, uxz, uxy = u[0], u[1], u[2], u[3], u[4], u[5] return array( - [[uxx, 0, 0,uyy,uzz, 0, 0, 0, 0,uxy, 0, 0, 0, 0,uyz,uxz, 0, 0], - [ 0,uyy, 0,uxx, 0,uzz, 0, 0, 0, 0,uxy, 0, 0, 0, 0, 0,uxz, 0], - [ 0, 0,uzz, 0,uxx,uyy, 0, 0, 0, 0, 0,uxy, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0,2*uyz, 0, 0, 0, 0, 0,uxy, 0,uxx, 0, 0,uxz], - [ 0, 0, 0, 0, 0, 0, 0,2*uxz, 0, 0, 0, 0, 0,uxy, 0,uxx,uyy,uyz], - [ 0, 0, 0, 0, 0, 0, 0, 0,2*uxy,uxx,uyy,uzz,uyz,uxz, 0, 0, 0, 0]]) + [[uxx, 0, 0,uyy,uzz, 0, 0, 0, 0,uxy, 0, 0, 0, 0, uyz/2.0,uxz/2.0, 0, 0 ], + [ 0,uyy, 0,uxx, 0,uzz, 0, 0, 0, 0,uxy, 0, 0, 0, 0, 0,uxz/2.0, 0 ], + [ 0, 0,uzz, 0,uxx,uyy, 0, 0, 0, 0, 0,uxy, 0, 0, 0, 0, 0, 0 ], + [ 0, 0, 0, 0, 0, 0, uyz, 0, 0, 0, 0, 0,uxy/2.0, 0, uxx, 0, 0,uxz/2.0], + [ 0, 0, 0, 0, 0, 0, 0, uxz, 0, 0, 0, 0, 0,uxy/2.0, 0, uxx, uyy,uyz/2.0], + [ 0, 0, 0, 0, 0, 0, 0, 0, uxy,uxx,uyy,uzz,uyz/2.0,uxz/2.0, 0, 0, 0, 0 ]]) def get_cij_order(cryst): @@ -705,11 +710,17 @@ def get_strain(cryst, refcell=None): Computes the strain tensor in the Voight notation as a conventional 6-vector. The calculation is done with respect to the crystal geometry passed in refcell parameter. + + The shear strain components (ε₄, ε₅, ε₆) are returned as engineering + strains, which are twice the corresponding tensor shear components: + ε₄ = 2ε₂₃, ε₅ = 2ε₁₃, ε₆ = 2ε₁₂. This is the standard Voigt notation + convention for strain used in elasticity theory. :param cryst: deformed structure :param refcell: reference, undeformed structure :returns: 6-vector of strain tensor in the Voight notation + [ε₁, ε₂, ε₃, ε₄, ε₅, ε₆] = [ε₁₁, ε₂₂, ε₃₃, 2ε₂₃, 2ε₁₃, 2ε₁₂] ''' if refcell is None: refcell = cryst @@ -718,7 +729,8 @@ def get_strain(cryst, refcell=None): m = inv(m) u = dot(m, du) u = (u+u.T)/2 - return array([u[0, 0], u[1, 1], u[2, 2], u[2, 1], u[2, 0], u[1, 0]]) + # Return Voigt notation: [ε₁₁, ε₂₂, ε₃₃, 2ε₂₃, 2ε₁₃, 2ε₁₂] + return array([u[0, 0], u[1, 1], u[2, 2], 2*u[2, 1], 2*u[2, 0], 2*u[1, 0]]) if __name__ == '__main__': From 0875a5459df9f37339d28092babe22004c011592 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 4 Jan 2026 20:23:08 +0000 Subject: [PATCH 3/7] Update documentation to clarify Voigt notation convention for strains Added a note to explain that the mathematical formulation in the documentation uses tensor components while the code returns engineering strains in proper Voigt notation. Both formulations are equivalent. Co-authored-by: jochym <5993422+jochym@users.noreply.github.com> --- docs/source/intro.rst | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/source/intro.rst b/docs/source/intro.rst index 50e0efd..64a1160 100644 --- a/docs/source/intro.rst +++ b/docs/source/intro.rst @@ -159,8 +159,18 @@ symmetry relations and strains :math:`s_{j}^{a}` create a new equation matrix :math:`S`. :math:`S_{ju}(s^{a})C_{u}=\sigma_{j}^{a}`. The :math:`S(s)` matrix is a linear function of the strain vector s with all symmetry relations taken into account. The index a runs over all data sets we have in the calculation while -index u runs over all independent components of the :math:`C_{ij}` matrix. For -the cubic crystal the above equation takes explicit form: +index u runs over all independent components of the :math:`C_{ij}` matrix. + +.. note:: + In the mathematical formulation below, the strain vector :math:`s` uses + tensor components (i.e., :math:`s_4 = \epsilon_{23}`) and the factor of 2 appears + explicitly in the matrices. However, the Elastic module's :python:`get_strain()` + function returns strains in standard Voigt notation with engineering shear strains + (i.e., :math:`\epsilon_4 = 2\epsilon_{23}`), and the symmetry functions account + for this convention. Both formulations are mathematically equivalent and yield + identical elastic constants. + +For the cubic crystal the above equation takes explicit form: .. math:: \left[\begin{array}{ccc} From 6afb604c33c3ed32105583b5a1d112a3e21918c7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 4 Jan 2026 20:25:54 +0000 Subject: [PATCH 4/7] Fix monoclinic and triclinic coupling terms Corrected the monoclinic and triclinic symmetry functions to properly handle coupling terms without introducing an extra factor of 1/2. The coupling terms should remain unchanged when converting from tensor to Voigt notation. Co-authored-by: jochym <5993422+jochym@users.noreply.github.com> --- elastic/elastic.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/elastic/elastic.py b/elastic/elastic.py index 71c49a1..8a6e293 100644 --- a/elastic/elastic.py +++ b/elastic/elastic.py @@ -241,12 +241,12 @@ def monoclinic(u): uxx, uyy, uzz, uyz, uxz, uxy = u[0], u[1], u[2], u[3], u[4], u[5] return array( - [[uxx, 0, 0,uyy,uzz, 0, 0, 0, 0,uxy, 0, 0, 0 ], - [ 0,uyy, 0,uxx, 0,uzz, 0, 0, 0, 0,uxy, 0, 0 ], - [ 0, 0,uzz, 0,uxx,uyy, 0, 0, 0, 0, 0,uxy, 0 ], - [ 0, 0, 0, 0, 0, 0, uyz, 0, 0, 0, 0, 0, uxz/2.0], - [ 0, 0, 0, 0, 0, 0, 0, uxz, 0, 0, 0, 0, uyz/2.0], - [ 0, 0, 0, 0, 0, 0, 0, 0, uxy,uxx,uyy,uzz, 0 ]]) + [[uxx, 0, 0,uyy,uzz, 0, 0, 0, 0,uxy, 0, 0, 0 ], + [ 0,uyy, 0,uxx, 0,uzz, 0, 0, 0, 0,uxy, 0, 0 ], + [ 0, 0,uzz, 0,uxx,uyy, 0, 0, 0, 0, 0,uxy, 0 ], + [ 0, 0, 0, 0, 0, 0, uyz, 0, 0, 0, 0, 0,uxz ], + [ 0, 0, 0, 0, 0, 0, 0, uxz, 0, 0, 0, 0,uyz ], + [ 0, 0, 0, 0, 0, 0, 0, 0, uxy,uxx,uyy,uzz, 0 ]]) def triclinic(u): @@ -274,12 +274,12 @@ def triclinic(u): # If you have test cases for this symmetry send them to the author. uxx, uyy, uzz, uyz, uxz, uxy = u[0], u[1], u[2], u[3], u[4], u[5] return array( - [[uxx, 0, 0,uyy,uzz, 0, 0, 0, 0,uxy, 0, 0, 0, 0, uyz/2.0,uxz/2.0, 0, 0 ], - [ 0,uyy, 0,uxx, 0,uzz, 0, 0, 0, 0,uxy, 0, 0, 0, 0, 0,uxz/2.0, 0 ], - [ 0, 0,uzz, 0,uxx,uyy, 0, 0, 0, 0, 0,uxy, 0, 0, 0, 0, 0, 0 ], - [ 0, 0, 0, 0, 0, 0, uyz, 0, 0, 0, 0, 0,uxy/2.0, 0, uxx, 0, 0,uxz/2.0], - [ 0, 0, 0, 0, 0, 0, 0, uxz, 0, 0, 0, 0, 0,uxy/2.0, 0, uxx, uyy,uyz/2.0], - [ 0, 0, 0, 0, 0, 0, 0, 0, uxy,uxx,uyy,uzz,uyz/2.0,uxz/2.0, 0, 0, 0, 0 ]]) + [[uxx, 0, 0,uyy,uzz, 0, 0, 0, 0,uxy, 0, 0, 0, 0,uyz,uxz, 0, 0], + [ 0,uyy, 0,uxx, 0,uzz, 0, 0, 0, 0,uxy, 0, 0, 0, 0, 0,uxz, 0], + [ 0, 0,uzz, 0,uxx,uyy, 0, 0, 0, 0, 0,uxy, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, uyz, 0, 0, 0, 0, 0,uxy, 0,uxx, 0, 0,uxz], + [ 0, 0, 0, 0, 0, 0, 0, uxz, 0, 0, 0, 0, 0,uxy, 0,uxx,uyy,uyz], + [ 0, 0, 0, 0, 0, 0, 0, 0, uxy,uxx,uyy,uzz,uyz,uxz, 0, 0, 0, 0]]) def get_cij_order(cryst): From d2ccd997c1a465eff70bc898d78b4f3197a2083d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 4 Jan 2026 20:27:34 +0000 Subject: [PATCH 5/7] Fix RST syntax and add clarification about trigonal symmetry Fixed RST syntax in documentation (removed :python: directive) and added explanatory comment in trigonal function about why some factors of 2 remain due to crystallographic symmetry relationships. Co-authored-by: jochym <5993422+jochym@users.noreply.github.com> --- docs/source/intro.rst | 2 +- elastic/elastic.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/source/intro.rst b/docs/source/intro.rst index 64a1160..60e1631 100644 --- a/docs/source/intro.rst +++ b/docs/source/intro.rst @@ -164,7 +164,7 @@ index u runs over all independent components of the :math:`C_{ij}` matrix. .. note:: In the mathematical formulation below, the strain vector :math:`s` uses tensor components (i.e., :math:`s_4 = \epsilon_{23}`) and the factor of 2 appears - explicitly in the matrices. However, the Elastic module's :python:`get_strain()` + explicitly in the matrices. However, the Elastic module's ``get_strain()`` function returns strains in standard Voigt notation with engineering shear strains (i.e., :math:`\epsilon_4 = 2\epsilon_{23}`), and the symmetry functions account for this convention. Both formulations are mathematically equivalent and yield diff --git a/elastic/elastic.py b/elastic/elastic.py index 8a6e293..edeeec8 100644 --- a/elastic/elastic.py +++ b/elastic/elastic.py @@ -184,6 +184,9 @@ def trigonal(u): # TODO: Not tested yet. # TODO: There is still some doubt about the :math:`C_{14}` constant. + # Note: Some coupling terms retain factors of 2 due to trigonal symmetry + # relationships, not due to Voigt notation. These are part of the + # crystallographic symmetry and are distinct from the engineering strain factors. uxx, uyy, uzz, uyz, uxz, uxy = u[0], u[1], u[2], u[3], u[4], u[5] return array( [[ uxx, 0, uyy, uzz, 0, uxz ], From 339a1be142940a6589d8a3d12da2f8ad2c44a9fe Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 04:37:44 +0000 Subject: [PATCH 6/7] Rename variables to use Voigt notation consistently throughout symmetry functions Changed variable names from tensor notation (uxx, uyy, uzz, uyz, uxz, uxy) to Voigt notation (e1, e2, e3, e4, e5, e6) in all symmetry functions: regular(), tetragonal(), orthorombic(), trigonal(), hexagonal(), monoclinic(), triclinic(). This makes the code completely consistent with Voigt notation convention. Co-authored-by: jochym <5993422+jochym@users.noreply.github.com> --- elastic/elastic.py | 98 +++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/elastic/elastic.py b/elastic/elastic.py index edeeec8..3d51f8f 100644 --- a/elastic/elastic.py +++ b/elastic/elastic.py @@ -103,14 +103,14 @@ def regular(u): :returns: Symmetry defined stress-strain equation matrix ''' - uxx, uyy, uzz, uyz, uxz, uxy = u[0], u[1], u[2], u[3], u[4], u[5] + e1, e2, e3, e4, e5, e6 = u[0], u[1], u[2], u[3], u[4], u[5] return array( - [[uxx, uyy + uzz, 0], - [uyy, uxx + uzz, 0], - [uzz, uxx + uyy, 0], - [0, 0, uyz], - [0, 0, uxz], - [0, 0, uxy]]) + [[e1, e2 + e3, 0], + [e2, e1 + e3, 0], + [e3, e1 + e2, 0], + [0, 0, e4], + [0, 0, e5], + [0, 0, e6]]) def tetragonal(u): @@ -128,14 +128,14 @@ def tetragonal(u): :returns: Symmetry defined stress-strain equation matrix ''' - uxx, uyy, uzz, uyz, uxz, uxy = u[0], u[1], u[2], u[3], u[4], u[5] + e1, e2, e3, e4, e5, e6 = u[0], u[1], u[2], u[3], u[4], u[5] return array( - [[uxx, 0, uyy, uzz, 0, 0], - [uyy, 0, uxx, uzz, 0, 0], - [0, uzz, 0, uxx+uyy, 0, 0], - [0, 0, 0, 0, uxz, 0], - [0, 0, 0, 0, uyz, 0], - [0, 0, 0, 0, 0, uxy]]) + [[e1, 0, e2, e3, 0, 0], + [e2, 0, e1, e3, 0, 0], + [0, e3, 0, e1+e2, 0, 0], + [0, 0, 0, 0, e5, 0], + [0, 0, 0, 0, e4, 0], + [0, 0, 0, 0, 0, e6]]) def orthorombic(u): @@ -154,14 +154,14 @@ def orthorombic(u): :returns: Symmetry defined stress-strain equation matrix ''' - uxx, uyy, uzz, uyz, uxz, uxy = u[0], u[1], u[2], u[3], u[4], u[5] + e1, e2, e3, e4, e5, e6 = u[0], u[1], u[2], u[3], u[4], u[5] return array( - [[uxx, 0, 0, uyy, uzz, 0, 0, 0, 0], - [0, uyy, 0, uxx, 0, uzz, 0, 0, 0], - [0, 0, uzz, 0, uxx, uyy, 0, 0, 0], - [0, 0, 0, 0, 0, 0, uyz, 0, 0], - [0, 0, 0, 0, 0, 0, 0, uxz, 0], - [0, 0, 0, 0, 0, 0, 0, 0, uxy]]) + [[e1, 0, 0, e2, e3, 0, 0, 0, 0], + [0, e2, 0, e1, 0, e3, 0, 0, 0], + [0, 0, e3, 0, e1, e2, 0, 0, 0], + [0, 0, 0, 0, 0, 0, e4, 0, 0], + [0, 0, 0, 0, 0, 0, 0, e5, 0], + [0, 0, 0, 0, 0, 0, 0, 0, e6]]) def trigonal(u): @@ -187,14 +187,14 @@ def trigonal(u): # Note: Some coupling terms retain factors of 2 due to trigonal symmetry # relationships, not due to Voigt notation. These are part of the # crystallographic symmetry and are distinct from the engineering strain factors. - uxx, uyy, uzz, uyz, uxz, uxy = u[0], u[1], u[2], u[3], u[4], u[5] + e1, e2, e3, e4, e5, e6 = u[0], u[1], u[2], u[3], u[4], u[5] return array( - [[ uxx, 0, uyy, uzz, 0, uxz ], - [ uyy, 0, uxx, uzz, 0, -uxz ], - [ 0, uzz, 0, uxx+uyy, 0, 0 ], - [ 0, 0, 0, 0, uyz, -2*uxy ], - [ 0, 0, 0, 0, uxz, (uxx-uyy) ], - [ uxy, 0, -uxy, 0, 0, -2*uyz ]]) + [[ e1, 0, e2, e3, 0, e5 ], + [ e2, 0, e1, e3, 0, -e5 ], + [ 0, e3, 0, e1+e2, 0, 0 ], + [ 0, 0, 0, 0, e4, -2*e6 ], + [ 0, 0, 0, 0, e5, (e1-e2) ], + [ e6, 0, -e6, 0, 0, -2*e4 ]]) def hexagonal(u): @@ -216,14 +216,14 @@ def hexagonal(u): ''' # TODO: Still needs good verification - uxx, uyy, uzz, uyz, uxz, uxy = u[0], u[1], u[2], u[3], u[4], u[5] + e1, e2, e3, e4, e5, e6 = u[0], u[1], u[2], u[3], u[4], u[5] return array( - [[ uxx, 0, uyy, uzz, 0 ], - [ uyy, 0, uxx, uzz, 0 ], - [ 0, uzz, 0, uxx+uyy, 0 ], - [ 0, 0, 0, 0, uyz ], - [ 0, 0, 0, 0, uxz ], - [ uxy, 0, -uxy, 0, 0 ]]) + [[ e1, 0, e2, e3, 0 ], + [ e2, 0, e1, e3, 0 ], + [ 0, e3, 0, e1+e2, 0 ], + [ 0, 0, 0, 0, e4 ], + [ 0, 0, 0, 0, e5 ], + [ e6, 0, -e6, 0, 0 ]]) def monoclinic(u): @@ -242,14 +242,14 @@ def monoclinic(u): :returns: Symmetry defined stress-strain equation matrix ''' - uxx, uyy, uzz, uyz, uxz, uxy = u[0], u[1], u[2], u[3], u[4], u[5] + e1, e2, e3, e4, e5, e6 = u[0], u[1], u[2], u[3], u[4], u[5] return array( - [[uxx, 0, 0,uyy,uzz, 0, 0, 0, 0,uxy, 0, 0, 0 ], - [ 0,uyy, 0,uxx, 0,uzz, 0, 0, 0, 0,uxy, 0, 0 ], - [ 0, 0,uzz, 0,uxx,uyy, 0, 0, 0, 0, 0,uxy, 0 ], - [ 0, 0, 0, 0, 0, 0, uyz, 0, 0, 0, 0, 0,uxz ], - [ 0, 0, 0, 0, 0, 0, 0, uxz, 0, 0, 0, 0,uyz ], - [ 0, 0, 0, 0, 0, 0, 0, 0, uxy,uxx,uyy,uzz, 0 ]]) + [[e1, 0, 0,e2,e3, 0, 0, 0, 0,e6, 0, 0, 0 ], + [ 0,e2, 0,e1, 0,e3, 0, 0, 0, 0,e6, 0, 0 ], + [ 0, 0,e3, 0,e1,e2, 0, 0, 0, 0, 0,e6, 0 ], + [ 0, 0, 0, 0, 0, 0, e4, 0, 0, 0, 0, 0,e5 ], + [ 0, 0, 0, 0, 0, 0, 0, e5, 0, 0, 0, 0,e4 ], + [ 0, 0, 0, 0, 0, 0, 0, 0, e6,e1,e2,e3, 0 ]]) def triclinic(u): @@ -275,14 +275,14 @@ def triclinic(u): # Based on the monoclinic matrix and not tested on real case. # If you have test cases for this symmetry send them to the author. - uxx, uyy, uzz, uyz, uxz, uxy = u[0], u[1], u[2], u[3], u[4], u[5] + e1, e2, e3, e4, e5, e6 = u[0], u[1], u[2], u[3], u[4], u[5] return array( - [[uxx, 0, 0,uyy,uzz, 0, 0, 0, 0,uxy, 0, 0, 0, 0,uyz,uxz, 0, 0], - [ 0,uyy, 0,uxx, 0,uzz, 0, 0, 0, 0,uxy, 0, 0, 0, 0, 0,uxz, 0], - [ 0, 0,uzz, 0,uxx,uyy, 0, 0, 0, 0, 0,uxy, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, uyz, 0, 0, 0, 0, 0,uxy, 0,uxx, 0, 0,uxz], - [ 0, 0, 0, 0, 0, 0, 0, uxz, 0, 0, 0, 0, 0,uxy, 0,uxx,uyy,uyz], - [ 0, 0, 0, 0, 0, 0, 0, 0, uxy,uxx,uyy,uzz,uyz,uxz, 0, 0, 0, 0]]) + [[e1, 0, 0,e2,e3, 0, 0, 0, 0,e6, 0, 0, 0, 0,e4,e5, 0, 0], + [ 0,e2, 0,e1, 0,e3, 0, 0, 0, 0,e6, 0, 0, 0, 0, 0,e5, 0], + [ 0, 0,e3, 0,e1,e2, 0, 0, 0, 0, 0,e6, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, e4, 0, 0, 0, 0, 0,e6, 0,e1, 0, 0,e5], + [ 0, 0, 0, 0, 0, 0, 0, e5, 0, 0, 0, 0, 0,e6, 0,e1,e2,e4], + [ 0, 0, 0, 0, 0, 0, 0, 0, e6,e1,e2,e3,e4,e5, 0, 0, 0, 0]]) def get_cij_order(cryst): From 47b4aed40b3d274dd65dcba89f3f022329d5b1e4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 04:40:33 +0000 Subject: [PATCH 7/7] Fix tetragonal symmetry function: correct e4/e5 ordering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed a bug in the tetragonal function where e4 and e5 were swapped in rows 4 and 5. The correct mapping is: row 4 (σ4/σyz) uses e4 (εyz), row 5 (σ5/σxz) uses e5 (εxz). This bug existed in the original code and was accidentally preserved during variable renaming. Co-authored-by: jochym <5993422+jochym@users.noreply.github.com> --- elastic/elastic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elastic/elastic.py b/elastic/elastic.py index 3d51f8f..f5aaafd 100644 --- a/elastic/elastic.py +++ b/elastic/elastic.py @@ -133,8 +133,8 @@ def tetragonal(u): [[e1, 0, e2, e3, 0, 0], [e2, 0, e1, e3, 0, 0], [0, e3, 0, e1+e2, 0, 0], - [0, 0, 0, 0, e5, 0], [0, 0, 0, 0, e4, 0], + [0, 0, 0, 0, e5, 0], [0, 0, 0, 0, 0, e6]])