英文:
population of elasticity tensor
问题
我试图创建一个用于填充张量的代码,该张量应该具有36个独立的分量和对称性 C[i,j,k,l] = C[j,i,k,l] = C[i,j,l,k]
。
我正在进行以下操作:
C = sym.MutableDenseNDimArray.zeros(3,3,3,3)
var = sym.symbols('C1:%d'%82)
ct = 0
for i in range(3):
for j in range(3):
for k in range(3):
for l in range(3):
if C[i,j,k,l] == 0:
C[i,j,k,l] = var[ct]
C[j,i,k,l] = var[ct]
C[i,j,l,k] = var[ct]
ct += 1
这给我提供了45个不同的条目。我做错了什么?
英文:
I am trying to create a code to populate a tensor with the symmetries of an elasticity tensor which should have 36 independent components and the symmetries C[i,j,k,l] = C[j,i,k,l] = C[i,j,l,k]
.
I am doing:
C = sym.MutableDenseNDimArray.zeros(3,3,3,3)
var = sym.symbols('C1:%d'%82)
ct = 0
for i in range(3):
for j in range(3):
for k in range(3):
for l in range(3):
if C[i,j,k,l] == 0:
C[i,j,k,l] = var[ct]
C[j,i,k,l] = var[ct]
C[i,j,l,k] = var[ct]
ct += 1
This is giving me 45 different entries. What am I doing wrong?
答案1
得分: 1
你似乎缺少对称性。如果你提到的两个对称性成立:
C[i,j,k,l] = C[j,i,k,l]
(对称性1)
C[i,j,k,l] = C[i,j,l,k]
(对称性2)
这意味着对每个元素都成立:
C[a,b,c,d] = C[b,a,c,d]
(对称性1)
C[b,a,c,d] = C[b,a,d,c]
(对称性2)
因此:
C[a,b,c,d] = C[b,a,d,c]
或
C[i,j,k,l] = C[j,i,l,k]
(隐含的对称性)
如果你在你的代码中包含这部分,你将得到:
C = sym.MutableDenseNDimArray.zeros(3,3,3,3)
var = sym.symbols('C1:%d' % 82)
ct = 0
for i in range(3):
for j in range(3):
for k in range(3):
for l in range(3):
if C[i,j,k,l] == 0:
C[i,j,k,l] = var[ct]
C[j,i,k,l] = var[ct]
C[i,j,l,k] = var[ct]
C[j,i,l,k] = var[ct]
ct += 1
这将给你36个不同的条目。
英文:
You seem to be missing a symmetry. If the 2 symmetries you mentioned:
C[i,j,k,l] = C[j,i,k,l]
(symmetry 1)
C[i,j,k,l] = C[i,j,l,k]
(symmetry 2)
hold for every element that means that:
C[a,b,c,d] = C[b,a,c,d]
(symmetry 1)
C[b,a,c,d] = C[b,a,d,c]
(symmetry 2)
and therefore:
C[a,b,c,d] = C[b,a,d,c]
or
C[i,j,k,l] = C[j,i,l,k]
(implied symmetry)
If you include that in your code you'll get:
C = sym.MutableDenseNDimArray.zeros(3,3,3,3)
var = sym.symbols('C1:%d'%82)
ct = 0
for i in range(3):
for j in range(3):
for k in range(3):
for l in range(3):
if C[i,j,k,l] == 0:
C[i,j,k,l] = var[ct]
C[j,i,k,l] = var[ct]
C[i,j,l,k] = var[ct]
C[j,i,l,k] = var[ct]
ct += 1
And that should give you 36 different entries.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论